delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/04/29/12:48:22

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Date: Thu, 29 Apr 1999 20:36:49 +0400
From: Egor Duda <deo AT logos-m DOT ru>
X-Mailer: The Bat! (v1.029) S/N A0F2A05A
Reply-To: Egor Duda <deo AT logos-m DOT ru>
Organization: DEO
Message-ID: <6858.990429@logos-m.ru>
To: cygwin-developers AT sourceware DOT cygnus DOT com
Subject: gdb "attach" and sharing thread info between processes
Mime-Version: 1.0

Hi!

  I've tried to use gdb "attach" feature to debug cygwin program and
got  INVALID_HANDLE_ERROR in gdb/win32_nat.c. As far, as i see, that's
due  to  incorrect   value   of   current_process  and  current_thread
variables. They're  initialized  correctly  when  gdb starts a debugee
as a child (through CreateProcess call). But when we're "attach"ing to
some other process,    those    variables   have   wrong   values   :(

  As for `current_process',  this  could  be  easily fixed, by calling
`OpenProcess'  when attaching to debugee. I've patched win32-nat.c and
managed    to    watch    vars    from   debugee   (before   patching,
ReadProcessMemory() fails with INVALID_HANDLE_ERROR.)

  But threads are different  matter...  :(  MS  promise  to  implement
OpenThread syscall in Win2000 only, and they say, that the only way to
get  thread  handle  is  to  ask  a  parent process to reveal it. As a
solution,  i would propose to move threads array (threads var declared
in  winsup/debug.cc)  from  per-process to shared area and implement a
call  to  cygwin  dll  to  give  away  thread  handle by processId and
ThreadId by scanning this thread list.

  With this call gdb will be able to initialize current_thread variable
properly when attaching to cygwin process.

So, the question is -- is it a "right way"?

Egor.            mailto:deo AT logos-m DOT ru ICQ 5165414 FidoNet 2:5020/496.19


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019