Commit graph

18 commits

Author SHA1 Message Date
Daniel Leung ba5f627815 scripts: size_report: rework to use pyelftools...
...instead of GNU binutils to extract DWARF information.
This is now a bit more portable across OS and toolchain.
One bouns is that this nows with on qemu_x86_64.

A few differences are:
() z_mrsh_* which are aliases to handler_no_syscalls() are now
   dropped as they are mapped to the same address, so that they
   are not counted multiple times.
() Static functions and variables with same names should now be
   attributed to the correct source files instead of being
   accumulated into the same symbol of one file (e.g. multiple
   thread_entry() in kernel tests).
() The totals for ROM and RAM are calculated from the
   corresponding sections. Previous script includes the debug
   sections as total ROM size which is not entirely correct.

Fixes #22996

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-07-16 12:14:22 +02:00
Ulf Magnusson d8accb55d1 scripts: footprint: Fix pylint warnings
- Remove unused variables and an unused 'sys' import

 - Simplify 'if len(foo) != 0' to 'if foo'. Non-empty lists/dicts/etc.
   are truthy in Python.

 - Use a raw string to fix this warning:

       scripts/footprint/size_report:270:0: W1401: Anomalous backslash
       in string: '\.'. String constant might be missing an r prefix.
       (anomalous-backslash-in-string)

   The issue is that '\.' just happens to work due to not being
   recognized as an escape sequence.

   Escape sequences are not interpreted in raw strings, so they're safer
   for regexes.

 - Replace 'is 0' with '== 0'. 'is' is for testing object identity, and
   0 isn't guaranteed to be a unique object (but always is in practice).

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-09-14 13:35:08 +08:00
Sebastian Bøe b8d4a77ecd size_report: Don't crash when observing stripped symbols
When stripped symbols are present in the build size_report has crashed
due to it not being aware of this case.

This patch causes stripped symbols to be ignored instead, allowing
analysis of the non-stripped symbols.

It is left as future work to somehow display how much space stripped
symbols are taking up.

Stripped symbols can be present when third-party binaries are linked
into the build.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-07-05 14:18:49 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Paul Sokolovsky c2a70a2710 scripts: size_report: Fix output of header break line
Was apparently an artifact of Python2 to Python3 conversion. Led to
printing of literal '='*110i instead of a line of ='s.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-02-28 09:23:16 -08:00
Kumar Gala 73c7cd184b size_report: cleanup up detection and error handling
We first check to see if we have a valid elf file before doing anything
else.  Otherwise we'd could get script errors instead of just notifying
the user the file doesn't exist.

Signed-off-by: Kumar Gala <kumar.gala@gmail.com>
2018-10-29 10:15:17 -04:00
Kumar Gala f6af3ed14a size_report: Mark arguments as required
We need a minimum of --outdir, --objdump, and --nm set for the script to
work so mark these arguments as required.

Signed-off-by: Kumar Gala <kumar.gala@gmail.com>
2018-10-29 10:15:17 -04:00
Kumar Gala a4173329d4 size_report: convert to use argparser as optparse has been deprecated
Do a straight forward conversion from optparse to argparser.  All
of our other python scripts use argparser already.

Signed-off-by: Kumar Gala <kumar.gala@gmail.com>
2018-10-29 10:15:17 -04:00
Sebastian Bøe d5216a5299 size_report: Don't assume all paths start with ZEPHYR_BASE
Instead of crashing when a source file outside of ZEPHYR_BASE is
detected we accept it as-is to include it in the report.

This fixes #5866

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-29 23:59:16 +05:30
Anas Nashif de713534b6 size_report: create a main() function
Refactor code and add main() function.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-29 05:16:52 +05:30
Anas Nashif de311407bd scripts: fix ram_reports and generate bin file if missing
Some boards do not generate .bin files by default, this file is however
needed when generating ram/rom reports, so in case it is not present,
create it.

Fixes #5784

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-29 05:16:52 +05:30
Sebastian Bøe 4bd904ccae size_report: Ported to native Windows
size_report was assuming Unix-style absolute paths and misbehaving
when paths had a colon ("C:\") in them. Also, refactored and improved
documentation.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-24 06:47:20 +05:30
Sebastian Bøe cfca2dbfa3 size_report: Use Universal newlines when calling check_output
Use Universal newlines when calling check_output and rely on the
locale's encoding to decode the output instead of explicitly decoding
UTF-8.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-24 06:47:20 +05:30
Sebastian Bøe 8569b28596 size_report: Don't use colors on Windows
Colours are rely on ANSI escape codes that are not supported on
Windows.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-24 06:47:20 +05:30
Sebastian Bøe 91d9fe7f5e size_report: Use "Universal newlines" to fix ram_report on Windows
size_report was assuming that the GNU Binutils programs were
generating files with the line ending '\n'. But on native Windows
binutils will generate files with the line ending \r\n.

This patches size_report to use so-called "Universal newlines"[0], so
that size_report can deal with any kind of newline on any kind of
platform.

[0] https://www.python.org/dev/peps/pep-0278/

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-24 06:47:20 +05:30
Anas Nashif 7256553955 scripts: python: cleanup script and fix PEP8 issues
Ran scripts through flake8 and fixed issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-03 19:03:41 -05:00
Sebastian Bøe c87d262295 size_report: Use the CMake-discovered toolchain instead of ENV vars
size_report was using the environment variables NM and OBJDUMP to find
it's toolchain dependencies. It is not clear how well this will work
on different platforms; OSX, Windows. So we now pass the paths of
these dependencies from the build system to the script.

PS: This ensures that size_report uses the cross-compiler's GNU bin
tool instead of the host GNU bin tools. This is presumably beneficial
as it has been required for other GNU bin tools like GDB.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2017-12-12 11:42:05 -05:00
Anas Nashif 38625607b1 scripts: move footprint scripts to footprint/
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-09-11 08:53:56 -07:00