Skip to content

Rust symbols are inconveniently shortened #5439

@bobrik

Description

@bobrik

Here's how parca resolves a symbol

$ git diff
diff --git a/pkg/symbol/elfutils/debuginfofile.go b/pkg/symbol/elfutils/debuginfofile.go
index 4a9ab2cf2..1c5a81aa9 100644
--- a/pkg/symbol/elfutils/debuginfofile.go
+++ b/pkg/symbol/elfutils/debuginfofile.go
@@ -102,6 +102,7 @@ func (f *debugInfoFile) SourceLines(addr uint64) ([]profile.LocationLine, error)
        }

        file, line := findLineInfo(f.lineEntries[cu.Offset], tr.Ranges)
+       fmt.Printf("addr = 0x%x, name = %s, file = %s, line = %d\n", addr, name, file, line)
        lines = append(lines, profile.LocationLine{
                Line: line,
                Function: f.demangler.Demangle(&pb.Function{
addr = 0x17e976, name = small_slot_len, file = ?, line = 0

Compare this to addr2line from elfutils:

$ eu-addr2line -e ./target/debug/weird-unwind -S 0x17e976
_ZN14regex_automata4util8captures14GroupInfoInner14small_slot_len17h3554d4e8237ec643E+0x16
/home/ivan/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/regex-automata-0.4.9/src/util/captures.rs:2323:9

You couldn't even tell it was something about regexps, but it is:

$ echo _ZN14regex_automata4util8captures14GroupInfoInner14small_slot_len17h3554d4e8237ec643E+0x16 | c++filt
regex_automata::util::captures::GroupInfoInner::small_slot_len::h3554d4e8237ec643+0x16

Compare the flamegraph view in Parca (new and build are very opaque!):

Image

To what perf manages to do:

Image

Interesting to note that symbols come demangled before demangler runs, for example:

addr = 0x3659e6, name = min<core::iter::adapters::map::Map<core::slice::iter::Iter<regex_syntax::hir::literal::Literal>, regex_syntax::hir::literal::{impl#4}::min_literal_len::{closure_env#0}>>, file = /rustc/48a426eca9df23b24b3559e545cf88dee61d4de9/library/core/src/iter/traits/iterator.rs, line = 3143

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions