]>
Commit | Line | Data |
---|---|---|
39236c6e A |
1 | #!/usr/bin/env python |
2 | ||
3 | """ This file holds all static values that debugging macros need. These are typically object type strings, #defines in C etc. | |
4 | The objective is to provide a single place to be the bridge between C code in xnu and the python macros used by lldb. | |
5 | If you define a variable which has been copied/referred over from C code and has high chance of changing over time. It would | |
6 | be best to define a supporting function of format "populate_<variable_name>". This will help in running them to repopulate. | |
7 | ||
8 | Please take a look at example of kobject_types below before making changes to this file. | |
9 | Note: The Format of the function has to be populate_<variable_name> so that the automated updating will pick it up. | |
10 | """ | |
11 | import os, re | |
12 | ||
13 | lcpu_self = 0xFFFE | |
14 | arm_level2_access_strings = [ " noaccess", | |
15 | " supervisor(readwrite) user(noaccess)", | |
16 | " supervisor(readwrite) user(readonly)", | |
17 | " supervisor(readwrite) user(readwrite)", | |
18 | " noaccess(reserved)", | |
19 | " supervisor(readonly) user(noaccess)", | |
20 | " supervisor(readonly) user(readonly)", | |
21 | " supervisor(readonly) user(readonly)", | |
22 | " " | |
23 | ] | |
24 | proc_state_strings = [ "", "Idle", "Run", "Sleep", "Stop", "Zombie", "Reaping" ] | |
25 | proc_flag_explain_strings = ["!0x00000004 - process is 32 bit", #only exception that does not follow bit settings | |
26 | "0x00000001 - may hold advisory locks", | |
27 | "0x00000002 - has a controlling tty", | |
28 | "0x00000004 - process is 64 bit", | |
29 | "0x00000008 - no SIGCHLD on child stop", | |
30 | "0x00000010 - waiting for child exec/exit", | |
31 | "0x00000020 - has started profiling", | |
32 | "0x00000040 - in select; wakeup/waiting danger", | |
33 | "0x00000080 - was stopped and continued", | |
34 | "0x00000100 - has set privileges since exec", | |
35 | "0x00000200 - system process: no signals, stats, or swap", | |
36 | "0x00000400 - timing out during a sleep", | |
37 | "0x00000800 - debugged process being traced", | |
38 | "0x00001000 - debugging process has waited for child", | |
39 | "0x00002000 - exit in progress", | |
40 | "0x00004000 - process has called exec", | |
41 | "0x00008000 - owe process an addupc() XXX", | |
42 | "0x00010000 - affinity for Rosetta children", | |
43 | "0x00020000 - wants to run Rosetta", | |
44 | "0x00040000 - has wait() in progress", | |
45 | "0x00080000 - kdebug tracing on for this process", | |
46 | "0x00100000 - blocked due to SIGTTOU or SIGTTIN", | |
47 | "0x00200000 - has called reboot()", | |
48 | "0x00400000 - is TBE state", | |
49 | "0x00800000 - signal exceptions", | |
50 | "0x01000000 - has thread cwd", | |
51 | "0x02000000 - has vfork() children", | |
52 | "0x04000000 - not allowed to attach", | |
53 | "0x08000000 - vfork() in progress", | |
54 | "0x10000000 - no shared libraries", | |
55 | "0x20000000 - force quota for root", | |
56 | "0x40000000 - no zombies when children exit", | |
57 | "0x80000000 - don't hang on remote FS ops" | |
58 | ] | |
59 | #File: xnu/osfmk/kern/ipc_kobject.h | |
60 | # string representations for Kobject types | |
61 | kobject_types = ['', 'THREAD', 'TASK', 'HOST', 'HOST_PRIV', 'PROCESSOR', 'PSET', 'PSET_NAME', 'TIMER', 'PAGER_REQ', 'DEVICE', 'XMM_OBJECT', 'XMM_PAGER', 'XMM_KERNEL', 'XMM_REPLY', | |
62 | 'NOTDEF 15', 'NOTDEF 16', 'HOST_SEC', 'LEDGER', 'MASTER_DEV', 'ACTIVATION', 'SUBSYTEM', 'IO_DONE_QUE', 'SEMAPHORE', 'LOCK_SET', 'CLOCK', 'CLOCK_CTRL' , 'IOKIT_SPARE', | |
63 | 'NAMED_MEM', 'IOKIT_CON', 'IOKIT_OBJ', 'UPL', 'MEM_OBJ_CONTROL', 'AU_SESSIONPORT', 'FILEPORT', 'LABELH'] | |
64 | ||
65 | def populate_kobject_types(xnu_dir_path): | |
66 | """ Function to read data from header file xnu/osfmk/kern/ipc_kobject.h | |
67 | and populate the known kobject types. | |
68 | """ | |
69 | filename = os.path.join(xnu_dir_path, 'osfmk', 'kern', 'ipc_kobject.h') | |
70 | filedata = open(filename).read() | |
71 | object_regex = re.compile("^#define\s+(IKOT_[A-Z_]*)\s+(\d+)\s*",re.MULTILINE|re.DOTALL) | |
72 | kobject_found_types =[] | |
73 | for v in object_regex.findall(filedata): | |
74 | kobject_found_types.append(v[0]) | |
75 | return kobject_found_types | |
76 | ||
77 | if __name__ == "__main__": | |
78 | populate_kobject_types("../../") | |
79 |