This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Log every call and exit in embedded system
On 3/26/07, mathieu lacage <Mathieu.Lacage@sophia.inria.fr> wrote:
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);
I'll investigate this further.
With embedded systems there are always issues... but I think I can use
these functions to log to a buffer the address of the called functions
(and then look them up).
> 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
Your tool seems very interesting, it's unfortunate it's not ready for
embedded systems.
On the documentation you mention malloc, but some embedded systems
don't have the code for malloc. Moreover, no embedded system uses
glibc, it uses newlib, uclib, and others... this means that the code
that is linked may not have the support for it (i.e. there are missing
functions).
There is the issue of the target code (the part that is linked to the
application) must be compiled with the corresponding GCC (for the
target system).
And besides all this, there is the issue of where to log the
information or how to send it.
Thanks!