On Apr 7, 2006, at 2:15 PM, Alex Shepherd wrote: > Hi Guys, > > Is there a utility in the WinAVR bundle that can display a sorted > list of > function sizes? Have you tried # sort by size, but mix up ROM and RAM avr-nm --size-sort --print-size -r myprog.elf # Sort first by type of symbol, and then by size avr-nm --size-sort --print-size -r dbg/qdpp.elf | sort +2 -3 +1 -2nr | less # If you'd rather see decimal than hex, then use "-t d" in the command as well: avr-nm -t d --size-sort --print-size -r dbg/qdpp.elf | sort +2 -3 +1 -2nr The output of which looks like (decimal address, decimal size, type, name): 08389700 00000042 B QF_pool_ 08389681 00000018 B QF_active_ 08389671 00000009 B QK_readySet_ 08389746 00000004 B QF_tickCtr_ 08389744 00000002 B QF_subscrList_ 08389750 00000002 B QF_timeEvtListHead_ 08389680 00000001 B QF_intLockNest_ 08389699 00000001 B QF_isrNest_ 08389742 00000001 B QF_maxPool_ 08389743 00000001 B QF_maxSignal_ 08388945 00000008 D QEP_reservedEvt_ 08388864 00000002 D QDPP_table 08388895 00000001 D QK_currPrio_ 00008190 00002252 T vfprintf 00017422 00001714 T QHsm_execTran 00001278 00001030 T Table_serving 00012010 00000562 T QActive_get__ 00011476 00000534 T QActive_postFIFO__ 00016524 00000512 T QHsm_dispatch Read the manpage for avr-nm for a better explanation. B = BSS (uninitialized data) D = initialized data T = ROM (Text) with the lowercase letters standing for "local" rather than "global" (external). The meaning of which varies with language. In C, things that are declared "static" end up being "local" (file scope). You can use the standard Unix commands (which you're probably already familiar with, of course) for selection, paging, redirection, etc. (I'm assuming that WinAVR comes with these? I'm not sure, and I don't have a Windows machine readily at hand.) Anyway, you can get the Cygwin utilities if you don't have a standard set of programs (at a minimum: sed, less, sort, grep, tee; perl, ruby, or awk can make more sophisticated programs easier to write). avr-nm ... | less (page by page) avr-nm ... | grep -i ' T ' (display only ROM (Text) (T or t) symbols) avr-nm ... > someFile.txt (save in a file) avr-nm ... | tee someFile.txt | less (save in a file and also page by page on the screen) etc. You can get endlessly creative with these. Here, for instance, is a one-liner that will display a list of ROM, then RAM objects sorted by size (biggest first by section); "ROM" or "RAM" means external(global), "rom" or "ram" means local. avr-nm -t d --size-sort --print-size -r dbg/qdpp.elf | sed -e 's/ T / ROM /' -e 's/ t / rom /' -e 's/ [DB] / RAM /' -e 's/ [db] / ram /' | sort +2 -3rf +1 -2nr The output of this looks like (address/size/type/name): 00008190 00002252 ROM vfprintf 00017422 00001714 ROM QHsm_execTran 00001278 00001030 ROM Table_serving 00007490 00000700 rom flcvt 00012010 00000562 ROM QActive_get__ 00011476 00000534 ROM QActive_postFIFO__ 00016524 00000512 ROM QHsm_dispatch 00015266 00000468 ROM QMPool_init 00010830 00000460 ROM QK_schedule_ 00014150 00000354 ROM QF_publish 00014504 00000352 ROM QF_tick 00017036 00000336 ROM QHsm_init 00012758 00000332 ROM QActive_subscribe_ 00019250 00000318 ROM __unpack_f 00000292 00000256 ROM QF_log2Lkup 00002308 00000254 ROM philosopherStart 00004090 00000246 ROM displyPhilStat 00013860 00000228 ROM QF_poolInit 00015928 00000224 ROM QTimeEvt_arm__ 00004778 00000218 rom lcd_read ... 00000286 00000006 rom l_this_file 00000195 00000005 rom l_this_file 00000231 00000005 rom __c.1971 00000200 00000004 rom l_this_file 00000236 00000003 rom l_this_file 08388998 00000170 ram l_philo 08389337 00000128 ram UART_TxBuf 08389502 00000128 ram UART1_TxBuf 08389228 00000099 ram l_regPoolSto 08389178 00000050 ram l_philQueueSto 08389700 00000042 RAM QF_pool_ And if you don't want to see addresses, you can do this: avr-nm -t d --size-sort -r dbg/qdpp.elf | sed -e 's/ T / ROM /' -e 's/ t / rom /' -e 's/ [DB] / RAM /' -e 's/ [db] / ram /' | sort +1 -2rf +0 -1nr which gives you this: 00002252 ROM vfprintf 00001714 ROM QHsm_execTran 00001030 ROM Table_serving 00000700 rom flcvt 00000562 ROM QActive_get__ 00000534 ROM QActive_postFIFO__ 00000512 ROM QHsm_dispatch 00000468 ROM QMPool_init 00000460 ROM QK_schedule_ 00000354 ROM QF_publish 00000352 ROM QF_tick 00000336 ROM QHsm_init 00000332 ROM QActive_subscribe_ 00000318 ROM __unpack_f I'm sure once you get the hang of the various utilities this will come naturally. Alternatively, I suppose you could put your favorite commands into shell scripts so you could run them in the future. Enjoy! > I had been using the avr-sizex utility to produce a sorted list of > functions > and their size which is shown below. However the avr-sizex utility > isn't > supplied in the newer WinAVR versions and so I have had to copy it > from > previous ones. > > What are others doing to determine the sizes of functions? > > Cheers > > Alex Shepherd > > ------------------------------------------------------------- > > E:> avr-sizex -m atmega8 -f 8192 -t 500 locochrono.elf > > Flash SRAM EEPROM > ----- ---- ------ > 57% 21% 0% > > Top Functions Top Variables (global/static) > ------------------------------ ------------------------------ > __vector_6 598 bytes LnBuffer 140 bytes > processSVMessage 562 bytes fcSlotData 14 bytes > recvLnMsg 452 bytes fcTimer 7 bytes > sendLocoNetPacketT 316 bytes eeSVRec 5 bytes > fcTimerAction 228 bytes SlowTimerActionLis 2 bytes > processTimerAction 180 bytes FastTimerActionLis 2 bytes > doSVDeferredProces 158 bytes DelayTimerTicks 2 bytes > main 146 bytes lnCompareTarget 2 bytes > sendLocoNetPacket 126 bytes lnRxBuffer 2 bytes > lcd_word 122 bytes lnTxData 2 bytes > processFastClockMe 110 bytes LnPacket 2 bytes > __vector_9 100 bytes ucToggle 1 bytes > displayStats 98 bytes fcState 1 bytes > lcd_init 96 bytes fcFlags 1 bytes > __vector_5 84 bytes fcLastPeriod 1 bytes > encodePeerData 72 bytes lnTxSuccess 1 bytes > addTimerAction 70 bytes lnTxIndex 1 bytes > decodePeerData 68 bytes lnTxLength 1 bytes > lcd_write 60 bytes DeferredProcessing 1 bytes > notifyFastClock 58 bytes DeferredSrcAddr 1 bytes > sendLocoNet4BytePa 52 bytes SvStatus 1 bytes > CheckAddressRange 50 bytes Status 1 bytes > initLocoNet 46 bytes lnCurrentByte 1 bytes > fcDoNotify 44 bytes SlowTimerAccumulat 1 bytes > getLnMsgSize 44 bytes FastTimerTicks 1 bytes > lcd_clrxy 40 bytes lnState 1 bytes > strrev 32 bytes SlowTimerTicks 1 bytes > readSVStorage 32 bytes lnBitCount 1 bytes > initFastClock 32 bytes > lcd_puts 30 bytes > notifyFastClockFra 28 bytes > initTimer 26 bytes > delayTimer 22 bytes > isValidSVStorage 20 bytes > memcpy 18 bytes > writeSVStorage 18 bytes > writeSVDestination 18 bytes > lcd_goto 16 bytes > lcd_clear 14 bytes > memset 14 bytes > SendLAck 12 bytes > recvLocoNetPacket 12 bytes > initLnBuf 12 bytes > delay_short 12 bytes > readSVDestinationI 10 bytes > pollFastClock 10 bytes > lcd_putc 6 bytes > getLnBufStats 6 bytes > resetTimerAction 6 bytes > > > > > > Yahoo! Groups Links > > > > > > > > > -- Ned Konz ned@bike-nomad.com -- Ned Konz MetaMagix embedded consulting MetaMagix@gmail.com
Message
Re: [AVR-Chat] Function size listing
2006-04-08 by Ned Konz
Attachments
- No local attachments were found for this message.