Last active
May 18, 2019 16:54
-
-
Save nevermoe/59a545feb3b5950ee138962c4368a495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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