Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / loclists-start-end.exp
CommitLineData
88b9d363 1# Copyright 2021-2022 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
18load_lib dwarf.exp
19
20if {![dwarf2_support]} {
21 return 0
22}
23
24# Test with 32-bit and 64-bit DWARF.
25foreach_with_prefix is_64 {false true} {
26 if { $is_64 } {
27 standard_testfile .c -dw64.S
28 set testfile ${testfile}-dw64
29 } else {
30 standard_testfile .c -dw32.S
31 set testfile ${testfile}-dw32
32 }
33
34 # Get the addresses / lengths of func1 and func2.
35 lassign [function_range func1 $srcdir/$subdir/$srcfile] func1_addr func1_len
36 lassign [function_range func2 $srcdir/$subdir/$srcfile] func2_addr func2_len
37
38 set asm_file [standard_output_file $srcfile2]
39 Dwarf::assemble $asm_file {
40 global func1_addr func1_len
41 global func2_addr func2_len
42 global is_64
43
44 # The CU uses the DW_FORM_loclistx form to refer to the .debug_loclists
45 # section.
46 cu {
47 version 5
48 is_64 $is_64
49 } {
50 declare_labels int_type
51
52 DW_TAG_compile_unit {
53 {DW_AT_loclists_base cu_table DW_FORM_sec_offset}
54 } {
55 int_type: DW_TAG_base_type {
56 {DW_AT_byte_size 4 DW_FORM_data1}
57 {DW_AT_encoding @DW_ATE_signed}
58 {DW_AT_name "int"}
59 }
60
61 DW_TAG_variable {
62 {DW_AT_name "foo"}
63 {DW_AT_location 1 DW_FORM_loclistx}
64 {DW_AT_type :$int_type}
65 }
66
67 DW_TAG_subprogram {
68 {DW_AT_name "func1"}
69 {DW_AT_low_pc $func1_addr}
70 {DW_AT_high_pc $func1_len DW_FORM_udata}
71 }
72
73 DW_TAG_subprogram {
74 {DW_AT_name "func2"}
75 {DW_AT_low_pc $func2_addr}
76 {DW_AT_high_pc $func2_len DW_FORM_udata}
77 }
78 }
79 }
80
81 loclists -is-64 $is_64 {
82 # This table is unused, but exists so that the used table is not at
83 # the beginning of the section.
84 table {
85 list_ {
86 start_end 0x1000 0x2000 { DW_OP_addr 0x100000 }
87 }
88 }
89
90 # The lists in this table are accessed by index (DW_FORM_rnglistx).
91 table -post-header-label cu_table {
92 # This list is unused, but exists to offset the next ones.
93 list_ {
94 start_end 0x1000 0x2000 { DW_OP_addr 0x100000 }
95 }
96
97 # For variable foo.
98 list_ {
99 # When in func1.
100 start_end $func1_addr "$func1_addr + $func1_len" {
101 DW_OP_constu 0x123456
102 DW_OP_stack_value
103 }
104
105 # When in func2.
106 start_end $func2_addr "$func2_addr + $func2_len" {
107 DW_OP_constu 0x234567
108 DW_OP_stack_value
109 }
110 }
111 }
112 }
113 }
114
115 if { [prepare_for_testing "failed to prepare" ${testfile} \
116 [list $srcfile $asm_file] {nodebug}] } {
117 return -1
118 }
119
120 if { ![runto_main] } {
121 fail "can't run to main"
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}
This page took 0.037332 seconds and 4 git commands to generate.