Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-ranges-psym.exp
blobd82f700c94c11b0d696cb3f1e8a55b226e46be21
1 # Copyright 2018-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 load_lib dwarf.exp
18 # Test that psymbols are made when DW_AT_ranges is used.
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 if {![dwarf2_support]} {
22     unsupported "dwarf2 support required for this test"
23     return 0
26 if ![is_c_compiler_gcc] {
27     unsupported "gcc required for this test"
28     return 0
31 standard_testfile main.c .c -dw.S
33 # We need to know the size of integer and address types in order to
34 # write some of the debugging info we'd like to generate.
36 # For that, we ask GDB by debugging our test program.  Any program
37 # would do, but since we already have it specifically for this
38 # testcase, might as well use that.
40 if { [prepare_for_testing "failed to prepare" ${testfile} \
41           [list ${srcfile} ${srcfile2}]] } {
42     return -1
45 set asm_file [standard_output_file $srcfile3]
46 Dwarf::assemble $asm_file {
47     global srcdir subdir srcfile srcfile2
48     declare_labels integer_label volatile_label func_ranges_label cu_ranges_label
49     set int_size [get_sizeof "int" 4]
51     # Find start address and length for our functions.
52     set sources  [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]
54     lassign [function_range foo $sources] \
55         foo_start foo_len
56     set foo_end "$foo_start + $foo_len"
58     lassign [function_range foo_low $sources] \
59         foo_low_start foo_low_len
60     set foo_low_end "$foo_low_start + $foo_low_len"
62     lassign [function_range bar $sources] \
63         bar_start bar_len
64     set bar_end "$bar_start + $bar_len"
66     lassign [function_range baz $sources] \
67         baz_start baz_len
68     set baz_end "$baz_start + $baz_len"
70     cu {} {
71         compile_unit {
72             {language @DW_LANG_C}
73             {name dw-ranges-psym.c}
74             {low_pc 0 addr}
75             {ranges ${cu_ranges_label} DW_FORM_sec_offset}
76         } {
77             integer_label: DW_TAG_base_type {
78                 {DW_AT_byte_size $int_size DW_FORM_sdata}
79                 {DW_AT_encoding  @DW_ATE_signed}
80                 {DW_AT_name      integer}
81             }
82             volatile_label: DW_TAG_volatile_type {
83                 {type :$integer_label}
84             }
85             subprogram {
86                 {external 1 flag}
87                 {name someothername}
88                 {ranges ${func_ranges_label} DW_FORM_sec_offset}
89             }
90             subprogram {
91                 {external 1 flag}
92                 {name bar}
93                 {low_pc $bar_start addr}
94                 {high_pc $bar_len DW_FORM_data4}
95             }
96             subprogram {
97                 {external 1 flag}
98                 {name baz}
99                 {low_pc $baz_start addr}
100                 {high_pc $baz_len DW_FORM_data4}
101             }
102         }
103     }
105     # Generate ranges data.
106     ranges {is_64 [is_64_target]} {
107         func_ranges_label: sequence {
108             range $foo_start $foo_end
109             range $foo_low_start $foo_low_end
110         }
111         cu_ranges_label: sequence {
112             range $foo_start $foo_end
113             range $foo_low_start $foo_low_end
114             range $bar_start $bar_end
115             range $baz_start $baz_end
116         }
117     }
120 if { [build_executable "failed to prepare" ${testfile} \
121           [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
122     return -1
125 clean_restart
126 gdb_load_no_complaints $binfile
128 if ![runto_main] {
129     return -1
132 # "someothername" should be put into the partial symbol table, but
133 # there was a bug causing functions using DW_AT_ranges not to be.
134 # Note we use a name that is very different from the linkage name, in
135 # order to not set the breakpoint via minsyms.
136 gdb_test "break someothername" \
137     "Breakpoint.*at.*"