Skip to content

Incorrect line numbers with the offline symbol resolver #1354

Description

@ariel-miculas

I'm instrumenting rust code (using https://docs.rs/tracy-client/latest/tracy_client/ and setting TRACY_SYMBOL_OFFLINE_RESOLVE=1) and I noticed that the line numbers don't seem quite right. For example, a symbol was showing a line number containing the closing } delimiter.

I'm using https://docs.rs/addr2line/latest/addr2line/ and I checked that it returns the same line (containing }) for that specific offset.
For the symbol resolution I'm using
./update/build/tracy-update -r <input.tracy> <output.tracy>

Claude suggests subtracting 1 from symbol offset, the reasoning being that the symbol points to the return address so we need to get back to the instruction that performed the call:

diff --git a/update/src/OfflineSymbolResolverAddr2Line.cpp b/update/src/OfflineSymbolResolverAddr2Line.cpp
index e8809243..1c92d2e4 100644
--- a/update/src/OfflineSymbolResolverAddr2Line.cpp
+++ b/update/src/OfflineSymbolResolverAddr2Line.cpp
@@ -97,7 +97,7 @@ public:
             for( ; entryIdx < batchEndIdx; entryIdx++ )
             {
                 const FrameEntry& entry = inputEntryList[entryIdx];
-                ss << " 0x" << std::hex << entry.symbolOffset;
+                ss << " 0x" << std::hex << (entry.symbolOffset - 1);
             }

             std::string resultStr = ExecShellCommand( ss.str().c_str() );

gdb does subtract 1 in get_frame_address_in_block, so it might be a plausible explanation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions