Mark Wielaard a1fa6696f5 Add support for DWARF5 as produced by GCC11
Implement DWARF5 in readdwarf.c and readdwarf3.c

Since gcc11 will default to DWARF5 by default it is time for
valgrind to support it. The patch handles everything gcc11 produces
(except for the new DWARF expressions).

There is some duplication in the patch since we actually have two DWARF
readers which use slightly different abstractions (Slices vs Cursors).
It would be nice if we could merge these somehow. The reader in
readdwarf3.c is only used when --read-var-info=yes is used (which
drd uses to provide the allocation context).

The handling of DW_FORM_implicit_const is tricky with the current design.
An abbrev which contains an attribute encoded with DW_FORM_implicit_const
has its value also in the abbrev. The code in readdwarf3.c assumed it
always could simply get the data from the .debug_info/current Cursor.
For now I added a value field to the name_form field that holds the
associated value. This is slightly wasteful since the extra field is
not necessary for other forms.

Tested against GCC10 (defaulting to DWARF4) and GCC11 (defaulting to
DWARF5) on x86_64. No regressions in the regtests.

https://bugs.kde.org/show_bug.cgi?id=432102
2021-01-27 13:15:53 +01:00

78 lines
2.6 KiB
C

/*--------------------------------------------------------------------*/
/*--- Read DWARF1/2/3 debug info. priv_readdwarf.h ---*/
/*--------------------------------------------------------------------*/
/*
This file is part of Valgrind, a dynamic binary instrumentation
framework.
Copyright (C) 2000-2017 Julian Seward
jseward@acm.org
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
The GNU General Public License is contained in the file COPYING.
*/
#ifndef __PRIV_READDWARF_H
#define __PRIV_READDWARF_H
#include "pub_core_debuginfo.h" // DebugInfo
#include "priv_image.h" // DiSlice
/*
Stabs reader greatly improved by Nick Nethercote, Apr 02.
This module was also extensively hacked on by Jeremy Fitzhardinge
and Tom Hughes.
*/
/* --------------------
DWARF3 reader
-------------------- */
extern
void ML_(read_debuginfo_dwarf3)
( DebugInfo* di,
DiSlice escn_debug_info, /* .debug_info */
DiSlice escn_debug_types, /* .debug_types */
DiSlice escn_debug_abbv, /* .debug_abbrev */
DiSlice escn_debug_line, /* .debug_line */
DiSlice escn_debug_str, /* .debug_str */
DiSlice escn_debug_str_alt, /* .debug_str */
DiSlice escn_debug_line_str );/* .debug_line_str */
/* --------------------
DWARF1 reader
-------------------- */
extern
void ML_(read_debuginfo_dwarf1) ( DebugInfo* di,
UChar* dwarf1d, Int dwarf1d_sz,
UChar* dwarf1l, Int dwarf1l_sz );
/* --------------------
CFI reader
-------------------- */
extern
void ML_(read_callframe_info_dwarf3)
( /*OUT*/ DebugInfo* di,
DiSlice escn_frame, Addr frame_avma, Bool is_ehframe );
#endif /* ndef __PRIV_READDWARF_H */
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/