blob: e2d7aa43d2de08d6a7d361d086f00ed029943d6b [file] [log] [blame]
# Copyright (C) 2004 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.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# Test xcode's stack-list-frames-lite command with a signal trampoline on
# the stack.
set timeout 30
set prms_id 0
set bug_id 0
load_lib mi-support.exp
set testfile "inf-call-interrupt-notsleep"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
# Start with a fresh gdb
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
gdb_test "break $srcfile:[gdb_get_line_number "This is a good place for a breakpoint"]" "Breakpoint 1 at $hex: file.*, line.*\\." "Set breakpoint on line 'This is a good place for a breakpoint'"
gdb_test "run" "Starting program: $binfile *\r\n\Reading symbols for shared libraries \(\[.+\]\)+ done.*Breakpoint 1, subroutine6.*" "run to breakpoint in subroutine6"
send_gdb "set interpreter mi1\n"
mi_gdb_test "104-stack-list-frames-lite -limit 500" \
"104\\^done,frames=\\\[0=\{pc=\"$hex\",fp=\"$hex\"\},1=\{pc=\"$hex\",fp=\"$hex\"\},2=\{pc=\"$hex\",fp=\"$hex\"\},3=\{pc=\"$hex\",fp=\"$hex\"\},4=\{pc=\"$hex\",fp=\"$hex\"\}.*\\\],valid=\"1\",count=\"11\".*" "-stack-list-frames-lite -limit 500 works"
set slow_worked 0
set fast_worked 0
mi_gdb_test "105-stack-info-depth" \
"105\\^done,depth=\"11\".*" "check stack depth is as expected"
#-re "120\\^done,stack=\\\[frame=\{level=\"0\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine6\",.*\},frame=\{level=\"1\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine5\",.*\},frame=\{level=\"2\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine4\",.*\},frame=\{level=\"3\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine3\",.*\},frame=\{level=\"4\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine2\",.*\},frame=\{level=\"5\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine1\",.*\},frame=\{level=\"6\",addr=\"($hex)\",fp=\"($hex)\",func=\"handler\",.*\},frame=\{level=\"7\",addr=\"($hex)\",fp=\"($hex)\",func=\".*signal handler called.*\",.*\},frame=\{level=\"8\",addr=\"($hex)\",fp=\"($hex)\",func=\"superroutine2\",.*\},frame=\{level=\"9\",addr=\"($hex)\",fp=\"($hex)\",func=\"superroutine1\",.*\},frame=\{level=\"10\",addr=\"($hex)\",fp=\"($hex)\",func=\"main\",.*\}\\\]\[\r\n\]+$mi_gdb_prompt$" {
send_gdb "120-stack-list-frames\n"
gdb_expect {
-re "120\\^done,stack=\\\[frame=\{level=\"0\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine6\",.*\},frame=\{level=\"1\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine5\",.*\},frame=\{level=\"2\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine4\",.*\},frame=\{level=\"3\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine3\",.*\},frame=\{level=\"4\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine2\",.*\},frame=\{level=\"5\",addr=\"($hex)\",fp=\"($hex)\",func=\"subroutine1\",.*\},frame=\{level=\"6\",addr=\"($hex)\",fp=\"($hex)\",func=\"handler\",.*\},frame=\{level=\"7\",addr=\"($hex)\",fp=\"($hex)\",func=\"<signal handler called>\"\},frame=\{level=\"8\",addr=\"($hex)\",fp=\"($hex)\",func=\"superroutine2\",.*\},frame=\{level=\"9\",addr=\"($hex)\",fp=\"($hex)\",func=\"superroutine1\",.*\},frame=\{level=\"10\",addr=\"($hex)\",fp=\"($hex)\",func=\"main\",.*\}\\\].*\[\r\n\]+$mi_gdb_prompt$" {
pass "get values from stack-list-frames"
set wildnum 1
for {set lev 0} {$lev < 10} {incr lev} {
set foonum [ expr 10 - $lev ]
set foo_addr($foonum) $expect_out($wildnum,string)
incr wildnum
set foo_fp($foonum) $expect_out($wildnum,string)
incr wildnum
}
set main_addr $expect_out($wildnum,string)
incr wildnum
set main_fp $expect_out($wildnum,string)
incr wildnum
set slow_worked 1
}
-re ".*$mi_gdb_prompt$" {
fail "get values from stack-list-frames"
}
timeout {
fail "(timeout) get values from stack-list-frames"
}
}
send_gdb "121-stack-list-frames-lite\n"
gdb_expect {
-re "121\\^done,frames=\\\[0=\{pc=\"($hex)\",fp=\"($hex)\"\},1=\{pc=\"($hex)\",fp=\"($hex)\"\},2=\{pc=\"($hex)\",fp=\"($hex)\"\},3=\{pc=\"($hex)\",fp=\"($hex)\"\},4=\{pc=\"($hex)\",fp=\"($hex)\"\},5=\{pc=\"($hex)\",fp=\"($hex)\"\},6=\{pc=\"($hex)\",fp=\"($hex)\"\},7=\{pc=\"($hex)\",fp=\"($hex)\"\},8=\{pc=\"($hex)\",fp=\"($hex)\"\},9=\{pc=\"($hex)\",fp=\"($hex)\"\},10=\{pc=\"($hex)\",fp=\"($hex)\"\}.*\\\],valid=\"1\",count=\"11\".*\[\r\n\]+$mi_gdb_prompt$" {
pass "get values from stack-list-frames-lite"
set wildnum 1
for {set lev 0} {$lev < 10} {incr lev} {
set foonum [ expr 10 - $lev ]
set foo_addr_lite($foonum) $expect_out($wildnum,string)
incr wildnum
set foo_fp_lite($foonum) $expect_out($wildnum,string)
incr wildnum
}
set main_addr_lite $expect_out($wildnum,string)
incr wildnum
set main_fp_lite $expect_out($wildnum,string)
incr wildnum
set fast_worked 1
}
-re ".*$mi_gdb_prompt$" {
fail "get values from stack-list-frames-lite"
}
timeout {
fail "(timeout) get values from stack-list-frames-lite"
}
}
if { $slow_worked && $fast_worked } {
for {set lev 0} {$lev < 10} {incr lev} {
set foonum [ expr 10 - $lev ]
if {$foo_addr($foonum) == $foo_addr_lite($foonum)} {
pass "frame $lev address from stack-list-frames and stack-list-frames-lite matches"
} else {
fail "frame $lev address from stack-list-frames and stack-list-frames-lite matches"
}
# The sigtramp frame itself will not have an FP that matches for reasons
# surpassing my own caring. The _sigtramp call is at frame 7.
if {$lev == 7} {
continue
}
if {$foo_fp($foonum) == $foo_fp_lite($foonum)} {
pass "frame $lev fp from stack-list-frames and stack-list-frames-lite matches"
} else {
fail "frame $lev fp from stack-list-frames and stack-list-frames-lite matches"
}
}
if {$main_addr == $main_addr_lite} {
pass "main () address from stack-list-frames and stack-list-frames-lite matches"
} else {
fail "main () address from stack-list-frames and stack-list-frames-lite matches"
}
if {$main_fp == $main_fp_lite} {
pass "main () fp from stack-list-frames and stack-list-frames-lite matches"
} else {
fail "main () fp from stack-list-frames and stack-list-frames-lite matches"
}
}
mi_gdb_exit
return 0