From 3d4bc8bea6b45893bd4b49f44df26bd602b4cba5 Mon Sep 17 00:00:00 2001 From: hunt Date: Thu, 7 Apr 2005 15:17:29 +0000 Subject: Update to use relayfs. --- runtime/docs/html/dir_000003.html | 2 + runtime/docs/html/dir_000004.html | 2 + runtime/docs/html/dtr_8mod_8c-source.html | 63 ++-- runtime/docs/html/files.html | 2 + runtime/docs/html/globals.html | 3 +- runtime/docs/html/globals_func.html | 3 +- runtime/docs/html/group__scbuf.html | 70 +++- runtime/docs/html/group__stack.html | 51 ++- runtime/docs/html/group__sym.html | 2 +- .../docs/html/kprobe__where__funct_8c-source.html | 4 +- runtime/docs/html/scbuf_8c-source.html | 164 +++++---- runtime/docs/html/stack_8c-source.html | 43 +-- runtime/docs/html/stack_8c.html | 4 +- runtime/docs/html/structmap__root.html | 2 +- runtime/docs/html/test4_2dtr_8c-source.html | 371 ++++++++++++++------- runtime/docs/html/todo.html | 7 +- 16 files changed, 521 insertions(+), 272 deletions(-) (limited to 'runtime/docs/html') diff --git a/runtime/docs/html/dir_000003.html b/runtime/docs/html/dir_000003.html index 173623b3..b9e20e19 100644 --- a/runtime/docs/html/dir_000003.html +++ b/runtime/docs/html/dir_000003.html @@ -13,6 +13,8 @@

Files

file  dtr.c [code] +file  dtr.mod.c [code] + file  nrec.c [code] file  README [code] diff --git a/runtime/docs/html/dir_000004.html b/runtime/docs/html/dir_000004.html index f2294de2..d3e72861 100644 --- a/runtime/docs/html/dir_000004.html +++ b/runtime/docs/html/dir_000004.html @@ -13,6 +13,8 @@

Files

file  kprobe_where_funct.c [code] +file  kprobe_where_funct.mod.c [code] + file  README [code] diff --git a/runtime/docs/html/dtr_8mod_8c-source.html b/runtime/docs/html/dtr_8mod_8c-source.html index 1deec9c6..e497c5c4 100644 --- a/runtime/docs/html/dtr_8mod_8c-source.html +++ b/runtime/docs/html/dtr_8mod_8c-source.html @@ -3,7 +3,7 @@ SystemTap: probes/test4/dtr.mod.c Source File - +
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages
@@ -27,30 +27,39 @@ 00018 __attribute_used__ 00019 __attribute__((section("__versions"))) = { 00020 { 0x506abef7, "struct_module" }, -00021 { 0xb240ca65, "schedule_work" }, -00022 { 0x1b9aca3f, "jprobe_return" }, -00023 { 0xe3b0192b, "vscnprintf" }, -00024 { 0x45e5f47f, "register_kprobe" }, -00025 { 0x1e736243, "unregister_kprobe" }, -00026 { 0xdd03a51e, "register_jprobe" }, -00027 { 0x49a83d3a, "unregister_jprobe" }, -00028 { 0x3fa03a97, "memset" }, -00029 { 0xc16fe12d, "__memcpy" }, -00030 { 0xe914e41e, "strcpy" }, -00031 { 0xe2d5255a, "strcmp" }, -00032 { 0x2fd1d81c, "vfree" }, -00033 { 0x37a0cba, "kfree" }, -00034 { 0xd6ee688f, "vmalloc" }, -00035 { 0x8ce16b3f, "__kmalloc" }, -00036 { 0x8e3c9cc3, "vprintk" }, -00037 { 0xdd132261, "printk" }, -00038 }; -00039 -00040 static const char __module_depends[] -00041 __attribute_used__ -00042 __attribute__((section(".modinfo"))) = -00043 "depends="; -00044 -00045 -00046 MODULE_INFO(srcversion, "3CC4F9300C5C4E353BD2804"); +00021 { 0xfcdec747, "sock_release" }, +00022 { 0x8968634b, "netlink_kernel_create" }, +00023 { 0xb240ca65, "schedule_work" }, +00024 { 0x1b9aca3f, "jprobe_return" }, +00025 { 0x757b6858, "skb_dequeue" }, +00026 { 0xd4aed67a, "netlink_ack" }, +00027 { 0x5fc0695e, "__kfree_skb" }, +00028 { 0xaa1449d7, "netlink_unicast" }, +00029 { 0x3958414f, "skb_over_panic" }, +00030 { 0x559dbbb8, "alloc_skb" }, +00031 { 0x7ec9bfbc, "strncpy" }, +00032 { 0xe3b0192b, "vscnprintf" }, +00033 { 0x45e5f47f, "register_kprobe" }, +00034 { 0x1e736243, "unregister_kprobe" }, +00035 { 0xdd03a51e, "register_jprobe" }, +00036 { 0x49a83d3a, "unregister_jprobe" }, +00037 { 0x3fa03a97, "memset" }, +00038 { 0xc16fe12d, "__memcpy" }, +00039 { 0xe914e41e, "strcpy" }, +00040 { 0xe2d5255a, "strcmp" }, +00041 { 0x2fd1d81c, "vfree" }, +00042 { 0x37a0cba, "kfree" }, +00043 { 0xd6ee688f, "vmalloc" }, +00044 { 0x8ce16b3f, "__kmalloc" }, +00045 { 0x8e3c9cc3, "vprintk" }, +00046 { 0xdd132261, "printk" }, +00047 }; +00048 +00049 static const char __module_depends[] +00050 __attribute_used__ +00051 __attribute__((section(".modinfo"))) = +00052 "depends="; +00053 +00054 +00055 MODULE_INFO(srcversion, "01D3B50188E5E952DA9FD12"); diff --git a/runtime/docs/html/files.html b/runtime/docs/html/files.html index ef853864..f61591f6 100644 --- a/runtime/docs/html/files.html +++ b/runtime/docs/html/files.html @@ -24,9 +24,11 @@ probes/tasklet/README [code] probes/tasklet/stp_tasklet.c [code] probes/test4/dtr.c [code] + probes/test4/dtr.mod.c [code] probes/test4/nrec.c [code] probes/test4/README [code] probes/where_func/kprobe_where_funct.c [code] + probes/where_func/kprobe_where_funct.mod.c [code] probes/where_func/README [code] diff --git a/runtime/docs/html/globals.html b/runtime/docs/html/globals.html index 74f0f2e2..7ac847b4 100644 --- a/runtime/docs/html/globals.html +++ b/runtime/docs/html/globals.html @@ -50,7 +50,8 @@ Here is a list of all documented functions, variables, defines, enums, and typed : io.c
  • _stp_register_jprobes() : probes.c
  • _stp_register_kprobes() : probes.c
  • _stp_ret_addr() -: current.c
  • _stp_strncpy_from_user() +: current.c
  • _stp_stack_print() +: stack.c
  • _stp_strncpy_from_user() : copy.c
  • _stp_unregister_jprobes() : probes.c
  • _stp_unregister_kprobes() : probes.c
  • _stp_valloc() diff --git a/runtime/docs/html/globals_func.html b/runtime/docs/html/globals_func.html index 051cf88c..1562f9d2 100644 --- a/runtime/docs/html/globals_func.html +++ b/runtime/docs/html/globals_func.html @@ -46,7 +46,8 @@ : io.c
  • _stp_register_jprobes() : probes.c
  • _stp_register_kprobes() : probes.c
  • _stp_ret_addr() -: current.c
  • _stp_strncpy_from_user() +: current.c
  • _stp_stack_print() +: stack.c
  • _stp_strncpy_from_user() : copy.c
  • _stp_unregister_jprobes() : probes.c
  • _stp_unregister_kprobes() : probes.c
  • _stp_valloc() diff --git a/runtime/docs/html/group__scbuf.html b/runtime/docs/html/group__scbuf.html index c5e0d6e0..89033737 100644 --- a/runtime/docs/html/group__scbuf.html +++ b/runtime/docs/html/group__scbuf.html @@ -17,29 +17,26 @@ void _stp_sprint (const char *fmt,...)  Sprint into the scratch buffer.
    - -void _stp_sprint_str (const char *str) +void _stp_sprint_str (const char *str) -void _stp_scbuf_clear (void) + Write a string into the scratch buffer.
    +char * _stp_scbuf_clear (void)  Clear the scratch buffer.
    -

    Variables

    - -char _stp_scbuf [8191+1] - - Scratch buffer for printing, building strings, etc.

    Detailed Description

    Scratch Buffer Functions.

    -The scratch buffer is for collecting output before storing in a map, printing, etc. This is a per-cpu static buffer. It is necessary because of the limited stack space available in the kernel.


    Function Documentation

    +The scratch buffer is for collecting output before storing in a map, printing, etc. This is a per-cpu static buffer. It is necessary because of the limited stack space available in the kernel.

    +

    Todo:
    Need careful review of these to insure safety.
    +

    Function Documentation

    +References _stp_sprint().
    - + @@ -60,11 +57,12 @@ The scratch buffer is for collecting output before storing in a map, printing, e

    Clear the scratch buffer.

    -Output from _stp_sprint() will accumulate in the buffer until this is called. +This function should be called before anything is written to the scratch buffer. Output will accumulate in the buffer until this function is called again.

    Returns:
    A pointer to the buffer.
    +

    -Definition at line 59 of file scbuf.c. +Definition at line 74 of file scbuf.c.

    -References _stp_scbuf, and STP_BUF_LEN. +References STP_BUF_LEN.

    void _stp_scbuf_clear char* _stp_scbuf_clear void 

    @@ -103,7 +101,7 @@ References _stp_scbuf, and

    Sprint into the scratch buffer.

    -Like printf, except output goes into _stp_scbuf, which will contain the null-terminated output. Safe because overflowing _stp_scbuf is not allowed. Size is limited by length of scratch buffer, STP_BUF_LEN.

    +Like printf, except output goes into a global scratch buffer which will contain the null-terminated output. Safe because overflowing the buffer is not allowed. Size is limited by length of scratch buffer, STP_BUF_LEN.

    Parameters:
    @@ -112,11 +110,51 @@ Like printf, except output goes into
    See also:
    _stp_scbuf_clear

    -Definition at line 32 of file scbuf.c. +Definition at line 34 of file scbuf.c.

    -References _stp_scbuf, and STP_BUF_LEN. +References STP_BUF_LEN.

    Referenced by _stp_symbol_sprint().

    fmt A printf-style format string followed by a variable number of args.
    +

    + + + + +
    + + + + + + + + + +
    void _stp_sprint_str const char *  str  ) 
    +
    + + + + + +
    +   + + +

    +Write a string into the scratch buffer. +

    +Copies a string into a global scratch buffer. Safe because overflowing the buffer is not allowed. Size is limited by length of scratch buffer, STP_BUF_LEN. This is more efficient than using _stp_sprint().

    +

    Parameters:
    + + +
    str A string.
    +
    + +

    +Definition at line 56 of file scbuf.c. +

    +References STP_BUF_LEN.

    diff --git a/runtime/docs/html/group__stack.html b/runtime/docs/html/group__stack.html index bf112d0a..159a529f 100644 --- a/runtime/docs/html/group__stack.html +++ b/runtime/docs/html/group__stack.html @@ -8,11 +8,58 @@

    Stack Tracing Functions

    - + + +

    Functions

    -void _stp_stack_print (int verbose, int levels)
    void _stp_stack_print (int verbose, int levels)
     Print stack dump.
    char * _stp_stack_sprint (int verbose, int levels)
    +

    Function Documentation

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_stack_print int  verbose,
    int  levels
    +
    + + + + +
    +   + + +

    +Print stack dump. +

    +Prints a stack dump to the trace buffer.

    Parameters:
    + + +
    verbose Verbosity:
    +
    + +

    +Definition at line 151 of file stack.c.

    diff --git a/runtime/docs/html/group__sym.html b/runtime/docs/html/group__sym.html index c5301602..eafa03c2 100644 --- a/runtime/docs/html/group__sym.html +++ b/runtime/docs/html/group__sym.html @@ -98,7 +98,7 @@ Uses scbuf.

    Definition at line 45 of file sym.c.

    -References _stp_sprint().

    diff --git a/runtime/docs/html/kprobe__where__funct_8c-source.html b/runtime/docs/html/kprobe__where__funct_8c-source.html index dbe9ac74..7da50eda 100644 --- a/runtime/docs/html/kprobe__where__funct_8c-source.html +++ b/runtime/docs/html/kprobe__where__funct_8c-source.html @@ -78,9 +78,9 @@ 00069 00070 /* now walk the hash table and print out all the information */ 00071 foreach(funct_locations, ptr) { -00072 _stp_scbuf_clear(); +00072 char *str =_stp_scbuf_clear(); 00073 _stp_symbol_sprint (key1int(ptr)); -00074 dlog("%lld\t0x%p\t(%s)\n", ptr->val, key1int(ptr), _stp_scbuf); +00074 dlog("%lld\t0x%p\t(%s)\n", ptr->val, key1int(ptr), str); 00075 } 00076 00077 _stp_map_del(funct_locations); diff --git a/runtime/docs/html/scbuf_8c-source.html b/runtime/docs/html/scbuf_8c-source.html index a9e9ddc8..ffdfaac7 100644 --- a/runtime/docs/html/scbuf_8c-source.html +++ b/runtime/docs/html/scbuf_8c-source.html @@ -5,75 +5,99 @@

    -

    scbuf.c

    00001 #ifndef _SCBUF_C_
    -00002 #define _SCBUF_C_
    +

    scbuf.c

    00001 #ifndef _SCBUF_C_ /* -*- linux-c -*- */
    +00002 #define _SCBUF_C_
     00003 
    -00004 /* -*- linux-c -*- */
    -00005 /** @file scbuf.c
    -00006  * @addtogroup scbuf Scratch Buffer
    -00007  * Scratch Buffer Functions.
    -00008  * The scratch buffer is for collecting output before storing in a map,
    -00009  * printing, etc. This is a per-cpu static buffer.  It is necessary because 
    -00010  * of the limited stack space available in the kernel.
    -00011  * @{
    -00012  */
    -00013 
    -00014 /** Maximum size of buffer, not including terminating NULL */
    -00015 #define STP_BUF_LEN 8191
    -00016 
    -00017 /** Scratch buffer for printing, building strings, etc */
    -00018 char _stp_scbuf[STP_BUF_LEN+1];
    -00019 static int _stp_scbuf_len = STP_BUF_LEN;
    -00020 
    -00021 /** Sprint into the scratch buffer.
    -00022  * Like printf, except output goes into  #_stp_scbuf,
    -00023  * which will contain the null-terminated output.
    -00024  * Safe because overflowing #_stp_scbuf is not allowed.
    -00025  * Size is limited by length of scratch buffer, STP_BUF_LEN.
    -00026  *
    -00027  * @param fmt A printf-style format string followed by a 
    -00028  * variable number of args.
    -00029  * @sa _stp_scbuf_clear
    -00030  */
    -00031 
    -00032 void _stp_sprint (const char *fmt, ...)
    -00033 {
    -00034   int num;
    -00035   va_list args;
    -00036   char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
    -00037   va_start(args, fmt);
    -00038   num = vscnprintf(buf, _stp_scbuf_len, fmt, args);
    -00039   va_end(args);
    -00040   if (num > 0)
    -00041     _stp_scbuf_len -= num;
    -00042 }
    -00043 
    -00044 void _stp_sprint_str (const char *str)
    -00045 {
    -00046   char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
    -00047   int num = strlen (str);
    -00048   if (num > _stp_scbuf_len)
    -00049     num = _stp_scbuf_len;
    -00050   strncpy (buf, str, num);
    -00051   _stp_scbuf_len -= num;
    -00052 }
    -00053 
    -00054 /** Clear the scratch buffer.
    -00055  * Output from _stp_sprint() will accumulate in the buffer
    -00056  * until this is called.
    -00057  */
    -00058 
    -00059 void _stp_scbuf_clear (void)
    -00060 {
    -00061   _stp_scbuf_len = STP_BUF_LEN;
    -00062   _stp_scbuf[0] = 0;
    -00063 }
    -00064 
    -00065 static char *_stp_scbuf_cur (void)
    -00066 {
    -00067   return _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
    -00068 }
    -00069 
    -00070 /** @} */
    -00071 #endif /* _SCBUF_C_ */
    +00004 #include <linux/config.h>
    +00005 
    +00006 /** @file scbuf.c
    +00007  * @addtogroup scbuf Scratch Buffer
    +00008  * Scratch Buffer Functions.
    +00009  * The scratch buffer is for collecting output before storing in a map,
    +00010  * printing, etc. This is a per-cpu static buffer.  It is necessary because 
    +00011  * of the limited stack space available in the kernel.
    +00012  * @todo Need careful review of these to insure safety.
    +00013  * @{
    +00014  */
    +00015 
    +00016 /** Maximum size of buffer, not including terminating NULL */
    +00017 #define STP_BUF_LEN 8191
    +00018 
    +00019 /** Scratch buffer for printing, building strings, etc */
    +00020 static char _stp_scbuf[NR_CPUS][STP_BUF_LEN+1];
    +00021 static int _stp_scbuf_len[NR_CPUS];
    +00022 
    +00023 /** Sprint into the scratch buffer.
    +00024  * Like printf, except output goes into a global scratch buffer
    +00025  * which will contain the null-terminated output.
    +00026  * Safe because overflowing the buffer is not allowed.
    +00027  * Size is limited by length of scratch buffer, STP_BUF_LEN.
    +00028  *
    +00029  * @param fmt A printf-style format string followed by a 
    +00030  * variable number of args.
    +00031  * @sa _stp_scbuf_clear
    +00032  */
    +00033 
    +00034 void _stp_sprint (const char *fmt, ...)
    +00035 {
    +00036         int num;
    +00037         va_list args;
    +00038         int cpu = smp_processor_id();
    +00039         char *buf = _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
    +00040         va_start(args, fmt);
    +00041         num = vscnprintf(buf, _stp_scbuf_len[cpu], fmt, args);
    +00042         va_end(args);
    +00043         if (num > 0)
    +00044                 _stp_scbuf_len[cpu] -= num;
    +00045 }
    +00046 
    +00047 /** Write a string into the scratch buffer.
    +00048  * Copies a string into a global scratch buffer.
    +00049  * Safe because overflowing the buffer is not allowed.
    +00050  * Size is limited by length of scratch buffer, STP_BUF_LEN.
    +00051  * This is more efficient than using _stp_sprint().
    +00052  *
    +00053  * @param str A string.
    +00054  */
    +00055 
    +00056 void _stp_sprint_str (const char *str)
    +00057 {
    +00058         int cpu = smp_processor_id();
    +00059         char *buf = _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
    +00060         int num = strlen (str);
    +00061         if (num > _stp_scbuf_len[cpu])
    +00062                 num = _stp_scbuf_len[cpu];
    +00063         strncpy (buf, str, num);
    +00064         _stp_scbuf_len[cpu] -= num;
    +00065 }
    +00066 
    +00067 /** Clear the scratch buffer.
    +00068  * This function should be called before anything is written to 
    +00069  * the scratch buffer.  Output will accumulate in the buffer
    +00070  * until this function is called again.  
    +00071  * @returns A pointer to the buffer.
    +00072  */
    +00073 
    +00074 char *_stp_scbuf_clear (void)
    +00075 {
    +00076         int cpu = smp_processor_id();
    +00077         _stp_scbuf_len[cpu] = STP_BUF_LEN;
    +00078         *_stp_scbuf[cpu] = 0;
    +00079         return _stp_scbuf[cpu];
    +00080 }
    +00081 
    +00082 /** Get the current top of the scratch buffer.
    +00083  * This returns the address of the location where
    +00084  * data will be written next in the scratch buffer.
    +00085  * @returns A pointer
    +00086  */
    +00087 
    +00088 static char *_stp_scbuf_cur (void)
    +00089 {
    +00090         int cpu = smp_processor_id();
    +00091         return _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
    +00092 }
    +00093 
    +00094 /** @} */
    +00095 #endif /* _SCBUF_C_ */
     
    diff --git a/runtime/docs/html/stack_8c-source.html b/runtime/docs/html/stack_8c-source.html index f4df8413..552f51cc 100644 --- a/runtime/docs/html/stack_8c-source.html +++ b/runtime/docs/html/stack_8c-source.html @@ -103,7 +103,7 @@ 00096 while (valid_stack_ptr(tinfo, (void *)ebp)) { 00097 addr = *(unsigned long *)(ebp + 4); 00098 _stp_symbol_sprint (addr); -00099 _stp_sprint_str("\n"); +00099 _stp_sprint_str("\n"); 00100 ebp = *(unsigned long *)ebp; 00101 } 00102 #else @@ -111,7 +111,7 @@ 00104 addr = *stack++; 00105 if (_stp_kta (addr)) { 00106 _stp_symbol_sprint (addr); -00107 _stp_sprint_str ("\n"); +00107 _stp_sprint_str ("\n"); 00108 } 00109 } 00110 #endif @@ -149,21 +149,26 @@ 00142 } 00143 00144 #endif /* i386 */ -00145 -00146 void _stp_stack_print (int verbose, int levels) -00147 { -00148 unsigned long stack; -00149 return __stp_stack_print (&stack, verbose, levels); -00150 } -00151 -00152 char *_stp_stack_sprint (int verbose, int levels) -00153 { -00154 unsigned long stack; -00155 char *ptr = _stp_scbuf_cur(); -00156 __stp_stack_sprint (&stack, verbose, levels); -00157 return ptr; -00158 } -00159 -00160 /** @} */ -00161 #endif /* _STACK_C_ */ +00145 +00146 /** Print stack dump. +00147 * Prints a stack dump to the trace buffer. +00148 * @param verbose Verbosity: +00149 */ +00150 +00151 void _stp_stack_print (int verbose, int levels) +00152 { +00153 unsigned long stack; +00154 return __stp_stack_print (&stack, verbose, levels); +00155 } +00156 +00157 char *_stp_stack_sprint (int verbose, int levels) +00158 { +00159 unsigned long stack; +00160 char *ptr = _stp_scbuf_cur(); +00161 __stp_stack_sprint (&stack, verbose, levels); +00162 return ptr; +00163 } +00164 +00165 /** @} */ +00166 #endif /* _STACK_C_ */
    diff --git a/runtime/docs/html/stack_8c.html b/runtime/docs/html/stack_8c.html index 65cb258e..093cc186 100644 --- a/runtime/docs/html/stack_8c.html +++ b/runtime/docs/html/stack_8c.html @@ -13,9 +13,9 @@ Go to the source code of this file. - + + diff --git a/runtime/docs/html/structmap__root.html b/runtime/docs/html/structmap__root.html index d6e95bd6..2a4eb819 100644 --- a/runtime/docs/html/structmap__root.html +++ b/runtime/docs/html/structmap__root.html @@ -99,7 +99,7 @@ Definition at line 67 of file

    this is the creation data saved between the key functions and the set/get functions

    -

    Todo:
    Needs to be per-cpu data for SMP support
    +
    Todo:
    Needs to be per-cpu data for SMP support

    Definition at line 93 of file map.h. diff --git a/runtime/docs/html/test4_2dtr_8c-source.html b/runtime/docs/html/test4_2dtr_8c-source.html index 2847b88a..af19db1a 100644 --- a/runtime/docs/html/test4_2dtr_8c-source.html +++ b/runtime/docs/html/test4_2dtr_8c-source.html @@ -13,138 +13,251 @@ 00004 #include <linux/module.h> 00005 #include <linux/interrupt.h> 00006 #include <net/sock.h> -00007 -00008 #include "runtime.h" -00009 #include "io.c" -00010 #include "map.c" -00011 #include "probes.c" -00012 #include "stack.c" -00013 -00014 MODULE_DESCRIPTION("SystemTap probe: test4"); -00015 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); -00016 -00017 static char tbuffer[2][50000]; -00018 static void stp_helper(void *); -00019 static DECLARE_WORK(stp_work, stp_helper, tbuffer); -00020 -00021 MAP opens, reads, writes, traces; -00022 static int bufcount = 0; -00023 -00024 static void stp_helper (void *data) -00025 { -00026 dlog ("HELPER\n"); -00027 } +00007 #include <linux/netlink.h> +00008 +00009 #include "runtime.h" +00010 #include "io.c" +00011 #include "map.c" +00012 #include "probes.c" +00013 #include "stack.c" +00014 +00015 MODULE_DESCRIPTION("SystemTap probe: test4"); +00016 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); +00017 +00018 static char tbuffer[2][50000]; +00019 static void stp_helper(void *); +00020 static DECLARE_WORK(stp_work, stp_helper, tbuffer); +00021 +00022 MAP opens, reads, writes, traces; +00023 static int bufcount = 0; +00024 +00025 /* netlink control channel */ +00026 static struct sock *control; +00027 static int seq = 0; 00028 -00029 asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) -00030 { -00031 _stp_map_key_str (opens, current->comm); -00032 _stp_map_add_int64 (opens, 1); -00033 jprobe_return(); -00034 return 0; -00035 } -00036 -00037 asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) -00038 { -00039 _stp_map_key_str (reads, current->comm); -00040 _stp_map_stat_add (reads, count); -00041 jprobe_return(); -00042 return 0; -00043 } -00044 -00045 asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) -00046 { -00047 _stp_map_key_str (writes, current->comm); -00048 _stp_map_stat_add (writes, count); -00049 jprobe_return(); -00050 return 0; -00051 } +00029 int pid; +00030 /* +00031 * send_reply - send reply to userspace over netlink control channel +00032 */ +00033 static int send_reply(int type, void *reply, int len, int pid) +00034 { +00035 struct sk_buff *skb; +00036 struct nlmsghdr *nlh; +00037 void *data; +00038 int size; +00039 int err; +00040 +00041 size = NLMSG_SPACE(len); +00042 skb = alloc_skb(size, GFP_KERNEL); +00043 if (!skb) +00044 return -1; +00045 nlh = NLMSG_PUT(skb, pid, seq++, type, size - sizeof(*nlh)); +00046 nlh->nlmsg_flags = 0; +00047 data = NLMSG_DATA(nlh); +00048 memcpy(data, reply, len); +00049 err = netlink_unicast(control, skb, pid, MSG_DONTWAIT); +00050 +00051 return 0; 00052 -00053 int inst_show_cpuinfo(struct seq_file *m, void *v) -00054 { -00055 _stp_stack_print (0,0); -00056 _stp_stack_print (1,0); -00057 -00058 _stp_scbuf_clear(); -00059 _stp_list_add (traces, _stp_stack_sprint(0,0)); -00060 if (bufcount++ == 0) -00061 schedule_work (&stp_work); -00062 -00063 jprobe_return(); -00064 return 0; -00065 } -00066 -00067 -00068 static struct jprobe dtr_probes[] = { -00069 { -00070 .kp.addr = (kprobe_opcode_t *)"sys_open", -00071 .entry = (kprobe_opcode_t *) inst_sys_open -00072 }, -00073 { -00074 .kp.addr = (kprobe_opcode_t *)"sys_read", -00075 .entry = (kprobe_opcode_t *) inst_sys_read -00076 }, -00077 { -00078 .kp.addr = (kprobe_opcode_t *)"sys_write", -00079 .entry = (kprobe_opcode_t *) inst_sys_write -00080 }, -00081 { -00082 .kp.addr = (kprobe_opcode_t *)"show_cpuinfo", -00083 .entry = (kprobe_opcode_t *) inst_show_cpuinfo, -00084 }, -00085 }; +00053 nlmsg_failure: +00054 if (skb) +00055 kfree_skb(skb); +00056 +00057 return -1; +00058 } +00059 +00060 static char pbuff[1024]; +00061 +00062 void nlog (const char *fmt, ...) +00063 { +00064 int len; +00065 va_list args; +00066 va_start(args, fmt); +00067 len = vscnprintf (pbuff, sizeof(pbuff), fmt, args) + 1; +00068 va_end(args); +00069 send_reply (42, pbuff, len, pid); +00070 } +00071 +00072 /* +00073 * msg_rcv_skb - dispatch userspace requests from netlink control channel +00074 */ +00075 static void msg_rcv_skb(struct sk_buff *skb) +00076 { +00077 struct nlmsghdr *nlh = NULL; +00078 int flags; +00079 int nlmsglen, skblen; +00080 void *data; +00081 +00082 skblen = skb->len; +00083 // dlog ("skblen = %d %d\n", skblen, sizeof(*nlh)); +00084 if (skblen < sizeof (*nlh)) +00085 return; 00086 -00087 #define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe)) -00088 -00089 static int init_dtr(void) -00090 { -00091 int ret; -00092 -00093 opens = _stp_map_new (1000, INT64); -00094 reads = _stp_map_new (1000, STAT); -00095 writes = _stp_map_new (1000, STAT); -00096 traces = _stp_list_new (1000, STRING); -00097 -00098 ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE); -00099 -00100 dlog("instrumentation is enabled...\n"); -00101 return ret; +00087 nlh = (struct nlmsghdr *)skb->data; +00088 nlmsglen = nlh->nlmsg_len; +00089 +00090 // dlog ("nlmsghlen=%d\n", nlmsglen); +00091 if (nlmsglen < sizeof(*nlh) || skblen < nlmsglen) +00092 return; +00093 +00094 pid = nlh->nlmsg_pid; +00095 flags = nlh->nlmsg_flags; +00096 +00097 // dlog ("pid=%d flags=%x %x %x %x\n", pid, flags, NLM_F_REQUEST, MSG_TRUNC, NLM_F_ACK); +00098 if (pid <= 0 || !(flags & NLM_F_REQUEST)) { +00099 netlink_ack(skb, nlh, -EINVAL); +00100 return; +00101 } 00102 -00103 } -00104 -00105 static void cleanup_dtr(void) -00106 { -00107 struct map_node_stat *st; -00108 struct map_node_int64 *ptr; -00109 struct map_node_str *sptr; -00110 -00111 _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE); -00112 -00113 foreach (traces, sptr) -00114 dlog ("trace: %s\n", sptr->str); -00115 -00116 foreach (opens, ptr) -00117 dlog ("opens[%s] = %lld\n", key1str(ptr), ptr->val); -00118 dlog ("\n"); -00119 -00120 foreach (reads, st) -00121 dlog ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), -00122 st->stats.count, st->stats.sum, st->stats.min, st->stats.max); -00123 dlog ("\n"); -00124 -00125 foreach (writes, st) -00126 dlog ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), -00127 st->stats.count, st->stats.sum, st->stats.min, st->stats.max); -00128 dlog ("\n"); -00129 -00130 _stp_map_del (opens); -00131 _stp_map_del (reads); -00132 _stp_map_del (writes); -00133 -00134 dlog("EXIT\n"); -00135 } -00136 -00137 module_init(init_dtr); -00138 module_exit(cleanup_dtr); -00139 MODULE_LICENSE("GPL"); +00103 if (flags & MSG_TRUNC) { +00104 netlink_ack(skb, nlh, -ECOMM); +00105 return; +00106 } +00107 +00108 data = NLMSG_DATA(nlh); +00109 +00110 // dlog ("NETLINK: Got message \"%s\" of type %d from pid %d\n", data, nlh->nlmsg_type,pid); +00111 +00112 if (flags & NLM_F_ACK) +00113 netlink_ack(skb, nlh, 0); +00114 +00115 send_reply (42, "Howdy Partner", 14, pid); +00116 } +00117 +00118 static void msg_rcv(struct sock *sk, int len) +00119 { +00120 struct sk_buff *skb; +00121 dlog ("netlink message received\n"); +00122 while ((skb = skb_dequeue(&sk->sk_receive_queue))) { +00123 msg_rcv_skb(skb); +00124 kfree_skb(skb); +00125 } +00126 } +00127 +00128 static void stp_helper (void *data) +00129 { +00130 dlog ("HELPER\n"); +00131 } +00132 +00133 asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) +00134 { +00135 _stp_map_key_str (opens, current->comm); +00136 _stp_map_add_int64 (opens, 1); +00137 jprobe_return(); +00138 return 0; +00139 } 00140 +00141 asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) +00142 { +00143 _stp_map_key_str (reads, current->comm); +00144 _stp_map_stat_add (reads, count); +00145 jprobe_return(); +00146 return 0; +00147 } +00148 +00149 asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) +00150 { +00151 _stp_map_key_str (writes, current->comm); +00152 _stp_map_stat_add (writes, count); +00153 jprobe_return(); +00154 return 0; +00155 } +00156 +00157 int inst_show_cpuinfo(struct seq_file *m, void *v) +00158 { +00159 _stp_stack_print (0,0); +00160 _stp_stack_print (1,0); +00161 +00162 _stp_scbuf_clear(); +00163 _stp_list_add (traces, _stp_stack_sprint(0,0)); +00164 if (bufcount++ == 0) +00165 schedule_work (&stp_work); +00166 +00167 jprobe_return(); +00168 return 0; +00169 } +00170 +00171 +00172 static struct jprobe dtr_probes[] = { +00173 { +00174 .kp.addr = (kprobe_opcode_t *)"sys_open", +00175 .entry = (kprobe_opcode_t *) inst_sys_open +00176 }, +00177 { +00178 .kp.addr = (kprobe_opcode_t *)"sys_read", +00179 .entry = (kprobe_opcode_t *) inst_sys_read +00180 }, +00181 { +00182 .kp.addr = (kprobe_opcode_t *)"sys_write", +00183 .entry = (kprobe_opcode_t *) inst_sys_write +00184 }, +00185 { +00186 .kp.addr = (kprobe_opcode_t *)"show_cpuinfo", +00187 .entry = (kprobe_opcode_t *) inst_show_cpuinfo, +00188 }, +00189 }; +00190 +00191 #define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe)) +00192 +00193 static int init_dtr(void) +00194 { +00195 int ret; +00196 +00197 control = netlink_kernel_create(31, msg_rcv); +00198 if (!control) { +00199 dlog ("Couldn't create netlink channel\n"); +00200 return -1; +00201 } +00202 +00203 opens = _stp_map_new (1000, INT64); +00204 reads = _stp_map_new (1000, STAT); +00205 writes = _stp_map_new (1000, STAT); +00206 traces = _stp_list_new (1000, STRING); +00207 +00208 ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE); +00209 +00210 dlog("instrumentation is enabled...\n"); +00211 return ret; +00212 +00213 } +00214 +00215 static void cleanup_dtr(void) +00216 { +00217 struct map_node_stat *st; +00218 struct map_node_int64 *ptr; +00219 struct map_node_str *sptr; +00220 +00221 _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE); +00222 +00223 foreach (traces, sptr) +00224 nlog ("trace: %s\n", sptr->str); +00225 +00226 foreach (opens, ptr) +00227 nlog ("opens[%s] = %lld\n", key1str(ptr), ptr->val); +00228 nlog ("\n"); +00229 +00230 foreach (reads, st) +00231 nlog ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), +00232 st->stats.count, st->stats.sum, st->stats.min, st->stats.max); +00233 nlog ("\n"); +00234 +00235 foreach (writes, st) +00236 nlog ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), +00237 st->stats.count, st->stats.sum, st->stats.min, st->stats.max); +00238 nlog ("\n"); +00239 +00240 _stp_map_del (opens); +00241 _stp_map_del (reads); +00242 _stp_map_del (writes); +00243 +00244 if (control) +00245 sock_release(control->sk_socket); +00246 +00247 dlog("EXIT\n"); +00248 } +00249 +00250 module_init(init_dtr); +00251 module_exit(cleanup_dtr); +00252 MODULE_LICENSE("GPL"); +00253 diff --git a/runtime/docs/html/todo.html b/runtime/docs/html/todo.html index 7435d106..22265a06 100644 --- a/runtime/docs/html/todo.html +++ b/runtime/docs/html/todo.html @@ -5,7 +5,7 @@

    -

    Todo List

    +

    Todo List

    Global map_root::create
    Needs to be per-cpu data for SMP support
    @@ -44,4 +44,9 @@
    Global _stp_map_stat_add (MAP map, int64_t val)
    Histograms don't work yet.
    +

    +

    +
    Group scbuf
    +
    Need careful review of these to insure safety.
    +
    -- cgit

    Functions

    -void _stp_stack_print (int verbose, int levels)
    void _stp_stack_print (int verbose, int levels)
     Print stack dump.
    char * _stp_stack_sprint (int verbose, int levels)