This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C programs introspection using binutils/gdb


On Thu, Apr 01, 2004 at 03:15:42PM +0200, Alexandre Courbot wrote:
> Hello everybody,
> 
> I'm currently trying to perform very fine-grained benchmarks on a C 
> application. Like, saving the values of a variable every time it 
> changes, or following a chained-list of pointers when some event occurs 
> in the program. For (good) design reasons I don't want to add special 
> code to the program's source. In short, what I'd like to achieve is 
> introspection of C programs without anything else than debugging 
> symbols, and defining behaviors the monitoring program should adopt when 
> some even occurs.
> 
> As a concrete exemple, let's say I'd like to produce a gnuplot graph 
> with the time in abscissa and the value of a variable in ordinate. The 
> time and values would be saved into an array every time the variable 
> changes.
> 
> I've considered using gdb for this. I don't know much about it but it 
> looks like it is easy to associate a gdb function to an event (i.e. 
> "scripting" gdb instead of using it in interactive mode). Also, the 
> great advantage of gdb is that it can catch any kind of event and let 
> the user see directly through the C structures.
> 
> I wonder however if this is the best solution for that purpose, and if I 
> haven't overestimated gdb scripting capabilities in that respect. Or 
> maybe there is another tool that allows similar results (I've thought of 
> gprof but it seems much less controllable than gdb). I'd also be 
> interested in hearing people who attempted similar experiences (can't 
> find anything similar after a good google search).

Neither GDB nor binutils are good tools for this.  You may want to
investigate valgrind, if it supports your platform.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]