From: Ivan Grokhotkov Date: Fri, 20 Apr 2018 15:55:19 +0000 (+0800) Subject: Merge branch 'feature/idf_size_report_symbols' into 'master' X-Git-Tag: v3.1-beta1~233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e982d4b185460da4499bfe6e6530e4852eb6b9e;p=esp-idf Merge branch 'feature/idf_size_report_symbols' into 'master' Feature/idf-size: report per-archive symbols and their sizes See merge request idf/esp-idf!1956 --- 4e982d4b185460da4499bfe6e6530e4852eb6b9e diff --cc tools/idf_size.py index 90721bf0d2,00fc2fa138..1893082ffb --- a/tools/idf_size.py +++ b/tools/idf_size.py @@@ -205,31 -220,50 +221,53 @@@ def print_detailed_sizes(sections, key "& rodata", "Total") print("%24s %10s %6s %6s %10s %8s %7s" % headings) - for k in sorted(sizes.keys()): + result = {} + for k in (sizes.keys()): v = sizes[k] + result[k] = {} + result[k]["data"] = v.get(".dram0.data", 0) + result[k]["bss"] = v.get(".dram0.bss", 0) + result[k]["iram"] = sum(t for (s,t) in v.items() if s.startswith(".iram0")) + result[k]["flash_text"] = v.get(".flash.text", 0) + result[k]["flash_rodata"] = v.get(".flash.rodata", 0) + result[k]["total"] = sum(result[k].values()) + + def return_total_size(elem): + val = elem[1] + return val["total"] + for k,v in sorted(result.items(), key=return_total_size, reverse=True): if ":" in k: # print subheadings for key of format archive:file sh,k = k.split(":") - if sh != sub_heading: - print(sh) - sub_heading = sh - - data = v.get(".dram0.data", 0) - bss = v.get(".dram0.bss", 0) - iram = sum(t for (s,t) in v.items() if s.startswith(".iram0")) - flash_text = v.get(".flash.text", 0) - flash_rodata = v.get(".flash.rodata", 0) - total = data + bss + iram + flash_text + flash_rodata print("%24s %10d %6d %6d %10d %8d %7d" % (k[:24], - data, - bss, - iram, - flash_text, - flash_rodata, - total)) + v["data"], + v["bss"], + v["iram"], + v["flash_text"], + v["flash_rodata"], + v["total"])) + def print_archive_symbols(sections, archive): + interested_sections = [".dram0.data", ".dram0.bss", ".iram0.text", ".iram0.vectors", ".flash.text", ".flash.rodata"] + result = {} + for t in interested_sections: + result[t] = {} + for section in sections.values(): + section_name = section["name"] + if section_name not in interested_sections: + continue + for s in section["sources"]: + if archive != s["archive"]: + continue + s["sym_name"] = re.sub("(.text.|.literal.|.data.|.bss.|.rodata.)", "", s["sym_name"]); + result[section_name][s["sym_name"]] = result[section_name].get(s["sym_name"], 0) + s["size"] + for t in interested_sections: + print "\nSymbols from section:", t + section_total = 0 + for key,val in sorted(result[t].items(), key=lambda (k,v): v, reverse=True): + print("%s(%d)"% (key.replace(t + ".", ""), val)), + section_total += val + print "\nSection total:",section_total + if __name__ == "__main__": main()