10
10
import argparse
11
11
from prettytable import PrettyTable
12
12
13
- from tools . utils import argparse_filestring_type , \
13
+ from utils import argparse_filestring_type , \
14
14
argparse_lowercase_hyphen_type , argparse_uppercase_type
15
15
16
16
DEBUG = False
17
+
17
18
RE_ARMCC = re .compile (
18
19
r'^\s+0x(\w{8})\s+0x(\w{8})\s+(\w+)\s+(\w+)\s+(\d+)\s+[*]?.+\s+(.+)$' )
19
20
RE_IAR = re .compile (
@@ -37,10 +38,12 @@ class MemapParser(object):
37
38
# sections to print info (generic for all toolchains)
38
39
sections = ('.text' , '.data' , '.bss' , '.heap' , '.stack' )
39
40
40
- def __init__ (self ):
41
+ def __init__ (self , detailed_misc = False ):
41
42
""" General initialization
42
43
"""
43
-
44
+ #
45
+ self .detailed_misc = detailed_misc
46
+
44
47
# list of all modules and their sections
45
48
self .modules = dict ()
46
49
@@ -95,8 +98,8 @@ def check_new_section_gcc(self, line):
95
98
else :
96
99
return False # everything else, means no change in section
97
100
98
- @ staticmethod
99
- def path_object_to_module_name (txt ):
101
+
102
+ def path_object_to_module_name (self , txt ):
100
103
""" Parse a path to object file to extract it's module and object data
101
104
102
105
Positional arguments:
@@ -119,9 +122,17 @@ def path_object_to_module_name(txt):
119
122
module_name = data [0 ] + '/' + data [1 ]
120
123
121
124
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 :
123
135
return ['Misc' , "" ]
124
-
125
136
126
137
def parse_section_gcc (self , line ):
127
138
""" Parse data from a section of gcc map file
@@ -617,6 +628,8 @@ def main():
617
628
", " .join (MemapParser .export_formats ))
618
629
619
630
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 )
620
633
621
634
# Parse/run command
622
635
if len (sys .argv ) <= 1 :
@@ -627,7 +640,7 @@ def main():
627
640
args = parser .parse_args ()
628
641
629
642
# Create memap object
630
- memap = MemapParser ()
643
+ memap = MemapParser (detailed_misc = args . detailed )
631
644
632
645
# Parse and decode a map file
633
646
if args .file and args .toolchain :
0 commit comments