23# define SO_TRACE_IN(__classAndMethod___) \
24 static const char *const __SO_TRACE_IN_STRING_BUF = __FILE__ ":" __classAndMethod___; \
25 SoTrace<uint16_t> __SoTraceObject(__SO_TRACE_IN_STRING_BUF, SoGlobalTraceBuffer);
29# define SO_TRACE_IN(__classAndMethod___)
73 inline void add(
const char *
const traceInString) {
81 _traceStack[_traceStackTop] = traceInString;
86 _traceList[_traceListEnd] = traceInString;
101 _traceStackTop =
static_cast<INDEXTYPE
>((_traceStackTop - 1) & _bufferIndexMask);
105 _traceStack[_traceStackTop] = NULL;
111 return _traceStackTop;
117 return _traceListEnd;
132 return _maxNumTraceListDumps;
137 _maxNumTraceListDumps = num;
142 return _maxNumTraceStackDumps;
147 _maxNumTraceStackDumps = num;
158 inline void _initClass() {
160 memset(_traceStack, 0, _numBufBytes);
161 memset(_traceList, 0, _numBufBytes);
173 _numBufEntries = (1L << (
sizeof(INDEXTYPE) << 3)) ,
174 _numBufBytes = _numBufEntries *
sizeof(
const char *),
175 _bufferIndexMask = _numBufEntries - 1
179 INDEXTYPE _traceStackTop;
182 INDEXTYPE _traceListEnd;
185 const char *_traceStack[_numBufEntries];
188 const char *_traceList[_numBufEntries];
212template <
typename INDEXTYPE>
228 if((_maxNumTraceStackDumps > 0) && (getTraceStackTop() > 0)) {
229 sprintf(num,
"\nCall stack of the last %d traced functions:\n", _maxNumTraceStackDumps);
234 const char *
const *traceStack = getTraceStack();
240 for(entry = stackPreTop; (entry != stackTop) && (stackCnt < _maxNumTraceStackDumps); entry--, stackCnt++) {
242 sprintf(num,
"%5d ", indexCounter);
245 const char *entryStrPtr = traceStack[entry];
249 traceListStr += entryStrPtr;
250 traceListStr += endLineStr;
258 if(_maxNumTraceListDumps > 0) {
260 sprintf(num,
"\nCall list of the %d most recently traced functions:\n", _maxNumTraceListDumps);
269 for(entry = listPreEnd; (entry != listEnd) && (listCnt < _maxNumTraceListDumps); entry--, listCnt++) {
271 sprintf(num,
"%5d ", indexCounter);
274 const char *entryStrPtr = traceList[entry];
278 traceListStr += entryStrPtr;
279 traceListStr += endLineStr;
291 return "<Could not determine last called functions or function stack>";
327 traceBuf.
add(traceInString);
349 inline SoTrace(
const SoTrace &trace) : _traceBuf(trace._traceBuf) {
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
unsigned short int uint16_t
INVENTOR_API SoTraceBuffer< SoGlobalTraceBufferType > SoGlobalTraceBuffer
This is a global singleton of the SoTraceBuffer class.
uint16_t SoGlobalTraceBufferType
The type used in the SoGlobalTraceBuffer.
Class for smart character strings.
This class manages a list and a stack of pointers to permanent strings.
SoGlobalTraceBufferType getMaxNumTraceStackDumps() const
Maximum number of trace stack entries to be shown on fatal error outputs.
void add(const char *const traceInString)
Add trace description.
INDEXTYPE getTraceStackTop() const
Returns index into trace stack buffer.
void setMaxNumTraceStackDumps(SoGlobalTraceBufferType num)
Sets the maximum number of trace stack entries to be shown on fatal error outputs.
SoGlobalTraceBufferType getMaxNumTraceListDumps() const
Maximum number of trace list entries to be shown on fatal error outputs.
INDEXTYPE getTraceListEnd() const
Returns index into trace list buffer.
SbString getTraceDumpString() const
Returns an SbString which returns a dump of trace list and trace dump entries for debugging purposes.
const char *const * getTraceStack() const
Returns the pointer to the first element of the trace stack.
const char *const * getTraceList() const
Returns the pointer to the first element of the trace list.
SoTraceBuffer()
Initializing constructor.
void setMaxNumTraceListDumps(SoGlobalTraceBufferType num)
Sets the maximum number of trace list entries to be shown on fatal error outputs.
This class simply implements a constructor and a destructor.
SoTrace(const char *const traceInString, SoTraceBuffer< INDEXTYPE > &traceBuf)
Constructor.