From: Pedro Alves <palves@redhat.com>
To: "Marc Brünink" <marc@nus.edu.sg>
Cc: Doug Evans <dje@google.com>, gdb <gdb@sourceware.org>
Subject: Re: Timer
Date: Tue, 07 May 2013 08:48:00 -0000 [thread overview]
Message-ID: <5188BFC1.8090607@redhat.com> (raw)
In-Reply-To: <52771B43-9617-412D-B9F8-5730757D6BAF@nus.edu.sg>
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 <marc@nus.edu.sg> 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
next prev parent reply other threads:[~2013-05-07 8:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 9:52 Timer Marc Brünink
2013-05-07 4:43 ` Timer Doug Evans
2013-05-07 6:42 ` Timer Marc Brünink
2013-05-07 8:48 ` Pedro Alves [this message]
2013-05-07 10:18 ` Timer Marc Brünink
2013-05-07 10:51 ` Timer Pedro Alves
2013-05-07 13:44 ` Timer Tom Tromey
2013-05-07 13:28 ` Timer Phil Muldoon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5188BFC1.8090607@redhat.com \
--to=palves@redhat.com \
--cc=dje@google.com \
--cc=gdb@sourceware.org \
--cc=marc@nus.edu.sg \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox