]>
Commit | Line | Data |
---|---|---|
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 | %% Name: stackwalker.tex | |
3 | %% Purpose: wxStackWalker documentation | |
4 | %% Author: Vadim Zeitlin | |
5 | %% Created: 2005-01-19 | |
6 | %% RCS-ID: $Id$ | |
7 | %% Copyright: (c) 2005 Vadim Zeitlin | |
8 | %% License: wxWindows license | |
9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
10 | ||
11 | \section{\class{wxStackWalker}}\label{wxstackwalker} | |
12 | ||
13 | wxStackWalker allows an application to enumerate, or walk, the stack frames (the function callstack). | |
14 | It is mostly useful in only two situations: | |
15 | inside \helpref{wxApp::OnFatalException}{wxapponfatalexception} function to | |
16 | programmatically get the location of the crash and, in debug builds, in | |
17 | \helpref{wxApp::OnAssertFailure}{wxapponassertfailure} to report the caller of the failed | |
18 | assert. | |
19 | ||
20 | wxStackWalker works by repeatedly calling | |
21 | the \helpref{OnStackFrame}{wxstackwalkeronstackframe} method for each frame in the | |
22 | stack, so to use it you must derive your own class from it and override this | |
23 | method. | |
24 | ||
25 | This class will not return anything except raw stack frame addresses if the | |
26 | debug information is not available. Under Win32 this means that the PDB file | |
27 | matching the program being executed should be present. Note that if you use | |
28 | Microsoft Visual C++ compiler, you can create PDB files even for the programs | |
29 | built in release mode and it doesn't affect the program size (at least if you | |
30 | don't forget to add \texttt{/opt:ref} option which is suppressed by using | |
31 | \texttt{/debug} linker option by default but should be always enabled for | |
32 | release builds). Under Unix, you need to compile your program with debugging | |
33 | information (usually using \texttt{-g} compiler and linker options) to get the | |
34 | file and line numbers information, however function names should be available | |
35 | even without it. Of course, all this is only true if you build using a recent | |
36 | enough version of GNU libc which provides the \texttt{backtrace()} function | |
37 | needed to walk the stack. | |
38 | ||
39 | \helpref{debugging overview}{debuggingoverview} for how to make it available. | |
40 | ||
41 | \wxheading{Derived from} | |
42 | ||
43 | No base class | |
44 | ||
45 | \wxheading{Include files} | |
46 | ||
47 | <wx/stackwalk.h> | |
48 | ||
49 | \wxheading{Library} | |
50 | ||
51 | \helpref{wxBase}{librarieslist} | |
52 | ||
53 | Only available if \texttt{wxUSE\_STACKWALKER} is $1$, currently only | |
54 | implemented for Win32 and Unix versions using recent version of GNU libc. | |
55 | ||
56 | \wxheading{See also} | |
57 | ||
58 | \helpref{wxStackFrame}{wxstackframe} | |
59 | ||
60 | ||
61 | \latexignore{\rtfignore{\wxheading{Members}}} | |
62 | ||
63 | ||
64 | \membersection{wxStackWalker::wxStackWalker}\label{wxstackwalkerwxstackwalker} | |
65 | ||
66 | \func{}{wxStackWalker}{\void} | |
67 | ||
68 | Constructor does nothing, use \helpref{Walk()}{wxstackwalkerwalk} to walk the | |
69 | stack. | |
70 | ||
71 | ||
72 | \membersection{wxStackWalker::\destruct{wxStackWalker}}\label{wxstackwalkerdtor} | |
73 | ||
74 | \func{}{\destruct{wxStackWalker}}{\void} | |
75 | ||
76 | Destructor does nothing neither but should be virtual as this class is used as | |
77 | a base one. | |
78 | ||
79 | ||
80 | \membersection{wxStackWalker::OnStackFrame}\label{wxstackwalkeronstackframe} | |
81 | ||
82 | \func{void}{OnStackFrame}{\param{const wxStackFrame\& }{frame}} | |
83 | ||
84 | This function must be overrided to process the given frame. | |
85 | ||
86 | ||
87 | \membersection{wxStackWalker::Walk}\label{wxstackwalkerwalk} | |
88 | ||
89 | \func{void}{Walk}{\param{size\_t }{skip = 1}, \param{size\_t }{maxDepth = 200}} | |
90 | ||
91 | Enumerate stack frames from the current location, skipping the initial | |
92 | number of them (this can be useful when Walk() is called from some known | |
93 | location and you don't want to see the first few frames anyhow; also | |
94 | notice that Walk() frame itself is not included if skip $\ge 1$). | |
95 | ||
96 | Up to \arg{maxDepth} frames are walked from the innermost to the outermost one. | |
97 | ||
98 | ||
99 | \membersection{wxStackWalker::WalkFromException}\label{wxstackwalkerwalkfromexception} | |
100 | ||
101 | \func{void}{WalkFromException}{\param{size\_t }{maxDepth = 200}} | |
102 | ||
103 | Enumerate stack frames from the location of uncaught exception. | |
104 | This method can only be called from | |
105 | \helpref{wxApp::OnFatalException()}{wxapponfatalexception}. | |
106 | ||
107 | Up to \arg{maxDepth} frames are walked from the innermost to the outermost one. | |
108 |