diff options
Diffstat (limited to '')
-rw-r--r-- | src/dbghelp.cpp | 32 | ||||
-rw-r--r-- | src/repo.cpp | 5 |
2 files changed, 32 insertions, 5 deletions
diff --git a/src/dbghelp.cpp b/src/dbghelp.cpp index 30829d4..0a78e4d 100644 --- a/src/dbghelp.cpp +++ b/src/dbghelp.cpp @@ -11,6 +11,7 @@ #include <DbgHelp.h> #include <cstddef> +#include <cstring> #include <stdexcept> #include <string> @@ -19,14 +20,17 @@ namespace pdb { namespace { - void enable_debug_output() + void set_dbghelp_options() { - SymSetOptions(SymGetOptions() | SYMOPT_DEBUG | SYMOPT_UNDNAME); + SymSetOptions(SymGetOptions() + | SYMOPT_DEBUG + | SYMOPT_LOAD_LINES + | SYMOPT_UNDNAME); } void initialize(HANDLE id) { - enable_debug_output(); + set_dbghelp_options(); if (!SymInitialize(id, NULL, FALSE)) throw error::windows(GetLastError()); @@ -129,14 +133,14 @@ namespace pdb throw error::windows(GetLastError()); } - SymbolInfo DbgHelp::resolve_symbol(Address online) const + SymbolInfo DbgHelp::resolve_symbol(Address offline) const { Address displacement = 0; SymbolInfo symbol; if (!SymFromAddr( id, - online, + offline, &displacement, &static_cast<SYMBOL_INFO&>(symbol))) throw error::windows(GetLastError()); @@ -157,4 +161,22 @@ namespace pdb return symbol; } + + LineInfo DbgHelp::resolve_line(Address offline) const + { + IMAGEHLP_LINE64 raw; + std::memset(&raw, 0, sizeof(raw)); + raw.SizeOfStruct = sizeof(raw); + + DWORD displacement = 0; + + if (!SymGetLineFromAddr64( + id, + offline, + &displacement, + &raw)) + throw error::windows(GetLastError()); + + return LineInfo{raw}; + } } diff --git a/src/repo.cpp b/src/repo.cpp index edd62d5..7a19c83 100644 --- a/src/repo.cpp +++ b/src/repo.cpp @@ -155,6 +155,11 @@ namespace pdb return symbol_from_buffer(dbghelp.resolve_symbol(name)); } + LineInfo Repo::resolve_line(Address online) const + { + return dbghelp.resolve_line(address_online_to_offline(online)); + } + const Module& Repo::module_with_online_base(Address base) const { return lookup_module(online_bases, base); |