This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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: Log every call and exit in embedded system


On Mon, 2007-03-26 at 11:03 +0100, Andrew STUBBS wrote:
> John Zoidberg wrote:
> > Is this the only way? Can anyone give me any suggestions or hints?
> 
> The way profiling works is that the compiler inserts a call to a 
> function (mcount?) at each function call (*). I'm not sure on the 
> precise rules for this, or whether it varies between target types, but 
> these are details that you can certainly dig up from somewhere.

with gcc, -finstrument-functions

generates calls to:

         void __cyg_profile_func_enter (void *this_fn,
                                         void *call_site);
          void __cyg_profile_func_exit  (void *this_fn,
                                         void *call_site);

> If you provide your own implementation for this function then it can do 
> anything you like. Printing a call graph at run time should not be too 
> hard (though it may be tricky if your print mechanisms are also 
> instrumented).

I actually wrote a tool to do this: http://cutebugs.net/bozo-profiler/

Mathieu


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