This is the mail archive of the
mailing list for the GDB project.
Re: Detecting when gdb is attached
- From: paawan oza <paawan1982 at yahoo dot com>
- To: "Gruenhagen, Andreas" <andreas dot gruenhagen at sap dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Thu, 4 Nov 2010 10:26:20 -0700 (PDT)
- Subject: Re: Detecting when gdb is attached
- References: <372C920CA9488345BDECCD4B62FF71D00F717855E5@DEWDFECCR08.wdf.sap.corp>
In my knowledge, the moment you attach gdb, your process is in stopped state and
done by kernel using SIGSTOP.
that time you process is already at some instruction.
I am not sure about youre requirement, but just after attach you can use signal
command to signals the process and write your own signal handler to notify you
app (for example 'signal SIGCONT').
but again you need to modify code.
if you are looking for no insn execution until gdb attached proabably try with
sigsuspend, sigprocmask sort of stuff.. but that changes code too.
I am not sure that helps.
----- Original Message ----
From: "Gruenhagen, Andreas" <email@example.com>
To: "firstname.lastname@example.org" <email@example.com>
Sent: Thu, November 4, 2010 7:10:21 PM
Subject: Detecting when gdb is attached
Dear gdb community,
I'm developing an application which cannot be started from within the gdb.
Therefore, I have the start the application and attach the gdb afterwards. In
some cases it would be nice to have the application wait in a spin loop until
the debugger is attached. Is there any way of accomplishing such a thing?
I certainly can program the spin loop myself, attach the debugger, and then
manually change a variable from within the debugger to end the loop. But,
obviously, this is not an elegant solution (lots of manual work, code has to be
changed and it has to be recompiled,and eventually, I might forget to delete the
spin loop after debugging).
I thought of having some sort of action which is executed when the gdb is
attached and detached, this could be for example used to switch a static flag in
Is something like this possible ?