diff options
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/ada-array-bound.c | 29 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/ada-array-bound.exp | 89 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/debug-names-non-ascending-cu.exp | 81 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp | 109 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp | 41 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw-form-strx.exp | 25 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl | 64 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-modula2-self-type.S | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-simple-locdesc.S | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw2-strp.S | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp | 95 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp | 88 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/pr11465.S | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/varval.exp | 2 |
15 files changed, 562 insertions, 87 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/ada-array-bound.c b/gdb/testsuite/gdb.dwarf2/ada-array-bound.c new file mode 100644 index 0000000..5a7d397 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/ada-array-bound.c @@ -0,0 +1,29 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 Free Software Foundation, Inc. + + 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 3 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 data used for the structure. */ + +unsigned char our_data[] = { 3, 7, 11, 13 }; + +/* Dummy main function. */ + +int +main() +{ + asm ("main_label: .globl main_label"); + return 0; +} diff --git a/gdb/testsuite/gdb.dwarf2/ada-array-bound.exp b/gdb/testsuite/gdb.dwarf2/ada-array-bound.exp new file mode 100644 index 0000000..f48df7b --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/ada-array-bound.exp @@ -0,0 +1,89 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 3 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/>. + +# Test handling of an array type whose bound comes from the field of a +# structure. + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +require dwarf2_support + +standard_testfile .c -debug.S + +# Set up the DWARF for the test. + +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + global srcdir subdir srcfile + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_Ada95} + {DW_AT_name $srcfile} + } { + declare_labels byte array disc struct + + byte: DW_TAG_base_type { + {DW_AT_byte_size 1 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_unsigned} + {DW_AT_name byte} + } + + array: DW_TAG_array_type { + {DW_AT_name array_type} + {DW_AT_type :$byte} + } { + DW_TAG_subrange_type { + {DW_AT_type :$byte} + {DW_AT_upper_bound :$disc} + } + } + + struct: DW_TAG_structure_type { + {DW_AT_name discriminated} + {DW_AT_byte_size 4 DW_FORM_sdata} + } { + disc: DW_TAG_member { + {DW_AT_name disc} + {DW_AT_type :$byte} + {DW_AT_data_member_location 0 DW_FORM_sdata} + } + DW_TAG_member { + {DW_AT_name nums} + {DW_AT_type :$array} + {DW_AT_data_member_location 1 DW_FORM_sdata} + } + } + + DW_TAG_variable { + {DW_AT_name "value"} + {DW_AT_type :$struct} + {DW_AT_external 1 DW_FORM_flag} + {DW_AT_location {DW_OP_addr [gdb_target_symbol "our_data"]} + SPECIAL_expr} + } + } + } +} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +gdb_test_no_output "set language ada" +gdb_test "print value" \ + [string_to_regexp " = (disc => 3, nums => (7, 11, 13))"] diff --git a/gdb/testsuite/gdb.dwarf2/debug-names-non-ascending-cu.exp b/gdb/testsuite/gdb.dwarf2/debug-names-non-ascending-cu.exp deleted file mode 100644 index d86b5c4..0000000 --- a/gdb/testsuite/gdb.dwarf2/debug-names-non-ascending-cu.exp +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2022-2025 Free Software Foundation, Inc. - -# 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 3 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/>. - -load_lib dwarf.exp - -# This test can only be run on targets which support DWARF-2 and use gas. -require dwarf2_support - -standard_testfile _start.c debug-names.S - -set func_info_vars \ - [get_func_info _start [list debug additional_flags=-nostartfiles]] - -# Create the DWARF. -set asm_file [standard_output_file $srcfile2] -Dwarf::assemble { - filename $asm_file - add_dummy_cus 0 -} { - global func_info_vars - foreach var $func_info_vars { - global $var - } - - cu { label cu_label } { - compile_unit {{language @DW_LANG_C}} { - subprogram { - {DW_AT_name _start} - {DW_AT_low_pc $_start_start DW_FORM_addr} - {DW_AT_high_pc $_start_end DW_FORM_addr} - } - } - } - - cu { label cu_label_2 } { - compile_unit {{language @DW_LANG_C}} { - base_type { - {name int} - {byte_size 4 sdata} - {encoding @DW_ATE_signed} - } - } - } - - debug_names {} { - cu cu_label_2 - cu cu_label - name _start subprogram cu_label 0xEDDB6232 - name int base_type cu_label 0xB888030 - } -} - -if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" \ - [list additional_flags=-nostartfiles]] { - return -1 -} - -# Check for warning. -set re \ - [list \ - "warning:" \ - "Section .debug_names has incorrect entry in CU table," \ - "ignoring .debug_names."] -set re [join $re] -gdb_assert {[regexp $re $gdb_file_cmd_msg]} "warning" - -# Verify that .debug_names section is ignored. -set index [have_index $binfile] -gdb_assert { [string equal $index ""] } ".debug_names not used" diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp b/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp new file mode 100644 index 0000000..6253629 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp @@ -0,0 +1,109 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 3 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/>. + +# This is a reproducer for PR 29518: +# +# https://sourceware.org/bugzilla/show_bug.cgi?id=29518 +# +# The root cause for the problem was that function +# dwarf2_find_containing_comp_unit was searching the whole "all_units" vector, +# containing both compile units and type units, causing it to sometimes +# erroneously return a type unit. It should have been restricted to searching +# compile units. +# +# To get dwarf2_find_containing_comp_unit to be called and reproduce the +# original bug, we need a value with form DW_FORM_ref_addr pointing to a +# different compile unit. This is produced by `%$int_type` below. + +load_lib dwarf.exp +require dwarf2_support +standard_testfile main.c .S + +set asm_file [standard_output_file $srcfile2] + +Dwarf::assemble $asm_file { + global srcfile + declare_labels int_type + + # The source CU. + cu {version 4} { + compile_unit { + } { + subprogram { + {MACRO_AT_func {main}} + {type %$int_type} + } + } + } + + # Create a bunch of empty / dummy CUs, to make the offset of int_type a bit + # higher. + for {set i 1} {$i < 10} {incr i} { + cu {version 4} { + compile_unit {} {} + } + } + + # The target CU. + cu {version 4} { + compile_unit { + } { + int_type: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name int} + } + } + } + + # Create many TUs. + # + # We need enough type units in the "all_units" vector in order to steer the + # binary search in dwarf2_find_containing_comp_unit towards the type units + # region of the array. + for {set i 1} {$i < 20} {incr i} { + tu {version 4} $i the_type_i { + type_unit {} { + declare_labels dummy_int_type + + the_type_i: structure_type { + {name s} + {byte_size 4 sdata} + } { + member { + {name i} + {type :$dummy_int_type} + } + } + + dummy_int_type: base_type { + {name int} + {encoding @DW_ATE_signed} + {byte_size 4 sdata} + } + } + } + } +} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +# Without the corresponding fix, we get an internal error: +# +# gdb/dwarf2/read.c:3940: internal-error: load_full_comp_unit: Assertion `! this_cu->is_debug_types' failed. +gdb_test "p main" " = {int \\(void\\)} $hex <main>" diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp new file mode 100644 index 0000000..cb24b19 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx-out-of-bounds.exp @@ -0,0 +1,41 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 3 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/>. + +# Check that an out-of-bounds DW_FORM_strx attribute triggers a DWARF error. + +# Out of bounds index. +set int_str_idx 1 + +# With readnow, the dwarf error is printed during the file command, so skip +# the test. +require !readnow + +set prepare_for_testing_done 0 +source $srcdir/$subdir/dw-form-strx.exp.tcl +require {expr $prepare_for_testing_done == 1} + +set re_dwarf_error \ + [string_list_to_regexp \ + "DWARF Error: Offset from DW_FORM_GNU_str_index or DW_FORM_strx" \ + " pointing outside of .debug_str_offsets section in CU at offset"\ + " "]$hex +set re_in_module \ + {in module [^\r\n]+} +set re_in_module [string_to_regexp {[}]$re_in_module[string_to_regexp {]}] +set re_no_symbol [string_to_regexp {No symbol "global_var" in current context.}] +gdb_test "ptype global_var" \ + [multi_line \ + "$re_dwarf_error $re_in_module"\ + $re_no_symbol] diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp new file mode 100644 index 0000000..3f739c4 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp @@ -0,0 +1,25 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 3 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/>. + +# Check that DW_FORM_strx works. + +# Correct index. +set int_str_idx 0 + +set prepare_for_testing_done 0 +source $srcdir/$subdir/dw-form-strx.exp.tcl +require {expr $prepare_for_testing_done == 1} + +gdb_test "ptype global_var" "type = int" diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl new file mode 100644 index 0000000..bc5a654 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl @@ -0,0 +1,64 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 3 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/>. + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +require dwarf2_support + +standard_testfile main.c -dw.S + +set asm_file [standard_output_file $srcfile2] + +# Debug info in the main file. +Dwarf::assemble $asm_file { + declare_labels base_offset_cu1 + + debug_str_offsets { base_offset base_offset_cu1 } int + + cu { + version 5 + } { + DW_TAG_compile_unit { + {DW_AT_str_offsets_base $base_offset_cu1 sec_offset} + } { + declare_labels int4_type + + int4_type: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name $::int_str_idx DW_FORM_strx_id} + } + + DW_TAG_variable { + {DW_AT_name global_var} + {DW_AT_type :$int4_type} + {DW_AT_location { + DW_OP_const1u 12 + DW_OP_stack_value + } SPECIAL_expr} + } + } + } +} + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return +} + +# Let includers know prepare_for_testing was done, without having to check +# source return status. +set prepare_for_testing_done 1 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-modula2-self-type.S b/gdb/testsuite/gdb.dwarf2/dw2-modula2-self-type.S index c09c6db..06a93ac 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-modula2-self-type.S +++ b/gdb/testsuite/gdb.dwarf2/dw2-modula2-self-type.S @@ -114,7 +114,11 @@ die221: .byte 0x0 - .section .debug_str +#ifdef __arm__ + .section .debug_str,"MS",%progbits,1 +#else + .section .debug_str,"MS",@progbits,1 +#endif .LASF1: .string "2.mod" .LASF0: diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp index ea0fc03..6120878 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp @@ -117,7 +117,7 @@ if ![runto_main] { # the hole is there in the symbol table, but not the partial symbol table, # we run into: # (gdb) bt -# warning: (Internal error: pc 0x555555554619 in read in psymtab, \ +# warning: (Internal error: pc 0x555555554619 in read in psymtab, # but not in symtab.) # ... # (gdb) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-simple-locdesc.S b/gdb/testsuite/gdb.dwarf2/dw2-simple-locdesc.S index cd999f4..551dda7 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-simple-locdesc.S +++ b/gdb/testsuite/gdb.dwarf2/dw2-simple-locdesc.S @@ -160,7 +160,11 @@ d: .byte 0 .byte 0 .byte 0 - .section .debug_str +#ifdef __arm__ + .section .debug_str,"MS",%progbits,1 +#else + .section .debug_str,"MS",@progbits,1 +#endif .LASF2: .string "GNU C 4.7.0 20110727 (experimental)" .LASF0: diff --git a/gdb/testsuite/gdb.dwarf2/dw2-strp.S b/gdb/testsuite/gdb.dwarf2/dw2-strp.S index c7ede95..db3e64f 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-strp.S +++ b/gdb/testsuite/gdb.dwarf2/dw2-strp.S @@ -163,7 +163,11 @@ .byte 0x0 /* Terminator */ /* String table */ - .section .debug_str +#ifdef __arm__ + .section .debug_str,"MS",%progbits,1 +#else + .section .debug_str,"MS",@progbits,1 +#endif .Lproducer: .string "GNU C 3.3.3" .Lchar_str: diff --git a/gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp b/gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp new file mode 100644 index 0000000..f4e02da --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp @@ -0,0 +1,95 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 3 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/>. + +# Test DW_AT_data_bit_offset with an expression. This is a DWARF +# extension, but expected to be in DWARF 6. See +# https://dwarfstd.org/issues/250501.1.html + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +require dwarf2_support + +standard_testfile ada-array-bound.c -debug.S + +# Set up the DWARF for the test. + +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + global srcdir subdir srcfile + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_Ada95} + {DW_AT_name $srcfile} + } { + declare_labels byte array struct + + byte: DW_TAG_base_type { + {DW_AT_byte_size 1 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_unsigned} + {DW_AT_name byte} + } + + array: DW_TAG_array_type { + {DW_AT_name array_type} + {DW_AT_type :$byte} + } { + DW_TAG_subrange_type { + {DW_AT_type :$byte} + {DW_AT_upper_bound 3 DW_FORM_sdata} + } + } + + struct: DW_TAG_structure_type { + {DW_AT_name discriminated} + {DW_AT_byte_size 4 DW_FORM_sdata} + } { + DW_TAG_member { + {DW_AT_name disc} + {DW_AT_type :$byte} + {DW_AT_data_member_location 0 DW_FORM_sdata} + } + + # We know this is always at offset 1 but use an + # expression just to test this code path. This is a + # DWARF extension. See + # https://dwarfstd.org/issues/250501.1.html. + DW_TAG_member { + {DW_AT_name nums} + {DW_AT_type :$array} + {DW_AT_data_bit_offset {DW_OP_lit8} SPECIAL_expr} + } + } + + DW_TAG_variable { + {DW_AT_name "value"} + {DW_AT_type :$struct} + {DW_AT_external 1 DW_FORM_flag} + {DW_AT_location {DW_OP_addr [gdb_target_symbol "our_data"]} + SPECIAL_expr} + } + } + } +} + +if {[prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}]} { + return -1 +} + +gdb_test_no_output "set language ada" +gdb_test "print value" \ + [string_to_regexp " = (disc => 3, nums => (7, 11, 13))"] diff --git a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp new file mode 100644 index 0000000..4f5867c --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp @@ -0,0 +1,88 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# 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 3 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/>. + +# Check support for a DW_FORM_strx attribute in a dwo file. + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +require dwarf2_support + +standard_testfile main.c -dw.S -dwo.S + +set main_asm_file [standard_output_file $srcfile2] +set dwo_asm_file [standard_output_file $srcfile3] + +# Debug info in the main file. +Dwarf::assemble $main_asm_file { + cu { + version 5 + dwo_id 0xF00D + } { + compile_unit { + {DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp} + } {} + } +} + +# Debug info in the DWO file. +Dwarf::assemble $dwo_asm_file { + debug_str_offsets { dwo 1 } int + + cu { + fission 1 + version 5 + dwo_id 0xF00D + } { + compile_unit {} { + declare_labels int4_type + + int4_type: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name 0 DW_FORM_strx_id} + } + + DW_TAG_variable { + {DW_AT_name global_var} + {DW_AT_type :$int4_type} + {DW_AT_location { + DW_OP_const1u 12 + DW_OP_stack_value + } SPECIAL_expr} + } + } + } +} + +# Build main file. +if { [build_executable "${testfile}.exp" $binfile \ + [list ${srcfile} ${main_asm_file}] {nodebug}] } { + return +} + +# Build DWO file. +set dwo_file [standard_output_file ${testfile}.dwo] +if { [gdb_compile_shlib $dwo_asm_file $dwo_file nodebug] != "" } { + return +} + +if { [is_remote host] } { + gdb_remote_download host $dwo_file +} + +clean_restart $binfile + +gdb_test "ptype global_var" "type = int" diff --git a/gdb/testsuite/gdb.dwarf2/pr11465.S b/gdb/testsuite/gdb.dwarf2/pr11465.S index fed98bc..f3f2c57 100644 --- a/gdb/testsuite/gdb.dwarf2/pr11465.S +++ b/gdb/testsuite/gdb.dwarf2/pr11465.S @@ -344,7 +344,11 @@ die149: .uleb128 0x16 /* DW_TAG_variable */ .byte 0x0 .byte 0x0 .byte 0x0 - .section .debug_str +#ifdef __arm__ + .section .debug_str,"MS",%progbits,1 +#else + .section .debug_str,"MS",@progbits,1 +#endif .LASF0: .string "_ZN1N1fE" .LASF7: diff --git a/gdb/testsuite/gdb.dwarf2/varval.exp b/gdb/testsuite/gdb.dwarf2/varval.exp index 0693f43..6846ecb 100644 --- a/gdb/testsuite/gdb.dwarf2/varval.exp +++ b/gdb/testsuite/gdb.dwarf2/varval.exp @@ -348,6 +348,6 @@ if ![runto_main] { } gdb_test "print badval" "value has been optimized out" gdb_test "print bad_die_val1" \ - "invalid dwarf2 offset 0xabcdef11" + {DWARF Error: could not find unit containing offset 0xabcdef11 \[in module .*/varval\]} gdb_test "print bad_die_val2" \ "Bad DW_OP_GNU_variable_value DIE\\." |