Bpftrace does not output information from the kernel function

Viewed 15

I am trying to use bpftrace to test a detector which hooks on usb_new_device() function. I want to use this to detect any USB devices that are inserted into the machine.

When I test the detector, I used

sudo bpftrace -e 'kprobe:usb_new_device {$udev = (struct usb_device*)arg0; printf("%s\n%s\n%s\n", str($udev->product), str($udev->manufacturer), str($udev->serial));}' 
Attaching 1 probe...

The program can be attached successfully.

When I insert a usb device on this machine, this program is invoked. But it doesn't output any information, looks like empty string. I wonder if there is anything wrong with the script?

Thanks a ton for any help!

0 Answers
Related