X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/3903760236c30e3b5ace7a4eefac3a269d68957c..e8c3f78193f1895ea514044358b93b1add9322f3:/tools/lldbmacros/utils.py diff --git a/tools/lldbmacros/utils.py b/tools/lldbmacros/utils.py old mode 100644 new mode 100755 index fbb0494bc..33d601f8d --- a/tools/lldbmacros/utils.py +++ b/tools/lldbmacros/utils.py @@ -140,7 +140,16 @@ def Cast(obj, target_type): """ return cast(obj, target_type) - +def ContainerOf(obj, target_type, field_name): + """ Type cast an object to another C type from a pointer to a field. + params: + obj - core.value object representing some C construct in lldb + target_type - str : ex 'struct thread' + - lldb.SBType : + field_name - the field name within the target_type obj is a pointer to + """ + return containerof(obj, target_type, field_name) + def loadLLDB(): """ Util function to load lldb python framework in case not available in common include paths. """ @@ -398,7 +407,7 @@ def dsymForUUID(uuid): """ import subprocess import plistlib - output = subprocess.check_output(["/usr/local/bin/dsymForUUID", uuid]) + output = subprocess.check_output(["/usr/local/bin/dsymForUUID", "--copyExecutable", uuid]) if output: # because of #plist = plistlib.readPlistFromString(output) @@ -461,3 +470,7 @@ def print_hex_data(data, begin_offset=0, desc=""): char_buf = "" print "{:08x} {: <50s} |{: <16s}|".format(begin_offset + index - 16, hex_buf, char_buf) return + +def Ones(x): + return (1 << x)-1 +