Add GetLastError() and switch to unordered_map
This commit is contained in:
parent
efc63cb49f
commit
c80d04fe52
@ -7,7 +7,7 @@
|
|||||||
#include "utils/error.hpp"
|
#include "utils/error.hpp"
|
||||||
#include "utils/microfmt.hpp"
|
#include "utils/microfmt.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@ -38,7 +38,7 @@ namespace detail {
|
|||||||
}
|
}
|
||||||
HANDLE duplicated_handle = nullptr;
|
HANDLE duplicated_handle = nullptr;
|
||||||
if (!DuplicateHandle(proc, proc, proc, &duplicated_handle , 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
if (!DuplicateHandle(proc, proc, proc, &duplicated_handle , 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
||||||
throw internal_error("DuplicateHandle failed");
|
throw internal_error("DuplicateHandle failed {}", GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!SymInitialize(duplicated_handle , NULL, TRUE)) {
|
if(!SymInitialize(duplicated_handle , NULL, TRUE)) {
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
#ifndef DBGHELP_SYMINIT_MANAGER_HPP
|
#ifndef DBGHELP_SYMINIT_MANAGER_HPP
|
||||||
#define DBGHELP_SYMINIT_MANAGER_HPP
|
#define DBGHELP_SYMINIT_MANAGER_HPP
|
||||||
|
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace cpptrace {
|
namespace cpptrace {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
struct dbghelp_syminit_manager {
|
struct dbghelp_syminit_manager {
|
||||||
// The set below contains Windows `HANDLE` objects, `void*` is used to avoid
|
// The set below contains Windows `HANDLE` objects, `void*` is used to avoid
|
||||||
// including the (expensive) Windows header here
|
// including the (expensive) Windows header here
|
||||||
std::map<void*, void*> cache;
|
std::unordered_map<void*, void*> cache;
|
||||||
|
|
||||||
~dbghelp_syminit_manager();
|
~dbghelp_syminit_manager();
|
||||||
void* init(void* proc);
|
void* init(void* proc);
|
||||||
|
|||||||
@ -433,10 +433,10 @@ namespace dbghelp {
|
|||||||
duplicated_handle = get_syminit_manager().init(proc);
|
duplicated_handle = get_syminit_manager().init(proc);
|
||||||
} else {
|
} else {
|
||||||
if (!DuplicateHandle(proc, proc, proc, &duplicated_handle , 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
if (!DuplicateHandle(proc, proc, proc, &duplicated_handle , 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
||||||
throw internal_error("DuplicateHandle failed");
|
throw internal_error("DuplicateHandle failed {}", GetLastError());
|
||||||
}
|
}
|
||||||
if(!SymInitialize(duplicated_handle , NULL, TRUE)) {
|
if(!SymInitialize(duplicated_handle , NULL, TRUE)) {
|
||||||
throw internal_error("SymInitialize failed");
|
throw internal_error("SymInitialize failed {}", GetLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(const auto frame : frames) {
|
for(const auto frame : frames) {
|
||||||
|
|||||||
@ -110,10 +110,10 @@ namespace detail {
|
|||||||
duplicated_handle = get_syminit_manager().init(proc);
|
duplicated_handle = get_syminit_manager().init(proc);
|
||||||
} else {
|
} else {
|
||||||
if (!DuplicateHandle(proc, proc, proc, &duplicated_handle , 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
if (!DuplicateHandle(proc, proc, proc, &duplicated_handle , 0, FALSE, DUPLICATE_SAME_ACCESS)) {
|
||||||
throw internal_error("DuplicateHandle failed");
|
throw internal_error("DuplicateHandle failed{}", GetLastError());
|
||||||
}
|
}
|
||||||
if(!SymInitialize(duplicated_handle , NULL, TRUE)) {
|
if(!SymInitialize(duplicated_handle , NULL, TRUE)) {
|
||||||
throw internal_error("SymInitialize failed");
|
throw internal_error("SymInitialize failed{}", GetLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(trace.size() < max_depth) {
|
while(trace.size() < max_depth) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user