Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Apr 1998 14:26:12 +0200 (SAT)
From:      Robert Nordier <rnordier@iafrica.com>
To:        erakupa@kk.etx.ericsson.se (ETX-B-SL Martti Kuparinen)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: how to get number of instructions in a prg
Message-ID:  <199804271226.OAA00569@ceia.nordier.com>
In-Reply-To: <199804270906.LAA08665@kk662.kk.etx.ericsson.se> from ETX-B-SL Martti Kuparinen at "Apr 27, 98 11:06:58 am"

next in thread | previous in thread | raw e-mail | index | archive | help
ETX-B-SL Martti Kuparinen wrote:

> What is the easiest way to count the number of assembler instructions
> in a program?
> 
> In gdb there is the "disassemble function-name" command, but it
> disassembles only the given function. One could of course call this
> several times and each time count the lines, but since a program can
> have several hundred small sub-functions, this method is not the best...

Many compilers will output assembler language if required.  So, if
you're working from source code, something along the following lines
would work:

    cc -S hello.c
    grep -c '^[[:space:]]\{1,\}[a-z]' hello.s

If you working from binaries, you could find yourself a disassembler
such as ndisasm (see nasm in the ports collection).  However,
because disassemblers can't easily distinguish between code and
data (and library code is included, etc), you'd have to work hard
to get accurate figures.

--
Robert Nordier

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804271226.OAA00569>