Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Stop breakpoint commands from poping the target
Date: Fri, 14 Mar 2008 08:02:00 -0000	[thread overview]
Message-ID: <200803140802.34377.pedro@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]

This patch goes on top of Vladimir's pending async fixes patch.

commands.exp triggers the problem this patch addresses, in
async mode.

In that test, we have a watch on a local variable, and then we
add a command to that watch to print the local variable's
value.  When the variable goes out of scope, gdb prints that,
and also runs the associated commands with the watch.  Since
the variable is out of scope, and error is thrown.  In sync
targets, the exception just ends the breakpoints command
processing, and goes on to proceed with the command loop.  But in
async mode, the exception ends up in
inf-loop.c:inferior_event_handler/INF_REG_EVENT, which considers exceptions
fatal, and pops the target.  The fix is to catch the exception earlier.

Imagine the following command list associated with a breakpoint:
  non_existing_command
  info target

As and example, in sync mode, trying to execute
non_existing_command causes an error that stops the
interpreting of all subsequent commands, hence info target is
never executed.  The patch installs the same behaviour for
async targets.

commands.exp passes cleanly with the linux native async patch
I'll post next.

-- 
Pedro Alves

[-- Attachment #2: bpstat_do_actions_dont_escape_exception.diff --]
[-- Type: text/x-diff, Size: 1713 bytes --]

2008-03-14  Pedro Alves  <pedro@codesourcery.com>

	* top.c (bpstat_do_actions_wrapper): New.
	(command_line_handler_continuation): Wrap call to
	bpstat_do_actions in catch_errors.

---
 gdb/top.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Index: src/gdb/top.c
===================================================================
--- src.orig/gdb/top.c	2008-03-14 07:10:51.000000000 +0000
+++ src/gdb/top.c	2008-03-14 07:22:10.000000000 +0000
@@ -364,6 +364,14 @@ do_chdir_cleanup (void *old_dir)
 }
 #endif
 
+static int
+bpstat_do_actions_wrapper (void *arg)
+{
+  bpstat *bsp = arg;
+  bpstat_do_actions (bsp);
+  return 1;
+}
+
 /* Do any commands attached to breakpoint we stopped at. Only if we
    are always running synchronously. Or if we have just executed a
    command that doesn't start the target. */
@@ -376,7 +384,12 @@ command_line_handler_continuation (struc
   long time_at_cmd_start  = arg->data.longint;
   long space_at_cmd_start = arg->next->data.longint;
 
-  bpstat_do_actions (&stop_bpstat);
+  /* Don't let exceptions escape into
+     inferior_event_handler/INF_REG_EVENT, as that pops the
+     target.  */
+  catch_errors (bpstat_do_actions_wrapper, (void *) &stop_bpstat,
+		"", RETURN_MASK_ALL);
+
   /*do_cleanups (old_chain); *//*?????FIXME????? */
 
   if (display_time)
@@ -542,7 +555,7 @@ execute_command (char *p, int from_tty)
 	}
     }
 
-  /* Set things up for this function to be compete later, once the
+  /* Set things up for this function to be finished later, once the
      execution has completed, if we are doing an execution command,
      otherwise, just go ahead and finish. */
   if (target_can_async_p () && target_executing)

             reply	other threads:[~2008-03-14  8:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14  8:02 Pedro Alves [this message]
2008-03-14  8:15 ` Vladimir Prus
2008-03-14 19:31   ` Daniel Jacobowitz
2008-03-17 16:44   ` Pedro Alves
2008-03-17 22:11     ` Daniel Jacobowitz
2008-03-15 15:59 ` Vladimir Prus
2008-03-17 16:49   ` Pedro Alves

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=200803140802.34377.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /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