"""
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.
"""
char_buf = ""
print "{:08x} {: <50s} |{: <16s}|".format(begin_offset + index - 16, hex_buf, char_buf)
return
+
+def Ones(x):
+ return (1 << x)-1
+
+def StripPAC(x, TySz):
+ sign_mask = 1 << 55
+ ptr_mask = Ones(64-TySz)
+ pac_mask = ~ptr_mask
+ sign = x & sign_mask
+ if sign:
+ return (x | pac_mask) + 2**64
+ else:
+ return x & ptr_mask