Clone of official tools

Committer:
The Other Jimmy
Date:
Wed Jan 04 11:58:24 2017 -0600
Revision:
31:8ea194f6145b
Parent:
30:f12ce67666d0
Child:
36:96847d42f010
Update tools to follow mbed-os tools release 5.3.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 1 #!/usr/bin/env python
screamer 8:a8ac6ed29081 2
screamer 29:1210849dba19 3 """Memory Map File Analyser for ARM mbed"""
screamer 8:a8ac6ed29081 4
screamer 8:a8ac6ed29081 5 import sys
screamer 8:a8ac6ed29081 6 import os
screamer 8:a8ac6ed29081 7 import re
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 8 import csv
screamer 8:a8ac6ed29081 9 import json
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 10 import argparse
screamer 8:a8ac6ed29081 11 from prettytable import PrettyTable
screamer 8:a8ac6ed29081 12
The Other Jimmy 31:8ea194f6145b 13 from utils import argparse_filestring_type, \
screamer 29:1210849dba19 14 argparse_lowercase_hyphen_type, argparse_uppercase_type
screamer 29:1210849dba19 15
screamer 29:1210849dba19 16 DEBUG = False
The Other Jimmy 31:8ea194f6145b 17
screamer 29:1210849dba19 18 RE_ARMCC = re.compile(
screamer 29:1210849dba19 19 r'^\s+0x(\w{8})\s+0x(\w{8})\s+(\w+)\s+(\w+)\s+(\d+)\s+[*]?.+\s+(.+)$')
screamer 29:1210849dba19 20 RE_IAR = re.compile(
screamer 29:1210849dba19 21 r'^\s+(.+)\s+(zero|const|ro code|inited|uninit)\s'
screamer 29:1210849dba19 22 r'+0x(\w{8})\s+0x(\w+)\s+(.+)\s.+$')
screamer 8:a8ac6ed29081 23
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 24 class MemapParser(object):
screamer 29:1210849dba19 25 """An object that represents parsed results, parses the memory map files,
screamer 29:1210849dba19 26 and writes out different file types of memory results
screamer 29:1210849dba19 27 """
screamer 29:1210849dba19 28
screamer 29:1210849dba19 29 print_sections = ('.text', '.data', '.bss')
screamer 29:1210849dba19 30
screamer 29:1210849dba19 31 misc_flash_sections = ('.interrupts', '.flash_config')
screamer 29:1210849dba19 32
screamer 29:1210849dba19 33 other_sections = ('.interrupts_ram', '.init', '.ARM.extab',
screamer 29:1210849dba19 34 '.ARM.exidx', '.ARM.attributes', '.eh_frame',
screamer 29:1210849dba19 35 '.init_array', '.fini_array', '.jcr', '.stab',
screamer 29:1210849dba19 36 '.stabstr', '.ARM.exidx', '.ARM')
screamer 29:1210849dba19 37
screamer 29:1210849dba19 38 # sections to print info (generic for all toolchains)
screamer 29:1210849dba19 39 sections = ('.text', '.data', '.bss', '.heap', '.stack')
screamer 8:a8ac6ed29081 40
The Other Jimmy 31:8ea194f6145b 41 def __init__(self, detailed_misc=False):
screamer 29:1210849dba19 42 """ General initialization
screamer 8:a8ac6ed29081 43 """
The Other Jimmy 31:8ea194f6145b 44 #
The Other Jimmy 31:8ea194f6145b 45 self.detailed_misc = detailed_misc
The Other Jimmy 31:8ea194f6145b 46
screamer 8:a8ac6ed29081 47 # list of all modules and their sections
screamer 8:a8ac6ed29081 48 self.modules = dict()
screamer 8:a8ac6ed29081 49
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 50 # sections must be defined in this order to take irrelevant out
screamer 8:a8ac6ed29081 51 self.all_sections = self.sections + self.other_sections + \
screamer 8:a8ac6ed29081 52 self.misc_flash_sections + ('unknown', 'OUTPUT')
screamer 8:a8ac6ed29081 53
screamer 8:a8ac6ed29081 54 # list of all object files and mappting to module names
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 55 self.object_to_module = dict()
screamer 8:a8ac6ed29081 56
The Other Jimmy 31:8ea194f6145b 57 # Memory report (sections + summary)
The Other Jimmy 31:8ea194f6145b 58 self.mem_report = []
The Other Jimmy 31:8ea194f6145b 59
The Other Jimmy 31:8ea194f6145b 60 # Just the memory summary section
screamer 22:9e85236d8716 61 self.mem_summary = dict()
screamer 22:9e85236d8716 62
The Other Jimmy 31:8ea194f6145b 63 self.subtotal = dict()
The Other Jimmy 31:8ea194f6145b 64
screamer 8:a8ac6ed29081 65 def module_add(self, module_name, size, section):
screamer 29:1210849dba19 66 """ Adds a module / section to the list
screamer 29:1210849dba19 67
screamer 29:1210849dba19 68 Positional arguments:
screamer 29:1210849dba19 69 module_name - name of the module to add
screamer 29:1210849dba19 70 size - the size of the module being added
screamer 29:1210849dba19 71 section - the section the module contributes to
screamer 8:a8ac6ed29081 72 """
screamer 8:a8ac6ed29081 73
screamer 8:a8ac6ed29081 74 if module_name in self.modules:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 75 self.modules[module_name][section] += size
screamer 8:a8ac6ed29081 76 else:
screamer 8:a8ac6ed29081 77 temp_dic = dict()
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 78 for section_idx in self.all_sections:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 79 temp_dic[section_idx] = 0
screamer 8:a8ac6ed29081 80 temp_dic[section] = size
screamer 8:a8ac6ed29081 81 self.modules[module_name] = temp_dic
screamer 8:a8ac6ed29081 82
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 83 def check_new_section_gcc(self, line):
screamer 29:1210849dba19 84 """ Check whether a new section in a map file has been detected (only
screamer 29:1210849dba19 85 applies to gcc)
screamer 29:1210849dba19 86
screamer 29:1210849dba19 87 Positional arguments:
screamer 29:1210849dba19 88 line - the line to check for a new section
screamer 8:a8ac6ed29081 89 """
screamer 8:a8ac6ed29081 90
screamer 8:a8ac6ed29081 91 for i in self.all_sections:
screamer 8:a8ac6ed29081 92 if line.startswith(i):
screamer 29:1210849dba19 93 # should name of the section (assuming it's a known one)
screamer 29:1210849dba19 94 return i
screamer 8:a8ac6ed29081 95
screamer 8:a8ac6ed29081 96 if line.startswith('.'):
screamer 22:9e85236d8716 97 return 'unknown' # all others are classified are unknown
screamer 8:a8ac6ed29081 98 else:
screamer 8:a8ac6ed29081 99 return False # everything else, means no change in section
screamer 8:a8ac6ed29081 100
The Other Jimmy 31:8ea194f6145b 101
The Other Jimmy 31:8ea194f6145b 102 def path_object_to_module_name(self, txt):
screamer 29:1210849dba19 103 """ Parse a path to object file to extract it's module and object data
screamer 29:1210849dba19 104
screamer 29:1210849dba19 105 Positional arguments:
screamer 29:1210849dba19 106 txt - the path to parse the object and module name from
screamer 8:a8ac6ed29081 107 """
screamer 8:a8ac6ed29081 108
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 109 txt = txt.replace('\\', '/')
screamer 8:a8ac6ed29081 110 rex_mbed_os_name = r'^.+mbed-os\/(.+)\/(.+\.o)$'
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 111 test_rex_mbed_os_name = re.match(rex_mbed_os_name, txt)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 112
screamer 8:a8ac6ed29081 113 if test_rex_mbed_os_name:
screamer 8:a8ac6ed29081 114
screamer 8:a8ac6ed29081 115 object_name = test_rex_mbed_os_name.group(2)
screamer 8:a8ac6ed29081 116 data = test_rex_mbed_os_name.group(1).split('/')
screamer 8:a8ac6ed29081 117 ndata = len(data)
screamer 8:a8ac6ed29081 118
screamer 8:a8ac6ed29081 119 if ndata == 1:
screamer 8:a8ac6ed29081 120 module_name = data[0]
screamer 8:a8ac6ed29081 121 else:
screamer 8:a8ac6ed29081 122 module_name = data[0] + '/' + data[1]
screamer 8:a8ac6ed29081 123
screamer 8:a8ac6ed29081 124 return [module_name, object_name]
The Other Jimmy 31:8ea194f6145b 125
The Other Jimmy 31:8ea194f6145b 126 elif self.detailed_misc:
The Other Jimmy 31:8ea194f6145b 127 rex_obj_name = r'^.+\/(.+\.o\)*)$'
The Other Jimmy 31:8ea194f6145b 128 test_rex_obj_name = re.match(rex_obj_name, txt)
The Other Jimmy 31:8ea194f6145b 129 if test_rex_obj_name:
The Other Jimmy 31:8ea194f6145b 130 object_name = test_rex_obj_name.group(1)
The Other Jimmy 31:8ea194f6145b 131 return ['Misc/' + object_name, ""]
The Other Jimmy 31:8ea194f6145b 132
screamer 8:a8ac6ed29081 133 return ['Misc', ""]
The Other Jimmy 31:8ea194f6145b 134 else:
The Other Jimmy 31:8ea194f6145b 135 return ['Misc', ""]
screamer 8:a8ac6ed29081 136
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 137 def parse_section_gcc(self, line):
screamer 29:1210849dba19 138 """ Parse data from a section of gcc map file
screamer 29:1210849dba19 139
screamer 29:1210849dba19 140 examples:
The Other Jimmy 31:8ea194f6145b 141 0x00004308 0x7c ./BUILD/K64F/GCC_ARM/mbed-os/hal/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/spi_api.o
The Other Jimmy 31:8ea194f6145b 142 .text 0x00000608 0x198 ./BUILD/K64F/GCC_ARM/mbed-os/core/mbed-rtos/rtx/TARGET_CORTEX_M/TARGET_RTOS_M4_M7/TOOLCHAIN_GCC/HAL_CM4.o
screamer 29:1210849dba19 143
screamer 29:1210849dba19 144 Positional arguments:
screamer 29:1210849dba19 145 line - the line to parse a section from
screamer 8:a8ac6ed29081 146 """
screamer 29:1210849dba19 147 rex_address_len_name = re.compile(
screamer 29:1210849dba19 148 r'^\s+.*0x(\w{8,16})\s+0x(\w+)\s(.+)$')
screamer 8:a8ac6ed29081 149
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 150 test_address_len_name = re.match(rex_address_len_name, line)
screamer 8:a8ac6ed29081 151
screamer 8:a8ac6ed29081 152 if test_address_len_name:
screamer 8:a8ac6ed29081 153
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 154 if int(test_address_len_name.group(2), 16) == 0: # size == 0
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 155 return ["", 0] # no valid entry
screamer 8:a8ac6ed29081 156 else:
screamer 29:1210849dba19 157 m_name, _ = self.path_object_to_module_name(
screamer 29:1210849dba19 158 test_address_len_name.group(3))
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 159 m_size = int(test_address_len_name.group(2), 16)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 160 return [m_name, m_size]
screamer 8:a8ac6ed29081 161
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 162 else: # special corner case for *fill* sections
screamer 8:a8ac6ed29081 163 # example
screamer 8:a8ac6ed29081 164 # *fill* 0x0000abe4 0x4
screamer 8:a8ac6ed29081 165 rex_address_len = r'^\s+\*fill\*\s+0x(\w{8,16})\s+0x(\w+).*$'
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 166 test_address_len = re.match(rex_address_len, line)
screamer 8:a8ac6ed29081 167
screamer 8:a8ac6ed29081 168 if test_address_len:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 169 if int(test_address_len.group(2), 16) == 0: # size == 0
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 170 return ["", 0] # no valid entry
screamer 8:a8ac6ed29081 171 else:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 172 m_name = 'Fill'
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 173 m_size = int(test_address_len.group(2), 16)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 174 return [m_name, m_size]
screamer 8:a8ac6ed29081 175 else:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 176 return ["", 0] # no valid entry
screamer 8:a8ac6ed29081 177
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 178 def parse_map_file_gcc(self, file_desc):
screamer 29:1210849dba19 179 """ Main logic to decode gcc map files
screamer 29:1210849dba19 180
screamer 29:1210849dba19 181 Positional arguments:
screamer 29:1210849dba19 182 file_desc - a stream object to parse as a gcc map file
screamer 8:a8ac6ed29081 183 """
screamer 8:a8ac6ed29081 184
screamer 8:a8ac6ed29081 185 current_section = 'unknown'
screamer 8:a8ac6ed29081 186
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 187 with file_desc as infile:
screamer 8:a8ac6ed29081 188
screamer 8:a8ac6ed29081 189 # Search area to parse
screamer 8:a8ac6ed29081 190 for line in infile:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 191 if line.startswith('Linker script and memory map'):
screamer 8:a8ac6ed29081 192 current_section = "unknown"
screamer 8:a8ac6ed29081 193 break
screamer 8:a8ac6ed29081 194
screamer 8:a8ac6ed29081 195 # Start decoding the map file
screamer 8:a8ac6ed29081 196 for line in infile:
screamer 8:a8ac6ed29081 197
screamer 8:a8ac6ed29081 198 change_section = self.check_new_section_gcc(line)
screamer 8:a8ac6ed29081 199
screamer 8:a8ac6ed29081 200 if change_section == "OUTPUT": # finish parsing file: exit
screamer 8:a8ac6ed29081 201 break
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 202 elif change_section != False:
screamer 8:a8ac6ed29081 203 current_section = change_section
screamer 8:a8ac6ed29081 204
screamer 8:a8ac6ed29081 205 [module_name, module_size] = self.parse_section_gcc(line)
screamer 8:a8ac6ed29081 206
screamer 8:a8ac6ed29081 207 if module_size == 0 or module_name == "":
screamer 8:a8ac6ed29081 208 pass
screamer 8:a8ac6ed29081 209 else:
screamer 8:a8ac6ed29081 210 self.module_add(module_name, module_size, current_section)
screamer 8:a8ac6ed29081 211
screamer 29:1210849dba19 212 if DEBUG:
screamer 8:a8ac6ed29081 213 print "Line: %s" % line,
screamer 29:1210849dba19 214 print "Module: %s\tSection: %s\tSize: %s" % \
screamer 29:1210849dba19 215 (module_name, current_section, module_size)
screamer 8:a8ac6ed29081 216 raw_input("----------")
screamer 8:a8ac6ed29081 217
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 218 def parse_section_armcc(self, line):
screamer 29:1210849dba19 219 """ Parse data from an armcc map file
screamer 29:1210849dba19 220
screamer 29:1210849dba19 221 Examples of armcc map file:
screamer 29:1210849dba19 222 Base_Addr Size Type Attr Idx E Section Name Object
screamer 29:1210849dba19 223 0x00000000 0x00000400 Data RO 11222 RESET startup_MK64F12.o
screamer 29:1210849dba19 224 0x00000410 0x00000008 Code RO 49364 * !!!main c_w.l(__main.o)
screamer 29:1210849dba19 225
screamer 29:1210849dba19 226 Positional arguments:
screamer 29:1210849dba19 227 line - the line to parse the section data from
screamer 8:a8ac6ed29081 228 """
screamer 8:a8ac6ed29081 229
screamer 29:1210849dba19 230 test_rex_armcc = re.match(RE_ARMCC, line)
screamer 8:a8ac6ed29081 231
screamer 8:a8ac6ed29081 232 if test_rex_armcc:
screamer 8:a8ac6ed29081 233
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 234 size = int(test_rex_armcc.group(2), 16)
screamer 8:a8ac6ed29081 235
screamer 8:a8ac6ed29081 236 if test_rex_armcc.group(4) == 'RO':
screamer 8:a8ac6ed29081 237 section = '.text'
screamer 8:a8ac6ed29081 238 else:
screamer 8:a8ac6ed29081 239 if test_rex_armcc.group(3) == 'Data':
screamer 8:a8ac6ed29081 240 section = '.data'
screamer 8:a8ac6ed29081 241 elif test_rex_armcc.group(3) == 'Zero':
screamer 8:a8ac6ed29081 242 section = '.bss'
screamer 8:a8ac6ed29081 243 else:
screamer 8:a8ac6ed29081 244 print "BUG armcc map parser"
screamer 8:a8ac6ed29081 245 raw_input()
screamer 8:a8ac6ed29081 246
screamer 8:a8ac6ed29081 247 # lookup object in dictionary and return module name
screamer 8:a8ac6ed29081 248 object_name = test_rex_armcc.group(6)
screamer 8:a8ac6ed29081 249 if object_name in self.object_to_module:
screamer 8:a8ac6ed29081 250 module_name = self.object_to_module[object_name]
screamer 8:a8ac6ed29081 251 else:
screamer 8:a8ac6ed29081 252 module_name = 'Misc'
screamer 8:a8ac6ed29081 253
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 254 return [module_name, size, section]
screamer 8:a8ac6ed29081 255
screamer 8:a8ac6ed29081 256 else:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 257 return ["", 0, ""] # no valid entry
screamer 8:a8ac6ed29081 258
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 259 def parse_section_iar(self, line):
screamer 29:1210849dba19 260 """ Parse data from an IAR map file
screamer 29:1210849dba19 261
screamer 29:1210849dba19 262 Examples of IAR map file:
screamer 29:1210849dba19 263 Section Kind Address Size Object
screamer 29:1210849dba19 264 .intvec ro code 0x00000000 0x198 startup_MK64F12.o [15]
screamer 29:1210849dba19 265 .rodata const 0x00000198 0x0 zero_init3.o [133]
screamer 29:1210849dba19 266 .iar.init_table const 0x00008384 0x2c - Linker created -
screamer 29:1210849dba19 267 Initializer bytes const 0x00000198 0xb2 <for P3 s0>
screamer 29:1210849dba19 268 .data inited 0x20000000 0xd4 driverAtmelRFInterface.o [70]
screamer 29:1210849dba19 269 .bss zero 0x20000598 0x318 RTX_Conf_CM.o [4]
screamer 29:1210849dba19 270 .iar.dynexit uninit 0x20001448 0x204 <Block tail>
screamer 29:1210849dba19 271 HEAP uninit 0x20001650 0x10000 <Block tail>
screamer 29:1210849dba19 272
screamer 29:1210849dba19 273 Positional_arguments:
screamer 29:1210849dba19 274 line - the line to parse section data from
screamer 8:a8ac6ed29081 275 """
screamer 8:a8ac6ed29081 276
screamer 29:1210849dba19 277 test_rex_iar = re.match(RE_IAR, line)
screamer 8:a8ac6ed29081 278
screamer 8:a8ac6ed29081 279 if test_rex_iar:
screamer 8:a8ac6ed29081 280
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 281 size = int(test_rex_iar.group(4), 16)
screamer 8:a8ac6ed29081 282
screamer 29:1210849dba19 283 if test_rex_iar.group(2) == 'const' or \
screamer 29:1210849dba19 284 test_rex_iar.group(2) == 'ro code':
screamer 8:a8ac6ed29081 285 section = '.text'
screamer 29:1210849dba19 286 elif test_rex_iar.group(2) == 'zero' or \
screamer 29:1210849dba19 287 test_rex_iar.group(2) == 'uninit':
screamer 8:a8ac6ed29081 288 if test_rex_iar.group(1)[0:4] == 'HEAP':
screamer 8:a8ac6ed29081 289 section = '.heap'
screamer 8:a8ac6ed29081 290 elif test_rex_iar.group(1)[0:6] == 'CSTACK':
screamer 8:a8ac6ed29081 291 section = '.stack'
screamer 8:a8ac6ed29081 292 else:
screamer 8:a8ac6ed29081 293 section = '.bss' # default section
screamer 8:a8ac6ed29081 294
screamer 8:a8ac6ed29081 295 elif test_rex_iar.group(2) == 'inited':
screamer 8:a8ac6ed29081 296 section = '.data'
screamer 8:a8ac6ed29081 297 else:
screamer 8:a8ac6ed29081 298 print "BUG IAR map parser"
screamer 8:a8ac6ed29081 299 raw_input()
screamer 8:a8ac6ed29081 300
screamer 8:a8ac6ed29081 301 # lookup object in dictionary and return module name
screamer 8:a8ac6ed29081 302 object_name = test_rex_iar.group(5)
screamer 8:a8ac6ed29081 303 if object_name in self.object_to_module:
screamer 8:a8ac6ed29081 304 module_name = self.object_to_module[object_name]
screamer 8:a8ac6ed29081 305 else:
screamer 8:a8ac6ed29081 306 module_name = 'Misc'
screamer 8:a8ac6ed29081 307
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 308 return [module_name, size, section]
screamer 8:a8ac6ed29081 309
screamer 8:a8ac6ed29081 310 else:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 311 return ["", 0, ""] # no valid entry
screamer 8:a8ac6ed29081 312
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 313 def parse_map_file_armcc(self, file_desc):
screamer 29:1210849dba19 314 """ Main logic to decode armc5 map files
screamer 29:1210849dba19 315
screamer 29:1210849dba19 316 Positional arguments:
screamer 29:1210849dba19 317 file_desc - a file like object to parse as an armc5 map file
screamer 8:a8ac6ed29081 318 """
screamer 8:a8ac6ed29081 319
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 320 with file_desc as infile:
screamer 8:a8ac6ed29081 321
screamer 8:a8ac6ed29081 322 # Search area to parse
screamer 8:a8ac6ed29081 323 for line in infile:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 324 if line.startswith(' Base Addr Size'):
screamer 8:a8ac6ed29081 325 break
screamer 8:a8ac6ed29081 326
screamer 8:a8ac6ed29081 327 # Start decoding the map file
screamer 8:a8ac6ed29081 328 for line in infile:
screamer 8:a8ac6ed29081 329
screamer 8:a8ac6ed29081 330 [name, size, section] = self.parse_section_armcc(line)
screamer 8:a8ac6ed29081 331
screamer 8:a8ac6ed29081 332 if size == 0 or name == "" or section == "":
screamer 8:a8ac6ed29081 333 pass
screamer 8:a8ac6ed29081 334 else:
screamer 8:a8ac6ed29081 335 self.module_add(name, size, section)
screamer 8:a8ac6ed29081 336
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 337 def parse_map_file_iar(self, file_desc):
screamer 29:1210849dba19 338 """ Main logic to decode IAR map files
screamer 29:1210849dba19 339
screamer 29:1210849dba19 340 Positional arguments:
screamer 29:1210849dba19 341 file_desc - a file like object to parse as an IAR map file
screamer 8:a8ac6ed29081 342 """
screamer 8:a8ac6ed29081 343
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 344 with file_desc as infile:
screamer 8:a8ac6ed29081 345
screamer 8:a8ac6ed29081 346 # Search area to parse
screamer 8:a8ac6ed29081 347 for line in infile:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 348 if line.startswith(' Section '):
screamer 8:a8ac6ed29081 349 break
screamer 8:a8ac6ed29081 350
screamer 8:a8ac6ed29081 351 # Start decoding the map file
screamer 8:a8ac6ed29081 352 for line in infile:
screamer 8:a8ac6ed29081 353
screamer 8:a8ac6ed29081 354 [name, size, section] = self.parse_section_iar(line)
screamer 8:a8ac6ed29081 355
screamer 8:a8ac6ed29081 356 if size == 0 or name == "" or section == "":
screamer 8:a8ac6ed29081 357 pass
screamer 8:a8ac6ed29081 358 else:
screamer 8:a8ac6ed29081 359 self.module_add(name, size, section)
screamer 8:a8ac6ed29081 360
The Other Jimmy 31:8ea194f6145b 361 def search_objects(self, path):
The Other Jimmy 31:8ea194f6145b 362 """ Searches for object files and creates mapping: object --> module
screamer 29:1210849dba19 363
screamer 29:1210849dba19 364 Positional arguments:
screamer 29:1210849dba19 365 path - the path to an object file
screamer 8:a8ac6ed29081 366 """
screamer 8:a8ac6ed29081 367
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 368 path = path.replace('\\', '/')
screamer 8:a8ac6ed29081 369
screamer 8:a8ac6ed29081 370 # check location of map file
The Other Jimmy 31:8ea194f6145b 371 rex = r'^(.+)' + r'\/(.+\.map)$'
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 372 test_rex = re.match(rex, path)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 373
screamer 8:a8ac6ed29081 374 if test_rex:
The Other Jimmy 31:8ea194f6145b 375 search_path = test_rex.group(1) + '/mbed-os/'
screamer 8:a8ac6ed29081 376 else:
The Other Jimmy 31:8ea194f6145b 377 print "Warning: this doesn't look like an mbed project"
screamer 8:a8ac6ed29081 378 return
screamer 8:a8ac6ed29081 379
screamer 29:1210849dba19 380 for root, _, obj_files in os.walk(search_path):
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 381 for obj_file in obj_files:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 382 if obj_file.endswith(".o"):
screamer 29:1210849dba19 383 module_name, object_name = self.path_object_to_module_name(
screamer 29:1210849dba19 384 os.path.join(root, obj_file))
screamer 8:a8ac6ed29081 385
screamer 8:a8ac6ed29081 386 if object_name in self.object_to_module:
screamer 29:1210849dba19 387 if DEBUG:
screamer 29:1210849dba19 388 print "WARNING: multiple usages of object file: %s"\
screamer 29:1210849dba19 389 % object_name
screamer 29:1210849dba19 390 print " Current: %s" % \
screamer 29:1210849dba19 391 self.object_to_module[object_name]
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 392 print " New: %s" % module_name
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 393 print " "
screamer 8:a8ac6ed29081 394 else:
screamer 8:a8ac6ed29081 395 self.object_to_module.update({object_name:module_name})
screamer 8:a8ac6ed29081 396
screamer 22:9e85236d8716 397 export_formats = ["json", "csv-ci", "table"]
screamer 22:9e85236d8716 398
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 399 def generate_output(self, export_format, file_output=None):
screamer 29:1210849dba19 400 """ Generates summary of memory map data
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 401
screamer 29:1210849dba19 402 Positional arguments:
screamer 29:1210849dba19 403 export_format - the format to dump
screamer 29:1210849dba19 404
screamer 29:1210849dba19 405 Keyword arguments:
screamer 29:1210849dba19 406 file_desc - descriptor (either stdout or file)
The Other Jimmy 31:8ea194f6145b 407
The Other Jimmy 31:8ea194f6145b 408 Returns: generated string for the 'table' format, otherwise None
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 409 """
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 410
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 411 try:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 412 if file_output:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 413 file_desc = open(file_output, 'wb')
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 414 else:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 415 file_desc = sys.stdout
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 416 except IOError as error:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 417 print "I/O error({0}): {1}".format(error.errno, error.strerror)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 418 return False
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 419
screamer 29:1210849dba19 420 to_call = {'json': self.generate_json,
screamer 29:1210849dba19 421 'csv-ci': self.generate_csv,
screamer 29:1210849dba19 422 'table': self.generate_table}[export_format]
The Other Jimmy 31:8ea194f6145b 423 output = to_call(file_desc)
screamer 29:1210849dba19 424
screamer 29:1210849dba19 425 if file_desc is not sys.stdout:
screamer 29:1210849dba19 426 file_desc.close()
screamer 29:1210849dba19 427
The Other Jimmy 31:8ea194f6145b 428 return output
The Other Jimmy 31:8ea194f6145b 429
The Other Jimmy 31:8ea194f6145b 430 def generate_json(self, file_desc):
screamer 29:1210849dba19 431 """Generate a json file from a memory map
screamer 29:1210849dba19 432
screamer 29:1210849dba19 433 Positional arguments:
screamer 29:1210849dba19 434 file_desc - the file to write out the final report to
screamer 29:1210849dba19 435 """
The Other Jimmy 31:8ea194f6145b 436 file_desc.write(json.dumps(self.mem_report, indent=4))
screamer 29:1210849dba19 437 file_desc.write('\n')
screamer 29:1210849dba19 438
The Other Jimmy 31:8ea194f6145b 439 return None
The Other Jimmy 31:8ea194f6145b 440
The Other Jimmy 31:8ea194f6145b 441 def generate_csv(self, file_desc):
screamer 29:1210849dba19 442 """Generate a CSV file from a memoy map
screamer 29:1210849dba19 443
screamer 29:1210849dba19 444 Positional arguments:
screamer 29:1210849dba19 445 file_desc - the file to write out the final report to
screamer 29:1210849dba19 446 """
screamer 29:1210849dba19 447 csv_writer = csv.writer(file_desc, delimiter=',',
The Other Jimmy 31:8ea194f6145b 448 quoting=csv.QUOTE_MINIMAL)
screamer 29:1210849dba19 449
screamer 29:1210849dba19 450 csv_module_section = []
screamer 29:1210849dba19 451 csv_sizes = []
screamer 29:1210849dba19 452 for i in sorted(self.modules):
screamer 29:1210849dba19 453 for k in self.print_sections:
screamer 29:1210849dba19 454 csv_module_section += [i+k]
screamer 29:1210849dba19 455 csv_sizes += [self.modules[i][k]]
screamer 29:1210849dba19 456
screamer 29:1210849dba19 457 csv_module_section += ['static_ram']
The Other Jimmy 31:8ea194f6145b 458 csv_sizes += [self.mem_summary['static_ram']]
screamer 29:1210849dba19 459
screamer 29:1210849dba19 460 csv_module_section += ['heap']
The Other Jimmy 31:8ea194f6145b 461 if self.mem_summary['heap'] == 0:
screamer 29:1210849dba19 462 csv_sizes += ['unknown']
screamer 29:1210849dba19 463 else:
The Other Jimmy 31:8ea194f6145b 464 csv_sizes += [self.mem_summary['heap']]
screamer 29:1210849dba19 465
screamer 29:1210849dba19 466 csv_module_section += ['stack']
The Other Jimmy 31:8ea194f6145b 467 if self.mem_summary['stack'] == 0:
screamer 29:1210849dba19 468 csv_sizes += ['unknown']
screamer 29:1210849dba19 469 else:
The Other Jimmy 31:8ea194f6145b 470 csv_sizes += [self.mem_summary['stack']]
screamer 29:1210849dba19 471
screamer 29:1210849dba19 472 csv_module_section += ['total_ram']
The Other Jimmy 31:8ea194f6145b 473 csv_sizes += [self.mem_summary['total_ram']]
screamer 29:1210849dba19 474
screamer 29:1210849dba19 475 csv_module_section += ['total_flash']
The Other Jimmy 31:8ea194f6145b 476 csv_sizes += [self.mem_summary['total_flash']]
screamer 29:1210849dba19 477
screamer 29:1210849dba19 478 csv_writer.writerow(csv_module_section)
screamer 29:1210849dba19 479 csv_writer.writerow(csv_sizes)
screamer 29:1210849dba19 480
The Other Jimmy 31:8ea194f6145b 481 return None
The Other Jimmy 31:8ea194f6145b 482
The Other Jimmy 31:8ea194f6145b 483 def generate_table(self, file_desc):
screamer 29:1210849dba19 484 """Generate a table from a memoy map
screamer 29:1210849dba19 485
screamer 29:1210849dba19 486 Positional arguments:
screamer 29:1210849dba19 487 file_desc - the file to write out the final report to
The Other Jimmy 31:8ea194f6145b 488
The Other Jimmy 31:8ea194f6145b 489 Returns: string of the generated table
screamer 29:1210849dba19 490 """
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 491 # Create table
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 492 columns = ['Module']
screamer 22:9e85236d8716 493 columns.extend(self.print_sections)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 494
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 495 table = PrettyTable(columns)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 496 table.align["Module"] = "l"
screamer 22:9e85236d8716 497 for col in self.print_sections:
screamer 22:9e85236d8716 498 table.align[col] = 'r'
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 499
screamer 13:ab47a20b66f0 500 for i in list(self.print_sections):
screamer 13:ab47a20b66f0 501 table.align[i] = 'r'
screamer 13:ab47a20b66f0 502
The Other Jimmy 31:8ea194f6145b 503 for i in sorted(self.modules):
The Other Jimmy 31:8ea194f6145b 504 row = [i]
The Other Jimmy 31:8ea194f6145b 505
The Other Jimmy 31:8ea194f6145b 506 for k in self.print_sections:
The Other Jimmy 31:8ea194f6145b 507 row.append(self.modules[i][k])
The Other Jimmy 31:8ea194f6145b 508
The Other Jimmy 31:8ea194f6145b 509 table.add_row(row)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 510
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 511 subtotal_row = ['Subtotals']
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 512 for k in self.print_sections:
The Other Jimmy 31:8ea194f6145b 513 subtotal_row.append(self.subtotal[k])
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 514
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 515 table.add_row(subtotal_row)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 516
The Other Jimmy 31:8ea194f6145b 517 output = table.get_string()
The Other Jimmy 31:8ea194f6145b 518 output += '\n'
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 519
The Other Jimmy 31:8ea194f6145b 520 if self.mem_summary['heap'] == 0:
The Other Jimmy 31:8ea194f6145b 521 output += "Allocated Heap: unknown\n"
screamer 29:1210849dba19 522 else:
The Other Jimmy 31:8ea194f6145b 523 output += "Allocated Heap: %s bytes\n" % \
The Other Jimmy 31:8ea194f6145b 524 str(self.mem_summary['heap'])
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 525
The Other Jimmy 31:8ea194f6145b 526 if self.mem_summary['stack'] == 0:
The Other Jimmy 31:8ea194f6145b 527 output += "Allocated Stack: unknown\n"
screamer 29:1210849dba19 528 else:
The Other Jimmy 31:8ea194f6145b 529 output += "Allocated Stack: %s bytes\n" % \
The Other Jimmy 31:8ea194f6145b 530 str(self.mem_summary['stack'])
screamer 13:ab47a20b66f0 531
The Other Jimmy 31:8ea194f6145b 532 output += "Total Static RAM memory (data + bss): %s bytes\n" % \
The Other Jimmy 31:8ea194f6145b 533 str(self.mem_summary['static_ram'])
The Other Jimmy 31:8ea194f6145b 534 output += "Total RAM memory (data + bss + heap + stack): %s bytes\n" % \
The Other Jimmy 31:8ea194f6145b 535 str(self.mem_summary['total_ram'])
The Other Jimmy 31:8ea194f6145b 536 output += "Total Flash memory (text + data + misc): %s bytes\n" % \
The Other Jimmy 31:8ea194f6145b 537 str(self.mem_summary['total_flash'])
The Other Jimmy 31:8ea194f6145b 538
The Other Jimmy 31:8ea194f6145b 539 return output
screamer 22:9e85236d8716 540
screamer 22:9e85236d8716 541 toolchains = ["ARM", "ARM_STD", "ARM_MICRO", "GCC_ARM", "IAR"]
screamer 22:9e85236d8716 542
The Other Jimmy 31:8ea194f6145b 543 def compute_report(self):
The Other Jimmy 31:8ea194f6145b 544 for k in self.sections:
The Other Jimmy 31:8ea194f6145b 545 self.subtotal[k] = 0
The Other Jimmy 31:8ea194f6145b 546
The Other Jimmy 31:8ea194f6145b 547 for i in sorted(self.modules):
The Other Jimmy 31:8ea194f6145b 548 for k in self.sections:
The Other Jimmy 31:8ea194f6145b 549 self.subtotal[k] += self.modules[i][k]
The Other Jimmy 31:8ea194f6145b 550
The Other Jimmy 31:8ea194f6145b 551 # Calculate misc flash sections
The Other Jimmy 31:8ea194f6145b 552 self.misc_flash_mem = 0
The Other Jimmy 31:8ea194f6145b 553 for i in self.modules:
The Other Jimmy 31:8ea194f6145b 554 for k in self.misc_flash_sections:
The Other Jimmy 31:8ea194f6145b 555 if self.modules[i][k]:
The Other Jimmy 31:8ea194f6145b 556 self.misc_flash_mem += self.modules[i][k]
The Other Jimmy 31:8ea194f6145b 557
The Other Jimmy 31:8ea194f6145b 558 self.mem_summary = {
The Other Jimmy 31:8ea194f6145b 559 'static_ram': (self.subtotal['.data'] + self.subtotal['.bss']),
The Other Jimmy 31:8ea194f6145b 560 'heap': (self.subtotal['.heap']),
The Other Jimmy 31:8ea194f6145b 561 'stack': (self.subtotal['.stack']),
The Other Jimmy 31:8ea194f6145b 562 'total_ram': (self.subtotal['.data'] + self.subtotal['.bss'] +
The Other Jimmy 31:8ea194f6145b 563 self.subtotal['.heap']+self.subtotal['.stack']),
The Other Jimmy 31:8ea194f6145b 564 'total_flash': (self.subtotal['.text'] + self.subtotal['.data'] +
The Other Jimmy 31:8ea194f6145b 565 self.misc_flash_mem),
The Other Jimmy 31:8ea194f6145b 566 }
The Other Jimmy 31:8ea194f6145b 567
The Other Jimmy 31:8ea194f6145b 568 self.mem_report = []
The Other Jimmy 31:8ea194f6145b 569 for i in sorted(self.modules):
The Other Jimmy 31:8ea194f6145b 570 self.mem_report.append({
The Other Jimmy 31:8ea194f6145b 571 "module":i,
The Other Jimmy 31:8ea194f6145b 572 "size":{
The Other Jimmy 31:8ea194f6145b 573 k:self.modules[i][k] for k in self.print_sections
The Other Jimmy 31:8ea194f6145b 574 }
The Other Jimmy 31:8ea194f6145b 575 })
The Other Jimmy 31:8ea194f6145b 576
The Other Jimmy 31:8ea194f6145b 577 self.mem_report.append({
The Other Jimmy 31:8ea194f6145b 578 'summary': self.mem_summary
The Other Jimmy 31:8ea194f6145b 579 })
The Other Jimmy 31:8ea194f6145b 580
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 581 def parse(self, mapfile, toolchain):
screamer 29:1210849dba19 582 """ Parse and decode map file depending on the toolchain
screamer 29:1210849dba19 583
screamer 29:1210849dba19 584 Positional arguments:
screamer 29:1210849dba19 585 mapfile - the file name of the memory map file
screamer 29:1210849dba19 586 toolchain - the toolchain used to create the file
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 587 """
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 588
screamer 22:9e85236d8716 589 result = True
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 590 try:
screamer 29:1210849dba19 591 with open(mapfile, 'r') as file_input:
screamer 29:1210849dba19 592 if toolchain == "ARM" or toolchain == "ARM_STD" or\
screamer 29:1210849dba19 593 toolchain == "ARM_MICRO":
The Other Jimmy 31:8ea194f6145b 594 self.search_objects(os.path.abspath(mapfile))
screamer 22:9e85236d8716 595 self.parse_map_file_armcc(file_input)
screamer 22:9e85236d8716 596 elif toolchain == "GCC_ARM":
screamer 22:9e85236d8716 597 self.parse_map_file_gcc(file_input)
screamer 22:9e85236d8716 598 elif toolchain == "IAR":
The Other Jimmy 31:8ea194f6145b 599 self.search_objects(os.path.abspath(mapfile))
screamer 22:9e85236d8716 600 self.parse_map_file_iar(file_input)
screamer 22:9e85236d8716 601 else:
screamer 22:9e85236d8716 602 result = False
The Other Jimmy 31:8ea194f6145b 603
The Other Jimmy 31:8ea194f6145b 604 self.compute_report()
The Other Jimmy 31:8ea194f6145b 605
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 606 except IOError as error:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 607 print "I/O error({0}): {1}".format(error.errno, error.strerror)
screamer 22:9e85236d8716 608 result = False
screamer 22:9e85236d8716 609 return result
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 610
screamer 8:a8ac6ed29081 611 def main():
screamer 29:1210849dba19 612 """Entry Point"""
screamer 8:a8ac6ed29081 613
The Other Jimmy 31:8ea194f6145b 614 version = '0.3.12'
screamer 8:a8ac6ed29081 615
screamer 8:a8ac6ed29081 616 # Parser handling
screamer 29:1210849dba19 617 parser = argparse.ArgumentParser(
screamer 29:1210849dba19 618 description="Memory Map File Analyser for ARM mbed\nversion %s" %
screamer 29:1210849dba19 619 version)
screamer 8:a8ac6ed29081 620
screamer 29:1210849dba19 621 parser.add_argument(
screamer 29:1210849dba19 622 'file', type=argparse_filestring_type, help='memory map file')
screamer 8:a8ac6ed29081 623
screamer 29:1210849dba19 624 parser.add_argument(
screamer 29:1210849dba19 625 '-t', '--toolchain', dest='toolchain',
screamer 29:1210849dba19 626 help='select a toolchain used to build the memory map file (%s)' %
screamer 29:1210849dba19 627 ", ".join(MemapParser.toolchains),
screamer 29:1210849dba19 628 required=True,
screamer 29:1210849dba19 629 type=argparse_uppercase_type(MemapParser.toolchains, "toolchain"))
screamer 8:a8ac6ed29081 630
screamer 29:1210849dba19 631 parser.add_argument(
screamer 29:1210849dba19 632 '-o', '--output', help='output file name', required=False)
screamer 8:a8ac6ed29081 633
screamer 29:1210849dba19 634 parser.add_argument(
screamer 29:1210849dba19 635 '-e', '--export', dest='export', required=False, default='table',
screamer 29:1210849dba19 636 type=argparse_lowercase_hyphen_type(MemapParser.export_formats,
screamer 29:1210849dba19 637 'export format'),
screamer 29:1210849dba19 638 help="export format (examples: %s: default)" %
screamer 29:1210849dba19 639 ", ".join(MemapParser.export_formats))
screamer 8:a8ac6ed29081 640
screamer 8:a8ac6ed29081 641 parser.add_argument('-v', '--version', action='version', version=version)
The Other Jimmy 31:8ea194f6145b 642
The Other Jimmy 31:8ea194f6145b 643 parser.add_argument('-d', '--detailed', action='store_true', help='Displays the elements in "Misc" in a detailed fashion', required=False)
screamer 8:a8ac6ed29081 644
screamer 8:a8ac6ed29081 645 # Parse/run command
screamer 8:a8ac6ed29081 646 if len(sys.argv) <= 1:
screamer 8:a8ac6ed29081 647 parser.print_help()
screamer 8:a8ac6ed29081 648 sys.exit(1)
screamer 8:a8ac6ed29081 649
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 650
screamer 29:1210849dba19 651 args = parser.parse_args()
screamer 8:a8ac6ed29081 652
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 653 # Create memap object
The Other Jimmy 31:8ea194f6145b 654 memap = MemapParser(detailed_misc=args.detailed)
screamer 8:a8ac6ed29081 655
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 656 # Parse and decode a map file
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 657 if args.file and args.toolchain:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 658 if memap.parse(args.file, args.toolchain) is False:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 659 sys.exit(0)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 660
The Other Jimmy 31:8ea194f6145b 661 returned_string = None
screamer 8:a8ac6ed29081 662 # Write output in file
screamer 8:a8ac6ed29081 663 if args.output != None:
The Other Jimmy 31:8ea194f6145b 664 returned_string = memap.generate_output(args.export, args.output)
screamer 8:a8ac6ed29081 665 else: # Write output in screen
The Other Jimmy 31:8ea194f6145b 666 returned_string = memap.generate_output(args.export)
The Other Jimmy 31:8ea194f6145b 667
The Other Jimmy 31:8ea194f6145b 668 if args.export == 'table' and returned_string:
The Other Jimmy 31:8ea194f6145b 669 print returned_string
screamer 8:a8ac6ed29081 670
screamer 8:a8ac6ed29081 671 sys.exit(0)
screamer 8:a8ac6ed29081 672
screamer 8:a8ac6ed29081 673 if __name__ == "__main__":
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 674 main()