diff --git a/include/cpptrace/cpptrace.hpp b/include/cpptrace/cpptrace.hpp index b4bb01f2..b41ad65b 100644 --- a/include/cpptrace/cpptrace.hpp +++ b/include/cpptrace/cpptrace.hpp @@ -147,7 +147,8 @@ namespace cpptrace { }; struct CPPTRACE_EXPORT stacktrace_frame { - frame_ptr address; + frame_ptr raw_address; + frame_ptr object_address; nullable line; nullable column; std::string filename; @@ -155,7 +156,8 @@ namespace cpptrace { bool is_inline; bool operator==(const stacktrace_frame& other) const { - return address == other.address + return raw_address == other.raw_address + && object_address == other.object_address && line == other.line && column == other.column && filename == other.filename diff --git a/include/ctrace/ctrace.h b/include/ctrace/ctrace.h index e9cdffc0..08d748c6 100644 --- a/include/ctrace/ctrace.h +++ b/include/ctrace/ctrace.h @@ -79,7 +79,8 @@ CTRACE_BEGIN_DEFINITIONS }; struct ctrace_stacktrace_frame { - ctrace_frame_ptr address; + ctrace_frame_ptr raw_address; + ctrace_frame_ptr object_address; uint32_t line; uint32_t column; const char* filename; diff --git a/src/cpptrace.cpp b/src/cpptrace.cpp index 11042aad..44ea0b7f 100644 --- a/src/cpptrace.cpp +++ b/src/cpptrace.cpp @@ -120,7 +120,7 @@ namespace cpptrace { << "0x" << std::setw(2 * sizeof(frame_ptr)) << std::setfill('0') - << frame.address + << frame.raw_address << std::dec << std::setfill(' '); if(!frame.symbol.empty()) { @@ -204,7 +204,7 @@ namespace cpptrace { << "0x" << std::setw(2 * sizeof(frame_ptr)) << std::setfill('0') - << frame.address + << frame.raw_address << std::dec << std::setfill(' ') << reset; diff --git a/src/ctrace.cpp b/src/ctrace.cpp index ecf775ee..5307f598 100644 --- a/src/ctrace.cpp +++ b/src/ctrace.cpp @@ -112,7 +112,8 @@ CTRACE_FORMAT_EPILOGUE frames, [] (const cpptrace::stacktrace_frame& frame) -> ctrace_stacktrace_frame { ctrace_stacktrace_frame new_frame; - new_frame.address = frame.address; + new_frame.raw_address = frame.raw_address; + new_frame.object_address = frame.object_address; new_frame.line = frame.line.value_or(invalid_pos); new_frame.column = frame.column.value_or(invalid_pos); new_frame.filename = generate_owning_string(frame.filename).data; @@ -135,7 +136,8 @@ CTRACE_FORMAT_EPILOGUE static constexpr auto null_v = nullable_type::null().raw_value; const ctrace_stacktrace_frame& old_frame = ptrace->frames[i]; cpptrace::stacktrace_frame new_frame; - new_frame.address = old_frame.address; + new_frame.raw_address = old_frame.raw_address; + new_frame.object_address = old_frame.object_address; new_frame.line = nullable_type{is_empty(old_frame.line) ? null_v : old_frame.line}; new_frame.column = nullable_type{is_empty(old_frame.column) ? null_v : old_frame.column}; new_frame.filename = old_frame.filename; @@ -348,7 +350,7 @@ extern "C" { (void)std::fprintf(to, "%s0x%0*llx%s", blue, int(ptr_len), - cpptrace::detail::to_ull(frames[i].address), + cpptrace::detail::to_ull(frames[i].raw_address), reset); } if(!ctrace::is_empty(frames[i].symbol)) { diff --git a/src/symbols/symbols_core.cpp b/src/symbols/symbols_core.cpp index b870cdd4..909028f2 100644 --- a/src/symbols/symbols_core.cpp +++ b/src/symbols/symbols_core.cpp @@ -63,7 +63,7 @@ namespace detail { std::vector addresses; for(const auto& frame : vec) { if(frame.symbol.empty() || frame.filename.empty()) { - addresses.push_back(frame.address); + addresses.push_back(frame.raw_address); } } std::vector new_frames = resolver(addresses); diff --git a/src/symbols/symbols_with_libdwarf.cpp b/src/symbols/symbols_with_libdwarf.cpp index 1c8151a1..3cca5653 100644 --- a/src/symbols/symbols_with_libdwarf.cpp +++ b/src/symbols/symbols_with_libdwarf.cpp @@ -406,6 +406,7 @@ namespace libdwarf { const auto col = die.get_unsigned_attribute(DW_AT_call_column); inlines.push_back(stacktrace_frame{ 0, + 0, // TODO: Could put an object address here... {static_cast(line.value_or(0))}, {static_cast(col.value_or(0))}, file, @@ -901,6 +902,7 @@ namespace libdwarf { return { { frame_info.raw_address, + frame_info.object_address, nullable::null(), nullable::null(), frame_info.object_path, @@ -912,7 +914,8 @@ namespace libdwarf { } stacktrace_frame frame = null_frame; frame.filename = frame_info.object_path; - frame.address = frame_info.raw_address; + frame.raw_address = frame_info.raw_address; + frame.object_address = frame_info.object_address; if(trace_dwarf) { std::fprintf( stderr, @@ -941,6 +944,7 @@ namespace libdwarf { return { { frame_info.raw_address, + frame_info.object_address, nullable::null(), nullable::null(), frame_info.object_path, @@ -1145,7 +1149,8 @@ namespace libdwarf { try { frame = resolver->resolve_frame(dlframe); } catch(...) { - frame.frame.address = dlframe.raw_address; + frame.frame.raw_address = dlframe.raw_address; + frame.frame.object_address = dlframe.object_address; frame.frame.filename = dlframe.object_path; if(!should_absorb_trace_exceptions()) { throw; @@ -1166,6 +1171,7 @@ namespace libdwarf { frame = { { dlframe.raw_address, + dlframe.object_address, nullable::null(), nullable::null(), dlframe.object_path, diff --git a/src/utils/common.hpp b/src/utils/common.hpp index 5f79f599..c7cad62b 100644 --- a/src/utils/common.hpp +++ b/src/utils/common.hpp @@ -55,7 +55,15 @@ namespace detail { return str; } - static const stacktrace_frame null_frame {0, nullable::null(), nullable::null(), "", "", false}; + static const stacktrace_frame null_frame { + 0, + 0, + nullable::null(), + nullable::null(), + "", + "", + false + }; bool should_absorb_trace_exceptions(); bool should_resolve_inlined_calls();