From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31474 invoked by alias); 4 Nov 2010 16:19:09 -0000 Received: (qmail 31465 invoked by uid 22791); 4 Nov 2010 16:19:07 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Nov 2010 16:19:03 +0000 Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id oA4GJ1f8031628 for ; Thu, 4 Nov 2010 09:19:01 -0700 Received: from ywp4 (ywp4.prod.google.com [10.192.16.4]) by wpaz29.hot.corp.google.com with ESMTP id oA4GIWr0008224 for ; Thu, 4 Nov 2010 09:19:00 -0700 Received: by ywp4 with SMTP id 4so1793357ywp.7 for ; Thu, 04 Nov 2010 09:19:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.90.65.13 with SMTP id n13mr1397133aga.171.1288887539357; Thu, 04 Nov 2010 09:18:59 -0700 (PDT) Received: by 10.90.81.2 with HTTP; Thu, 4 Nov 2010 09:18:59 -0700 (PDT) In-Reply-To: <372C920CA9488345BDECCD4B62FF71D00F717855E5@DEWDFECCR08.wdf.sap.corp> References: <372C920CA9488345BDECCD4B62FF71D00F717855E5@DEWDFECCR08.wdf.sap.corp> Date: Thu, 04 Nov 2010 16:19:00 -0000 Message-ID: Subject: Re: Detecting when gdb is attached From: Doug Evans To: "Gruenhagen, Andreas" Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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/msg00024.txt.bz2 On Thu, Nov 4, 2010 at 6:40 AM, Gruenhagen, Andreas wrote: > 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 loo= p 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 th= en 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 t= o 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 f= lag in the debugee. > Is something like this possible ? Hi. I'm not sure I understand the issue. I can't tell if adding code to the app to detect when gdb has attached is ok or not. [e.g. "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?" versus "I might forget to delete the spin loop"] Guessing, what if you passed a flag to the app to enable the spin loop? Then you can keep the spin loop and only specify the flag when you want to attach with gdb.