API Documentation
Loading...
Searching...
No Matches
StackTracer.h
Go to the documentation of this file.
1/*
2//
3// Description: This class is used to get the call stack when there is an exception being caught use SEH
4//
5// Author: Baiyan Huang
6// Date: 8/30/2009
7//
8// Usage:
9// __try
10// {
11// // main functions...
12// }
13// __except(StackTracer::ExceptionFilter(GetExceptionInformation()))
14// {
15// // Your code to show or log the exception msg...
16// }
17*/
18
19#pragma once
20#include <NDEVR/String.h>
21#ifdef _WIN32
22 #include <vector>
23 #include <map>
24 #include <Windows.h>
25 #include <string>
26
27#endif
28namespace NDEVR
29{
37 {
38 public:
39#ifdef _WIN32
40 static LONG ExceptionFilter(LPEXCEPTION_POINTERS e);
41 static DWORD GetExceptionCode();
42#endif
43 // return the exception message along with call stacks
44 static String GetCallStack();
46
47 // Return exception code and call stack data structure so that
48 // user could customize their own message format
50 String callStack() const;
51
52 private:
53 static StackTracer s_StackTracer;
54
55 private:
56 StackTracer(void);
57 ~StackTracer(void);
58#ifdef _WIN32
59 // The main function to handle exception
60 LONG __stdcall HandleException(LPEXCEPTION_POINTERS e);
61
62 // Work through the stack upwards to get the entire call stack
63 void traceCallStack(CONTEXT* pContext);
64#endif
65 private:
66#ifdef _WIN32
67 DWORD m_dwExceptionCode = 0;
68 typedef std::map<DWORD, const char*> CodeDescMap;
69 CodeDescMap m_mapCodeDesc;
70 DWORD m_dwMachineType = 0; // Machine type matters when trace the call stack (StackWalk64)
71#endif
72 Buffer<FunctionCall> m_call_stack;
73
74 };
75}
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition StackTracer.h:37
static Buffer< FunctionCall > GetExceptionCallStack()
Definition StackTracer.cpp:199
static String GetExceptionMessage()
Definition StackTracer.cpp:100
String callStack() const
Definition StackTracer.cpp:203
static String GetCallStack()
Definition StackTracer.cpp:86
Definition String.h:40
Definition ACIColor.h:37
Definition StackTracer.h:31
String FileName
Definition StackTracer.h:33
String FunctionName
Definition StackTracer.h:32
int LineNumber
Definition StackTracer.h:34