Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [RFC] Add new commands to windows native code.
Date: Thu, 08 Aug 2013 08:44:00 -0000	[thread overview]
Message-ID: <001f01ce9413$72450b20$56cf2160$@muller@ics-cnrs.unistra.fr> (raw)

  This patch adds three new commands to windows native code:
these are three Boolean set/show commands :

1) set print-first-chance-exception on/off
to also print a "gdb: unknown target exception ..."
string on each first-chance exception.

2) set stop-on-first-chance-exception on/off
to stop code execution each time a first chance exception occurs.
and
3) set stop-on-debug-string-event on/off
to stop code execution each time a debug string event occurs.

  The third command was particularly useful to 
understand and eliminate a msvcrt debug string event generated 
by GDB code (fix to be submitted in a next patch).

  Comments most welcome,


Pierre Muller
GDB pascal language maintainer


2013-08-07  Pierre Muller  <muller@sourceware.org>

	* src/gdb/windows-nat.c (print_first_chance_exception): New
	static variable.
	(stop_on_first_chance_exception): New static variable.
	(stop_on_debug_string_event): New static variable.
	(handle_output_debug_string): Stop on warning if
	STOP_ON_DEBUG_STRING_EVENT is non zero.
	(handle_exception): Print first chance exception if
	PRINT_FIRST_CHANCE_EXCEPTION is non zero. Stop on first chance
	exception if STOP_ON_FIRST_CHANCE_EXCEPTION is non zero.
	(_initialize_windows_nat): Register set/show commands for
	the three new variables introduced above.


Index: src/gdb/windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.257
diff -u -p -r1.257 windows-nat.c
--- src/gdb/windows-nat.c	1 Jul 2013 11:28:30 -0000	1.257
+++ src/gdb/windows-nat.c	7 Aug 2013 12:37:33 -0000
@@ -222,6 +222,13 @@ static int debug_events = 0;		/* show ev
 static int debug_memory = 0;		/* show target memory accesses */
 static int debug_exceptions = 0;	/* show target exceptions */
 static int useshell = 0;		/* use shell for subprocesses */
+/* Show first chance exceptions.  */
+static int print_first_chance_exception = 0;
+/* Stop on first chance exceptions.  */
+static int stop_on_first_chance_exception = 0;
+/* Stop on debug string event.  */
+static int stop_on_debug_string_event = 0;
+
 
 /* This vector maps GDB's idea of a register's number into an offset
    in the windows exception context vector.
@@ -958,7 +965,15 @@ handle_output_debug_string (struct targe
 #ifdef __CYGWIN__
       if (strncmp (s, "cYg", 3) != 0)
 #endif
-	warning (("%s"), s);
+	{
+	  warning (("%s"), s);
+	  if (stop_on_debug_string_event)
+	    {
+	      retval = current_event.dwThreadId;
+	      ourstatus->kind = TARGET_WAITKIND_STOPPED;
+	    }
+
+	}
     }
 #ifdef __COPY_CONTEXT_SIZE
   else
@@ -1234,7 +1249,20 @@ handle_exception (struct target_waitstat
     default:
       /* Treat unhandled first chance exceptions specially.  */
       if (current_event.u.Exception.dwFirstChance)
-	return -1;
+	{
+	  if (print_first_chance_exception)
+	    printf_unfiltered ("gdb: unknown target exception 0x%08x at
%s\n",
+	    (unsigned)
current_event.u.Exception.ExceptionRecord.ExceptionCode,
+	    host_address_to_string (
+	      current_event.u.Exception.ExceptionRecord.ExceptionAddress));
+
+	  if (stop_on_first_chance_exception)
+	    {
+	      ourstatus->value.sig = GDB_SIGNAL_UNKNOWN;
+	      break;
+	    }
+	  return -1;
+	}
       printf_unfiltered ("gdb: unknown target exception 0x%08x at %s\n",
 	(unsigned) current_event.u.Exception.ExceptionRecord.ExceptionCode,
 	host_address_to_string (
@@ -2635,6 +2664,30 @@ Show whether to display kernel exception
 			   NULL, /* FIXME: i18n: */
 			   &setlist, &showlist);
 
+  add_setshow_boolean_cmd ("print-first-chance-exception", class_support,
+			   &print_first_chance_exception, _("\
+Set whether to display first chance exceptions in child process."), _("\
+Show whether to display first chance exceptions in child process."), NULL,
+			   NULL,
+			   NULL, /* FIXME: i18n: */
+			   &setlist, &showlist);
+
+  add_setshow_boolean_cmd ("stop-on-first-chance-exception", class_support,
+			   &stop_on_first_chance_exception, _("\
+Set whether to stop on first chance exceptions in child process."), _("\
+Show whether to stop on first chance exceptions in child process."), NULL,
+			   NULL,
+			   NULL, /* FIXME: i18n: */
+			   &setlist, &showlist);
+
+  add_setshow_boolean_cmd ("stop-on-debug-string-event", class_support,
+			   &stop_on_debug_string_event, _("\
+Set whether to stop on debug string event in child process."), _("\
+Show whether to stop on debug string event in child process."), NULL,
+			   NULL,
+			   NULL, /* FIXME: i18n: */
+			   &setlist, &showlist);
+
   init_w32_command_list ();
 
   add_cmd ("selector", class_info, display_selectors,


             reply	other threads:[~2013-08-08  8:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-08  8:44 Pierre Muller [this message]
     [not found] <"001f01ce9413$72450b20$56cf2160$@muller"@ics-cnrs.unistra.fr>
2013-08-09 14:06 ` Eli Zaretskii
2013-08-09 15:03   ` Pedro Alves
2013-08-19 14:39   ` Pierre Muller
     [not found]   ` <"000001ce9ce9$d4669a10$7d33ce30$@muller"@ics-cnrs.unistra.fr>
2013-08-19 15:55     ` Eli Zaretskii

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='001f01ce9413$72450b20$56cf2160$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --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