Jump to ID:
Core Development Tools

Project Home

Documents

Source Code

Discussions

Wiki

Project Info
Forum Topic - Guidance on analyzing a single function : (8 Items)
   
 
 
Guidance on analyzing a single function  
I have a function being called in an interrupt task that is taking too much time.  This interrupt is being fired every 
millisecond and is calling a function which walks through in a list of queued objects and called a method.  Normally, 
the function takes just a few microseconds.  Occasionally, this function overrruns 1 millisecond.  I need to time the 
function and all subroutines, and keep a stack trace for each subroutine to find the culprit.  I tried enabling Function
 Instrumentation but this brought my program to its knees.

Short of renting an expensive JTAG emulator, is there a way to with the available tools provided with QNX?

I realize that I will likely need to add tracing calls to individual functions, but I will need to store times and stack
 traces quickly and then do post-mortem analysis of the data to trap this in as close to real-time as possible.  Can 
this be done?
Re: Guidance on analyzing a single function  
Look at TraceEvent() (probably NTO_TRACE_INSERTUSRSTREVENT) and
the tracelogger utility.  You can look at the trace in the ide
avterwards of via the traceprinter utility.  The trace contains
time stamps.  Collecting a stack trace may be slightly harder.

-seanb

On Thu, Aug 18, 2011 at 10:22:22AM -0400, Robert Murrell wrote:
> I have a function being called in an interrupt task that is taking too
> much time.  This interrupt is being fired every millisecond and is
> calling a function which walks through in a list of queued objects and
> called a method.  Normally, the function takes just a few microseconds.
> Occasionally, this function overrruns 1 millisecond.  I need to time the
> function and all subroutines, and keep a stack trace for each subroutine
> to find the culprit.  I tried enabling Function Instrumentation but this
> brought my program to its knees.
> 
> Short of renting an expensive JTAG emulator, is there a way to with the
> available tools provided with QNX?
> 
> I realize that I will likely need to add tracing calls to individual
> functions, but I will need to store times and stack traces quickly and
> then do post-mortem analysis of the data to trap this in as close to
> real-time as possible.  Can this be done?
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post88192
> 
Re: Guidance on analyzing a single function  
Thanks for responding.  I just found TraceEvent() in the help.  I don't see a way to get a stack trace, but it looks 
like I can effectively build one by sprinkling trace_func_enter() and trace_func_exit() calls in the functions.  I can 
iteratively build the calling sequence.  Any other hints that might be useful?
RE: Guidance on analyzing a single function  
At the start of the ISR get the "time" with ClockCycles(), then inside the code add

if ( (StartTime+MaximumAllowed ) > ClockCycles() )
{
	puts("too long" ); 
}
	
Now you run your program though the debugger and set a breakpoint on puts().    Hence when the ISR takes too long, 
you'll catch it. You can place that code at different location in  your program.   
	
> -----Message d'origine-----
> De : Sean Boudreau [mailto:community-noreply@qnx.com]
> Envoyé : 18 août 2011 10:30
> À : general-toolchain
> Objet : Re: Guidance on analyzing a single function
> 
> 
> Look at TraceEvent() (probably NTO_TRACE_INSERTUSRSTREVENT) and the
> tracelogger utility.  You can look at the trace in the ide avterwards of via the
> traceprinter utility.  The trace contains time stamps.  Collecting a stack trace may
> be slightly harder.
> 
> -seanb
> 
> On Thu, Aug 18, 2011 at 10:22:22AM -0400, Robert Murrell wrote:
> > I have a function being called in an interrupt task that is taking too
> > much time.  This interrupt is being fired every millisecond and is
> > calling a function which walks through in a list of queued objects and
> > called a method.  Normally, the function takes just a few microseconds.
> > Occasionally, this function overrruns 1 millisecond.  I need to time
> > the function and all subroutines, and keep a stack trace for each
> > subroutine to find the culprit.  I tried enabling Function
> > Instrumentation but this brought my program to its knees.
> >
> > Short of renting an expensive JTAG emulator, is there a way to with
> > the available tools provided with QNX?
> >
> > I realize that I will likely need to add tracing calls to individual
> > functions, but I will need to store times and stack traces quickly and
> > then do post-mortem analysis of the data to trap this in as close to
> > real-time as possible.  Can this be done?
> >
> >
> >
> >
> > _______________________________________________
> >
> > General
> > http://community.qnx.com/sf/go/post88192
> >
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post88193
> 
Re: RE: Guidance on analyzing a single function  

Obivously this will only work of your ISR is a thread

> At the start of the ISR get the "time" with ClockCycles(), then inside the 
> code add
> 
> if ( (StartTime+MaximumAllowed ) > ClockCycles() )
> {
> 	puts("too long" ); 
> }
> 	
> Now you run your program though the debugger and set a breakpoint on puts().  
>   Hence when the ISR takes too long, you'll catch it. You can place that code 
> at different location in  your program.   
> 	
Re: Guidance on analyzing a single function  
You should use function instrumentation in kernel trace mode, it would generate kernel events (that some people 
suggested to do to you manually)
You run problem and take kernel trace at the same time (Called System Wide mode in App Profiler launch configuration)

On 08/18/2011 10:22 AM, Robert Murrell wrote:
> I have a function being called in an interrupt task that is taking too much time.  This interrupt is being fired every
 millisecond and is calling a function which walks through in a list of queued objects and called a method.  Normally, 
the function takes just a few microseconds.  Occasionally, this function overrruns 1 millisecond.  I need to time the 
function and all subroutines, and keep a stack trace for each subroutine to find the culprit.  I tried enabling Function
 Instrumentation but this brought my program to its knees.
> 
> Short of renting an expensive JTAG emulator, is there a way to with the available tools provided with QNX?
> 
> I realize that I will likely need to add tracing calls to individual functions, but I will need to store times and 
stack traces quickly and then do post-mortem analysis of the data to trap this in as close to real-time as possible.  
Can this be done?
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post88192
> 
Re: Guidance on analyzing a single function  
Elena,

I tried enabling Function Instrumentation but my program wouldn't run.  There were too many overruns and the high 
priority tasks were not allowing the low priority tasks to run.  I have to target individual functions to limit tracing.

Re: Guidance on analyzing a single function  
It won't run in interrupts unless you run it in Kernel mode, did you run it kernel mode?
You can enable/disable tracing as you enter your interrupt too

On 08/18/2011 11:31 AM, Robert Murrell wrote:
> Elena,
> 
> I tried enabling Function Instrumentation but my program wouldn't run.  There were too many overruns and the high 
priority tasks were not allowing the low priority tasks to run.  I have to target individual functions to limit tracing.

> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post88201
>