Is it possible to symbolicate C++ code?
Asked Answered
L

3

6

I have been running into trouble recently trying to symbolicate a crash log of an iOS app. For some reason the UUID of the dSYM was not indexed in Spotlight. After some manual search and a healthy dose of command line incantations, I managed to symbolicate partially the crash log.

At first I thought the dSYM might be incomplete or something like that, but then I realized that the method calls missing were the ones occurring in C++ code: this project is an Objective-C app that calls into C++ libraries (via Objective-C++) which call back to Objective-C code (again, via Objective-C++ code). The calls that I'm missing are, specifically, the ones that happen in C++ land.

So, my question is: is there some way that the symbolication process can resolve the function calls of C++ code? Which special options do I need to set, if any?

Lunisolar answered 20/6, 2012 at 22:23 Comment(6)
Does it simply leave the addresses or does it give you something like _ZN7...?Acth
nope, they are not name mangled functions if you refer to that. It's a base address and an offset: 14 MyApp 0x001001bc 0xfe000 + 8636 15 MyApp 0x00100174 0xfe000 + 8564Lunisolar
if you lldb your app, can you disassemble any of your C++ methods by name? Do you have a static library binary or are you compiling everything in your project?Friedly
I have some static libs, but the part where it is crashing is my code. It crashes in some Obj-C code (that I can symbolicate correctly) called by Obj-C++ (and that's the part that I'd like symbolicated)Lunisolar
symbolize. symbolicate ... sounds like you want to do something very unkind.Efficacious
@Efficacious that's how the existing literature refers to it, however strange sounds to you; and thus is how I refer to it as well.Lunisolar
A
0

One useful program that comes with the apple sdk is atos (address to symbol). Basically, here's what you want to do:

atos -o myExecutable -arch armv7 0x(address here)

It should print out the name of the symbol at that address.

Acth answered 24/6, 2012 at 16:49 Comment(2)
That works for ObjC. For C++, I get something like: 0x00261588 (in MyApp) + 465932Lunisolar
LLVM 3.1 which, as far as I know, is clangLunisolar
S
0

I'm not well versed in Objective-C, but I'd make sure that the C++ code is being compiled with symbols. Particularly, did you make sure to include -rdynamic and/or -g when compiling the C++ code?

Superpower answered 24/6, 2012 at 16:54 Comment(4)
Those look like flags for gcc. Do you know how to accomplish the same in LLVM?Lunisolar
Apple uses LLVM as the backend for gcc and clang. clang basically takes the same flags as gcc. Make sure that all of your code is compiled with the debug level turned up to 3. Use -g3. You may also want to disable optimization (-O0).Narrative
@Narrative the optimization level has nothing to do -AFAIK- with symbolication after a crash, that'd rather be stripping. There's no -g3 in clang, only -gLunisolar
You're right about the -g. Funny that it never complains about my old habbits... I've found that optimization often affects the ability of the debugger "symbolicate" the stack, especially in C++ code. At higher levels of optimization, LLVM will often inline (and then further optimize) code. All is good until you need a stack trace, and gdb/lldb can't associate the highly-inlined code with its actual function.Narrative
R
0

try

dwarfdump --lookup=0xYOUR_ADRESS YOUR_DSYM_FILE

you will have to look up each adress manually ( or write a script to do this ) but if the symbols are ok ( your dSym file is bigger than say 20MB) this will do the job .

Rosecan answered 18/10, 2012 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.