]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2023-2024 Free Software Foundation, Inc. |
b10f2cd3 TT |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # Check that the DWARF reader works with a a DW_AT_specification that | |
17 | # refers to a later DIE. | |
18 | ||
19 | load_lib dwarf.exp | |
20 | ||
21 | # This test can only be run on targets which support DWARF-2 and use gas. | |
22 | require dwarf2_support | |
23 | ||
24 | standard_testfile main.c -debug.S | |
25 | ||
26 | # Set up the DWARF for the test. | |
27 | set asm_file [standard_output_file $srcfile2] | |
28 | Dwarf::assemble $asm_file { | |
29 | global srcfile | |
30 | ||
31 | cu {} { | |
32 | DW_TAG_compile_unit { | |
33 | {DW_AT_language @DW_LANG_C_plus_plus} | |
34 | {DW_AT_name $srcfile} | |
35 | {DW_AT_comp_dir /tmp} | |
36 | ||
37 | } { | |
38 | declare_labels spec myint | |
39 | ||
40 | # The new indexer has special code to compute the full | |
41 | # name of an object that uses a specification that appears | |
42 | # later in the DWARF. | |
43 | DW_TAG_variable { | |
44 | {DW_AT_specification :$spec} | |
45 | {DW_AT_location { | |
46 | DW_OP_const1u 23 | |
47 | DW_OP_stack_value | |
48 | } SPECIAL_expr} | |
49 | } | |
50 | ||
51 | myint: DW_TAG_base_type { | |
52 | {DW_AT_byte_size 4 DW_FORM_sdata} | |
53 | {DW_AT_encoding @DW_ATE_signed} | |
54 | {DW_AT_name myint} | |
55 | } | |
56 | ||
57 | DW_TAG_namespace { | |
58 | {DW_AT_name ns} | |
59 | } { | |
60 | spec: DW_TAG_variable { | |
61 | {DW_AT_name v} | |
62 | {DW_AT_type :$myint} | |
63 | {DW_AT_declaration 1 DW_FORM_flag_present} | |
64 | } | |
65 | } | |
66 | } | |
67 | } | |
68 | } | |
69 | ||
70 | if {[prepare_for_testing "failed to prepare" ${testfile} \ | |
71 | [list $srcfile $asm_file] {nodebug}]} { | |
72 | return -1 | |
73 | } | |
74 | ||
75 | set in_v 0 | |
76 | gdb_test_multiple "maint print objfiles" "v has a parent" { | |
b664df49 | 77 | -re "^ *\\\[\[0-9\]\\\] *\\(\\(cooked_index_entry\[^\r\n\]*" { |
b10f2cd3 TT |
78 | set in_v 0 |
79 | exp_continue | |
80 | } | |
81 | -re "^ *name: *v\[\r\n\]*" { | |
82 | set in_v 1 | |
83 | exp_continue | |
84 | } | |
b664df49 | 85 | -re "^ *parent: *\\(\\(cooked_index_entry \\*\\) (0|$hex)\\)" { |
b10f2cd3 TT |
86 | if {$in_v} { |
87 | if {$expect_out(1,string) == "0"} { | |
88 | fail $gdb_test_name | |
89 | } else { | |
90 | pass $gdb_test_name | |
91 | } | |
92 | set in_v 0 | |
93 | } | |
94 | exp_continue | |
95 | } | |
96 | -re "^\[^\r\n\]*\[\r\n\]+" { | |
97 | exp_continue | |
98 | } | |
99 | -re "$gdb_prompt " { | |
100 | # Done. | |
101 | } | |
102 | } |