Using gdb as a trace agent

Ramana Radhakrishnan ramana.radhakrishnan@codito.com
Tue May 18 07:07:00 GMT 2004


Hi Alex,

Alexandre Courbot wrote:

>> Yep.  Here's why it's only been implemented remotely:
>
>
> Is it possible to use tracepoints remotely as of today? I mean, the 
> code seems to be here in GDB, but is there a target that supports them?
>
> Say I have 2 computers running GNU/Linux and a network connection 
> between them. Can I then use tracepoints to analyze my program as of 
> today?

AFAIK no .

>
>> So for native configurations, the challenge is to find a low-overhead
>> way to handle those traps.  For example, one could add tracepoint
>> support to gdbserver, but then you'd have one process collecting data
>> from another process via ptrace or some other system call, and it
>> wouldn't be very lightweight.
>
>
> If gdbserver is running on a different host than gdb, then I guess the 
> overhead would be comparable to any other system, right? (just a 
> question, I'm just a regular gdb user for now). So maybe the first 
> thing to do would be to add tracepoint support to gdbserver, since you 
> seem to say it's missing.
>
> On a completely local configuration, the problem is different indeed. 
> Maybe if you can evaluate the amount of data to be collected, you can 
> reserve a large enough area of memory that would receive all the 
> traced datas, without any expression evaluation during collection. 
> Evaluation would occur during data examination, so the program gets 
> disturbed as less as possible while running. Problem: make sure memory 
> doesn't blow up and avoid allocations while debugging. These two 
> reasons are probably what makes tracepoints implementation easier on a 
> distributed architecture.


>
> Well, these are just random ideas. As I said, I don't have a clear 
> idea yet of gdb's internals.
>
> I'm very interested in that anyway. We need here to be able to 
> evaluate our OSes in an easy, non-intrusive and efficient way. GDB has 
> proven it was great even for non-debugging purposes (for instance, 
> introspecting a program and get some datas out of it to be exploited 
> by gnuplot), with tracepoints it would be just *fine*. Oh, and file 
> IOs to write the collected datas into files without debuggee and GDB 
> output with them. ;)
>
> Just saw that there has been some discussion about this subject recently:
>
> http://sources.redhat.com/ml/gdb/2004-01/msg00012.html
> Seems the ideas were nearly the same. Did it give some results (i.e. 
> code)?

Well we internally have some code which is slightly dated but should not 
be too much effort to integrate into the current CVS tree. (The idea was 
to make gdbserver multithreaded and have a separate thread running which 
would collect the trace data. That was simpler and easier to implement 
in a hurry.It should not be too much of a problem to do asynchronous IO 
with gdbserver too.  ) . So that is the current status with respect to 
the thread that you are referring to . Let me check with the code  we 
have and get back to you. What is the target that you need this for ? 
good old x86?

cheers
Ramana






More information about the Gdb mailing list