NUTTRACER

From Nutwiki
Revision as of 17:02, 27 October 2016 by Harald (Talk | contribs) (1 revision imported)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to use NUTTRACER

A while ago I used tracing:

I re-built Nut/OS with the "OS Tracer" flag set under the "RTOS Kernel" section in Nutconf and added some lines to my prog:

// set the _TRACING_ define to enable the calls to TRACE_add #define _TRACING_ #define stats
..program continues ...
#ifdef stats
if ( NutTraceInit  ( 4000, TRACE_MODE_CIRCULAR ) == 0) 
  {
  printf ("Error in NutTraceInit\r\n");
  }
NutTraceRegisterUserTag(1, "Befor FGETS\0"); 
NutTraceRegisterUserTag(2, "After FGETS\0"); 
NutTraceRegisterUserTag(3, "Befor IOCTL\0"); 
NutTraceRegisterUserTag(4, "After FREAD\0"); 
#endif
..program continues ...
#ifdef stats	
     TRACE_ADD_ITEM(TRACE_TAG_USER,1) 
#endif
   ..program continues ...
#ifdef stats	
     TRACE_ADD_ITEM(TRACE_TAG_USER,2) 
#endif
#ifdef stats
   NutTraceStop  () ; 
   NutTracePrint  (uart_FILE, 0);
#endif 
..program ends

The NutTracePrint produced something like:

TRACE contains 4000 items,  printing 4000 items.        
TAG                 PC/Info         Time [s:ms:us] 
--------------------------------------------------        
Trace Start         0x0                  0:000:002     
Thread    Sleep     main                 0:006:168               
Thread    Yield     main                 0:006:172            
Thread    Wait      httpd1               0:006:188  
Thread    Yield     httpd1               0:006:192                   
Thread    Wait      httpd2               0:006:202         
Thread    Yield     httpd2               0:006:207      
Thread    Wait      FWD                  0:006:219                
Thread    Yield     FWD                  0:006:223             
Thread    Wait      tcpsm                0:006:646   
Thread    Yield     tcpsm                0:006:651
Thread    Yield     idle                 0:181:309          
Thread    Sleep     rxi1                 0:182:007       
Thread    Yield     rxi1                 0:182:012    
Thread    Yield     idle                 0:206:301              
Thread    Wait      tcpsm                0:206:722           
Thread    Yield     tcpsm                0:206:727 
Thread    Yield     idle                 0:381:248                  
Thread    Sleep     rxi1                 0:381:867        
Thread    Yield     rxi1                 0:381:871     
Thread    Yield     idle                 0:406:241               
Thread    Wait      tcpsm                0:406:662            
Thread    Yield     tcpsm                0:406:666  
Thread    Yield     idle                 0:581:187                   
Thread    Sleep     rxi1                 0:581:807         
Thread    Yield     rxi1                 0:581:811      
Thread    Yield     idle                 0:606:180   
Thread    Wait      tcpsm                0:606:601