Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: LRN <lrn1986@gmail.com>
To: gdb-patches@sourceware.org
Subject: Re: [Bug win32/14529] Make gdb capable of JIT-debugging on W32
Date: Sat, 29 Sep 2012 19:32:00 -0000	[thread overview]
Message-ID: <50674CCF.9020800@gmail.com> (raw)
In-Reply-To: <838vbtf07z.fsf@gnu.org>

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 29.09.2012 17:05, Eli Zaretskii wrote:
>> Date: Sat, 29 Sep 2012 16:42:03 +0400 From: LRN
>> <lrn1986@gmail.com>
>> 
>> +@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 W32 JIT debugging
>> (AeDebug).
> 
> First, please use "MS-Windows" instead of "W32".
OK, although it might not be technically correct. I have no idea
whether ReactOS implements this debugging facility or not, but if it
does, then it is not right to name it "MS-Windows", since ReactOS is
neither MS, nor Windows.
I usually use "W32", because most of the time doing something with
WinAPI means interacting with Win32 subsystem, which, as i've
mentioned above, [is not/will not be] implemented exclusively by Windows.
Now, since GNU folks frown upon "win" in Win32, and naming it Woe32
sounds weird to me, i just use "W32".
Anyway, i've changed the patch.

> More importantly, I think we should document the Registry entry
> the user needs to tweak, and how to define it, in order to install
> GDB as a JIT debugger.  In other words, the above does not explain
> enough about the expected use of this command, which (AFAIU) is
> from the GDB command line using the -ex switch, which I understand
> is the only way to get hold of the mysterious ID parameter this
> command needs.
> 
Done.

Hopefully i didn't screw up texinfo file with wrong commands or
formatting.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQEcBAEBAgAGBQJQZ0zPAAoJEOs4Jb6SI2CwjxcIALmQvhA1rfRv/UJeAx4nsavM
jdWA52BbG2uaHiBI31TGmzDIecEk24yvWPTWx0F3Y/XbGojHuXpFCa4d7ekUbGFr
HBO/1DP5ZeoOEgHxK3YvnuDUkGtLnvU04q5IJmGfEOVC88nRjEr3gveGRTU9lvI0
3buThR+6sLC8+KhKk/zDtIC8MrohUGGhiVrH5oZyiiSUJ0BByicszd8U90B784qP
N0ceVolAEsIV8x6Pk+nnU12G87pB9sItpNwmwFBfjWNANUSA165mAnnDCMltmZAU
7QlKK7IxR6MyRwPxYjU9qzcS/E+/0qyNx5BSy3cqsLvzd8AfvKdZeHNphPUT1FY=
=c6nq
-----END PGP SIGNATURE-----

[-- Attachment #2: 0001-Make-gdb-JIT-capable-W32-v4.mingw32.patch --]
[-- Type: text/plain, Size: 3575 bytes --]

From 68db59b52726d0838b5974ec201becfebed8f27d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1?=
 =?UTF-8?q?=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1986@gmail.com>
Date: Sat, 29 Sep 2012 18:16:16 +0400
Subject: [PATCH] Make gdb JIT-capable (MS-Windows)

Adds the signal-event command (MS-Windows-only) that signals
an event with user-provided ID. Used to resume crashing
process when attached to it via MS-Windows JIT debugging (AeDebug).

PR gdb/14529
---
 gdb/doc/gdb.texinfo | 26 ++++++++++++++++++++++++++
 gdb/windows-nat.c   | 22 ++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 5fcbada..555563a 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18859,6 +18859,32 @@ This is a Cygwin-specific alias of @code{info shared}.
 This command loads symbols from a dll similarly to
 add-sym command but without the need to specify a base address.
 
+@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
+Debugger (REG_SZ) - a command to launch the debugger. Suggested command is:
+<fully-qualified-path-to-gdb.exe> -ex "attach %ld" -ex "signal-event %ld"
+-ex "c"
+
+First %ld will be replaced by process ID, second %ld will be replaced by ID
+of the event that blocks the crashing process, waiting for debugger to attach.
+
+@item
+Auto (REG_SZ) - either @code{1} or @code{0}. @code{1} will make the system run
+debugger specified by Debugger key automatically, @code{0} will cause a dialog
+box with "OK" and "Cancel" buttons to appear, which allows the user to either
+terminate crashing process (OK) or debug it (Cancel).
+@end itemize
+
 @kindex set cygwin-exceptions
 @cindex debugging the Cygwin DLL
 @cindex Cygwin DLL, debugging
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 905d4bf..f003ece 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -933,6 +933,25 @@ dll_symbol_command (char *args, int from_tty)
   safe_symbol_file_add (args, from_tty, NULL, 0, OBJF_SHARED | OBJF_USERLOADED);
 }
 
+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.  */
@@ -2547,6 +2566,9 @@ _initialize_windows_nat (void)
   cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);
 #endif
 
+  c = add_com ("signal-event", class_run, signal_event_command,
+	       _("Signal an object with ID."));
+
   c = add_com ("dll-symbols", class_files, dll_symbol_command,
 	       _("Load dll library symbols from FILE."));
   set_cmd_completer (c, filename_completer);
-- 
1.7.11


  reply	other threads:[~2012-09-29 19:32 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-29 17:55 LRN
2012-08-31 14:53 ` Eli Zaretskii
2012-08-31 15:37   ` LRN
2012-09-10  2:22     ` LRN
2012-09-10 18:15       ` Tom Tromey
2012-09-10 18:32         ` LRN
2012-09-11 18:21       ` Pedro Alves
2012-09-11 18:27         ` LRN
2012-09-11 18:30           ` Pedro Alves
2012-09-11 18:09     ` Pedro Alves
2012-09-11 18:23       ` LRN
2012-09-11 18:27         ` Pedro Alves
2012-09-11 18:31           ` LRN
2012-09-29 12:42           ` LRN
2012-09-29 13:05             ` Eli Zaretskii
2012-09-29 19:32               ` LRN [this message]
2012-09-30  7:51                 ` Eli Zaretskii
2012-09-30 12:46                   ` LRN
2012-10-01 13:18                     ` Eli Zaretskii
2012-10-01 16:22                       ` LRN
2012-08-31 15:37   ` Christopher Faylor
2012-08-31 15:40     ` LRN
2012-10-01 22:37 ` Sergio Durigan Junior
2012-10-01 22:48   ` LRN
2012-10-02  5:53     ` Sergio Durigan Junior
2012-10-02 12:48       ` Joel Brobecker
2012-10-02 12:57         ` LRN
2016-06-30 13:17           ` LRN
2016-06-30 15:25             ` Eli Zaretskii
2016-06-30 15:44               ` LRN
2016-06-30 16:23                 ` Eli Zaretskii
2016-06-30 17:19                   ` LRN
2016-06-30 17:42                     ` Eli Zaretskii
2016-06-30 18:36                       ` LRN
2016-06-30 18:57                         ` Eli Zaretskii
2016-06-30 19:14                           ` LRN
2016-07-02  1:16                             ` LRN
2016-07-02  7:48                               ` Eli Zaretskii
2016-07-10 13:06                                 ` LRN
2016-07-10 14:55                                   ` Eli Zaretskii
2016-07-18 10:08                                     ` LRN
2016-07-19 19:10                                       ` Eli Zaretskii
2016-07-20  4:43                                         ` LRN
2016-07-23  8:41                                           ` 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=50674CCF.9020800@gmail.com \
    --to=lrn1986@gmail.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