From: Jason Molenda <jason-swarelist@molenda.com>
To: Andrew Cagney <ac131313@redhat.com>
Cc: gdb-patches@sources.redhat.com, jjohnstn@redhat.com
Subject: Re: PATCH RFA: Fix MI stack frame output for synthetic frames
Date: Sat, 09 Nov 2002 00:47:00 -0000 [thread overview]
Message-ID: <20021109004723.A20334@molenda.com> (raw)
In-Reply-To: <3DCC3CEE.5040902@redhat.com>; from ac131313@redhat.com on Fri, Nov 08, 2002 at 05:38:38PM -0500
[-- Attachment #1: Type: text/plain, Size: 2129 bytes --]
On Fri, Nov 08, 2002 at 05:38:38PM -0500, Andrew Cagney wrote:
> It should be possible to test the "<function called from gdb>" case.
> All the more main-stream architectures now use dummy-frames so any one
> of them can be used for the test.
>
> Can you do that?
OK, how's this look? I don't care about the names of the files or
anything like that.
[gdb/ChangeLog]
2002-11-09 Jason Molenda (jason-cl@molenda.com)
* stack.c (print_frame_info_base): Output complete FRAME tuple
for synthesized frames.
[gdb/testsuite/ChangeLog]
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/inferior-mischief.c: Part of same.
It's probably not necessary, but I'll include the final plain text
of print_frame_info_base that I settled on for this patch so no
one needs to do unidiff decompression in their heads. This change
introduces no new testsuite regressions.
struct cleanup *uiout_cleanup;
if (frame_in_dummy (fi) || fi->signal_handler_caller)
{
annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
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. */
if (level >= 0)
{
ui_out_text (uiout, "#");
ui_out_field_fmt_int (uiout, 2, ui_left, "level", level);
}
if (ui_out_is_mi_like_p (uiout))
{
annotate_frame_address ();
ui_out_field_core_addr (uiout, "addr", fi->pc);
annotate_frame_address_end ();
}
if (frame_in_dummy (fi))
{
annotate_function_call ();
ui_out_field_string (uiout, "func", "<function called from gdb>");
}
else if (fi->signal_handler_caller)
{
annotate_signal_handler_caller ();
ui_out_field_string (uiout, "func", "<signal handler called>");
}
ui_out_text (uiout, "\n");
annotate_frame_end ();
do_cleanups (uiout_cleanup);
return;
}
[-- Attachment #2: pa.txt --]
[-- Type: text/plain, Size: 12031 bytes --]
[gdb/ChangeLog]
2002-11-09 Jason Molenda (jason-cl@molenda.com)
* stack.c (print_frame_info_base): Output complete FRAME tuple
for synthesized frames.
[gdb/testsuite/ChangeLog]
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/inferior-mischief.c: Part of same.
Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.46
diff -u -p -r1.46 stack.c
--- stack.c 3 Oct 2002 22:34:58 -0000 1.46
+++ stack.c 9 Nov 2002 08:38:34 -0000
@@ -332,28 +332,12 @@ print_frame_info_base (struct frame_info
struct symtab_and_line sal;
int source_print;
int location_print;
+ struct cleanup *uiout_cleanup;
-#if 0
- char buf[MAX_REGISTER_RAW_SIZE];
- CORE_ADDR sp;
-
- /* On the 68k, this spends too much time in m68k_find_saved_regs. */
-
- /* Get the value of SP_REGNUM relative to the frame. */
- get_saved_register (buf, (int *) NULL, (CORE_ADDR *) NULL,
- FRAME_INFO_ID (fi), SP_REGNUM, (enum lval_type *) NULL);
- sp = extract_address (buf, REGISTER_RAW_SIZE (SP_REGNUM));
-
- /* This is not a perfect test, because if a function alloca's some
- memory, puts some code there, and then jumps into it, then the test
- will succeed even though there is no call dummy. Probably best is
- to check for a bp_call_dummy breakpoint. */
- if (PC_IN_CALL_DUMMY (fi->pc, sp, fi->frame))
-#else
- if (frame_in_dummy (fi))
-#endif
+ if (frame_in_dummy (fi) || fi->signal_handler_caller)
{
annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
+ 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. */
@@ -362,25 +346,26 @@ print_frame_info_base (struct frame_info
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 (fi->signal_handler_caller)
- {
- annotate_frame_begin (level == -1 ? 0 : level, fi->pc);
-
- /* 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 ();
}
- annotate_signal_handler_caller ();
- printf_filtered ("<signal handler called>\n");
+ if (frame_in_dummy (fi))
+ {
+ annotate_function_call ();
+ ui_out_field_string (uiout, "func", "<function called from gdb>");
+ }
+ else if (fi->signal_handler_caller)
+ {
+ annotate_signal_handler_caller ();
+ ui_out_field_string (uiout, "func", "<signal handler called>");
+ }
+ ui_out_text (uiout, "\n");
annotate_frame_end ();
+
+ do_cleanups (uiout_cleanup);
return;
}
Index: testsuite/gdb.mi/inferior-mischief.c
===================================================================
RCS file: testsuite/gdb.mi/inferior-mischief.c
diff -N testsuite/gdb.mi/inferior-mischief.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.mi/inferior-mischief.c 9 Nov 2002 08:38:44 -0000
@@ -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 */
+}
+
Index: testsuite/gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: testsuite/gdb.mi/mi-syn-frame.exp
diff -N testsuite/gdb.mi/mi-syn-frame.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ mi-syn-frame.exp 9 Nov 2002 08:41:01 -0000
@@ -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 "inferior-mischief"
+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=\".*inferior-mischief.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=\".*inferior-mischief.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"foo\",file=\".*inferior-mischief.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*inferior-mischief.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=\".*inferior-mischief.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=\".*inferior-mischief.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=\".*inferior-mischief.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*inferior-mischief.c\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*inferior-mischief.c\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*inferior-mischief.c\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*inferior-mischief.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=\".*inferior-mischief.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=\".*inferior-mischief.c\",line=\"$decimal\"\},stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*inferior-mischief.c\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*inferior-mischief.c\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
+
+mi_gdb_exit
+
+return 0
next prev parent reply other threads:[~2002-11-09 8:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-08 14:22 PATCH: " Jason Molenda
2002-11-08 14:38 ` Andrew Cagney
2002-11-08 14:46 ` Jason Molenda
2002-11-08 15:56 ` Andrew Cagney
2002-11-09 0:47 ` Jason Molenda [this message]
2002-11-09 2:13 ` PATCH RFA: " Jason Molenda
2002-11-15 11:16 ` Ping on two MI patches Jason Molenda
2003-02-02 5:52 ` PATCH RFA: Fix MI stack frame output for synthetic frames Andrew Cagney
2003-02-02 17:38 ` Mark Kettenis
2003-02-02 18:23 ` Andrew Cagney
2003-02-02 20:51 ` Mark Kettenis
2003-02-03 18:15 ` David Carlton
2003-02-03 18:27 ` Jason Molenda
2003-02-03 18:34 ` Daniel Jacobowitz
2003-02-04 8:09 ` Jason Molenda
2003-02-05 8:28 ` Jason Molenda
2003-02-05 13:59 ` Daniel Jacobowitz
2003-02-05 14:54 ` Elena Zannoni
2003-02-06 6:28 ` Fix committed for mi-syn-frames fails (was: Re: PATCH RFA: Fix MI stack frame output for synthetic frames) Jason Molenda
2003-02-06 6:31 ` Jason Molenda
2003-02-06 17:01 ` David Carlton
2003-02-06 18:21 ` Andrew Cagney
2003-02-06 18:27 ` Jason Molenda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021109004723.A20334@molenda.com \
--to=jason-swarelist@molenda.com \
--cc=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jjohnstn@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox