Dwarves Archive on lore.kernel.org
 help / color / Atom feed
From: Arnaldo Carvalho de Melo <acme-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Erik Ekman <yarrick-UYDU3/A3LUY@public.gmane.org>
Cc: dwarves-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Creating ELF function/file size statistics
Date: Thu, 31 Jan 2008 10:23:45 -0200
Message-ID: <20080131122345.GJ1819@ghostprotocols.net> (raw)

> I am doing some developing in C and want to see ELF size per function,
> file and directory. Right now I extract the sizes of functions and
> fields from objdump and use an ugly sed hack to find the file of each
> function/object, and then a python script that does some matching.

> I read about the DWARF format and it seems it includes the things I
> need. The output from objdump -W and eu-readelf -w shows that
> functions and object are tied to a file in some way.

> Does any of the existing dwarf programs do this? pdwtags looked as a
> best fit from reading the OLS paper. I have not fetched the latest
> source yet due to some workplace firewalls. If no tool does this and
> it is possible, then I am interested in developing one.

> Please cc me, i am not on the list.

I had to look up your address on the net and only saw your message today
because I don't use the newsgroups interface regularly, anyway:

pfunct is the tool, look at this, the top 5 functions per .o file on a
directory hierarchy:

[acme@doppio pahole]$ find examples -name "*.o" | while read file ; do \
		echo "---> $file" ; \
		pfunct --sizes $file | sort -k2 -nr | head -5 ; \ 
		echo "--------" ; done
---> examples/qsize.o
operator<<: 164
operator>>: 83
q_atomic_decrement: 25
---> examples/prototype1.o
main: 50
---> examples/qsettings.o
getPath: 1233
checkAccess: 762
globalMutex: 277
iniChopTrailingSpaces: 259
unusedCacheFunc: 229
---> examples/multi-cu/main.o
main: 63
---> examples/multi-cu/a.o
a_foo_print: 29
---> examples/prototype2.o
foo: 27
[acme@doppio pahole]$

There are more options, some useful, some just for laughs, like

----------------------------- 8< -------------------------------------------

[acme@doppio pahole]$ pfunct --help
Usage: pfunct [OPTION...] -e [FILE] {[FUNCTION]}

  -c, --class=CLASS          functions that have CLASS pointer parameters
  -E, --externals            show just external functions
  -f, --function=FUNCTION    show just FUNCTION
  -g, --goto_labels          show number of goto labels
  -G, --cc_uninlined         declared inline, uninlined by compiler
  -H, --cc_inlined           not declared inline, inlined by compiler
  -i, --inline_expansions    show inline expansions
  -I, --inline_expansions_stats   show inline expansions stats
  -l, --decl_info            show source code info
  -N, --function_name_len    show size of functions names
  -p, --nr_parms             show number of parameters
  -s, --sizes                show size of functions
  -S, --nr_variables         show number of variables
  -t, --total_inline_stats   show Multi-CU total inline expansions stats
  -T, --variables            show variables
  -V, --verbose              be verbose

 Input selection options:
      --debuginfo-path=PATH  Search path for separate debuginfo files
  -e, --executable=FILE      Find addresses in FILE
  -k, --kernel               Find addresses in the running kernel
  -K, --offline-kernel[=RELEASE]   Kernel with all modules
  -M, --linux-process-map=FILE   Find addresses in files mapped as read from
                             FILE in Linux /proc/PID/maps format
      --pid=PID              Find addresses in files mapped into process PID

  -?, --help                 Give this help list
      --usage                Give a short usage message

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

----------------------------- 8< -------------------------------------------

- Arnaldo

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 12:23 Arnaldo Carvalho de Melo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-01-28 15:31 Erik Ekman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080131122345.GJ1819@ghostprotocols.net \
    --to=acme-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dwarves-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=yarrick-UYDU3/A3LUY@public.gmane.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Dwarves Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dwarves/0 dwarves/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dwarves dwarves/ https://lore.kernel.org/dwarves \
	public-inbox-index dwarves

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git