2
2
# pylint: disable=too-many-arguments, too-many-locals, too-many-branches, too-many-lines, line-too-long, too-many-nested-blocks, too-many-public-methods, too-many-instance-attributes
3
3
# pylint: disable=invalid-name, missing-docstring
4
4
5
- # Memory Map File Analyser for ARM mbed OS
5
+ # Memory Map File Analyser for ARM mbed
6
6
7
7
import sys
8
8
import os
@@ -317,7 +317,7 @@ def search_objects(self, path, toolchain):
317
317
if test_rex :
318
318
search_path = test_rex .group (1 ) + toolchain + '/mbed-os/'
319
319
else :
320
- # It looks this is not an mbed OS project
320
+ # It looks this is not an mbed project
321
321
# object-to-module mapping cannot be generated
322
322
print "Warning: specified toolchain doesn't match with path to the memory map file."
323
323
return
@@ -369,6 +369,9 @@ def generate_output(self, export_format, file_output=None):
369
369
table = PrettyTable (columns )
370
370
table .align ["Module" ] = "l"
371
371
372
+ for i in list (self .print_sections ):
373
+ table .align [i ] = 'r'
374
+
372
375
subtotal = dict ()
373
376
for k in self .sections :
374
377
subtotal [k ] = 0
@@ -399,9 +402,9 @@ def generate_output(self, export_format, file_output=None):
399
402
if export_format == 'json' :
400
403
json_obj .append ({\
401
404
'summary' :{\
402
- 'static_ram ' :(subtotal ['.data' ]+ subtotal ['.bss' ]),\
403
- 'heap ' :(subtotal ['.heap' ]),\
404
- 'stack ' :(subtotal ['.stack' ]),\
405
+ 'total_static_ram ' :(subtotal ['.data' ]+ subtotal ['.bss' ]),\
406
+ 'allocated_heap ' :(subtotal ['.heap' ]),\
407
+ 'allocated_stack ' :(subtotal ['.stack' ]),\
405
408
'total_ram' :(subtotal ['.data' ]+ subtotal ['.bss' ]+ subtotal ['.heap' ]+ subtotal ['.stack' ]),\
406
409
'total_flash' :(subtotal ['.text' ]+ subtotal ['.data' ]+ misc_flash_mem ),}})
407
410
@@ -419,14 +422,20 @@ def generate_output(self, export_format, file_output=None):
419
422
csv_module_section += [i + k ]
420
423
csv_sizes += [self .modules [i ][k ]]
421
424
422
- csv_module_section += ['static_ram ' ]
425
+ csv_module_section += ['total_static_ram ' ]
423
426
csv_sizes += [subtotal ['.data' ]+ subtotal ['.bss' ]]
424
427
425
- csv_module_section += ['heap' ]
426
- csv_sizes += [subtotal ['.heap' ]]
428
+ csv_module_section += ['allocated_heap' ]
429
+ if subtotal ['.heap' ] == 0 :
430
+ csv_sizes += ['unknown' ]
431
+ else :
432
+ csv_sizes += [subtotal ['.heap' ]]
427
433
428
- csv_module_section += ['stack' ]
429
- csv_sizes += [subtotal ['.stack' ]]
434
+ csv_module_section += ['allocated_stack' ]
435
+ if subtotal ['.stack' ] == 0 :
436
+ csv_sizes += ['unknown' ]
437
+ else :
438
+ csv_sizes += [subtotal ['.stack' ]]
430
439
431
440
csv_module_section += ['total_ram' ]
432
441
csv_sizes += [subtotal ['.data' ]+ subtotal ['.bss' ]+ subtotal ['.heap' ]+ subtotal ['.stack' ]]
@@ -440,11 +449,20 @@ def generate_output(self, export_format, file_output=None):
440
449
else : # default format is 'table'
441
450
file_desc .write (table .get_string ())
442
451
file_desc .write ('\n ' )
443
- file_desc .write ("Static RAM memory (data + bss): %s\n " % (str (subtotal ['.data' ]+ subtotal ['.bss' ])))
444
- file_desc .write ("Heap: %s\n " % str (subtotal ['.heap' ]))
445
- file_desc .write ("Stack: %s\n " % str (subtotal ['.stack' ]))
446
- file_desc .write ("Total RAM memory (data + bss + heap + stack): %s\n " % (str (subtotal ['.data' ]+ subtotal ['.bss' ]+ subtotal ['.heap' ]+ subtotal ['.stack' ])))
447
- file_desc .write ("Total Flash memory (text + data + misc): %s\n " % (str (subtotal ['.text' ]+ subtotal ['.data' ]+ misc_flash_mem )))
452
+
453
+ if subtotal ['.heap' ] == 0 :
454
+ file_desc .write ("Allocated Heap: unknown\n " )
455
+ else :
456
+ file_desc .write ("Allocated Heap: %s bytes\n " % str (subtotal ['.heap' ]))
457
+
458
+ if subtotal ['.stack' ] == 0 :
459
+ file_desc .write ("Allocated Stack: unknown\n " )
460
+ else :
461
+ file_desc .write ("Allocated Stack: %s bytes\n " % str (subtotal ['.stack' ]))
462
+
463
+ file_desc .write ("Total Static RAM memory (data + bss): %s bytes\n " % (str (subtotal ['.data' ]+ subtotal ['.bss' ])))
464
+ file_desc .write ("Total RAM memory (data + bss + heap + stack): %s bytes\n " % (str (subtotal ['.data' ]+ subtotal ['.bss' ]+ subtotal ['.heap' ]+ subtotal ['.stack' ])))
465
+ file_desc .write ("Total Flash memory (text + data + misc): %s bytes\n " % (str (subtotal ['.text' ]+ subtotal ['.data' ]+ misc_flash_mem )))
448
466
449
467
if file_desc is not sys .stdout :
450
468
file_desc .close ()
@@ -479,10 +497,10 @@ def parse(self, mapfile, toolchain):
479
497
480
498
def main ():
481
499
482
- version = '0.3.10 '
500
+ version = '0.3.11 '
483
501
484
502
# Parser handling
485
- parser = argparse .ArgumentParser (description = "Memory Map File Analyser for ARM mbed OS \n version %s" % version )
503
+ parser = argparse .ArgumentParser (description = "Memory Map File Analyser for ARM mbed\n version %s" % version )
486
504
487
505
parser .add_argument ('file' , help = 'memory map file' )
488
506
0 commit comments