Rizin
unix-like reverse engineering framework and cli tools
build_mig_index Namespace Reference

Functions

def convert (trace_codes, trap_json)
 

Variables

string header
 

Function Documentation

◆ convert()

def build_mig_index.convert (   trace_codes,
  trap_json 
)

Definition at line 30 of file build_mig_index.py.

30 def convert(trace_codes, trap_json):
31  data = {}
32  with open(trace_codes, "r") as f:
33  for line in f:
34  splitted = re.compile("\s+").split(line.rstrip("\n"))
35  name = splitted[1]
36  code = int(splitted[0], 0)
37  klass = code & 0xFF000000
38  if klass == 0xFF000000: # MIG
39  name = name.replace("MSG_", "")
40  num = (code & 0x00FFFFFF) >> 2
41  data[num] = name
42 
43  with open(trap_json, "r") as f:
44  traps = json.loads(f.read())
45  for routine in traps:
46  num = routine["num"]
47  if num in data:
48  continue
49  data[num] = routine["name"]
50 
51  result = []
52  for num in data:
53  result.append((num, data[num]))
54 
55  result.sort(key=lambda x: x[0])
56 
57  print(header)
58  print("#ifndef RZ_MIG_INDEX_H")
59  print("#define RZ_MIG_INDEX_H\n")
60 
61  print("#define RZ_MIG_INDEX_LEN %d\n" % (len(data) * 2))
62 
63  print("static const char *mig_index[RZ_MIG_INDEX_LEN] = {")
64  for pair in result:
65  print('\t"%d", "%s",' % pair)
66  print("};\n")
67 
68  print("#endif")
69 
70 
size_t len
Definition: 6502dis.c:15
def convert(trace_codes, trap_json)
static int
Definition: sfsocketcall.h:114

References test-lz4-list.exit, int, and len.

Referenced by stream_encode().

Variable Documentation

◆ header

string build_mig_index.header
Initial value:
1 = """// SPDX-FileCopyrightText: 2019-2021 RizinOrg <info@rizin.re>
2 // SPDX-FileCopyrightText: 2019 Francesco Tamagni <mrmacete@protonmail.ch>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 // clang-format off
6 
7 /*
8  * This file is generated in this way:
9  *
10  * python3 build_mig_index.py ~/xnu-4570.51.1/bsd/kern/trace_codes traps.json > mig_index.h
11  *
12  *
13  * The traps.json file is generated from any dyld cache using the machtraps.py rzpipe script.
14  *
15  */
16 """

Definition at line 12 of file build_mig_index.py.