Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dw2-inline-stepping.exp
blobdaf1893f04e39aaa0a0cbc90a479d195f7cc5c5b
1 # Copyright 2019-2024 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 # This test shows the importance of not corrupting the order of line
17 # table information.  When multiple lines are given for the same
18 # address the compiler usually lists these in the order in which we
19 # would expect to encounter them.  When stepping through nested inline
20 # frames the last line given for an address is assumed by GDB to be
21 # the most inner frame, and this is what GDB displays.
23 # If we corrupt the order of the line table entries then GDB will
24 # display the wrong line as being the inner most frame.
26 load_lib dwarf.exp
28 # This test can only be run on targets which support DWARF-2 and use gas.
29 require dwarf2_support
31 # The .c files use __attribute__.
32 require is_c_compiler_gcc
34 standard_testfile .c .S
36 set asm_file [standard_output_file $srcfile2]
37 Dwarf::assemble $asm_file {
38     global srcdir subdir srcfile srcfile2
39     declare_labels ranges_label lines_label foo_prog
41     lassign [function_range main [list ${srcdir}/${subdir}/$srcfile]] \
42         main_start main_len
43     set main_end "$main_start + $main_len"
44     lassign [function_range bar [list ${srcdir}/${subdir}/$srcfile]] \
45         bar_start bar_len
46     set bar_end "$bar_start + $bar_len"
48     set call_line [gdb_get_line_number "main call foo"]
50     cu {} {
51         compile_unit {
52             {language @DW_LANG_C}
53             {name dw2-inline-stepping.c}
54             {low_pc 0 addr}
55             {stmt_list ${lines_label} DW_FORM_sec_offset}
56             {ranges ${ranges_label} DW_FORM_sec_offset}
57         } {
58             subprogram {
59                 {external 1 flag}
60                 {name bar}
61                 {low_pc $bar_start addr}
62                 {high_pc "$bar_start + $bar_len" addr}
63             }
64             foo_prog: subprogram {
65                 {name foo}
66                 {inline 3 data1}
67             }
68             subprogram {
69                 {external 1 flag}
70                 {name main}
71                 {low_pc $main_start addr}
72                 {high_pc "$main_start + $main_len" addr}
73             } {
74                 inlined_subroutine {
75                     {abstract_origin %$foo_prog}
76                     {low_pc main_label2 addr}
77                     {high_pc main_label3 addr}
78                     {call_file 1 data1}
79                     {call_line $call_line data1}
80                 }
81             }
82         }
83     }
85     lines {version 2} lines_label {
86         include_dir "${srcdir}/${subdir}"
87         file_name "$srcfile" 1
89         program {
90             DW_LNE_set_address $main_start
91             line [gdb_get_line_number "main prologue"]
92             DW_LNS_copy
93             DW_LNE_set_address main_label
94             line [gdb_get_line_number "main set global_var"]
95             DW_LNS_copy
96             DW_LNE_set_address main_label2
97             line [gdb_get_line_number "main call foo"]
98             DW_LNS_copy
99             DW_LNE_set_address main_label2
100             line [gdb_get_line_number "foo call bar"]
101             DW_LNS_copy
102             DW_LNE_set_address $main_end
103             DW_LNE_end_sequence
105             DW_LNE_set_address $bar_start
106             line [gdb_get_line_number "bar prologue"]
107             DW_LNS_copy
108             DW_LNE_set_address bar_label
109             line [gdb_get_line_number "bar return global_var"]
110             DW_LNS_copy
111             DW_LNE_set_address $bar_end
112             DW_LNE_end_sequence
113         }
114     }
116     ranges {is_64 [is_64_target]} {
117         ranges_label: sequence {
118             range ${main_start} ${main_end}
119             range ${bar_start} ${bar_end}
120         }
121     }
124 if { [prepare_for_testing "failed to prepare" ${testfile} \
125           [list $srcfile $asm_file] {nodebug}] } {
126     return -1
129 if ![runto_main] {
130     return -1
133 set patterns [list "main call foo" \
134                   "foo call bar" \
135                   "bar return global_var"]
136 foreach p $patterns {
137     gdb_test "step" "/\\* $p \\*/" \
138         "step to '$p'"