X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/fe8ab488e9161c46dd9885d58fc52996dc0249ff..ecc0ceb4089d506a0b8d16686a95817b331af9cb:/tools/lldbmacros/utils.py?ds=sidebyside diff --git a/tools/lldbmacros/utils.py b/tools/lldbmacros/utils.py index 5c7ff72c6..68161d7c3 100644 --- a/tools/lldbmacros/utils.py +++ b/tools/lldbmacros/utils.py @@ -362,6 +362,22 @@ def loadDSYM(uuid, load_address): debuglog(cmd_str) lldb.debugger.HandleCommand(cmd_str) +def RunShellCommand(command): + """ Run a shell command in subprocess. + params: command with arguments to run + returns: (exit_code, stdout, stderr) + """ + import shlex, subprocess + cmd_args = shlex.split(command) + output_str = "" + exit_code = 0 + try: + output_str = subprocess.check_output(cmd_args, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError, e: + exit_code = e.returncode + finally: + return (exit_code, output_str, '') + def dsymForUUID(uuid): """ Get dsym informaiton by calling dsymForUUID params: uuid - str - uuid string from executable. eg. 4DD2344C0-4A81-3EAB-BDCF-FEAFED9EB73E @@ -393,3 +409,15 @@ def debuglog(s): if config['debug']: print "DEBUG:",s return None + +def IsAppleInternal(): + """ check if apple_internal modules are available + returns: True if apple_internal module is present + """ + import imp + try: + imp.find_module("apple_internal") + retval = True + except ImportError: + retval = False + return retval