public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Re: [RFC] Add new commands to windows native code.
       [not found] <"001f01ce9413$72450b20$56cf2160$@muller"@ics-cnrs.unistra.fr>
@ 2013-08-09 14:06 ` Eli Zaretskii
  2013-08-09 15:03   ` Pedro Alves
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Eli Zaretskii @ 2013-08-09 14:06 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches

> From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> Date: Thu, 8 Aug 2013 10:44:08 +0200
> 
>   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).

I agree that these are useful features, but I would think they are
more appropriate as part of "catch" implementation for Windows.  For
starters, treating these as catchpoints will allow to use all the
features of catchpoints: ignore counts, commands, display in "info
breakpoints", etc.

So would you like to rewrite this as subcommands of "catch"?  E.g.,
how about

  . catch exception [NAME]

    will stop when a specified exception (default: any exception) is
    detected

  . catch debug-string

    will stop whenever any debug string event is detected.

In any case, these are user-visible changes, so they will require
updates to the user manual.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] Add new commands to windows native code.
  2013-08-09 14:06 ` [RFC] Add new commands to windows native code 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>
  2 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2013-08-09 15:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Pierre Muller, gdb-patches

I'd be good to keep GDBserver in the loop too.  We're
trying to bridge the gap between GDB and GDBserver afterall,
and new features in the native target that don't end up
in GDBserver now just means more work later on.
IOW, it'd be very good to keep the RSP and GDBserver in
mind when designing the implementation for such a feature
(whatever it ends up looking like).

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [RFC] Add new commands to windows native code.
  2013-08-09 14:06 ` [RFC] Add new commands to windows native code 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>
  2 siblings, 0 replies; 5+ messages in thread
From: Pierre Muller @ 2013-08-19 14:39 UTC (permalink / raw)
  To: 'Eli Zaretskii'; +Cc: gdb-patches

 Hi Eli,



> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Eli Zaretskii
> Envoyé : vendredi 9 août 2013 16:06
> À : Pierre Muller
> Cc : gdb-patches@sourceware.org
> Objet : Re: [RFC] Add new commands to windows native code.
> 
> > From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> > Date: Thu, 8 Aug 2013 10:44:08 +0200
> >
> >   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).
> 
> I agree that these are useful features, but I would think they are
> more appropriate as part of "catch" implementation for Windows.  For
> starters, treating these as catchpoints will allow to use all the
> features of catchpoints: ignore counts, commands, display in "info
> breakpoints", etc.
> 
> So would you like to rewrite this as subcommands of "catch"?  E.g.,
> how about
> 
>   . catch exception [NAME]

  Currently catch exception is an ADA specific catch type...

  It seems that 'catch catch regex ' 
could be used...

  But currently all exception are converted into signals inside
windows-nat.c code...
  So that implementing your suggestion would basically mean
that the Windows API exception would not be converted into 
signals anymore...
  This is a huge change, which should probably not be enabled 
by default, no?
 
>     will stop when a specified exception (default: any exception) is
>     detected
> 
>   . catch debug-string
> 
>     will stop whenever any debug string event is detected.
> 
> In any case, these are user-visible changes, so they will require
> updates to the user manual.

  I do agree here...
  But frankly speaking, I fear that I will never be able to
implement such a feature :(
  The list of stuff I wrote for windows OS GDB support
that was never integrated into main-line is already quite huge...

  I did look a little a the catching code inside break-catch-throw.c 
but I still didn't even get how the exception number is supposed to
be passed to the loop that looks through the list of all breakpoints
to see if there is a match...

Pierre 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] Add new commands to windows native code.
       [not found]   ` <"000001ce9ce9$d4669a10$7d33ce30$@muller"@ics-cnrs.unistra.fr>
@ 2013-08-19 15:55     ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2013-08-19 15:55 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches

> From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> Cc: <gdb-patches@sourceware.org>
> Date: Mon, 19 Aug 2013 16:38:53 +0200
> 
> >   . catch exception [NAME]
> 
>   Currently catch exception is an ADA specific catch type...

Aren't C++ exceptions supported as well?

>   It seems that 'catch catch regex ' 
> could be used...

Less user-friendly, but also fine, IMO.

>   But currently all exception are converted into signals inside
> windows-nat.c code...
>   So that implementing your suggestion would basically mean
> that the Windows API exception would not be converted into 
> signals anymore...

Your changes, OTOH, would cause the inferior be stopped twice for the
same reason, AFAIU.  I don't know what is worse.

>   This is a huge change, which should probably not be enabled 
> by default, no?

I agree, but then catchpoints are never set by default, only by user
command.  So I see no usability problem here.

>   But frankly speaking, I fear that I will never be able to
> implement such a feature :(
>   The list of stuff I wrote for windows OS GDB support
> that was never integrated into main-line is already quite huge...

I can hardly believe that it would be much harder than the 3 options
you suggested.

>   I did look a little a the catching code inside break-catch-throw.c 
> but I still didn't even get how the exception number is supposed to
> be passed to the loop that looks through the list of all breakpoints
> to see if there is a match...

Maybe someone of the senior maintainers could help out here?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC] Add new commands to windows native code.
@ 2013-08-08  8:44 Pierre Muller
  0 siblings, 0 replies; 5+ messages in thread
From: Pierre Muller @ 2013-08-08  8:44 UTC (permalink / raw)
  To: gdb-patches

  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,

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-19 15:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <"001f01ce9413$72450b20$56cf2160$@muller"@ics-cnrs.unistra.fr>
2013-08-09 14:06 ` [RFC] Add new commands to windows native code 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
2013-08-08  8:44 Pierre Muller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).