Skip to content

Commit

Permalink
Use GetModuleNames to determine the full module path for msvc imple…
Browse files Browse the repository at this point in the history
…mentation
  • Loading branch information
Dani-Hub authored and apolukhin committed Dec 21, 2024
1 parent 22982db commit 8c4e503
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions include/boost/stacktrace/detail/frame_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,57 @@ public:
const std::size_t delimiter = result.find_first_of('!');
if (module_name) {
*module_name = result.substr(0, delimiter);
if (!module_name->empty()) {
ULONG64 base = 0;
res = (S_OK == idebug_->GetModuleByOffset(
offset,
0,
nullptr,
&base
));

if (res) {
name[0] = '\0';
size = 0;
res = (S_OK == idebug_->GetModuleNames(
DEBUG_ANY_ID,
base,
name,
sizeof(name),
&size,
nullptr,
0,
nullptr,
nullptr,
0,
nullptr
));
}

if (!res && size != 0)
{
std::string module_path(size, char());
res = (S_OK == idebug_->GetModuleNames(
DEBUG_ANY_ID,
base,
&module_path[0],
static_cast<ULONG>(module_path.size()),
&size,
nullptr,
0,
nullptr,
nullptr,
0,
nullptr
));
if (res && size > 1) {
module_name->assign(module_path, size - 1);
}
}
else if (res && size > 1) {
module_name->assign(name, size - 1);
}
}
}

if (delimiter == std::string::npos) {
Expand Down

0 comments on commit 8c4e503

Please sign in to comment.