]> git.saurik.com Git - apple/xnu.git/blobdiff - tools/lldbmacros/xnudefines.py
xnu-3789.51.2.tar.gz
[apple/xnu.git] / tools / lldbmacros / xnudefines.py
index 604c2791ce409c350970b9ed2ecdf260212e93a2..9aa59c68fbed11c9e2254b404a321c28b111a4c2 100644 (file)
 """
 import os, re
 
+def GetStateString(strings_dict, state):
+    """ Turn a dictionary from flag value to flag name and a state mask with
+        those flags into a space-separated string of names.
+
+        params:
+            strings_dict: a dictionary of flag values to flag names
+            state: the value to get the state string of
+        return:
+            a space separated list of flag names present in state
+    """
+    max_mask = max(strings_dict.keys())
+
+    first = True
+    output = ''
+    mask = 0x1
+    while mask <= max_mask:
+        bit = int(state & mask)
+        if bit and bit in strings_dict:
+            if not first:
+                output += ' '
+            else:
+                first = False
+            output += strings_dict[int(state & mask)]
+        mask = mask << 1
+
+    return output
+
+kdebug_flags_strings = { 0x00100000: 'RANGECHECK',
+                         0x00200000: 'VALCHECK',
+                         0x00400000: 'TYPEFILTER_CHECK',
+                         0x80000000: 'BUFINIT' }
+kdebug_typefilter_check = 0x00400000
+
+kperf_samplers_strings = { 1 << 0: 'TH_INFO',
+                           1 << 1: 'TH_SNAP',
+                           1 << 2: 'KSTACK',
+                           1 << 3: 'USTACK',
+                           1 << 4: 'PMC_THREAD',
+                           1 << 5: 'PMC_CPU',
+                           1 << 6: 'PMC_CONFIG',
+                           1 << 7: 'MEMINFO',
+                           1 << 8: 'TH_SCHED',
+                           1 << 9: 'TH_DISP',
+                           1 << 10: 'TK_SNAP' }
+
 lcpu_self = 0xFFFE
 arm_level2_access_strings = [ " noaccess",
                               " supervisor(readwrite) user(noaccess)",