Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match precompiled static library's debugging symbols to source code with Xcode 5?

I have to compile FFmpeg for iOS using an external build script, but when I am debugging I see assembler if I delve too deep into libavformat library functions:

0x109a73:  cmpl   $0, 1192(%ebp)
0x109a7a:  jns    0x109a86                  ; mov_write_header + 198 at movenc.c:3539
0x109a7c:  movl   $1, 1192(%ebp)
0x109a86:  movl   16(%ebp), %eax
0x109a89:  cmpl   $0, 84(%eax)
0x109a8d:  movl   %edx, %ecx
0x109a8f:  jne    0x109ad9                  ; mov_write_header + 281 at movenc.c:3548
0x109a91:  testb  $2, 48(%ecx)
0x109a95:  jne    0x109ac1                  ; mov_write_header + 257 at movenc.c:3541

There are clear debugging symbols left behind which would lead me to believe that there should be some way to tell Xcode the location of this source code to allow easier debugging.

Is this even possible?

edit: I found a related question here No symbols/source for external library in Xcode 4

So when I run xcrun dwarfdump libavformat.a | grep "\.c" I get a bunch of results like this:

AT_decl_file( "libavformat/movenc.c" )

So I tried putting the relevant source files in folders relative to both the .a file and my .xcodeproj file, but neither of those methods worked. Full source code is available here: https://github.com/openwatch/livestreamer-ios

edit2: I found another question about how to set the source mapping for lldb but I'm not quite sure what to do... LLDB equivalent of gdb "directory" command for specifying source search path?

It seems like I might need to do

(lldb) settings set target.source-map libavformat/movenc.c /path/to/libavformat/movenc.c 

for every file I need?

like image 503
Chris Ballinger Avatar asked Sep 19 '13 19:09

Chris Ballinger


1 Answers

So it appears that the issue is that I was compiling libavcodec.a, libavformat.a, etc into a single static library in my FFmpegWrapper project (libFFmpegWrapper.a), which I was then including as a static library in the containing project called LiveStreamer. Moving the .a files and adding the source files (not added to the build target) to the LiveStreamer project fixed the issue.

If anyone runs into this in the future, feel free to drop me a line because I was struggling with this for days.

like image 119
Chris Ballinger Avatar answered Nov 13 '22 12:11

Chris Ballinger