Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show more information about module in Windows #342

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion backward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3633,6 +3633,10 @@ template <> class TraceResolverImpl<system_tag::windows_tag>
image_type = h->FileHeader.Machine;
}

~TraceResolverImpl() {
SymCleanup(GetCurrentProcess());
}

static const int max_sym_len = 255;
struct symbol_t {
SYMBOL_INFO sym;
Expand All @@ -3644,6 +3648,15 @@ template <> class TraceResolverImpl<system_tag::windows_tag>
ResolvedTrace resolve(ResolvedTrace t) override {
HANDLE process = GetCurrentProcess();

std::string mod_info_str = "";
HMODULE hmod = (HMODULE)SymGetModuleBase64(process, (DWORD64)t.addr);
if(hmod) {
const auto mod_info = get_mod_info(process)(hmod);
std::stringstream stream;
stream << mod_info.module_name << " (base 0x" << std::hex << (DWORD64)mod_info.base_address << ")";
mod_info_str = stream.str();
}

char name[256];

memset(&sym, 0, sizeof(sym));
Expand Down Expand Up @@ -3678,7 +3691,7 @@ template <> class TraceResolverImpl<system_tag::windows_tag>
}

t.source.function = name;
t.object_filename = "";
t.object_filename = mod_info_str;
t.object_function = name;

return t;
Expand Down