This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Bug win32/14529] Make gdb capable of JIT-debugging on W32
- From: Christopher Faylor <cgf-use-the-mailinglist-please at sourceware dot org>
- To: gdb-patches at sourceware dot org, LRN <lrn1986 at gmail dot com>, Eli Zaretskii <eliz at gnu dot org>
- Date: Fri, 31 Aug 2012 11:36:56 -0400
- Subject: Re: [Bug win32/14529] Make gdb capable of JIT-debugging on W32
- References: <503E575D.1000608@gmail.com> <83y5kvp0za.fsf@gnu.org>
On Fri, Aug 31, 2012 at 05:52:57PM +0300, Eli Zaretskii wrote:
>> Date: Wed, 29 Aug 2012 21:54:37 +0400
>> From: LRN <lrn1986@gmail.com>
>>
>> To be a JIT-debugger [1] on Windows, gdb has to be able to signal an
>> event, which is passed to it by command line. If that is not done, the
>> process being debugged will not come out of a waiting loop after gdb
>> attaches to it.
>> If the event is signaled, Windows will break the loop, and let the
>> exception fall into gdb's lap (well, stack will be a bit borked, but
>> that's another issue for another day, and there are ways of working
>> around it), after gdb user does 'continue'.
>>
>> The attached patch [2] does exactly that by adding extra
>> "--event=EVENT" argument, thus AeDebug command line will look like this:
>> c:\mingw32\bin\gdb.exe --pid=%ld --event=%ld
>
>What is AeDebug? do you mean the Registry entry of that name? And
>what value should be used in --event= option?
>
>This needs a documentation patch to explain how this option should be
>used.
>
>> +void
>> +signal_event_command (char *args, int from_tty)
>> +{
>> + int async_exec = 0;
>> + uintmax_t event_id = 0;
>> + char *endargs = NULL;
>> + struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
>> +
>> + dont_repeat (); /* Not for the faint of heart */
>> +
>> + event_id = strtoumax (args, &endargs, 10);
>> +
>> + if ((event_id == UINTMAX_MAX && errno == ERANGE) || event_id == 0)
>> + error (_("Failed to convert event id `%s' to integer"), args);
>> +
>> +#ifdef __MINGW32__
>> + SetEvent ((HANDLE) event_id);
>> + CloseHandle ((HANDLE) event_id);
>> +#else
>> + /* Does nothing on other platforms */
>> +#endif
>> + discard_cleanups (back_to);
>> +}
>
>I wonder whether it would be cleaner to have the entire function to be
>conditionally compiled on MinGW only.
>
>> @@ -1055,6 +1065,7 @@ Options:\n\n\
>> --dbx DBX compatibility mode.\n\
>> --directory=DIR Search for source files in DIR.\n\
>> --epoch Output information used by epoch emacs-GDB interface.\n\
>> + --event=EVENT Signal the EVENT when attached to a process. W32 only.\n\
>
>And also this part.
It sounds like it would work on Cygwin too.
cgf