Skip to content

Enhance memap, and configure depth level #4766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

theotherjimmy
Copy link
Contributor

Generates a detailed report by analysing static memory information from the map file.

The information from the map file is combined with the information from the BUILD directory (compiled objects and path to these objects), including the main application and user libraries.

In addition, it's now possible to visualise compiler libraries and identify other miscellaneous objects introduced by the toolchain.

By default, memap generates a report with depth=2, but it's possible to specify a different depth level, and even to enable a full report (depth=0).

It has been tested with the three major toolchains: GCC, ARM and IAR compiler.

Status

READY

Migrations

NO

Todos

@sg- @theotherjimmy @screamerbg please review

Usage

$ mbed compile -t <toolchain> -m <target>    # displays memap info with depth=2 (default)
$ python mbed-os/tools/memap.py BUILD/<TARGET>/<TOOLCHAIN>/<memap-file.map> -t <TOOLCHAIN> -d <DEPTH_LEVEL>

Examples

$ python mbed-os/tools/memap.py BUILD/K64F/GCC_ARM/example.map -t GCC_ARM -d 1
+-----------+-------+-------+-------+
| Module    | .text | .data |  .bss |
+-----------+-------+-------+-------+
| [fill]    |    62 |     4 |  2513 |
| [lib]     | 26514 |  2212 |    84 |
| main.o    |    56 |     0 |     4 |
| mbed-os   | 17487 |    40 |  7719 |
| Subtotals | 44119 |  2256 | 10320 |
+-----------+-------+-------+-------+
Allocated Heap: 24576 bytes
Allocated Stack: unknown
Total Static RAM memory (data + bss): 12576 bytes
Total RAM memory (data + bss + heap + stack): 37152 bytes
Total Flash memory (text + data + misc): 47415 bytes

$ python mbed-os/tools/memap.py BUILD/K64F/GCC_ARM/example.map -t GCC_ARM -d 2
+------------------+-------+-------+-------+
| Module           | .text | .data |  .bss |
+------------------+-------+-------+-------+
| [fill]           |    62 |     4 |  2513 |
| [lib]/libc.a     | 22434 |  2204 |    56 |
| [lib]/libgcc.a   |  3728 |     0 |     0 |
| [lib]/libm.a     |    88 |     0 |     0 |
| [lib]/libnosys.a |    32 |     0 |     0 |
| [lib]/misc       |   232 |     8 |    28 |
| main.o           |    56 |     0 |     4 |
| mbed-os/features |    42 |     0 |   184 |
| mbed-os/hal      |   450 |     0 |     8 |
| mbed-os/platform |  1252 |     4 |   269 |
| mbed-os/rtos     |  5955 |    24 |  6874 |
| mbed-os/targets  |  9788 |    12 |   384 |
| Subtotals        | 44119 |  2256 | 10320 |
+------------------+-------+-------+-------+
Allocated Heap: 24576 bytes
Allocated Stack: unknown
Total Static RAM memory (data + bss): 12576 bytes
Total RAM memory (data + bss + heap + stack): 37152 bytes
Total Flash memory (text + data + misc): 47415 bytes

$ python mbed-os/tools/memap.py BUILD/K64F/GCC_ARM/example.map -t GCC_ARM -d 3
+----------------------------------------+-------+-------+-------+
| Module                                 | .text | .data |  .bss |
+----------------------------------------+-------+-------+-------+
| [fill]                                 |    62 |     4 |  2513 |
| [lib]/libc.a/lib_a-abort.o             |    16 |     0 |     0 |
| [lib]/libc.a/lib_a-assert.o            |   123 |     0 |     0 |
| [lib]/libc.a/lib_a-callocr.o           |    96 |     0 |     0 |
| [lib]/libc.a/lib_a-closer.o            |    36 |     0 |     0 |
| [lib]/libc.a/lib_a-dtoa.o              |  4044 |     0 |     0 |
| [lib]/libc.a/lib_a-errno.o             |    12 |     0 |     0 |
| [lib]/libc.a/lib_a-fclose.o            |   132 |     0 |     0 |
| [lib]/libc.a/lib_a-fflush.o            |   420 |     0 |     0 |
| [lib]/libc.a/lib_a-findfp.o            |   272 |     0 |     0 |
| [lib]/libc.a/lib_a-fiprintf.o          |    40 |     0 |     0 |
| [lib]/libc.a/lib_a-fputwc.o            |   212 |     0 |     0 |
| [lib]/libc.a/lib_a-freer.o             |   588 |     0 |     0 |
| [lib]/libc.a/lib_a-fstatr.o            |    40 |     0 |     0 |
| [lib]/libc.a/lib_a-fvwrite.o           |   792 |     0 |     0 |
| [lib]/libc.a/lib_a-fwalk.o             |    84 |     0 |     0 |
| [lib]/libc.a/lib_a-impure.o            |     6 |  1068 |     0 |
| [lib]/libc.a/lib_a-init.o              |    80 |     0 |     0 |
| [lib]/libc.a/lib_a-isattyr.o           |    36 |     0 |     0 |
| [lib]/libc.a/lib_a-locale.o            |    40 |    92 |     0 |
| [lib]/libc.a/lib_a-lseekr.o            |    40 |     0 |     0 |
| [lib]/libc.a/lib_a-makebuf.o           |   224 |     0 |     0 |
| [lib]/libc.a/lib_a-mallocr.o           |  1316 |  1040 |    52 |
| [lib]/libc.a/lib_a-memchr.o            |   148 |     0 |     0 |
| [lib]/libc.a/lib_a-memcpy.o            |   308 |     0 |     0 |
| [lib]/libc.a/lib_a-memmove.o           |   200 |     0 |     0 |
| [lib]/libc.a/lib_a-memset.o            |   156 |     0 |     0 |
| [lib]/libc.a/lib_a-mprec.o             |  1764 |     0 |     0 |
| [lib]/libc.a/lib_a-readr.o             |    40 |     0 |     0 |
| [lib]/libc.a/lib_a-reallocr.o          |  1004 |     0 |     0 |
| [lib]/libc.a/lib_a-reent.o             |     0 |     0 |     4 |
| [lib]/libc.a/lib_a-sbrkr.o             |    36 |     0 |     0 |
| [lib]/libc.a/lib_a-signal.o            |   104 |     0 |     0 |
| [lib]/libc.a/lib_a-signalr.o           |    44 |     0 |     0 |
| [lib]/libc.a/lib_a-stdio.o             |   132 |     0 |     0 |
| [lib]/libc.a/lib_a-strlen.o            |    92 |     0 |     0 |
| [lib]/libc.a/lib_a-svfiprintf.o        |   260 |     0 |     0 |
| [lib]/libc.a/lib_a-svfprintf.o         |  5426 |     0 |     0 |
| [lib]/libc.a/lib_a-vfiprintf.o         |  3407 |     0 |     0 |
| [lib]/libc.a/lib_a-vsnprintf.o         |   148 |     0 |     0 |
| [lib]/libc.a/lib_a-wbuf.o              |   168 |     0 |     0 |
| [lib]/libc.a/lib_a-wcrtomb.o           |    84 |     0 |     0 |
| [lib]/libc.a/lib_a-wctomb_r.o          |    28 |     4 |     0 |
| [lib]/libc.a/lib_a-writer.o            |    40 |     0 |     0 |
| [lib]/libc.a/lib_a-wsetup.o            |   196 |     0 |     0 |
| [lib]/libgcc.a/_aeabi_uldivmod.o       |    48 |     0 |     0 |
| [lib]/libgcc.a/_arm_addsubdf3.o        |   880 |     0 |     0 |
| [lib]/libgcc.a/_arm_cmpdf2.o           |   272 |     0 |     0 |
| [lib]/libgcc.a/_arm_fixdfsi.o          |    80 |     0 |     0 |
| [lib]/libgcc.a/_arm_muldivdf3.o        |  1060 |     0 |     0 |
| [lib]/libgcc.a/_divdi3.o               |   668 |     0 |     0 |
| [lib]/libgcc.a/_dvmd_tls.o             |     4 |     0 |     0 |
| [lib]/libgcc.a/_udivdi3.o              |   620 |     0 |     0 |
| [lib]/libgcc.a/bpabi.o                 |    96 |     0 |     0 |
| [lib]/libm.a/lib_a-s_fpclassify.o      |    88 |     0 |     0 |
| [lib]/libnosys.a/getpid.o              |    16 |     0 |     0 |
| [lib]/libnosys.a/kill.o                |    16 |     0 |     0 |
| [lib]/misc/crt0.o                      |   116 |     0 |     0 |
| [lib]/misc/crtbegin.o                  |    92 |     4 |    28 |
| [lib]/misc/crtend.o                    |     0 |     4 |     0 |
| [lib]/misc/crti.o                      |     8 |     0 |     0 |
| [lib]/misc/crtn.o                      |    16 |     0 |     0 |
| main.o                                 |    56 |     0 |     4 |
| mbed-os/features/storage               |    42 |     0 |   184 |
| mbed-os/hal/mbed_gpio.o                |    96 |     0 |     0 |
| mbed-os/hal/mbed_pinmap_common.o       |   242 |     0 |     0 |
| mbed-os/hal/mbed_ticker_api.o          |    72 |     0 |     0 |
| mbed-os/hal/mbed_us_ticker_api.o       |    40 |     0 |     8 |
| mbed-os/platform/mbed_alloc_wrappers.o |    16 |     0 |     0 |
| mbed-os/platform/mbed_assert.o         |    85 |     0 |     0 |
| mbed-os/platform/mbed_board.o          |   156 |     0 |     0 |
| mbed-os/platform/mbed_critical.o       |   251 |     0 |     5 |
| mbed-os/platform/mbed_error.o          |    22 |     0 |     0 |
| mbed-os/platform/mbed_retarget.o       |   636 |     4 |   264 |
| mbed-os/platform/mbed_wait_api_rtos.o  |    86 |     0 |     0 |
| mbed-os/rtos/Thread.o                  |    20 |     0 |     4 |
| mbed-os/rtos/rtos_idle.o               |    20 |     4 |     0 |
| mbed-os/rtos/rtx                       |  5915 |    20 |  6870 |
| mbed-os/targets/TARGET_Freescale       |  9788 |    12 |   384 |
| Subtotals                              | 44119 |  2256 | 10320 |
+----------------------------------------+-------+-------+-------+
Allocated Heap: 24576 bytes
Allocated Stack: unknown
Total Static RAM memory (data + bss): 12576 bytes
Total RAM memory (data + bss + heap + stack): 37152 bytes
Total Flash memory (text + data + misc): 47415 bytes

Marcelo Salazar and others added 9 commits May 25, 2017 12:09
- Major refactor to first search objects in filesystem and
  then match with information from map file
- Added support for GCC compiler
- Disabled tests (TODO) and fixed minor issues
- Added support for ARM compiler
- Added support for IAR compiler
- Fixed bug when parsing libraries
- Build generates memap report (default depth=2)
- Clean up
@geky
Copy link
Contributor

geky commented Jul 18, 2017

Was this forked for CI issue?

We have some ongoing issues with this patch unfortunately:
see #4392 (comment)

@theotherjimmy
Copy link
Contributor Author

Yes

@theotherjimmy
Copy link
Contributor Author

Looks like it's fine now. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants