Date: Tue, 11 Mar 2014 16:04:31 +1030 From: "Daniel O'Connor" <doconnor@gsoft.com.au> To: Prashanth Kumar <pra_udupi@yahoo.co.in> Cc: freebsd-dtrace@freebsd.org Subject: Re: dtracing static symbols Message-ID: <7C202659-0BD9-4F93-8886-24DD7AEB495F@gsoft.com.au> In-Reply-To: <1394514256.45492.YahooMailBasic@web192604.mail.sg3.yahoo.com> References: <1394514256.45492.YahooMailBasic@web192604.mail.sg3.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <pra_udupi@yahoo.co.in> 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 <stdio.h> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7C202659-0BD9-4F93-8886-24DD7AEB495F>