mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shawn Willden <shawn-lkml@willden.org>
To: linux-kernel@vger.kernel.org
Subject: What's the best way to instrument a driver?
Date: Wed, 12 Nov 2003 10:00:09 -0700	[thread overview]
Message-ID: <200311121000.09229.shawn-lkml@willden.org> (raw)

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.

             reply	other threads:[~2003-11-12 17:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-12 17:00 Shawn Willden [this message]
2003-11-12 17:35 ` Shawn Willden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200311121000.09229.shawn-lkml@willden.org \
    --to=shawn-lkml@willden.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®