xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/prologue.exp (revision 8e33eff89e26cf71871ead62f0d5063e1313c33a)
1# Test for prologue skipping in minimal symbols with line info.
2# Copyright 2007-2023 Free Software Foundation, Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17if { [skip_cplus_tests] } {  return }
18
19standard_testfile .c
20
21if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
22     untested "failed to compile"
23     return -1
24}
25
26clean_restart ${binfile}
27
28if {![runto_main]} {
29    return
30}
31
32proc find_breakpoint_pc { sym } {
33    global decimal hex gdb_prompt
34
35    if { [gdb_breakpoint $sym temporary] } {
36	pass "setting breakpoint at $sym"
37    }
38
39    gdb_test "continue" "marker \\(.*\\) at.*" "continue to $sym"
40
41    set pc 0
42    set msg "reading \$pc: $sym"
43    gdb_test_multiple "print/x \$pc" $msg {
44	-re "\\\$$decimal = ($hex)\r\n$gdb_prompt $" {
45	    set pc $expect_out(1,string)
46	    pass $msg
47	}
48    }
49
50    return $pc
51}
52
53# GDB would skip the prologue differently when given a symbol with
54# debug info than when given a minimal symbol from the symbol table.
55# Make sure this is fixed.
56
57set pc1 [find_breakpoint_pc "marker"]
58
59set pc2 [find_breakpoint_pc "other"]
60
61gdb_test "print /d $pc1 == $pc2" "\\\$$decimal = 1" "same pc from minimal symbol"
62