delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/05/14/11:34:52

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
q=dns; s=default; b=mpe7+9cnaFVzWw0qpKAmoBoPuCR60haaz1h/I/0Odjj
EUZW+Gkz326cEYG4Kfz5xySnPVPaHv5dO8sbs6LWF97y4fFpgKmfCabrRwyYqPcX
41DhPviM/whwC5RDLYeFMT0YrhevBBjQuxuX6h/r69bQm8vmz9luYUH6uA9J3esI
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
s=default; bh=3xZpPi6GgmFAO6anFRw/09sNlwo=; b=RZ5buGXjMWZaeEL+/
87wtjVHp29ZK+HSviobCtK1sMwiLmh+fhIVROniYFrUPmhiiolHDMCP4aZ/UKorr
GrB7ZXSTgDL/symePN8rGv1OugfgsdBPJGt1Mlb4mxH7eyc/NrcZywe0oRxUiQOU
tCUzNZ+NadqcPTXtLdhMDnl4+E=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-lb0-f181.google.com
X-Received: by 10.112.12.8 with SMTP id u8mr2940201lbb.9.1400081669078; Wed, 14 May 2014 08:34:29 -0700 (PDT)
Message-ID: <53738CF9.3020706@gmail.com>
Date: Wed, 14 May 2014 19:34:17 +0400
From: LRN <lrn1986 AT gmail DOT com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Thunderbird/32.0a1
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Debugging sub-processes with gdb
References: <f5boaz0e6qb DOT fsf AT troutbeck DOT inf DOT ed DOT ac DOT uk> <20140514152505 DOT GB6620 AT ednor DOT casa DOT cgf DOT cx>
In-Reply-To: <20140514152505.GB6620@ednor.casa.cgf.cx>
X-IsSubscribed: yes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14.05.2014 19:25, Christopher Faylor wrote:
> On Wed, May 14, 2014 at 04:10:36PM +0100, Henry S. Thompson wrote:
>> I'm trying to debug a problem with xemacs that involves the child 
>> process forked when you execute M-x shell.
>> 
>> None of the mechanisms in the gdb documentation for choosing to step 
>> into the child process (instead of the parent) after a fork() seem to 
>> work for me.  That is, in particular, setting follow-for-mode to child 
>> still leaves me in the parent after stepping over a fork().
>> 
>> Setting detach-on-fork to 'off' also seems to have no effect.
>> 
>> Have I misunderstood something, or does this aspect of gdb just not work
>> under cygwin (x86_64, 1.7.29-2)?
> 
> Debugging subprocesses doesn't work for Windows gdb.  Sorry.
> 
> If you have control over the code you could have it print a pid, wait, and
> then attach to it with gdb.  That works.

What i do in these cases:
1) Find the call to CreateProcess() that spawns the child (if it uses some
kind of _spawn() instead, you're screwed)
2) Add a breakpoint (b1) before the call and a breakpoint (b2) after the call
3) commands b1
set createprocessflags=createprocessflags | 4
c
end

(replace createprocessflags with the variable used to hold the flags)
4) commands b2
p processinfo.dwProcessId
end

(replace processinfo with the variable used to hold handles and IDs for
spawned child process/thread)

This way all processes will be spawned in suspended state (that's what 4 is
for), and gdb will stop on a breakpoint after the call to wait for you to
figure out what to do. If you want to debug the child, re-attach gdb to it,
or launch a new gdb instance and attach that one. In either case, add a
breakpoint at main, then continue. Once that is done, use ProcessHacker (or
anything similar) to Resume the suspended child process. If the child itself
spawns children you want to debug, repeat these steps there as well.

I was able to debug ld.exe this way (it is spawned by collect2.exe, which is
spawned by gcc.exe).

- -- 
O< ascii ribbon - stop html email! - www.asciiribbon.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)

iQEcBAEBAgAGBQJTc4z5AAoJEOs4Jb6SI2CwLokIAOHl4OnE6AmqI5VX92u27EEL
Mhmr3/QF8N3NkH6lJJmydk5aczEyfq65Xh2LYJsfUhZ8YWSvqQYHZhnQHQ38JIYR
LrlatzKswRbpSphal3VfVIEyrMaK1vACWJSC0hzScDd+JPSL399i1hGgTE2rEYoV
6b4jLRAZIM3H5N3OyeUctqL11JSZsKEhxWUM0APMmMbyrFBS4+hxDF09Lxv3VnQU
5mA2OFE6r7yXt+ju4lo0zSWmJ1+jjY2ikIW1ngD88Z2P2TIkfrEOSUZS4SWvt0O8
JJHokW5Y5PO3D7v+I0VwcC6Rjqn8dnNK5H6aO3u1QxUowrARNc+SbL7WeT8mt/I=
=TAj2
-----END PGP SIGNATURE-----

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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