Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
wdbg_sym.h
Go to the documentation of this file.
1/* Copyright (C) 2022 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# pragma warning(disable:4091) // hides previous local declaration
32#endif
33
34#include "lib/sysdep/os/win/win.h" // CONTEXT, EXCEPTION_POINTERS
35
36struct _tagSTACKFRAME64;
37
38/**
39 * called for each stack frame found by wdbg_sym_WalkStack.
40 *
41 * @param frame the dbghelp stack frame (we can't just pass the
42 * instruction-pointer because dump_frame_cb needs the frame pointer to
43 * locate frame-relative variables)
44 * @param cbData the user-specified value that was passed to wdbg_sym_WalkStack
45 * @return Status (see RETURN_STATUS_FROM_CALLBACK).
46 **/
47typedef Status (*StackFrameCallback)(const _tagSTACKFRAME64* frame, uintptr_t cbData);
48
49/**
50 * Iterate over a call stack, invoking a callback for each frame encountered.
51 *
52 * @param cb
53 * @param cbData
54 * @param context Processor context from which to start (taken from
55 * an exception record or debug_CaptureContext).
56 * @param lastFuncToSkip
57 *
58 * @note It is safe to use ENSURE/debug_warn/WARN_RETURN_STATUS_IF_ERR even during a
59 * stack trace (which is triggered by ENSURE et al. in app code) because
60 * nested stack traces are ignored and only the error is displayed.
61 **/
62Status wdbg_sym_WalkStack(StackFrameCallback cb, uintptr_t cbData, CONTEXT& context, const wchar_t* lastFuncToSkip = 0);
63
64void wdbg_sym_WriteMinidump(EXCEPTION_POINTERS* ep);
65
66#endif // #ifndef INCLUDED_WDBG_SYM
i64 Status
Error handling system.
Definition: status.h:173
Status(* StackFrameCallback)(const _tagSTACKFRAME64 *frame, uintptr_t cbData)
called for each stack frame found by wdbg_sym_WalkStack.
Definition: wdbg_sym.h:47
void wdbg_sym_WriteMinidump(EXCEPTION_POINTERS *ep)
Definition: wdbg_sym.cpp:1743
Status wdbg_sym_WalkStack(StackFrameCallback cb, uintptr_t cbData, CONTEXT &context, const wchar_t *lastFuncToSkip=0)
Iterate over a call stack, invoking a callback for each frame encountered.
Definition: wdbg_sym.cpp:299