0

I'm building my project on one computer on Xcode/clang environment, and i'd like to run it under lldb debugger on another station without copying the source code, only the executables, and the symbol files.

I've copied all dSYM directories, so that lldb debugger could identify the symbols I need and present the real function (currently I get function names like ___lldb_unnamed_function532 upon backtrace command)

I tried using the command

settings set target.source_map /source_dir /target_dir

Where target_dir represents the path where i placed all dSYM dirs, and source_dir represents the path of the original parent directory of all the dSYM dirs.

Unfortunately, it doesn't work unless the source code reside on /target_dir.

Where did i go wrong?

Ok, so I've found out that when i copy the dSYM dir to the same location of the executables, so lldb manage to decipher the symbols. is there any way to "tell" lldb for another location?

abligh
  • 24,573
  • 4
  • 47
  • 84
Zohar81
  • 4,554
  • 5
  • 29
  • 82
  • I think that you should use this DBGFileMappedPaths: http://lldb.llvm.org/symbols.html – terence hill Nov 05 '15 at 11:42
  • @terencehill, it seems like what i need. However, i couldn't find the uuid file that maps the dSYM folders. do you know how to generate this file ? it should be under ~/Library/SymbolCache/dsyms/uuids but i don't have SymbolCache folder – Zohar81 Nov 05 '15 at 12:16
  • I don't but this post http://stackoverflow.com/questions/32506103/lldb-add-symbols-file says to use the command: xcrun dwarfdump --uuid to print the uuid for the executable – terence hill Nov 05 '15 at 13:16
  • I think that you can choose where to place the uuids, the folder ~/Library/SymbolCache/dsyms/uuids is just an example. I'm trying to do it ... – terence hill Nov 05 '15 at 13:47
  • Why not make it simple on your self. You have copied everything except the source (and eventually you will have to modify the source to fix any problems found during debugging, so why not copy the source also? There is also the consideration of: will the remote machine allow your local machine to access the source code? – user3629249 Nov 05 '15 at 14:31

1 Answers1

5

To specify a different path for dSYM you can do the following steps:

First generate the UUID for the executable using the following command:

xcrun dwarfdump --uuid path-to-executable

Then make the directory by splitting the first 20 hex digits into 4 character chunks and creating a tree of directories: each subsequent directory is created inside the previous one. Then create a symlink whose name is the last 12 hex digits in the deepest directory. For example if the UUID generated is: 23516BE4-29BE-350C-91C9-F36E7999F0F1

then make the Folders: 2351/6BE4/29BE/350C/91C9/

and the Symlink: F36E7999F0F1

The symlinks value is a full path to the mach-o files inside the dSYM bundle which contains the DWARF. If the dSYM is in source/foo.dSYM/Contents/Resources/DWARF/foo, then the link must be the full path to source/foo.dSYM/Contents/Resources/DWARF/foo (see the example below).

The last part is to tell DebugSymbols to check this UUID file map cache using:

% defaults write com.apple.DebugSymbols DBGFileMappedPaths path-to-your uuids tree

For example you can put the directories you have created under ~/Library/SymbolCache/dsyms/uuids/ (or wherever you want) so that the complete path to your final link will be: ~/Library/SymbolCache/dsyms/uuids/2351/6BE4/29BE/350C/91C9/F36E7999F0F1

And the command:

% defaults write com.apple.DebugSymbols DBGFileMappedPaths ~/Library/SymbolCache/dsyms/uuids/

Then check it with:

defaults read com.apple.DebugSymbols DBGFileMappedPaths

source: http://lldb.llvm.org/symbols.html, LLDB: add symbols file?

I tried it on my MAC OS X:

xcrun dwarfdump --uuid ./a.out

UUID: 7C9D0D55-3882-3F1B-99CA-446AFF4B5D0E (x86_64) ./a.out

mkdir PAPERINO
mv a.out.dSYM/ PAPERINO/

mkdir -p ~/Library/SymbolCache/dsyms/uuids/
mkdir -p ~/Library/SymbolCache/dsyms/uuids/7C9D0/0D55/3882/3F1B/99CA
cd ~/Library/SymbolCache/dsyms/uuids/7C9D0/0D55/3882/3F1B/99CA/

ln -s ../../../<my path>/PAPERINO/a.out.dSYM/Contents/Resources/DWARF/a.out 446AFF4B5D0E

And finally I was able to list the source in lldb:

lldb ./a.out 
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) source list
   6    {
   7        char input[40] = {'\0'};
   8        int count = 0;
Community
  • 1
  • 1
terence hill
  • 3,354
  • 18
  • 31
  • Hi, that's actually worked for me too. thanks for your help. I just wonder if you also have any experience with remote debugging. the dSYM files contains the symbols but i also need the code for stepping in/out C code lines rather then assembly. unfortunately, i cannot put the code anywhere in the station that runs the executable. perhaps you know how to work with lldb-server. i couldn't even find the installation file... – Zohar81 Nov 05 '15 at 17:21
  • Hi, unfortunately I have no experience with remote debugging, however you can try to post the question ;) – terence hill Nov 05 '15 at 17:24