Skip to content

Instantly share code, notes, and snippets.

@zrxq
Last active February 7, 2024 11:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save zrxq/9582777 to your computer and use it in GitHub Desktop.
Save zrxq/9582777 to your computer and use it in GitHub Desktop.
Execute lldb command and open its output in Sublime Text
comma script import ~/lldb/subl.py
comma script add -f subl.subl subl
# 1. Edit your ~/.lldbinit
# 2. Put this file (subl.py) in ~/lldb/
# 3. Restart Xcode
# 4. Test the command:
#
# (lldb) subl <any lldb command>
#
# e.g.
#
# (lldb) subl po myArray
#
# or
#
# (lldb) subl help
#
# 5. If it doesn't work, make sure you have `subl` installed and the path (see below) is correct
#
# See also: http://www.sublimetext.com/docs/3/osx_command_line.html
#
import lldb
import subprocess
def subl(debugger, command, result, dict):
res = lldb.SBCommandReturnObject()
comminter = debugger.GetCommandInterpreter()
comminter.HandleCommand(command, res)
if not res.Succeeded():
return
output = res.GetOutput()
subl = subprocess.Popen(['/usr/local/bin/subl','--stay', '-'], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subl.stdin.write(output)
subl.stdin.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment