From owner-freebsd-dtrace@FreeBSD.ORG Tue Mar 11 05:34:58 2014 Return-Path: Delivered-To: freebsd-dtrace@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ED2E06EC for ; Tue, 11 Mar 2014 05:34:57 +0000 (UTC) Received: from cain.gsoft.com.au (cain.gsoft.com.au [203.31.81.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 800A32A3 for ; Tue, 11 Mar 2014 05:34:56 +0000 (UTC) Received: from ur.gsoft.com.au (Ur.gsoft.com.au [203.31.81.34]) (authenticated bits=0) by cain.gsoft.com.au (8.14.4/8.14.3) with ESMTP id s2B5YVis022289 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Tue, 11 Mar 2014 16:04:41 +1030 (CST) (envelope-from doconnor@gsoft.com.au) Subject: Re: dtracing static symbols Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Content-Type: multipart/signed; boundary="Apple-Mail=_C881AA60-5F55-42C6-8A24-F625A6763A22"; protocol="application/pgp-signature"; micalg=pgp-sha1 From: "Daniel O'Connor" In-Reply-To: <1394514256.45492.YahooMailBasic@web192604.mail.sg3.yahoo.com> Date: Tue, 11 Mar 2014 16:04:31 +1030 Message-Id: <7C202659-0BD9-4F93-8886-24DD7AEB495F@gsoft.com.au> References: <1394514256.45492.YahooMailBasic@web192604.mail.sg3.yahoo.com> To: Prashanth Kumar X-Mailer: Apple Mail (2.1874) X-Spam-Score: -2.51 () ALL_TRUSTED,BAYES_00,T_RP_MATCHES_RCVD X-Scanned-By: MIMEDefang 2.67 on 203.31.81.10 Cc: freebsd-dtrace@freebsd.org X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Mar 2014 05:34:58 -0000 --Apple-Mail=_C881AA60-5F55-42C6-8A24-F625A6763A22 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 On 11 Mar 2014, at 15:34, Prashanth Kumar wrote: > If the binary being traced has static symbols in its symbol table, = DTrace should > be able to trace the function. Can you describe the example where you = found this > difference in FreeBSD and OSX? Unfortunately the static symbols don't show up in the symbol table (as = shown by nm). Is there a compile or link flag which will change that? Here is an example.. [ur 15:43] ~ >cat static.c #include static void foo(void) { printf("Foo\n"); } void bar(void) { printf("Boo\n"); } int main(int argc, char **argv) { foo(); bar(); return 0; } [ur 15:43] ~ >cc static.c -o static [ur 15:43] ~ >sudo dtrace -Ppid\$target -l -c ./static|less On OSX you see.. ... 956613 pid46749 static foo = return 956614 pid46749 static foo = entry 956615 pid46749 static foo 0 956616 pid46749 static foo 1 956617 pid46749 static foo 4 956618 pid46749 static foo 8 956619 pid46749 static foo f 956620 pid46749 static foo 11 956621 pid46749 static foo 16 956622 pid46749 static foo 19 956623 pid46749 static foo 1d 956624 pid46749 static foo 1e .. (I'm not sure what the various numbers mean) However on FreeBSD you don't see any thing for the binary itself, only = the libraries. This is true even if you build with.. [mdtest 5:22] ~ >cc static.o -o static [mdtest 5:22] ~ >ctfconvert -g -L labelenv static.o [mdtest 5:22] ~ >cc -g static.c -o static.o -c Curiously you also can't run it with -c, I had to put a usleep() at the = start and then use -p. Trying to use -c fails with.. [mdtest 5:25] ~ >sudo dtrace -Ppid\$target -l -c ./static Foo Bar dtrace: failed to control pid 52006: process exited with status 0 FWIW nm on the binary shows both symbols (foo and bar) [mdtest 5:33] ~ >nm static|egrep '(foo|bar)' 0000000000400700 T bar 00000000004006f0 t foo Finally, while -c doesn't work on FreeBSD but actually runs the binary, = -c on OSX works (but the binary isn't executed - or at least you don't = see its output) -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C --Apple-Mail=_C881AA60-5F55-42C6-8A24-F625A6763A22 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iD8DBQFTHqBn5ZPcIHs/zowRAusOAJ9Jo+QUuvnkEWXQvmKGgC5rPYqa/gCfdmjZ UFyYHVj04G71HGtwvVpJsPY= =cMQD -----END PGP SIGNATURE----- --Apple-Mail=_C881AA60-5F55-42C6-8A24-F625A6763A22--