dtracing static symbols

Daniel O'Connor doconnor at gsoft.com.au
Tue Mar 11 21:24:55 UTC 2014


On 12 Mar 2014, at 2:30, Robert Mustacchi <rm at joyent.com> wrote:
> On 03/10/2014 10:34 PM, Daniel O'Connor wrote:
>> 
>> On 11 Mar 2014, at 15:34, Prashanth Kumar <pra_udupi at 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?
> 
> Because it's a static function the compiler may inline it, which may be
> why you don't actually see an entry in nm nor that it can be found by
> DTrace. You'll want to look at the disassembled output of your program
> to see if it was inlined. Different compilers can and will do different
> things. There generally are flags you can pass to the compiler to tell
> it not to inline it, but that's compiler specific.

I just realised that my test contradicted the statement I made earlier..
However I checked my test program (static.c) and it the functions definitely appear in the symbol table.
[mdtest 21:13] ~ >nm static|egrep '(foo|bar)'
0000000000400600 T bar
0000000000400620 t foo

I also added the noinline attribute for good measure.

It seems that _nothing_ shows up for executables, only shared libraries, this is OK for me since my code resides in a library but it is a bit surprised nonetheless..

>> (I'm not sure what the various numbers mean)
> 
> The pid provider can instrument any instruction in a function, those are
> the instruction offsets.

Ahh, thanks.

--
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






-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-dtrace/attachments/20140312/d1244122/attachment.sig>


More information about the freebsd-dtrace mailing list