diff options
author | Josh Stone <jistone@redhat.com> | 2009-03-10 15:46:21 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-03-10 15:46:21 -0700 |
commit | 6351f32433edb111b28362963c97d1cd0d1d8561 (patch) | |
tree | d4c922167996a23b5fc6f7888bb12846c34c2c8a | |
parent | abb41d920aecf908a132597f0a4bc26a10e58a7c (diff) | |
download | systemtap-steved-6351f32433edb111b28362963c97d1cd0d1d8561.tar.gz systemtap-steved-6351f32433edb111b28362963c97d1cd0d1d8561.tar.xz systemtap-steved-6351f32433edb111b28362963c97d1cd0d1d8561.zip |
PR9932: use @cast module search path
The nfs, rpc, and scsi tapsets use @cast on types that may be compiled
into a kernel module or into the main kernel binary. The @cast search
path separated with colons lets us search both the kernel and the module.
For a couple of cases, I also merged sequential @casts that work just
fine as a single cast with a multiple-level dereference.
-rw-r--r-- | tapset/nfs.stp | 50 | ||||
-rw-r--r-- | tapset/rpc.stp | 41 | ||||
-rw-r--r-- | tapset/scsi.stp | 4 |
3 files changed, 35 insertions, 60 deletions
diff --git a/tapset/nfs.stp b/tapset/nfs.stp index fe25eff2..6752747f 100644 --- a/tapset/nfs.stp +++ b/tapset/nfs.stp @@ -137,11 +137,10 @@ function __nfs_wpages:long(inode:long) %{ /* pure */ /*Get struct inode from struct page*/ function __p2i :long(page:long) { - mapping = page? @cast(page, "page", "kernel")->mapping : 0 + mapping = page? @cast(page, "page", "kernel:nfs")->mapping : 0 if (mapping == 0) return 0 - else - return @cast(mapping, "address_space", "kernel")->host + return @cast(mapping, "address_space", "kernel:nfs")->host } /*Get i_flags from struct page*/ @@ -150,8 +149,7 @@ function __p2i_flag : long (page:long) host = __p2i(page) if (host == 0) return -1 - else - return @cast(host, "inode", "kernel")->i_flags + return @cast(host, "inode", "kernel:nfs")->i_flags } /*Get i_state from struct page*/ @@ -160,8 +158,7 @@ function __p2i_state :long (page:long) host = __p2i(page) if (host == 0) return -1 - else - return @cast(host, "inode", "kernel")->i_state + return @cast(host, "inode", "kernel:nfs")->i_state } /*Get i_size from struct page*/ @@ -170,19 +167,17 @@ function __p2i_size :long (page:long) host = __p2i(page) if (host == 0) return -1 - else - return @cast(host, "inode", "kernel")->i_size + return @cast(host, "inode", "kernel:nfs")->i_size } /*Get s_flags from struct page*/ function __p2sb_flag:long (page:long) { host = __p2i(page) - i_sb = host? @cast(host, "inode", "kernel")->i_sb : 0 + i_sb = host? @cast(host, "inode", "kernel:nfs")->i_sb : 0 if (i_sb == 0) return -1 - else - return @cast(i_sb, "super_block", "kernel")->s_flags + return @cast(i_sb, "super_block", "kernel:nfs")->s_flags } function __d_loff_t :long (ppos :long) %{ /* pure */ @@ -198,14 +193,13 @@ function __d_loff_t :long (ppos :long) %{ /* pure */ function __file_inode:long (file:long) { %( kernel_v >= "2.6.20" %? - dentry = file? @cast(file, "file", "kernel")->f_path->dentry : 0 + dentry = file? @cast(file, "file", "kernel:nfs")->f_path->dentry : 0 %: - dentry = file? @cast(file, "file", "kernel")->f_dentry : 0 + dentry = file? @cast(file, "file", "kernel:nfs")->f_dentry : 0 %) if (dentry == 0) return 0 - else - return @cast(dentry, "dentry", "kernel")->d_inode + return @cast(dentry, "dentry", "kernel:nfs")->d_inode } function __file_id:long (file:long) @@ -213,10 +207,7 @@ function __file_id:long (file:long) d_inode = __file_inode(file) if (d_inode == 0) return 0 - else { - i_sb = @cast(d_inode, "inode", "kernel")->i_sb - return @cast(i_sb, "super_block", "kernel")->s_id - } + return @cast(d_inode, "inode", "kernel:nfs")->i_sb->s_id } function __file_mode:long (file:long) @@ -224,24 +215,21 @@ function __file_mode:long (file:long) d_inode = __file_inode(file) if (d_inode == 0) return 0 - else - return @cast(d_inode, "inode", "kernel")->i_mode + return @cast(d_inode, "inode", "kernel:nfs")->i_mode } function __file_parentname:string (file:long) { %( kernel_v >= "2.6.20" %? - dentry = file? @cast(file, "file", "kernel")->f_path->dentry : 0 + dentry = file? @cast(file, "file", "kernel:nfs")->f_path->dentry : 0 %: - dentry = file? @cast(file, "file", "kernel")->f_dentry : 0 + dentry = file? @cast(file, "file", "kernel:nfs")->f_dentry : 0 %) - d_parent = dentry? @cast(dentry, "dentry", "kernel")->d_parent : 0 + d_parent = dentry? @cast(dentry, "dentry", "kernel:nfs")->d_parent : 0 if (d_parent == 0) return "NULL" - else { - name = @cast(d_parent, "dentry", "kernel")->d_name->name - return kernel_string(name) - } + name = @cast(d_parent, "dentry", "kernel:nfs")->d_name->name + return kernel_string(name) } /* @@ -336,8 +324,8 @@ probe nfs.fop.llseek = kernel.function ("nfs_file_llseek") !, { dev = __file_dev($filp) ino = __file_ino($filp) - s_id = __file_id($filp) - devname = kernel_string(s_id) + s_id = __file_id($filp) + devname = kernel_string(s_id) maxbyte = __file_maxbytes($filp) offset = $offset diff --git a/tapset/rpc.stp b/tapset/rpc.stp index e6eaed46..1d47daed 100644 --- a/tapset/rpc.stp +++ b/tapset/rpc.stp @@ -880,48 +880,36 @@ function xid_from_clnt:long(clnt:long) { if (clnt == 0) return 0 - else { - cl_xprt = @cast(clnt, "rpc_clnt", "kernel")->cl_xprt - return @cast(cl_xprt, "rpc_xprt", "kernel")->xid - } + return @cast(clnt, "rpc_clnt", "kernel:sunrpc")->cl_xprt->xid } function prog_from_clnt:long(clnt:long) { if (clnt == 0) return 0 - else { %(kernel_v >= "2.6.19" %? - return @cast(clnt, "rpc_clnt", "kernel")->cl_prog + return @cast(clnt, "rpc_clnt", "kernel:sunrpc")->cl_prog %: - cl_pmap = @cast(clnt, "rpc_clnt", "kernel")->cl_pmap - return @cast(cl_pmap, "rpc_portmap", "kernel")->pm_prog + return @cast(clnt, "rpc_clnt", "kernel:sunrpc")->cl_pmap->pm_prog %) - } } function vers_from_clnt:long(clnt:long) { - if (clnt == 0) - return 0 - else { + if (clnt == 0) + return 0 %(kernel_v >= "2.6.19" %? - return @cast(clnt, "rpc_clnt", "kernel")->cl_vers + return @cast(clnt, "rpc_clnt", "kernel:sunrpc")->cl_vers %: - cl_pmap = @cast(clnt, "rpc_clnt", "kernel")->cl_pmap - return @cast(cl_pmap, "rpc_portmap", "kernel")->pm_vers + return @cast(clnt, "rpc_clnt", "kernel:sunrpc")->cl_pmap->pm_vers %) - } } function prot_from_clnt:long(clnt:long) { - if (clnt == 0) - return 0 - else { - cl_xprt = @cast(clnt, "rpc_clnt", "kernel")->cl_xprt - return @cast(cl_xprt, "rpc_xprt", "kernel")->prot - } + if (clnt == 0) + return 0 + return @cast(clnt, "rpc_clnt", "kernel:sunrpc")->cl_xprt->prot } function port_from_clnt:long(clnt:long) @@ -934,12 +922,14 @@ function port_from_clnt:long(clnt:long) 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 + else THIS->__retvalue = 0; CATCH_DEREF_FAULT(); %} @@ -970,10 +960,7 @@ function proc_from_msg:long(msg:long) { if (msg == 0) return 0 - else { - rpc_proc = @cast(msg, "rpc_message", "kernel")->rpc_proc - return @cast(rpc_proc, "rpc_procinfo", "kernel")->p_proc - } + return @cast(msg, "rpc_message", "kernel:sunrpc")->rpc_proc->p_proc } function vers_from_prog:long(program:long, vers:long) diff --git a/tapset/scsi.stp b/tapset/scsi.stp index b1b2d19b..6d332e8b 100644 --- a/tapset/scsi.stp +++ b/tapset/scsi.stp @@ -137,6 +137,6 @@ function scsi_timer_pending:long(var:long) function get_devstate_from_req:long(var:long) { - sdev = @cast(var, "request_queue", "kernel")->queuedata - return @cast(sdev, "scsi_device", "kernel")->sdev_state + sdev = @cast(var, "request_queue", "kernel:scsi_mod")->queuedata + return @cast(sdev, "scsi_device", "kernel:scsi_mod")->sdev_state } |