Unix Programming - GDB question on displaying cycles

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2007 > GDB question on displaying cycles





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author GDB question on displaying cycles
Christian Christmann

2007-01-18, 1:17 pm

Hi,

I'm simulating binaries (for a DSP) in gdb. Everything works fine.
Now I want to display the (approx.) consumed cycles for a specific
routine. Up to now, I was doing this manually, an example:
1) I set the breakpoint to the first instruction of the routine
2) continued execution to this point
3) displayed value of $cycles
4) set a breakpoint at the very last instruction of this function
5) continued execution to this point
6) run "stepi" to simulate the last instruction execution
7) displayed the value of $cycles

The difference between the second and first value of $cycles
was the execution time for this routine.

Now I want to automatize this process by putting all the
gdb commands into file that I pass with "--command=" to gdb.
My problem is 4). How can I set a breakpoint to the last
instruction of a routine (the routine name is known) without
looking at the code (and manually determine the instruction
address)?

Thank you.

Regards,
Chris

Paul Pluzhnikov

2007-01-18, 1:17 pm

Christian Christmann <plfriko@yahoo.de> writes:

> My problem is 4). How can I set a breakpoint to the last
> instruction of a routine (the routine name is known) without
> looking at the code (and manually determine the instruction
> address)?


Perhaps you don't need to -- if you "finish" instead, you'll be
stopped on the next instruction after the "last return", which may
be close enough.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Christian Christmann

2007-01-18, 7:22 pm

On Thu, 18 Jan 2007 08:06:21 -0800, Paul Pluzhnikov wrote:


> Perhaps you don't need to -- if you "finish" instead, you'll be
> stopped on the next instruction after the "last return", which may
> be close enough.


With "finish" you mean finishing the entire program execution?
The problem is that after returning from the main function, still
"exit code" is executed. This is more than just one instruction.

Regards,
Chris
Paul Pluzhnikov

2007-01-18, 7:22 pm

Christian Christmann <plfriko@yahoo.de> writes:

> With "finish" you mean finishing the entire program execution?


No; I mean gdb "finish" command:

`finish'
Continue running until just after function in the selected stack
frame returns. Print the returned value (if any).

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Christian Christmann

2007-01-19, 7:22 am

On Thu, 18 Jan 2007 15:56:12 -0800, Paul Pluzhnikov wrote:

> `finish'
> Continue running until just after function in the selected stack
> frame returns. Print the returned value (if any).


Thank you. That's what I need.


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com