[PATCH] Fix "PC register is not available" issue
Joel Brobecker
brobecker@adacore.com
Fri Mar 28 13:00:00 GMT 2014
> > it'd be interesting to understand why we send a TerminateProcess
> > first, and then try to SetThreadContext later on. It does not seem
> > to make sense.
>
> That happens because windows_kill_inferior does this:
>
> static void
> windows_kill_inferior (struct target_ops *ops)
> {
> CHECK (TerminateProcess (current_process_handle, 0));
>
> for (;;)
> {
> if (!windows_continue (DBG_CONTINUE, -1, 1))
> break;
> if (!WaitForDebugEvent (¤t_event, INFINITE))
> break;
> if (current_event.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT)
> break;
> }
>
> target_mourn_inferior (); /* Or just windows_mourn_inferior? */
> }
>
> IOW, we resume the inferior (perhaps to collect all the debug
> events?).
I see - I didn't realize we were doing that, but a quick read
of the corresponding MSDN page confirms that this is necessary:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686714(v=vs.85).aspx
> Given what I told above, what additional investigations are needed?
>
> Note that the second part is not entirely separate: those phantom
> threads hit the problem with SetThreadContext as well, and checking
> whether the thread already exited does let through fewer of those
> warnings.
In light of everything, I have no further comment at the moment
regarding your latest patch. Perhaps one tiny detail:
> + if (killed)
> + SetThreadContext (th->h, &th->context);
> + else
> + CHECK (SetThreadContext (th->h, &th->context));
Rather than duplicate the call to SetThreadContext, perhaps
another way of doing it would be:
DWORD status;
status = SetThreadContext (th->h, &th->context);
if (!killed)
CHECK (status)
(not a strong suggestion, feel free to ignore)
--
Joel
More information about the Gdb-patches
mailing list