Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-ranges-psym.exp
CommitLineData
b811d2c2 1# Copyright 2018-2020 Free Software Foundation, Inc.
05caa1d2
TT
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# Test that psymbols are made when DW_AT_ranges is used.
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
26if [get_compiler_info] {
27 return -1
28}
29if !$gcc_compiled {
30 unsupported "gcc required for this test"
31 return 0
32}
33
34standard_testfile dw2-ranges-main.c dw2-ranges-psym.c dw2-ranges-psym-dw.S
35
36# We need to know the size of integer and address types in order to
37# write some of the debugging info we'd like to generate.
38#
39# For that, we ask GDB by debugging our test program. Any program
40# would do, but since we already have it specifically for this
41# testcase, might as well use that.
42
43if { [prepare_for_testing "failed to prepare" ${testfile} \
44 [list ${srcfile} ${srcfile2}]] } {
45 return -1
46}
47
48set asm_file [standard_output_file $srcfile3]
49Dwarf::assemble $asm_file {
50 global srcdir subdir srcfile srcfile2
51 declare_labels integer_label volatile_label func_ranges_label cu_ranges_label
52 set int_size [get_sizeof "int" 4]
53
54 # Find start address and length for our functions.
55 set sources [list ${srcdir}/${subdir}/$srcfile ${srcdir}/${subdir}/$srcfile2]
56
57 lassign [function_range foo $sources] \
58 foo_start foo_len
59 set foo_end "$foo_start + $foo_len"
60
61 lassign [function_range foo_low $sources] \
62 foo_low_start foo_low_len
63 set foo_low_end "$foo_low_start + $foo_low_len"
64
65 lassign [function_range bar $sources] \
66 bar_start bar_len
67 set bar_end "$bar_start + $bar_len"
68
69 lassign [function_range baz $sources] \
70 baz_start baz_len
71 set baz_end "$baz_start + $baz_len"
72
73 cu {} {
74 compile_unit {
75 {language @DW_LANG_C}
76 {name dw-ranges-psym.c}
77 {low_pc 0 addr}
78 {ranges ${cu_ranges_label} DW_FORM_sec_offset}
79 } {
80 integer_label: DW_TAG_base_type {
81 {DW_AT_byte_size $int_size DW_FORM_sdata}
82 {DW_AT_encoding @DW_ATE_signed}
83 {DW_AT_name integer}
84 }
85 volatile_label: DW_TAG_volatile_type {
86 {type :$integer_label}
87 }
88 subprogram {
89 {external 1 flag}
90 {name someothername}
91 {ranges ${func_ranges_label} DW_FORM_sec_offset}
92 }
93 subprogram {
94 {external 1 flag}
95 {name bar}
96 {low_pc $bar_start addr}
97 {high_pc $bar_len DW_FORM_data4}
98 }
99 subprogram {
100 {external 1 flag}
101 {name baz}
102 {low_pc $baz_start addr}
103 {high_pc $baz_len DW_FORM_data4}
104 }
105 }
106 }
107
108 # Generate ranges data.
109 ranges {is_64 [is_64_target]} {
110 func_ranges_label: sequence {
111 {range {$foo_start } $foo_end}
112 {range {$foo_low_start} $foo_low_end}
113 }
114 cu_ranges_label: sequence {
115 {range {$foo_start } $foo_end}
116 {range {$foo_low_start} $foo_low_end}
117 {range {$bar_start} $bar_end}
118 {range {$baz_start} $baz_end}
119 }
120 }
121}
122
123if { [prepare_for_testing "failed to prepare" ${testfile} \
124 [list $srcfile $srcfile2 $asm_file] {nodebug}] } {
125 return -1
126}
127
128if ![runto_main] {
129 return -1
130}
131
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.
136gdb_test "break someothername" \
d1e36019 137 "Breakpoint.*at.*"
This page took 0.128206 seconds and 4 git commands to generate.