binutils-gdb/gdb/dwarf2
nitachra 048fde1ef4 DWARFv5: Handle DW_MACRO_define_strx and DW_MACRO_undef_strx macro entries.
GDB complaints "During symbol reading: unrecognized DW_MACFINO
opcode 0xb" with the testcase given below. Clang is emitting
DW_MACRO_define_strx and DW_MACRO_undef_strx entries in .debug_macro
section which are not supported in GDB. This patch handles them.

DW_MACRO_define_strx and DW_MACRO_undef_strx are added in DWARFv5.
They have two operands. The first operand encodes the line number of
the #define or #undef macro directive. The second operand identifies
a string; it is represented using an unsigned LEB128 encoded value,
which is interpreted as a zero-based index into an array of offsets
in the .debug_str_offsets section. This is as per the section 6.3.2.1
of Dwarf Debugging Information Format Version 5.

Test case used:
 #define MAX_SIZE 10
int main(void)
{
   int size = 0;
   size = size + MAX_SIZE;

   printf("\n The value of size is [%d]\n",size);

   return 0;
}

clang -gdwarf-5 -fdebug-macro  macro.c -o macro.out

Before the patch:

gdb/new_gdb/binutils-gdb/build/bin/gdb -q macro.out -ex "set complaints 1" -ex "start"
Reading symbols from macro.out...
During symbol reading: unrecognized DW_MACFINO opcode 0xb
Temporary breakpoint 1 at 0x4004df: file macro.c, line 7.
Starting program: /home/nitika/workspace/macro.out

Temporary breakpoint 1, main () at macro.c:7
7          int size = 0;
(gdb)

Tested by running the testsuite before and after the patch with
 -gdwarf-5 and there is no increase in the number of test cases
that fails. Used clang 11.0.0.

gdb/ChangeLog:

	* dwarf2/macro.c (dwarf_decode_macro_bytes): Handle DW_MACRO_define_strx
	and DW_MACRO_undef_strx.
	(dwarf_decode_macros): Likewise
	* dwarf2/read.c (dwarf_decode_macros): Pass str_offsets_base in the parameters
	which is the value of DW_AT_str_offsets_base.
	* dwarf2/macro.h (dwarf_decode_macros): Modify the definition to include
	str_offsets_base.
2020-10-02 12:27:45 +05:30
..
abbrev.c
abbrev.h
attribute.c Add attribute::as_boolean method 2020-09-29 20:29:07 -06:00
attribute.h Remove DW_UNSND 2020-09-29 20:29:07 -06:00
comp-unit.c
comp-unit.h
die.h Change die_info methods to check the attribute's form 2020-09-29 20:29:07 -06:00
dwz.c
dwz.h
expr.c
expr.h
frame-tailcall.c
frame-tailcall.h
frame.c
frame.h
index-cache.c
index-cache.h
index-common.c
index-common.h
index-write.c
index-write.h
leb.c
leb.h
line-header.c
line-header.h
loc.c
loc.h
macro.c DWARFv5: Handle DW_MACRO_define_strx and DW_MACRO_undef_strx macro entries. 2020-10-02 12:27:45 +05:30
macro.h DWARFv5: Handle DW_MACRO_define_strx and DW_MACRO_undef_strx macro entries. 2020-10-02 12:27:45 +05:30
read.c DWARFv5: Handle DW_MACRO_define_strx and DW_MACRO_undef_strx macro entries. 2020-10-02 12:27:45 +05:30
read.h
section.c
section.h
stringify.c
stringify.h