forked from idhyt/android_root_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkparse.py
49 lines (34 loc) · 1.04 KB
/
kparse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# encoding: utf-8
"""
@author: idhyt
@date:
@description:
parse result
"""
import os
import argparse
CURRENT_PATH = os.path.split(os.path.realpath(__file__))[0]
def get_args():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-f', '--file', help="kernel, xxxxx file")
args = parser.parse_args()
return args
def parse_kallsyms(file_name):
kallsyms_file_path = "/".join([CURRENT_PATH, file_name])
result = []
with open(kallsyms_file_path, "r") as f:
content = f.readlines()
for line in content:
if line.find("ffffffc0") == 0 or line.find("c000") == 0:
result.append(line.replace("\r\n", "\n"))
f.close()
with open(kallsyms_file_path, "w") as f:
f.write("".join(result))
f.close()
def parse_result():
args = get_args()
if args.file == "kallsyms":
parse_kallsyms(args.file)
if __name__ == '__main__':
parse_result()