summaryrefslogtreecommitdiff
path: root/src/mongo/util/stacktrace.cpp
diff options
context:
space:
mode:
authorTad Marshall <tad@10gen.com>2012-07-30 18:33:08 -0400
committerTad Marshall <tad@10gen.com>2012-07-31 14:13:20 -0400
commit5300139ceb188361f773c7a6f3c24f9fe9affd6a (patch)
treed826820a7e823ea213659d7dce960d6761e4f2e1 /src/mongo/util/stacktrace.cpp
parentbb2b218b02b60e03ddd3487f7bf159497645f7e9 (diff)
downloadmongo-5300139ceb188361f773c7a6f3c24f9fe9affd6a.tar.gz
SERVER-6554 Windows unhandled exception filter print stack trace
Modify the Windows stack trace printing code to accept a "context", and use the context record passed to the unhandled exception filter to start the stack trace at the faulting instruction. Collect the context used for "normal" stack traces from inside printStackTrace.
Diffstat (limited to 'src/mongo/util/stacktrace.cpp')
-rw-r--r--src/mongo/util/stacktrace.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mongo/util/stacktrace.cpp b/src/mongo/util/stacktrace.cpp
index 9e9e61f138b..1daebe8b23f 100644
--- a/src/mongo/util/stacktrace.cpp
+++ b/src/mongo/util/stacktrace.cpp
@@ -151,6 +151,20 @@ namespace mongo {
* @param os ostream& to receive printed stack backtrace
*/
void printStackTrace( std::ostream& os ) {
+ CONTEXT context;
+ memset( &context, 0, sizeof(context) );
+ context.ContextFlags = CONTEXT_CONTROL;
+ RtlCaptureContext( &context );
+ printWindowsStackTrace( context, os );
+ }
+
+ /**
+ * Print stack trace (using a specified stack context) to "os"
+ *
+ * @param context CONTEXT record for stack trace
+ * @param os ostream& to receive printed stack backtrace
+ */
+ void printWindowsStackTrace( CONTEXT& context, std::ostream& os ) {
HANDLE process = GetCurrentProcess();
BOOL ret = SymInitialize( process, NULL, TRUE );
if ( ret == FALSE ) {
@@ -163,11 +177,6 @@ namespace mongo {
options |= SYMOPT_LOAD_LINES | SYMOPT_FAIL_CRITICAL_ERRORS;
SymSetOptions( options );
- CONTEXT context;
- memset( &context, 0, sizeof(context) );
- context.ContextFlags = CONTEXT_CONTROL;
- RtlCaptureContext( &context );
-
STACKFRAME64 frame64;
memset( &frame64, 0, sizeof(frame64) );