From 4f94f20d4159c3708d74079ba7760b890950da7c Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sat, 7 Sep 2024 12:02:52 -0500 Subject: [PATCH] Fix computation of object address for safe object frames. I forgot to do this as part of a528aa8e0b6fbc8bb7ba2b81889509dd605b4d09, also related to #104 --- include/cpptrace/cpptrace.hpp | 4 +++- src/binary/object.cpp | 6 +----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/cpptrace/cpptrace.hpp b/include/cpptrace/cpptrace.hpp index 5e66418..667510a 100644 --- a/include/cpptrace/cpptrace.hpp +++ b/include/cpptrace/cpptrace.hpp @@ -235,7 +235,9 @@ namespace cpptrace { ); struct CPPTRACE_EXPORT safe_object_frame { frame_ptr raw_address; - frame_ptr address_relative_to_object_start; // base must still be added + // This ends up being the real object address. It was named at a time when I thought the object base address + // still needed to be added in + frame_ptr address_relative_to_object_start; char object_path[CPPTRACE_PATH_MAX + 1]; // To be called outside a signal handler. Not signal safe. object_frame resolve() const; diff --git a/src/binary/object.cpp b/src/binary/object.cpp index caf6589..d084957 100644 --- a/src/binary/object.cpp +++ b/src/binary/object.cpp @@ -169,13 +169,9 @@ namespace detail { "" }; } - auto base = get_module_image_base(frame.object_path); - if(base.is_error()) { - throw base.unwrap_error(); // This throw is intentional - } return { frame.raw_address, - frame.address_relative_to_object_start + base.unwrap_value(), + frame.address_relative_to_object_start, std::move(object_path) }; }