blob: 20338c378ecaa13f2d5748d81e444560fcadb736 (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# usr/bin/python3
def process_map_file(map_file_path):
result = (
"# Memory Addresses\n"
"This page displays the memory addresses of variables in the project.\n"
"\n"
"## Memory Addresses\n"
"The following table shows the memory addresses of important variables:\n"
"Variable Name | Memory Address\n"
"--------------|---------------\n"
)
with open(map_file_path, 'r') as file:
for line in file:
# Check if the line starts with a memory address (e.g., 0x)
if line.strip().startswith("0x"):
# Split the line into tokens
tokens = line.split()
# Ensure there are enough tokens to extract address and function name
if len(tokens) >= 2:
address = f"0x{int(tokens[0][2:].upper(), base=16):08X}"
if int(address, 16) == 0:
continue
function_name = tokens[-1]
if function_name.startswith("L8"): # Ignore local labels
continue
if function_name.startswith("jpt_"):
continue
if function_name.startswith("0x"):
continue
if function_name.startswith("("):
continue
if function_name.startswith("__"):
continue
# Format the information into the Doxygen style
result += f"[{function_name}](@ref {function_name}) | {address}\n"
result += (
"\n"
"Note: This information is generated during the compilation process.\n"
"\n"
)
return result
if __name__ == "__main__":
map_file_path = "build/us/mk64.us.map"
doxygen_formatted_content = process_map_file(map_file_path)
# Specify the output file path
output_file_path = "docs/doxygen_syms.md"
# Write the result to the output file
with open(output_file_path, 'w') as output_file:
output_file.write(doxygen_formatted_content)
|