InstrumentingProfiler.cpp File Reference
#include "ProfilerCompatibility.h"
#include "SysprogsProfilerInterface.h"
#include <string.h>
#include "DebuggerChecker.h"
#include "SmallNumberCoder.h"

Classes

class  SysprogsInstrumentingProfiler::SmallNumberCoder
 
class  SysprogsInstrumentingProfiler::SmallNumberDecoder
 
class  SysprogsInstrumentingProfiler::Chronometer::ProfilerTimeRegionRAII
 
class  SysprogsInstrumentingProfiler::VendorSpecificWorkarounds::VendorSpecificInterruptHolderRAII
 
struct  SysprogsInstrumentingProfiler::InstrumentedFrame
 
struct  SysprogsInstrumentingProfiler::ProfilerThreadRecord
 
class  SysprogsInstrumentingProfiler::InstrumentedFramePool
 
struct  SysprogsInstrumentingProfiler::RunTimeReportRecord
 
struct  OverheadReportPacket
 

Namespaces

 SysprogsInstrumentingProfiler
 
 SysprogsInstrumentingProfiler::Chronometer
 
 SysprogsInstrumentingProfiler::VendorSpecificWorkarounds
 
 SysprogsStackVerifier
 
 OverheadMeasurementFunctions
 

Macros

#define SYSPROGS_PROFILER_MAX_THREADS   16
 
#define __countof(array)   (sizeof(array) / sizeof((array)[0]))
 
#define SysprogsInstrumentingProfiler_QueryAndResetPerformanceCounter   SysprogsInstrumentingProfiler_QueryAndResetPerformanceCounter_Inline
 
#define DWT_CYCCNT   (*((unsigned *)0xE0001004))
 
#define DWT_CTRL   (*((unsigned *)0xE0001000))
 
#define COREDEBUG_DEMCR   (*((unsigned *)0xe000edfc))
 
#define CLEAR_R0_BIT_0()
 
#define SYSPROGS_THUMB_HOOK_PROLOGUE()
 
#define SYSPROGS_THUMB_HOOK_EPILOGUE()
 
#define SYSPROGS_THUMB_HOOK_PROLOGUE_WITH_TAG_PUSHES_R1()
 
#define SYSPROGS_PROFILER_EXIT_IF_SUSPENDED(exitLabelName)
 

Typedefs

typedef unsigned long long ProfilerTimeType
 
typedef unsigned uintptr_t
 
typedef unsigned SysprogsInstrumentingProfiler::ProfilerUIntPtr
 

Enumerations

enum  RealTimeTracePacketType {
  rtpInitialization = 1, rtpFunctionRuntime = 2, rtpOverflow = 3, rtpOverheadReport = 4,
  rtpThreadSwitch = 5, rtpThreadCreated = 6, rtpResourceTaken = 7, rtpResourceReleased = 8,
  rtpSignedValueChanged = 9, rtpUnsignedValueChanged = 10, rtpFPValueChanged = 11, rtpCustomEvent = 12,
  rtpCustomEventEx = 13, rtpNewTicksPerSecond = 14
}
 
enum  InstrumentingProfilerFlags {
  ipfNone = 0x00, ipfProfileFunctionCalls = 0x01, ipfRecordFunctionTiming = 0x02, ipfVerifyFunctionStacks = 0x04,
  ipfReportThreadCreation = 0x08, ipfReportThreadTimes = 0x10
}
 
enum  SysprogsInstrumentingProfiler::InstrumentingProfilerErrorCode {
  SysprogsInstrumentingProfiler::ipeNoError = 0, SysprogsInstrumentingProfiler::ipeFrameBufferOverflow, SysprogsInstrumentingProfiler::ipeStackPointerMismatch, SysprogsInstrumentingProfiler::ipeNoFrames,
  SysprogsInstrumentingProfiler::ipeScratchBufferOverflow, SysprogsInstrumentingProfiler::ipeInterfaceError, SysprogsInstrumentingProfiler::ipeOutOfThreadSlots, SysprogsInstrumentingProfiler::ipeStackNotAligned
}
 

Functions

void SysprogsInstrumentingProfiler::__attribute__ ((noinline)) RaiseError(InstrumentingProfilerErrorCode errorCode
 
 SysprogsInstrumentingProfiler::if (s_ThreadIDReportPending)
 
 SysprogsInstrumentingProfiler::for (const InstrumentedFrame *pFrame=pTopFrame;pFrame;pFrame=pFrame->pNextFrame)
 
 SysprogsInstrumentingProfiler::if ((int) unreportedFrames< 0) unreportedFrames
 
 SysprogsInstrumentingProfiler::if (!coder.WritePackedUIntPair(totalFrames-unreportedFrames, unreportedFrames)) RaiseError(ipeScratchBufferOverflow)
 
 SysprogsInstrumentingProfiler::while (unreportedFrames)
 
 SysprogsInstrumentingProfiler::if (!coder.WriteSmallUnsignedIntWithFlag(ProfilerTimeToUInt32(runTime), pTopFrame->FoldedTime!=0)) RaiseError(ipeScratchBufferOverflow)
 
 SysprogsInstrumentingProfiler::if (pTopFrame->FoldedTime) if(!coder.WriteSmallUnsignedInt(ProfilerTimeToUInt32(pTopFrame-> FoldedTime))) RaiseError(ipeScratchBufferOverflow)
 
 SysprogsInstrumentingProfiler::while (!SysprogsProfiler_WriteData(pdcInstrumentationProfilerNormalStream,(char *) coder.GetBuffer(), 0, coder.GetBuffer(), coder.GetOffset()))
 
 SysprogsInstrumentingProfiler::while (!SysprogsProfiler_WriteData(pdcRealTimeAnalysisStream,&rec, sizeof(rec), 0, 0)&&!g_FastSemihostingCallActive)
 
void SysprogsInstrumentingProfiler::SysprogsInstrumentingProfilerReturnHookImpl (void **pStack)
 
 SysprogsInstrumentingProfiler::__attribute__ ((always_inline)) static inline bool IsProcessStackMode(void)
 
void SysprogsInstrumentingProfiler::SysprogsInstrumentingProfilerHookImpl (void **pStack)
 
void SysprogsInstrumentingProfiler::ReportThreadCreated (void *newThread, const char *pThreadName)
 
void SysprogsInstrumentingProfiler::ReportThreadSwitch (void *newThread)
 
 __attribute__ ((naked)) void SysprogsInstrumentingProfilerHook()
 
volatile void * __attribute__ ((alias("SysprogsProfiler_FunctionHookTable"))) SysprogsProfiler_FunctionHookTableEnd
 
 OverheadMeasurementFunctions::__attribute__ ((noinline, naked, optimize("-O0"))) void NonInstrumented()
 
void SysprogsProfiler_RTOSThreadSwitched (void *newThread, const char *pThreadName, void *pStackLimit)
 
void SysprogsProfiler_RTOSThreadDeleted (void *thread)
 
void SysprogsProfiler_ReportResourceTaken (void *pResource, void *pOwner, unsigned optional24BitTag)
 
void SysprogsProfiler_ReportResourceReleased (void *pResource, void *pOwner, unsigned optional24BitTag)
 
void SysprogsProfiler_ReportIntegralValue (void *pResource, unsigned value, int reportAsSigned)
 
void SysprogsProfiler_ReportFPValue (void *pResource, double value)
 
void SysprogsProfiler_ReportGenericEvent (void *pResource, const char *pEvent)
 
void SysprogsProfiler_ReportGenericEventEx (void *pResource, void *argument, RealTimeEventArgType argType, int argSize)
 
void __attribute__ ((weak)) InitializeProfilerRTOSHooks()
 
void ReportTicksPerSecond (unsigned ticksPerSecond)
 Reports the profiler clock resolution to the host. More...
 
void InitializeCustomRealTimeWatch ()
 

Variables

int g_FastSemihostingCallActive
 
int g_SuppressInstrumentingProfiler = 1
 
int g_StopOnRealTimeReportingBufferOverflow = 0
 
InstrumentingProfilerFlags g_InstrumentingProfilerRTOSFlags
 
ProfilerTimeType SysprogsInstrumentingProfiler::Chronometer::ApplicationClockBase
 
ProfilerTimeType SysprogsInstrumentingProfiler::Chronometer::ProfilerTimeOverhead
 
unsigned SysprogsInstrumentingProfiler::Chronometer::IncludeOverheadTimeInAppTime
 
void uintptr_t SysprogsInstrumentingProfiler::pArg
 
class SysprogsInstrumentingProfiler::InstrumentedFramePool SysprogsInstrumentingProfiler::s_InstrumentedFramePool
 
unsigned SysprogsInstrumentingProfiler::FunctionFoldingThreshold
 
SmallNumberCoder SysprogsInstrumentingProfiler::coder (buffer, sizeof(buffer), 0, 0)
 
unsigned SysprogsInstrumentingProfiler::totalFrames = 0
 
unsigned SysprogsInstrumentingProfiler::unreportedFrames = -1
 
const InstrumentedFrame * SysprogsInstrumentingProfiler::pFrame = pTopFrame
 
void ProfilerTimeType SysprogsInstrumentingProfiler::runTime
 
void * SysprogsStackVerifier::StackLimit = 0
 
volatile void * SysprogsProfiler_FunctionHookTable
 

Macro Definition Documentation

#define __countof (   array)    (sizeof(array) / sizeof((array)[0]))
#define CLEAR_R0_BIT_0 ( )
Value:
asm("lsr r0, #1"); \
asm("lsl r0, #1");
#define COREDEBUG_DEMCR   (*((unsigned *)0xe000edfc))
#define DWT_CTRL   (*((unsigned *)0xE0001000))
#define DWT_CYCCNT   (*((unsigned *)0xE0001004))
#define SYSPROGS_PROFILER_EXIT_IF_SUSPENDED (   exitLabelName)
Value:
asm("ldr r0, =g_SuppressInstrumentingProfiler"); \
asm("ldr r0, [r0]"); \
asm("tst r0, r0"); \
asm("bne " exitLabelName);
#define SYSPROGS_PROFILER_MAX_THREADS   16
#define SYSPROGS_THUMB_HOOK_EPILOGUE ( )
Value:
asm("pop {r0}"); \
asm("mov lr, r0"); \
asm("pop {r0, pc}");
#define SYSPROGS_THUMB_HOOK_PROLOGUE ( )
Value:
/* Old stack layout: [R0] [R1] [LR]. New stack layout: [LR] [R0] [PC]*/ \
asm("str r0, [sp, #4]"); /* [new R0] = r0 */ \
asm("ldr r0, [sp, #8]"); /* r0 = [old LR] */ \
asm("str r0, [sp, #0]"); /* [new LR] = r0 */ \
asm("mov r0, lr"); \
asm("ldr r0, [r0, #0]"); /* r0 = [original PC] */ \
asm("str r0, [sp, #8]"); /* [new PC] = r0 */
#define CLEAR_R0_BIT_0()
Definition: InstrumentingProfiler.cpp:533
#define SYSPROGS_THUMB_HOOK_PROLOGUE_WITH_TAG_PUSHES_R1 ( )
Value:
/* Old stack layout: [R0] [R1] [LR]. New stack layout: [LR] [R0] [PC]*/ \
asm("str r0, [sp, #4]"); /* [new R0] = r0 */ \
asm("ldr r0, [sp, #8]"); /* r0 = [old LR] */ \
asm("str r0, [sp, #0]"); /* [new LR] = r0 */ \
asm("mov r0, lr"); \
asm("push {r1}"); \
asm("ldr r1, [r0, #0]"); /* r0 = [original PC] */ \
asm("str r1, [sp, #12]"); /* [new PC] = r0 */
#define CLEAR_R0_BIT_0()
Definition: InstrumentingProfiler.cpp:533
#define SysprogsInstrumentingProfiler_QueryAndResetPerformanceCounter   SysprogsInstrumentingProfiler_QueryAndResetPerformanceCounter_Inline

Typedef Documentation

typedef unsigned long long ProfilerTimeType
typedef unsigned uintptr_t

Enumeration Type Documentation

Enumerator
ipfNone 
ipfProfileFunctionCalls 
ipfRecordFunctionTiming 
ipfVerifyFunctionStacks 
ipfReportThreadCreation 
ipfReportThreadTimes 
Enumerator
rtpInitialization 
rtpFunctionRuntime 
rtpOverflow 
rtpOverheadReport 
rtpThreadSwitch 
rtpThreadCreated 
rtpResourceTaken 
rtpResourceReleased 
rtpSignedValueChanged 
rtpUnsignedValueChanged 
rtpFPValueChanged 
rtpCustomEvent 
rtpCustomEventEx 
rtpNewTicksPerSecond 

Function Documentation

__attribute__ ( (naked)  )
volatile void* __attribute__ ( (alias("SysprogsProfiler_FunctionHookTable"))  )
void __attribute__ ( (weak)  )
void InitializeCustomRealTimeWatch ( )
void ReportTicksPerSecond ( unsigned  ticksPerSecond)

Reports the profiler clock resolution to the host.

Use this function to report the resolution of the profiler clock (i.e. the meaning of the values returned by SysprogsInstrumentingProfiler_QueryAndResetPerformanceCounter) to the host. This allows VisualGDB to report physical time values instead of just ticks.

void SysprogsProfiler_ReportFPValue ( void *  pResource,
double  value 
)
void SysprogsProfiler_ReportGenericEvent ( void *  pResource,
const char *  pEvent 
)
void SysprogsProfiler_ReportGenericEventEx ( void *  pResource,
void *  argument,
RealTimeEventArgType  argType,
int  argSize 
)
void SysprogsProfiler_ReportIntegralValue ( void *  pResource,
unsigned  value,
int  reportAsSigned 
)
void SysprogsProfiler_ReportResourceReleased ( void *  pResource,
void *  pOwner,
unsigned  optional24BitTag 
)
void SysprogsProfiler_ReportResourceTaken ( void *  pResource,
void *  pOwner,
unsigned  optional24BitTag 
)
void SysprogsProfiler_RTOSThreadDeleted ( void *  thread)
void SysprogsProfiler_RTOSThreadSwitched ( void *  newThread,
const char *  pThreadName,
void *  pStackLimit 
)

Variable Documentation

int g_FastSemihostingCallActive
InstrumentingProfilerFlags g_InstrumentingProfilerRTOSFlags
int g_StopOnRealTimeReportingBufferOverflow = 0
int g_SuppressInstrumentingProfiler = 1
volatile void* SysprogsProfiler_FunctionHookTable