Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Symbol address #1

Open
mbentin opened this issue Jan 15, 2025 · 7 comments
Open

Extract Symbol address #1

mbentin opened this issue Jan 15, 2025 · 7 comments

Comments

@mbentin
Copy link

mbentin commented Jan 15, 2025

Is it possible to extract the symbol address from the DWARF?
It could be a really useful function for symbolicating.

@mattmassicotte
Copy link
Contributor

Yes, it absolutely is. I have used CoreSymbolication do that in the past.

@mbentin
Copy link
Author

mbentin commented Jan 15, 2025

@mattmassicotte Sorry for the dumb question, but is it visible in the swift wrapper?
Because in https://github.com/ChimeHQ/CoreSymbolication/blob/main/Sources/SwiftCoreSymbolication/Symbol.swift I cannot locate any address. And even in the C Headers I am not so sure if it is there?

@mattmassicotte
Copy link
Contributor

You should be able to create a Symbolicator type by pointing it at the dwarf file within a dSYM and have it work. The Symbol type just wraps up the information about a particular symbol entry, and is independent of where the symbolic information comes from.

But you are bringing up a good point that perhaps some more documentation would be useful...

@mbentin
Copy link
Author

mbentin commented Jan 15, 2025

My understanding was that when I get a crash report, in my case a MXCrashDiagnostic, I just read the load address "address", then I get the address of the symbol from "offsetIntoBinaryTextSegment".
Atos does the thing quite good, calculates the ASLR slide and search automagically in the dSYM for the symbol.
With CoreSymbolication, I am not so sure how I can do that. I can calculate the address I need to look for in the DWARF, but how do I match it?

So far so good, I loaded the dwarf in Symbolicator, going through, but there is no address?

for symbolicator in symbolicators {
         for owner in symbolicator.symbolOwners {
                owner.enumerateSymbols { symbol in
                       symbol.enumerateSoureInfo { info in
                            print("\(owner.baseAddress):\(symbol.name) -- \(info.sanitizedFilePath):\(info.lineNumber)")
                        }
               }
        }
}

And with a dwarfdump --arch arm64 myDSYMFile I also get the addresses inside the DWARF.
That's why I am a bit lost ^^

@mattmassicotte
Copy link
Contributor

Ahhh yes, you need to consult the info.range, I believe! If you are looking for the range of the entire symbol, it is possible the library supports that, but we'd have to do some digging.

@mbentin
Copy link
Author

mbentin commented Jan 17, 2025

Great thank you! I did not know it could be a range. After reviewing the DWARF doc it's clear https://dwarfstd.org/doc/DWARF5.pdf, page 51:

The base address of the scope for any of the debugging information entries listed above is given by either the DW_AT_low_pc attribute or the first address in the first range entry in the list of ranges given by the DW_AT_ranges attribute. If there is no such attribute, the base address is undefined.

So the first address of the range is the DW_AT_low_pc aka the address of the symbol

@mattmassicotte
Copy link
Contributor

Glad you got it figured out!

I'm going to keep this issue open to cover adding a little documentation on how to use this.

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

No branches or pull requests

2 participants