Skip to content

Symbol demangling#74

Merged
nbaksalyar merged 7 commits into
headcrab-rs:masterfrom
Stupremee:demangle-symbols
Aug 6, 2020
Merged

Symbol demangling#74
nbaksalyar merged 7 commits into
headcrab-rs:masterfrom
Stupremee:demangle-symbols

Conversation

@Stupremee

Copy link
Copy Markdown
Contributor

I'm not sure if this is the approach you wanted, but I think this should work.

Resolves #71

@Stupremee

Copy link
Copy Markdown
Contributor Author

There's definitely something not working. Please dont merge

@nbaksalyar

Copy link
Copy Markdown
Member

Thanks, this is great! I think we can also change the list of expected names in tests/unwind_stack.rs to verify the demangling routines work correctly. Do you want to do this as a part of this pull request?

@Stupremee

Copy link
Copy Markdown
Contributor Author

Yes that's how I saw that my code is broken

@bjorn3

bjorn3 commented Aug 5, 2020

Copy link
Copy Markdown
Contributor

I just remembered that addr2line already has demangling support. This also handles inlined functions. https://docs.rs/addr2line/0.13.0/addr2line/struct.FunctionName.html#method.demangle

Directly using rustc-demangle is useful for when there is no DWARF debuginfo though.

Comment thread tests/unwind_stack.rs Outdated
"_ZN3std2rt19lang_start_internal17h",
"hello::main::",
"std::rt::lang_start::{{closure}}::",
"std::rt::lang_start_internal::",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think get_address_symbol_name should not demangle the name. Instead there could be an extra method get_address_demangled_name.

@nbaksalyar

Copy link
Copy Markdown
Member

addr2line already has demangling support

Yeah, it also seems to be automatically choosing between the C++ & Rust mangling schemes depending on DWARF lang param, which is a nice feature if we want to support more langs in the future. So we can probably use addr2line as the default demangling function and resort to the direct rustc-demangle when there's no DWARF available?

@Stupremee

Copy link
Copy Markdown
Contributor Author

I just remembered that addr2line already has demangling support.

That sounds good. Should I wait for #54 or add it here as well?

@bjorn3

bjorn3 commented Aug 5, 2020

Copy link
Copy Markdown
Contributor

Please wait, it conflicts with #54.

@nbaksalyar

Copy link
Copy Markdown
Member

#54 is merged now 👍

Comment thread src/symbol/sym.rs Outdated

@nbaksalyar nbaksalyar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment thread src/symbol/sym.rs Outdated
Comment thread src/symbol/mod.rs
Comment thread src/symbol/sym.rs
@bjorn3

bjorn3 commented Aug 5, 2020

Copy link
Copy Markdown
Contributor

Can you change

.get_address_symbol_name(func)
to use the demangled name?

@nbaksalyar nbaksalyar merged commit c0ce589 into headcrab-rs:master Aug 6, 2020
@nbaksalyar

Copy link
Copy Markdown
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Demangle symbol names

3 participants