return -1
}
+# Not all of the lines of code near the start of main are executed for
+# every machine. Also, optimization may reorder some of the lines.
+# So all we do is try to step or next over everything until we get
+# to a line that we know is always executed.
+
+proc do_steps_and_nexts {} {
+ global prompt
+
+ for {set count 0} {$count < 20} {incr count} {
+ send "list\n"
+ expect {
+ -re ".*symarg = NULL.*$prompt $" {
+ set description "step over symarg initialization"
+ set command "step"
+ }
+ -re ".*execarg = NULL.*$prompt $" {
+ set description "step over execarg initialization"
+ set command "step"
+ }
+ -re ".*corearg = NULL.*$prompt $" {
+ set description "step over corearg initialization"
+ set command "step"
+ }
+ -re ".*cdarg = NULL.*$prompt $" {
+ set description "step over cdarg initialization"
+ set command "step"
+ }
+ -re ".*ttyarg = NULL.*$prompt $" {
+ set description "step over ttyarg initialization"
+ set command "step"
+ }
+ -re ".*time_at_startup = get_run_time.*$prompt $" {
+ set description "next over get_run_time and everything it calls"
+ set command "next"
+ }
+ -re ".*START_PROGRESS.*$prompt $" {
+ set description "next over START_PROGRESS and everything it calls"
+ set command "next"
+ }
+ -re ".*mac_init.*$prompt $" {
+ set description "next over mac_init and everything it calls"
+ set command "next"
+ }
+ -re ".*init_malloc.*$prompt $" {
+ set description "next over init_malloc and everything it calls"
+ set command "next"
+ }
+ -re ".*SET_TOP_LEVEL.*$prompt $" {
+ set description "next over SET_TOP_LEVEL call"
+ set command "next"
+ }
+ -re ".*cmdsize = 1.*$prompt $" {
+ set description "step over cmdsize initialization"
+ set command "next"
+ }
+ -re ".*cmdarg = .* xmalloc.*$prompt $" {
+ set description "next over cmdarg initialization via xmalloc"
+ set command "next"
+ }
+ -re ".*ncmd = 0.*$prompt $" {
+ set description "next over ncmd initialization"
+ set command "next"
+ }
+ -re ".*dirsize = 1.*$prompt $" {
+ set description "next over dirsize initialization"
+ set command "next"
+ }
+ -re ".*dirarg = .* xmalloc.*$prompt $" {
+ return
+ }
+ -re "\[ \t\]+\{\r\n$prompt $" {
+ setup_xfail "mips-*-irix5*"
+ fail "$description ended up at odd location"
+ }
+ -re ".*main.c.*No such file or directory" {
+ setup_xfail "rs6000-*-aix3*"
+ fail "must be able to list source lines"
+ return
+ }
+ default {
+ fail "unknown source line near main"
+ return
+ }
+ }
+ send "$command\n"
+ expect {
+ -re ".*No such file or directory.\r\n$prompt $" {
+ fail "$description (no source available)"
+ }
+ -re ".*A file or directory .* does not exist..\r\n$prompt $" {
+ fail "$description (no source available)"
+ }
+ -re ".*$prompt $" {
+ pass "$description"
+ }
+ timeout {
+ fail "$description (timeout)"
+ }
+ }
+ }
+}
+
proc test_with_self {} {
global prompt
global tool
"set interrupt character in test_with_self"
}
+ # FIXME: If we put this after the run to main, the first list
+ # command doesn't print the same line as the current line where
+ # gdb is stopped.
+ send "set listsize 1\n" ; expect -re "$prompt $"
+
# run yourself
# It may take a very long time for the inferior gdb to start (lynx),
# so we bump it back up for the duration of this command.
timeout { fail "(timeout) printed version" }
}
- # lets do a few single steps
-
- set description "step over symarg initialization"
- send "step\n"
- expect {
- -re "char \[*\]+execarg = NULL;.*$prompt $" {
- pass "$description"
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- timeout {
- fail "$description (timeout)"
- }
- }
+ do_steps_and_nexts
- set description "step over execarg initialization"
- send "step\n"
+ set description "print a string"
+ send "print \"foo\"\n"
expect {
- -re "char \[*\]corearg = NULL;.*$prompt $" {
+ -re ".\[0-9\]+ = \"foo\".*$prompt $" {
pass "$description"
}
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
-re ".*$prompt $" {
fail "$description"
}
}
}
- set description "step over corearg initialization"
- send "step\n"
- expect {
- -re "char \[*\]cdarg = NULL;.*$prompt $" {
- pass "$description"
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- timeout {
- fail "$description (timeout)"
- }
- }
-
- set ttyarg_in_delay_slot 0
- set description "step over cdarg initialization"
+ # do_steps_and_nexts left us ready to execute an xmalloc call,
+ # so give that a try.
+ # If we don't actually enter the xmalloc call when we give a
+ # step command that seems like a genuine bug. It seems to happen
+ # on most RISC processors.
+ setup_xfail "alpha-*-*" "hppa*-*-*" "mips-*-*"
+ set description "step into xmalloc call"
send "step\n"
expect {
- -re "char \[*\]ttyarg = NULL;.*$prompt $" {
- pass "$description"
- }
- -re ".*time_at_startup = get_run_time .*$prompt $" {
+ -re "xmalloc.*size=.*at.*utils.c.*$prompt $" {
pass "$description"
- set ttyarg_in_delay_slot 1
}
-re ".*No such file or directory.\r\n$prompt $" {
pass "$description (no source available)"
}
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
+ -re "A file or directory .* does not exist..\r\n$prompt $" {
pass "$description (no source available)"
}
-re ".*$prompt $" {
fail "$description (timeout)"
}
}
-
- set description "step over ttyarg initialization"
- if $ttyarg_in_delay_slot==1 then {
- pass "$description (in delay slot)"
- } else {
- send "step\n"
- expect {
- -re ".*time_at_startup = get_run_time .*$prompt $" {
- pass "$description"
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- timeout {
- fail "$description (timeout)"
- }
- }
- }
-
- # now jump over a few functions
-
- set description "next over get_run_time and everything it calls"
- set got_over_get_run_time 0
- send "next\n"
- expect {
- -re ".*init_malloc.*$prompt $" {
- pass "$description"
- set got_over_get_run_time 1
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- set got_over_get_run_time 1
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- set got_over_get_run_time 1
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- timeout {
- fail "$description (timeout)"
- }
- }
- # -re "if \(setmp \(to_top_level\)\).*$prompt $" { pass "first next" }
-
- if $got_over_get_run_time then {
- set description "next over init_malloc and everything it calls"
- send "next\n"
- expect {
- -re "if.*SET_TOP_LEVEL.*$prompt $" {
- pass "$description"
- }
- -re "i = .*count.*$prompt $" {
- pass "$description"
- set description "next over ALIGN_STACK_ON_STARTUP code"
- send "next\n"
- expect {
- -re "if.*i != 0.*$prompt $" {
- pass "$description"
- send "next\n"
- expect {
- -re "if.*SET_TOP_LEVEL.*$prompt $" {
- pass "$description"
- }
- -re "alloca.*$prompt $" {
- send "next\n"
- expect {
- -re "if.*level.*$prompt $" {
- pass "$description"
- }
- }
- }
- }
- }
- }
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- default {
- fail "$description (timeout or eof)"
- }
- }
- }
-
- set next_ok 1
- set need_to_step_over_cmdsize 1
- set description "next over SET_TOP_LEVEL call"
- send "next\n"
- expect {
- -re "cmdsize = 1;.*$prompt $" {
- pass "$description"
- }
- -re "cmdarg = .*xmalloc.*$prompt $" {
- # This can happen in optimized code where the "cmdsize = 1" line
- # is basically removed.
- pass "$description"
- set need_to_step_over_cmdsize 0
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*$prompt $" {
- fail "$description"
- set next_ok 0
- }
- timeout {
- fail "$description (timeout)"
- set next_ok 0
- }
- }
-
- set description "print a string"
- send "print \"foo\"\n"
- expect {
- -re ".\[0-9\]+ = \"foo\".*$prompt $" {
- pass "$description"
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- timeout {
- fail "$description (timeout)"
- }
- }
-
- if $need_to_step_over_cmdsize {
- set description "step over cmdsize initialization"
- send "step\n"
- expect {
- -re "cmdarg = .*xmalloc.*$prompt $" {
- pass "$description"
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- timeout {
- fail "$description (timeout)"
- }
- }
- }
-
- # and another step for good luck
- if $next_ok {
- set description "step into xmalloc call"
- send "step\n"
- expect {
- -re "xmalloc.*size=.*at.*utils.c.*$prompt $" {
- pass "$description"
- }
- -re ".*No such file or directory.\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re "A file or directory .* does not exist..\r\n$prompt $" {
- pass "$description (no source available)"
- }
- -re ".*$prompt $" {
- fail "$description"
- }
- timeout {
- fail "$description (timeout)"
- }
- }
- }
# start the "xgdb" process
send "continue\n"
# This fails on some linux systems for unknown reasons. On the
# systems where it fails, sometimes it works fine when run manually.
# The testsuite failures may not be limited to just aout systems.
- setup_xfail "i*86-*-linuxaout"
+ setup_xfail "i*86-*-linuxaout" "hppa*-*-hpux*"
set description "backtrace through signal handler"
send "backtrace\n"
expect {