Pyrogenesis
13997
|
#include "precompiled.h"
#include "lib/sysdep/os/win/wdbg_sym.h"
#include <cstdlib>
#include <cstdio>
#include <set>
#include "lib/byte_order.h"
#include "lib/module_init.h"
#include "lib/sysdep/cpu.h"
#include "lib/debug_stl.h"
#include "lib/app_hooks.h"
#include "lib/external_libraries/dbghelp.h"
#include "lib/sysdep/os/win/wdbg.h"
#include "lib/sysdep/os/win/wutil.h"
#include "lib/sysdep/os/win/winit.h"
Go to the source code of this file.
Classes | |
struct | SYMBOL_INFO_PACKAGEW2 |
struct | TI_FINDCHILDREN_PARAMS2 |
struct | DumpState |
Macros | |
#define | INDENT STMT(for(size_t i__ = 0; i__ <= state.level; i__++) out(L" ");) |
#define | UNINDENT STMT(out_erase((state.level+1)*4);) |
#define | SUPPRESS_HANDLE(name) if(!wcscmp(type_name, L#name L"__")) return true; |
Typedefs | |
typedef Status(* | DumpFunc )(DWORD typeId, const u8 *p, DumpState &state) |
Enumerations | |
enum | CV_HREG_e { CV_REG_EBP = 22, CV_AMD64_RBP = 334 } |
Functions | |
WINIT_REGISTER_CRITICAL_INIT (wdbg_sym_Init) | |
static | WUTIL_FUNC (pRtlCaptureContext, VOID,(PCONTEXT)) |
static Status | wdbg_sym_Init () |
static Status | InitDbghelp () |
static void | sym_init () |
static STACKFRAME64 | PopulateStackFrame (CONTEXT &context) |
static IMAGEHLP_STACK_FRAME | PopulateImageStackFrame (const STACKFRAME64 &sf) |
static Status | ResolveSymbol_lk (void *ptr_of_interest, wchar_t *sym_name, wchar_t *file, int *line) |
Status | debug_ResolveSymbol (void *ptr_of_interest, wchar_t *sym_name, wchar_t *file, int *line) |
read and return symbol information for the given address. More... | |
Status | debug_CaptureContext (void *pcontext) |
static Status | CallStackWalk (STACKFRAME64 &sf, CONTEXT &context) |
Status | wdbg_sym_WalkStack (StackFrameCallback cb, uintptr_t cbData, CONTEXT &context, const wchar_t *lastFuncToSkip) |
Iterate over a call stack, invoking a callback for each frame encountered. More... | |
void * | debug_GetCaller (void *pcontext, const wchar_t *lastFuncToSkip) |
return the caller of a certain function on the call stack. More... | |
static void | out_init (wchar_t *buf, size_t max_chars) |
static void | out (const wchar_t *fmt,...) |
static void | out_erase (size_t num_chars) |
static void | out_latch_pos () |
static Status | out_check_limit () |
static bool | is_string (const u8 *p, size_t stride) |
static Status | dump_sym (DWORD id, const u8 *p, DumpState &state) |
static void | dump_error (Status err) |
static Status | dump_string (const u8 *p, size_t el_size) |
static void | seq_determine_formatting (size_t el_size, size_t el_count, bool *fits_on_one_line, size_t *num_elements_to_show) |
static Status | dump_sequence (DebugStlIterator el_iterator, void *internal, size_t el_count, DWORD el_type_id, size_t el_size, DumpState &state) |
static const u8 * | array_iterator (void *internal, size_t el_size) |
static Status | dump_array (const u8 *p, size_t el_count, DWORD el_type_id, size_t el_size, DumpState &state) |
static Status | CanHandleDataKind (DWORD dataKind) |
static bool | IsRelativeToFramePointer (DWORD flags, DWORD reg) |
static bool | IsUnretrievable (DWORD flags) |
static Status | DetermineSymbolAddress (DWORD id, const SYMBOL_INFOW *sym, const DumpState &state, const u8 **pp) |
static Status | dump_sym_array (DWORD type_id, const u8 *p, DumpState &state) |
static void | AppendCharacterIfPrintable (u64 data) |
static Status | dump_sym_base_type (DWORD type_id, const u8 *p, DumpState &state) |
static Status | dump_sym_base_class (DWORD type_id, const u8 *p, DumpState &state) |
static Status | dump_sym_data (DWORD id, const u8 *p, DumpState &state) |
static Status | dump_sym_enum (DWORD type_id, const u8 *p, DumpState &state) |
static Status | dump_sym_function (DWORD type_id, const u8 *p, DumpState &state) |
static Status | dump_sym_function_type (DWORD type_id, const u8 *p, DumpState &state) |
static void | ptr_reset_visited () |
static bool | ptr_already_visited (const u8 *p) |
static Status | dump_sym_pointer (DWORD type_id, const u8 *p, DumpState &state) |
static Status | dump_sym_typedef (DWORD type_id, const u8 *p, DumpState &state) |
static Status | udt_get_child_type (const wchar_t *child_name, ULONG numChildren, const DWORD *children, const DumpState &state, DWORD *el_type_id, size_t *el_size) |
static Status | udt_dump_std (const wchar_t *type_name, const u8 *p, size_t size, DumpState &state, ULONG numChildren, const DWORD *children) |
static bool | udt_should_suppress (const wchar_t *type_name) |
static Status | udt_dump_suppressed (const wchar_t *type_name, const u8 *p, size_t size, DumpState state, ULONG numChildren, const DWORD *children) |
static bool | udt_fits_on_one_line (const wchar_t *type_name, size_t child_count, size_t total_size) |
static Status | udt_dump_normal (const wchar_t *type_name, const u8 *p, size_t size, DumpState state, ULONG numChildren, const DWORD *children) |
static Status | dump_sym_udt (DWORD type_id, const u8 *p, DumpState &state) |
static Status | dump_sym_vtable (DWORD type_id, const u8 *p, DumpState &state) |
static Status | dump_sym_unknown (DWORD type_id, const u8 *p, DumpState &state) |
static DumpFunc | DumpFuncFromTypeTag (DWORD typeTag) |
static bool | ShouldSkipSymbol (const wchar_t *name) |
static BOOL CALLBACK | dump_sym_cb (SYMBOL_INFOW *sym, ULONG size, PVOID userContext) |
static Status | dump_frame_cb (const STACKFRAME64 *sf, uintptr_t userContext) |
Status | debug_DumpStack (wchar_t *buf, size_t maxChars, void *pcontext, const wchar_t *lastFuncToSkip) |
write a complete stack trace (including values of local variables) into the specified buffer. More... | |
void | wdbg_sym_WriteMinidump (EXCEPTION_POINTERS *exception_pointers) |
Variables | |
static HANDLE | hProcess |
static WORD | machine |
static const size_t | maxIndirection = 255 |
static const size_t | maxLevel = 255 |
static size_t | out_chars_left |
static wchar_t * | out_pos |
static bool | out_have_warned_of_overflow |
static wchar_t * | out_latched_pos |
static bool | out_have_warned_of_limit |
static const size_t | maxVisited = 1000 |
static const u8 * | visited [maxVisited] |
static size_t | numVisited |
Definition at line 504 of file wdbg_sym.cpp.
#define SUPPRESS_HANDLE | ( | name | ) | if(!wcscmp(type_name, L#name L"__")) return true; |
Definition at line 505 of file wdbg_sym.cpp.
Definition at line 1592 of file wdbg_sym.cpp.
enum CV_HREG_e |
Enumerator | |
---|---|
CV_REG_EBP | |
CV_AMD64_RBP |
Definition at line 553 of file wdbg_sym.cpp.
|
static |
Definition at line 859 of file wdbg_sym.cpp.
|
static |
Definition at line 715 of file wdbg_sym.cpp.
|
static |
Definition at line 284 of file wdbg_sym.cpp.
Definition at line 732 of file wdbg_sym.cpp.
Status debug_CaptureContext | ( | void * | context | ) |
context | must point to an instance of the platform-specific type (e.g. CONTEXT) or CACHE_ALIGNED storage of DEBUG_CONTEXT_SIZE bytes. |
Definition at line 260 of file wdbg_sym.cpp.
Status debug_DumpStack | ( | wchar_t * | buf, |
size_t | maxChars, | ||
void * | context, | ||
const wchar_t * | lastFuncToSkip | ||
) |
write a complete stack trace (including values of local variables) into the specified buffer.
buf | Target buffer. |
maxChars | Max chars of buffer (should be several thousand). |
context | Platform-specific representation of execution state (e.g. Win32 CONTEXT). either specify an SEH exception's context record or use debug_CaptureContext to retrieve the current state. Rationale: intermediates such as debug_DisplayError change the context, so it should be captured as soon as possible. |
lastFuncToSkip | Is used for omitting error-reporting functions like debug_OnAssertionFailure from the stack trace. It is either 0 (skip nothing) or a substring of a function's name (this allows platform-independent matching of stdcall-decorated names). Rationale: this is safer than specifying a fixed number of frames, which can be incorrect due to inlining. |
Definition at line 1730 of file wdbg_sym.cpp.
void* debug_GetCaller | ( | void * | context, |
const wchar_t * | lastFuncToSkip | ||
) |
return the caller of a certain function on the call stack.
this function is useful for recording (partial) stack traces for memory allocation tracking, etc.
context,lastFuncToSkip | - see debug_DumpStack |
Definition at line 342 of file wdbg_sym.cpp.
Status debug_ResolveSymbol | ( | void * | ptr_of_interest, |
wchar_t * | sym_name, | ||
wchar_t * | file, | ||
int * | line | ||
) |
read and return symbol information for the given address.
NOTE: the PDB implementation is rather slow (~500 us).
ptr_of_interest | address of symbol (e.g. function, variable) |
sym_name | optional out; holds at least DEBUG_SYMBOL_CHARS; receives symbol name returned via debug info. |
file | optional out; holds at least DEBUG_FILE_CHARS; receives base name only (no path; see rationale in wdbg_sym) of source file containing the symbol. |
line | optional out; receives source file line number of symbol. |
note: all of the output parameters are optional; we pass back as much information as is available and desired.
Definition at line 249 of file wdbg_sym.cpp.
|
static |
Definition at line 793 of file wdbg_sym.cpp.
|
static |
Definition at line 724 of file wdbg_sym.cpp.
|
static |
Definition at line 560 of file wdbg_sym.cpp.
|
static |
Definition at line 1676 of file wdbg_sym.cpp.
|
static |
Definition at line 652 of file wdbg_sym.cpp.
Definition at line 593 of file wdbg_sym.cpp.
Definition at line 1628 of file wdbg_sym.cpp.
Definition at line 829 of file wdbg_sym.cpp.
Definition at line 1006 of file wdbg_sym.cpp.
Definition at line 870 of file wdbg_sym.cpp.
Definition at line 1655 of file wdbg_sym.cpp.
Definition at line 1025 of file wdbg_sym.cpp.
Definition at line 1049 of file wdbg_sym.cpp.
Definition at line 1107 of file wdbg_sym.cpp.
Definition at line 1115 of file wdbg_sym.cpp.
Definition at line 1183 of file wdbg_sym.cpp.
Definition at line 1226 of file wdbg_sym.cpp.
Definition at line 1521 of file wdbg_sym.cpp.
Definition at line 1577 of file wdbg_sym.cpp.
Definition at line 1567 of file wdbg_sym.cpp.
Definition at line 1594 of file wdbg_sym.cpp.
|
static |
Definition at line 65 of file wdbg_sym.cpp.
|
static |
Definition at line 513 of file wdbg_sym.cpp.
Definition at line 764 of file wdbg_sym.cpp.
|
static |
Definition at line 775 of file wdbg_sym.cpp.
|
static |
Definition at line 419 of file wdbg_sym.cpp.
|
static |
Definition at line 488 of file wdbg_sym.cpp.
|
static |
Definition at line 465 of file wdbg_sym.cpp.
|
static |
Definition at line 410 of file wdbg_sym.cpp.
|
static |
Definition at line 480 of file wdbg_sym.cpp.
|
static |
Definition at line 134 of file wdbg_sym.cpp.
|
static |
Definition at line 114 of file wdbg_sym.cpp.
|
static |
Definition at line 1151 of file wdbg_sym.cpp.
|
static |
Definition at line 1146 of file wdbg_sym.cpp.
|
static |
Definition at line 187 of file wdbg_sym.cpp.
|
static |
Definition at line 627 of file wdbg_sym.cpp.
|
static |
Definition at line 1644 of file wdbg_sym.cpp.
|
static |
Definition at line 107 of file wdbg_sym.cpp.
|
static |
Definition at line 1443 of file wdbg_sym.cpp.
|
static |
Definition at line 1274 of file wdbg_sym.cpp.
|
static |
Definition at line 1391 of file wdbg_sym.cpp.
|
static |
Definition at line 1411 of file wdbg_sym.cpp.
|
static |
Definition at line 1240 of file wdbg_sym.cpp.
|
static |
Definition at line 1342 of file wdbg_sym.cpp.
|
static |
Definition at line 48 of file wdbg_sym.cpp.
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.
cb | |
cbData | |
context | Processor context from which to start (taken from an exception record or debug_CaptureContext). |
lastFuncToSkip |
Definition at line 311 of file wdbg_sym.cpp.
void wdbg_sym_WriteMinidump | ( | EXCEPTION_POINTERS * | exception_pointers | ) |
Definition at line 1755 of file wdbg_sym.cpp.
WINIT_REGISTER_CRITICAL_INIT | ( | wdbg_sym_Init | ) |
|
static |
|
static |
Definition at line 60 of file wdbg_sym.cpp.
|
static |
Definition at line 63 of file wdbg_sym.cpp.
|
static |
Definition at line 368 of file wdbg_sym.cpp.
|
static |
Definition at line 369 of file wdbg_sym.cpp.
|
static |
Definition at line 1142 of file wdbg_sym.cpp.
|
static |
Definition at line 1144 of file wdbg_sym.cpp.
|
static |
Definition at line 387 of file wdbg_sym.cpp.
|
static |
Definition at line 408 of file wdbg_sym.cpp.
|
static |
Definition at line 391 of file wdbg_sym.cpp.
|
static |
Definition at line 407 of file wdbg_sym.cpp.
|
static |
Definition at line 388 of file wdbg_sym.cpp.
|
static |
Definition at line 1143 of file wdbg_sym.cpp.