Attaching sources to a binary dylib in Xcode

假如想象 提交于 2019-11-29 06:03:25

问题


I've a framework with a dylib in my iOS app which was compiled on another machine. I checked out the sources on my machine and tried instructing lldb to map the source code path using:

settings set target.source-map /source/code/path/in/dylib/prefix /source/code/path/on/my/machine/prefix

To no avail, still seeing assembly.

Note #1: the dylib was compiled from C++ code in the same version of Xcode.

Note #2: I'm used nm -pa /path/to/dylib to determine whether file paths are embedded into the debug info, and they are, lldb doesn't play along for some reason.

Thanks

UPDATE

I've followed Jim Ingham's answer below and created a script that automates this, the script is available as a gist link in this article I wrote: https://medium.com/@maxraskin/background-1b4b6a9c65be


回答1:


To debug code built on one machine but debugged on another you have to build a dSYM and have that available on the machine on which you are debugging. If you haven't done that, nothing is going to work.

Next thing to check is that lldb is picking up the dSYM. This page has some description of how this process works:

http://lldb.llvm.org/symbols.html

but if all else fails, you can use the add-dsym command to add it by hand.

If that still hasn't fixed your problem, then pick some symbol in your dylib, and do:

(lldb) image lookup -vn <SYMBOL_NAME>

or alternately find some address in the loaded dylib and do:

(lldb) image lookup -va <ADDRESS>

If lldb found the dSYM and the debug info is correct, one of the lines of output should be the entry for the "Compile Unit". That is what the debug info says the path to the source file is. The appropriate base of that path is what you should use in target.source-map. If you don't see that entry, then the debug information for that compilation unit is getting lost somehow.

If all those things look good and lldb still isn't seeing the source files, then you are likely hitting a bug, in which case please file a bug with http://bugreporter.apple.com.



来源:https://stackoverflow.com/questions/41698021/attaching-sources-to-a-binary-dylib-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!