| # 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. |
| # |
| # Written by Jason Molenda (jmolenda@apple.com) |
| |
| load_lib mi-support.exp |
| set MIFLAGS "-i=mi1" |
| |
| gdb_exit |
| if [mi_gdb_start] { |
| continue |
| } |
| |
| set testfile "callfuncs" |
| 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." |
| } |
| |
| mi_delete_breakpoints |
| mi_gdb_reinitialize_dir $srcdir/$subdir |
| mi_gdb_load ${binfile} |
| |
| send_gdb "100-break-insert foo4\n" |
| gdb_expect { |
| -re "100\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\".*foo4.*\",file=\".*callfuncs.c\",line=\"($decimal)\",shlib=\"$binfile\",times=\"0\"\}\[\r\n\]+$mi_gdb_prompt$" { |
| pass "break-insert foo4" |
| } |
| -re ".*$mi_gdb_prompt$" { |
| fail "break-insert foo4" |
| } |
| timeout { |
| fail "(timeout) break-insert foo4" |
| } |
| } |
| |
| set stack_list_item "\{pc=\"$hex\",fp=\"$hex\"\[^\}\]*\}" |
| set stack_list_item_with_value "\{pc=\"\($hex\)\",fp=\"\($hex\)\"\[^\}\]*\}" |
| |
| mi_run_cmd |
| # The running part has been checked already by mi_run_cmd |
| |
| mi_get_bp_stopped "1" "\[01\]" "" "foo4" "callfuncs.c" ".*" "run to foo4" |
| |
| mi_gdb_test "103-mi-verify-command stack-list-frames-lite" {103\^done,name="stack-list-frames-lite",defined="true",implemented="true"} "Verify stack-list-frames-lite defined" |
| |
| mi_gdb_test "200-stack-list-frames-lite -limit" {200\^error,msg="mi_cmd_stack_list_frames_lite: No argument to -limit."} "-stack-list-frames-lite catch no argument to -limit error" |
| |
| mi_gdb_test "201-stack-list-frames-lite -names" {201\^error,msg="mi_cmd_stack_list_frames_lite: No argument to -names."} "-stack-list-frames-lite catch no argument to -names error" |
| |
| mi_gdb_test "202-stack-list-frames-lite -names -limit" {202\^error,msg="mi_cmd_stack_list_frames_lite: Invalid argument to -names."} "-stack-list-frames-lite catch no argument to -names -limit error" |
| |
| mi_gdb_test "104-stack-list-frames-lite -limit 500" \ |
| "104\\^done,frames=\\\[0=$stack_list_item,1=$stack_list_item,2=$stack_list_item,3=$stack_list_item,4=$stack_list_item\\\],valid=\"1\",count=\"5\"" "-stack-list-frames-lite -limit 500 works" |
| |
| mi_gdb_test "105-stack-info-depth" \ |
| "105\\^done,depth=\"5\"" "check stack depth is as expected" |
| |
| mi_gdb_test "106-stack-list-frames-lite -limit 2" \ |
| "106\\^done,frames=\\\[0=$stack_list_item,1=$stack_list_item\\\],valid=\"1\",count=\"5\"" "-stack-list-frames-lite -limit 2 works" |
| |
| # Go to a deeper function. |
| |
| |
| send_gdb "110-break-insert foo8\n" |
| gdb_expect { |
| -re "110\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\".*foo8.*\",file=\".*callfuncs.c\",line=\"($decimal)\",shlib=\"$binfile\",times=\"0\"\}\[\r\n\]+$mi_gdb_prompt$" { |
| pass "break-insert foo8" |
| } |
| -re ".*$mi_gdb_prompt$" { |
| fail "break-insert foo8" |
| } |
| timeout { |
| fail "(timeout) break-insert foo8" |
| } |
| } |
| |
| send_gdb "000-exec-continue\n" |
| |
| mi_get_bp_stopped "2" "\[01\]" "" "foo8" "callfuncs.c" ".*" "run to foo8" |
| |
| mi_gdb_test "114-stack-list-frames-lite -limit 500" \ |
| "114\\^done,frames=\\\[0=$stack_list_item,1=$stack_list_item,2=$stack_list_item,3=$stack_list_item,4=$stack_list_item,5=$stack_list_item,6=$stack_list_item,7=$stack_list_item,8=$stack_list_item\\\],valid=\"1\",count=\"9\"" "-stack-list-frames-lite -limit 500 works" |
| |
| mi_gdb_test "115-stack-info-depth" \ |
| "115\\^done,depth=\"9\"" "check stack depth is as expected" |
| |
| mi_gdb_test "116-stack-list-frames-lite -limit 2" \ |
| "116\\^done,frames=\\\[0=$stack_list_item,1=$stack_list_item\\\],valid=\"1\",count=\"9\"" "-stack-list-frames-lite -limit 2 works" |
| |
| mi_gdb_test "116-stack-list-frames-lite -limit 2 -names 1" \ |
| "116\\^done,frames=\\\[0=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo8\",has_debug=\"1\"\},1=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo7\",has_debug=\"1\"\}\\\],valid=\"1\",count=\"9\"" "-stack-list-frames-lite -limit 2 -names works" |
| |
| mi_gdb_test "117-stack-list-frames-lite -limit 7" \ |
| "117\\^done,frames=\\\[0=$stack_list_item,1=$stack_list_item,2=$stack_list_item,3=$stack_list_item,4=$stack_list_item,5=$stack_list_item,6=$stack_list_item\\\],valid=\"1\",count=\"9\"" "-stack-list-frames-lite -limit 7 works" |
| |
| mi_gdb_test "117-stack-list-frames-lite -names 1 -limit 7" \ |
| "117\\^done,frames=\\\[0=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo8\"\,has_debug=\"1\"},1=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo7\",has_debug=\"1\"\},2=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo6\",has_debug=\"1\"\},3=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo5\",has_debug=\"1\"\},4=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo4\",has_debug=\"1\"\},5=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo3\",has_debug=\"1\"\},6=\{pc=\"$hex\",fp=\"$hex\"\(,|,\[^,]*,\)func=\"foo2\",has_debug=\"1\"\}\\\],valid=\"1\",count=\"9\"" "-stack-list-frames-lite -names -limit 7 works" |
| |
| set slow_worked 0 |
| set fast_worked 0 |
| |
| send_gdb "120-stack-list-frames\n" |
| gdb_expect { |
| -re "120\\^done,stack=\\\[frame=\{level=\"0\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo8\",.*\},frame=\{level=\"1\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo7\",.*\},frame=\{level=\"2\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo6\",.*\},frame=\{level=\"3\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo5\",.*\},frame=\{level=\"4\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo4\",.*\},frame=\{level=\"5\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo3\",.*\},frame=\{level=\"6\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo2\",.*\},frame=\{level=\"7\",addr=\"($hex)\",fp=\"($hex)\",func=\"foo1\",.*\},frame=\{level=\"8\",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 < 8} {incr lev} { |
| set foonum [ expr 8 - $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=$stack_list_item_with_value,1=$stack_list_item_with_value,2=$stack_list_item_with_value,3=$stack_list_item_with_value,4=$stack_list_item_with_value,5=$stack_list_item_with_value,6=$stack_list_item_with_value,7=$stack_list_item_with_value,8=$stack_list_item_with_value\\\],valid=\"1\",count=\"9\"\[\r\n\]+$mi_gdb_prompt$" { |
| pass "get values from stack-list-frames-lite" |
| set wildnum 1 |
| for {set lev 0} {$lev < 8} {incr lev} { |
| set foonum [ expr 8 - $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 < 8} {incr lev} { |
| set foonum [ expr 8 - $lev ] |
| if {$foo_addr($foonum) == $foo_addr_lite($foonum)} { |
| pass "foo$foonum () address from stack-list-frames and stack-list-frames-lite matches" |
| } else { |
| fail "foo$foonum () address from stack-list-frames and stack-list-frames-lite matches - slow: $foo_addr($foonum) fast: $foo_addr_lite($foonum)" |
| } |
| if {$foo_fp($foonum) == $foo_fp_lite($foonum)} { |
| pass "foo$foonum () fp from stack-list-frames and stack-list-frames-lite matches" |
| } else { |
| fail "foo$foonum () fp from stack-list-frames and stack-list-frames-lite matches - slow: $foo_fp($foonum) fast: $foo_fp_lite($foonum)" |
| } |
| } |
| |
| 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 |
| |
| # Commented out because I can't get it to behave right - never gets to sigfoo8, |
| # although works as expected when exercised manually. |
| # |
| # Now try sigtramp stuff |
| # |
| #send_gdb "130-break-insert sigfoo8\n" |
| #gdb_expect { |
| # -re "130\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\".*sigfoo8.*\",file=\".*callfuncs.c\",line=\"($decimal)\",shlib=\"$binfile\",times=\"0\"\}\[\r\n\]+$mi_gdb_prompt$" { |
| # pass "break-insert sigfoo8" |
| # } |
| # -re ".*$mi_gdb_prompt$" { |
| # fail "break-insert sigfoo8" |
| # } |
| # timeout { |
| # fail "(timeout) break-insert sigfoo8" |
| # } |
| #} |
| # |
| # |
| #send_gdb "000-exec-continue\n" |
| # |
| #mi_get_bp_stopped "3" "\[01\]" "" "sigfoo8" "callfuncs.c" ".*" "run to sigfoo8" |
| # |
| #mi_gdb_test "131-stack-list-frames-lite -limit 8" \ |
| # "131\\^done,frames=\\\[0=$stack_list_item,1=$stack_list_item,2=$stack_list_item,3=$stack_list_item,4=$stack_list_item,5=$stack_list_item,6=$stack_list_item,7=$stack_list_item,8=$stack_list_item,9=$stack_list_item\\\],valid=\"1\",count=\"10\"" "-stack-list-frames-lite -limit 500 works" |
| # |
| #mi_gdb_test "132-stack-info-depth" \ |
| # "132\\^done,depth=\"10\"" "check stack depth is as expected" |
| # |
| #send_gdb "133-stack-list-frames 0 7\n" |
| #gdb_expect { |
| # -re "133\\^done,stack=\\\[frame=\{level=\"0\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo8\",.*\},frame=\{level=\"1\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo7\",.*\},frame=\{level=\"2\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo6\",.*\},frame=\{level=\"3\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo5\",.*\},frame=\{level=\"4\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo4\",.*\},frame=\{level=\"5\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo3\",.*\},frame=\{level=\"6\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo2\",.*\},frame=\{level=\"7\",addr=\"($hex)\",fp=\"($hex)\",func=\"sigfoo1\",.*\}\\\]\[\r\n\]+$mi_gdb_prompt$" { |
| # pass "get values from stack-list-frames" |
| # set wildnum 1 |
| # for {set lev 0} {$lev < 7} {incr lev} { |
| # set sigfoonum [ expr 8 - $lev ] |
| # set sigfoo_addr($sigfoonum) $expect_out($wildnum,string) |
| # incr wildnum |
| # set sigfoo_fp($sigfoonum) $expect_out($wildnum,string) |
| # incr wildnum |
| # } |
| # } |
| # -re ".*$mi_gdb_prompt$" { |
| # fail "get values from stack-list-frames" |
| # } |
| # timeout { |
| # fail "(timeout) get values from stack-list-frames" |
| # } |
| #} |
| # |
| #send_gdb "133-stack-list-frames-lite -limit 7\n" |
| #gdb_expect { |
| # -re "133\\^done,frames=\\\[0=$stack_list_item_with_value,1=$stack_list_item_with_value,2=$stack_list_item_with_value,3=$stack_list_item_with_value,4=$stack_list_item_with_value,5=$stack_list_item_with_value,6=$stack_list_item_with_value\\\],valid=\"1\",count=\"10\"\[\r\n\]+$mi_gdb_prompt$" { |
| # pass "get values from sigtramp stack-list-frames-lite" |
| # set wildnum 1 |
| # for {set lev 0} {$lev < 8} {incr lev} { |
| # set sigfoonum [ expr 8 - $lev ] |
| # set sigfoo_addr_lite($sigfoonum) $expect_out($wildnum,string) |
| # incr wildnum |
| # set sigfoo_fp_lite($sigfoonum) $expect_out($wildnum,string) |
| # incr wildnum |
| # } |
| # } |
| # -re ".*$mi_gdb_prompt$" { |
| # fail "get values from sigtramp stack-list-frames-lite" |
| # } |
| # timeout { |
| # fail "(timeout) get values from sigtramp stack-list-frames-lite" |
| # } |
| #} |
| # |
| #for {set lev 0} {$lev < 7} {incr lev} { |
| # set sigfoonum [ expr 8 - $lev ] |
| # if {$sigfoo_addr($sigfoonum) == $sigfoo_addr_lite($sigfoonum)} { |
| # pass "sigfoo$sigfoonum () address from stack-list-frames and stack-list-frames-lite matches" |
| # } else { |
| # fail "sigfoo$sigfoonum () address from stack-list-frames and stack-list-frames-lite matches" |
| # } |
| # if {$sigfoo_fp($sigfoonum) == $sigfoo_fp_lite($sigfoonum)} { |
| # pass "sigfoo$sigfoonum () fp from stack-list-frames and stack-list-frames-lite matches" |
| # } else { |
| # fail "sigfoo$sigfoonum () fp from stack-list-frames and stack-list-frames-lite matches" |
| # } |
| #} |
| # |