]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-ranges-psym-warning.exp
CommitLineData
213516ef 1# Copyright 2021-2023 Free Software Foundation, Inc.
211aafd1
TV
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
16load_lib dwarf.exp
17
18# Check psymtabs addrmaps generated from DW_AT_ranges of functions.
19
20# This test can only be run on targets which support DWARF-2 and use gas.
21if {![dwarf2_support]} {
22 unsupported "dwarf2 support required for this test"
23 return 0
24}
25
26standard_testfile -main.c .c -dw.S
27
28# We need to know the size of integer and address types in order to
29# write some of the debugging info we'd like to generate.
30#
31# For that, we ask GDB by debugging our test program. Any program
32# would do, but since we already have it specifically for this
33# testcase, might as well use that.
34
35if { [prepare_for_testing "failed to prepare" ${testfile} \
36 [list ${srcfile} ${srcfile2}]] } {
37 return -1
38}
39
40set asm_file [standard_output_file $srcfile3]
41Dwarf::assemble $asm_file {
42 global srcdir subdir srcfile srcfile2
43 declare_labels integer_label func_ranges_label
44 set int_size [get_sizeof "int" 4]
45
46 # Find start address and length for our functions.
47 set sources [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]
48
49 lassign [function_range foo $sources] \
50 foo_start foo_len
51 set foo_end "$foo_start + $foo_len"
52
53 lassign [function_range foo_low $sources] \
54 foo_low_start foo_low_len
55 set foo_low_end "$foo_low_start + $foo_low_len"
56
57 lassign [function_range bar $sources] \
58 bar_start bar_len
59 set bar_end "$bar_start + $bar_len"
60
61 lassign [function_range baz $sources] \
62 baz_start baz_len
63 set baz_end "$baz_start + $baz_len"
64
65 cu {} {
66 compile_unit {
67 {language @DW_LANG_C}
68 {name dw-ranges-psym.c}
69 {low_pc 0 addr}
70 } {
71 integer_label: DW_TAG_base_type {
72 {DW_AT_byte_size $int_size DW_FORM_sdata}
73 {DW_AT_encoding @DW_ATE_signed}
74 {DW_AT_name integer}
75 }
76 subprogram {
77 {external 1 flag}
78 {name foo}
79 {ranges ${func_ranges_label} DW_FORM_sec_offset}
80 }
81 subprogram {
82 {external 1 flag}
83 {name bar}
84 {low_pc $bar_start addr}
85 {high_pc $bar_len DW_FORM_data4}
86 }
87 subprogram {
88 {external 1 flag}
89 {name baz}
90 {low_pc $baz_start addr}
91 {high_pc $baz_len DW_FORM_data4}
92 }
93 }
94 }
95
96 # Generate ranges data. Create a hole at $foo_low_start + 1" .. $foo_low_end.
97 ranges {is_64 [is_64_target]} {
98 func_ranges_label: sequence {
99 range $foo_start $foo_end
100 range $foo_low_start "$foo_low_start + 1"
101 #range "$foo_low_start + 1" $foo_low_end
102 }
103 }
104}
105
106if { [build_executable "failed to prepare" ${testfile} \
107 [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
108 return -1
109}
110
111clean_restart
112
113gdb_load_no_complaints $binfile
114
115if ![runto_main] {
116 return -1
117}
118
119# Generate backtrace from baz, that visits the hole in the addrmap. If
120# the hole is there in the symbol table, but not the partial symbol table,
121# we run into:
122# (gdb) bt
123# warning: (Internal error: pc 0x555555554619 in read in psymtab, \
124# but not in symtab.)
125# ...
126# (gdb)
127
128gdb_test "break baz" \
129 "Breakpoint.*at.*"
130
131gdb_test "continue"
132
133set re "warning: \\(Internal error: pc $hex in read in psymtab, but not in symtab\\.\\)"
134gdb_test_multiple "bt" "" {
135 -re -wrap "$re.*" {
136 fail $gdb_test_name
137 }
138 -re -wrap "" {
139 pass $gdb_test_name
140 }
141}