* linespec.c (minsym_found): Advance to the next line if possible.
[external/binutils.git] / gdb / testsuite / gdb.base / prologue.exp
1 # Test for prologue skipping in minimal symbols with line info.
2 # Copyright 2007 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 2 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, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
17
18 if { [skip_cplus_tests] } { continue }
19
20 set testfile "prologue"
21 set srcfile ${testfile}.c
22 set binfile ${objdir}/${subdir}/${testfile}
23
24 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
25      untested prologue.exp
26      return -1
27 }
28
29 gdb_exit
30 gdb_start
31 gdb_reinitialize_dir $srcdir/$subdir
32 gdb_load ${binfile}
33
34 if ![runto_main] then {
35     perror "couldn't run to breakpoint"
36     continue
37 }
38
39 proc find_breakpoint_pc { sym } {
40     global decimal hex gdb_prompt
41
42     if { [gdb_breakpoint $sym temporary] } {
43         pass "setting breakpoint at $sym"
44     }
45
46     gdb_test "continue" "marker \\(.*\\) at.*" "continue to $sym"
47
48     set pc 0
49     set msg "reading \$pc: $sym"
50     gdb_test_multiple "print/x \$pc" $msg {
51         -re "\\\$$decimal = ($hex)\r\n$gdb_prompt $" {
52             set pc $expect_out(1,string)
53             pass $msg
54         }
55     }
56
57     return $pc
58 }
59
60 # GDB would skip the prologue differently when given a symbol with
61 # debug info than when given a minimal symbol from the symbol table.
62 # Make sure this is fixed.
63
64 set pc1 [find_breakpoint_pc "marker"]
65
66 set pc2 [find_breakpoint_pc "other"]
67
68 gdb_test "print $pc1 == $pc2" "\\\$$decimal = 1" "same pc from minimal symbol"