What is wrong with dtrace's stack()?

Alan Somers asomers at freebsd.org
Sun Oct 21 21:46:09 UTC 2018


On Sun, Oct 21, 2018 at 11:27 AM Lev Serebryakov <lev at freebsd.org> wrote:

> Hello Conrad,
>
> Sunday, October 21, 2018, 8:21:43 PM, you wrote:
>
> > Your assembler dump offsets are in decimal.
>  Ooops!
>

Also, rather than inspecting the assembly, you can fire up kgdb and type
(kgdb) list *(soo_write+0x33)
And it will tell you the corresponding source line.


>
> >  Look for offset 0x33 = +51, not +33.
>  It is call to sosend(), which could call many other things, but why it is
> missed at stack output!?
>

dtrace doesn't have visibility into functions that get automatically
inlined.  So effectively it leaves out some stack frames.  Also, dtrace
doesn't indicate when a function got called via a function pointer as
opposed to a direct call.  ipsec_hdrsiz_input, for example, gets called
only via function pointers, referenced by the IPSEC_HDRSIZE macro.  That,
in turn, is called by tcp_output.  Finally, if the compiler uses a tail
call optimization, then dtrace won't see the tail caller's stack frame.  In
your case, it looks like there are several layers that are invisible to
dtrace.  The true stack probably looks something like this:

soo_write->sosend->sosend_generic (via pru_sosend function
pointer)->tcp_usr_send(via pru_send function pointer)->tcp_output(via
tfb_tcp_output function pointer)->IPSEC_HDRSIZE->ipsec_hdrsiz_inpcb (via
hdrsiz function pointer)

Hope that helps.
-Alan


>
> --
> Best regards,
>  Lev                            mailto:lev at FreeBSD.org
>
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>


More information about the freebsd-hackers mailing list