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
|
import json
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from collections import defaultdict
|
||||||
from prettytable import PrettyTable
|
from prettytable import PrettyTable
|
||||||
|
|
||||||
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
|
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
|
||||||
|
@ -54,7 +55,8 @@ class _Parser(object):
|
||||||
contents[section] += size
|
contents[section] += size
|
||||||
return
|
return
|
||||||
|
|
||||||
new_module = {section: size}
|
new_module = defaultdict(int)
|
||||||
|
new_module[section] = size
|
||||||
self.modules[object_name] = new_module
|
self.modules[object_name] = new_module
|
||||||
|
|
||||||
def module_replace(self, old_object, new_object):
|
def module_replace(self, old_object, new_object):
|
||||||
|
@ -519,7 +521,8 @@ class MemapParser(object):
|
||||||
|
|
||||||
Returns: generated string for the 'table' format, otherwise None
|
Returns: generated string for the 'table' format, otherwise None
|
||||||
"""
|
"""
|
||||||
self.reduce_depth(depth)
|
if depth is None or depth > 0:
|
||||||
|
self.reduce_depth(depth)
|
||||||
self.compute_report()
|
self.compute_report()
|
||||||
try:
|
try:
|
||||||
if file_output:
|
if file_output:
|
||||||
|
@ -625,10 +628,9 @@ class MemapParser(object):
|
||||||
for k in self.sections:
|
for k in self.sections:
|
||||||
self.subtotal[k] = 0
|
self.subtotal[k] = 0
|
||||||
|
|
||||||
for i in self.short_modules:
|
for mod in self.modules.values():
|
||||||
for k in self.sections:
|
for k in self.sections:
|
||||||
self.short_modules[i].setdefault(k, 0)
|
self.subtotal[k] += mod[k]
|
||||||
self.subtotal[k] += self.short_modules[i][k]
|
|
||||||
|
|
||||||
self.mem_summary = {
|
self.mem_summary = {
|
||||||
'static_ram': (self.subtotal['.data'] + self.subtotal['.bss']),
|
'static_ram': (self.subtotal['.data'] + self.subtotal['.bss']),
|
||||||
|
@ -636,13 +638,14 @@ class MemapParser(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mem_report = []
|
self.mem_report = []
|
||||||
for i in sorted(self.short_modules):
|
if self.short_modules:
|
||||||
self.mem_report.append({
|
for name, sizes in sorted(self.short_modules.items()):
|
||||||
"module":i,
|
self.mem_report.append({
|
||||||
"size":{
|
"module": name,
|
||||||
k: self.short_modules[i][k] for k in self.print_sections
|
"size":{
|
||||||
}
|
k: sizes.get(k, 0) for k in self.print_sections
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
self.mem_report.append({
|
self.mem_report.append({
|
||||||
'summary': self.mem_summary
|
'summary': self.mem_summary
|
||||||
|
|
Loading…
Reference in New Issue