Really fix it this time

This commit is contained in:
Jeremy 2023-11-19 23:07:41 -06:00
parent f4237c75df
commit ac7db48cef
No known key found for this signature in database
GPG Key ID: B4C8300FEC395042
2 changed files with 7 additions and 5 deletions

View File

@ -56,8 +56,8 @@ namespace cpptrace {
struct CPPTRACE_EXPORT object_frame {
std::string obj_path;
std::string symbol;
frame_ptr raw_address = 0;
frame_ptr obj_address = 0;
frame_ptr raw_address;
frame_ptr obj_address;
};
struct CPPTRACE_EXPORT object_trace {
@ -193,8 +193,8 @@ namespace cpptrace {
std::size_t max_depth
);
struct CPPTRACE_EXPORT minimal_object_frame {
frame_ptr raw_address = 0;
frame_ptr address_relative_to_object_base_in_memory = 0;
frame_ptr raw_address;
frame_ptr address_relative_to_object_base_in_memory;
char object_path[CPPTRACE_PATH_MAX + 1];
// To be called outside a signal handler. Not signal safe.
object_frame resolve() const;

View File

@ -70,6 +70,7 @@ namespace detail {
Dl_info info;
object_frame frame;
frame.raw_address = addr;
frame.obj_address = 0;
if(dladdr(reinterpret_cast<void*>(addr), &info)) { // thread safe
// dli_sname and dli_saddr are only present with -rdynamic, sname will be included
// but we don't really need dli_saddr
@ -129,6 +130,7 @@ namespace detail {
for(const frame_ptr addr : addrs) {
object_frame frame;
frame.raw_address = addr;
frame.obj_address = 0;
HMODULE handle;
// Multithread safe as long as another thread doesn't come along and free the module
if(GetModuleHandleExA(
@ -150,7 +152,7 @@ namespace detail {
#endif
inline object_frame resolve_minimal_object_frame(const minimal_object_frame& frame) {
return object_frame {
return {
frame.object_path,
"",
frame.raw_address,