| 1 |
/* |
| 2 |
Copyright (c) 2004-2005 Andrei Polushin |
| 3 |
|
| 4 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
of this software and associated documentation files (the "Software"), to deal |
| 6 |
in the Software without restriction, including without limitation the rights |
| 7 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 |
copies of the Software, and to permit persons to whom the Software is |
| 9 |
furnished to do so, subject to the following conditions: |
| 10 |
|
| 11 |
The above copyright notice and this permission notice shall be included in |
| 12 |
all copies or substantial portions of the Software. |
| 13 |
|
| 14 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 20 |
THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef GC_MSVC_DBG_H |
| 24 |
#define GC_MSVC_DBG_H |
| 25 |
|
| 26 |
#include <stdlib.h> |
| 27 |
|
| 28 |
#ifdef __cplusplus |
| 29 |
extern "C" { |
| 30 |
#endif |
| 31 |
|
| 32 |
#if !MSVC_DBG_DLL |
| 33 |
#define MSVC_DBG_EXPORT |
| 34 |
#elif MSVC_DBG_BUILD |
| 35 |
#define MSVC_DBG_EXPORT __declspec(dllexport) |
| 36 |
#else |
| 37 |
#define MSVC_DBG_EXPORT __declspec(dllimport) |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifndef MAX_SYM_NAME |
| 41 |
#define MAX_SYM_NAME 2000 |
| 42 |
#endif |
| 43 |
|
| 44 |
typedef void* HANDLE; |
| 45 |
typedef struct _CONTEXT CONTEXT; |
| 46 |
|
| 47 |
MSVC_DBG_EXPORT size_t GetStackFrames(size_t skip, void* frames[], size_t maxFrames); |
| 48 |
MSVC_DBG_EXPORT size_t GetStackFramesFromContext(HANDLE hProcess, HANDLE hThread, CONTEXT* context, size_t skip, void* frames[], size_t maxFrames); |
| 49 |
|
| 50 |
MSVC_DBG_EXPORT size_t GetModuleNameFromAddress(void* address, char* moduleName, size_t size); |
| 51 |
MSVC_DBG_EXPORT size_t GetModuleNameFromStack(size_t skip, char* moduleName, size_t size); |
| 52 |
|
| 53 |
MSVC_DBG_EXPORT size_t GetSymbolNameFromAddress(void* address, char* symbolName, size_t size, size_t* offsetBytes); |
| 54 |
MSVC_DBG_EXPORT size_t GetSymbolNameFromStack(size_t skip, char* symbolName, size_t size, size_t* offsetBytes); |
| 55 |
|
| 56 |
MSVC_DBG_EXPORT size_t GetFileLineFromAddress(void* address, char* fileName, size_t size, size_t* lineNumber, size_t* offsetBytes); |
| 57 |
MSVC_DBG_EXPORT size_t GetFileLineFromStack(size_t skip, char* fileName, size_t size, size_t* lineNumber, size_t* offsetBytes); |
| 58 |
|
| 59 |
MSVC_DBG_EXPORT size_t GetDescriptionFromAddress(void* address, const char* format, char* description, size_t size); |
| 60 |
MSVC_DBG_EXPORT size_t GetDescriptionFromStack(void*const frames[], size_t count, const char* format, char* description[], size_t size); |
| 61 |
|
| 62 |
/* Compatibility with <execinfo.h> */ |
| 63 |
MSVC_DBG_EXPORT int backtrace(void* addresses[], int count); |
| 64 |
MSVC_DBG_EXPORT char** backtrace_symbols(void*const addresses[], int count); |
| 65 |
|
| 66 |
#ifdef __cplusplus |
| 67 |
} /* extern "C" */ |
| 68 |
#endif |
| 69 |
|
| 70 |
#endif /* GC_MSVC_DBG_H */ |