wxRuby Documentation Home

# Wx::DebugContext

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 Widgets,
i.e. if the WXDEBUG symbol is defined. DebugContext
and related functions and macros can be compiled out by setting
USE_DEBUG_CONTEXT to 0 is setup.h

## Derived from

No parent class.

## See also

Overviewwxdebugcontextoverview

## Methods

- DebugContext#check
- DebugContext#dump
- DebugContext#get_check_previous
- DebugContext#get_debug_mode
- DebugContext#get_level
- DebugContext#get_stream
- DebugContext#get_stream_buf
- DebugContext#has_stream
- DebugContext#print_classes
- DebugContext#print_statistics
- DebugContext#set_checkpoint
- DebugContext#set_check_previous
- DebugContext#set_debug_mode
- DebugContext#set_file
- DebugContext#set_level
- DebugContext#set_standard_error
- DebugContext#set_stream

### DebugContext#check

Integer 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.

### DebugContext#dump

Boolean dump()

Performs a memory dump from the currently set checkpoint, writing to the
current debug stream. Calls the Dump member function for each Object
derived instance.

#### Return value

true if the function succeeded, false otherwise.

### DebugContext#get_check_previous

Boolean get_check_previous()

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

DebugContext#set_check_previous

### DebugContext#get_debug_mode

Boolean get_debug_mode()

Returns true if debug mode is on. If debug mode is on, the Object 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

DebugContext#set_debug_mode

### DebugContext#get_level

Integer get_level()

Gets the debug level (default 1). The debug level is used by the TraceLevel 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 Log functionality.

#### See also

DebugContext#set_level

### DebugContext#get_stream

ostream get_stream()

Returns the output stream associated with the debug context.

This is obsolete, replaced by Log functionality.

#### See also

DebugContext#set_stream

### DebugContext#get_stream_buf

streambuf get_stream_buf()

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 Log functionality.

### DebugContext#has_stream

Boolean has_stream()

Returns true if there is a stream currently associated
with the debug context.

This is obsolete, replaced by Log functionality.

#### See also

DebugContext#set_stream, DebugContext#get_stream

### DebugContext#print_classes

Boolean print_classes()

Prints a list of the classes declared in this application, giving derivation
and whether instances of this class can be dynamically created.

#### See also

DebugContext#print_statistics

### DebugContext#print_statistics

Boolean print_statistics(%(arg-type)Boolean% 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 If true, the function will also print how many
  objects of each class have been allocated, and the space taken by
  these class instances.

#### See also

DebugContext#print_statistics

### DebugContext#set_checkpoint

set_checkpoint(%(arg-type)Boolean% 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 If true, the checkpoint is reset to include all
  memory allocations since the program started.

### DebugContext#set_check_previous

set_check_previous(%(arg-type)Boolean% 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

DebugContext#get_check_previous

### DebugContext#set_debug_mode

set_debug_mode(%(arg-type)Boolean% debug)

Sets the debug mode on or off. If debug mode is on, the Object 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

DebugContext#get_debug_mode

### DebugContext#set_file

Boolean set_file(%(arg-type)String% 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).

### DebugContext#set_level

set_level(%(arg-type)Integer% level)

Sets the debug level (default 1). The debug level is used by the TraceLevel 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 Log functionality.

#### See also

DebugContext#get_level

### DebugContext#set_standard_error

Boolean set_standard_error()

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 Log functionality.

### DebugContext#set_stream

set_stream(%(arg-type)ostream% stream, streambuf streamBuf = nil)

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 Log functionality.

#### Parameters

- stream Stream to associate with the debug context. Do not set this to NULL.
- streamBuf Stream buffer to associate with the debug context.

#### See also

DebugContext#get_stream, DebugContext#has_stream

[This page automatically generated from the Textile source at 2023-06-09 00:45:28 +0000]