]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | #ifndef _MSVC_DBG_H | |
23 | #define _MSVC_DBG_H | |
24 | ||
25 | #include <stdlib.h> | |
26 | ||
27 | #ifdef __cplusplus | |
28 | extern "C" { | |
29 | #endif | |
30 | ||
31 | #if !MSVC_DBG_DLL | |
32 | #define MSVC_DBG_EXPORT | |
33 | #elif MSVC_DBG_BUILD | |
34 | #define MSVC_DBG_EXPORT __declspec(dllexport) | |
35 | #else | |
36 | #define MSVC_DBG_EXPORT __declspec(dllimport) | |
37 | #endif | |
38 | ||
39 | #ifndef MAX_SYM_NAME | |
40 | #define MAX_SYM_NAME 2000 | |
41 | #endif | |
42 | ||
43 | typedef void* HANDLE; | |
44 | typedef struct _CONTEXT CONTEXT; | |
45 | ||
46 | MSVC_DBG_EXPORT size_t GetStackFrames(size_t skip, void* frames[], size_t maxFrames); | |
47 | MSVC_DBG_EXPORT size_t GetStackFramesFromContext(HANDLE hProcess, HANDLE hThread, CONTEXT* context, size_t skip, void* frames[], size_t maxFrames); | |
48 | ||
49 | MSVC_DBG_EXPORT size_t GetModuleNameFromAddress(void* address, char* moduleName, size_t size); | |
50 | MSVC_DBG_EXPORT size_t GetModuleNameFromStack(size_t skip, char* moduleName, size_t size); | |
51 | ||
52 | MSVC_DBG_EXPORT size_t GetSymbolNameFromAddress(void* address, char* symbolName, size_t size, size_t* offsetBytes); | |
53 | MSVC_DBG_EXPORT size_t GetSymbolNameFromStack(size_t skip, char* symbolName, size_t size, size_t* offsetBytes); | |
54 | ||
55 | MSVC_DBG_EXPORT size_t GetFileLineFromAddress(void* address, char* fileName, size_t size, size_t* lineNumber, size_t* offsetBytes); | |
56 | MSVC_DBG_EXPORT size_t GetFileLineFromStack(size_t skip, char* fileName, size_t size, size_t* lineNumber, size_t* offsetBytes); | |
57 | ||
58 | MSVC_DBG_EXPORT size_t GetDescriptionFromAddress(void* address, const char* format, char* description, size_t size); | |
59 | MSVC_DBG_EXPORT size_t GetDescriptionFromStack(void*const frames[], size_t count, const char* format, char* description[], size_t size); | |
60 | ||
61 | /* Compatibility with <execinfo.h> */ | |
62 | MSVC_DBG_EXPORT int backtrace(void* addresses[], int count); | |
63 | MSVC_DBG_EXPORT char** backtrace_symbols(void*const addresses[], int count); | |
64 | ||
65 | #ifdef __cplusplus | |
66 | } | |
67 | #endif | |
68 | ||
69 | #endif/*_MSVC_DBG_H*/ |