A class for performing various debugging and memory tracing operations. Full functionality (such as printing out objects currently allocated) is only present in a debugging build of wxWidgets, i.e. if the __WXDEBUG__ symbol is defined. wxDebugContext and related functions and macros can be compiled out by setting wxUSE_DEBUG_CONTEXT to 0 is setup.h
Derived from
No parent class.
Include files
<wx/memory.h>
See also
Members
wxDebugContext::Check
wxDebugContext::Dump
wxDebugContext::GetCheckPrevious
wxDebugContext::GetDebugMode
wxDebugContext::GetLevel
wxDebugContext::GetStream
wxDebugContext::GetStreamBuf
wxDebugContext::HasStream
wxDebugContext::PrintClasses
wxDebugContext::PrintStatistics
wxDebugContext::SetCheckpoint
wxDebugContext::SetCheckPrevious
wxDebugContext::SetDebugMode
wxDebugContext::SetFile
wxDebugContext::SetLevel
wxDebugContext::SetStandardError
wxDebugContext::SetStream
int Check()
Checks the memory blocks for errors, starting from the currently set checkpoint.
Return value
Returns the number of errors, so a value of zero represents success. Returns -1 if an error was detected that prevents further checking.
bool Dump()
Performs a memory dump from the currently set checkpoint, writing to the current debug stream. Calls the Dump member function for each wxObject derived instance.
Return value
true if the function succeeded, false otherwise.
bool GetCheckPrevious()
Returns true if the memory allocator checks all previous memory blocks for errors. By default, this is false since it slows down execution considerably.
See also
wxDebugContext::SetCheckPrevious
bool GetDebugMode()
Returns true if debug mode is on. If debug mode is on, the wxObject new and delete operators store or use information about memory allocation. Otherwise, a straight malloc and free will be performed by these operators.
See also
int GetLevel()
Gets the debug level (default 1). The debug level is used by the wxTraceLevel function and the WXTRACELEVEL macro to specify how detailed the trace information is; setting a different level will only have an effect if trace statements in the application specify a value other than one.
This is obsolete, replaced by wxLog functionality.
See also
ostream& GetStream()
Returns the output stream associated with the debug context.
This is obsolete, replaced by wxLog functionality.
See also
streambuf* GetStreamBuf()
Returns a pointer to the output stream buffer associated with the debug context. There may not necessarily be a stream buffer if the stream has been set by the user.
This is obsolete, replaced by wxLog functionality.
bool HasStream()
Returns true if there is a stream currently associated with the debug context.
This is obsolete, replaced by wxLog functionality.
See also
wxDebugContext::SetStream, wxDebugContext::GetStream
bool PrintClasses()
Prints a list of the classes declared in this application, giving derivation and whether instances of this class can be dynamically created.
See also
wxDebugContext::PrintStatistics
bool PrintStatistics(bool detailed = true)
Performs a statistics analysis from the currently set checkpoint, writing to the current debug stream. The number of object and non-object allocations is printed, together with the total size.
Parameters
detailed
See also
wxDebugContext::PrintStatistics
void SetCheckpoint(bool all = false)
Sets the current checkpoint: Dump and PrintStatistics operations will be performed from this point on. This allows you to ignore allocations that have been performed up to this point.
Parameters
all
void SetCheckPrevious(bool check)
Tells the memory allocator to check all previous memory blocks for errors. By default, this is false since it slows down execution considerably.
See also
wxDebugContext::GetCheckPrevious
void SetDebugMode(bool debug)
Sets the debug mode on or off. If debug mode is on, the wxObject new and delete operators store or use information about memory allocation. Otherwise, a straight malloc and free will be performed by these operators.
By default, debug mode is on if __WXDEBUG__ is defined. If the application uses this function, it should make sure that all object memory allocated is deallocated with the same value of debug mode. Otherwise, the delete operator might try to look for memory information that does not exist.
See also
bool SetFile(const wxString& filename)
Sets the current debug file and creates a stream. This will delete any existing stream and stream buffer. By default, the debug context stream outputs to the debugger (Windows) or standard error (other platforms).
void SetLevel(int level)
Sets the debug level (default 1). The debug level is used by the wxTraceLevel function and the WXTRACELEVEL macro to specify how detailed the trace information is; setting a different level will only have an effect if trace statements in the application specify a value other than one.
This is obsolete, replaced by wxLog functionality.
See also
bool SetStandardError()
Sets the debugging stream to be the debugger (Windows) or standard error (other platforms). This is the default setting. The existing stream will be flushed and deleted.
This is obsolete, replaced by wxLog functionality.
void SetStream(ostream* stream, streambuf* streamBuf = NULL)
Sets the stream and optionally, stream buffer associated with the debug context. This operation flushes and deletes the existing stream (and stream buffer if any).
This is obsolete, replaced by wxLog functionality.
Parameters
stream
streamBuf
See also
wxDebugContext::GetStream, wxDebugContext::HasStream