diff options
| author | George V. Neville-Neil <gnn@FreeBSD.org> | 2012-05-12 20:38:18 +0000 |
|---|---|---|
| committer | George V. Neville-Neil <gnn@FreeBSD.org> | 2012-05-12 20:38:18 +0000 |
| commit | 055173dba4a263acf10325a49eebf82915369ed2 (patch) | |
| tree | aec2772e8855e6dbaea6d8136ed0c47bcb825dee /Snippits | |
| parent | 87c8f7aa3a46118212b99f0d58b18aa93c06b02a (diff) | |
Add the remaining scripts from the DTraceToolkit, version 0.99, to thevendor/dtracetoolkit/dtracetoolkit-20120512vendor/dtracetoolkit
Notes
Notes:
svn path=/vendor/dtracetoolkit/dist/; revision=235368
svn path=/vendor/dtracetoolkit/dtracetoolkit-20120512/; revision=235374; tag=vendor/dtracetoolkit/dtracetoolkit-20120512
Diffstat (limited to 'Snippits')
| -rw-r--r-- | Snippits/Readme | 11 | ||||
| -rw-r--r-- | Snippits/fd2pathname.txt | 32 |
2 files changed, 43 insertions, 0 deletions
diff --git a/Snippits/Readme b/Snippits/Readme new file mode 100644 index 000000000000..b54dc77583b0 --- /dev/null +++ b/Snippits/Readme @@ -0,0 +1,11 @@ +Snippits - DTrace code snippits + + This directory has useful snippits of D scripting in seperate files. + + When coding in DTrace, I frequently refer to the same chunks of code + from the same scripts, when I need to do certain things that I have + solved in the past. I also refer other people to them when asked. + This directory is a library for such "snippits" of code. + + This directory does not contain runnable DTrace scripts. + diff --git a/Snippits/fd2pathname.txt b/Snippits/fd2pathname.txt new file mode 100644 index 000000000000..b056e1318135 --- /dev/null +++ b/Snippits/fd2pathname.txt @@ -0,0 +1,32 @@ +You have a file descriptor (probably from a syscall), and you want the +corresponding pathname. + +If you are on newer versions of DTrace, there is the fds[] array, + +# dtrace -n 'syscall::read:entry { @[fds[arg0].fi_pathname] = count(); }' +dtrace: description 'syscall::read:entry ' matched 1 probe +^C + + /etc/minor_perm 2 + /etc/mnttab 2 + /etc/motd 2 + /etc/magic 4 + /usr/sbin/clri 5 + /devices/pseudo/clone@0:ptm 6 + /sbin/mount 6 + /dev/pts/28 7 + /devices/pseudo/consms@0:mouse 31 + /devices/pseudo/conskbd@0:kbd 47 + <unknown> 351 + +easy. + +but if you are on an older version of DTrace, try this to convert from +this->fd to self->vpath, + + this->filep = + curthread->t_procp->p_user.u_finfo.fi_list[this->fd].uf_file; + this->vnodep = this->filep != 0 ? this->filep->f_vnode : 0; + self->vpath = this->vnodep ? (this->vnodep->v_path != 0 ? + cleanpath(this->vnodep->v_path) : "<unknown>") : "<unknown>"; + |
