]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2021-2024 Free Software Foundation, Inc. |
80d1206d AS |
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 | # Test support for DW_LLE_start_end (PR symtab/27999). | |
17 | ||
18 | load_lib dwarf.exp | |
19 | ||
ce8d533e | 20 | require dwarf2_support |
80d1206d AS |
21 | |
22 | # Test with 32-bit and 64-bit DWARF. | |
23 | foreach_with_prefix is_64 {false true} { | |
24 | if { $is_64 } { | |
25 | standard_testfile .c -dw64.S | |
26 | set testfile ${testfile}-dw64 | |
27 | } else { | |
28 | standard_testfile .c -dw32.S | |
29 | set testfile ${testfile}-dw32 | |
30 | } | |
31 | ||
32 | # Get the addresses / lengths of func1 and func2. | |
33 | lassign [function_range func1 $srcdir/$subdir/$srcfile] func1_addr func1_len | |
34 | lassign [function_range func2 $srcdir/$subdir/$srcfile] func2_addr func2_len | |
35 | ||
36 | set asm_file [standard_output_file $srcfile2] | |
37 | Dwarf::assemble $asm_file { | |
38 | global func1_addr func1_len | |
39 | global func2_addr func2_len | |
40 | global is_64 | |
41 | ||
42 | # The CU uses the DW_FORM_loclistx form to refer to the .debug_loclists | |
43 | # section. | |
44 | cu { | |
45 | version 5 | |
46 | is_64 $is_64 | |
47 | } { | |
48 | declare_labels int_type | |
49 | ||
50 | DW_TAG_compile_unit { | |
51 | {DW_AT_loclists_base cu_table DW_FORM_sec_offset} | |
52 | } { | |
53 | int_type: DW_TAG_base_type { | |
54 | {DW_AT_byte_size 4 DW_FORM_data1} | |
55 | {DW_AT_encoding @DW_ATE_signed} | |
56 | {DW_AT_name "int"} | |
57 | } | |
58 | ||
59 | DW_TAG_variable { | |
60 | {DW_AT_name "foo"} | |
61 | {DW_AT_location 1 DW_FORM_loclistx} | |
62 | {DW_AT_type :$int_type} | |
63 | } | |
64 | ||
65 | DW_TAG_subprogram { | |
66 | {DW_AT_name "func1"} | |
67 | {DW_AT_low_pc $func1_addr} | |
68 | {DW_AT_high_pc $func1_len DW_FORM_udata} | |
69 | } | |
70 | ||
71 | DW_TAG_subprogram { | |
72 | {DW_AT_name "func2"} | |
73 | {DW_AT_low_pc $func2_addr} | |
74 | {DW_AT_high_pc $func2_len DW_FORM_udata} | |
75 | } | |
76 | } | |
77 | } | |
78 | ||
46a5b75b | 79 | loclists {is-64 $is_64} { |
80d1206d AS |
80 | # This table is unused, but exists so that the used table is not at |
81 | # the beginning of the section. | |
46a5b75b | 82 | table {} { |
80d1206d AS |
83 | list_ { |
84 | start_end 0x1000 0x2000 { DW_OP_addr 0x100000 } | |
85 | } | |
86 | } | |
87 | ||
88 | # The lists in this table are accessed by index (DW_FORM_rnglistx). | |
46a5b75b | 89 | table {post-header-label cu_table} { |
80d1206d AS |
90 | # This list is unused, but exists to offset the next ones. |
91 | list_ { | |
92 | start_end 0x1000 0x2000 { DW_OP_addr 0x100000 } | |
93 | } | |
94 | ||
95 | # For variable foo. | |
96 | list_ { | |
7b9f73fa TT |
97 | # This should not affect the following addresses. |
98 | base_address 0xffff | |
99 | ||
80d1206d AS |
100 | # When in func1. |
101 | start_end $func1_addr "$func1_addr + $func1_len" { | |
102 | DW_OP_constu 0x123456 | |
103 | DW_OP_stack_value | |
104 | } | |
105 | ||
106 | # When in func2. | |
107 | start_end $func2_addr "$func2_addr + $func2_len" { | |
108 | DW_OP_constu 0x234567 | |
109 | DW_OP_stack_value | |
110 | } | |
111 | } | |
112 | } | |
113 | } | |
114 | } | |
115 | ||
116 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
117 | [list $srcfile $asm_file] {nodebug}] } { | |
118 | return -1 | |
119 | } | |
120 | ||
121 | if { ![runto_main] } { | |
80d1206d AS |
122 | return |
123 | } | |
124 | ||
125 | gdb_breakpoint "func1" | |
126 | gdb_breakpoint "func2" | |
127 | ||
128 | gdb_continue_to_breakpoint "func1" | |
129 | with_test_prefix "at func1" { | |
130 | gdb_test "print /x foo" " = 0x123456" | |
131 | } | |
132 | ||
133 | gdb_continue_to_breakpoint "func2" | |
134 | with_test_prefix "at func2" { | |
135 | gdb_test "print /x foo" " = 0x234567" | |
136 | } | |
137 | } |