Skip to content

Commit 0a9f93c

Browse files
committed
Use GetModuleNames to determine the full module path for msvc implementation
1 parent 22982db commit 0a9f93c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

include/boost/stacktrace/detail/frame_msvc.ipp

+51
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,57 @@ public:
247247
const std::size_t delimiter = result.find_first_of('!');
248248
if (module_name) {
249249
*module_name = result.substr(0, delimiter);
250+
if (!module_name->empty()) {
251+
ULONG64 base = 0;
252+
res = (S_OK == idebug_->GetModuleByOffset(
253+
offset,
254+
0,
255+
nullptr,
256+
&base
257+
));
258+
259+
if (res) {
260+
name[0] = '\0';
261+
size = 0;
262+
res = (S_OK == idebug_->GetModuleNames(
263+
DEBUG_ANY_ID,
264+
base,
265+
name,
266+
sizeof(name),
267+
&size,
268+
nullptr,
269+
0,
270+
nullptr,
271+
nullptr,
272+
0,
273+
nullptr
274+
));
275+
}
276+
277+
if (!res && size != 0)
278+
{
279+
std::string module_path(size, char());
280+
res = (S_OK == idebug_->GetModuleNames(
281+
DEBUG_ANY_ID,
282+
base,
283+
&module_path[0],
284+
static_cast<ULONG>(module_path.size()),
285+
&size,
286+
nullptr,
287+
0,
288+
nullptr,
289+
nullptr,
290+
0,
291+
nullptr
292+
));
293+
if (res && size > 1) {
294+
module_name->assign(module_path, size - 1);
295+
}
296+
}
297+
else if (res && size > 1) {
298+
module_name->assign(name, size - 1);
299+
}
300+
}
250301
}
251302

252303
if (delimiter == std::string::npos) {

0 commit comments

Comments
 (0)