diff options
-rw-r--r-- | doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml | 2 | ||||
-rw-r--r-- | doc/Tapset_Reference_Guide/manpager.sh | 118 | ||||
-rw-r--r-- | runtime/loc2c-runtime.h | 11 | ||||
-rw-r--r-- | runtime/sym.h | 1 | ||||
-rw-r--r-- | runtime/task_finder.c | 2 | ||||
-rw-r--r-- | tapset/context-symbols.stp | 13 | ||||
-rw-r--r-- | tapset/context-unwind.stp | 10 | ||||
-rw-r--r-- | tapset/context.stp | 71 | ||||
-rw-r--r-- | tapset/ioscheduler.stp | 2 | ||||
-rw-r--r-- | tapset/memory.stp | 8 | ||||
-rw-r--r-- | tapset/scsi.stp | 10 | ||||
-rw-r--r-- | tapset/socket.stp | 70 | ||||
-rw-r--r-- | tapset/task.stp | 24 | ||||
-rw-r--r-- | tapset/udp.stp | 42 | ||||
-rw-r--r-- | tapsets.cxx | 11 | ||||
-rwxr-xr-x | testsuite/buildok/task-embedded.stp | 4 | ||||
-rwxr-xr-x | testsuite/buildok/task_test.stp | 2 | ||||
-rw-r--r-- | testsuite/systemtap.base/static_uprobes.exp | 18 | ||||
-rw-r--r-- | translate.cxx | 9 |
19 files changed, 229 insertions, 199 deletions
diff --git a/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml b/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml index 01e4c358..d497eae6 100644 --- a/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml +++ b/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml @@ -276,7 +276,7 @@ probe process.create = kernel.function("copy_process").return <listitem><para><command>emphasis</command></para></listitem> <listitem><para><command>programlisting</command></para></listitem> <listitem><para><command>remark</command> (tagged strings will appear in Publican beta - builds of the document.</para></listitem> + builds of the document)</para></listitem> </itemizedlist> diff --git a/doc/Tapset_Reference_Guide/manpager.sh b/doc/Tapset_Reference_Guide/manpager.sh index 9aede5c4..2b9873b7 100644 --- a/doc/Tapset_Reference_Guide/manpager.sh +++ b/doc/Tapset_Reference_Guide/manpager.sh @@ -3,78 +3,79 @@ # generated herein should be in sync with Tapset Reference Guide # cleanup -rm -rf manpages +rm -rf workingdir # create working directory -mkdir manpages ; +mkdir workingdir ; # create list of man pages to generate; should be in sync with Tapset Reference Guide cat ../SystemTap_Tapset_Reference/tapsets.tmpl | grep ^\!Itapset > manpageus ; sed -i -e 's/\!Itapset\///g' manpageus ; # copy list of man pages into working directory -for i in `cat manpageus` ; do cp ../../tapset/$i manpages ; done ; +for i in `cat manpageus` ; do cp ../../tapset/$i workingdir ; done ; # enter workdir -# rm manpageus ; -cd manpages ; +cd workingdir ; # copy tapsetdescriptions, then clean -for i in `ls`; do sed -n '/\/\/ <tapsetdescription>/,/\/\/ <\/tapsetdescription>/ s/.*/&/w temp' < $i ; +for i in `cat ../manpageus`; do +sed -n '/\/\/ <tapsetdescription>/,/\/\/ <\/tapsetdescription>/ s/.*/&/w temp' < $i ; mv temp $i.tapsetdescription ; sed -i -e 's/\/\/ <tapsetdescription>//g' $i.tapsetdescription ; sed -i -e 's/\/\/ <\/tapsetdescription>//g' $i.tapsetdescription ; sed -i -e 's/\/\///g' $i.tapsetdescription ; done -# strip all tapset files to just comments; but first, make sure all comments are exactly 1 space before * -for i in `ls | grep -v tapsetdescription` ; do sed -i -e 's/^ \*/ \*/g' $i; done ; -for i in `ls | grep -v tapsetdescription` ; do sed -i -e '/^ \*/!d' $i; done ; +# strip all tapset files to just comments; but all comments must be exactly 1 space before and after "*" +for i in `cat ../manpageus` ; do sed -i -e 's/^ \*/ \*/g' $i; +sed -i -e 's/^ \* / \* /g' $i; +# mark the start of each probe entry (sub "/**") +perl -p -i -e 's|^/\*\*| *probestart|g' $i; +sed -i -e '/^ \*/!d' $i; # rename all tapsets (remove .stp filename suffix), create templates -for i in `ls | grep -v tapsetdescription` ; do echo $i > tempname ; sed -i -e 's/.stp//g' tempname ; mv $i `cat tempname` ; mv tempname $i ; done ; +echo $i > tempname ; +sed -i -e 's/.stp//g' tempname ; +mv $i `cat tempname` ; mv tempname $i ; +done ; # clean all tapsetdescriptions (remove excess spaces) # for i in `ls | grep tapsetdescription` ; do perl -p -i -e 's|^\n||g' $i ; done ; -for i in `ls | grep -v .stp | grep -v tapsetdescription` ; -do echo ".\" -*- nroff -*-" >> $i.template ; -echo ".TH STAPPROBES.manpagename 5 @DATE@ "IBM"" >> $i.template ; +# create man page headers +for i in `ls | grep -v .stp | grep -v tapsetdescription` ; do +#echo ".\" -*- nroff -*-" >> $i.template ; +echo ".TH STAPPROBES."$i" 5 @DATE@ "IBM"" >> $i.template ; echo ".SH NAME" >> $i.template ; echo "stapprobes."`cat $i.stp`" \- systemtap "`cat $i.stp`" probe points" >> $i.template ; echo " " >> $i.template ; -echo ".\" macros" >> $i.template ; -echo ".de SAMPLE" >> $i.template ; -echo ".br" >> $i.template ; -echo ".RS" >> $i.template ; -echo ".nf" >> $i.template ; -echo ".nh" >> $i.template ; -echo ".." >> $i.template ; -echo ".de ESAMPLE" >> $i.template ; -echo ".hy" >> $i.template ; -echo ".fi" >> $i.template ; -echo ".RE" >> $i.template ; -echo ".." >> $i.template ; -echo " " >> $i.template ; echo ".SH DESCRIPTION" >> $i.template ; cat $i.stp.tapsetdescription >> $i.template ; +echo " " >> $i.template ; +#echo " " >> $i.template ; +echo ".SH PROBES" >> $i.template ; +echo ".br" >> $i.template ; echo ".P" >> $i.template ; echo ".TP" >> $i.template ; done +# MOST IMPORTANT: clean man page body! for i in `ls | grep -v .stp | grep -v tapsetdescription | grep -v template` ; -do cp $i $i.manpagebody ; -perl -p -i -e 's| \* sfunction|.B|g' $i.manpagebody ; -perl -p -i -e 's| \* probe|.B|g' $i.manpagebody ; -perl -p -i -e 's| -|\n\t|g' $i.manpagebody ; -perl -p -i -e 's|(^\t[^\n]*)\n|$1\n\n.B Arguments:|g' $i.manpagebody ; -perl -p -i -e 's| \* @([^:]*):|.I $1 \n|g' $i.manpagebody ; -perl -p -i -e 's| \* ([^:]*):|.B $1 \n|g' $i.manpagebody ; -perl -p -i -e 's| \* ||g' $i.manpagebody ; -perl -p -i -e 's|.B Arguments: \*|.B No Arguments:\n\n.B Description:|g' $i.manpagebody ; -perl -p -i -e 's|.B Arguments:.I|.B Arguments:\n.I|g' $i.manpagebody ; -perl -p -i -e 's|^ \*/|\n.P\n.TP|g' $i.manpagebody ; -perl -p -i -e 's|\.I|\n\n.I|g' $i.manpagebody ; -perl -p -i -e 's|.B Context|\n.B Context|g' $i.manpagebody ; -#perl -p -i -e 's|^[^*]*\*|.P|g' $i.manpagebody ; +do cp $i $i.tmp ; +perl -p -i -e 's| \* sfunction|.BR|g' $i.tmp ; +perl -p -i -e 's| \* probe|.BR|g' $i.tmp ; +perl -p -i -e 's| -|\ninitlinehere|g' $i.tmp ; +perl -p -i -e 's|^initlinehere([^\n]*)\n|\n.br\n$1\n\n.B Arguments:|g' $i.tmp ; +perl -p -i -e 's| \* @([^:]*):|\n.I $1\n.br\n|g' $i.tmp ; +perl -p -i -e 's| \* ([^:]*):|\n.BR $1:\n.br\n|g' $i.tmp ; +perl -p -i -e 's|\*probestart|\n.P\n.TP|g' $i.tmp ; +perl -p -i -e 's|\.I|\n\n.I|g' $i.tmp ; +# special formatting for Arguments header +perl -p -i -e 's|.B Arguments: \*\/||g' $i.tmp ; +perl -p -i -e 's|.B Arguments: \*|.B Description:|g' $i.tmp ; + +cat $i.tmp | +perl -p -e 'undef $/;s|.B Arguments:\n.B|.B|msg' | +perl -p -e 'undef $/;s|\n\n\n|\n\n|msg' > $i.manpagebody ; done # generate footer template @@ -87,17 +88,44 @@ for i in `cat manpageus`; do echo ".IR stapprobes."$i" (5)," >> footer ; done # assemble parts for i in `cat manpageus`; do -cat $i.template >> stapprobes.$i.5.in ; -cat $i.manpagebody >> stapprobes.$i.5.in ; -cat footer >> stapprobes.$i.5.in ; +cat $i.template >> $i.5 ; +cat $i.manpagebody >> $i.5 ; +cat footer >> $i.5 ; done # cleanup for i in `cat manpageus`; do -perl -p -i -e 's|.B Description:/|\n.P\n.TP|g' stapprobes.$i.5.in ; +# context.stp +perl -p -i -e 's|.B Description:/|\n.P\n.TP|g' $i.5 ; +perl -p -i -e 's|.B Description:|.B Description:\n\n |g' $i.5 ; +# convert tags +perl -p -i -e 's|</[^>]*>([^.])|$1\n|g' $i.5 ; +perl -p -i -e 's|<[^>]*>|\n.B |g' $i.5 ; +cat $i.5 | +perl -p -e 'undef $/;s|\.B Arguments:\n\n\.B |.B|msg' | +# for tagged commands followed by periods +perl -p -e 'undef $/;s|\n\.B \.|.\n|msg' | +perl -p -e 'undef $/;s|\n \* | |msg' > stapprobes.$i.5.in ; +# cleanup all remaining stars, excess initial whitespace, and trailing "/" per line +perl -p -i -e 's|^ \*||g' stapprobes.$i.5.in; +perl -p -i -e 's|^[ ]*||g' stapprobes.$i.5.in; +perl -p -i -e 's|^/||g' stapprobes.$i.5.in; +# cleanup remaining excess whitespace +perl -p -i -e 's|\t\t| |g' stapprobes.$i.5.in; +perl -p -i -e 's|^ ||g' stapprobes.$i.5.in; +sed -i -e 's/ / /g' stapprobes.$i.5.in; done +# file cleanup +rm `ls | grep -v stapprobes` +#mv workingdir final_manpages +# perl -p -i -e 's|||g' stapprobes.$i.5.in ; # perl -p -i -e 's|||g' $i.manpagebody # use to move marked strings. -# sed -n '/\/\/ <tapsetdescription>/,/\/\/ <\/tapsetdescription>/ s/.*/&/w bleh' < ioscheduler
\ No newline at end of file +# sed -n '/\/\/ <tapsetdescription>/,/\/\/ <\/tapsetdescription>/ s/.*/&/w bleh' < ioscheduler +# remove excess initial whitespace for each line +# perl -p -i -e 's|^ ||g' stapprobes.$i.5.in; +# convert tags +# perl -p -i -e 's|</[^>]*>|\n|g' stapprobes.$i.5.in ; +# perl -p -i -e 's|<[^>]*>|\n.B |g' stapprobes.$i.5.in ;
\ No newline at end of file diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h index 92c017d3..16ddb950 100644 --- a/runtime/loc2c-runtime.h +++ b/runtime/loc2c-runtime.h @@ -186,7 +186,7 @@ */ #define kread(ptr) ({ \ - typeof(*(ptr)) _v; \ + typeof(*(ptr)) _v = 0; \ if (lookup_bad_addr((unsigned long)(ptr)) || \ probe_kernel_read((void *)&_v, (void *)(ptr), sizeof(*(ptr)))) \ DEREF_FAULT(ptr); \ @@ -202,14 +202,13 @@ }) #define deref(size, addr) ({ \ - intptr_t _i; \ + intptr_t _i = 0; \ switch (size) { \ case 1: _i = kread((u8 *)(addr)); break; \ case 2: _i = kread((u16 *)(addr)); break; \ case 4: _i = kread((u32 *)(addr)); break; \ case 8: _i = kread((u64 *)(addr)); break; \ default: __deref_bad(); \ - /* uninitialized _i should also be caught by -Werror */ \ } \ _i; \ }) @@ -235,7 +234,7 @@ extern void __store_deref_bad(void); ({ \ int _bad = 0; \ u8 _b; u16 _w; u32 _l; \ - intptr_t _v; \ + intptr_t _v = 0; \ if (lookup_bad_addr((unsigned long)addr)) \ _bad = 1; \ else \ @@ -275,7 +274,7 @@ extern void __store_deref_bad(void); ({ \ int _bad = 0; \ u8 _b; u16 _w; u32 _l; u64 _q; \ - intptr_t _v; \ + intptr_t _v = 0; \ if (lookup_bad_addr((unsigned long)addr)) \ _bad = 1; \ else \ @@ -392,7 +391,7 @@ extern void __store_deref_bad(void); #define deref(size, addr) \ ({ \ int _bad = 0; \ - intptr_t _v; \ + intptr_t _v = 0; \ if (lookup_bad_addr((unsigned long)addr)) \ _bad = 1; \ else \ diff --git a/runtime/sym.h b/runtime/sym.h index e642cab4..586b10ca 100644 --- a/runtime/sym.h +++ b/runtime/sym.h @@ -25,6 +25,7 @@ struct _stp_section { struct _stp_module { const char* name; + const char* path; /* canonical path used for runtime matching. */ struct _stp_section *sections; unsigned num_sections; diff --git a/runtime/task_finder.c b/runtime/task_finder.c index ae381a41..38f9145d 100644 --- a/runtime/task_finder.c +++ b/runtime/task_finder.c @@ -72,7 +72,7 @@ static int __stp_tf_vm_cb(struct stap_task_finder_target *tgt, struct _stp_module *module = NULL; if (vm_path != NULL) for (i = 0; i < _stp_num_modules; i++) - if (strcmp(vm_path, _stp_modules[i]->name) == 0) + if (strcmp(vm_path, _stp_modules[i]->path) == 0) { #ifdef DEBUG_TASK_FINDER_VMA _stp_dbug(__FUNCTION__, __LINE__, diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp index 4a08ec60..a3aae408 100644 --- a/tapset/context-symbols.stp +++ b/tapset/context-symbols.stp @@ -18,12 +18,13 @@ %} // weirdness with print_stack, argument appears in build as undescribed /** - * sfunction print_stack - Print out stack from string + * sfunction print_stack - Print out stack from string. * @stk: String with list of hexidecimal addresses. (FIXME) * * Perform a symbolic lookup of the addresses in the given string, - * which is assumed to be the result of a prior call to + * which is assumed to be the result of a prior call to * <command>backtrace()</command>. + * * Print one line per address, including the address, the * name of the function containing the address, and an estimate of * its position within that function. Return nothing. @@ -40,9 +41,7 @@ function print_stack(stk:string) %{ %} /** - * sfunction probefunc - Function probed - * - * Return the probe point's function name, if known. + * sfunction probefunc - Return the probe point's function name, if known. */ function probefunc:string () %{ /* pure */ char *ptr, *start; @@ -76,9 +75,7 @@ function probefunc:string () %{ /* pure */ %} /** - * sfunction probemod - Module probed - * - * Return the probe point's module name, if known. + * sfunction probemod - Return the probe point's module name, if known. */ function probemod:string () %{ /* pure */ char *ptr, *start; diff --git a/tapset/context-unwind.stp b/tapset/context-unwind.stp index 5c1253b8..90d4e0f4 100644 --- a/tapset/context-unwind.stp +++ b/tapset/context-unwind.stp @@ -23,7 +23,7 @@ /** * sfunction print_backtrace - Print stack back trace * - * Equivalent to <command>print_stack(backtrace())</command>, + * Equivalent to <command>print_stack(backtrace())</command>, * except that deeper stack nesting may be supported. Return nothing. */ function print_backtrace () %{ @@ -37,8 +37,8 @@ function print_backtrace () %{ /** * sfunction backtrace - Hex backtrace of current stack * - * Return a string of hex addresses that are a backtrace of the - * stack. It may be truncated due to maximum string length. + * Return a string of hex addresses that are a backtrace of the + * stack. Output may be truncated as per maximum string length. */ function backtrace:string () %{ /* pure */ if (CONTEXT->regs) @@ -50,7 +50,7 @@ function backtrace:string () %{ /* pure */ /** * sfunction caller - Return name and address of calling function * - * Return the address and name of the calling function. + * Return the address and name of the calling function. * <emphasis>Works only for return probes at this time.</emphasis> */ function caller:string() %{ /* pure */ @@ -64,7 +64,7 @@ function caller:string() %{ /* pure */ /** * sfunction caller_addr - Return caller address * - * Return the address of the calling function. + * Return the address of the calling function. * <emphasis> Works only for return probes at this time.</emphasis> */ function caller_addr:long () %{ /* pure */ diff --git a/tapset/context.stp b/tapset/context.stp index f4b0207a..9f4be0e6 100644 --- a/tapset/context.stp +++ b/tapset/context.stp @@ -21,37 +21,28 @@ function print_regs () %{ %} /** - * sfunction execname - Execname of current processes - * - * Return the name of the current process. + * sfunction execname - Returns the execname of a target process (or group of processes). */ function execname:string () %{ /* pure */ strlcpy (THIS->__retvalue, current->comm, MAXSTRINGLEN); %} /** - * sfunction pid - Process ID of current process - * - * - * Return the id of the current process. + * sfunction pid - Returns the ID of a target process. */ function pid:long () %{ /* pure */ THIS->__retvalue = current->tgid; %} /** - * sfunction tid - Thread ID of current process - * - * Return the id of the current thread. + * sfunction tid - Returns the thread ID of a target process. */ function tid:long () %{ /* pure */ THIS->__retvalue = current->pid; %} /** - * sfunction ppid - Parent Process ID of current process - * - * Return the id of the parent process. + * sfunction ppid - Returns the process ID of a target process's parent process. */ function ppid:long () %{ /* pure */ #if defined(STAPCONF_REAL_PARENT) @@ -62,9 +53,7 @@ function ppid:long () %{ /* pure */ %} /** - * sfunction pexecname - Execname of the parent process. - * - * Return the name of the parent process. + * sfunction pexecname - Returns the execname of a target process's parent process. */ function pexecname:string () %{ /* pure */ #if defined(STAPCONF_REAL_PARENT) @@ -75,9 +64,7 @@ function pexecname:string () %{ /* pure */ %} /** - * sfunction gid - Group ID of current process - * - * Return the gid of the current process. + * sfunction gid - Returns the group ID of a target process. */ function gid:long () %{ /* pure */ #ifdef STAPCONF_TASK_UID @@ -88,9 +75,7 @@ function gid:long () %{ /* pure */ %} /** - * sfunction egid - Effective gid of the current process. - * - * Return the effective gid of the current process. + * sfunction egid - Returns the effective gid of a target process. */ function egid:long () %{ /* pure */ #ifdef STAPCONF_TASK_UID @@ -101,9 +86,7 @@ function egid:long () %{ /* pure */ %} /** - * sfunction uid -User ID of the current process. - * - * Return the uid of the current process. + * sfunction uid - Returns the user ID of a target process. */ function uid:long () %{ /* pure */ #ifdef STAPCONF_TASK_UID @@ -114,9 +97,7 @@ function uid:long () %{ /* pure */ %} /** - * sfunction euid - Effective User ID of the current process. - * - * Return the effective uid of the current process. + * sfunction euid - Return the effective uid of a target process. */ function euid:long () %{ /* pure */ #ifdef STAPCONF_TASK_UID @@ -132,26 +113,24 @@ function cpuid:long () %{ /* pure */ %} /** - * sfunction cpu - The current cpu number. - * - * Return the current cpu number. + * sfunction cpu - Returns the current cpu number. */ function cpu:long () %{ /* pure */ THIS->__retvalue = smp_processor_id(); %} /** - * sfunction pp - Current probe point - * - * Return the probe point associated with the currently running - * probe handler, including alias and wildcard expansion effects. + * sfunction pp - Return the probe point associated with the currently running probe handler, + * including alias and wildcard expansion effects + * Context: + * The current probe point. */ function pp:string () %{ /* pure */ strlcpy (THIS->__retvalue, CONTEXT->probe_point, MAXSTRINGLEN); %} /** - * sfunction registers_valid - Register information valid + * sfunction registers_valid - Determines validity of <command>register()</command> and <command>u_register()</command> in current context. * * Return 1 if register() and u_register() can be used * in the current context, or 0 otherwise. @@ -163,7 +142,7 @@ function registers_valid:long () %{ /* pure */ %} /** - * sfunction user_mode - User Mode + * sfunction user_mode - Determines if probe point occurs in user-mode. * * Return 1 if the probe point occurred in user-mode. */ @@ -180,7 +159,7 @@ function user_mode:long () %{ /* pure */ /* currently a user-mode address? */ %} /** - * sfunction is_return - Is return probe + * sfunction is_return - Determines if probe point is a return probe. * * Return 1 if the probe point is a return probe. * <emphasis>Deprecated.</emphasis> @@ -193,9 +172,7 @@ function is_return:long () %{ /* pure */ %} /** - * sfunction target - Target pid - * - * Return the pid of the target process. + * sfunction target - Return the process ID of the target process. */ function target:long () %{ /* pure */ THIS->__retvalue = _stp_target; @@ -224,18 +201,16 @@ function stp_pid:long () %{ /* pure */ %} /** - * sfunction stack_size - Size of kernel stack - * - * Return the size of the kernel stack. + * sfunction stack_size - Return the size of the kernel stack. */ function stack_size:long () %{ /* pure */ THIS->__retvalue = THREAD_SIZE; %} /** - * sfunction stack_used - Current amount of kernel stack used + * sfunction stack_used - Returns the amount of kernel stack used. * - * Return how many bytes are currently used in the kernel stack. + * Determines how many bytes are currently used in the kernel stack. */ function stack_used:long () %{ /* pure */ char a; @@ -243,9 +218,9 @@ function stack_used:long () %{ /* pure */ %} /** - * sfunction stack_unused - Amount of kernel stack currently available + * sfunction stack_unused - Returns the amount of kernel stack currently available. * - * Return how many bytes are currently available in the kernel stack. + * Determines how many bytes are currently available in the kernel stack. */ function stack_unused:long () %{ /* pure */ char a; diff --git a/tapset/ioscheduler.stp b/tapset/ioscheduler.stp index 875ccea9..a79ae752 100644 --- a/tapset/ioscheduler.stp +++ b/tapset/ioscheduler.stp @@ -60,7 +60,7 @@ probe ioscheduler.elv_next_request.return } /** - * probe ioscheduler.elv_add_request -A request was added to the request queue + * probe ioscheduler.elv_add_request - A request was added to the request queue * @elevator_name: The type of I/O elevator currently enabled * @req: Address of the request * @req_flags: Request flags diff --git a/tapset/memory.stp b/tapset/memory.stp index 9dbe3fba..83875aa4 100644 --- a/tapset/memory.stp +++ b/tapset/memory.stp @@ -56,7 +56,7 @@ function vm_fault_contains:long (value:long, test:long) /** * probe vm.pagefault - Records that a page fault occurred. * @address: The address of the faulting memory access; i.e. the address that caused the page fault. - * @write_access: Indicates whether this was a write or read access; <command>1</command> indicates a write, + * @write_access: Indicates whether this was a write or read access; <command>1</command> indicates a write, * while <command>0</command> indicates a read. * * Context: The process which triggered the fault @@ -113,8 +113,8 @@ function _IS_ZERO_PAGE:long(from:long, vaddr:long) %{ /* pure */ * Context: * The context is the process attempting the write. * - * Fires when a process attempts to write to a shared page. - * If a copy is necessary, this will be followed by a + * Fires when a process attempts to write to a shared page. + * If a copy is necessary, this will be followed by a * <command>vm.write_shared_copy</command>. */ probe vm.write_shared = kernel.function("do_wp_page") { @@ -122,7 +122,7 @@ probe vm.write_shared = kernel.function("do_wp_page") { } /** - * probe vm.write_shared_copy- Page copy for shared page write. + * probe vm.write_shared_copy - Page copy for shared page write. * @address: The address of the shared write. * @zero: Boolean indicating whether it is a zero page * (can do a clear instead of a copy). diff --git a/tapset/scsi.stp b/tapset/scsi.stp index 8ff3dcca..e1457739 100644 --- a/tapset/scsi.stp +++ b/tapset/scsi.stp @@ -46,9 +46,9 @@ probe scsi.ioentry * @lun: The lun number * @dev_id: The scsi device id * @device_state: The current state of the device. - * @data_direction: The data_direction specifies whether this command is from/to - * the device. 0 (DMA_BIDIRECTIONAL), 1 (DMA_TO_DEVICE), - * 2 (DMA_FROM_DEVICE), 3 (DMA_NONE) + * @data_direction: The data_direction specifies whether this command is from/to the device. + * 0 (DMA_BIDIRECTIONAL), 1 (DMA_TO_DEVICE), + * 2 (DMA_FROM_DEVICE), 3 (DMA_NONE) * @request_buffer: The request buffer address * @req_bufflen: The request buffer length */ @@ -81,7 +81,7 @@ probe scsi.iodispatching * @dev_id: The scsi device id * @device_state: The current state of the device * @data_direction: The data_direction specifies whether this command is - * from/to the device. + * from/to the device. */ probe scsi.iodone = module("scsi_mod").function("scsi_done@drivers/scsi/scsi.c")?, @@ -106,7 +106,7 @@ probe scsi.iodone * @dev_id: The scsi device id * @device_state: The current state of the device * @data_direction: The data_direction specifies whether this command is from/to - * the device + * the device * @goodbytes: The bytes completed. */ // mid-layer processes the completed IO diff --git a/tapset/socket.stp b/tapset/socket.stp index 93730f9f..0f01b8d4 100644 --- a/tapset/socket.stp +++ b/tapset/socket.stp @@ -67,8 +67,8 @@ probe socket.receive = socket.recvmsg.return, ### FUNCTION SPECIFIC SEND/RECEIVE PROBES ### -/* - * probe socket.sendmsg - Message being sent on socket +/** + * probe socket.sendmsg - Message is currently being sent on a socket. * @name: Name of this probe * @size: Message size in bytes * @protocol: Protocol value @@ -95,7 +95,7 @@ probe socket.sendmsg = kernel.function ("sock_sendmsg") } /** - * probe socket.sendmsg.return - Return from Message being sent on socket + * probe socket.sendmsg.return - Return from <command>socket.sendmsg</command>. * @name: Name of this probe * @size: Size of message sent (in bytes) or error code if success = 0 * @protocol: Protocol value @@ -151,7 +151,7 @@ probe socket.recvmsg = kernel.function ("sock_recvmsg") type = $sock->type } -/* +/** * probe socket.recvmsg.return - Return from Message being received on socket * @name: Name of this probe * @size: Size of message received (in bytes) or error code if success = 0 @@ -198,14 +198,14 @@ probe socket.recvmsg.return = kernel.function ("sock_recvmsg").return * Fires at the beginning of sending a message on a socket * via the sock_aio_write() function */ -/* - * 2.6.9~2.6.15: - * static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t size, loff_t pos); - * 2.6.16~2.6.18: - * static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t count, loff_t pos); - * 2.6.19~2.6.26: - * static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); - */ +// +// 2.6.9~2.6.15: +// static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t size, loff_t pos); +// 2.6.16~2.6.18: +// static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t count, loff_t pos); +// 2.6.19~2.6.26: +// static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); + probe socket.aio_write = kernel.function ("sock_aio_write") { name = "socket.aio_write" @@ -272,14 +272,14 @@ probe socket.aio_write.return = kernel.function ("sock_aio_write").return * Fires at the beginning of receiving a message on a socket * via the sock_aio_read() function */ -/* - * 2.6.9~2.6.15: - * static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t size, loff_t pos); - * 2.6.16~2.6.18: - * static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t count, loff_t pos); - * 2.6.19~2.6.26: - * static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); - */ +// +// 2.6.9~2.6.15: +// static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t size, loff_t pos); +// 2.6.16~2.6.18: +// static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t count, loff_t pos); +// 2.6.19~2.6.26: +// static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos); + probe socket.aio_read = kernel.function ("sock_aio_read") { name = "socket.aio_read" @@ -543,18 +543,16 @@ probe socket.close.return = kernel.function ("sock_release").return ####### PROTOCOL HELPER FUNCTIONS ######## -/* - * sock_prot_num2str - * Given a protocol number, return a string representation. +/** + * sfunction sock_prot_num2str - Given a protocol number, return a string representation. */ function sock_prot_num2str:string (proto:long) { return (proto in _prot_num2str ? _prot_num2str[proto] : "UNDEF") } -/* - * sock_prot_str2num - * Given a protocol name (string), return the corresponding protocol number. +/** + * sfunction sock_prot_str2num - Given a protocol name (string), return the corresponding protocol number. */ function sock_prot_str2num:long (proto:string) { @@ -563,18 +561,16 @@ function sock_prot_str2num:long (proto:string) ######### PROTOCOL FAMILY HELPER FUNCTIONS ########### -/* - * sock_fam_num2str - * Given a protocol family number, return a string representation. +/** + * sfunction sock_fam_num2str - Given a protocol family number, return a string representation. */ function sock_fam_num2str:string (family:long) { return (family in _fam_num2str ? _fam_num2str[family] : "UNDEF") } -/* - * sock_fam_str2num - * Given a protocol family name (string), return the corresponding +/** + * sfunction sock_fam_str2num - Given a protocol family name (string), return the corresponding * protocol family number. */ function sock_fam_str2num:long (family:string) @@ -584,18 +580,16 @@ function sock_fam_str2num:long (family:string) ######### SOCKET STATE HELPER FUNCTIONS ########## -/* - * sock_state_num2str - * Given a socket state number, return a string representation. +/** + * sfunction sock_state_num2str - Given a socket state number, return a string representation. */ function sock_state_num2str:string (state:long) { return (state in _state_num2str ? _state_num2str[state] : "UNDEF") } -/* - * sock_state_str2num - * Given a socket state string, return the corresponding state number. +/** + * sfunction sock_state_str2num - Given a socket state string, return the corresponding state number. */ function sock_state_str2num:long (state:string) { diff --git a/tapset/task.stp b/tapset/task.stp index 07337156..f1a10b0a 100644 --- a/tapset/task.stp +++ b/tapset/task.stp @@ -63,6 +63,30 @@ function task_pid:long (task:long) } +// Return the task of the given process id +function pid2task:long (pid:long) %{ /* pure */ + struct task_struct *t = NULL; + pid_t t_pid = (pid_t)(long)THIS->pid; + rcu_read_lock(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) + t = find_task_by_vpid (t_pid); +#else + t = find_task_by_pid (t_pid); +#endif + rcu_read_unlock(); + THIS->__retvalue = (long)t; + CATCH_DEREF_FAULT(); +%} + +// Return the name of the given process id +function pid2execname:string (pid:long) { + tsk = pid2task(pid) + if (tsk) + return task_execname(tsk) + return "" +} + + // Return the thread id of the given task function task_tid:long (task:long) { diff --git a/tapset/udp.stp b/tapset/udp.stp index f2b19a7f..2255074a 100644 --- a/tapset/udp.stp +++ b/tapset/udp.stp @@ -17,12 +17,12 @@ /** * probe udp.sendmsg - Fires whenever a process sends a UDP message - * @name: Name of this probe - * @sock: Network socket - * @size: Number of bytes to send + * @name: The name of this probe + * @sock: Network socket used by the process + * @size: Number of bytes sent by the process * * Context: - * The process which sends a udp message + * The process which sent a UDP message */ probe udp.sendmsg = kernel.function("udp_sendmsg") { name = "udp.sendmsg" @@ -32,11 +32,11 @@ probe udp.sendmsg = kernel.function("udp_sendmsg") { /** * probe udp.sendmsg.return - Fires whenever an attempt to send a UDP message is completed - * @name: Name of this probe - * @size: Number of bytes sent + * @name: The name of this probe + * @size: Number of bytes sent by the process * * Context: - * The process which sends a udp message + * The process which sent a UDP message */ probe udp.sendmsg.return = kernel.function("udp_sendmsg").return { name = "udp.sendmsg" @@ -45,12 +45,12 @@ probe udp.sendmsg.return = kernel.function("udp_sendmsg").return { /** * probe udp.recvmsg - Fires whenever a UDP message is received - * @name: Name of this probe - * @sock: Network socket - * @size: Number of bytes received + * @name: The name of this probe + * @sock: Network socket used by the process + * @size: Number of bytes received by the process * * Context: - * The process which receives a udp message + * The process which received a UDP message */ probe udp.recvmsg = kernel.function("udp_recvmsg") { name = "udp.recvmsg" @@ -59,12 +59,12 @@ probe udp.recvmsg = kernel.function("udp_recvmsg") { } /** - * probe udp.recvmsg.return - An attempt to receive a UDP message received has been completed - * @name: Name of this probe - * @size: Number of bytes received + * probe udp.recvmsg.return - Fires whenever an attempt to receive a UDP message received is completed + * @name: The name of this probe + * @size: Number of bytes received by the process * * Context: - * The process which receives a udp message + * The process which received a UDP message */ probe udp.recvmsg.return = kernel.function("udp_recvmsg").return { name = "udp.recvmsg" @@ -72,13 +72,13 @@ probe udp.recvmsg.return = kernel.function("udp_recvmsg").return { } /** - * probe udp.disconnect - A process requests for UPD to be UDP disconnected - * @name: Name of this probe - * @sock: Network socket + * probe udp.disconnect - Fires when a process requests for a UDP disconnection + * @name: The name of this probe + * @sock: Network socket used by the process * @flags: Flags (e.g. FIN, etc) * * Context: - * The process which disconnects UDP + * The process which requests a UDP disconnection */ probe udp.disconnect = kernel.function("udp_disconnect") { name = "udp.disconnect" @@ -88,11 +88,11 @@ probe udp.disconnect = kernel.function("udp_disconnect") { /** * probe udp.disconnect.return - UDP has been disconnected successfully - * @name: Name of this probe + * @name: The name of this probe * @ret: Error code (0: no error) * * Context: - * The process which disconnects udp + * The process which requested a UDP disconnection */ probe udp.disconnect.return = kernel.function("udp_disconnect").return { name = "udp.disconnect" diff --git a/tapsets.cxx b/tapsets.cxx index 6efcb3af..2f940b29 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -9770,8 +9770,13 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline(1) << "return register_trace_" << p->tracepoint_name << "(enter_tracepoint_probe_" << i << ");"; s.op->newline(-1) << "}"; - s.op->newline() << "static int unregister_tracepoint_probe_" << i << "(void) {"; - s.op->newline(1) << "return unregister_trace_" << p->tracepoint_name + + // NB: we're not prepared to deal with unreg failures. However, failures + // can only occur if the tracepoint doesn't exist (yet?), or if we + // weren't even registered. The former should be OKed by the initial + // registration call, and the latter is safe to ignore. + s.op->newline() << "static void unregister_tracepoint_probe_" << i << "(void) {"; + s.op->newline(1) << "(void) unregister_trace_" << p->tracepoint_name << "(enter_tracepoint_probe_" << i << ");"; s.op->newline(-1) << "}"; s.op->newline(); @@ -9780,7 +9785,7 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s) // emit an array of registration functions for easy init/shutdown s.op->newline() << "static struct stap_tracepoint_probe {"; s.op->newline(1) << "int (*reg)(void);"; - s.op->newline(0) << "int (*unreg)(void);"; + s.op->newline(0) << "void (*unreg)(void);"; s.op->newline(-1) << "} stap_tracepoint_probes[] = {"; s.op->indent(1); for (unsigned i = 0; i < probes.size(); ++i) diff --git a/testsuite/buildok/task-embedded.stp b/testsuite/buildok/task-embedded.stp index 4d1f5300..d35f3e0d 100755 --- a/testsuite/buildok/task-embedded.stp +++ b/testsuite/buildok/task-embedded.stp @@ -14,6 +14,8 @@ probe begin { task_nice (0) + task_cpu (0) + task_open_file_handles (0) + - task_max_file_handles (0)) + task_max_file_handles (0) + + pid2task(0)) print (task_execname (0)) + print (pid2execname (0)) } diff --git a/testsuite/buildok/task_test.stp b/testsuite/buildok/task_test.stp index c8da7da5..792f96ea 100755 --- a/testsuite/buildok/task_test.stp +++ b/testsuite/buildok/task_test.stp @@ -16,5 +16,7 @@ probe begin { log(sprint(task_cpu(c))) log(sprint(task_open_file_handles(c))) log(sprint(task_max_file_handles(c))) + log(sprint(pid2task(pid()))) + log(sprint(pid2execname(pid()))) exit() } diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index a4bd5e2c..b4214436 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -1,5 +1,4 @@ - -set test "sduprobes" +set test "static_uprobes" # Compile a C program to use as the user-space probing target set sup_srcpath "[pwd]/static_uprobes.c" @@ -115,9 +114,7 @@ if { $res != "" } { pass "$test compiling C -g" } -spawn mv $sup_srcpath "[pwd]/static_uprobes.cc" -set sup_srcpath "[pwd]/static_uprobes.cc" -set sup_flags "$sup_flags c++" +set sup_flags "$sup_flags additional_flags=-x additional_flags=c++" set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags] if { $res != "" } { verbose "target_compile failed: $res" 2 @@ -163,9 +160,9 @@ if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" } set ok 0 -# spawn objcopy -R .probes $supcplus_exepath $sup_exepath -verbose -log "cp $supcplus_exepath $sup_exepath" -spawn cp $supcplus_exepath $sup_exepath +# Test setting a probe without .probes using only dwarf label info +verbose -log "objcopy -R .probes $supcplus_exepath $sup_exepath" +spawn objcopy -R .probes $supcplus_exepath $sup_exepath verbose -log "spawn stap -c $sup_exepath $sup_stppath" spawn stap -c $sup_exepath $sup_stppath expect { @@ -182,7 +179,4 @@ wait if {$ok == 5} { pass "$test C++" } { fail "$test C++ ($ok)" } -# catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_hpath $sup_stppath} - -# It's not so important to clean up, and it's unhelpful if -# one needs to diagnose a test failure. +catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath} diff --git a/translate.cxx b/translate.cxx index f4c28536..377a11fb 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4700,6 +4700,15 @@ dump_unwindsyms (Dwfl_Module *m, c->output << "static struct _stp_module _stp_module_" << stpmod_idx << " = {\n"; c->output << ".name = " << lex_cast_qstring (modname) << ", \n"; + + // Get the canonical path of the main file for comparison at runtime. + // When given directly by the user through -d or in case of the kernel + // name and path might differ. path should be used for matching. + const char *mainfile; + dwfl_module_info (m, NULL, NULL, NULL, NULL, NULL, &mainfile, NULL); + mainfile = canonicalize_file_name(mainfile); + c->output << ".path = " << lex_cast_qstring (mainfile) << ",\n"; + c->output << ".dwarf_module_base = 0x" << hex << base << dec << ", \n"; if (unwind != NULL) |