pw_bloat: Fully specify data sources instead of appending
Instead of appending data sources in addition to memoryregions,
`pw bloat` and `pw_bloat.memory_regions_size_report` are updated
to accept the full list of data sources.
In addition, the default is changed from `memoryregions`, to
`memoryregions,sections` to match the default output from bloaty
for a diff report (albeit with memoryregions enabled).
Change-Id: I42e749bac571365ddcd939e694f14db615e76828
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126914
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
diff --git a/pw_bloat/py/pw_bloat/__main__.py b/pw_bloat/py/pw_bloat/__main__.py
index 5aee9fa..30d3bb2 100644
--- a/pw_bloat/py/pw_bloat/__main__.py
+++ b/pw_bloat/py/pw_bloat/__main__.py
@@ -39,9 +39,9 @@
parser.add_argument(
'-d',
'--data-sources',
- help='Comma-separated list of additional Bloaty data sources to report',
+ help='Comma-separated list of Bloaty data sources to report',
type=lambda s: s.split(','),
- default=(),
+ default=('memoryregions,sections'),
)
parser.add_argument(
'--diff',
@@ -72,7 +72,7 @@
"""
bloaty_tsv = bloat.memory_regions_size_report(
- elf, additional_data_sources=data_sources, extra_args=('--tsv',)
+ elf, data_sources=data_sources, extra_args=('--tsv',)
)
return DataSourceMap.from_bloaty_tsv(bloaty_tsv)
diff --git a/pw_bloat/py/pw_bloat/bloat.py b/pw_bloat/py/pw_bloat/bloat.py
index 0bc5b01..e821e93 100755
--- a/pw_bloat/py/pw_bloat/bloat.py
+++ b/pw_bloat/py/pw_bloat/bloat.py
@@ -116,15 +116,14 @@
def memory_regions_size_report(
elf: Path,
- additional_data_sources: Iterable[str] = (),
+ data_sources: Iterable[str] = (),
extra_args: Iterable[str] = (),
) -> Iterable[str]:
"""Runs a size report on an ELF file using pw_bloat memory region symbols.
Arguments:
elf: The ELF binary on which to run.
- additional_data_sources: Optional hierarchical data sources to display
- following the root memory regions.
+ data_sources: Hierarchical data sources to display.
extra_args: Additional command line arguments forwarded to bloaty.
Returns:
@@ -151,7 +150,7 @@
run_bloaty(
str(elf.resolve()),
bloaty_config.name,
- data_sources=('memoryregions', *additional_data_sources),
+ data_sources=data_sources,
extra_args=extra_args,
)
.decode('utf-8')