Skip to content

Instantly share code, notes, and snippets.

@nevermoe
Last active May 18, 2019 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nevermoe/59a545feb3b5950ee138962c4368a495 to your computer and use it in GitHub Desktop.
Save nevermoe/59a545feb3b5950ee138962c4368a495 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
## echo "command script import ~/Documents/git_codes/lldb_utilities/lldb_utilities.py" >> ~/.lldbinit
import lldb
import commands
import optparse
import shlex
def dbgcall(command):
res = lldb.SBCommandReturnObject()
lldb.debugger.GetCommandInterpreter().HandleCommand(command, res)
return res.GetOutput()
def imlist(debugger, command, result, internal_dict):
output = dbgcall("image list")
for line in output.splitlines():
if command in line:
print line
def ls(debugger, command, result, internal_dict):
print >>result, (commands.getoutput('/bin/ls %s' % command))
# And the initialization code to add your commands
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('command script add -f lldb_utilities.ls ls')
print 'The "ls" python command has been installed and is ready for use.'
debugger.HandleCommand('command script add -f lldb_utilities.imlist imlist')
print 'The "imlist" python command has been installed and is ready for use.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment