profiling code on embedded platform

Edwin Olson eolson@MIT.EDU
Fri Apr 27 16:19:00 GMT 2007


Hi folks,

I'm interested in getting some profiling data for my embedded 
application (C code compiled with gcc 4.1.2 on arm7tdmi). Because the 
real-world ISR effects are dominant, simulation results aren't terribly 
helpful (unless I implement a whole lot of simulated peripherals!)

My thought was that I'd write a FIQ (fast interrupt routine) to sample 
the PC and log these addresses to a host PC. (I believe I can write this 
code in a minimally invasive, low-overhead manner). But then I'd need to 
correlate those addresses against my C code. I don't mind if I need to 
integrate samples for minutes or hours to get reasonable accuracy. 
Here's my question:

How can I generate a data file that contains, for each address in FLASH, 
the corresponding file and line number that led to it?  I suspect this 
data can be made available in the output ELF file (gdb seems to have 
access to it, for example). Unfortunately, I'm not sure where to look. 
(2nd order question: would the address->line# mappings be robust to the 
effects of instruction reordering due to compiler optimizations?)

Or alternatively, I'm open to alternative suggestions/strategies or 
referrals to other mailing lists. But this seemed like a reasonable 
starting place.

Thanks!

-Ed
(PS: If I produce any code for this, I will make it freely available.)



More information about the Gcc-help mailing list