From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25908 invoked by alias); 7 May 2013 08:48:16 -0000 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 Received: (qmail 25471 invoked by uid 89); 7 May 2013 08:48:10 -0000 X-Spam-SWARE-Status: No, score=-8.4 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 07 May 2013 08:48:09 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r478m4OG000352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 May 2013 04:48:04 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r478m2uF004565; Tue, 7 May 2013 04:48:03 -0400 Message-ID: <5188BFC1.8090607@redhat.com> Date: Tue, 07 May 2013 08:48:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Marc_Br=FCnink?= CC: Doug Evans , gdb Subject: Re: Timer References: <52771B43-9617-412D-B9F8-5730757D6BAF@nus.edu.sg> In-Reply-To: <52771B43-9617-412D-B9F8-5730757D6BAF@nus.edu.sg> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2013-05/txt/msg00032.txt.bz2 On 05/07/2013 07:42 AM, Marc Brünink wrote: > > On May 7, 2013, at 12:43 PM, Doug Evans wrote: > >> On Mon, May 6, 2013 at 2:52 AM, Marc Brünink wrote: >>> I want to execute a piece of code at regular intervals. Actually I'm sampling $pc. >>> (let's not go into detail why I use gdb) >>> >>> My current solution just starts another process that sends a SIGTRAP to the debugged application. Using a simple script I can print the $pc. >>> >>> However, I just realised that this approach does not work too well. If gdb is stopped due to a breakpoint it will interpret the received SIGTRAP as another hit of the very same breakpoint. >>> >>> Reproduce: >>> 1. Attach to any program >>> 2. Create any breakpoint >>> 3. Wait until breakpoint is hit >>> 4. Send SIGTRAP to debugged application >>> 5. continue >>> >>> Actually, now that I think about it, I should have anticipated this behaviour. >>> Is there a better way to execute a piece of code at regular intervals? You could also use another signal instead of SIGTRAP. >> bash$ man setitimer > > I suppose you are suggesting to modify either GDB or the application. This is exactly what I don't want. Any other way to accomplish this (using gdb)? You could use LD_PRELOAD to inject a library that uses setitimer into your program. I guess you could do it with gdb python scripting too. -- Pedro Alves