0

I am working on a SHARC architecture on an embedded platform that I cannot use with a JTAG debugger because of real-time constraints.

My idea is to implement a sort of an invasive profiler based on the linker memory-map file (which is a nice XML file with all the symbols and the addresses).

During the runtime and when the target is compiled with the proper declarations -DPROFILING, I can add a JMP instruction at the beginning and at the end of a function to benchmark it.

With these spies, I can record the execution time for a particular function along with the stack status.

Currently my interface to my target is written in Python and I am thinking about these profiling methods:

p = Profiling('memorymap.xml')
trigger = p.AddTrigger('interrupt_isr', variable_change = 'var_foo')
p.AddSpy('function_foo', nacquisitions = 8, trigger = trigger)

The spy will start recording the next 8 execution of the function function_foo once the trigger condition is met. A trigger is added a the beginning of the function interrupt_isr and is fired when the variable var_foo has changed.

Currently I am not very satisfied of the profiling strategy I came with. Is there any standard profiling interface that I can get inspiration from?

The injection mechanism consists of several steps:

  1. Read the instruction at the desired label/function name
  2. Copy the read instruction at the end of the spy routine
  3. Replace the instruction with a jump to the spy routine
  4. Execute the spy routine
  5. Jump back at the original address
nowox
  • 25,978
  • 39
  • 143
  • 293
  • Does this thing have a debugger, like GDB maybe? – Mike Dunlavey Oct 27 '15 at 21:13
  • There is a debugger and even `gprof`, but these tools are aimed to be used either with a JTAG connection or on simulation. An independant runtime solution is not available so I need my own. – nowox Oct 27 '15 at 21:18
  • Btw, I still did not understand how I should use `gprof` with an executable that I canot run on the same architecture where `gprof` is installed... – nowox Oct 27 '15 at 21:20
  • I only ask because if you have a debugger you can use [*this*](http://stackoverflow.com/a/4299378/23771) or [*this*](http://stackoverflow.com/a/378024/23771) method. They work a little differently from typical profilers that get time measurements. These methods rely on the property of speedup opportunities that they are preferentially drawn to random-time interrupts. If you have a simulator, you can do it there. Any speedups you get with the simulator will likely carry over to the embedded hardware. – Mike Dunlavey Oct 27 '15 at 21:21

0 Answers0