mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* What's the best way to instrument a driver?
@ 2003-11-12 17:00 Shawn Willden
  2003-11-12 17:35 ` Shawn Willden
  0 siblings, 1 reply; 2+ messages in thread
From: Shawn Willden @ 2003-11-12 17:00 UTC (permalink / raw)
  To: linux-kernel

Please excuse the newbie questions here, and feel free to slap me around if 
this is all in some googlable documentation that I haven't been able to 
find:

I need to instrument a driver (currently, a usb device, but I'll probably 
want to do others later, so my question is a bit more general than the 
current need) so that I can see everything that is being sent through.  I 
can think of several ways to go about this, but I thought it might be a 
good idea to ask what would be the simplest/most flexible.

>From what I can see there are two basic approaches:  kernel space and 
userspace.

Since what I want to watch right now is just the data flowing to/from a 
particular USB device, it seems like I could probably just wrap something 
around the appropriate /proc/bus/usb/... file.  Could I create a named 
pipe or something and use that?  Would I be able to see and pass ioctls if 
I did it that way?  Another problem is figuring out a way to convince the 
closed source app I'm trying to watch to use my wrapper file, rather than 
the real one.  Any ideas?

If userspace can't work, then I see a couple of kernel space options:

The first is to create a new "passthrough" device that can wrap another 
device and direct a copy of whatever passes through out to user space.  
The other, less pleasant, alternative is to simply hack driver (usb.c in 
this case, I think) and fill it full of printks.  I don't like that as 
well because it will require me to understand a significant part of the 
driver implementation, which will take time.  Also, all of the data for 
all usb devices passes through that driver, so I'd have to figure out how 
to separate out the data that I care about.

Finally, assuming I end up with a kernel space implementation, what is the 
best way to move the data to userspace?  printk is certainly easy, but I 
understand it has a small buffer.  I suppose it's probably easy to find 
the buffer and increase it.  Is there a better way?

Thanks for any suggestions,

Shawn.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-12 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-12 17:00 What's the best way to instrument a driver? Shawn Willden
2003-11-12 17:35 ` Shawn Willden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®