Skip to content

Commit f10743f

Browse files
committed
Added info about C++ exception handler to README.md
1 parent 68e9994 commit f10743f

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ class StackWalker
121121
protected:
122122
virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName);
123123
virtual void OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size,
124-
DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion);
124+
DWORD result, LPCSTR symType, LPCSTR pdbName,
125+
ULONGLONG fileVersion);
125126
virtual void OnCallstackEntry(CallstackEntryType eType, CallstackEntry &entry);
126127
virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
127128
};
@@ -140,9 +141,12 @@ public:
140141
LPCSTR szSymPath = NULL,
141142
DWORD dwProcessId = GetCurrentProcessId(),
142143
HANDLE hProcess = GetCurrentProcess());
143-
// Just for other processes with
144-
// default-values for options and symPath
144+
145+
// Just for other processes with default-values for options and symPath
145146
StackWalker(DWORD dwProcessId, HANDLE hProcess);
147+
148+
// For showing stack trace after __except or catch
149+
StackWalker(ExceptType extype, int options = OptionsAll, PEXCEPTION_POINTERS exp = NULL);
146150
};
147151
```
148152

@@ -159,7 +163,7 @@ public:
159163

160164
### Displaying the callstack of an exception
161165

162-
With this `StackWalker` you can also display the callstack inside an exception handler. You only need to write a filter-function which does the stack-walking:
166+
With this `StackWalker` you can also display the callstack inside an structured exception handler. You only need to write a filter-function which does the stack-walking:
163167

164168
```c++
165169
// The exception filter function:
@@ -180,6 +184,25 @@ __except (ExpFilter(GetExceptionInformation(), GetExceptionCode()))
180184
}
181185
```
182186
187+
Display the callstack inside an C++ exception handler (two ways):
188+
```c++
189+
// This is how to catch an exception:
190+
try
191+
{
192+
// do some ugly stuff...
193+
}
194+
catch (std::exception & ex)
195+
{
196+
StackWalker sw;
197+
sw.ShowCallstack(GetCurrentThread(), sw.GetCurrentExceptionContext());
198+
}
199+
catch (...)
200+
{
201+
StackWalker sw(StackWalker::AfterCatch);
202+
sw.ShowCallstack();
203+
}
204+
```
205+
183206
## Points of Interest
184207

185208
### Context and callstack

0 commit comments

Comments
 (0)