From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18211 invoked by alias); 4 Nov 2010 17:26:30 -0000 Received: (qmail 18195 invoked by uid 22791); 4 Nov 2010 17:26:28 -0000 X-SWARE-Spam-Status: No, hits=0.1 required=5.0 tests=AWL,BAYES_20,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nm12.bullet.mail.sp2.yahoo.com (HELO nm12.bullet.mail.sp2.yahoo.com) (98.139.91.82) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 04 Nov 2010 17:26:22 +0000 Received: from [98.139.91.69] by nm12.bullet.mail.sp2.yahoo.com with NNFMP; 04 Nov 2010 17:26:21 -0000 Received: from [98.139.91.51] by tm9.bullet.mail.sp2.yahoo.com with NNFMP; 04 Nov 2010 17:26:21 -0000 Received: from [127.0.0.1] by omp1051.mail.sp2.yahoo.com with NNFMP; 04 Nov 2010 17:26:21 -0000 Received: (qmail 53223 invoked by uid 60001); 4 Nov 2010 17:26:20 -0000 Message-ID: <710963.53020.qm@web112503.mail.gq1.yahoo.com> Received: from [123.237.143.28] by web112503.mail.gq1.yahoo.com via HTTP; Thu, 04 Nov 2010 10:26:20 PDT References: <372C920CA9488345BDECCD4B62FF71D00F717855E5@DEWDFECCR08.wdf.sap.corp> Date: Thu, 04 Nov 2010 17:26:00 -0000 From: paawan oza Subject: Re: Detecting when gdb is attached To: "Gruenhagen, Andreas" Cc: "gdb@sourceware.org" In-Reply-To: <372C920CA9488345BDECCD4B62FF71D00F717855E5@DEWDFECCR08.wdf.sap.corp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00025.txt.bz2 Hi, 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. Regards, Oza. ----- Original Message ---- From: "Gruenhagen, Andreas" To: "gdb@sourceware.org" 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 the debugee. Is something like this possible ? Best regards Andreas