Using dtrace to print kernel struct argument

Hi all,

TLDR; I want to print out a complicated struct in a human readable way dtrace. I could manually add in the struct, but there are several nested structs and that gets messy and difficult to replicate very quickly. How does one do this?

Detailed: I am trying to display the print a structure that is returned by the kernel function usbd_get_endpoint. The background is because I am running usbd_transfer_setup but getting an error condition and do not understand why, so I want to instrument usbd_get_endpoint, which is called by usbd_transfer_setup.

I want to print out the struct usb_endpoint in a human readable format. It is located in sys/dev/usb/usbdi.h

Currently I have done this:
Code:
#include <sys/dev/usb/usbdi.h>

fbt::usbd_get_endpoint:return
{
    printf("Exit %d\n", arg0);
}

Here are my outputs:

Code:
[farhan@freebsddev ~]$ sudo dtrace -s usbd_get_endpoint.d
dtrace: failed to compile script usbd_get_endpoint.d: invalid control directive: #include
[farhan@freebsddev ~]$ sudo dtrace -C -s usbd_get_endpoint.d
dtrace: failed to compile script usbd_get_endpoint.d: line 1: invalid type combination
Is including header files possible in dtrace? If so, how is this done?
 
You don't need to include any headers into your script. All types used in kernel are already available via kernel's CTF.
 
Back
Top