CustomRealTimeWatches.h
Go to the documentation of this file.
1 #pragma once
3 
4 struct RunTimeWatch;
6 struct EventStreamWatch;
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 static void RunTimeWatch_ReportStart(struct RunTimeWatch *pWatch);
13 static void RunTimeWatch_ReportEnd(struct RunTimeWatch *pWatch);
14 
15 static void ScalarRealTimeWatch_ReportSignedValue(struct ScalarRealTimeWatch *pWatch, int value);
16 static void ScalarRealTimeWatch_ReportUnsignedValue(struct ScalarRealTimeWatch *pWatch, unsigned value);
17 static void ScalarRealTimeWatch_ReportFPValue(struct ScalarRealTimeWatch *pWatch, double value);
18 
19 static void EventStreamWatch_ReportEvent(struct EventStreamWatch *pWatch, const char *pEvent);
20 static void EventStreamWatch_ReportEvent_SignedInt(struct EventStreamWatch *pWatch, int arbitraryEventArgument);
21 static void EventStreamWatch_ReportEvent_UnsignedInt(struct EventStreamWatch *pWatch, unsigned arbitraryEventArgument);
22 static void EventStreamWatch_ReportEvent_FP(struct EventStreamWatch *pWatch, double arbitraryEventArgument);
23 
25 
26 #ifdef __cplusplus
27 }
28 #endif
29 
31 {
32  volatile int Enabled; //Set automatically by the debugger
33 
34 #ifdef __cplusplus
35  void ReportStart()
36  {
37  RunTimeWatch_ReportStart(this);
38  }
39 
40  void ReportEnd()
41  {
42  RunTimeWatch_ReportEnd(this);
43  }
44 
45 #endif
46 };
47 
49 {
50  volatile int Enabled; //Set automatically by the debugger
51 #ifdef __cplusplus
52  void ReportValue(int value)
53  {
54  ScalarRealTimeWatch_ReportSignedValue(this, value);
55  }
56 
57  void ReportValue(unsigned value)
58  {
59  ScalarRealTimeWatch_ReportUnsignedValue(this, value);
60  }
61 
62  void ReportValue(double value)
63  {
64  ScalarRealTimeWatch_ReportFPValue(this, value);
65  }
66 #endif
67 };
68 
70 {
71  volatile int Enabled; //Set automatically by the debugger
72 #ifdef __cplusplus
73  void ReportEvent(const char *pEvent)
74  {
75  EventStreamWatch_ReportEvent(this, pEvent);
76  }
77 
78  void ReportEvent(int arbitraryEventArgument)
79  {
80  EventStreamWatch_ReportEvent_SignedInt(this, arbitraryEventArgument);
81  }
82 
83  void ReportEvent(unsigned arbitraryEventArgument)
84  {
85  EventStreamWatch_ReportEvent_UnsignedInt(this, arbitraryEventArgument);
86  }
87 
88  void ReportEvent(double arbitraryEventArgument)
89  {
90  EventStreamWatch_ReportEvent_FP(this, arbitraryEventArgument);
91  }
92 
93 #endif
94 };
95 
96 #ifdef __cplusplus
97 class ScopedRunTimeReporter
98 {
99 private:
100  RunTimeWatch *m_pWatch;
101 
102 public:
103  ScopedRunTimeReporter(RunTimeWatch &watch)
104  : m_pWatch(&watch)
105  {
106  m_pWatch->ReportStart();
107  }
108 
109  ~ScopedRunTimeReporter()
110  {
111  m_pWatch->ReportEnd();
112  }
113 };
114 #endif
115 
116 static void RunTimeWatch_ReportStart(struct RunTimeWatch *pWatch)
117 {
118  if (!pWatch->Enabled)
119  return;
121 }
122 
123 static void RunTimeWatch_ReportEnd(struct RunTimeWatch *pWatch)
124 {
125  if (!pWatch->Enabled)
126  return;
128 }
129 
130 static void ScalarRealTimeWatch_ReportSignedValue(struct ScalarRealTimeWatch *pWatch, int value)
131 {
132  if (!pWatch->Enabled)
133  return;
134  SysprogsProfiler_ReportIntegralValue(pWatch, (unsigned)value, 1);
135 }
136 
137 static void ScalarRealTimeWatch_ReportUnsignedValue(struct ScalarRealTimeWatch *pWatch, unsigned value)
138 {
139  if (!pWatch->Enabled)
140  return;
141  SysprogsProfiler_ReportIntegralValue(pWatch, value, 0);
142 }
143 
144 static void ScalarRealTimeWatch_ReportFPValue(struct ScalarRealTimeWatch *pWatch, double value)
145 {
146  if (!pWatch->Enabled)
147  return;
148  SysprogsProfiler_ReportFPValue(pWatch, value);
149 }
150 
151 static void EventStreamWatch_ReportEvent(struct EventStreamWatch *pWatch, const char *pEvent)
152 {
153  if (!pWatch->Enabled)
154  return;
155  SysprogsProfiler_ReportGenericEvent(pWatch, pEvent);
156 }
157 
158 void EventStreamWatch_ReportEvent_SignedInt(struct EventStreamWatch *pWatch, int arbitraryEventArgument)
159 {
160  if (!pWatch->Enabled)
161  return;
162  SysprogsProfiler_ReportGenericEventEx(pWatch, &arbitraryEventArgument, rtaSignedInt, sizeof(arbitraryEventArgument));
163 }
164 
165 void EventStreamWatch_ReportEvent_UnsignedInt(struct EventStreamWatch *pWatch, unsigned arbitraryEventArgument)
166 {
167  if (!pWatch->Enabled)
168  return;
169  SysprogsProfiler_ReportGenericEventEx(pWatch, &arbitraryEventArgument, rtaUnsignedInt, sizeof(arbitraryEventArgument));
170 }
171 
172 void EventStreamWatch_ReportEvent_FP(struct EventStreamWatch *pWatch, double arbitraryEventArgument)
173 {
174  if (!pWatch->Enabled)
175  return;
176  SysprogsProfiler_ReportGenericEventEx(pWatch, &arbitraryEventArgument, rtaFloatingPoint, sizeof(arbitraryEventArgument));
177 }
Definition: CustomRealTimeWatches.h:30
Definition: SysprogsProfilerInterface.h:15
volatile int Enabled
Definition: CustomRealTimeWatches.h:32
void SysprogsProfiler_ReportGenericEvent(void *pResource, const char *pEvent)
Definition: InstrumentingProfiler.cpp:817
void SysprogsProfiler_ReportResourceReleased(void *pResource, void *pOwner, unsigned optional24BitTag)
Definition: InstrumentingProfiler.cpp:790
void SysprogsProfiler_ReportGenericEventEx(void *pResource, void *argument, RealTimeEventArgType argType, int argSize)
Definition: InstrumentingProfiler.cpp:827
void SysprogsProfiler_ReportResourceTaken(void *pResource, void *pOwner, unsigned optional24BitTag)
Definition: InstrumentingProfiler.cpp:781
volatile int Enabled
Definition: CustomRealTimeWatches.h:50
Definition: CustomRealTimeWatches.h:48
Definition: SysprogsProfilerInterface.h:17
Definition: SysprogsProfilerInterface.h:16
void InitializeCustomRealTimeWatch()
Definition: InstrumentingProfiler.cpp:914
void SysprogsProfiler_ReportFPValue(void *pResource, double value)
Definition: InstrumentingProfiler.cpp:808
void SysprogsProfiler_ReportIntegralValue(void *pResource, unsigned value, int reportAsSigned)
Definition: InstrumentingProfiler.cpp:799
Definition: CustomRealTimeWatches.h:69
volatile int Enabled
Definition: CustomRealTimeWatches.h:71