From: Anton B. <an...@sa...> - 2006-09-18 01:05:19
|
Hi, > On Sat, Sep 16, 2006 at 03:49:13PM +1000, Anton Blanchard wrote: > > > :int main() > > :{ > > : while (1) { > > 14336 32.9034 : *(volatile int *)y += 1; /* main total: 29511 67.7324 */ > > : bar(); > > : } > > :} > > First, bfd is returning the wrong line for main()'s start. That total is > a function total. I had a look into this. When compiled without optimisation we get this: main: .loc 1 10 0 <---- stwu 1,-16(1) mflr 0 stw 31,12(1) stw 0,20(1) mr 31,1 .loc 1 12 0 <---- lis 9,y@ha So main starts at line 10. But with -O2 we lose the stack spill code and get: main: .loc 1 10 0 <---- .loc 1 12 0 <---- lis 9,y@ha and we must end up picking up the second entry, line 12. Not sure if its a bug in binutils, most of the time we probably want the second line attribution since its closer to the code. > > Which is much closer to reality. Any ideas how to fix this properly? > > What are is_correct_functions()'s arguments? if (!is_correct_function(function, sym.name())) Basically we step through the instructions in main() and find instructions attributed to bar() since its been inlined. > No idea how to fix, seems a choice between one or other brokenness Yeah Im not sure either. The current behaviour penalises apps that are built correctly (vs ones built with mixed debug/non debug objects) so it would be good to find a compromise. Anton |