Listing Code and Data Size for Each Source File with GNU and Eclipse
Join the DZone community and get the full member experience.Join For Free
i have used the ‘classic’ codewarrior ide for years, before i moved over to eclipse some years ago. and as with any ide or tool switch, things are different in the ‘new world’. in summary, i don’t want to go back anyway, and eclipse is my development tool of choice now. but from time to time i get challenged about something like “hey, this was possible in the previous tool, so how can i do the same in eclipse?”. as a fan of eclipse, this then gets my attention as i feel that eclipse can do it, and it can do it better. ;-)
so what about this one: in codewarrior the project view lists code and data size for each source file:
codewarrior can easily do this, as it maintains an internal data base of the code and details of each compilation unit/file. to me, that feature is nice, but had not much relevance for me, as this does not tell me what will be the code and data size in the application (.elf) file. because the linker will be smart enough to strip unused functions and data.
anyway, how to do this in eclipse and gnu tools? actually, i have not found a way to show it in a nice view :-(. but i know from my post “ printing code size information in eclipse ” that the ‘size’ utility prints code and data size. but by default only for the application after linking. which is what i need anyway. but what about listing code and date size for the source files?
my solution is to list the object files as ‘other flags’ the ‘print size’ settings in the project:
with the gnu gcc arm embedded (launchpad) 4.8.x it is possible to use wildcards like sources\*.o. this is not supported in the gnu tools in kds, as they are using older or different tools, but you can swap the tools chain, see “ switching arm gnu tool chain and libraries in kinetis design studio “.
i can use relative paths, as at least with the gnu arm eclipse plugins the gnu tools have the ‘output’ folder as current directory:
this then lists the size information at the end of the link phase:
'invoking: cross arm gnu print size' arm-none-eabi-size --format=berkeley sources\events.o sources\main.o generated_code\cpu.o generated_code\wait1.o generated_code\io1.o generated_code\csio1.o "k64_pex_printf.elf" text data bss dec hex filename 12 0 0 12 c sources\events.o 140 0 0 140 8c sources\main.o 108 0 0 108 6c generated_code\cpu.o 188 0 0 188 bc generated_code\wait1.o 824 0 24 848 350 generated_code\io1.o 276 0 0 276 114 generated_code\csio1.o 10572 712 8496 19780 4d44 k64_pex_printf.elf 'finished building: k64_pex_printf.siz'
it is possible to list the code and data size for each source (well, object) file in eclipse. i admit it is not in the project view or in a graphical view, and i need to list the object files individually. so i do not say that eclipse can do the *same*, but i think it is very close ;-)
happy sizing :-)
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.