Support JIT debugging on MS-Windows
authorРуслан Ижбулатов <lrn1986@gmail.com>
Sat, 23 Jul 2016 08:38:03 +0000 (11:38 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 23 Jul 2016 08:38:03 +0000 (11:38 +0300)
gdb/ChangeLog:
2016-06-30  Руслан Ижбулатов  <lrn1986@gmail.com>

PR gdb/14529
* windows-nat.c (signal_event_command): New command 'signal-event'
for W32 JIT debug support.
* NEWS: Add an entry about the new 'signal-event' command.

gdb/doc/ChangeLog:
2016-06-30  Руслан Ижбулатов  <lrn1986@gmail.com>

* gdb.texinfo (Cygwin Native): Document the new 'signal-event'
command.

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/windows-nat.c

index 014c0bf9d03db91466e0edcb560ba349e1c5c936..0f4a8b64196eec140ab8ff20fe0db5395ea06f92 100644 (file)
@@ -1,3 +1,10 @@
+2016-06-30  Руслан Ижбулатов  <lrn1986@gmail.com>
+
+       PR gdb/14529
+       * windows-nat.c (signal_event_command): New command 'signal-event'
+       for W32 JIT debug support.
+       * NEWS: Add an entry about the new 'signal-event' command.
+
 2016-07-22  Tom Tromey  <tom@tromey.com>
 
        PR rust/20162:
index c29e69af4885cedf240cbb5c32a707751b609410..0e339dd7fbbc972273b534801a42fb826335e311 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -85,6 +85,13 @@ new-ui INTERP TTY
   ** gdb.Breakpoint objects have a new attribute "pending", which
      indicates whether the breakpoint is pending.
 
+signal-event EVENTID
+  Signal ("set") the given MS-Windows event object.  This is used in
+  conjunction with the Windows JIT debugging (AeDebug) support, where
+  the OS suspends a crashing process until a debugger can attach to
+  it.  Resuming the crashing process, in order to debug it, is done by
+  signalling an event.
+
 * Support for tracepoints and fast tracepoints on s390-linux and s390x-linux
   was added in GDBserver, including JIT compiling fast tracepoint's
   conditional expression bytecode into native code.
index f133f3349186e2ffa7c9c9cb5805bd2c95eeaea3..e45d92558b37462ddaae706538c482fdd0bbde7a 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-30  Руслан Ижбулатов  <lrn1986@gmail.com>
+
+       * gdb.texinfo (Cygwin Native): Document the new 'signal-event'
+       command.
+
 2016-07-13  Tom Tromey  <tom@tromey.com>
 
        PR python/15620, PR python/18620:
@@ -11724,4 +11729,5 @@ mode: change-log
 left-margin: 8
 fill-column: 74
 version-control: never
+coding: utf-8
 End:
index a068622defda740b7ecd981a1b791e5a72e3cd84..285a912bbb02d6423f630cabf906fbb388cdecea 100644 (file)
@@ -21520,6 +21520,35 @@ This command displays thread specific information stored in the
 Thread Information Block (readable on the X86 CPU family using @code{$fs}
 selector for 32-bit programs and @code{$gs} for 64-bit programs).
 
+@kindex signal-event
+@item signal-event @var{id}
+This command signals an event with user-provided @var{id}.  Used to resume
+crashing process when attached to it using MS-Windows JIT debugging (AeDebug).
+
+To use it, create or edit the following keys in
+@code{HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug} and/or
+@code{HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug}
+(for x86_64 versions):
+
+@itemize @minus
+@item
+@code{Debugger} (REG_SZ) --- a command to launch the debugger.
+Suggested command is: @code{@var{fully-qualified-path-to-gdb.exe} -ex
+"attach %ld" -ex "signal-event %ld" -ex "continue"}.
+
+The first @code{%ld} will be replaced by the process ID of the
+crashing process, the second @code{%ld} will be replaced by the ID of
+the event that blocks the crashing process, waiting for @value{GDBN}
+to attach.
+
+@item
+@code{Auto} (REG_SZ) --- either @code{1} or @code{0}.  @code{1} will
+make the system run debugger specified by the Debugger key
+automatically, @code{0} will cause a dialog box with ``OK'' and
+``Cancel'' buttons to appear, which allows the user to either
+terminate the crashing process (OK) or debug it (Cancel).
+@end itemize
+
 @kindex set cygwin-exceptions
 @cindex debugging the Cygwin DLL
 @cindex Cygwin DLL, debugging
index c95dc9a3c59f51e63ea870dbb0060737d6438e32..3f67486975cf8f28c52ae44ecd17113c878cf8fe 100644 (file)
@@ -56,6 +56,7 @@
 #include "solist.h"
 #include "solib.h"
 #include "xml-support.h"
+#include "inttypes.h"
 
 #include "i386-tdep.h"
 #include "i387-tdep.h"
@@ -825,6 +826,25 @@ windows_clear_solib (void)
   solib_end = &solib_start;
 }
 
+static void
+signal_event_command (char *args, int from_tty)
+{
+  uintptr_t event_id = 0;
+  char *endargs = NULL;
+
+  if (args == NULL)
+    error (_("signal-event requires an argument (integer event id)"));
+
+  event_id = strtoumax (args, &endargs, 10);
+
+  if ((errno == ERANGE) || (event_id == 0) || (event_id > UINTPTR_MAX) ||
+      ((HANDLE) event_id == INVALID_HANDLE_VALUE))
+    error (_("Failed to convert `%s' to event id"), args);
+
+  SetEvent ((HANDLE) event_id);
+  CloseHandle ((HANDLE) event_id);
+}
+
 /* Handle DEBUG_STRING output from child process.
    Cygwin prepends its messages with a "cygwin:".  Interpret this as
    a Cygwin signal.  Otherwise just print the string as a warning.  */
@@ -2550,6 +2570,13 @@ _initialize_windows_nat (void)
   cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);
 #endif
 
+  add_com ("signal-event", class_run, signal_event_command, _("\
+Signal a crashed process with event ID, to allow its debugging.\n\
+This command is needed in support of setting up GDB as JIT debugger on \
+MS-Windows.  The command should be invoked from the GDB command line using \
+the '-ex' command-line option.  The ID of the event that blocks the \
+crashed process will be supplied by the Windows JIT debugging mechanism."));
+
 #ifdef __CYGWIN__
   add_setshow_boolean_cmd ("shell", class_support, &useshell, _("\
 Set use of shell to start subprocess."), _("\
This page took 0.060534 seconds and 4 git commands to generate.