mirror of https://github.com/ARMmbed/mbed-os.git
Summarize memory map when --stats-depth is 0
parent
57762fbab8
commit
573fd4f739
|
@ -12,6 +12,7 @@ import csv
|
|||
import json
|
||||
from argparse import ArgumentParser
|
||||
from copy import deepcopy
|
||||
from collections import defaultdict
|
||||
from prettytable import PrettyTable
|
||||
|
||||
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
|
||||
|
@ -54,7 +55,8 @@ class _Parser(object):
|
|||
contents[section] += size
|
||||
return
|
||||
|
||||
new_module = {section: size}
|
||||
new_module = defaultdict(int)
|
||||
new_module[section] = size
|
||||
self.modules[object_name] = new_module
|
||||
|
||||
def module_replace(self, old_object, new_object):
|
||||
|
@ -519,6 +521,7 @@ class MemapParser(object):
|
|||
|
||||
Returns: generated string for the 'table' format, otherwise None
|
||||
"""
|
||||
if depth is None or depth > 0:
|
||||
self.reduce_depth(depth)
|
||||
self.compute_report()
|
||||
try:
|
||||
|
@ -625,10 +628,9 @@ class MemapParser(object):
|
|||
for k in self.sections:
|
||||
self.subtotal[k] = 0
|
||||
|
||||
for i in self.short_modules:
|
||||
for mod in self.modules.values():
|
||||
for k in self.sections:
|
||||
self.short_modules[i].setdefault(k, 0)
|
||||
self.subtotal[k] += self.short_modules[i][k]
|
||||
self.subtotal[k] += mod[k]
|
||||
|
||||
self.mem_summary = {
|
||||
'static_ram': (self.subtotal['.data'] + self.subtotal['.bss']),
|
||||
|
@ -636,11 +638,12 @@ class MemapParser(object):
|
|||
}
|
||||
|
||||
self.mem_report = []
|
||||
for i in sorted(self.short_modules):
|
||||
if self.short_modules:
|
||||
for name, sizes in sorted(self.short_modules.items()):
|
||||
self.mem_report.append({
|
||||
"module":i,
|
||||
"module": name,
|
||||
"size":{
|
||||
k: self.short_modules[i][k] for k in self.print_sections
|
||||
k: sizes.get(k, 0) for k in self.print_sections
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue