Re: Debugging agent library

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAFXXi0mqnd7XQQXFX5mQXF0r8dRn+crsyz8g0uip=svZpm245Q@mail.gmail.com>
Hi Yao,

On 7 May 2013 03:33, Yao Qi <[email protected]> wrote:
> 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

tstart here gives me the error:

(gdb) tstart
Target returns error code '.In-process agent library not loaded in
process.  Fast and static tracepoints unavailable.'

I compiled my small app using (libdagent.so is already in my ld search path):
$ gcc test.c -Wall -g -ldagent -O0

I run the gdbserver using:
$ LD_PRELOAD=/usr/local/lib/libdagent.so gdbserver :1234 ./a.out

Then I use the same commands as you have shown in your example. info
sharedlibrary shows that the agent is loaded:

(gdb) info sharedlibrary
From                To                  Syms Read   Shared Object Library
0x00007ffff7dddb00  0x00007ffff7df685b  Yes (*)     /lib64/ld-linux-x86-64.so.2
0x00007ffff7bd38c0  0x00007ffff7bd8e38  Yes         /usr/local/lib/libdagent.so
0x00007ffff785ba20  0x00007ffff797c72c  Yes (*)     /lib64/libc.so.6
0x00007ffff7625660  0x00007ffff7630eb8  Yes (*)     /lib64/libpthread.so.0

Is there something I am missing here?

> (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 (齐尧)

Also, is it possible to write our own application to control tracing,
instead of using GDB? I guess we would need to talk to the agent using
the IPA protocol, is that right?

Thanks !

Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.