* lib/gdb.exp(gdb_step_for_stub): New function.

(gdb_run_cmd): Look for gdb,do_reload_on_run target feature--if it
	exists, reload the executable and do a "continue" instead of
	doing a jump.
	(runto_main): Use gdb_step_for_stub.

	* gdb.base/break.exp: Use gdb_step_for_stub. Also, rename certain
 	tests to have unique names.
	* gdb.base/callfuncs.exp: Ditto.
	* gdb.base/commands.exp: Ditto.
	* gdb.base/default.exp: Ditto.
	* gdb.base/help.exp: Ditto.
	* gdb.base/list.exp: Ditto.
	* gdb.base/opaque.exp: Ditto.
	* gdb.base/printcmds.exp: Ditto. Use a loop to emit multiple
	similar tests.

	* gdb.base/setshow.c: Add set_debug_traps/breakpoint calls.
	* gdb.c++/cplusfuncs.cc: Ditto.
	* gdb.c++/virtfunc.cc: Ditto.

	* config/monitor.exp: Keep track of the last file we saw, rather
	than trying to get the info from gdb.

	* gdb.fortran/types.exp: Move comment to previous line.

Fixes for TCL8 miscellaneous problems, plus other changes.
This commit is contained in:
Bob Manson 1997-09-13 00:08:05 +00:00
parent eb16c04c8c
commit fc75bd970a
2 changed files with 151 additions and 58 deletions

View File

@ -37,8 +37,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
# built the second test case since we can't use prototypes
warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DNO_PROTOTYPES}] != "" } {
perror "Couldn't compile ${testfile}.c"
return -1
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
}
@ -65,7 +64,7 @@ proc set_lang_c {} {
send_gdb "set language c\n"
gdb_expect {
-re ".*$gdb_prompt $" {}
timeout { fail "set language c (timeout)" ; return 0 }
timeout { fail "set language c (timeout)" ; return 0; }
}
send_gdb "show language\n"
@ -122,31 +121,43 @@ proc do_function_calls {} {
gdb_test "p t_long_values(789,long_val2)" " = 1"
gdb_test "p t_long_values(long_val1,-321)" " = 1"
gdb_test "p t_float_values(0.0,0.0)" " = 0"
gdb_test "p t_float_values(3.14159,-2.3765)" " = 1"
gdb_test "p t_float_values(float_val1,float_val2)" " = 1"
gdb_test "p t_float_values(3.14159,float_val2)" " = 1"
gdb_test "p t_float_values(float_val1,-2.3765)" " = 1"
if ![target_info exists gdb,skip_float_tests] {
gdb_test "p t_float_values(0.0,0.0)" " = 0"
# Test passing of arguments which might not be widened.
gdb_test "p t_float_values2(0.0,0.0)" " = 0"
# These next four tests fail on the mn10300.
# The first value is passed in regs, the other in memory.
# Gcc emits different stabs for the two parameters; the first is
# claimed to be a float, the second a double.
# dbxout.c in gcc claims this is the desired behavior.
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(3.14159,-2.3765)" " = 1"
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(float_val1,float_val2)" " = 1"
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(3.14159,float_val2)" " = 1"
setup_xfail "mn10300-*-*"
gdb_test "p t_float_values(float_val1,-2.3765)" " = 1"
# Although PR 5318 mentions SunOS specifically, this seems
# to be a generic problem on quite a few platforms.
if $prototypes then {
setup_xfail "hppa*-*-*" "sparc-*-*" "mips*-*-*" 5318
if {!$gcc_compiled} then {
setup_xfail "alpha-dec-osf2*" "i*86-*-sysv4*" 5318
# Test passing of arguments which might not be widened.
gdb_test "p t_float_values2(0.0,0.0)" " = 0"
# Although PR 5318 mentions SunOS specifically, this seems
# to be a generic problem on quite a few platforms.
if $prototypes then {
setup_xfail "hppa*-*-*" "sparc-*-*" "mips*-*-*" 5318
if {!$gcc_compiled} then {
setup_xfail "alpha-dec-osf2*" "i*86-*-sysv4*" 5318
}
}
}
gdb_test "p t_float_values2(3.14159,float_val2)" " = 1"
gdb_test "p t_small_values(1,2,3,4,5,6,7,8,9,10)" " = 55"
gdb_test "p t_float_values2(3.14159,float_val2)" " = 1"
gdb_test "p t_small_values(1,2,3,4,5,6,7,8,9,10)" " = 55"
gdb_test "p t_double_values(0.0,0.0)" " = 0"
gdb_test "p t_double_values(45.654,-67.66)" " = 1"
gdb_test "p t_double_values(double_val1,double_val2)" " = 1"
gdb_test "p t_double_values(45.654,double_val2)" " = 1"
gdb_test "p t_double_values(double_val1,-67.66)" " = 1"
gdb_test "p t_double_values(0.0,0.0)" " = 0"
gdb_test "p t_double_values(45.654,-67.66)" " = 1"
gdb_test "p t_double_values(double_val1,double_val2)" " = 1"
gdb_test "p t_double_values(45.654,double_val2)" " = 1"
gdb_test "p t_double_values(double_val1,-67.66)" " = 1"
}
gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
@ -198,25 +209,28 @@ proc do_function_calls {} {
gdb_test "p sum_args(2,{2,3})" " = 5"
gdb_test "p sum_args(3,{2,3,4})" " = 9"
gdb_test "p sum_args(4,{2,3,4,5})" " = 14"
gdb_test "p sum10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" " = 55"
# These tests are broken, so we'll skip them.
gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \
"call inferior func with struct - returns char"
gdb_test "p t_structs_s(struct_val1)" "= 87" \
"call inferior func with struct - returns short"
gdb_test "p t_structs_i(struct_val1)" "= 76" \
"call inferior func with struct - returns int"
gdb_test "p t_structs_l(struct_val1)" "= 51" \
"call inferior func with struct - returns long"
setup_xfail "i*86-*-*"
gdb_test "p t_structs_f(struct_val1)" "= 2.12.*" \
"call inferior func with struct - returns float"
setup_xfail "i*86-*-*"
gdb_test "p t_structs_d(struct_val1)" "= 9.87.*" \
"call inferior func with struct - returns double"
gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
"call inferior func with struct - returns char *"
if ![istarget "tic80-*-*"] {
gdb_test "p sum10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" " = 55"
gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \
"call inferior func with struct - returns char"
gdb_test "p t_structs_s(struct_val1)" "= 87" \
"call inferior func with struct - returns short"
gdb_test "p t_structs_i(struct_val1)" "= 76" \
"call inferior func with struct - returns int"
gdb_test "p t_structs_l(struct_val1)" "= 51" \
"call inferior func with struct - returns long"
setup_xfail "i*86-*-*"
gdb_test "p t_structs_f(struct_val1)" "= 2.12.*" \
"call inferior func with struct - returns float"
setup_xfail "i*86-*-*"
gdb_test "p t_structs_d(struct_val1)" "= 9.87.*" \
"call inferior func with struct - returns double"
gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
"call inferior func with struct - returns char *"
}
}
# Start with a fresh gdb.
@ -230,14 +244,15 @@ gdb_test "set print sevenbit-strings" ""
gdb_test "set print address off" ""
gdb_test "set width 0" ""
if [set_lang_c] then {
if [runto_main] then {
gdb_test "next" ".*"
do_function_calls
} else {
fail "C function calling tests suppressed"
}
if { ![set_lang_c] } {
gdb_suppress_tests;
} else {
fail "C function calling tests suppressed"
if { ![runto_main] } {
gdb_suppress_tests;
}
}
gdb_test "next" ".*"
do_function_calls
return 0

View File

@ -38,6 +38,9 @@ if ![info exists CHILL_RT0] {
}
verbose "using CHILL_RT0 = $CHILL_RT0" 2
if [info exists TOOL_EXECUTABLE] {
set GDB $TOOL_EXECUTABLE;
}
if ![info exists GDB] {
if ![is_remote host] {
set GDB [findfile $base_dir/../../gdb/gdb "$base_dir/../../gdb/gdb" [transform gdb]]
@ -171,6 +174,17 @@ proc gdb_run_cmd {args} {
}
if [target_info exists use_gdb_stub] {
if [target_info exists gdb,do_reload_on_run] {
# According to Stu, this will always work.
gdb_load "";
send_gdb "continue\n";
gdb_expect 60 {
-re "Continu\[^\r\n\]*\[\r\n\]" {}
default {}
}
return;
}
if [target_info exists gdb,start_symbol] {
set start [target_info gdb,start_symbol];
} else {
@ -284,7 +298,7 @@ proc runto { function } {
# specially--if it uses stubs, assuming we hit
# breakpoint() and just step out of the function.
#
proc runto_main {} {
proc runto_main { } {
global gdb_prompt
global decimal
@ -294,13 +308,8 @@ proc runto_main {} {
delete_breakpoints
send_gdb "step\n"
# if use stubs step out of the breakpoint() function.
gdb_expect 120 {
-re "main.* at .*$gdb_prompt $" {}
-re "_start.*$gdb_prompt $" {}
timeout { fail "single step at breakpoint() (timeout)" ; return 0 }
}
gdb_step_for_stub;
return 1
}
@ -360,7 +369,17 @@ proc gdb_test { args } {
}
}
gdb_expect 600 {
if [info exists timeout] {
set tmt $timeout;
} else {
global timeout;
if [info exists timeout] {
set tmt $timeout;
} else {
set tmt 60;
}
}
gdb_expect $tmt {
-re "Ending remote debugging.*$gdb_prompt$" {
if ![isnative] then {
warning "Can`t communicate to remote target."
@ -608,6 +627,7 @@ proc default_gdb_exit {} {
send_gdb "y\n";
exp_continue;
}
-re "DOSEXIT code" { }
default { }
}
}
@ -1025,3 +1045,61 @@ proc setup_xfail_format { format } {
return 0
}
proc gdb_step_for_stub { } {
global gdb_prompt;
if [target_info exists gdb_stub_step_command] {
set command [target_info gdb_stub_step_command];
} else {
set command "step";
}
send_gdb "${command}\n";
set tries 0;
gdb_expect 60 {
-re "(main.* at |.*in .*start).*$gdb_prompt" {
return;
}
-re "libgloss/\[a-z\]*\[0-9\]*/stub.c" {
send_gdb "where\n";
gdb_expect {
-re "main\[^\r\n\]*at \(\[^:]+\):\(\[0-9\]+\)" {
set file $expect_out(1,string);
set linenum [expr $expect_out(2,string) + 1];
set breakplace "${file}:${linenum}";
}
default {}
}
send_gdb "break ${breakplace}\n";
gdb_expect 60 {
-re "Breakpoint (\[0-9\]+) at.*$gdb_prompt" {
set breakpoint $expect_out(1,string);
}
-re "Breakpoint (\[0-9\]+): file.*$gdb_prompt" {
set breakpoint $expect_out(1,string);
}
default {}
}
send_gdb "continue\n";
gdb_expect 60 {
-re "Breakpoint ${breakpoint},.*$gdb_prompt" {
gdb_test "delete $breakpoint" ".*" "";
return;
}
default {}
}
}
-re ".*$gdb_prompt" {
incr tries;
if { $tries == 5 } {
fail "stepping out of breakpoint function";
return;
}
send_gdb "${command}\n";
exp_continue;
}
default {
fail "stepping out of breakpoint function";
return;
}
}
}