]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2016-2024 Free Software Foundation, Inc. |
e385593e JK |
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 | load_lib dwarf.exp | |
16 | ||
17 | # This test can only be run on targets which support DWARF-2 and use gas. | |
ce8d533e | 18 | require dwarf2_support |
e385593e | 19 | |
90c3ec2d | 20 | standard_testfile main.c .S |
e385593e JK |
21 | |
22 | # Make some DWARF for the test. | |
90c3ec2d | 23 | set asm_file [standard_output_file $srcfile2] |
e385593e JK |
24 | Dwarf::assemble $asm_file { |
25 | cu {} { | |
26 | compile_unit { | |
90c3ec2d | 27 | {MACRO_AT_range {main}} |
e385593e JK |
28 | } { |
29 | declare_labels integer_label | |
30 | ||
31 | integer_label: DW_TAG_base_type { | |
32 | {DW_AT_byte_size 4 DW_FORM_sdata} | |
33 | {DW_AT_encoding @DW_ATE_signed} | |
34 | {DW_AT_name integer} | |
35 | } | |
36 | ||
37 | DW_TAG_subprogram { | |
90c3ec2d | 38 | {MACRO_AT_func {main}} |
e385593e | 39 | {DW_AT_external 1 flag} |
e385593e JK |
40 | } { |
41 | DW_TAG_lexical_block { | |
42 | } { | |
43 | DW_TAG_variable { | |
44 | {DW_AT_name testvar} | |
45 | {DW_AT_type :$integer_label} | |
46 | {DW_AT_external 1 flag} | |
47 | {DW_AT_location { | |
48 | DW_OP_addr [gdb_target_symbol main] | |
49 | } SPECIAL_expr} | |
50 | } | |
51 | } | |
52 | } | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
5b362f04 | 57 | if { [prepare_for_testing "failed to prepare" ${testfile} \ |
90c3ec2d | 58 | [list $srcfile $asm_file] {nodebug}] } { |
e385593e JK |
59 | return -1 |
60 | } | |
61 | ||
62 | runto_main | |
63 | ||
64 | # FAILing GDB did print: No symbol "testvar" in current context. | |
65 | gdb_test "p testvar" { = -?[0-9]+} |