This is the mail archive of the
mailing list for the GDB project.
- From: Marc Brünink <marc at nus dot edu dot sg>
- To: Doug Evans <dje at google dot com>
- Cc: gdb <gdb at sourceware dot org>
- Date: Tue, 7 May 2013 14:42:18 +0800
- Subject: Re: Timer
- References: <A941B6D9-B0CA-4EC2-AEFE-476014555337 at nus dot edu dot sg> <CADPb22Q0rQCQMee992CZBPHkjJOvBkCZMhqHx0V_y7v=VWDORA at mail dot gmail dot com>
On May 7, 2013, at 12:43 PM, Doug Evans wrote:
> On Mon, May 6, 2013 at 2:52 AM, Marc Brünink <firstname.lastname@example.org> 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.
>> 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?
> 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)?