Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Marc Brünink" <marc@nus.edu.sg>
To: Doug Evans <dje@google.com>
Cc: gdb <gdb@sourceware.org>
Subject: Re: Timer
Date: Tue, 07 May 2013 06:42:00 -0000	[thread overview]
Message-ID: <52771B43-9617-412D-B9F8-5730757D6BAF@nus.edu.sg> (raw)
In-Reply-To: <CADPb22Q0rQCQMee992CZBPHkjJOvBkCZMhqHx0V_y7v=VWDORA@mail.gmail.com>


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?
> 
> 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)?

Marc
From gdb-return-42104-listarch-gdb=sources.redhat.com@sourceware.org Tue May 07 07:33:38 2013
Return-Path: <gdb-return-42104-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 32724 invoked by alias); 7 May 2013 07:33:38 -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 32653 invoked by uid 89); 7 May 2013 07:33:37 -0000
X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1
Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131)    by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 07 May 2013 07:33:36 +0000
Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58])	by relay1.mentorg.com with esmtp 	id 1UZcP1-0005rE-1r from Yao_Qi@mentor.com ; Tue, 07 May 2013 00:33:35 -0700
Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675);	 Tue, 7 May 2013 00:33:35 -0700
Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Tue, 7 May 2013 00:33:33 -0700
Message-ID: <5188AE42.50308@codesourcery.com>
Date: Tue, 07 May 2013 07:33:00 -0000
From: Yao Qi <yao@codesourcery.com>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2
MIME-Version: 1.0
To: Suchakra Sharma <suchakrapani.sharma@polymtl.ca>
CC: <gdb@sourceware.org>, <simon.marchi@polymtl.ca>
Subject: Re: Debugging agent library
References: <1367868074.5194.19.camel@station15.dorsal.polymtl.ca>
In-Reply-To: <1367868074.5194.19.camel@station15.dorsal.polymtl.ca>
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: 8bit
X-SW-Source: 2013-05/txt/msg00031.txt.bz2
Content-length: 1745

Hello,
Suchakra,

On 05/07/2013 03:21 AM, Suchakra Sharma wrote:
> Hi,
>
> We tried to find out how to use the debugging agent library here [1] but
> were unsuccessful. As of now, we have built a test app linked to dagent

It would be nice if you post some details about how you use dagent and
the error message you got.

> which creates a socket file and expects commands. We wish to use it with
> GDB as well as other applications to primarily objective of tracing
> using GDB's fast tracepoint infra. Any help in this regard will be
> appreciated.
>
> [1] https://github.com/MentorEmbedded/Debug-Agent-Library/wiki
>

I checked out the wiki and realize that the existing documentation has
an assumption that readers are much familiar with GDB and GDB
tracepoint.  The session below shows how to install fast tracepoint
through dagent.

In one console, start the program in GDBserver,

$ LD_PRELOAD=/install/lib/libdagent.so ./gdbserver/gdbserver :1234
./testsuite/gdb.base/break

In the other console, start GDB and connect to GDBserver,

$ ./gdb ./testsuite/gdb.base/break
(gdb) target remote :1234
(gdb) b main
(gdb) c

(gdb) b marker4  // set breakpoint to make sure program doesn't exit
(gdb) ftrace *0x0804851e // set fast tracepoint at certain address
(gdb) set agent on   // enable agent
(gdb) tstart         // start tracing
(gdb) c
(gdb) tstop          // stop tracing
(gdb) tfind          // examine the trace frames tracepoint collects
Found trace frame 0, tracepoint 3
#0  main (argc=<unavailable>, argv=<unavailable>, envp=<unavailable>) at
../../../../git/gdb/testsuite/gdb.base/break.c:94
94          marker1 ();  /* set breakpoint 11 here */

Let me know if you get something else or obviously wrong.

--
Yao (齐尧)


  reply	other threads:[~2013-05-07  6:42 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   ` Marc Brünink [this message]
2013-05-07  8:48     ` Timer Pedro Alves
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=52771B43-9617-412D-B9F8-5730757D6BAF@nus.edu.sg \
    --to=marc@nus.edu.sg \
    --cc=dje@google.com \
    --cc=gdb@sourceware.org \
    /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