1 /* Copyright (C) 2018 Wildfire Games. 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining 4 * a copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sublicense, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 /* 24 * Win32 stack trace and symbol engine. 25 */ 26 27 #ifndef INCLUDED_WDBG_SYM 28 #define INCLUDED_WDBG_SYM 29 30 #ifdef _MSC_VER 31 #if _MSC_VER > 1800 32 # pragma warning(disable:4091) // hides previous local declaration 33 #endif 34 #endif 35 36 #include "lib/sysdep/os/win/win.h" // CONTEXT, EXCEPTION_POINTERS 37 38 struct _tagSTACKFRAME64; 39 40 /** 41 * called for each stack frame found by wdbg_sym_WalkStack. 42 * 43 * @param frame the dbghelp stack frame (we can't just pass the 44 * instruction-pointer because dump_frame_cb needs the frame pointer to 45 * locate frame-relative variables) 46 * @param cbData the user-specified value that was passed to wdbg_sym_WalkStack 47 * @return Status (see RETURN_STATUS_FROM_CALLBACK). 48 **/ 49 typedef Status (*StackFrameCallback)(const _tagSTACKFRAME64* frame, uintptr_t cbData); 50 51 /** 52 * Iterate over a call stack, invoking a callback for each frame encountered. 53 * 54 * @param cb 55 * @param cbData 56 * @param context Processor context from which to start (taken from 57 * an exception record or debug_CaptureContext). 58 * @param lastFuncToSkip 59 * 60 * @note It is safe to use ENSURE/debug_warn/WARN_RETURN_STATUS_IF_ERR even during a 61 * stack trace (which is triggered by ENSURE et al. in app code) because 62 * nested stack traces are ignored and only the error is displayed. 63 **/ 64 LIB_API Status wdbg_sym_WalkStack(StackFrameCallback cb, uintptr_t cbData, CONTEXT& context, const wchar_t* lastFuncToSkip = 0); 65 66 LIB_API void wdbg_sym_WriteMinidump(EXCEPTION_POINTERS* ep); 67 68 #endif // #ifndef INCLUDED_WDBG_SYM 69