Re: [Bug win32/14529] Make gdb capable of JIT-debugging on W32

LRN
2012-09-29T12:42:23Z

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

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

On 09/11/2012 07:23 PM, LRN wrote:
> On 11.09.2012 22:08, Pedro Alves wrote:
>> Alternatively, and perhaps it really is a better option, get rid
>> of the --event option, but make this a real command, implemented
>> in windows-nat.c, so that the user has better control of when to
>> signal the event, like:
>>
>> gdb -ex "foo" -ex "bar" -ex "attach PID" -ex
>> "signal-aedebug-event FOO"
>>
> That's an interesting option. Will require better documentation
> though (i haven't realized that i can do that until now; shows how
> well i know gdb :). And i'll need to test it to make sure that W32
> is actually capable of, say, replacing a quoted %ld...
>

OK, here's the patch. It is much smaller and simpler indeed.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQEcBAEBAgAGBQJQZuyZAAoJEOs4Jb6SI2Cw8fsH/iQGmgDalamwOwrsVPl8RoB3
HG8OhUjGdb3CmO5m9FGfntsp/B4b/mloPytRQfRrGg/txcuQ5OiHcP2hffA1XGbz
YaizJWDAH/qKEXBBok3jNeJoh2wt4FFPguMPGnUVtu7Orf72aQYgV0vWnErPJYKk
p7p9qsh2nInBU7y1jgAaIR9snyok5MD3BzuGyfW8rPV1H6e+HvctZIt83vzUaBFb
5QtoDrBcm5M5/Mnj/xkMu3YVfbvmj/l2HBRfwNf9KGVReu2uATM5SnlafD/hlCFt
XVUC2wbdRF1IrUhEF+YSwS9EOe4VEJ+mIRNo/faaapKSgkVJgGuQJF4Vf8jm4zQ=
=Q6V+
-----END PGP SIGNATURE-----

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

From 66f1c7d0df80834cd640fad657aefaf8dbcd6819 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 03:33:01 +0400
Subject: [PATCH] Make gdb JIT-capable (W32)

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

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

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 5fcbada..9dc559d 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18859,6 +18859,11 @@ 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 W32 JIT debugging (AeDebug).
+
@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