1 \section{\class{wxDebugContext
}}\label{wxdebugcontext
}
3 A class for performing various debugging and memory tracing
4 operations. Full functionality (such as printing out objects
5 currently allocated) is only present in a debugging build of wxWindows,
6 i.e. if the
\_\_WXDEBUG\_\_ symbol is defined. wxDebugContext
7 and related functions and macros can be compiled out by setting
8 wxUSE
\_DEBUG\_CONTEXT to
0 is setup.h
10 \wxheading{Derived from
}
14 \wxheading{Include files
}
20 \overview{Overview
}{wxdebugcontextoverview
}
22 \latexignore{\rtfignore{\wxheading{Members
}}}
24 \membersection{wxDebugContext::Check
}\label{wxdebugcontextcheck
}
26 \func{int
}{Check
}{\void}
28 Checks the memory blocks for errors, starting from the currently set
31 \wxheading{Return value
}
33 Returns the number of errors,
34 so a value of zero represents success. Returns -
1 if an error
35 was detected that prevents further checking.
37 \membersection{wxDebugContext::Dump
}\label{wxdebugcontextdump
}
39 \func{bool
}{Dump
}{\void}
41 Performs a memory dump from the currently set checkpoint, writing to the
42 current debug stream. Calls the
{\bf Dump
} member function for each wxObject
45 \wxheading{Return value
}
47 true if the function succeeded, false otherwise.
49 \membersection{wxDebugContext::GetCheckPrevious
}\label{wxdebugcontextgetcheckprevious
}
51 \func{bool
}{GetCheckPrevious
}{\void}
53 Returns true if the memory allocator checks all previous memory blocks for errors.
54 By default, this is false since it slows down execution considerably.
58 \helpref{wxDebugContext::SetCheckPrevious
}{wxdebugcontextsetcheckprevious
}
60 \membersection{wxDebugContext::GetDebugMode
}\label{wxdebugcontextgetdebugmode
}
62 \func{bool
}{GetDebugMode
}{\void}
64 Returns true if debug mode is on. If debug mode is on, the wxObject new and delete
65 operators store or use information about memory allocation. Otherwise,
66 a straight malloc and free will be performed by these operators.
70 \helpref{wxDebugContext::SetDebugMode
}{wxdebugcontextsetdebugmode
}
72 \membersection{wxDebugContext::GetLevel
}\label{wxdebugcontextgetlevel
}
74 \func{int
}{GetLevel
}{\void}
76 Gets the debug level (default
1). The debug level is used by the wxTraceLevel function and
77 the WXTRACELEVEL macro to specify how detailed the trace information is; setting
78 a different level will only have an effect if trace statements in the application
79 specify a value other than one.
81 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
85 \helpref{wxDebugContext::SetLevel
}{wxdebugcontextsetlevel
}
87 \membersection{wxDebugContext::GetStream
}\label{wxdebugcontextgetstream
}
89 \func{ostream\&
}{GetStream
}{\void}
91 Returns the output stream associated with the debug context.
93 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
97 \helpref{wxDebugContext::SetStream
}{wxdebugcontextsetstream
}
99 \membersection{wxDebugContext::GetStreamBuf
}\label{wxdebugcontextgetstreambuf
}
101 \func{streambuf*
}{GetStreamBuf
}{\void}
103 Returns a pointer to the output stream buffer associated with the debug context.
104 There may not necessarily be a stream buffer if the stream has been set
107 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
109 \membersection{wxDebugContext::HasStream
}\label{wxdebugcontexthasstream
}
111 \func{bool
}{HasStream
}{\void}
113 Returns true if there is a stream currently associated
114 with the debug context.
116 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
120 \helpref{wxDebugContext::SetStream
}{wxdebugcontextsetstream
},
\helpref{wxDebugContext::GetStream
}{wxdebugcontextgetstream
}
122 \membersection{wxDebugContext::PrintClasses
}\label{wxdebugcontextprintclasses
}
124 \func{bool
}{PrintClasses
}{\void}
126 Prints a list of the classes declared in this application, giving derivation
127 and whether instances of this class can be dynamically created.
131 \helpref{wxDebugContext::PrintStatistics
}{wxdebugcontextprintstatistics
}
133 \membersection{wxDebugContext::PrintStatistics
}\label{wxdebugcontextprintstatistics
}
135 \func{bool
}{PrintStatistics
}{\param{bool
}{ detailed = true
}}
137 Performs a statistics analysis from the currently set checkpoint, writing
138 to the current debug stream. The number of object and non-object
139 allocations is printed, together with the total size.
141 \wxheading{Parameters
}
143 \docparam{detailed
}{If true, the function will also print how many
144 objects of each class have been allocated, and the space taken by
145 these class instances.
}
149 \helpref{wxDebugContext::PrintStatistics
}{wxdebugcontextprintstatistics
}
151 \membersection{wxDebugContext::SetCheckpoint
}\label{wxdebugcontextsetcheckpoint
}
153 \func{void
}{SetCheckpoint
}{\param{bool
}{ all = false
}}
155 Sets the current checkpoint: Dump and PrintStatistics operations will
156 be performed from this point on. This allows you to ignore allocations
157 that have been performed up to this point.
159 \wxheading{Parameters
}
161 \docparam{all
}{If true, the checkpoint is reset to include all
162 memory allocations since the program started.
}
164 \membersection{wxDebugContext::SetCheckPrevious
}\label{wxdebugcontextsetcheckprevious
}
166 \func{void
}{SetCheckPrevious
}{\param{bool
}{ check
}}
168 Tells the memory allocator to check all previous memory blocks for errors.
169 By default, this is false since it slows down execution considerably.
173 \helpref{wxDebugContext::GetCheckPrevious
}{wxdebugcontextgetcheckprevious
}
175 \membersection{wxDebugContext::SetDebugMode
}\label{wxdebugcontextsetdebugmode
}
177 \func{void
}{SetDebugMode
}{\param{bool
}{ debug
}}
179 Sets the debug mode on or off. If debug mode is on, the wxObject new and delete
180 operators store or use information about memory allocation. Otherwise,
181 a straight malloc and free will be performed by these operators.
183 By default, debug mode is on if
\_\_WXDEBUG\_\_ is defined. If the application
184 uses this function, it should make sure that all object memory allocated
185 is deallocated with the same value of debug mode. Otherwise, the
186 delete operator might try to look for memory information that does not
191 \helpref{wxDebugContext::GetDebugMode
}{wxdebugcontextgetdebugmode
}
193 \membersection{wxDebugContext::SetFile
}\label{wxdebugcontextsetfile
}
195 \func{bool
}{SetFile
}{\param{const wxString\&
}{filename
}}
197 Sets the current debug file and creates a stream. This will delete any existing
198 stream and stream buffer. By default, the debug context stream
199 outputs to the debugger (Windows) or standard error (other platforms).
201 \membersection{wxDebugContext::SetLevel
}\label{wxdebugcontextsetlevel
}
203 \func{void
}{SetLevel
}{\param{int
}{ level
}}
205 Sets the debug level (default
1). The debug level is used by the wxTraceLevel function and
206 the WXTRACELEVEL macro to specify how detailed the trace information is; setting
207 a different level will only have an effect if trace statements in the application
208 specify a value other than one.
210 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
214 \helpref{wxDebugContext::GetLevel
}{wxdebugcontextgetlevel
}
216 \membersection{wxDebugContext::SetStandardError
}\label{wxdebugcontextsetstandarderror
}
218 \func{bool
}{SetStandardError
}{\void}
220 Sets the debugging stream to be the debugger (Windows) or standard error (other platforms).
221 This is the default setting. The existing stream will be flushed and deleted.
223 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
225 \membersection{wxDebugContext::SetStream
}\label{wxdebugcontextsetstream
}
227 \func{void
}{SetStream
}{\param{ostream*
}{stream
},
\param{streambuf*
}{streamBuf = NULL
}}
229 Sets the stream and optionally, stream buffer associated with the debug context.
230 This operation flushes and deletes the existing stream (and stream buffer if any).
232 This is obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
234 \wxheading{Parameters
}
236 \docparam{stream
}{Stream to associate with the debug context. Do not set this to NULL.
}
238 \docparam{streamBuf
}{Stream buffer to associate with the debug context.
}
242 \helpref{wxDebugContext::GetStream
}{wxdebugcontextgetstream
},
\helpref{wxDebugContext::HasStream
}{wxdebugcontexthasstream
}
244 \section{\class{wxDebugStreamBuf
}}\label{wxdebugstreambuf
}
246 This class allows you to treat debugging output in a similar
247 (stream-based) fashion on different platforms. Under
248 Windows, an ostream constructed with this buffer outputs
249 to the debugger, or other program that intercepts debugging
250 output. On other platforms, the output goes to standard error (cerr).
252 This is soon to be obsolete, replaced by
\helpref{wxLog
}{wxlog
} functionality.
254 \wxheading{Derived from
}
258 \wxheading{Include files
}
265 wxDebugStreamBuf streamBuf;
266 ostream stream(&streamBuf);
268 stream << "Hello world!" << endl;
273 \overview{Overview
}{wxdebugcontextoverview
}