From owner-freebsd-hackers Mon Apr 27 05:28:45 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id FAA29128 for freebsd-hackers-outgoing; Mon, 27 Apr 1998 05:28:45 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ceia.nordier.com (m1-30-dbn.dial-up.net [196.34.155.30]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA29111 for ; Mon, 27 Apr 1998 05:28:34 -0700 (PDT) (envelope-from rnordier@iafrica.com) Received: (from rnordier@localhost) by ceia.nordier.com (8.8.8/8.6.12) id OAA00569; Mon, 27 Apr 1998 14:26:15 +0200 (SAT) From: Robert Nordier Message-Id: <199804271226.OAA00569@ceia.nordier.com> Subject: Re: how to get number of instructions in a prg In-Reply-To: <199804270906.LAA08665@kk662.kk.etx.ericsson.se> from ETX-B-SL Martti Kuparinen at "Apr 27, 98 11:06:58 am" To: erakupa@kk.etx.ericsson.se (ETX-B-SL Martti Kuparinen) Date: Mon, 27 Apr 1998 14:26:12 +0200 (SAT) Cc: hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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