This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] Add new commands to windows native code.
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: <gdb-patches at sourceware dot org>
- Date: Thu, 8 Aug 2013 10:44:08 +0200
- Subject: [RFC] Add new commands to windows native code.
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,