summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPeter Schauer <Peter.Schauer@mytum.de>2000-11-06 20:38:02 +0000
committerPeter Schauer <Peter.Schauer@mytum.de>2000-11-06 20:38:02 +0000
commitc7db355bcdf4f72eb71aea0c32506e163b0c4613 (patch)
treeb663ea883637ac6101db3e34bf2e8c194d0a342b /gdb/testsuite
parentcf055d540cdf37fb33e63e20c692d56132f4d983 (diff)
downloadbinutils-gdb-c7db355bcdf4f72eb71aea0c32506e163b0c4613.tar.gz
* gdb.base/callfuncs.c (main): Moved to end of file, call
t_double_values to initialize the FPU before inferior calls are made. * gdb.base/callfuncs.exp: Test for register preservation after calling inferior functions. Add tests for continuining, finishing and returning from a stop in a call dummy.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog8
-rw-r--r--gdb/testsuite/gdb.base/callfuncs.c31
-rw-r--r--gdb/testsuite/gdb.base/callfuncs.exp91
3 files changed, 115 insertions, 15 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 0155fb8e0a6..91f97eb84b6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2000-11-06 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
+
+ * gdb.base/callfuncs.c (main): Moved to end of file, call
+ t_double_values to initialize the FPU before inferior calls are made.
+ * gdb.base/callfuncs.exp: Test for register preservation after calling
+ inferior functions. Add tests for continuining, finishing and
+ returning from a stop in a call dummy.
+
2000-10-24 Michael Snyder <msnyder@cleaver.cygnus.com>
* gdb.base/commands.exp: Break up long lines, and re-indent.
diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c
index ecf902657db..f53bd3177cb 100644
--- a/gdb/testsuite/gdb.base/callfuncs.c
+++ b/gdb/testsuite/gdb.base/callfuncs.c
@@ -172,21 +172,6 @@ cmp10 (i0, i1, i2, i3, i4, i5, i6, i7, i8, i9)
(i5 == 5) && (i6 == 6) && (i7 == 7) && (i8 == 8) && (i9 == 9);
}
-
-/* Gotta have a main to be able to generate a linked, runnable
- executable, and also provide a useful place to set a breakpoint. */
-extern void * malloc() ;
-int main ()
-{
-#ifdef usestubs
- set_debug_traps();
- breakpoint();
-#endif
- malloc(1);
- t_structs_c(struct_val1);
- return 0 ;
-}
-
/* Functions that expect specific values to be passed and return
either 0 or 1, depending upon whether the values were
passed incorrectly or correctly, respectively. */
@@ -357,3 +342,19 @@ int a, b;
{
return ((*func_arg1)(a, b));
}
+
+
+/* Gotta have a main to be able to generate a linked, runnable
+ executable, and also provide a useful place to set a breakpoint. */
+extern void * malloc() ;
+int main ()
+{
+#ifdef usestubs
+ set_debug_traps();
+ breakpoint();
+#endif
+ malloc(1);
+ t_double_values(double_val1, double_val2);
+ t_structs_c(struct_val1);
+ return 0 ;
+}
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 8d43ec6a1c5..eab99dd6dc6 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -237,6 +237,24 @@ proc do_function_calls {} {
"call inferior func with struct - returns char *"
}
+# Procedure to get current content of all registers.
+global all_registers_content
+set all_registers_content ""
+proc do_get_all_registers { } {
+ global gdb_prompt
+ global expect_out
+ global all_registers_content
+
+ set all_registers_content ""
+ send_gdb "info all-registers\n"
+ gdb_expect {
+ -re "info all-registers\r\n(.*)$gdb_prompt $" {
+ set all_registers_content $expect_out(1,string)
+ }
+ default {}
+ }
+}
+
# Start with a fresh gdb.
gdb_exit
@@ -271,7 +289,80 @@ if { $hp_aCC_compiler } {
}
}
+# Make sure that malloc gets called and that the floating point unit
+# is initialized via a call to t_double_values.
+gdb_test "next" "t_double_values\\(double_val1, double_val2\\);.*"
gdb_test "next" "t_structs_c\\(struct_val1\\);.*"
+
+# Save all register contents.
+do_get_all_registers
+set old_reg_content $all_registers_content
+
+# Perform function calls.
do_function_calls
+# Check if all registers still have the same value.
+do_get_all_registers
+set new_reg_content $all_registers_content
+if ![string compare $old_reg_content $new_reg_content] then {
+ pass "gdb function calls preserve register contents"
+} else {
+ set old_reg_content $all_registers_content
+ fail "gdb function calls preserve register contents"
+}
+
+# Set breakpoint at a function we will call from gdb.
+gdb_breakpoint add
+
+# Call function (causing a breakpoint hit in the call dummy) and do a continue,
+# make sure we are back at main and still have the same register contents.
+gdb_test "print add(4,5)" "The program being debugged stopped while.*" ""
+gdb_test "continue" "Continuing.*" "continue from call dummy breakpoint"
+if ![gdb_test "bt 2" \
+ "#0 main.*" \
+ "bt after continuing from call dummy breakpoint"] then {
+ do_get_all_registers
+ set new_reg_content $all_registers_content
+ if ![string compare $old_reg_content $new_reg_content] then {
+ pass "continue after stop in call dummy preserves register contents"
+ } else {
+ fail "continue after stop in call dummy preserves register contents"
+ }
+}
+
+# Call function (causing a breakpoint hit in the call dummy) and do a finish,
+# make sure we are back at main and still have the same register contents.
+gdb_test "print add(4,5)" "The program being debugged stopped while.*" ""
+gdb_test "finish" \
+ "Value returned is.* = 9" \
+ "finish from call dummy breakpoint returns correct value"
+if ![gdb_test "bt 2" \
+ "#0 main.*" \
+ "bt after finishing from call dummy breakpoint"] then {
+ do_get_all_registers
+ set new_reg_content $all_registers_content
+ if ![string compare $old_reg_content $new_reg_content] then {
+ pass "finish after stop in call dummy preserves register contents"
+ } else {
+ fail "finish after stop in call dummy preserves register contents"
+ }
+}
+
+# Call function (causing a breakpoint hit in the call dummy) and do a return
+# with a value, make sure we are back at main with the same register contents.
+gdb_test "print add(4,5)" "The program being debugged stopped while.*" ""
+if ![gdb_test "return 7" \
+ "#0 main.*" \
+ "back at main after return from call dummy breakpoint" \
+ "Make add return now. .y or n.*" \
+ "y"] then {
+ do_get_all_registers
+ set new_reg_content $all_registers_content
+ if ![string compare $old_reg_content $new_reg_content] then {
+ pass "return after stop in call dummy preserves register contents"
+ } else {
+ fail "return after stop in call dummy preserves register contents"
+ }
+}
+
return 0