Looking at an assembly listing of your code is the most direct method for finding out details of space allocation. On my Ubuntu Linux system, I use a shell script (that is, a file containing shell commands) like the following to produce an assembly listing of the most-recently-compiled
.ino file, which must be in the working directory when the script executes:
# Look for .ino in current directory, and find recent /tmp/build...
[ -z "$item" ] && echo ino file not found && exit
BDIR=/tmp/$(ls -t /tmp | egrep -m1 build.*tmp)
BASE=$(basename $item .ino)
avr-objdump -S -I$PWD $BDIR/$BASE.cpp.elf > $BASE.ino.asm
All the stuff before the
avr-objdump line allows the script to find out the name of the current
.ino file and the name of the
/tmp/ subdirectory where the
.elf file is found.
You can also use
avr-objdump to get a more concise size listing, as follows, where
$BASE are as in the script above and represent the build directory in
/tmp/, and the basename of the
avr-objdump -C -d $BDIR/$BASE.cpp.o| egrep -C2 '^Disassembly' | egrep -v '^--|^$|^Disassembly' | less
This will produce a list with two-line entries like the following, in which each line beginning with 00000000 is a subroutine name, and the next line shows the last line of its compiled code. In this example output, the
setup_PowerDown() routine has
0xA4 bytes of code, ISR
0x10 bytes, etc.
a4: 08 95 ret
c6: 18 95 reti
10: 08 95 ret
00000000 <eeWrite1(unsigned char, unsigned char)>:
3a: 08 95 ret
00000000 <eeWrite2(unsigned char, unsigned char)>:
18: 0c 94 00 00 jmp 0 ; 0x0 <eeWrite2(unsigned char, unsigned char)>
00000000 <parValidate(unsigned char, unsigned char, unsigned char)>:
64: 08 95 ret
e0: 08 95 ret
84: 08 95 ret
Some IDEs provide symbol table information that includes sizes of routines, stack frames, and data. I don't know if that's available via Arduino IDE, AVR-libc, or GNU Binutils. The symbol table provided by
avr-readelf -s (as in following command) provides quite detailed symbol information that seems quite useless in its raw form.
avr-readelf -s $BDIR/$BASE.cpp.o
The methods described above are somewhat ad hoc, and depend on files left after
avr-g++ run. I don't know of any “official” methods for getting the information you want to see.