This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tapset + testsuite corrections


Frank Ch. Eigler a écrit :

Since we have some interest in keeping tapsets working with older
kernels, we generally need to use kernel version-sensitive
#if/#else/#endif conditional compilation in embedded-C code.

Yes, I had it in mind and took care of this where it was needed. So normally, it should work for both old and new kernels.

(An
analogous %( %? %: %) construct exists for script code, and is
documented in the man pages.)

Thanks for the tip, I did not discover this yet.



That is fine. Please also see src/HACKING for additional guidelines, such as designation of a copyright holder for your changes.

Ok, thanks.


I've attached the same patch, with updates, and unified style this time.
Here is the Changelog:

	* tapset/LKET/nfs.stp, tapset/nfs.stp, tapset/vfs.stp: local variables
	f_dentry renamed, because conflicting with a new #define in kernel
	header linux/fs.h in 2.6.20.
	* tapset/rpc.stp: struct rpc_xprt modified since kernel 2.6.19.
	* testsuite/buildok/twenty.stp: updated with new struct file since
	kernel 2.6.20
	* testsuite/semok/seventeen.stp: updated with new function name
	since kernel 2.6.19

--
Pierre Peiffer
---
 tapset/ChangeLog              |    7 +++++++
 tapset/LKET/nfs.stp           |    4 ++--
 tapset/nfs.stp                |   22 +++++++++++-----------
 tapset/rpc.stp                |    8 ++++++++
 tapset/vfs.stp                |   28 ++++++++++++++--------------
 testsuite/ChangeLog           |    7 +++++++
 testsuite/buildok/twenty.stp  |    4 ++++
 testsuite/semok/seventeen.stp |    3 ++-
 8 files changed, 55 insertions(+), 28 deletions(-)

Index: src/tapset/LKET/nfs.stp
===================================================================
--- src.orig/tapset/LKET/nfs.stp	2007-02-15 13:10:23.000000000 +0100
+++ src/tapset/LKET/nfs.stp	2007-02-15 13:14:35.000000000 +0100
@@ -1,8 +1,8 @@
 /* Helper functions */
 function __file_fsname:string (file:long) %{ /* pure */
 	struct file *file = (struct file *)(long)THIS->file;
-	struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-	struct inode *d_inode = f_dentry? kread(&(f_dentry->d_inode)) : NULL;
+	struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+	struct inode *d_inode = dentry? kread(&(dentry->d_inode)) : NULL;
 	if (d_inode == NULL)
 		strlcpy(THIS->__retvalue, "NULL", MAXSTRINGLEN);
 	else {
Index: src/tapset/nfs.stp
===================================================================
--- src.orig/tapset/nfs.stp	2007-02-15 13:10:24.000000000 +0100
+++ src/tapset/nfs.stp	2007-02-15 13:14:35.000000000 +0100
@@ -197,21 +197,21 @@ function __d_loff_t :long (ppos :long) %
 
 function __file_inode:long (file:long) %{ /* pure */
     struct file *file = (struct file *)(long)THIS->file;
-    struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-    if (f_dentry == NULL)
+    struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+    if (dentry == NULL)
         THIS->__retvalue = 0;
     else
-        THIS->__retvalue = (long)kread(&(f_dentry->d_inode));
+        THIS->__retvalue = (long)kread(&(dentry->d_inode));
     CATCH_DEREF_FAULT();
 %}
 
 function __file_id:long (file:long) %{ /* pure */
     struct file *file = (struct file *)(long)THIS->file;
-    struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-    if (f_dentry == NULL)
+    struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+    if (dentry == NULL)
         THIS->__retvalue = 0;
     else {
-        struct inode *d_inode = kread(&(f_dentry->d_inode));
+        struct inode *d_inode = kread(&(dentry->d_inode));
         struct super_block *i_sb = kread(&(d_inode->i_sb));
         THIS->__retvalue = (long)&(i_sb->s_id);
     }
@@ -220,11 +220,11 @@ function __file_id:long (file:long) %{ /
 
 function __file_mode:long (file:long) %{ /* pure */
     struct file *file = (struct file *)(long)THIS->file;
-    struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-    if (f_dentry == NULL)
+    struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+    if (dentry == NULL)
         THIS->__retvalue = 0;
     else {
-        struct inode *d_inode = kread(&(f_dentry->d_inode));
+        struct inode *d_inode = kread(&(dentry->d_inode));
         THIS->__retvalue = kread(&(d_inode->i_mode));
     }
     CATCH_DEREF_FAULT();
@@ -232,8 +232,8 @@ function __file_mode:long (file:long) %{
 
 function __file_parentname:string (file:long) %{ /* pure */
     struct file *file = (struct file *)(long)THIS->file;
-    struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-    struct dentry *d_parent = f_dentry? kread(&(f_dentry->d_parent)) : NULL;
+    struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+    struct dentry *d_parent = dentry? kread(&(dentry->d_parent)) : NULL;
     if (d_parent == NULL)
         strlcpy(THIS->__retvalue, "NULL", MAXSTRINGLEN);
     else {
Index: src/tapset/rpc.stp
===================================================================
--- src.orig/tapset/rpc.stp	2007-02-15 13:10:25.000000000 +0100
+++ src/tapset/rpc.stp	2007-02-15 13:14:35.000000000 +0100
@@ -879,9 +879,17 @@ function port_from_clnt:long(clnt:long)
 %{
 	struct rpc_clnt *clnt = (struct rpc_clnt *)(long)THIS->clnt;
 	struct rpc_xprt *cl_xprt = clnt? kread(&(clnt->cl_xprt)) : NULL;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+	if (cl_xprt && kread(&(cl_xprt->addr.ss_family)) == AF_INET) {
+		/* Now consider ipv4 only */
+		struct sockaddr_in *sap = (struct sockaddr_in *) &cl_xprt->addr;
+
+		THIS->__retvalue = ntohs(kread(&(sap->sin_port)));
+#else
 	if (cl_xprt && kread(&(cl_xprt->addr.sin_family)) == AF_INET) {
 		/* Now consider ipv4 only */
 		THIS->__retvalue = ntohs(kread(&(cl_xprt->addr.sin_port)));
+#endif
 	} else
 		THIS->__retvalue = 0;
 	CATCH_DEREF_FAULT();
Index: src/tapset/vfs.stp
===================================================================
--- src.orig/tapset/vfs.stp	2007-02-15 13:10:25.000000000 +0100
+++ src/tapset/vfs.stp	2007-02-15 13:14:35.000000000 +0100
@@ -81,11 +81,11 @@ function __page_bdev:long (page:long) %{
 
 function __file_dev:long (file:long) %{ /* pure */
 	struct file *file = (struct file *)(long)THIS->file;
-	struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-	if (f_dentry == NULL) {
+	struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+	if (dentry == NULL) {
 		THIS->__retvalue = 0;
 	} else {
-		struct inode *d_inode = kread(&(f_dentry->d_inode));
+		struct inode *d_inode = kread(&(dentry->d_inode));
 		struct super_block *i_sb = kread(&(d_inode->i_sb));
 		THIS->__retvalue = kread(&(i_sb->s_dev));
 	}
@@ -94,11 +94,11 @@ function __file_dev:long (file:long) %{ 
 
 function __file_bdev:long (file:long) %{ /* pure */
 	struct file *file = (struct file *)(long)THIS->file;
-	struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-	if (f_dentry == NULL) {
+	struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+	if (dentry == NULL) {
 		THIS->__retvalue = 0;
 	} else {
-		struct inode *d_inode = kread(&(f_dentry->d_inode));
+		struct inode *d_inode = kread(&(dentry->d_inode));
 		struct super_block *i_sb = kread(&(d_inode->i_sb));
 		THIS->__retvalue = (long)kread(&(i_sb->s_bdev));
 	}
@@ -107,11 +107,11 @@ function __file_bdev:long (file:long) %{
 
 function __file_ino:long (file:long) %{ /* pure */
 	struct file *file = (struct file *)(long)THIS->file;
-	struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-	if (f_dentry == NULL) {
+	struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+	if (dentry == NULL) {
 		THIS->__retvalue = 0;
 	} else {
-		struct inode *d_inode = kread(&(f_dentry->d_inode));
+		struct inode *d_inode = kread(&(dentry->d_inode));
 		THIS->__retvalue = kread(&(d_inode->i_ino));
 	}
 	CATCH_DEREF_FAULT();
@@ -119,11 +119,11 @@ function __file_ino:long (file:long) %{ 
 
 function __file_maxbytes:long (file:long) %{ /* pure */
 	struct file *file = (struct file *)(long)THIS->file;
-	struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-	if (f_dentry == NULL) {
+	struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+	if (dentry == NULL) {
 		THIS->__retvalue = 0;
 	} else {
-		struct inode *d_inode = kread(&(f_dentry->d_inode));
+		struct inode *d_inode = kread(&(dentry->d_inode));
 		struct super_block *i_sb = kread(&(d_inode->i_sb));
 		THIS->__retvalue = kread(&(i_sb->s_maxbytes));
 	}
@@ -132,8 +132,8 @@ function __file_maxbytes:long (file:long
 
 function __file_filename:string (file:long) %{ /* pure */
 	struct file *file = (struct file *)(long)THIS->file;
-	struct dentry *f_dentry = file? kread(&(file->f_dentry)) : NULL;
-	const unsigned char *name = f_dentry? kread(&(f_dentry->d_name.name)) : NULL;
+	struct dentry *dentry = file? kread(&(file->f_dentry)) : NULL;
+	const unsigned char *name = dentry? kread(&(dentry->d_name.name)) : NULL;
 	if (name == NULL) {
 		strlcpy(THIS->__retvalue, "NULL", MAXSTRINGLEN);
 	} else {
Index: src/testsuite/buildok/twenty.stp
===================================================================
--- src.orig/testsuite/buildok/twenty.stp	2007-02-15 13:10:31.000000000 +0100
+++ src/testsuite/buildok/twenty.stp	2007-02-15 14:01:49.000000000 +0100
@@ -4,5 +4,9 @@
 
 probe kernel.function("vfs_readdir")
 {
+%( kernel_v >= "2.6.20" %?
+	$file->f_path->dentry->d_name->len = 1
+%:
 	$file->f_dentry->d_name->len = 1
+%)
 }
Index: src/testsuite/semok/seventeen.stp
===================================================================
--- src.orig/testsuite/semok/seventeen.stp	2007-02-15 13:10:41.000000000 +0100
+++ src/testsuite/semok/seventeen.stp	2007-02-15 14:41:57.000000000 +0100
@@ -1,7 +1,8 @@
 #! stap -p2
 
 global foo
-probe kernel.function("pipe_writev")
+probe kernel.function(
+%( kernel_v < "2.6.19" %? "pipe_writev" %: "pipe_write" %) )
 {
    a = $nr_segs
    foo [a] = 1
Index: src/tapset/ChangeLog
===================================================================
--- src.orig/tapset/ChangeLog	2007-02-15 13:10:23.000000000 +0100
+++ src/tapset/ChangeLog	2007-02-15 15:26:47.000000000 +0100
@@ -1,3 +1,10 @@
+2007-02-15  Pierre Peiffer  <pierre.peiffer@bull.net>
+
+	* LKET/nfs.stp, nfs.stp, vfs.stp: rename local variables f_dentry:
+	to dentry, because conflicting with a new #define in kernel
+	header linux/fs.h in 2.6.20.
+	* rpc.stp: Fix use of struct rpc_xprt: modified since kernel 2.6.19.
+
 2007-02-09  Frank Ch. Eigler  <fche@elastic.org>
 
 	* conversions.stp (*): Make errmsg usage uniform.
Index: src/testsuite/ChangeLog
===================================================================
--- src.orig/testsuite/ChangeLog	2007-02-15 13:10:29.000000000 +0100
+++ src/testsuite/ChangeLog	2007-02-15 15:27:47.000000000 +0100
@@ -1,3 +1,10 @@
+2007-02-15  Pierre Peiffer  <pierre.peiffer@bull.net>
+
+	* buildok/twenty.stp: updated with new struct file since
+	kernel 2.6.20
+	* semok/seventeen.stp: updated with new function name
+	since kernel 2.6.19
+
 2007-02-09  Frank Ch. Eigler  <fche@elastic.org>
 
 	* systemtap.base/prologue.*: New test case.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]