Search code examples
lldbxcode12spotlight

Where is lldb.macosx.crashlog?


Summary

The lldb scripts lldb.macosx.crashlog have some bugs in them stopping me from debugging my crashes. I want to find the source code of these scripts and fix them. Where are they?

I have looked in /Applications, /Library, and ~/Library using commands like:

sudo find /Library -name 'lldb.macosx.crashlog*'

Details

WWDC 2018 414 video titled Understanding Crashes and Crash Logs says to run command script import lldb.macosx.crashlog in lldb. This imports a set of scripts.

(lldb) command script list 
Current user-defined commands:
  crashlog      -- For more information run 'help crashlog'
  cstr_refs     -- For more information run 'help cstr_refs'
  find_variable -- For more information run 'help find_variable'
  malloc_info   -- For more information run 'help malloc_info'
  objc_refs     -- For more information run 'help objc_refs'
  ptr_refs      -- For more information run 'help ptr_refs'
  save_crashlog -- For more information run 'help save_crashlog'
For more information on any command, type 'help <command-name>'.

The main script to use from the WWDC video is crashlog like this:

(lldb) crashlog /Users/jeff/Library/Developer/Xcode/Products/com.myapp/1.2.3\ \(4\)/Crashes/AppStore/hash.xccrashpoint/DistributionInfos/all/Logs/LocallySymbolicated/date-uuid.crash

As long as you have the dSYM files downloaded from App Store Connect (because of bitcode) and the app archive that you uploaded to App Store Connect somewhere on your file system, the crashlog script will find them ok.

However, the following errors happen.

First, while stepping thru the "Getting symbols for..." for each dSYM, it stops early and prints the stack trace.

Then, it prints this error about 8 calls deep in thread 0:

error: python exception: can only concatenate str (not "NoneType") to str

And in the end, lldb is left in a state that disassemble does not work.


Solution

  • On macOS, you may find mdfind useful if you're not sure about the filename or location; it uses the same central metadata store as Spotlight.

    Running:

    mdfind -name crashlog
    

    on my machine, lists (among others) these relevant files:

    /Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python/lldb/macosx/crashlog.py
    /Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python3/lldb/macosx/crashlog.py
    

    These provide the:

    • crashlog and
    • save_crashlog

    commands.