This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH][gdb/testsuite] Compile varval twice, once without bad DWARF
- From: Tom de Vries <tdevries at suse dot de>
- To: gdb-patches at sourceware dot org
- Cc: Kevin Buettner <kevinb at redhat dot com>
- Date: Mon, 24 Jun 2019 15:21:40 +0200
- Subject: Re: [PATCH][gdb/testsuite] Compile varval twice, once without bad DWARF
- References: <20190624131839.GA18606@delia>
[ EOLDPATCH ]
On 24-06-19 15:18, Tom de Vries wrote:
> Hi,
>
> When we run gdb.dwarf2/varval.exp with board cc-with-dwz, we run into:
> ...
> gdb compile failed, dwz: varval: Couldn't find DIE referenced by \
> DW_OP_GNU_variable_value
> cc-with-tweaks.sh: dwz did not modify varval.
> UNTESTED: gdb.dwarf2/varval.exp: failed to prepare
> ...
>
> The problem is that varval contains some bad DWARF, which has been added
> intentionally to test GDB, but that bad DWARF causes dwz to error out, which
> has the consequence that the test-case remains untested with cc-with-dwz,
> while the test-case contains also correct DWARF that does not occur in any
> other test, and which we would really like to test with board cc-with-dwz.
>
> Fix this by compiling varval twice, once without and once with the bad DWARF,
> such that we have at least:
> ...
> PASS: gdb.dwarf2/varval.exp: print varval
> PASS: gdb.dwarf2/varval.exp: print varval2
> PASS: gdb.dwarf2/varval.exp: print constval
> PASS: gdb.dwarf2/varval.exp: print mixedval
> PASS: gdb.dwarf2/varval.exp: print pointerval
> PASS: gdb.dwarf2/varval.exp: print *pointerval
> PASS: gdb.dwarf2/varval.exp: print structval
> PASS: gdb.dwarf2/varval.exp: print untypedval
> gdb compile failed, dwz: varval: Couldn't find DIE referenced by \
> DW_OP_GNU_variable_value
> cc-with-tweaks.sh: dwz did not modify varval.
> UNTESTED: gdb.dwarf2/varval.exp: failed to prepare
> ...
>
> Tested on x86_64-linux.
>
> OK for trunk?
>
> Thanks,
> - Tom
>
[gdb/testsuite] Compile varval twice, once without bad DWARF
When we run gdb.dwarf2/varval.exp with board cc-with-dwz, we run into:
...
gdb compile failed, dwz: varval: Couldn't find DIE referenced by \
DW_OP_GNU_variable_value
cc-with-tweaks.sh: dwz did not modify varval.
UNTESTED: gdb.dwarf2/varval.exp: failed to prepare
...
The problem is that varval contains some bad DWARF, which has been added
intentionally to test GDB, but that bad DWARF causes dwz to error out, which
has the consequence that the test-case remains untested with cc-with-dwz,
while the test-case contains also correct DWARF that does not occur in any
other test, and which we would really like to test with board cc-with-dwz.
Fix this by compiling varval twice, once without and once with the bad DWARF,
such that we have at least:
...
PASS: gdb.dwarf2/varval.exp: print varval
PASS: gdb.dwarf2/varval.exp: print varval2
PASS: gdb.dwarf2/varval.exp: print constval
PASS: gdb.dwarf2/varval.exp: print mixedval
PASS: gdb.dwarf2/varval.exp: print pointerval
PASS: gdb.dwarf2/varval.exp: print *pointerval
PASS: gdb.dwarf2/varval.exp: print structval
PASS: gdb.dwarf2/varval.exp: print untypedval
gdb compile failed, dwz: varval: Couldn't find DIE referenced by \
DW_OP_GNU_variable_value
cc-with-tweaks.sh: dwz did not modify varval.
UNTESTED: gdb.dwarf2/varval.exp: failed to prepare
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-06-24 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/varval.exp: Compile twice, once without bad DWARF.
---
gdb/testsuite/gdb.dwarf2/varval.exp | 423 +++++++++++++++++++-----------------
1 file changed, 221 insertions(+), 202 deletions(-)
diff --git a/gdb/testsuite/gdb.dwarf2/varval.exp b/gdb/testsuite/gdb.dwarf2/varval.exp
index 4711f4a24a..594591025f 100644
--- a/gdb/testsuite/gdb.dwarf2/varval.exp
+++ b/gdb/testsuite/gdb.dwarf2/varval.exp
@@ -39,237 +39,252 @@ if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
return -1
}
-# Create the DWARF.
-Dwarf::assemble ${asm_file} {
- global srcdir subdir srcfile
-
- cu {} {
- DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- } {
- declare_labels int_label ptr_label struct_label var_a_label \
- var_b_label var_c_label var_p_label var_bad_label \
- varval_label var_s_label var_untyped_label \
- var_a_abstract_label var_a_concrete_label \
- varval2_label
-
- set int_size [get_sizeof "int" -1]
-
- # gdb always assumes references are implemented as pointers.
- set addr_size [get_sizeof "void *" -1]
-
- int_label: DW_TAG_base_type {
- {DW_AT_byte_size ${int_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
- }
-
- ptr_label: DW_TAG_pointer_type {
- {DW_AT_type :$int_label}
- }
-
- var_a_label: DW_TAG_variable {
- {DW_AT_name "var_a"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
- }
-
- var_a_abstract_label: DW_TAG_variable {
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- }
+proc setup_exec { arg_bad } {
+ global asm_file executable srcfile bad
+ set bad ${arg_bad}
- var_b_label: DW_TAG_variable {
- {DW_AT_name "var_b"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_b"]} SPECIAL_expr}
- }
+ # Create the DWARF.
+ Dwarf::assemble ${asm_file} {
+ global srcdir subdir srcfile bad
- var_c_label: DW_TAG_variable {
- {DW_AT_name "var_c"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_const_value 53 DW_FORM_sdata}
- }
+ cu {} {
+ DW_TAG_compile_unit {
+ {DW_AT_language @DW_LANG_C_plus_plus}
+ } {
+ declare_labels int_label ptr_label struct_label var_a_label \
+ var_b_label var_c_label var_p_label var_bad_label \
+ varval_label var_s_label var_untyped_label \
+ var_a_abstract_label var_a_concrete_label \
+ varval2_label
- var_p_label: DW_TAG_variable {
- {DW_AT_name "var_p"}
- {DW_AT_type :${ptr_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_p"]} SPECIAL_expr}
- }
+ set int_size [get_sizeof "int" -1]
- var_bad_label: DW_TAG_variable {
- {DW_AT_name "var_bad"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- }
+ # gdb always assumes references are implemented as pointers.
+ set addr_size [get_sizeof "void *" -1]
- struct_label: DW_TAG_structure_type {
- {DW_AT_byte_size 8*$int_size DW_FORM_sdata}
- } {
- DW_TAG_member {
- {DW_AT_name "a"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 0*$int_size DW_FORM_udata}
- }
- DW_TAG_member {
- {DW_AT_name "b"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 1*$int_size DW_FORM_udata}
- }
- DW_TAG_member {
- {DW_AT_name "c"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 2*$int_size DW_FORM_udata}
- }
- DW_TAG_member {
- {DW_AT_name "d"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 3*$int_size DW_FORM_udata}
- }
- DW_TAG_member {
- {DW_AT_name "e"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 4*$int_size DW_FORM_udata}
+ int_label: DW_TAG_base_type {
+ {DW_AT_byte_size ${int_size} DW_FORM_udata}
+ {DW_AT_encoding @DW_ATE_signed}
+ {DW_AT_name "int"}
}
- DW_TAG_member {
- {DW_AT_name "f"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 5*$int_size DW_FORM_udata}
- }
- DW_TAG_member {
- {DW_AT_name "g"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 6*$int_size DW_FORM_udata}
- }
- DW_TAG_member {
- {DW_AT_name "h"}
+
+ ptr_label: DW_TAG_pointer_type {
{DW_AT_type :$int_label}
- {DW_AT_data_member_location 7*$int_size DW_FORM_udata}
}
- }
-
- var_s_label: DW_TAG_variable {
- {DW_AT_name "var_s"}
- {DW_AT_type :${struct_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_s"]} SPECIAL_expr}
- }
- var_untyped_label: DW_TAG_variable {
- {DW_AT_name "var_untyped"}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_b"]} SPECIAL_expr}
- }
-
- DW_TAG_subprogram {
- {MACRO_AT_func { "main" "${srcdir}/${subdir}/${srcfile}" }}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- } {
- varval_label: DW_TAG_variable {
- {DW_AT_name "varval"}
+ var_a_label: DW_TAG_variable {
+ {DW_AT_name "var_a"}
{DW_AT_type :${int_label}}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_a_label}
- DW_OP_stack_value
- } SPECIAL_expr}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
}
- varval2_label: DW_TAG_variable {
- {DW_AT_name "varval2"}
+
+ var_a_abstract_label: DW_TAG_variable {
{DW_AT_type :${int_label}}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_a_abstract_label}
- DW_OP_stack_value
- } SPECIAL_expr}
- }
- var_a_concrete_label: DW_TAG_variable {
- {DW_AT_abstract_origin :${var_a_abstract_label}}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
+ {DW_AT_external 1 DW_FORM_flag}
}
- DW_TAG_variable {
- {DW_AT_name "constval"}
+
+ var_b_label: DW_TAG_variable {
+ {DW_AT_name "var_b"}
{DW_AT_type :${int_label}}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_c_label}
- DW_OP_stack_value
- } SPECIAL_expr}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_b"]} SPECIAL_expr}
}
- DW_TAG_variable {
- {DW_AT_name "mixedval"}
+
+ var_c_label: DW_TAG_variable {
+ {DW_AT_name "var_c"}
{DW_AT_type :${int_label}}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_c_label}
- DW_OP_GNU_variable_value ${var_b_label}
- DW_OP_div
- DW_OP_GNU_variable_value ${varval_label}
- DW_OP_plus
- DW_OP_dup
- DW_OP_plus
- DW_OP_GNU_variable_value ${varval_label}
- DW_OP_minus
- DW_OP_stack_value
- } SPECIAL_expr}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_const_value 53 DW_FORM_sdata}
}
- DW_TAG_variable {
- {DW_AT_name "pointerval"}
+
+ var_p_label: DW_TAG_variable {
+ {DW_AT_name "var_p"}
{DW_AT_type :${ptr_label}}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_p_label}
- DW_OP_stack_value
- } SPECIAL_expr}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_p"]} SPECIAL_expr}
}
- DW_TAG_variable {
- {DW_AT_name "badval"}
- {DW_AT_type :${int_label}}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_bad_label}
- DW_OP_stack_value
- } SPECIAL_expr}
+
+ if { $bad } {
+ var_bad_label: DW_TAG_variable {
+ {DW_AT_name "var_bad"}
+ {DW_AT_type :${int_label}}
+ {DW_AT_external 1 DW_FORM_flag}
+ }
}
- DW_TAG_variable {
- {DW_AT_name "structval"}
- {DW_AT_type :${struct_label}}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_s_label}
- DW_OP_stack_value
- } SPECIAL_expr}
+
+ struct_label: DW_TAG_structure_type {
+ {DW_AT_byte_size 8*$int_size DW_FORM_sdata}
+ } {
+ DW_TAG_member {
+ {DW_AT_name "a"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 0*$int_size DW_FORM_udata}
+ }
+ DW_TAG_member {
+ {DW_AT_name "b"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 1*$int_size DW_FORM_udata}
+ }
+ DW_TAG_member {
+ {DW_AT_name "c"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 2*$int_size DW_FORM_udata}
+ }
+ DW_TAG_member {
+ {DW_AT_name "d"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 3*$int_size DW_FORM_udata}
+ }
+ DW_TAG_member {
+ {DW_AT_name "e"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 4*$int_size DW_FORM_udata}
+ }
+ DW_TAG_member {
+ {DW_AT_name "f"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 5*$int_size DW_FORM_udata}
+ }
+ DW_TAG_member {
+ {DW_AT_name "g"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 6*$int_size DW_FORM_udata}
+ }
+ DW_TAG_member {
+ {DW_AT_name "h"}
+ {DW_AT_type :$int_label}
+ {DW_AT_data_member_location 7*$int_size DW_FORM_udata}
+ }
}
- DW_TAG_variable {
- {DW_AT_name "untypedval"}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${var_untyped_label}
- DW_OP_stack_value
- } SPECIAL_expr}
+
+ var_s_label: DW_TAG_variable {
+ {DW_AT_name "var_s"}
+ {DW_AT_type :${struct_label}}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_s"]} SPECIAL_expr}
}
- DW_TAG_variable {
- {DW_AT_name "bad_die_val1"}
- {DW_AT_location {
- DW_OP_GNU_variable_value 0xabcdef11
- DW_OP_stack_value
- } SPECIAL_expr}
+
+ var_untyped_label: DW_TAG_variable {
+ {DW_AT_name "var_untyped"}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_b"]} SPECIAL_expr}
}
- DW_TAG_variable {
- {DW_AT_name "bad_die_val2"}
- {DW_AT_location {
- DW_OP_GNU_variable_value ${ptr_label}+1
- DW_OP_stack_value
- } SPECIAL_expr}
+
+ DW_TAG_subprogram {
+ {MACRO_AT_func { "main" "${srcdir}/${subdir}/${srcfile}" }}
+ {DW_AT_type :${int_label}}
+ {DW_AT_external 1 DW_FORM_flag}
+ } {
+ varval_label: DW_TAG_variable {
+ {DW_AT_name "varval"}
+ {DW_AT_type :${int_label}}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_a_label}
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ varval2_label: DW_TAG_variable {
+ {DW_AT_name "varval2"}
+ {DW_AT_type :${int_label}}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_a_abstract_label}
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ var_a_concrete_label: DW_TAG_variable {
+ {DW_AT_abstract_origin :${var_a_abstract_label}}
+ {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
+ }
+ DW_TAG_variable {
+ {DW_AT_name "constval"}
+ {DW_AT_type :${int_label}}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_c_label}
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ DW_TAG_variable {
+ {DW_AT_name "mixedval"}
+ {DW_AT_type :${int_label}}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_c_label}
+ DW_OP_GNU_variable_value ${var_b_label}
+ DW_OP_div
+ DW_OP_GNU_variable_value ${varval_label}
+ DW_OP_plus
+ DW_OP_dup
+ DW_OP_plus
+ DW_OP_GNU_variable_value ${varval_label}
+ DW_OP_minus
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ DW_TAG_variable {
+ {DW_AT_name "pointerval"}
+ {DW_AT_type :${ptr_label}}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_p_label}
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ if { $bad } {
+ DW_TAG_variable {
+ {DW_AT_name "badval"}
+ {DW_AT_type :${int_label}}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_bad_label}
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ }
+ DW_TAG_variable {
+ {DW_AT_name "structval"}
+ {DW_AT_type :${struct_label}}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_s_label}
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ DW_TAG_variable {
+ {DW_AT_name "untypedval"}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${var_untyped_label}
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ if { $bad } {
+ DW_TAG_variable {
+ {DW_AT_name "bad_die_val1"}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value 0xabcdef11
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ DW_TAG_variable {
+ {DW_AT_name "bad_die_val2"}
+ {DW_AT_location {
+ DW_OP_GNU_variable_value ${ptr_label}+1
+ DW_OP_stack_value
+ } SPECIAL_expr}
+ }
+ }
}
}
}
}
-}
-if [prepare_for_testing "failed to prepare" ${executable} [list ${asm_file} ${srcfile}] {}] {
- return -1
+ if [prepare_for_testing "failed to prepare" ${executable} [list ${asm_file} ${srcfile}] {}] {
+ return -1
+ }
+
+ # DW_OP_GNU_variable_value implementation requires a valid frame.
+ if ![runto_main] {
+ return -1
+ }
}
-# DW_OP_GNU_variable_value implementation requires a valid frame.
-if ![runto_main] {
+if { [setup_exec 0] == -1 } {
return -1
}
@@ -279,7 +294,6 @@ gdb_test "print constval" "= 53"
gdb_test "print mixedval" "= 42"
gdb_test "print pointerval" "= \\(int \\*\\) $hex <var_b>"
gdb_test "print *pointerval" "= 3"
-gdb_test "print badval" "value has been optimized out"
# Jakub says: "The intended behavior is that the debug info consumer
# computes the value of that referenced variable at the current PC,
@@ -293,6 +307,11 @@ gdb_test "print structval" \
gdb_test "print untypedval" \
"Type of DW_OP_GNU_variable_value DIE must be an integer or pointer\\."
+if { [setup_exec 1] == -1 } {
+ return -1
+}
+
+gdb_test "print badval" "value has been optimized out"
gdb_test "print bad_die_val1" \
"invalid dwarf2 offset 0xabcdef11"
gdb_test "print bad_die_val2" \