33 lines
888 B
Python
33 lines
888 B
Python
#-------------------------------------------------------------------------------
|
|
# map_diff
|
|
# 22/03/2022
|
|
# tool script used to easily compare diffs of (IAR) .map files
|
|
#
|
|
# usage ex: diff -hu file1.map file2.map | python map_diff.py
|
|
#-------------------------------------------------------------------------------
|
|
|
|
import fileinput
|
|
import re
|
|
|
|
old_size = 0x0
|
|
new_size = 0x0
|
|
prev_line = ""
|
|
total_diff = 0
|
|
|
|
p = re.compile('0x\w+ ')
|
|
for line in fileinput.input():
|
|
val = re.search(p, line)
|
|
if val:
|
|
if line[0] == '-':
|
|
old_size = int(val.group(0), base=16)
|
|
prev_line = line
|
|
else:
|
|
new_size = int(val.group(0), base=16)
|
|
if new_size != old_size:
|
|
diff = new_size-old_size
|
|
total_diff += diff
|
|
print(prev_line + line + "diff: " + str(diff))
|
|
|
|
print("total diff: " + str(total_diff))
|
|
|