]>
git.saurik.com Git - apple/xnu.git/blob - bsd/kern/makekdebugevents.py
3 # This script scans the trace.codes file, containing a mapping of event id to
4 # event name for all events, and writes to stdout a C declaration for a table
5 # named kd_events[] or these mappings.
6 # Required to generate a header file used by DEVELOPMENT and DEBUG kernels.
12 # we expect one arg specifying the path to the trace.codes file
13 if (len(sys
.argv
) < 2):
15 trace_code_file
= sys
.argv
[1]
17 # regular expression pattern to match <hex_id> <string>
18 id_name_pattern
= re
.compile('0x([0-9a-fA-F]+)\s+([^\s]*)')
21 # scan file to generate internal table
22 with open(trace_code_file
, 'rt') as codes
:
24 m
= id_name_pattern
.match(line
)
26 code_table
+= [(int(m
.group(1),base
=16), m
.group(2))]
29 print "typedef struct {"
31 print " const char *name;"
33 # emit structure declaration and sorted initialization:
34 print "kd_event_t kd_events[] = {"
35 for mapping
in sorted(code_table
, key
=lambda x
: x
[0]):
36 print " {0x%x, \"%s\"}," % mapping