From: "Marc Brünink" <marc@nus.edu.sg>
To: Pedro Alves <palves@redhat.com>
Cc: Doug Evans <dje@google.com>, gdb <gdb@sourceware.org>
Subject: Re: Timer
Date: Tue, 07 May 2013 10:18:00 -0000 [thread overview]
Message-ID: <AC3E31D9-B46C-423D-B414-F3C50C0896A9@nus.edu.sg> (raw)
In-Reply-To: <5188BFC1.8090607@redhat.com>
On May 7, 2013, at 4:48 PM, Pedro Alves wrote:
> 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.
Yes, this is probably the way to go. However, I remember having some issues with different signals. Esp if an applications depends on the delivery of a signal and I use it to implement the timer interrupt. But I suppose using SIGPROF or something similar should be fine.
>
>>> 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.
Possible, but contradicts the gdb-only approach.
> I guess you could do it with gdb python scripting too.
This would be nice but does not work. As far as I remember there is a sigsupend in linux-nat.c which will thwart using a simple threading.Timer. But I might be wrong here. Whatever the reason, it does not work.
Marc
From gdb-return-42109-listarch-gdb=sources.redhat.com@sourceware.org Tue May 07 10:19:00 2013
Return-Path: <gdb-return-42109-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 7725 invoked by alias); 7 May 2013 10:19:00 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 7714 invoked by uid 89); 7 May 2013 10:18:59 -0000
X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,SPF_PASS,TW_NX autolearn=ham version=3.3.1
Received: from mail-da0-f43.google.com (HELO mail-da0-f43.google.com) (209.85.210.43) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 07 May 2013 10:18:58 +0000
Received: by mail-da0-f43.google.com with SMTP id u7so253039dae.30 for <gdb@sourceware.org>; Tue, 07 May 2013 03:18:57 -0700 (PDT)
X-Received: by 10.66.8.69 with SMTP id p5mr1910944paa.57.1367917970512; Tue, 07 May 2013 02:12:50 -0700 (PDT)
Received: from [192.168.0.104] ([112.233.222.117]) by mx.google.com with ESMTPSA id aa8sm29572136pad.14.2013.05.07.02.12.46 for <multiple recipients> (version=TLSv1 cipherìDHE-RSA-RC4-SHA bits\x128/128); Tue, 07 May 2013 02:12:48 -0700 (PDT)
Message-ID: <5188C586.6010201@gmail.com>
Date: Tue, 07 May 2013 10:19:00 -0000
From: xunxun <xunxun1982@gmail.com>
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
MIME-Version: 1.0
To: John Martin <jmartin@larraioz.com>
CC: gdb@sourceware.org
Subject: Re: Doubt with gdb
References: <5188C0F5.2010306@larraioz.com> <5188C241.9000209@larraioz.com> <5188C2D9.2020503@gmail.com> <5188C421.3060102@larraioz.com>
In-Reply-To: <5188C421.3060102@larraioz.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-SW-Source: 2013-05/txt/msg00036.txt.bz2
Content-length: 674
亠2013/5/7 æÂÂæÂÂ亠17:06, John Martin Ã¥ÂÂéÂÂ:
> Hello,
>
> And, is it possible to extract only variables of a function?
>
> info variables return me all variables of program.
>
> info variables "function" ????
>
>
> El 07/05/13 11:01, xunxun escribió:
>> 亠2013/5/7 æÂÂæÂÂ亠16:58, John Martin Ã¥ÂÂéÂÂ:
>>> Hello,
>>> is there any way to tell GDB that return all static variables of a
>>> function?
>>> best regards.
>>>
>>>
>> |info variables |
>> ||
>> <http://sourceware.org/gdb/current/onlinedocs/gdb/Symbols.html#index-info-variables-918>
>> --
>> Best Regards,
>> xunxun
>
Maybe you need the local variables?
info local
>
> --
--
Best Regards,
xunxun
next prev parent reply other threads:[~2013-05-07 10:18 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 ` Timer Pedro Alves
2013-05-07 10:18 ` Marc Brünink [this message]
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=AC3E31D9-B46C-423D-B414-F3C50C0896A9@nus.edu.sg \
--to=marc@nus.edu.sg \
--cc=dje@google.com \
--cc=gdb@sourceware.org \
--cc=palves@redhat.com \
/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