* [PATCH] A new tapset that adds support for tty and serial devices @ 2009-10-20 18:10 leitao 2009-10-20 18:10 ` [PATCH] A new testcase for tty tapset leitao 0 siblings, 1 reply; 9+ messages in thread From: leitao @ 2009-10-20 18:10 UTC (permalink / raw) To: systemtap A new tapset that supports tty devices and consequently serial devices. It is just a basic implementation that can be extended as demands appears --- tapset/tty.stp | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 189 insertions(+), 0 deletions(-) create mode 100644 tapset/tty.stp diff --git a/tapset/tty.stp b/tapset/tty.stp new file mode 100644 index 0000000..73d7d91 --- /dev/null +++ b/tapset/tty.stp @@ -0,0 +1,189 @@ +// tty tapset +// Copyright (C) 2009 IBM Corp. +// +// Author: Breno Leitao <leitao@linux.vnet.ibm.com> +// +// This file is part of systemtap, and is free software. You can +// redistribute it and/or modify it under the terms of the GNU General +// Public License (GPL); either version 2, or (at your option) any +// later version. + +/** + * probe tty.open - Called when a tty is opened + * @inode_number: the inode number + * @inode_state: the inode state + * @inode _flags: the inode flags + * @file_name : the file name + * @file_mode : the file mode + * @file_flags : the file flags + */ +probe tty.open = kernel.function("tty_open") { + inode_number= $inode->i_ino + inode_state = $inode->i_state + inode_flags = $inode->i_flags + + file_name = d_name($filp->f_path->dentry) + file_mode = $filp->f_mode + file_flags = $filp->f_flags +} + +/** + * probe tty.release - Called when the tty is closed + * @inode_number: the inode number + * @inode_state: the inode state + * @inode _flags: the inode flags + * @file_name : the file name + * @file_mode : the file mode + * @file_flags : the file flags + */ +probe tty.release = kernel.function("tty_release") { + inode_number= $inode->i_ino + inode_state = $inode->i_state + inode_flags = $inode->i_flags + + file_name = d_name($filp->f_path->dentry) + file_mode = $filp->f_mode + file_flags = $filp->f_flags +} + +/** + * probe tty.resize - Called when a terminal resize happens + * @name: the tty name + * @old_row: the old row value + * @old_col: the old col value + * @old_ypixel: the old ypixel + * @old_xpixel: the old xpixel + * @new_row: the new row value + * @new_col: the new col value + * @new_ypixel: the new ypixel value + * @new_xpixel: the new xpixel value +*/ +probe tty.resize = kernel.function("tty_do_resize"){ + name = kernel_string($tty->name) + old_row = $tty->winsize->ws_row + old_col = $tty->winsize->ws_col + old_ypixel = $tty->winsize->ws_ypixel + old_xpixel = $tty->winsize->ws_xpixel + + new_row = $ws->ws_row + new_col = $ws->ws_col + new_ypixel = $ws->ws_ypixel + new_xpixel = $ws->ws_xpixel +} + +/** + * probe tty.ioctl - called when a ioctl is request to the tty + * @name: the file name + * @cmd: the ioctl command + * @arg: the ioctl argument + */ +probe tty.ioctl = kernel.function("tty_ioctl"){ + name = kernel_string($file->f_path->dentry->d_iname) + + cmd = $cmd + arg = $arg +} + +/** + * probe tty.init - Called when a tty is being initalized + * @driver_name: the driver name + * @name: the driver .dev_name name + * @module: the module name + */ +probe tty.init = kernel.function("tty_init_dev"){ + driver_name = kernel_string($driver->driver_name) + name = kernel_string($driver->name) + module = kernel_string($driver->owner->name) +} + +/** + * probe tty.register - Called when a tty device is registred + * @driver_name: the driver name + * @name: the driver .dev_name name + * @module: the module name + * @index: the tty index requested + */ +probe tty.register = kernel.function("tty_register_device"){ + driver_name = kernel_string($driver->driver_name) + name = kernel_string($driver->name) + module = kernel_string($driver->owner->name) + index = $index +} + +/** + * probe tty.unregister - Called when a tty device is being unregistered + * @driver_name: the driver name + * @name: the driver .dev_name name + * @module: the module name + * @index: the tty index requested + */ +probe tty.unregister = kernel.function("tty_unregister_device"){ + driver_name = kernel_string($driver->driver_name) + name = kernel_string($driver->name) + module = kernel_string($driver->owner->name) + index = $index +} + +/** + * probe tty.poll - Called when a tty device is being polled + * @file_name: the tty file name + * @wait_key: the wait queue key + */ +probe tty.poll = kernel.function("tty_poll"){ + file_name = d_name($filp->f_path->dentry) + + if ($wait) + wait_key = $wait->key + else + wait_key = 0 +} + +/** + * probe tty.receive - called when a tty receives a message + * @cp: the buffer that was received + * @fp: The flag buffer + * @count: The amount of characters received + * @driver_name: the driver name + * @name: the name of the module file + * @index: The tty Index + * @id: the tty id + */ +probe tty.receive = kernel.function("n_tty_receive_buf"){ + cp = kernel_string($cp) + fp = kernel_string($fp) + count = $count + + driver_name = kernel_string($tty->driver->driver_name) + name = kernel_string($tty->driver->name) + index = $tty->index + id = $tty->magic +} + +/** + * probe tty.write - write to the tty line + * @buffer: the buffer that will be written + * @nr: The amount of characters + * @driver_name: the driver name + * @file_name: the file name lreated to the tty + */ +probe tty.write = kernel.function("n_tty_write"){ + buffer = kernel_string($buf) + nr = $nr + + file_name = d_name($file->f_path->dentry) + driver_name = kernel_string($tty->driver->driver_name) +} + +/** + * probe tty.read - called when a tty line will be read + * @buffer: the buffer that will receive the characters + * @nr: The amount of characters to be read + * @driver_name: the driver name + * @file_name: the file name lreated to the tty + */ +probe tty.read = kernel.function("n_tty_read"){ + buffer = kernel_string($buf) + nr = $nr + file_name = d_name($file->f_path->dentry) + driver_name = kernel_string($tty->driver->driver_name) +} -- 1.6.0.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] A new testcase for tty tapset 2009-10-20 18:10 [PATCH] A new tapset that adds support for tty and serial devices leitao @ 2009-10-20 18:10 ` leitao 2009-10-20 18:10 ` [PATCH] tty: improving the ttyspy example leitao 0 siblings, 1 reply; 9+ messages in thread From: leitao @ 2009-10-20 18:10 UTC (permalink / raw) To: systemtap This is a basic test to assure that the tty tapset is working compiling and working properly --- testsuite/buildok/tty.stp | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) create mode 100755 testsuite/buildok/tty.stp diff --git a/testsuite/buildok/tty.stp b/testsuite/buildok/tty.stp new file mode 100755 index 0000000..0b5018d --- /dev/null +++ b/testsuite/buildok/tty.stp @@ -0,0 +1,51 @@ +#! stap -wp4 + +probe tty.poll{ + printf("Pooling tty %s for wait queue key %d\n", file_name, wait_key); +} + +probe tty.register { + printf("Device registered using index %d using driver %s(%s/%s)\n", index, driver_name, name, module) +} + +probe tty.unregister { + printf("Device registered using index %d using driver %s(%s/%s)\n", index, driver_name, name, module) +} + +probe tty.release { + printf("Closing file %s\n", file_name) + printf("INODE: number %d\nState: %d\nFlag: %d\n", inode_number, inode_state, inode_flags) + printf("File: %s (mode %x flags %x)\n", file_name, file_mode, file_flags) +} + +probe tty.open { + printf("Opening tty file %s\n", file_name) + printf("INODE: number %d\nState: %d\nFlag: %d\n", inode_number, inode_state, inode_flags) + printf("File: %s mode %x flags %x\n", file_name, file_mode, file_flags) +} + +probe tty.resize { + printf("Resizing %s from %dx%d (%d/%d) to %dx%d (%d/%d)\n", name, old_row, old_col, old_xpixel, old_ypixel, + new_row, new_col, new_xpixel, new_ypixel) +} + +probe tty.ioctl { + printf("Ioctling file %s with %d %d\n", name, cmd, arg) +} + +probe tty.init { + printf("new tty with name %s from driver %s and module %s\nn", driver_name, name, module) +} + +probe tty.receive { + printf("Driver %s/%s (%d/%d) received %s (%s) with len %d\n", name, driver_name, index, id, cp, fp, count) +} + + +probe tty.write { + printf("Buffer %s (len %d) wrote on file %s (driver %s)\n", buffer, nr, file_name, driver_name) +} + +probe tty.read { + printf("Reading tty file %s (driver %s) to a buffer with size %d containing %s\n", file_name, driver_name, nr, buffer) +} -- 1.6.0.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] tty: improving the ttyspy example 2009-10-20 18:10 ` [PATCH] A new testcase for tty tapset leitao @ 2009-10-20 18:10 ` leitao 2009-10-20 18:10 ` [PATCH] tty: Adding tty.stp to the documentation leitao 2009-10-20 21:07 ` [PATCH] tty: improving the ttyspy example David Smith 0 siblings, 2 replies; 9+ messages in thread From: leitao @ 2009-10-20 18:10 UTC (permalink / raw) To: systemtap This patch just adds some probe examples to ttyspy.stp example. --- testsuite/systemtap.examples/io/ttyspy.stp | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/testsuite/systemtap.examples/io/ttyspy.stp b/testsuite/systemtap.examples/io/ttyspy.stp index 272d82e..1830509 100755 --- a/testsuite/systemtap.examples/io/ttyspy.stp +++ b/testsuite/systemtap.examples/io/ttyspy.stp @@ -44,3 +44,18 @@ probe timer.s(3) { } } +probe tty.receive_buf { + printf("Buffer %s received by driver %s\n", cp, fp, name) +} + +probe tty.put_char { + printf("Char %d sent by driver %s\n", cp, name) +} + +probe tty.write { + printf("buffer %s wrote on %s\n", buffer, file_name) +} + +probe tty.read { + printf("buffer %s read from %s\n", buffer, file_name) +} -- 1.6.0.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] tty: Adding tty.stp to the documentation 2009-10-20 18:10 ` [PATCH] tty: improving the ttyspy example leitao @ 2009-10-20 18:10 ` leitao 2009-10-20 21:23 ` Josh Stone 2009-10-20 21:07 ` [PATCH] tty: improving the ttyspy example David Smith 1 sibling, 1 reply; 9+ messages in thread From: leitao @ 2009-10-20 18:10 UTC (permalink / raw) To: systemtap Adding the TTY tapset to the .tmpl Reference documentation --- doc/SystemTap_Tapset_Reference/tapsets.tmpl | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/doc/SystemTap_Tapset_Reference/tapsets.tmpl b/doc/SystemTap_Tapset_Reference/tapsets.tmpl index 705cd3b..909dcfb 100644 --- a/doc/SystemTap_Tapset_Reference/tapsets.tmpl +++ b/doc/SystemTap_Tapset_Reference/tapsets.tmpl @@ -164,6 +164,15 @@ !Itapset/scsi.stp </chapter> + <chapter id="tty.stp"> + <title>TTY Tapset</title> + <para> + This family of probe points is used to probe TTY (Teletype) activities. + It contains the following probe points: + </para> +!Itapset/scsi.stp + </chapter> + <chapter id="networking.stp"> <title>Networking Tapset</title> <para> -- 1.6.0.2 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] tty: Adding tty.stp to the documentation 2009-10-20 18:10 ` [PATCH] tty: Adding tty.stp to the documentation leitao @ 2009-10-20 21:23 ` Josh Stone 0 siblings, 0 replies; 9+ messages in thread From: Josh Stone @ 2009-10-20 21:23 UTC (permalink / raw) To: leitao; +Cc: systemtap On 10/20/2009 11:08 AM, leitao@linux.vnet.ibm.com wrote: > Adding the TTY tapset to the .tmpl Reference documentation > --- > doc/SystemTap_Tapset_Reference/tapsets.tmpl | 9 +++++++++ > 1 files changed, 9 insertions(+), 0 deletions(-) > > diff --git a/doc/SystemTap_Tapset_Reference/tapsets.tmpl b/doc/SystemTap_Tapset_Reference/tapsets.tmpl > index 705cd3b..909dcfb 100644 > --- a/doc/SystemTap_Tapset_Reference/tapsets.tmpl > +++ b/doc/SystemTap_Tapset_Reference/tapsets.tmpl > @@ -164,6 +164,15 @@ > !Itapset/scsi.stp > </chapter> > > + <chapter id="tty.stp"> > + <title>TTY Tapset</title> > + <para> > + This family of probe points is used to probe TTY (Teletype) activities. > + It contains the following probe points: > + </para> > +!Itapset/scsi.stp > + </chapter> > + Note the copy/paste error on !I... Please double-check that the docs are generated correctly. For example, both tty.open and tty.release* have an extra space: > + * @inode _flags: the inode flags Thanks, Josh * Perhaps this should be called tty.close? I realize that the functions you're probing have these imbalanced names, but that doesn't mean we have to follow suit in the tapset. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] tty: improving the ttyspy example 2009-10-20 18:10 ` [PATCH] tty: improving the ttyspy example leitao 2009-10-20 18:10 ` [PATCH] tty: Adding tty.stp to the documentation leitao @ 2009-10-20 21:07 ` David Smith 2009-10-21 13:34 ` Breno Leitao 1 sibling, 1 reply; 9+ messages in thread From: David Smith @ 2009-10-20 21:07 UTC (permalink / raw) To: leitao; +Cc: systemtap In general, the tapset and testcase look fine. There are two questions I have that I've asked about below. But, I'm not sure these changes improves the ttyspy.stp example. I've never actually run it, but I believe your changes will display data that the existing probes have already printed (and disrupt the output formatting). On 10/20/2009 01:08 PM, leitao@linux.vnet.ibm.com wrote: > This patch just adds some probe examples to ttyspy.stp example. > --- > testsuite/systemtap.examples/io/ttyspy.stp | 15 +++++++++++++++ > 1 files changed, 15 insertions(+), 0 deletions(-) > > diff --git a/testsuite/systemtap.examples/io/ttyspy.stp b/testsuite/systemtap.examples/io/ttyspy.stp > index 272d82e..1830509 100755 > --- a/testsuite/systemtap.examples/io/ttyspy.stp > +++ b/testsuite/systemtap.examples/io/ttyspy.stp > @@ -44,3 +44,18 @@ probe timer.s(3) { > } > } > > +probe tty.receive_buf { > + printf("Buffer %s received by driver %s\n", cp, fp, name) > +} Shouldn't this be 'tty.receive', not 'tty.receive_buf'? > + > +probe tty.put_char { > + printf("Char %d sent by driver %s\n", cp, name) > +} I don't see a 'tty.put_char' probe in the tapset. Was this supposed to be something else? > +probe tty.write { > + printf("buffer %s wrote on %s\n", buffer, file_name) > +} > + > +probe tty.read { > + printf("buffer %s read from %s\n", buffer, file_name) > +} -- David Smith dsmith@redhat.com Red Hat http://www.redhat.com 256.217.0141 (direct) 256.837.0057 (fax) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] tty: improving the ttyspy example 2009-10-20 21:07 ` [PATCH] tty: improving the ttyspy example David Smith @ 2009-10-21 13:34 ` Breno Leitao 2009-10-21 13:46 ` David Smith 0 siblings, 1 reply; 9+ messages in thread From: Breno Leitao @ 2009-10-21 13:34 UTC (permalink / raw) To: David Smith; +Cc: systemtap David Smith wrote: > In general, the tapset and testcase look fine. There are two questions > I have that I've asked about below. > > But, I'm not sure these changes improves the ttyspy.stp example. I've > never actually run it, but I believe your changes will display data that > the existing probes have already printed (and disrupt the output > formatting). Yes. That is true. What is your suggestion here ? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] tty: improving the ttyspy example 2009-10-21 13:34 ` Breno Leitao @ 2009-10-21 13:46 ` David Smith 2009-10-21 14:03 ` Breno Leitao 0 siblings, 1 reply; 9+ messages in thread From: David Smith @ 2009-10-21 13:46 UTC (permalink / raw) To: Breno Leitao; +Cc: systemtap On 10/21/2009 08:31 AM, Breno Leitao wrote: > David Smith wrote: >> In general, the tapset and testcase look fine. There are two questions >> I have that I've asked about below. >> >> But, I'm not sure these changes improves the ttyspy.stp example. I've >> never actually run it, but I believe your changes will display data that >> the existing probes have already printed (and disrupt the output >> formatting). > > Yes. That is true. What is your suggestion here ? I guess I wouldn't change ttyspy.stp. If you'd like, create your own example script that shows off the tty tapset. -- David Smith dsmith@redhat.com Red Hat http://www.redhat.com 256.217.0141 (direct) 256.837.0057 (fax) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] tty: improving the ttyspy example 2009-10-21 13:46 ` David Smith @ 2009-10-21 14:03 ` Breno Leitao 0 siblings, 0 replies; 9+ messages in thread From: Breno Leitao @ 2009-10-21 14:03 UTC (permalink / raw) To: David Smith; +Cc: systemtap David Smith wrote: > On 10/21/2009 08:31 AM, Breno Leitao wrote: >> David Smith wrote: >>> In general, the tapset and testcase look fine. There are two questions >>> I have that I've asked about below. >>> >>> But, I'm not sure these changes improves the ttyspy.stp example. I've >>> never actually run it, but I believe your changes will display data that >>> the existing probes have already printed (and disrupt the output >>> formatting). >> Yes. That is true. What is your suggestion here ? > > I guess I wouldn't change ttyspy.stp. If you'd like, create your own > example script that shows off the tty tapset. Ok. I just changed ttyspy.stp because Frank has asked me to put there my "new" receive and write probes. So, with those other fixes and without touching the ttyspy.stp, can I push my patches ? ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-10-21 14:03 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-10-20 18:10 [PATCH] A new tapset that adds support for tty and serial devices leitao 2009-10-20 18:10 ` [PATCH] A new testcase for tty tapset leitao 2009-10-20 18:10 ` [PATCH] tty: improving the ttyspy example leitao 2009-10-20 18:10 ` [PATCH] tty: Adding tty.stp to the documentation leitao 2009-10-20 21:23 ` Josh Stone 2009-10-20 21:07 ` [PATCH] tty: improving the ttyspy example David Smith 2009-10-21 13:34 ` Breno Leitao 2009-10-21 13:46 ` David Smith 2009-10-21 14:03 ` Breno Leitao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).