Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pedro Alves" <pedro_alves@portugalmail.pt>
To: "Pierre Muller" <muller@ics.u-strasbg.fr>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] gdb/win32-nat.c: do not call CloseHandle on process and thread handles
Date: Thu, 22 Nov 2007 14:37:00 -0000	[thread overview]
Message-ID: <4053daab0711220637h2bc01450ra45a19f4013fd44d@mail.gmail.com> (raw)
In-Reply-To: <002c01c82d0f$8c789050$a569b0f0$@u-strasbg.fr>

Pierre Muller wrote:
> > You'll still have to somehow close this process handle
> (current_process_handle):
> >
> > /* Called in pathological case where Windows fails to send a
> >    CREATE_PROCESS_DEBUG_EVENT after an attach.  */
> > static DWORD fake_create_process (void) {
> >   current_process_handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE,
> >                                         current_event.dwProcessId);
> >   main_thread_id = current_event.dwThreadId;
> >   current_thread = win32_add_thread (main_thread_id,
> >
> current_event.u.CreateThread.hThread);
> >   return main_thread_id;
> > }
>
> I don't think that anything in the testsuite checks
> this case.
>
>
>   The only code location that calls this function has also some comment:
>
>     case CREATE_THREAD_DEBUG_EVENT:
>       DEBUG_EVENTS (("gdb: kernel event for pid=%d tid=%x code=%s)\n",
>                      (unsigned) current_event.dwProcessId,
>                      (unsigned) current_event.dwThreadId,
>                      "CREATE_THREAD_DEBUG_EVENT"));
>       if (saw_create != 1)
>         {
>           if (!saw_create && attach_flag)
>             {
>               /* Kludge around a Windows bug where first event is a create
>                  thread event.  Caused when attached process does not have
>                  a main thread. */
>               retval = ourstatus->value.related_pid = fake_create_process
> ();
>               saw_create++;
>             }
>
>   But what does the wording 'does not have a main thread' mean?
> Is there a way to create such a process in order to try to find out
> how we need to solve this issue?

Try attaching to the example posted at threads/1048.

> Concerning attached processes that send a CREATE_THREAD_DEBUG_EVENT first,
> is the CREATE_PROCESS_DEBUG_EVENT event still sent to debugger,
> but after the CREATE_THREAD_DEBUG_EVENT?
>

Don't know, you'll have to check, but I doubt it.
It just might be easier to always open a handle to the process (OpenProcess),
and not touch the one coming on the event.  Then you would always close
the process handle, because you know you're the one who opened it.  OTTOMH,
gdbserver does something similar, but leaks.
This uses an extra handle on the normal case, but I don't think I'd care, as
long as there are no leaks. Otherwise, you'll just have to keep a flag
somewhere.

-- 
Pedro Alves


  reply	other threads:[~2007-11-22 14:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-22 12:49 Pierre Muller
2007-11-22 12:56 ` Pedro Alves
2007-11-22 13:56   ` Pierre Muller
2007-11-22 14:37     ` Pedro Alves [this message]
2007-11-23  1:18       ` Christopher Faylor
2007-11-23 16:21         ` Pierre Muller
2007-11-24  5:44           ` Christopher Faylor
2007-11-26  9:21             ` [RFA 2] " Pierre Muller
2007-12-02  5:46               ` Christopher Faylor
2007-11-23 16:33         ` [RFA] " Pedro Alves

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=4053daab0711220637h2bc01450ra45a19f4013fd44d@mail.gmail.com \
    --to=pedro_alves@portugalmail.pt \
    --cc=gdb-patches@sourceware.org \
    --cc=muller@ics.u-strasbg.fr \
    /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