2

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.

Jeff
  • 3,829
  • 1
  • 31
  • 49
  • `mdfind -name crashlog` shows both `/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python/lldb/macosx/crashlog.py` and `/Library/Developer/CommandLineTools/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python3/lldb/macosx/crashlog.py` which appears to provide the `crashlog` and `save_crashlog` commands (at least) directly. – msbit Aug 03 '21 at 23:16
  • @msbit Thank you! Please add that comment as an answer so I can accept it. I did so many `find` commands with zero results. – Jeff Aug 04 '21 at 16:49
  • BTW, the way to understand this after you've figured it out else wise is `command script import` is an lldb wrapper on top of the `import` functionality of the current script interpreter. It can import python modules on the current PYTHONPATH or if you give it a .py file it will put that directory on the path & then do the import. lldb.macosx.crashlog is a python module specification for something in the built-in lldb Python module, which is shipped in the LLDB.framework. Everything in the lldb module will come from there - though a lot of the methods are imported from C++ in the __lldb.so. – Jim Ingham Aug 04 '21 at 18:59
  • @JimIngham wrote "lldb.macosx.crashlog is a python module specification for something in the built-in lldb Python module" Yeah, I did not realize that '.' was a pathing element until after seeing msbit comment. Thanks for confirming that, tho. – Jeff Aug 04 '21 at 19:06

1 Answers1

1

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.

msbit
  • 4,152
  • 2
  • 9
  • 22