Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Roland Puntaier <Roland.Puntaier@br-automation.com>
To: gdb@sourceware.org
Subject: Re: gdb-6.6 mingw port hangs after Ctrl-C
Date: Wed, 22 Aug 2007 11:10:00 -0000	[thread overview]
Message-ID: <OFE68D095B.3ACA11DC-ONC125733F.00375C8A-C125733F.003D5E58@br-automation.com> (raw)
In-Reply-To: <20070821025607.GA14389@ednor.casa.cgf.cx>

> Christopher Faylor:
> You can stop another thread with a "SuspendThread()" call and you can
> cause the thread to resume in another location with a "ResumeThread()"
> by changing the EIP that is passed to it.  However, if you do that while
> you are in the middle of a low-level Windows function which, say, holds
> a mutex, then you are going to eventually run into problems.

I wanted to try this with the following changes in remoted.c,
but I could'nt find a way to get the EIP of the new address, i.e. 
"continueHere:". 
How could that be done?

#include <windows.h>//Added
static HANDLE h_main_thread = 0;//Added

static void
interrupt_query (void)
{
  target_terminal_ours ();

  if (query ("Interrupted while waiting for the program.\n\
Give up (and stop debugging it)? "))
    {
      target_mourn_inferior ();
      if (h_main_thread){//Added
        CONTEXT threadContext;//Added
        SuspendThread(h_main_thread);//Added
        GetThreadContext(h_main_thread,&threadContext);//Added
        threadContext.Eip = &continueHere;//Added and wished it would work
        SetThreadContext(h_main_thread,&threadContext);//Added
        ResumeThread(h_main_thread);//Added
        ExitThread(0);//Added
      }//Added
continueHere://Added and wished it would work
      deprecated_throw_reason (RETURN_QUIT);
    }

  target_terminal_inferior ();
}

...

static ptid_t
remote_wait (ptid_t ptid, struct target_waitstatus *status)
{
...
      h_main_thread=GetCurrentThread();//Added
      ofunc = signal (SIGINT, remote_interrupt);
      getpkt (&rs->buf, &rs->buf_size, 1);
      signal (SIGINT, ofunc);
      h_main_thread=0;//Added
....


> Christopher Faylor:
> You'd need to use overlapped I/O for those situations.  If you do that
> then you'd have to decide whether you want gdb to work on Windows 9x/Me
> or not.
This seems less brute force: 
 WSARecv(), WSAWaitForMultipleEvents() instead of recv() 
 and let WSAWaitForMultipleEvents() return through an event signaled in 
interrupt_query()
 and if that event happened, continue calling deprecated_throw_reason 
(RETURN_QUIT); this time from the main thread.


  parent reply	other threads:[~2007-08-22 11:10 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-20 16:20 Roland Puntaier
2007-08-20 16:24 ` Daniel Jacobowitz
2007-08-20 19:16   ` Eli Zaretskii
2007-08-20 19:31     ` Daniel Jacobowitz
2007-08-21  2:56       ` Christopher Faylor
2007-08-21 17:42         ` Jim Blandy
2007-08-21 19:09           ` Eli Zaretskii
2007-08-21 23:47             ` Jim Blandy
2007-08-22  3:13               ` Eli Zaretskii
2007-08-22 10:13                 ` Dave Korn
2007-08-22 19:17                   ` Eli Zaretskii
2007-08-24  9:19                     ` Roland Puntaier
2007-08-24 16:12                     ` Roland Puntaier
2007-08-21 22:55           ` Christopher Faylor
2007-08-22 11:10         ` Roland Puntaier [this message]
2007-08-22 19:20           ` Eli Zaretskii
2007-08-23  2:49             ` 答复: (Rising Spam Alert)Re: " xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
2007-08-23  2:49             ` xchen
     [not found]             ` <NUTMEGt3HvoFOAmEaJs0000003d@mail.artimi.com>
2007-08-23  9:30               ` Dave Korn
2007-08-21  3:22       ` 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=OFE68D095B.3ACA11DC-ONC125733F.00375C8A-C125733F.003D5E58@br-automation.com \
    --to=roland.puntaier@br-automation.com \
    --cc=gdb@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