aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-02-02 05:51:09 +0000
committerAndrew Cagney <cagney@redhat.com>2003-02-02 05:51:09 +0000
commit075559bc196f31237cf09c3eda0757f493f4dc25 (patch)
tree9ef8613d89aaf077d9c5d9488ce001bfc183bfcb
parent6789195b4218084c38719f3c44e09eaa8108fc12 (diff)
downloadgdb-075559bc196f31237cf09c3eda0757f493f4dc25.zip
gdb-075559bc196f31237cf09c3eda0757f493f4dc25.tar.gz
gdb-075559bc196f31237cf09c3eda0757f493f4dc25.tar.bz2
2003-02-01 Andrew Cagney <ac131313@redhat.com>
From 2002-11-09 Jason Molenda (jason-cl@molenda.com) * stack.c (print_frame_info_base): Output complete FRAME tuple for synthesized frames. 2003-02-01 Andrew Cagney <ac131313@redhat.com> From 2002-11-09 Jason Molenda (jason-cl@molenda.com): * gdb.mi/mi-syn-frame.exp: New tests for synthetic frames in stack backtraces. * gdb.mi/mi-syn-frame.c: Part of same.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/stack.c40
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.mi/mi-syn-frame.c61
-rw-r--r--gdb/testsuite/gdb.mi/mi-syn-frame.exp106
5 files changed, 202 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0ecfdec..9388cf2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2003-02-01 Andrew Cagney <ac131313@redhat.com>
+
+ From 2002-11-09 Jason Molenda (jason-cl@molenda.com)
+ * stack.c (print_frame_info_base): Output complete FRAME tuple
+ for synthesized frames.
+
2003-02-02 Andrew Cagney <ac131313@redhat.com>
* mips-nat.c (zerobuf): Delete.
diff --git a/gdb/stack.c b/gdb/stack.c
index 405a5e4..e167b6e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -197,9 +197,11 @@ print_frame_info (struct frame_info *fi, int level, int source, int args)
int source_print;
int location_print;
- if (get_frame_type (fi) == DUMMY_FRAME)
+ if (get_frame_type (fi) == DUMMY_FRAME
+ || get_frame_type (fi) == SIGTRAMP_FRAME)
{
- annotate_frame_begin (level == -1 ? 0 : level, get_frame_pc (fi));
+ struct cleanup *uiout_cleanup
+ = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
/* Do this regardless of SOURCE because we don't have any source
to list for this frame. */
@@ -208,25 +210,27 @@ print_frame_info (struct frame_info *fi, int level, int source, int args)
ui_out_text (uiout, "#");
ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
}
- annotate_function_call ();
- printf_filtered ("<function called from gdb>\n");
- annotate_frame_end ();
- return;
- }
- if ((get_frame_type (fi) == SIGTRAMP_FRAME))
- {
- annotate_frame_begin (level == -1 ? 0 : level, get_frame_pc (fi));
-
- /* Do this regardless of SOURCE because we don't have any source
- to list for this frame. */
- if (level >= 0)
+ if (ui_out_is_mi_like_p (uiout))
{
- ui_out_text (uiout, "#");
- ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
+ annotate_frame_address ();
+ ui_out_field_core_addr (uiout, "addr", fi->pc);
+ annotate_frame_address_end ();
+ }
+
+ if (get_frame_type (fi) == DUMMY_FRAME)
+ {
+ annotate_function_call ();
+ ui_out_field_string (uiout, "func", "<function called from gdb>");
+ }
+ else if (get_frame_type (fi) == SIGTRAMP_FRAME)
+ {
+ annotate_signal_handler_caller ();
+ ui_out_field_string (uiout, "func", "<signal handler called>");
}
- annotate_signal_handler_caller ();
- printf_filtered ("<signal handler called>\n");
+ ui_out_text (uiout, "\n");
annotate_frame_end ();
+
+ do_cleanups (uiout_cleanup);
return;
}
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2dd5bda..5e0fce0 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2003-02-01 Andrew Cagney <ac131313@redhat.com>
+
+ From 2002-11-09 Jason Molenda (jason-cl@molenda.com):
+ * gdb.mi/mi-syn-frame.exp: New tests for synthetic frames in
+ stack backtraces.
+ * gdb.mi/mi-syn-frame.c: Part of same.
+
2003-02-01 Mark Kettenis <kettenis@gnu.org>
* gdb.mi/gdb669.exp, gdb.mi/mi-pthreads.exp,
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.c b/gdb/testsuite/gdb.mi/mi-syn-frame.c
new file mode 100644
index 0000000..83d2d46
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.c
@@ -0,0 +1,61 @@
+#include <signal.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+void foo (void);
+void bar (void);
+
+void subroutine (int);
+void handler (int);
+void have_a_very_merry_interrupt (void);
+
+main ()
+{
+ puts ("Starting up");
+
+ foo (); /* Put a breakpoint on foo() and call it to see a dummy frame */
+
+
+ have_a_very_merry_interrupt ();
+
+ puts ("Shutting down");
+}
+
+void
+foo (void)
+{
+ puts ("hi in foo");
+}
+
+void
+bar (void)
+{
+ char *nuller = 0;
+
+ puts ("hi in bar");
+
+ *nuller = 'a'; /* try to cause a segfault */
+}
+
+void
+handler (int sig)
+{
+ subroutine (sig);
+}
+
+void
+subroutine (int in)
+{
+ while (in < 100)
+ in++;
+}
+
+void
+have_a_very_merry_interrupt (void)
+{
+ puts ("Waiting to get a signal");
+ signal (SIGALRM, handler);
+ alarm (1);
+ sleep (2); /* We'll receive that signal while sleeping */
+}
+
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.exp b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
new file mode 100644
index 0000000..49f9772
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
@@ -0,0 +1,106 @@
+# Copyright 2002 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 MI output with synthetic frames on the stack (call dummies,
+# signal handlers).
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+set testfile "mi-syn-frame"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
+
+mi_gdb_exit
+mi_gdb_start
+mi_delete_breakpoints
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+mi_run_to_main
+
+mi_gdb_test "400-break-insert foo" "400\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}"
+
+
+#
+# Call foo() by hand, where we'll hit a breakpoint.
+#
+
+mi_gdb_test "401-data-evaluate-expression foo()" "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(foo\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+401\\^error,msg=\"The program being debugged stopped while in a function called from GDB.*\"" "call inferior's function with a breakpoint set in it"
+
+mi_gdb_test "402-stack-list-frames" "402\\^done,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"foo\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]" "backtrace from inferior function stopped at bp, showing gdb dummy frame"
+
+#
+# Continue back to main()
+#
+
+send_gdb "403-exec-continue\n"
+gdb_expect {
+ -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
+ pass "403-exec-continue"
+ }
+ timeout {
+ fail "403-exec-continue"
+ }
+}
+
+mi_gdb_test "404-stack-list-frames 0 0" "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
+
+
+#
+# Call have_a_very_merry_interrupt() which will eventually raise a signal
+# that's caught by handler() which calls subroutine().
+
+mi_gdb_test "405-break-insert subroutine" "405\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}"
+
+mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\""
+
+# We should have both a signal handler and a call dummy frame
+# in this next output.
+
+mi_gdb_test "407-stack-list-frames" "407\\^done,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"subroutine\",args=\\\[\{name=\"in\",value=\"$decimal\"\}\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
+
+
+send_gdb "408-exec-continue\n"
+gdb_expect {
+ -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
+ pass "408-exec-continue"
+ }
+ timeout {
+ fail "408-exec-continue"
+ }
+}
+
+mi_gdb_test "409-stack-list-frames 0 0" "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"\}.*\\\]"
+
+#
+# Call bar() by hand, which should get an exception while running.
+#
+
+mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+
+mi_gdb_test "411-stack-list-frames" "411\\^done,reason=\"signal-received\",signal-name=\".*\",signal-meaning=\".*\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"bar\",args=\\\[\\\],file=\".*mi-syn-frame.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
+
+mi_gdb_exit
+
+return 0