blob: 7a474abf8dd2046b0100486a28e4a2c6a3563404 [file] [log] [blame]
# Copyright 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if $tracelevel then {
strace $tracelevel
}
#
# test running programs
#
set prms_id 0
set bug_id 0
set testfile "nested-inlines"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if ![istarget "powerpc-apple-darwin*"] {
verbose "Skipping PPC-specific inline test."
return
}
set additional_flags "additional_flags=-O3"
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
if {$debug_default_format_is_dwarf == 0 } then {
return;
}
# Start with a fresh gdb
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_file_cmd "${binfile}"
send_gdb "set width 0\n"
gdb_expect -re "$gdb_prompt $"
gdb_test "break main" "Breakpoint 1 at $hex: file.*, line 12\\." "Set breakpoint at main"
gdb_test "break nested-inlines.c:72" "Breakpoint 2 at $hex: file.*, line 72.*" "Set breakpoint at end of baz"
gdb_test "break nested-inlines.c:50" "Breakpoint 6 at $hex: file.*, line 50.*" "Set breakpoint at end of bar"
gdb_test "run" "Starting program: $binfile *\r\n\Reading symbols for shared libraries \(\[.+\]\)+ done.*Breakpoint 1, main.*" "continue to breakpoint in main()"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
# PLAN A
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "step" ".*z = baz.*" "Step into second inlined function (bar)"
gdb_test "step" ".*62.*buffer = .*" "Step into third inlined function (baz)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (1)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (2)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (3)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (4)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (5)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (6)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (7)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (8)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (9)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (10)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (11)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (12)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (13)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (14)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (15)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (16)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (17)"
gdb_test "next" "baz.*inlined.*" "stepping through baz (18)"
gdb_test "step" "bar.*inlined.*" "stepping out of (inlined) baz back to bar"
gdb_test "next" "bar.*inlined.*" "stepping through bar (1)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (2)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (3)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (4)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (5)"
gdb_test "next" ".*" "stepping through bar (6)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (7)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (8)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (9)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (10)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (11)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (12)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (13)"
gdb_test "next" "bar.*inlined.*" "stepping through bar (14)"
# gdb_test "next" "bar.*inlined.*" "stepping through bar (15)"
# gdb_test "next" "bar.*inlined.*" "stepping through bar (16)"
# gdb_test "next" "bar.*inlined.*" "stepping through bar (17)"
# gdb_test "next" "bar.*inlined.*" "stepping through bar (18)"
# gdb_test "next" "bar.*inlined.*" "stepping through bar (19)"
gdb_test "continue" ".*Breakpoint .*, bar \\\[inlined\\\].*50.*" "Continue to end of bar"
gdb_test "step" "foo.*inlined.*" "stepping out of (inlined) bar back to foo"
gdb_test "next" "The squareroot of.*" "stepping out of (inlined) foo back to main"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN B
gdb_test "delete 2 3 4 5 6 7 8" ".*" "Delete all breakpoints except first one in main"
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "next" ".*We made it all the way to the top.*" "Next over inlined subroutine (foo)."
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN C
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "finish" ".*fprintf.*We made it all the way to the top.*" "Finish out of inlined function (foo)"
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN D
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "next" ".*" "Next over inlined function (bar)"
gdb_test "finish" ".*fprintf.*We made it all the way to the top.*" "Finish out of inlined function (foo)"
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN E
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "step" ".*z = baz.*" "Step into second inlined function (bar)"
gdb_test "finish" ".*foo.*inlined.*sqrt.*" "Finish out of inlined function (bar)"
gdb_test "finish" ".*fprintf.*We made it all the way to the top.*" "Finish out of inlined function (foo)"
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN F
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "step" ".*z = baz.*" "Step into second inlined function (bar)"
gdb_test "next" ".*" "Next over inlined function (baz)"
gdb_test "next" ".*bar.*inlined.*" "Next in bar"
gdb_test "finish" ".*foo.*inlined.*sqrt.*" "Finish out of inlined function (bar)"
gdb_test "finish" ".*fprintf.*We made it all the way to the top.*" "Finish out of inlined function (foo)"
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN G
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "step" ".*z = baz.*" "Step into second inlined function (bar)"
gdb_test "step" ".*62.*buffer = .*" "Step into third inlined function (baz)"
gdb_test "finish" ".*bar.*inlined.*n = z.*" "Finish out of inlined function (baz)"
gdb_test "finish" ".*foo.*inlined.*sqrt.*" "Finish out of inlined function (bar)"
gdb_test "finish" ".*fprintf.*We made it all the way to the top.*" "Finish out of inlined function (foo)"
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN H
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "step" ".*z = baz.*" "Step into second inlined function (bar)"
gdb_test "step" ".*62.*buffer = .*" "Step into third inlined function (baz)"
gdb_test "next" ".*baz.*inlined.*fprintf.*" "Next in baz"
gdb_test "finish" ".*bar.*inlined.*n = z.*" "Finish out of inlined function (baz)"
gdb_test "next" ".*bar.*inlined.*for .*" "Next in bar"
gdb_test "finish" ".*foo.*inlined.*sqrt.*" "Finish out of inlined function (bar)"
gdb_test "finish" ".*fprintf.*We made it all the way to the top.*" "Finish out of inlined function (foo)"
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN I
gdb_test "run" "Starting program:.*Breakpoint 1.*" "Re-starting program"
gdb_test "next" ".*foo ().*" "Step to first inlined call site"
gdb_test "step" ".*y = bar.*" "Step into first inlined function (foo)"
gdb_test "step" ".*z = baz.*" "Step into second inlined function (bar)"
gdb_test "step" ".*62.*buffer = .*" "Step into third inlined function (baz)"
# gdb_test "up" ".*bar.*inlined.*" "up (to bar)"
# gdb_test "up" ".*foo.*inlined.*" "up (to foo)"
# gdb_test "up" ".*main.*" "up (to main)"
# gdb_test "down" ".*foo.*inlined.*" "down (to foo)"
# gdb_test "down" ".*bar.*inlined.*" "down (to bar)"
# gdb_test "up" ".*foo.*inlined.*" "up (to foo)"
# gdb_test "down" ".*bar.*inlined.*" "down (to bar)"
# gdb_test "down" ".*baz.*inlined.*" "down (to baz)"
# gdb_test "up" ".*bar.*inlined.*" "up (to bar)"
# gdb_test "down" ".*baz.*inlined.*" "down (to baz)"
# gdb_test "where" ".*Function baz was inlined into function bar.*Function bar was inlined into function foo.*Function foo was inlined into function main.*nested-inlines.c:14.*" "Where in baz"
gdb_test "finish" ".*bar.*inlined.*n = z.*" "Finish out of inlined function (baz)"
gdb_test "where" ".*" "Where in bar"
gdb_test "finish" ".*foo.*inlined.*sqrt.*" "Finish out of inlined function (bar)"
gdb_test "where" ".*" "Where in foo"
gdb_test "finish" ".*fprintf.*We made it all the way to the top.*" "Finish out of inlined function (foo)"
gdb_test "where" ".*" "Where in main"
gdb_test "next" "We made it.*" "Next (1)"
gdb_test "continue" ".*Program exited normally.*" "Finish program"
# PLAN J
gdb_test "disable 1" ".*" "Disable breakpoint at main."
gdb_test "break bar" "Breakpoint 9 at $hex: file.*, line.*Breakpoint 10 \\(inlined bar\\).*Breakpoint 11 \\(inlined bar\\).*" "Set breakpoints at inlined function bar"
gdb_test "run" "Starting program: $binfile *\r\n\.*Breakpoint .*, bar.*inlined.*" "continue to breakpoint in bar"
gdb_test "next" ".*n = z.*" "Step over inlined function (baz)"
gdb_test "finish" ".*foo.*inlined.*sqrt.*" "Finish out of inlined function bar"
gdb_test "next" "The squareroot of.*" "stepping out of (inlined) foo back to main"
gdb_exit
return 0