From: Mark Wielaard Date: Mon, 14 Dec 2020 16:38:09 +0000 (+0100) Subject: Use DW_FORM_exprloc in testsuite Dwarf Assembler for DWARF version 4+. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eab9267c330046846aa15217da7dcb77f4588220;p=binutils-gdb.git Use DW_FORM_exprloc in testsuite Dwarf Assembler for DWARF version 4+. Since DWARF version 4 expressions are represented by DW_FORM_exprloc instead of a block form. Support this in the testsuite Dwarf Assembler by setting the SPECIAL_expr form once we know the CU version. This doesn't change any testsuite results, it just makes the produced DWARF valid. gdb also accepts expressions in block form for DWARF version 4 and above, but this is technically incorrect. gdb/testsuite/ChangeLog: * lib/dwarf.exp (Dwarf::_read_constants): Don't set _constants(SPECIAL_expr) here, but set it... (Dwarf::cu): ...here based on _cu_version. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 1c522e83193..ab03f0745da 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-12-14 Mark Wielaard + + * lib/dwarf.exp (Dwarf::_read_constants): Don't set + _constants(SPECIAL_expr) here, but set it... + (Dwarf::cu): ...here based on _cu_version. + 2020-12-14 Tom de Vries * lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index ecd438b205e..43ae29697cd 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -234,8 +234,9 @@ proc get_func_info { name {options {debug}} } { # section automatically. # # If FORM is 'SPECIAL_expr', then VALUE is treated as a location -# expression. The effective form is then DW_FORM_block, and VALUE -# is passed to the (internal) '_location' proc to be translated. +# expression. The effective form is then DW_FORM_block or DW_FORM_exprloc +# for DWARF version >= 4, and VALUE is passed to the (internal) +# '_location' proc to be translated. # This proc implements a miniature DW_OP_ assembler. # # If FORM is not given, it is guessed: @@ -389,7 +390,6 @@ namespace eval Dwarf { proc _read_constants {} { global srcdir hex decimal - variable _constants # DWARF name-matching regexp. set dwrx "DW_\[a-zA-Z0-9_\]+" @@ -416,8 +416,6 @@ namespace eval Dwarf { } } close $fd - - set _constants(SPECIAL_expr) $_constants(DW_FORM_block) } proc _quote {string} { @@ -1042,6 +1040,7 @@ namespace eval Dwarf { # BODY is Tcl code that emits the DIEs which make up the body of # the CU. It is evaluated in the caller's context. proc cu {options body} { + variable _constants variable _cu_count variable _abbrev_section variable _abbrev_num @@ -1081,6 +1080,12 @@ namespace eval Dwarf { set _abbrev_section ".debug_abbrev.dwo" } + if {$_cu_version < 4} { + set _constants(SPECIAL_expr) $_constants(DW_FORM_block) + } else { + set _constants(SPECIAL_expr) $_constants(DW_FORM_exprloc) + } + _section $section set cu_num [incr _cu_count]