Skip to content

Commit 23f7090

Browse files
authored
Merge pull request #2845 from javier-moreno-tridonic-com/feature-detailed-memap
[Tools] Added -d (--detailed) paremeter to unfold 'Misc' contents in memap.py table
2 parents 872363d + 2b36d2d commit 23f7090

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

tools/memap.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
import argparse
1111
from prettytable import PrettyTable
1212

13-
from tools.utils import argparse_filestring_type, \
13+
from utils import argparse_filestring_type, \
1414
argparse_lowercase_hyphen_type, argparse_uppercase_type
1515

1616
DEBUG = False
17+
1718
RE_ARMCC = re.compile(
1819
r'^\s+0x(\w{8})\s+0x(\w{8})\s+(\w+)\s+(\w+)\s+(\d+)\s+[*]?.+\s+(.+)$')
1920
RE_IAR = re.compile(
@@ -37,10 +38,12 @@ class MemapParser(object):
3738
# sections to print info (generic for all toolchains)
3839
sections = ('.text', '.data', '.bss', '.heap', '.stack')
3940

40-
def __init__(self):
41+
def __init__(self, detailed_misc=False):
4142
""" General initialization
4243
"""
43-
44+
#
45+
self.detailed_misc = detailed_misc
46+
4447
# list of all modules and their sections
4548
self.modules = dict()
4649

@@ -95,8 +98,8 @@ def check_new_section_gcc(self, line):
9598
else:
9699
return False # everything else, means no change in section
97100

98-
@staticmethod
99-
def path_object_to_module_name(txt):
101+
102+
def path_object_to_module_name(self, txt):
100103
""" Parse a path to object file to extract it's module and object data
101104
102105
Positional arguments:
@@ -119,9 +122,17 @@ def path_object_to_module_name(txt):
119122
module_name = data[0] + '/' + data[1]
120123

121124
return [module_name, object_name]
122-
else:
125+
126+
elif self.detailed_misc:
127+
rex_obj_name = r'^.+\/(.+\.o\)*)$'
128+
test_rex_obj_name = re.match(rex_obj_name, txt)
129+
if test_rex_obj_name:
130+
object_name = test_rex_obj_name.group(1)
131+
return ['Misc/' + object_name, ""]
132+
133+
return ['Misc', ""]
134+
else:
123135
return ['Misc', ""]
124-
125136

126137
def parse_section_gcc(self, line):
127138
""" Parse data from a section of gcc map file
@@ -617,6 +628,8 @@ def main():
617628
", ".join(MemapParser.export_formats))
618629

619630
parser.add_argument('-v', '--version', action='version', version=version)
631+
632+
parser.add_argument('-d', '--detailed', action='store_true', help='Displays the elements in "Misc" in a detailed fashion', required=False)
620633

621634
# Parse/run command
622635
if len(sys.argv) <= 1:
@@ -627,7 +640,7 @@ def main():
627640
args = parser.parse_args()
628641

629642
# Create memap object
630-
memap = MemapParser()
643+
memap = MemapParser(detailed_misc=args.detailed)
631644

632645
# Parse and decode a map file
633646
if args.file and args.toolchain:

0 commit comments

Comments
 (0)