Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <muller@ics.u-strasbg.fr>
To: "'Pedro Alves'" <pedro@codesourcery.com>, <gdb-patches@sourceware.org>
Subject: RE: [RFC] win32-nat.c 'set new-console' and interruption
Date: Mon, 23 Jun 2008 17:25:00 -0000	[thread overview]
Message-ID: <001601c8d54a$f45a1660$dd0e4320$@u-strasbg.fr> (raw)
In-Reply-To: <200806231541.26276.pedro@codesourcery.com>



> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pedro Alves
> Envoyé : Monday, June 23, 2008 4:41 PM
> À : gdb-patches@sourceware.org
> Cc : Pierre Muller
> Objet : Re: [RFC] win32-nat.c 'set new-console' and interruption
> 
> A Monday 23 June 2008 15:23:06, Pierre Muller wrote:
> 
> > I have a proposal to remove that possible race condition:
> > The exception record has a field that contains the exception
> > address, if I test that there is no GDB inserted breakpoint at
> > that location before converting the TARGET_SIGNAL_TRAP
> > into a TARGET_SIGNAL_INT, it should fix most problems, no?
> >
> >   The one case that it would still not catch would be
> > a 'int 3' instruction that is in the debuggee code from the start
> > but other than at startup, such instructions are quite unlikely, no?
> >
> 
> IIRC, DebugBreakProcess injects a thread in the debuggee and
> always breaks at the same address / in the same function -- I don't
> know if there's a hardcoded 0xcc at the break address you
> could check, or if the exception is generated programatically,
> but at least you could conditionalize on the function name (if there's
> no hardcoded break, you still can't distiguish by name only a user
> break placed in that special break function)

  I checked this: on windows XP it does use an 'int 3' instruction
that is situated in ntdll DLL at an exported function named
DbgUiConnectToDbg, but I would really like to avoid hard-coding this into
win32-nat.c as there is no assurance that other versions of
Microsoft OS will use the same function.

> Another option is to use SuspendThread on all threads to stop
> the process, which is what I believe Visual Studio uses.
> gdbserver has that implemented for systems that don't have
> DebugBreakProcess.

That is also a nice idea...
The only problem in that case is, which thread do we then
use as the current_thread? 
Do we default on main_thread_id?
But the current win32-nat source code has a particularity
here: it never removes the main_thread_idd thread
even if that thread exits, I don't really know 
why it was coded like this but that means that using
main_thread_id might put us in a 'dead' thread.

  I never managed to send a patch for this, 
and I suspect that there are some hidden reason for
this strange behavior!

  We could insert code that stops all threads into
win32_wait at the location of the 
deprecated_ui_loop_hook code,
but I don't know really how to handle this:
if you suspend manually all threads, you can of course
set ourstatus, but the question is how do you coordinate this 
with the next call to win32_resume?
Is it enough to add a global variable
threads_suspended_manually (not sure this is the best name)
and to add something like
if (!threads_suspended_manually)
  res = ContinueDebugEvent (...)
else
  /* Here we add the code to resume all threads */

If fear that we might need more special code, for instance if
win32_resume is called with a non zero signal to pass,
which would of course be impossible in that case.

  I would personally prefer to postpone this 
to a later patch, but Christopher should 
tell us what the best way is.


Pierre Muller
Pascal language support maintainer for GDB


 



  reply	other threads:[~2008-06-23 16:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-21 17:05 Pierre Muller
2008-06-21 18:37 ` Christopher Faylor
2008-06-22  3:17   ` Daniel Jacobowitz
2008-06-22  3:18     ` Corinna Vinschen
2008-06-23  1:04       ` Christopher Faylor
2008-06-23  1:10         ` Corinna Vinschen
2008-06-23  7:40         ` Pierre Muller
2008-06-23 12:00           ` Christopher Faylor
2008-06-23 16:05             ` Pierre Muller
2008-06-23 17:00               ` Pedro Alves
2008-06-23 17:25                 ` Pierre Muller [this message]
2008-06-23 18:03                 ` Christopher Faylor
2008-06-23 19:24                   ` Pedro Alves
2008-06-23 20:33                     ` Pierre Muller
2008-06-23 21:06                       ` Joel Brobecker
2008-06-24  6:33                         ` Christopher Faylor
2008-06-24 13:36                           ` [RFC-v3] " Pierre Muller
2008-06-24  2:33                     ` [RFC] " Christopher Faylor
2008-06-24 13:54                       ` Pedro Alves
2008-06-24 18:29                         ` Christopher Faylor
2008-06-22  9:00     ` Christopher Faylor
2008-06-23  8:52   ` [RFC v2] " Pierre Muller

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='001601c8d54a$f45a1660$dd0e4320$@u-strasbg.fr' \
    --to=muller@ics.u-strasbg.fr \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /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