]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2020-2023 Free Software Foundation, Inc. |
1c47ec3e 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 | ||
16 | # Check whether .debug_ranges is correctly read in during symtab expansion. | |
17 | ||
18 | load_lib dwarf.exp | |
19 | ||
20 | # This test can only be run on targets which support DWARF-2 and use gas. | |
21 | if {![dwarf2_support]} { | |
22 | return 0 | |
23 | }; | |
24 | ||
25 | standard_testfile main.c .S | |
26 | ||
27 | set executable ${testfile} | |
28 | set asm_file [standard_output_file ${srcfile2}] | |
29 | ||
1c47ec3e TV |
30 | # Create the DWARF. |
31 | Dwarf::assemble $asm_file { | |
32 | global srcdir subdir srcfile | |
33 | ||
34 | declare_labels int_label | |
35 | declare_labels ranges_label | |
36 | ||
37 | set main_func \ | |
38 | [function_range main [list ${srcdir}/${subdir}/$srcfile]] | |
39 | ||
40 | cu {} { | |
41 | compile_unit { | |
42 | {language @DW_LANG_C_plus_plus} | |
43 | {name "cu1"} | |
44 | } { | |
45 | DW_TAG_variable { | |
46 | {name foo} | |
4001d90d | 47 | {type %$int_label} |
1c47ec3e TV |
48 | {const_value 1 DW_FORM_sdata} |
49 | } | |
50 | } | |
51 | } | |
52 | ||
53 | cu {} { | |
54 | compile_unit { | |
55 | {language @DW_LANG_C_plus_plus} | |
56 | {name "cu2"} | |
57 | {ranges ${ranges_label} sec_offset} | |
58 | {low_pc {[lindex $main_func 0]}} | |
59 | } { | |
60 | int_label: base_type { | |
61 | {byte_size 4 udata} | |
62 | {encoding @DW_ATE_signed} | |
63 | {name int} | |
64 | } | |
65 | } | |
66 | } | |
67 | ||
68 | ranges {is_64 [is_64_target]} { | |
69 | ranges_label: sequence { | |
a1945bd4 | 70 | range 0 [lindex $main_func 1] |
1c47ec3e TV |
71 | } |
72 | } | |
73 | } | |
74 | ||
75 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
76 | [list $srcfile $asm_file] {nodebug}] } { | |
77 | return -1 | |
78 | } | |
79 | ||
1c47ec3e TV |
80 | # Expand cu1. This will enqueue cu2. |
81 | gdb_test "ptype foo" "type = int" | |
82 | ||
83 | # Now check that cu2 has an address range starting at main. | |
84 | set cu2_blockvector_re \ | |
85 | [multi_line \ | |
86 | "Symtab for file cu2 at $hex" \ | |
87 | "Read from object file \[^\r\n\]*" \ | |
88 | "Language: c\\+\\+" \ | |
89 | "" \ | |
90 | "Blockvector:" \ | |
91 | "" \ | |
92 | "block #000, \[^\r\n\]* in ($hex)..$hex" \ | |
93 | ".*"] | |
94 | gdb_test_multiple "maint print symbols -objfile $binfile" "CU addr found" { | |
95 | -re -wrap $cu2_blockvector_re { | |
96 | set addr $expect_out(1,string) | |
97 | if { $addr eq "0x0" } { | |
98 | fail "$gdb_test_name (Found 0x0)" | |
99 | } else { | |
100 | gdb_test "info symbol $addr" "main in section .*" \ | |
101 | $gdb_test_name | |
102 | } | |
103 | } | |
104 | } |