From b9c556e44326b40b2c927a0a5b5626332a8c9587 Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 22 Mar 2005 08:57:11 +0000 Subject: *** empty log message *** --- runtime/docs/footer.html | 3 + runtime/docs/header.html | 6 +- runtime/docs/html/README-source.html | 65 +- runtime/docs/html/alloc_8h-source.html | 124 +- runtime/docs/html/annotated.html | 22 +- runtime/docs/html/copy_8c-source.html | 80 +- runtime/docs/html/dir_000000.html | 43 + runtime/docs/html/dir_000001.html | 91 ++ runtime/docs/html/dir_000002.html | 29 + runtime/docs/html/dir_000003.html | 42 + runtime/docs/html/dir_000004.html | 30 + runtime/docs/html/dirs.html | 19 + runtime/docs/html/dtr_8mod_8c-source.html | 59 + runtime/docs/html/files.html | 41 +- runtime/docs/html/functions.html | 47 +- runtime/docs/html/functions_vars.html | 45 +- runtime/docs/html/globals.html | 96 +- runtime/docs/html/globals_defs.html | 27 +- runtime/docs/html/globals_func.html | 48 +- runtime/docs/html/globals_type.html | 13 +- runtime/docs/html/index.html | 30 +- runtime/docs/html/io_8c-source.html | 58 +- .../docs/html/kprobe__where__funct_8c-source.html | 90 ++ runtime/docs/html/map_8c-source.html | 1499 +++++++++++--------- runtime/docs/html/map_8c.html | 144 +- runtime/docs/html/map_8h-source.html | 286 ++-- runtime/docs/html/map_8h.html | 320 +---- runtime/docs/html/pages.html | 13 +- runtime/docs/html/probes.html | 10 + runtime/docs/html/probes_2README-source.html | 16 + .../html/probes_2shellsnoop_2README-source.html | 85 ++ .../docs/html/probes_2tasklet_2README-source.html | 22 + .../docs/html/probes_2test4_2README-source.html | 36 + .../html/probes_2where__func_2README-source.html | 38 + runtime/docs/html/probes_8c-source.html | 64 +- runtime/docs/html/runtime_8h-source.html | 17 +- runtime/docs/html/shellsnoop_2dtr_8c-source.html | 138 ++ runtime/docs/html/stack_8c-source.html | 45 +- runtime/docs/html/stp__tasklet_8c-source.html | 60 + runtime/docs/html/structmap__node.html | 194 +-- runtime/docs/html/structmap__root.html | 470 +----- runtime/docs/html/structstat.html | 166 +-- runtime/docs/html/test4_2dtr_8c-source.html | 117 ++ runtime/docs/html/todo.html | 18 +- runtime/docs/html/unionkey__data.html | 78 +- 45 files changed, 2541 insertions(+), 2403 deletions(-) create mode 100644 runtime/docs/footer.html create mode 100644 runtime/docs/html/dir_000000.html create mode 100644 runtime/docs/html/dir_000001.html create mode 100644 runtime/docs/html/dir_000002.html create mode 100644 runtime/docs/html/dir_000003.html create mode 100644 runtime/docs/html/dir_000004.html create mode 100644 runtime/docs/html/dirs.html create mode 100644 runtime/docs/html/dtr_8mod_8c-source.html create mode 100644 runtime/docs/html/kprobe__where__funct_8c-source.html create mode 100644 runtime/docs/html/probes.html create mode 100644 runtime/docs/html/probes_2README-source.html create mode 100644 runtime/docs/html/probes_2shellsnoop_2README-source.html create mode 100644 runtime/docs/html/probes_2tasklet_2README-source.html create mode 100644 runtime/docs/html/probes_2test4_2README-source.html create mode 100644 runtime/docs/html/probes_2where__func_2README-source.html create mode 100644 runtime/docs/html/shellsnoop_2dtr_8c-source.html create mode 100644 runtime/docs/html/stp__tasklet_8c-source.html create mode 100644 runtime/docs/html/test4_2dtr_8c-source.html (limited to 'runtime/docs') diff --git a/runtime/docs/footer.html b/runtime/docs/footer.html new file mode 100644 index 00000000..add9de59 --- /dev/null +++ b/runtime/docs/footer.html @@ -0,0 +1,3 @@ +
+Generated on $datetime for $projectname. + diff --git a/runtime/docs/header.html b/runtime/docs/header.html index f47a1c4f..9207e14e 100644 --- a/runtime/docs/header.html +++ b/runtime/docs/header.html @@ -1,7 +1,7 @@ -SystemTap: SystemTap Runtime Library +SystemTap Runtime Library - - +
SystemTap +
diff --git a/runtime/docs/html/README-source.html b/runtime/docs/html/README-source.html index 32a5d7a8..6110dbbb 100644 --- a/runtime/docs/html/README-source.html +++ b/runtime/docs/html/README-source.html @@ -1,14 +1,63 @@ -SystemTap: SystemTap Runtime Library +SystemTap: README Source File - - -

README

Go to the documentation of this file.
00001 
-

Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- + +

README

00001 /** @mainpage SystemTap Runtime Library
+00002  *
+00003  * @section intro_sec Introduction
+00004  *
+00005  * The SystemTap Runtime Library consists of all functions
+00006  * and code fragments needed by the compiler/translator to
+00007  * include in building a kernel module using kprobes.
+00008  *
+00009  * @section design_sec Design
+00010  * @subsection impl_sec Implementation
+00011  * The library is written in \c C and is really not a library but a collection of code
+00012  * That can be conditionally included in a modules. It will probably become a library later.
+00013  *
+00014  * @subsection map_sec Maps (Associative Arrays)
+00015  * Maps are implemented as hash lists. It is not expected that users will
+00016  * attempt to collect so much data in kernel space that performance problems will require
+00017  * more complex solutions such as AVL trees.
+00018  *
+00019  * Maps are created with _stp_map_new().  Each map can hold only one type of 
+00020  * data; int64, string, or statistics.  Each element belonging to a map can have up to 2 keys
+00021  * and a value.  Implemented key types are strings and longs.
+00022  *      
+00023  * To simplify the implementation, the functions to set the key and the functions to set the data are separated.
+00024  * That means we need only 4 functions to set the key and 3 functions to set the value. 
+00025  *
+00026  * For example:
+00027  * @include map.c
+00028 
+00029  * All elements have a default value of 0 (or NULL).  Elements are only saved to the map when their value is set
+00030  * to something nonzero.  This means that querying for the existance of a key is inexpensive because
+00031  * no element is created, just a hash table lookup.
+00032  *
+00033  * @subsection list_sec Lists
+00034  * A list is a special map which has internally ascending long integer keys.  Adding a value to
+00035  * a list does not require setting a key first. Create a list with _stp_map_new(). Add to it
+00036  * with _stp_list_add_str() and _stp_list_add_int64().  Clear it with _stp_list_clear().
+00037  *
+00038  * @section status_sec Status
+00039  * @li Maps are implemented and tested. Histograms are not yet finished.
+00040  * @li Copy_From_User functions are done.
+00041  * @li If maps overflow or memory runs out for some reason, globals are set but nothing is done yet.
+00042  * I expect to implement a function to tell the system to either ignore it or unload the module and quit.
+00043  * @li Locking and per-cpu data are not yet implemented to be SMP-safe.  This is not yet necessary because the
+00044  * current kprobes implementation single-threads probes for us. 
+00045  *
+00046  * @section probe_sec Example Probes
+00047  * 
+00048  * Working sample probe code using the runtime is in runtime/probes.
+00049  * <a href="dir_000000.html"> Browse probes.</a>
+00050  * 
+00051  * @section todo_sec ToDo 
+00052  * \link todo Click Here for Complete List \endlink
+00053  */
+

+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/alloc_8h-source.html b/runtime/docs/html/alloc_8h-source.html index 42be2b62..7d2a3310 100644 --- a/runtime/docs/html/alloc_8h-source.html +++ b/runtime/docs/html/alloc_8h-source.html @@ -1,53 +1,83 @@ -SystemTap: SystemTap Runtime Library +SystemTap: alloc.h Source File - - -

alloc.h

Go to the documentation of this file.
00001 enum errorcode { ERR_NONE=0, ERR_NO_MEM };
-00002 enum errorcode _stp_error = ERR_NONE;
-00003 
-00012 inline void *_stp_alloc(size_t len)
-00013 {
-00014         void *ptr = kmalloc(len, GFP_ATOMIC);
-00015         if (ptr == NULL)
-00016                 _stp_error = ERR_NO_MEM;
-00017         return ptr;
-00018 }
-00019 
-00028 inline void *_stp_calloc(size_t len)
-00029 {
-00030         void *ptr = _stp_alloc(len);
-00031         if (ptr)
-00032                 memset(ptr, 0, len);
-00033         return ptr;
-00034 }
-00035 
-00043 inline void *_stp_valloc(size_t len)
-00044 {
-00045         void *ptr = vmalloc(len);
-00046         if (ptr)
-00047                 memset(ptr, 0, len);
-00048         else
-00049                 _stp_error = ERR_NO_MEM;
-00050         return ptr;
-00051 }
-00052 
-00057 inline void _stp_free(void *ptr)
-00058 {
-00059         if (ptr)
-00060                 kfree(ptr);
-00061 }
-00062 
-00067 inline void _stp_vfree(void *ptr)
-00068 {
-00069         if (ptr)
-00070                 vfree(ptr);
-00071 }
-

Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- + +

alloc.h

00001 /* -*- linux-c -*- */
+00002 
+00003 enum errorcode { ERR_NONE=0, ERR_NO_MEM };
+00004 enum errorcode _stp_error = ERR_NONE;
+00005 
+00006 /** Allocates memory within a probe.
+00007  * This is used for small allocations from within a running
+00008  * probe where the process cannot sleep. 
+00009  * @param len Number of bytes to allocate.
+00010  * @return a valid pointer on success or NULL on failure.
+00011  * @bug Currently uses kmalloc (GFP_ATOMIC).
+00012  */
+00013 
+00014 void *_stp_alloc(size_t len)
+00015 {
+00016         void *ptr = kmalloc(len, GFP_ATOMIC);
+00017         if (unlikely(ptr == NULL))
+00018                 _stp_error = ERR_NO_MEM;
+00019         return ptr;
+00020 }
+00021 
+00022 /** Allocates and clears memory within a probe.
+00023  * This is used for small allocations from within a running
+00024  * probe where the process cannot sleep. 
+00025  * @param len Number of bytes to allocate.
+00026  * @return a valid pointer on success or NULL on failure.
+00027  * @bug Currently uses kmalloc (GFP_ATOMIC).
+00028  */
+00029 
+00030 void *_stp_calloc(size_t len)
+00031 {
+00032         void *ptr = _stp_alloc(len);
+00033         if (likely(ptr))
+00034                 memset(ptr, 0, len);
+00035         return ptr;
+00036 }
+00037 
+00038 /** Allocates and clears memory outside a probe.
+00039  * This is typically used in the module initialization to
+00040  * allocate new maps, lists, etc.
+00041  * @param len Number of bytes to allocate.
+00042  * @return a valid pointer on success or NULL on failure.
+00043  */
+00044 
+00045 void *_stp_valloc(size_t len)
+00046 {
+00047         void *ptr = vmalloc(len);
+00048         if (likely(ptr))
+00049                 memset(ptr, 0, len);
+00050         else
+00051                 _stp_error = ERR_NO_MEM;
+00052         return ptr;
+00053 }
+00054 
+00055 /** Frees memory allocated by _stp_alloc or _stp_calloc.
+00056  * @param ptr pointer to memory to free
+00057  */
+00058 
+00059 void _stp_free(void *ptr)
+00060 {
+00061         if (likely(ptr))
+00062                 kfree(ptr);
+00063 }
+00064 
+00065 /** Frees memory allocated by _stp_valloc.
+00066  * @param ptr pointer to memory to free
+00067  */
+00068 
+00069 void _stp_vfree(void *ptr)
+00070 {
+00071         if (likely(ptr))
+00072                 vfree(ptr);
+00073 }
+

+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/annotated.html b/runtime/docs/html/annotated.html index cec81d58..d0cf4605 100644 --- a/runtime/docs/html/annotated.html +++ b/runtime/docs/html/annotated.html @@ -1,22 +1,16 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Data Structures - - +

SystemTap Data Structures

Here are the data structures with brief descriptions: - - - - - - - + + + +
key_data
map_node
map_node_int64
map_node_stat
map_node_str
map_root
stat
key_dataKeys are either longs or char *
map_nodeAll map nodes have the following structure
map_rootThis structure contains all information about a map
statStatistics are stored in this struct
-
Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +
+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/copy_8c-source.html b/runtime/docs/html/copy_8c-source.html index 3d70030b..bab47938 100644 --- a/runtime/docs/html/copy_8c-source.html +++ b/runtime/docs/html/copy_8c-source.html @@ -1,12 +1,11 @@ -SystemTap: SystemTap Runtime Library +SystemTap: copy.c Source File - - -

copy.c

Go to the documentation of this file.
00001 long _stp_strncpy_from_user(char *dst, const char __user *src, long count);
+
+

copy.c

00001 long _stp_strncpy_from_user(char *dst, const char __user *src, long count);
 00002 //static long __stp_strncpy_from_user(char *dst, const char __user *src, long count);
 00003 
 00004 #if defined (__i386__)
@@ -66,22 +65,61 @@
 00058                 : "memory");                                               \
 00059 } while (0)
 00060 #endif
-00061 
+00061 
+00062 /** Copy a NULL-terminated string from userspace.
+00063  * On success, returns the length of the string (not including the trailing
+00064  * NULL).
+00065  *
+00066  * If access to userspace fails, returns -EFAULT (some data may have been
+00067  * copied).
+00068  * @param dst Destination address, in kernel space.  This buffer must be at
+00069  *         least <i>count</i> bytes long.
+00070  * @param src Source address, in user space.
+00071  * @param count Maximum number of bytes to copy, including the trailing NULL.
+00072  * 
+00073  * If <i>count</i> is smaller than the length of the string, copies 
+00074  * <i>count</i> bytes and returns <i>count</i>.
+00075  */
+00076 
+00077 
 00078 long
-00079 _stp_strncpy_from_user(char *dst, const char __user *src, long count)
+00079 _stp_strncpy_from_user(char *dst, const char __user *src, long count)
 00080 {
 00081         long res;
 00082         __stp_strncpy_from_user(dst, src, count, res);
 00083         return res;
 00084 }
-00085 
+00085 
+00086 /** Copy a block of data from user space.
+00087  *
+00088  * If some data could not be copied, this function will pad the copied
+00089  * data to the requested size using zero bytes.
+00090 
+00091  * @param dst Destination address, in kernel space.
+00092  * @param src Source address, in user space.
+00093  * @param count Number of bytes to copy.
+00094  * @return number of bytes that could not be copied. On success, 
+00095  * this will be zero.
+00096  *
+00097  */
+00098 
 00099 unsigned long inline
-00100 _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
+00100 _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
 00101 {
 00102         return __copy_from_user_inatomic(dst, src, count);
 00103 }
-00104 
-00115 int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
+00104 
+00105 /** Copy an argv from user space to a List.
+00106  *
+00107  * @param list A list.
+00108  * @param argv Source argv, in user space.
+00109  * @return number of elements in <i>list</i>
+00110  *
+00111  * @b Example:
+00112  * @include argv.c
+00113  */
+00114 
+00115 int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
 00116 {
 00117         char str[128];
 00118         char __user *vstr;
@@ -90,22 +128,20 @@
 00121         if (argv)
 00122                 argv++;
 00123 
-00124         while (argv != NULL) {
+00124         while (argv != NULL) {
 00125                 if (get_user (vstr, argv))
-00126                         break;
-00127 
-00128                 if (vstr == NULL)
-00129                         break;
+00126                         break;
+00127                 
+00128                 if (vstr == NULL)
+00129                         break;
 00130                 
-00131                 len = _stp_strncpy_from_user(str, vstr, 128);
+00131                 len = _stp_strncpy_from_user(str, vstr, 128);
 00132                 str[len] = 0;
-00133                 _stp_list_add_str (list, str);
+00133                 _stp_list_add_str (list, str);
 00134                 argv++;
 00135         }
-00136         return list->num;
+00136         return list->num;
 00137 }
-

Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +

+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/dir_000000.html b/runtime/docs/html/dir_000000.html new file mode 100644 index 00000000..78bdc36c --- /dev/null +++ b/runtime/docs/html/dir_000000.html @@ -0,0 +1,43 @@ + + +SystemTap: probes/ Directory Reference + + + + + +

probes Directory Reference

This directory contains working example probes that demonstrate and test the runtime library. +More... + + + + + + +

+

+ + + +

+

+ + + +

+

+ + + +

+

+ + +

Directories

directory  shellsnoop
 Snoops on what commands are being run by shells.
directory  tasklet
 Sample probe in a tasklet.
directory  test4
 This example probe tracks file opens, reads and writes.
directory  where_func
 This is a silly little instrumentation routine to instrument functions entry by name.

Files

file  README [code]
+

Detailed Description

+This directory contains working example probes that demonstrate and test the runtime library. +

+They are tested on i386 and x86_64.


+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/dir_000001.html b/runtime/docs/html/dir_000001.html new file mode 100644 index 00000000..b2802585 --- /dev/null +++ b/runtime/docs/html/dir_000001.html @@ -0,0 +1,91 @@ + + +SystemTap: probes/shellsnoop/ Directory Reference + + + + + +

shellsnoop Directory Reference

Snoops on what commands are being run by shells. +More... + + + + + + + + +

Files

file  dtr.c [code]
file  dtr.mod.c [code]
file  README [code]
+

Detailed Description

+Snoops on what commands are being run by shells. +

+This is a translation of on an old dtr probe. It demonstrates maps, lists, and how to use _stp_copy_argv_from_user() and _stp_strncpy_from_user().

+Original dtr source:

+

+# shellsnoop.probe - snoop shell execution as it occurs.
+# clone of dtrace shellsnoop example
+
+global {
+  long @pids[long];
+}
+
+probe do_execve:entry {
+  char __user *vstr;
+  char str[256];
+  int len;
+
+  /* watch shells only */
+  /* FIXME: detect more shells, like csh, tcsh, zsh */
+
+  if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh")
+      || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh"))
+    {
+      dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename);
+      @pids[current->pid] = 1;
+
+      /* print out argv, ignoring argv[0] */
+      if (argv) argv++;
+      while (argv != NULL)
+        {
+          if (get_user (vstr, argv))
+            break;
+          if (!vstr)
+            break;
+          len = dtr_strncpy_from_user(str, vstr, 256);
+          str[len] = 0;
+          printk ("%s ", str);
+          argv++;
+        }
+      printk ("\n");
+    }
+}
+
+# use filp_open because copy_from_user not needed there
+probe filp_open:entry {
+  if (@pids[current->pid])
+    dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename);
+}
+
+probe sys_read:entry {
+  if (@pids[current->pid])
+    dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd);
+}
+
+probe sys_write:entry {
+  size_t len;
+  char str[256];
+  if (@pids[current->pid])
+    {
+      if (count < 64) len = count;
+      else len = 64;
+      if (len = dtr_strncpy_from_user(str, buf, len)) {
+        str[len] = 0;
+        dlog ("%d\t%d\t%s\tW %s\n", current->pid, current->parent->pid, current->comm, str);
+        }
+    }
+}
+

+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/dir_000002.html b/runtime/docs/html/dir_000002.html new file mode 100644 index 00000000..7b82c65e --- /dev/null +++ b/runtime/docs/html/dir_000002.html @@ -0,0 +1,29 @@ + + +SystemTap: probes/tasklet/ Directory Reference + + + + + +

tasklet Directory Reference

Sample probe in a tasklet. +More... + + + + + + +

Files

file  README [code]
file  stp_tasklet.c [code]
+

Detailed Description

+Sample probe in a tasklet. +

+Useful for interrupt context testing.

+

+> ./build
+> insmod stp_tasklet.ko
+> rmmod stp_tasklet.ko
+

+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/dir_000003.html b/runtime/docs/html/dir_000003.html new file mode 100644 index 00000000..3cb48158 --- /dev/null +++ b/runtime/docs/html/dir_000003.html @@ -0,0 +1,42 @@ + + +SystemTap: probes/test4/ Directory Reference + + + + + +

test4 Directory Reference

This example probe tracks file opens, reads and writes. +More... + + + + + + +

Files

file  dtr.c [code]
file  README [code]
+

Detailed Description

+This example probe tracks file opens, reads and writes. +

+It demonstrates maps, stats, and iterators.

+This is a translation of on an old dtr probe. Original source is

+global {
+  long @opens[string];
+  sum @reads[string], @writes[string];
+}
+
+probe sys_open:entry {
+  @opens[current->comm]++;
+}
+
+probe sys_read:entry {
+  @reads[current->comm] << count;
+}
+
+probe sys_write:entry {
+  @writes[current->comm] << count;
+}
+

+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/dir_000004.html b/runtime/docs/html/dir_000004.html new file mode 100644 index 00000000..263e859d --- /dev/null +++ b/runtime/docs/html/dir_000004.html @@ -0,0 +1,30 @@ + + +SystemTap: probes/where_func/ Directory Reference + + + + + +

where_func Directory Reference

This is a silly little instrumentation routine to instrument functions entry by name. +More... + + + + + + +

Files

file  kprobe_where_funct.c [code]
file  README [code]
+

Detailed Description

+This is a silly little instrumentation routine to instrument functions entry by name. +

+It makes use of the SystemTap runtime libraries to break down the number of times the function by caller.

+It demonstrates kprobes, passing a module parameter, using the print buffer, and using _stp_print_symbol() to map the addresses back to locations in functions.

+By default it instruments schedule().

+The instrumentation module is built by having the kernel that is going to be instrumented currently on the machine and doing

./build
+
The instrumentation is inserted as root with:
/sbin/insmod kprobe_funct_where.ko funct_name=function_name
+
The instrumentation is removed as root with:
/sbin/rmmod kprobe_funct_where
+
-Will Cohen
+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/dirs.html b/runtime/docs/html/dirs.html new file mode 100644 index 00000000..4b3bdc57 --- /dev/null +++ b/runtime/docs/html/dirs.html @@ -0,0 +1,19 @@ + + +SystemTap: Directory Hierarchy + + + + +

SystemTap Directories

This directory hierarchy is sorted roughly, but not completely, alphabetically: +
+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/dtr_8mod_8c-source.html b/runtime/docs/html/dtr_8mod_8c-source.html new file mode 100644 index 00000000..38f5967a --- /dev/null +++ b/runtime/docs/html/dtr_8mod_8c-source.html @@ -0,0 +1,59 @@ + + +SystemTap: probes/shellsnoop/dtr.mod.c Source File + + + + + +

dtr.mod.c

00001 #include <linux/module.h>
+00002 #include <linux/vermagic.h>
+00003 #include <linux/compiler.h>
+00004 
+00005 MODULE_INFO(vermagic, VERMAGIC_STRING);
+00006 
+00007 #undef unix
+00008 struct module __this_module
+00009 __attribute__((section(".gnu.linkonce.this_module"))) = {
+00010  .name = __stringify(KBUILD_MODNAME),
+00011  .init = init_module,
+00012 #ifdef CONFIG_MODULE_UNLOAD
+00013  .exit = cleanup_module,
+00014 #endif
+00015 };
+00016 
+00017 static const struct modversion_info ____versions[]
+00018 __attribute_used__
+00019 __attribute__((section("__versions"))) = {
+00020         { 0x506abef7, "struct_module" },
+00021         { 0x1b9aca3f, "jprobe_return" },
+00022         { 0x45e5f47f, "register_kprobe" },
+00023         { 0x1e736243, "unregister_kprobe" },
+00024         { 0xdd03a51e, "register_jprobe" },
+00025         { 0x49a83d3a, "unregister_jprobe" },
+00026         { 0xaa27f890, "__get_user_8" },
+00027         { 0x21e5679c, "copy_user_generic" },
+00028         { 0x3fa03a97, "memset" },
+00029         { 0xc16fe12d, "__memcpy" },
+00030         { 0xe914e41e, "strcpy" },
+00031         { 0xe2d5255a, "strcmp" },
+00032         { 0xe3b0192b, "vscnprintf" },
+00033         { 0x8e3c9cc3, "vprintk" },
+00034         { 0xdd132261, "printk" },
+00035         { 0x2fd1d81c, "vfree" },
+00036         { 0x37a0cba, "kfree" },
+00037         { 0xd6ee688f, "vmalloc" },
+00038         { 0x8ce16b3f, "__kmalloc" },
+00039 };
+00040 
+00041 static const char __module_depends[]
+00042 __attribute_used__
+00043 __attribute__((section(".modinfo"))) =
+00044 "depends=";
+00045 
+00046 
+00047 MODULE_INFO(srcversion, "D6A3BE8A54CB181A59924B3");
+

+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/files.html b/runtime/docs/html/files.html index 61d4d78f..ecbc299e 100644 --- a/runtime/docs/html/files.html +++ b/runtime/docs/html/files.html @@ -1,24 +1,31 @@ -SystemTap: SystemTap Runtime Library +SystemTap: File Index - - -

SystemTap File List

Here is a list of all files with brief descriptions: - - - - - - - - - + +

SystemTap File List

Here is a list of all documented files with brief descriptions:
alloc.h [code]
copy.c [code]
io.c [code]
map.c [code]
map.h [code]
probes.c [code]
README [code]
runtime.h [code]
stack.c [code]
+ + + + + + + + + + + + + + + + + + +
alloc.h [code]
copy.c [code]
io.c [code]
map.c [code]Implements maps (associative arrays) and lists
map.h [code]Header file for maps and lists
probes.c [code]
README [code]
runtime.h [code]
stack.c [code]
probes/README [code]
probes/shellsnoop/dtr.c [code]
probes/shellsnoop/dtr.mod.c [code]
probes/shellsnoop/README [code]
probes/tasklet/README [code]
probes/tasklet/stp_tasklet.c [code]
probes/test4/dtr.c [code]
probes/test4/README [code]
probes/where_func/kprobe_where_funct.c [code]
probes/where_func/README [code]
-
Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +
+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/functions.html b/runtime/docs/html/functions.html index 57e3e3fa..b7efe33e 100644 --- a/runtime/docs/html/functions.html +++ b/runtime/docs/html/functions.html @@ -1,48 +1,17 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Data Fields - - +

-Here is a list of all struct and union fields with links to the structures/unions they belong to:

-
Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +Here is a list of all documented struct and union fields with links to the struct/union documentation for each field: +
+Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/functions_vars.html b/runtime/docs/html/functions_vars.html index 9b26f053..d70b21ef 100644 --- a/runtime/docs/html/functions_vars.html +++ b/runtime/docs/html/functions_vars.html @@ -1,48 +1,17 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Data Fields - Variables - - +

-
Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +
  • maxnum +: map_root
  • num +: map_root +
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/globals.html b/runtime/docs/html/globals.html index 8e03810f..3e4cb61e 100644 --- a/runtime/docs/html/globals.html +++ b/runtime/docs/html/globals.html @@ -1,27 +1,15 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Globals - - - -
    _ | c | d | e | f | i | k | l | m | n | p | s | v
    - -

    +

    +

    -Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

    - _ -

    +
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/globals_func.html b/runtime/docs/html/globals_func.html index c1cde956..02c03dcb 100644 --- a/runtime/docs/html/globals_func.html +++ b/runtime/docs/html/globals_func.html @@ -1,25 +1,15 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Globals - Functions - - - -
    _ | c | d | s
    - -

    +

    +

    -

    - _ -

    +
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/globals_type.html b/runtime/docs/html/globals_type.html index 69817e46..7c2d40d7 100644 --- a/runtime/docs/html/globals_type.html +++ b/runtime/docs/html/globals_type.html @@ -1,19 +1,16 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Globals - Typedefs - - - + +

    -
    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/index.html b/runtime/docs/html/index.html index dd4edd27..bae6d763 100644 --- a/runtime/docs/html/index.html +++ b/runtime/docs/html/index.html @@ -3,16 +3,17 @@ SystemTap: SystemTap Runtime Library - - +

    SystemTap Runtime Library

    0.1

    Introduction

    The SystemTap Runtime Library consists of all functions and code fragments needed by the compiler/translator to include in building a kernel module using kprobes.

    Design

    -

    +

    +Implementation

    +The library is written in C and is really not a library but a collection of code That can be conditionally included in a modules. It will probably become a library later.

    Maps (Associative Arrays)

    Maps are implemented as hash lists. It is not expected that users will attempt to collect so much data in kernel space that performance problems will require more complex solutions such as AVL trees.

    Maps are created with _stp_map_new(). Each map can hold only one type of data; int64, string, or statistics. Each element belonging to a map can have up to 2 keys and a value. Implemented key types are strings and longs.

    @@ -25,17 +26,20 @@ For example:

     map_key_str (mymap, "birth year");
     map_set_int64 (mymap, 2000);  
     

    -All elements have a default value of 0 (or NULL). Elements are only saved to the map when their value is set to something nonzero. This means that querying for the existance of a key is inexpensive because no element is created, just a hash table lookup.

    -A list is a special map which has internally ascending long integer keys. Adding a value to a list does not require setting a key first. See _stp_list_add_str() and _stp_list_add_int64().

    +All elements have a default value of 0 (or NULL). Elements are only saved to the map when their value is set to something nonzero. This means that querying for the existance of a key is inexpensive because no element is created, just a hash table lookup.

    +Lists

    +A list is a special map which has internally ascending long integer keys. Adding a value to a list does not require setting a key first. Create a list with _stp_map_new(). Add to it with _stp_list_add_str() and _stp_list_add_int64(). Clear it with _stp_list_clear().

    Status

    -Maps are implemented and tested. Histograms are not yet finished.

    -Copy_From_User functions are done.

    -If maps overflow or memory runs out for some reason, globals are set but nothing is done yet. I expect to implement a function to tell the system to either ignore it or unload the module and quit.

    +
      +
    • Maps are implemented and tested. Histograms are not yet finished.
    • +
    • Copy_From_User functions are done.
    • +
    • If maps overflow or memory runs out for some reason, globals are set but nothing is done yet. I expect to implement a function to tell the system to either ignore it or unload the module and quit.
    • +
    • Locking and per-cpu data are not yet implemented to be SMP-safe. This is not yet necessary because the current kprobes implementation single-threads probes for us.
    • +
    +

    Example Probes

    -Working sample probe code using the runtime is in runtime/probes.

    +Working sample probe code using the runtime is in runtime/probes. Browse probes.

    ToDo

    -Click Here for Complete List The Runtime Library is not actually a library yet. It is just a collection of functions included in the probe boilerplate. Maybe it should stay that way to allow the translator more flexibility in what is included.
    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +Click Here for Complete List
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/io_8c-source.html b/runtime/docs/html/io_8c-source.html index a152c946..246f36d8 100644 --- a/runtime/docs/html/io_8c-source.html +++ b/runtime/docs/html/io_8c-source.html @@ -1,13 +1,21 @@ -SystemTap: SystemTap Runtime Library +SystemTap: io.c Source File - - -

    io.c

    Go to the documentation of this file.
    00001 
    -00011 void dlog (const char *fmt, ...)
    +
    +

    io.c

    00001 /** Logs data.
    +00002  * This function is compatible with printk.  In fact it currently
    +00003  * sends all output to vprintk, after sending "STP: ". This allows
    +00004  * us to easily detect SystemTap output in the log file.
    +00005  *
    +00006  * @param fmt A variable number of args.
    +00007  * @bug Lines are limited in length by printk buffer.
    +00008  * @todo Needs replaced with something much faster that does not
    +00009  * use the system log.
    +00010  */
    +00011 void dlog (const char *fmt, ...)
     00012 {
     00013   va_list args;
     00014   printk("STP: ");
    @@ -23,17 +31,17 @@
     00024                             char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP;
     00025 
     00026 
    -00027 #define STP_BUF_LEN 8191
    +00027 #define STP_BUF_LEN 8191
     00028 
     00029 /* FIXME. These need to be per-cpu */
    -00030 static char _stp_pbuf[STP_BUF_LEN+1];
    -00031 static int _stp_pbuf_len = STP_BUF_LEN;
    +00030 static char _stp_pbuf[STP_BUF_LEN+1];
    +00031 static int _stp_pbuf_len = STP_BUF_LEN;
     00032 
    -00033 void _stp_print_buf (const char *fmt, ...)
    +00033 void _stp_print_buf (const char *fmt, ...)
     00034 {
     00035   int num;
     00036   va_list args;
    -00037   char *buf = _stp_pbuf + STP_BUF_LEN - _stp_pbuf_len;
    +00037   char *buf = _stp_pbuf + STP_BUF_LEN - _stp_pbuf_len;
     00038   va_start(args, fmt);
     00039   num = vscnprintf(buf, _stp_pbuf_len, fmt, args);
     00040   va_end(args);
    @@ -41,13 +49,13 @@
     00042     _stp_pbuf_len -= num;
     00043 }
     00044 
    -00045 void _stp_print_buf_init (void)
    +00045 void _stp_print_buf_init (void)
     00046 {
    -00047   _stp_pbuf_len = STP_BUF_LEN;
    +00047   _stp_pbuf_len = STP_BUF_LEN;
     00048   _stp_pbuf[0] = 0;
     00049 }
     00050 
    -00051 void _stp_print_symbol(const char *fmt, unsigned long address)
    +00051 void _stp_print_symbol(const char *fmt, unsigned long address)
     00052 {
     00053         char *modname;
     00054         const char *name;
    @@ -57,18 +65,18 @@
     00058         name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
     00059 
     00060         if (!name)
    -00061                 _stp_print_buf("0x%lx", address);
    -00062         else {
    +00061                 _stp_print_buf("0x%lx", address);
    +00062         else {
     00063           if (modname)
    -00064             _stp_print_buf("%s+%#lx/%#lx [%s]", name, offset,
    +00064             _stp_print_buf("%s+%#lx/%#lx [%s]", name, offset,
     00065                            size, modname);
    -00066           else
    -00067             _stp_print_buf("%s+%#lx/%#lx", name, offset, size);
    +00066           else
    +00067             _stp_print_buf("%s+%#lx/%#lx", name, offset, size);
     00068         }
     00069 }
     00070 
     00071  
    -00072 unsigned long cur_ret_addr (struct pt_regs *regs)
    +00072 unsigned long cur_ret_addr (struct pt_regs *regs)
     00073 {
     00074 #ifdef __x86_64__
     00075   unsigned long *ra = (unsigned long *)regs->rsp;
    @@ -76,12 +84,10 @@
     00077   unsigned long *ra = (unsigned long *)regs->esp;
     00078 #endif
     00079   if (ra)
    -00080     return *ra;
    -00081   else
    -00082     return 0;
    +00080     return *ra;
    +00081   else
    +00082     return 0;
     00083 }
    -

    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/kprobe__where__funct_8c-source.html b/runtime/docs/html/kprobe__where__funct_8c-source.html new file mode 100644 index 00000000..3d7702c1 --- /dev/null +++ b/runtime/docs/html/kprobe__where__funct_8c-source.html @@ -0,0 +1,90 @@ + + +SystemTap: probes/where_func/kprobe_where_funct.c Source File + + + + + +

    kprobe_where_funct.c

    00001 /* kprobe_where_funct.c
    +00002    this is a simple module to get information about calls to a function that is passed as a module option
    +00003    Will Cohen
    +00004 */
    +00005 
    +00006 #define HASH_TABLE_BITS 8
    +00007 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
    +00008 #define BUCKETS 16              /* largest histogram width */
    +00009 
    +00010 #include "runtime.h"
    +00011 #include "io.c"
    +00012 #include "map.c"
    +00013 #include "probes.c"
    +00014 
    +00015 MODULE_DESCRIPTION("SystemTap probe: where_func");
    +00016 MODULE_AUTHOR("Will Cohen and Martin Hunt");
    +00017 
    +00018 static char default_name[] = "schedule";
    +00019 static char *funct_name = default_name;
    +00020 module_param(funct_name, charp, 0);
    +00021 MODULE_PARM_DESC(funct_name, "function entry name.\n");
    +00022 
    +00023 static int count_funct = 0;
    +00024 
    +00025 MAP funct_locations;
    +00026 
    +00027 static int inst_funct(struct kprobe *p, struct pt_regs *regs)
    +00028 {
    +00029         long ret_addr = cur_ret_addr(regs);
    +00030         ++count_funct;
    +00031         _stp_map_key_long(funct_locations, ret_addr);
    +00032         _stp_map_add_int64(funct_locations, 1);
    +00033         return 0;
    +00034 }
    +00035 
    +00036 /*For each probe you need to allocate a kprobe structure*/
    +00037 static struct kprobe kp[] = {
    +00038         {
    +00039                 .addr = default_name,
    +00040                 .pre_handler = inst_funct,
    +00041         }
    +00042 };
    +00043 #define MAX_KPROBES (sizeof(kp)/sizeof(struct kprobe))
    +00044 
    +00045 int init_module(void)
    +00046 {
    +00047         int ret;
    +00048 
    +00049         funct_locations = _stp_map_new(1000, INT64);
    +00050 
    +00051         if (funct_name)
    +00052                 kp[0].addr = funct_name;
    +00053 
    +00054         ret = _stp_register_kprobes (kp, MAX_KPROBES);
    +00055 
    +00056         return ret;
    +00057 }
    +00058 
    +00059 void cleanup_module(void)
    +00060 {
    +00061         struct map_node_int64 *ptr;
    +00062 
    +00063         _stp_unregister_kprobes (kp, MAX_KPROBES);
    +00064 
    +00065         dlog("%s() called %d times.\n", funct_name, count_funct);
    +00066         dlog("NUM\tCaller Addr\tCaller Name\n", funct_name);
    +00067 
    +00068         /* now walk the hash table and print out all the information */
    +00069         foreach(funct_locations, ptr) {
    +00070                 _stp_print_buf_init();
    +00071                 _stp_print_symbol("%s\n", key1int(ptr));
    +00072                 dlog("%lld\t0x%p\t(%s)\n", ptr->val, key1int(ptr), _stp_pbuf);
    +00073         }
    +00074 
    +00075         _stp_map_del(funct_locations);
    +00076 }
    +00077 
    +00078 MODULE_LICENSE("GPL");
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/map_8c-source.html b/runtime/docs/html/map_8c-source.html index 03aa6f47..22e39231 100644 --- a/runtime/docs/html/map_8c-source.html +++ b/runtime/docs/html/map_8c-source.html @@ -1,675 +1,870 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map.c Source File - - -

    map.c

    Go to the documentation of this file.
    00001 /* -*- linux-c -*- */
    -00002 
    -00003 static int map_sizes[] = {
    -00004         sizeof(struct map_node_int64),
    -00005         sizeof(struct map_node_stat),
    -00006         sizeof(struct map_node_str),
    -00007         0
    -00008 };
    -00009 
    -00010 static inline unsigned string_hash(const char *key1, const char *key2)
    -00011 {
    -00012         int hash = 0, count = 0;
    -00013         char *v1 = (char *)key1;
    -00014         char *v2 = (char *)key2;
    -00015         while (*v1 && count++ < 5) {
    -00016                 hash += *v1++;
    -00017         }
    -00018         while (v2 && *v2 && count++ < 5) {
    -00019                 hash += *v2++;
    -00020         }
    -00021         return hash_long((unsigned long)hash, HASH_TABLE_BITS);
    -00022 }
    -00023 
    -00024 static inline unsigned mixed_hash(const char *key1, long key2)
    -00025 {
    -00026         int hash = 0, count = 0;
    -00027         char *v = (char *)key1;
    -00028         while (v && *v && count++ < 5)
    -00029                 hash += *v++;
    -00030         return hash_long((unsigned long)(hash ^ key2), HASH_TABLE_BITS);
    -00031 }
    -00032 
    -00043 MAP _stp_map_new(unsigned max_entries, enum valtype type)
    -00044 {
    -00045         size_t size;
    -00046         MAP m = (MAP) _stp_valloc(sizeof(struct map_root));
    -00047         if (m == NULL)
    -00048                 return NULL;
    -00049 
    -00050         INIT_LIST_HEAD(&m->head);
    -00051 
    -00052         m->maxnum = max_entries;
    -00053         m->type = type;
    -00054         if (type >= END) {
    -00055                 dbug ("map_new: unknown type %d\n", type);
    -00056                 return NULL;
    -00057         }
    -00058 
    -00059         if (max_entries) {
    -00060                 void *tmp;
    -00061                 int i;
    -00062                 struct list_head *e;
    -00063 
    -00064                 INIT_LIST_HEAD(&m->pool);
    -00065                 size = map_sizes[type];
    -00066                 tmp = _stp_valloc(max_entries * size);
    +
    +

    map.c

    Go to the documentation of this file.
    00001 /* -*- linux-c -*- */
    +00002 /** @file map.c
    +00003  * @brief Implements maps (associative arrays) and lists
    +00004  */
    +00005 
    +00006 
    +00007 static int map_sizes[] = {
    +00008         sizeof(struct map_node_int64),
    +00009         sizeof(struct map_node_stat),
    +00010         sizeof(struct map_node_str),
    +00011         0
    +00012 };
    +00013 
    +00014 static unsigned string_hash(const char *key1, const char *key2)
    +00015 {
    +00016         int hash = 0, count = 0;
    +00017         char *v1 = (char *)key1;
    +00018         char *v2 = (char *)key2;
    +00019         while (*v1 && count++ < 5) {
    +00020                 hash += *v1++;
    +00021         }
    +00022         while (v2 && *v2 && count++ < 5) {
    +00023                 hash += *v2++;
    +00024         }
    +00025         return hash_long((unsigned long)hash, HASH_TABLE_BITS);
    +00026 }
    +00027 
    +00028 static unsigned mixed_hash(const char *key1, long key2)
    +00029 {
    +00030         int hash = 0, count = 0;
    +00031         char *v = (char *)key1;
    +00032         while (v && *v && count++ < 5)
    +00033                 hash += *v++;
    +00034         return hash_long((unsigned long)(hash ^ key2), HASH_TABLE_BITS);
    +00035 }
    +00036 
    +00037 /** Create a new map.
    +00038  * Maps must be created at module initialization time.
    +00039  * @param max_entries The maximum number of entries allowed. Currently that number will
    +00040  * be preallocated.  If more entries are required, the oldest ones will be deleted. This makes
    +00041  * it effectively a circular buffer.  If max_entries is 0, there will be no maximum and entries
    +00042  * will be allocated dynamically.
    +00043  * @param type Type of values stored in this map. 
    +00044  * @return A MAP on success or NULL on failure.
    +00045  */
    +00046 
    +00047 MAP _stp_map_new(unsigned max_entries, enum valtype type)
    +00048 {
    +00049         size_t size;
    +00050         MAP m = (MAP) _stp_valloc(sizeof(struct map_root));
    +00051         if (m == NULL)
    +00052                 return NULL;
    +00053 
    +00054         INIT_LIST_HEAD(&m->head);
    +00055 
    +00056         m->maxnum = max_entries;
    +00057         m->type = type;
    +00058         if (type >= END) {
    +00059                 dbug ("map_new: unknown type %d\n", type);
    +00060                 return NULL;
    +00061         }
    +00062 
    +00063         if (max_entries) {
    +00064                 void *tmp;
    +00065                 int i;
    +00066                 struct list_head *e;
     00067 
    -00068                 for (i = max_entries - 1; i >= 0; i--) {
    -00069                         e = i * size + tmp;
    -00070                         dbug ("e=%lx\n", (long)e);
    -00071                         list_add(e, &m->pool);
    -00072                 }
    -00073                 m->membuf = tmp;
    -00074         }
    -00075         return m;
    -00076 }
    -00077 
    -00078 static void map_free_strings(MAP map, struct map_node *n)
    -00079 {
    -00080         struct map_node_str *m = (struct map_node_str *)n;
    -00081         dbug ("n = %lx\n", (long)n);
    -00082         if (map->type == STRING) {
    -00083                 dbug ("val STRING %lx\n", (long)m->str);
    -00084                 if (m->str)
    -00085                         _stp_free(m->str);
    -00086         }
    -00087         if (m->n.key1type == STR) {
    -00088                 dbug ("key1 STR %lx\n", (long)key1str(m));
    -00089                 if (key1str(m))
    -00090                         _stp_free(key1str(m));
    -00091         }
    -00092         if (m->n.key2type == STR) {
    -00093                 dbug ("key2 STR %lx\n", (long)key2str(m));
    -00094                 if (key2str(m))
    -00095                         _stp_free(key2str(m));
    -00096         }
    -00097 }
    -00098 
    -00104 void _stp_map_key_del(MAP map)
    -00105 {
    -00106         struct map_node *m;
    +00068                 INIT_LIST_HEAD(&m->pool);
    +00069                 size = map_sizes[type];
    +00070                 tmp = _stp_valloc(max_entries * size);
    +00071 
    +00072                 for (i = max_entries - 1; i >= 0; i--) {
    +00073                         e = i * size + tmp;
    +00074                         dbug ("e=%lx\n", (long)e);
    +00075                         list_add(e, &m->pool);
    +00076                 }
    +00077                 m->membuf = tmp;
    +00078         }
    +00079         return m;
    +00080 }
    +00081 
    +00082 static void map_free_strings(MAP map, struct map_node *n)
    +00083 {
    +00084         struct map_node_str *m = (struct map_node_str *)n;
    +00085         dbug ("n = %lx\n", (long)n);
    +00086         if (map->type == STRING) {
    +00087                 dbug ("val STRING %lx\n", (long)m->str);
    +00088                 if (m->str)
    +00089                         _stp_free(m->str);
    +00090         }
    +00091         if (m->n.key1type == STR) {
    +00092                 dbug ("key1 STR %lx\n", (long)key1str(m));
    +00093                 if (key1str(m))
    +00094                         _stp_free(key1str(m));
    +00095         }
    +00096         if (m->n.key2type == STR) {
    +00097                 dbug ("key2 STR %lx\n", (long)key2str(m));
    +00098                 if (key2str(m))
    +00099                         _stp_free(key2str(m));
    +00100         }
    +00101 }
    +00102 
    +00103 /** Deletes the current element.
    +00104  * If no current element (key) for this map is set, this function does nothing.
    +00105  * @param map 
    +00106  */
     00107 
    -00108         dbug ("create=%d key=%lx\n", map->create, (long)map->key);
    -00109         if (map == NULL)
    -00110                 return;
    +00108 void _stp_map_key_del(MAP map)
    +00109 {
    +00110         struct map_node *m;
     00111 
    -00112         if (map->create) {
    -00113                 map->create = 0;
    -00114                 map->key = NULL;
    -00115                 return;
    -00116         }
    -00117 
    -00118         if (map->key == NULL)
    +00112         dbug ("create=%d key=%lx\n", map->create, (long)map->key);
    +00113         if (map == NULL)
    +00114                 return;
    +00115 
    +00116         if (map->create) {
    +00117                 map->create = 0;
    +00118                 map->key = NULL;
     00119                 return;
    -00120 
    -00121         m = (struct map_node *)map->key;
    -00122 
    -00123         /* remove node from old hash list */
    -00124         hlist_del_init(&m->hnode);
    -00125 
    -00126         /* remove from entry list */
    -00127         list_del(&m->lnode);
    -00128 
    -00129         /* remove any allocated string storage */
    -00130         map_free_strings(map, (struct map_node *)map->key);
    -00131 
    -00132         if (map->maxnum)
    -00133                 list_add(&m->lnode, &map->pool);
    -00134         else
    -00135                 _stp_free(m);
    -00136 
    -00137         map->key = NULL;
    -00138         map->num--;
    -00139 }
    +00120         }
    +00121 
    +00122         if (map->key == NULL)
    +00123                 return;
    +00124 
    +00125         m = (struct map_node *)map->key;
    +00126 
    +00127         /* remove node from old hash list */
    +00128         hlist_del_init(&m->hnode);
    +00129 
    +00130         /* remove from entry list */
    +00131         list_del(&m->lnode);
    +00132 
    +00133         /* remove any allocated string storage */
    +00134         map_free_strings(map, (struct map_node *)map->key);
    +00135 
    +00136         if (map->maxnum)
    +00137                 list_add(&m->lnode, &map->pool);
    +00138         else
    +00139                 _stp_free(m);
     00140 
    -00149 struct map_node *_stp_map_start(MAP map)
    -00150 {
    -00151         if (map == NULL)
    -00152                 return NULL;
    -00153 
    -00154         dbug ("%lx\n", (long)map->head.next);
    -00155 
    -00156         if (list_empty(&map->head))
    -00157                 return NULL;
    -00158 
    -00159         return (struct map_node *)map->head.next;
    -00160 }
    -00161 
    -00172 struct map_node *_stp_map_iter(MAP map, struct map_node *m)
    -00173 {
    -00174         if (map == NULL)
    -00175                 return NULL;
    -00176 
    -00177         dbug ("%lx next=%lx  prev=%lx  map->head.next=%lx\n", (long)m, (long)m->lnode.next, (long)m->lnode.prev, (long)map->head.next);
    -00178 
    -00179         if (m->lnode.next == &map->head)
    -00180                 return NULL;
    -00181 
    -00182         return (struct map_node *)m->lnode.next;
    -00183 }
    -00184 
    -00190 void _stp_map_del(MAP map)
    -00191 {
    -00192         if (map == NULL)
    -00193                 return;
    +00141         map->key = NULL;
    +00142         map->num--;
    +00143 }
    +00144 
    +00145 /** Get the first element in a map.
    +00146  * @param map 
    +00147  * @returns a pointer to the first element.
    +00148  * This is typically used with _stp_map_iter().  See the foreach() macro
    +00149  * for typical usage.  It probably does what you want anyway.
    +00150  * @sa foreach
    +00151  */
    +00152 
    +00153 struct map_node *_stp_map_start(MAP map)
    +00154 {
    +00155         if (map == NULL)
    +00156                 return NULL;
    +00157 
    +00158         dbug ("%lx\n", (long)map->head.next);
    +00159 
    +00160         if (list_empty(&map->head))
    +00161                 return NULL;
    +00162 
    +00163         return (struct map_node *)map->head.next;
    +00164 }
    +00165 
    +00166 /** Get the next element in a map.
    +00167  * @param map 
    +00168  * @param m a pointer to the current element, returned from _stp_map_start()
    +00169  * or _stp_map_iter().
    +00170  * @returns a pointer to the next element.
    +00171  * This is typically used with _stp_map_start().  See the foreach() macro
    +00172  * for typical usage.  It probably does what you want anyway.
    +00173  * @sa foreach
    +00174  */
    +00175 
    +00176 struct map_node *_stp_map_iter(MAP map, struct map_node *m)
    +00177 {
    +00178         if (map == NULL)
    +00179                 return NULL;
    +00180 
    +00181         dbug ("%lx next=%lx  prev=%lx  map->head.next=%lx\n", (long)m, 
    +00182               (long)m->lnode.next, (long)m->lnode.prev, (long)map->head.next);
    +00183 
    +00184         if (m->lnode.next == &map->head)
    +00185                 return NULL;
    +00186 
    +00187         return (struct map_node *)m->lnode.next;
    +00188 }
    +00189 
    +00190 /** Deletes a map.
    +00191  * Deletes a map, freeing all memory in all elements.  Normally done only when the module exits.
    +00192  * @param map
    +00193  */
     00194 
    -00195         if (!list_empty(&map->head)) {
    -00196                 struct map_node *ptr = (struct map_node *)map->head.next;
    -00197                 while (ptr && ptr != (struct map_node *)&map->head) {
    -00198                         map_free_strings(map, ptr);
    -00199                         ptr = (struct map_node *)ptr->lnode.next;
    -00200                 }
    -00201         }
    -00202         _stp_vfree(map->membuf);
    -00203         _stp_vfree(map);
    -00204 }
    -00205 
    -00206 /**********************  KEY FUNCTIONS *********************/
    -00207 
    -00208 
    -00218 void _stp_map_key_long_long(MAP map, long key1, long key2)
    -00219 {
    -00220         unsigned hv;
    -00221         struct hlist_head *head;
    -00222         struct hlist_node *e;
    -00223 
    -00224         if (map == NULL)
    -00225                 return;
    -00226 
    -00227         hv = hash_long(key1 ^ key2, HASH_TABLE_BITS);
    -00228         head = &map->hashes[hv];
    -00229 
    -00230         dbug ("hash for %ld,%ld is %d\n", key1, key2, hv);
    +00195 void _stp_map_del(MAP map)
    +00196 {
    +00197         if (map == NULL)
    +00198                 return;
    +00199 
    +00200         if (!list_empty(&map->head)) {
    +00201                 struct map_node *ptr = (struct map_node *)map->head.next;
    +00202                 while (ptr && ptr != (struct map_node *)&map->head) {
    +00203                         map_free_strings(map, ptr);
    +00204                         ptr = (struct map_node *)ptr->lnode.next;
    +00205                 }
    +00206         }
    +00207         _stp_vfree(map->membuf);
    +00208         _stp_vfree(map);
    +00209 }
    +00210 
    +00211 /**********************  KEY FUNCTIONS *********************/
    +00212 
    +00213 
    +00214 /** Set the map's key to two longs.
    +00215  * This sets the current element based on a key of two strings. If the keys are
    +00216  * not found, a new element will not be created until a <i>_stp_map_set_xxx</i>
    +00217  * call.
    +00218  * @param map
    +00219  * @param key1 first key
    +00220  * @param key2 second key
    +00221  */
    +00222 
    +00223 void _stp_map_key_long_long(MAP map, long key1, long key2)
    +00224 {
    +00225         unsigned hv;
    +00226         struct hlist_head *head;
    +00227         struct hlist_node *e;
    +00228 
    +00229         if (map == NULL)
    +00230                 return;
     00231 
    -00232         hlist_for_each(e, head) {
    -00233                 struct map_node *n =
    -00234                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00235                 dbug ("n =%lx  key=%ld,%ld\n", (long)n, n->key1.val, n->key2.val);
    -00236                 if (key1 == n->key1.val && key2 == n->key2.val) {
    -00237                         map->key = n;
    -00238                         dbug ("saving key %lx\n", (long)map->key);
    -00239                         map->create = 0;
    -00240                         return;
    -00241                 }
    -00242         }
    -00243 
    -00244         map->c_key1.val = key1;
    -00245         map->c_key2.val = key2;
    -00246         map->c_key1type = LONG;
    -00247         map->c_key2type = LONG;
    -00248         map->c_keyhead = head;
    -00249         map->create = 1;
    -00250 }
    -00251 
    -00261 void _stp_map_key_str_str(MAP map, char *key1, char *key2)
    -00262 {
    -00263         unsigned hv;
    -00264         struct hlist_head *head;
    -00265         struct hlist_node *e;
    -00266 
    -00267         if (map == NULL)
    -00268                 return;
    -00269 
    -00270         if (key1 == NULL) {
    -00271                 map->key = NULL;
    -00272                 return;
    -00273         }
    +00232         hv = hash_long(key1 ^ key2, HASH_TABLE_BITS);
    +00233         head = &map->hashes[hv];
    +00234 
    +00235         dbug ("hash for %ld,%ld is %d\n", key1, key2, hv);
    +00236 
    +00237         hlist_for_each(e, head) {
    +00238                 struct map_node *n =
    +00239                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00240                 dbug ("n =%lx  key=%ld,%ld\n", (long)n, n->key1.val, n->key2.val);
    +00241                 if (key1 == n->key1.val && key2 == n->key2.val) {
    +00242                         map->key = n;
    +00243                         dbug ("saving key %lx\n", (long)map->key);
    +00244                         map->create = 0;
    +00245                         return;
    +00246                 }
    +00247         }
    +00248 
    +00249         map->c_key1.val = key1;
    +00250         map->c_key2.val = key2;
    +00251         map->c_key1type = LONG;
    +00252         map->c_key2type = LONG;
    +00253         map->c_keyhead = head;
    +00254         map->create = 1;
    +00255 }
    +00256 
    +00257 /** Set the map's key to two strings.
    +00258  * This sets the current element based on a key of two strings. If the keys are
    +00259  * not found, a new element will not be created until a <i>_stp_map_set_xxx</i>
    +00260  * call.
    +00261  * @param map
    +00262  * @param key1 first key
    +00263  * @param key2 second key
    +00264  */
    +00265 
    +00266 void _stp_map_key_str_str(MAP map, char *key1, char *key2)
    +00267 {
    +00268         unsigned hv;
    +00269         struct hlist_head *head;
    +00270         struct hlist_node *e;
    +00271 
    +00272         if (map == NULL)
    +00273                 return;
     00274 
    -00275         hv = string_hash(key1, key2);
    -00276         head = &map->hashes[hv];
    -00277 
    -00278         dbug ("hash for %s,%s is %d\n", key1, key2, hv);
    +00275         if (key1 == NULL) {
    +00276                 map->key = NULL;
    +00277                 return;
    +00278         }
     00279 
    -00280         hlist_for_each(e, head) {
    -00281                 struct map_node *n =
    -00282                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00283                 dbug ("e =%lx  key=%s,%s\n", (long)e, n->key1.str,n->key2.str);
    -00284                 if (strcmp(key1, n->key1.str) == 0
    -00285                     && (key2 == NULL || strcmp(key2, n->key2.str) == 0)) {
    -00286                         map->key = n;
    -00287                         dbug ("saving key %lx\n", (long)map->key);
    -00288                         map->create = 0;
    -00289                         return;
    -00290                 }
    -00291         }
    -00292 
    -00293         map->c_key1.str = key1;
    -00294         map->c_key2.str = key2;
    -00295         map->c_key1type = STR;
    -00296         map->c_key2type = STR;
    -00297         map->c_keyhead = head;
    -00298         map->create = 1;
    -00299 }
    -00300 
    -00310 void _stp_map_key_str_long(MAP map, char *key1, long key2)
    -00311 {
    -00312         unsigned hv;
    -00313         struct hlist_head *head;
    -00314         struct hlist_node *e;
    -00315 
    -00316         if (map == NULL)
    -00317                 return;
    -00318 
    -00319         if (key1 == NULL) {
    -00320                 map->key = NULL;
    -00321                 return;
    -00322         }
    +00280         hv = string_hash(key1, key2);
    +00281         head = &map->hashes[hv];
    +00282 
    +00283         dbug ("hash for %s,%s is %d\n", key1, key2, hv);
    +00284 
    +00285         hlist_for_each(e, head) {
    +00286                 struct map_node *n =
    +00287                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00288                 dbug ("e =%lx  key=%s,%s\n", (long)e, n->key1.str,n->key2.str);
    +00289                 if (strcmp(key1, n->key1.str) == 0
    +00290                     && (key2 == NULL || strcmp(key2, n->key2.str) == 0)) {
    +00291                         map->key = n;
    +00292                         dbug ("saving key %lx\n", (long)map->key);
    +00293                         map->create = 0;
    +00294                         return;
    +00295                 }
    +00296         }
    +00297 
    +00298         map->c_key1.str = key1;
    +00299         map->c_key2.str = key2;
    +00300         map->c_key1type = STR;
    +00301         map->c_key2type = STR;
    +00302         map->c_keyhead = head;
    +00303         map->create = 1;
    +00304 }
    +00305 
    +00306 /** Set the map's key to a string and a long.
    +00307  * This sets the current element based on a key of a string and a long. If the keys are
    +00308  * not found, a new element will not be created until a <i>_stp_map_set_xxx</i>
    +00309  * call.
    +00310  * @param map
    +00311  * @param key1 first key
    +00312  * @param key2 second key
    +00313  */
    +00314 
    +00315 void _stp_map_key_str_long(MAP map, char *key1, long key2)
    +00316 {
    +00317         unsigned hv;
    +00318         struct hlist_head *head;
    +00319         struct hlist_node *e;
    +00320 
    +00321         if (map == NULL)
    +00322                 return;
     00323 
    -00324         hv = mixed_hash(key1, key2);
    -00325         head = &map->hashes[hv];
    -00326 
    -00327         dbug ("hash for %s,%ld is %d\n", key1, key2, hv);
    +00324         if (key1 == NULL) {
    +00325                 map->key = NULL;
    +00326                 return;
    +00327         }
     00328 
    -00329         hlist_for_each(e, head) {
    -00330                 struct map_node *n =
    -00331                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00332                 dbug ("e =%lx  key=%s,%ld\n", (long)e, n->key1.str,(long)n->key2.val);
    -00333                 if (strcmp(key1, n->key1.str) == 0 && key2 == n->key2.val) {
    -00334                         map->key = n;
    -00335                         dbug ("saving key %lx\n", (long)map->key);
    -00336                         map->create = 0;
    -00337                         return;
    -00338                 }
    -00339         }
    -00340 
    -00341         map->c_key1.str = key1;
    -00342         map->c_key2.val = key2;
    -00343         map->c_key1type = STR;
    -00344         map->c_key2type = LONG;
    -00345         map->c_keyhead = head;
    -00346         map->create = 1;
    -00347 }
    -00348 
    -00358 void _stp_map_key_long_str(MAP map, long key1, char *key2)
    -00359 {
    -00360         unsigned hv;
    -00361         struct hlist_head *head;
    -00362         struct hlist_node *e;
    -00363 
    -00364         if (map == NULL)
    -00365                 return;
    -00366 
    -00367         hv = mixed_hash(key2, key1);
    -00368         head = &map->hashes[hv];
    -00369         dbug ("hash for %ld,%s is %d\n", key1, key2, hv);
    -00370 
    -00371         hlist_for_each(e, head) {
    -00372                 struct map_node *n =
    -00373                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00374                 dbug ("e =%lx  key=%ld,%s\n", (long)e, n->key1.val,n->key2.str);
    -00375                 if (key1 == n->key1.val && strcmp(key2, n->key2.str) == 0) {
    -00376                         map->key = n;
    -00377                         dbug ("saving key %lx\n", (long)map->key);
    -00378                         map->create = 0;
    -00379                         return;
    -00380                 }
    -00381         }
    -00382 
    -00383         map->c_key1.val = key1;
    -00384         map->c_key2.str = key2;
    -00385         map->c_key1type = LONG;
    -00386         map->c_key2type = STR;
    -00387         map->c_keyhead = head;
    -00388         map->create = 1;
    -00389 }
    -00390 
    -00399 void _stp_map_key_str(MAP map, char *key)
    -00400 {
    -00401         if (map == NULL)
    -00402                 return;
    -00403         _stp_map_key_str_str(map, key, NULL);
    -00404         map->c_key2type = NONE;
    -00405 }
    -00406 
    -00415 void _stp_map_key_long(MAP map, long key)
    -00416 {
    -00417         if (map == NULL)
    -00418                 return;
    -00419         _stp_map_key_long_long(map, key, 0);
    -00420         map->c_key2type = NONE;
    -00421 }
    -00422 
    -00423 /**********************  SET/GET VALUES *********************/
    -00424 
    -00425 static void map_copy_keys(MAP map, struct map_node *m)
    -00426 {
    -00427         m->key1type = map->c_key1type;
    -00428         m->key2type = map->c_key2type;
    -00429         switch (map->c_key1type) {
    -00430         case STR:
    -00431                 m->key1.str = _stp_alloc(strlen(map->c_key1.str) + 1);
    -00432                 strcpy(m->key1.str, map->c_key1.str);
    -00433                 break;
    -00434         case LONG:
    -00435                 m->key1.val = map->c_key1.val;
    -00436                 break;
    -00437         case NONE:
    -00438                 /* ERROR */
    -00439                 break;
    -00440         }
    -00441         switch (map->c_key2type) {
    -00442         case STR:
    -00443                 m->key2.str = _stp_alloc(strlen(map->c_key2.str) + 1);
    -00444                 strcpy(m->key2.str, map->c_key2.str);
    -00445                 break;
    -00446         case LONG:
    -00447                 m->key2.val = map->c_key2.val;
    -00448                 break;
    -00449         case NONE:
    +00329         hv = mixed_hash(key1, key2);
    +00330         head = &map->hashes[hv];
    +00331 
    +00332         dbug ("hash for %s,%ld is %d\n", key1, key2, hv);
    +00333 
    +00334         hlist_for_each(e, head) {
    +00335                 struct map_node *n =
    +00336                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00337                 dbug ("e =%lx  key=%s,%ld\n", (long)e, n->key1.str,(long)n->key2.val);
    +00338                 if (strcmp(key1, n->key1.str) == 0 && key2 == n->key2.val) {
    +00339                         map->key = n;
    +00340                         dbug ("saving key %lx\n", (long)map->key);
    +00341                         map->create = 0;
    +00342                         return;
    +00343                 }
    +00344         }
    +00345 
    +00346         map->c_key1.str = key1;
    +00347         map->c_key2.val = key2;
    +00348         map->c_key1type = STR;
    +00349         map->c_key2type = LONG;
    +00350         map->c_keyhead = head;
    +00351         map->create = 1;
    +00352 }
    +00353 
    +00354 /** Set the map's key to a long and a string.
    +00355  * This sets the current element based on a key of a long and a string. If the keys are
    +00356  * not found, a new element will not be created until a <i>_stp_map_set_xxx</i>
    +00357  * call.
    +00358  * @param map
    +00359  * @param key1 first key
    +00360  * @param key2 second key
    +00361  */
    +00362 
    +00363 void _stp_map_key_long_str(MAP map, long key1, char *key2)
    +00364 {
    +00365         unsigned hv;
    +00366         struct hlist_head *head;
    +00367         struct hlist_node *e;
    +00368 
    +00369         if (map == NULL)
    +00370                 return;
    +00371 
    +00372         hv = mixed_hash(key2, key1);
    +00373         head = &map->hashes[hv];
    +00374         dbug ("hash for %ld,%s is %d\n", key1, key2, hv);
    +00375 
    +00376         hlist_for_each(e, head) {
    +00377                 struct map_node *n =
    +00378                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00379                 dbug ("e =%lx  key=%ld,%s\n", (long)e, n->key1.val,n->key2.str);
    +00380                 if (key1 == n->key1.val && strcmp(key2, n->key2.str) == 0) {
    +00381                         map->key = n;
    +00382                         dbug ("saving key %lx\n", (long)map->key);
    +00383                         map->create = 0;
    +00384                         return;
    +00385                 }
    +00386         }
    +00387 
    +00388         map->c_key1.val = key1;
    +00389         map->c_key2.str = key2;
    +00390         map->c_key1type = LONG;
    +00391         map->c_key2type = STR;
    +00392         map->c_keyhead = head;
    +00393         map->create = 1;
    +00394 }
    +00395 
    +00396 /** Set the map's key to a string.
    +00397  * This sets the current element based on a string key. If the key is
    +00398  * not found, a new element will not be created until a <i>_stp_map_set_xxx</i>
    +00399  * call.
    +00400  * @param map
    +00401  * @param key
    +00402  */
    +00403 
    +00404 void _stp_map_key_str(MAP map, char *key)
    +00405 {
    +00406         if (map == NULL)
    +00407                 return;
    +00408         _stp_map_key_str_str(map, key, NULL);
    +00409         map->c_key2type = NONE;
    +00410 }
    +00411 
    +00412 /** Set the map's key to a long.
    +00413  * This sets the current element based on a long key. If the key is
    +00414  * not found, a new element will not be created until a <i>_stp_map_set_xxx</i>
    +00415  * call.
    +00416  * @param map
    +00417  * @param key 
    +00418  */
    +00419 
    +00420 void _stp_map_key_long(MAP map, long key)
    +00421 {
    +00422         if (map == NULL)
    +00423                 return;
    +00424         _stp_map_key_long_long(map, key, 0);
    +00425         map->c_key2type = NONE;
    +00426 }
    +00427 
    +00428 /**********************  SET/GET VALUES *********************/
    +00429 
    +00430 static void map_copy_keys(MAP map, struct map_node *m)
    +00431 {
    +00432         m->key1type = map->c_key1type;
    +00433         m->key2type = map->c_key2type;
    +00434         switch (map->c_key1type) {
    +00435         case STR:
    +00436                 m->key1.str = _stp_alloc(strlen(map->c_key1.str) + 1);
    +00437                 strcpy(m->key1.str, map->c_key1.str);
    +00438                 break;
    +00439         case LONG:
    +00440                 m->key1.val = map->c_key1.val;
    +00441                 break;
    +00442         case NONE:
    +00443                 /* ERROR */
    +00444                 break;
    +00445         }
    +00446         switch (map->c_key2type) {
    +00447         case STR:
    +00448                 m->key2.str = _stp_alloc(strlen(map->c_key2.str) + 1);
    +00449                 strcpy(m->key2.str, map->c_key2.str);
     00450                 break;
    -00451         }
    -00452 
    -00453         /* add node to new hash list */
    -00454         hlist_add_head(&m->hnode, map->c_keyhead);
    -00455         
    -00456         map->key = m;
    -00457         map->create = 0;
    -00458         map->num++;
    -00459 }
    -00460 
    -00461 static void __stp_map_set_int64(MAP map, int64_t val, int add)
    -00462 {
    -00463         struct map_node_int64 *m;
    -00464 
    -00465         if (map == NULL)
    -00466                 return;
    -00467 
    -00468         if (map->create) {
    -00469                 if (val == 0)
    -00470                         return;
    -00471 
    -00472                 if (map->maxnum) {
    -00473                         if (list_empty(&map->pool)) {
    -00474                                 if (map->no_wrap) {
    -00475                                         /* ERROR. FIXME */
    -00476                                         return;
    -00477                                 }
    -00478                                 m = (struct map_node_int64 *)map->head.next;
    -00479                                 hlist_del_init(&m->n.hnode);
    -00480                                 map_free_strings(map, (struct map_node *)m);
    -00481                                 dbug ("got %lx off head\n", (long)m);
    -00482                         } else {
    -00483                                 m = (struct map_node_int64 *)map->pool.next;
    -00484                                 dbug ("got %lx off pool\n", (long)m);
    -00485                         }
    -00486                         list_move_tail(&m->n.lnode, &map->head);
    -00487                 } else {
    -00488                         m = (struct map_node_int64 *)
    -00489                             _stp_calloc(sizeof(struct map_node_int64));
    -00490                         /* add node to list */
    -00491                         list_add_tail(&m->n.lnode, &map->head);
    -00492                 }
    -00493 
    -00494                 /* copy the key(s) */
    -00495                 map_copy_keys(map, &m->n);
    -00496 
    -00497                 /* set the value */
    -00498                 m->val = val;
    -00499         } else {
    -00500                 if (map->key == NULL)
    -00501                         return;
    -00502 
    -00503                 if (val) {
    -00504                         m = (struct map_node_int64 *)map->key;
    -00505                         if (add)
    -00506                                 m->val += val;
    -00507                         else
    -00508                                 m->val = val;
    -00509                 } else if (!add) {
    -00510                         /* setting value to 0 is the same as deleting */
    -00511                         _stp_map_key_del(map);
    -00512                 }
    -00513         }
    -00514 }
    -00515 
    -00525 void _stp_map_set_int64(MAP map, int64_t val)
    -00526 {
    -00527         __stp_map_set_int64 (map, val, 0);
    -00528 }
    -00529 
    -00530 
    -00541 void _stp_map_add_int64(MAP map, int64_t val)
    -00542 {
    -00543         __stp_map_set_int64 (map, val, 1);
    -00544 }
    -00545 
    -00551 int64_t _stp_map_get_int64(MAP map)
    -00552 {
    -00553         struct map_node_int64 *m;
    -00554         if (map == NULL || map->create || map->key == NULL)
    -00555                 return 0;
    -00556         dbug ("%lx\n", (long)map->key);
    -00557         m = (struct map_node_int64 *)map->key;
    -00558         return m->val;
    -00559 }
    -00560 
    -00571 void _stp_map_set_str(MAP map, char *val)
    -00572 {
    -00573         struct map_node_str *m;
    -00574 
    -00575         if (map == NULL)
    -00576                 return;
    +00451         case LONG:
    +00452                 m->key2.val = map->c_key2.val;
    +00453                 break;
    +00454         case NONE:
    +00455                 break;
    +00456         }
    +00457 
    +00458         /* add node to new hash list */
    +00459         hlist_add_head(&m->hnode, map->c_keyhead);
    +00460         
    +00461         map->key = m;
    +00462         map->create = 0;
    +00463         map->num++;
    +00464 }
    +00465 
    +00466 static void __stp_map_set_int64(MAP map, int64_t val, int add)
    +00467 {
    +00468         struct map_node_int64 *m;
    +00469 
    +00470         if (map == NULL)
    +00471                 return;
    +00472 
    +00473         if (map->create) {
    +00474                 if (val == 0)
    +00475                         return;
    +00476 
    +00477                 if (map->maxnum) {
    +00478                         if (list_empty(&map->pool)) {
    +00479                                 if (map->no_wrap) {
    +00480                                         /* ERROR. FIXME */
    +00481                                         return;
    +00482                                 }
    +00483                                 m = (struct map_node_int64 *)map->head.next;
    +00484                                 hlist_del_init(&m->n.hnode);
    +00485                                 map_free_strings(map, (struct map_node *)m);
    +00486                                 dbug ("got %lx off head\n", (long)m);
    +00487                         } else {
    +00488                                 m = (struct map_node_int64 *)map->pool.next;
    +00489                                 dbug ("got %lx off pool\n", (long)m);
    +00490                         }
    +00491                         list_move_tail(&m->n.lnode, &map->head);
    +00492                 } else {
    +00493                         m = (struct map_node_int64 *)
    +00494                             _stp_calloc(sizeof(struct map_node_int64));
    +00495                         /* add node to list */
    +00496                         list_add_tail(&m->n.lnode, &map->head);
    +00497                 }
    +00498 
    +00499                 /* copy the key(s) */
    +00500                 map_copy_keys(map, &m->n);
    +00501 
    +00502                 /* set the value */
    +00503                 m->val = val;
    +00504         } else {
    +00505                 if (map->key == NULL)
    +00506                         return;
    +00507 
    +00508                 if (val) {
    +00509                         m = (struct map_node_int64 *)map->key;
    +00510                         if (add)
    +00511                                 m->val += val;
    +00512                         else
    +00513                                 m->val = val;
    +00514                 } else if (!add) {
    +00515                         /* setting value to 0 is the same as deleting */
    +00516                         _stp_map_key_del(map);
    +00517                 }
    +00518         }
    +00519 }
    +00520 
    +00521 /** Set the current element's value to an int64.
    +00522  * This sets the current element's value to an int64. The map must have been created
    +00523  * to hold int64s using _stp_map_new()
    +00524  *
    +00525  * If the element doesn't exist, it is created.  If no current element (key)
    +00526  * is set for the map, this function does nothing.
    +00527  * @param map
    +00528  * @param val new value
    +00529  * @sa _stp_map_add_int64
    +00530  */
    +00531 void _stp_map_set_int64(MAP map, int64_t val)
    +00532 {
    +00533         __stp_map_set_int64 (map, val, 0);
    +00534 }
    +00535 
    +00536 
    +00537 /** Adds an int64 to the current element's value.
    +00538  * This adds an int64 to the current element's value. The map must have been created
    +00539  * to hold int64s using _stp_map_new()
    +00540  *
    +00541  * If the element doesn't exist, it is created.  If no current element (key)
    +00542  * is set for the map, this function does nothing.
    +00543  * @param map
    +00544  * @param val value
    +00545  * @sa _stp_map_set_int64
    +00546  */
    +00547 
    +00548 void _stp_map_add_int64(MAP map, int64_t val)
    +00549 {
    +00550         __stp_map_set_int64 (map, val, 1);
    +00551 }
    +00552 
    +00553 /** Gets the current element's value.
    +00554  * @param map
    +00555  * @returns The value. If the current element is not set or doesn't exist, returns 0.
    +00556  */
    +00557 
    +00558 int64_t _stp_map_get_int64(MAP map)
    +00559 {
    +00560         struct map_node_int64 *m;
    +00561         if (map == NULL || map->create || map->key == NULL)
    +00562                 return 0;
    +00563         dbug ("%lx\n", (long)map->key);
    +00564         m = (struct map_node_int64 *)map->key;
    +00565         return m->val;
    +00566 }
    +00567 
    +00568 /** Set the current element's value to a string.
    +00569  * This sets the current element's value to an string. The map must have been created
    +00570  * to hold int64s using <i>_stp_map_new(xxx, STRING)</i>
    +00571  *
    +00572  * If the element doesn't exist, it is created.  If no current element (key)
    +00573  * is set for the map, this function does nothing.
    +00574  * @param map
    +00575  * @param val new string
    +00576  */
     00577 
    -00578         if (map->create) {
    -00579                 if (val == NULL)
    -00580                         return;
    +00578 void _stp_map_set_str(MAP map, char *val)
    +00579 {
    +00580         struct map_node_str *m;
     00581 
    -00582                 if (map->maxnum) {
    -00583                         if (list_empty(&map->pool)) {
    -00584                                 if (map->no_wrap) {
    -00585                                         /* ERROR. FIXME */
    -00586                                         return;
    -00587                                 }
    -00588                                 m = (struct map_node_str *)map->head.next;
    -00589                                 hlist_del_init(&m->n.hnode);
    -00590                                 map_free_strings(map, (struct map_node *)m);
    -00591                                 dbug ("got %lx off head\n", (long)m);
    -00592                         } else {
    -00593                                 m = (struct map_node_str *)map->pool.next;
    -00594                                 dbug ("got %lx off pool\n", (long)m);
    -00595                         }
    -00596                         list_move_tail(&m->n.lnode, &map->head);
    -00597                 } else {
    -00598                         m = (struct map_node_str *)
    -00599                             _stp_calloc(sizeof(struct map_node_str));
    -00600                         /* add node to list */
    -00601                         list_add_tail(&m->n.lnode, &map->head);
    -00602                 }
    -00603 
    -00604                 /* copy the key(s) */
    -00605                 map_copy_keys(map, &m->n);
    -00606 
    -00607                 /* set the value */
    -00608                 m->str = _stp_alloc(strlen(val) + 1);
    -00609                 strcpy(m->str, val);
    -00610         } else {
    -00611                 if (map->key == NULL)
    -00612                         return;
    +00582         if (map == NULL)
    +00583                 return;
    +00584 
    +00585         if (map->create) {
    +00586                 if (val == NULL)
    +00587                         return;
    +00588 
    +00589                 if (map->maxnum) {
    +00590                         if (list_empty(&map->pool)) {
    +00591                                 if (map->no_wrap) {
    +00592                                         /* ERROR. FIXME */
    +00593                                         return;
    +00594                                 }
    +00595                                 m = (struct map_node_str *)map->head.next;
    +00596                                 hlist_del_init(&m->n.hnode);
    +00597                                 map_free_strings(map, (struct map_node *)m);
    +00598                                 dbug ("got %lx off head\n", (long)m);
    +00599                         } else {
    +00600                                 m = (struct map_node_str *)map->pool.next;
    +00601                                 dbug ("got %lx off pool\n", (long)m);
    +00602                         }
    +00603                         list_move_tail(&m->n.lnode, &map->head);
    +00604                 } else {
    +00605                         m = (struct map_node_str *)
    +00606                             _stp_calloc(sizeof(struct map_node_str));
    +00607                         /* add node to list */
    +00608                         list_add_tail(&m->n.lnode, &map->head);
    +00609                 }
    +00610 
    +00611                 /* copy the key(s) */
    +00612                 map_copy_keys(map, &m->n);
     00613 
    -00614                 if (val) {
    -00615                         m = (struct map_node_str *)map->key;
    -00616                         if (m->str)
    -00617                                 _stp_free(m->str);
    -00618                         m->str = _stp_alloc(strlen(val) + 1);
    -00619                         strcpy(m->str, val);
    -00620                 } else {
    -00621                         /* setting value to 0 is the same as deleting */
    -00622                         _stp_map_key_del(map);
    -00623                 }
    -00624         }
    -00625 }
    -00626 
    -00632 char *_stp_map_get_str(MAP map)
    -00633 {
    -00634         struct map_node_str *m;
    -00635         if (map == NULL || map->create || map->key == NULL)
    -00636                 return NULL;
    -00637         dbug ("%lx\n", (long)map->key);
    -00638         m = (struct map_node_str *)map->key;
    -00639         return m->str;
    -00640 }
    -00641 
    -00656 void _stp_map_set_stat(MAP map, stat * stats)
    -00657 {
    -00658         struct map_node_stat *m;
    -00659 
    -00660         if (map == NULL)
    -00661                 return;
    -00662         dbug ("set_stat %lx\n", (long)map->key);
    -00663 
    -00664         if (map->create) {
    -00665                 if (stats == NULL)
    -00666                         return;
    -00667 
    -00668                 if (map->maxnum) {
    -00669                         if (list_empty(&map->pool)) {
    -00670                                 if (map->no_wrap) {
    -00671                                         /* ERROR. FIXME */
    -00672                                         return;
    -00673                                 }
    -00674                                 m = (struct map_node_stat *)map->head.next;
    -00675                                 hlist_del_init(&m->n.hnode);
    -00676                                 map_free_strings(map, (struct map_node *)m);
    -00677                                 dbug ("got %lx off head\n", (long)m);
    -00678                         } else {
    -00679                                 m = (struct map_node_stat *)map->pool.next;
    -00680                                 dbug ("got %lx off pool\n", (long)m);
    -00681                         }
    -00682                         list_move_tail(&m->n.lnode, &map->head);
    -00683                 } else {
    -00684                         m = (struct map_node_stat *)
    -00685                             _stp_calloc(sizeof(struct map_node_stat));
    -00686                         /* add node to list */
    -00687                         list_add_tail(&m->n.lnode, &map->head);
    -00688                 }
    -00689 
    -00690                 /* copy the key(s) */
    -00691                 map_copy_keys(map, &m->n);
    -00692 
    -00693                 /* set the value */
    -00694                 memcpy(&m->stats, stats, sizeof(stat));
    -00695         } else {
    -00696                 if (map->key == NULL)
    -00697                         return;
    -00698 
    -00699                 if (stats) {
    -00700                         m = (struct map_node_stat *)map->key;
    -00701                         memcpy(&m->stats, stats, sizeof(stat));
    -00702                 } else {
    -00703                         /* setting value to NULL is the same as deleting */
    -00704                         _stp_map_key_del(map);
    -00705                 }
    -00706         }
    -00707 }
    -00708 
    -00715 stat *_stp_map_get_stat(MAP map)
    -00716 {
    -00717         struct map_node_stat *m;
    -00718         if (map == NULL || map->create || map->key == NULL)
    -00719                 return NULL;
    -00720         dbug ("%lx\n", (long)map->key);
    -00721         m = (struct map_node_stat *)map->key;
    -00722         return &m->stats;
    -00723 }
    -00724 
    -00736 void _stp_map_stat_add(MAP map, int64_t val)
    -00737 {
    -00738         struct map_node_stat *m;
    -00739         if (map == NULL)
    -00740                 return;
    -00741 
    -00742         if (map->create) {
    -00743                 stat st = { 1, val, val, val };
    -00744                 /* histogram */
    -00745                 _stp_map_set_stat(map, &st);
    -00746                 return;
    -00747         }
    +00614                 /* set the value */
    +00615                 m->str = _stp_alloc(strlen(val) + 1);
    +00616                 strcpy(m->str, val);
    +00617         } else {
    +00618                 if (map->key == NULL)
    +00619                         return;
    +00620 
    +00621                 if (val) {
    +00622                         m = (struct map_node_str *)map->key;
    +00623                         if (m->str)
    +00624                                 _stp_free(m->str);
    +00625                         m->str = _stp_alloc(strlen(val) + 1);
    +00626                         strcpy(m->str, val);
    +00627                 } else {
    +00628                         /* setting value to 0 is the same as deleting */
    +00629                         _stp_map_key_del(map);
    +00630                 }
    +00631         }
    +00632 }
    +00633 
    +00634 /** Gets the current element's value.
    +00635  * @param map
    +00636  * @returns A string pointer. If the current element is not set or doesn't exist, returns NULL.
    +00637  */
    +00638 
    +00639 char *_stp_map_get_str(MAP map)
    +00640 {
    +00641         struct map_node_str *m;
    +00642         if (map == NULL || map->create || map->key == NULL)
    +00643                 return NULL;
    +00644         dbug ("%lx\n", (long)map->key);
    +00645         m = (struct map_node_str *)map->key;
    +00646         return m->str;
    +00647 }
    +00648 
    +00649 /** Set the current element's value to a stat.
    +00650  * This sets the current element's value to an stat struct. The map must have been created
    +00651  * to hold stats using <i>_stp_map_new(xxx, STAT)</i>.  This function would only be used
    +00652  * if we wanted to set stats to something other than the normal initial values (count = 0,
    +00653  * sum = 0, etc).  It may be deleted if it doesn't turn out to be useful.
    +00654  * @sa _stp_map_stat_add 
    +00655  *
    +00656  * If the element doesn't exist, it is created.  If no current element (key)
    +00657  * is set for the map, this function does nothing.
    +00658  * @param map
    +00659  * @param stats pointer to stats struct.
    +00660  * @todo Histograms don't work yet.
    +00661  */
    +00662 
    +00663 void _stp_map_set_stat(MAP map, stat * stats)
    +00664 {
    +00665         struct map_node_stat *m;
    +00666 
    +00667         if (map == NULL)
    +00668                 return;
    +00669         dbug ("set_stat %lx\n", (long)map->key);
    +00670 
    +00671         if (map->create) {
    +00672                 if (stats == NULL)
    +00673                         return;
    +00674 
    +00675                 if (map->maxnum) {
    +00676                         if (list_empty(&map->pool)) {
    +00677                                 if (map->no_wrap) {
    +00678                                         /* ERROR. FIXME */
    +00679                                         return;
    +00680                                 }
    +00681                                 m = (struct map_node_stat *)map->head.next;
    +00682                                 hlist_del_init(&m->n.hnode);
    +00683                                 map_free_strings(map, (struct map_node *)m);
    +00684                                 dbug ("got %lx off head\n", (long)m);
    +00685                         } else {
    +00686                                 m = (struct map_node_stat *)map->pool.next;
    +00687                                 dbug ("got %lx off pool\n", (long)m);
    +00688                         }
    +00689                         list_move_tail(&m->n.lnode, &map->head);
    +00690                 } else {
    +00691                         m = (struct map_node_stat *)
    +00692                             _stp_calloc(sizeof(struct map_node_stat));
    +00693                         /* add node to list */
    +00694                         list_add_tail(&m->n.lnode, &map->head);
    +00695                 }
    +00696 
    +00697                 /* copy the key(s) */
    +00698                 map_copy_keys(map, &m->n);
    +00699 
    +00700                 /* set the value */
    +00701                 memcpy(&m->stats, stats, sizeof(stat));
    +00702         } else {
    +00703                 if (map->key == NULL)
    +00704                         return;
    +00705 
    +00706                 if (stats) {
    +00707                         m = (struct map_node_stat *)map->key;
    +00708                         memcpy(&m->stats, stats, sizeof(stat));
    +00709                 } else {
    +00710                         /* setting value to NULL is the same as deleting */
    +00711                         _stp_map_key_del(map);
    +00712                 }
    +00713         }
    +00714 }
    +00715 
    +00716 /** Gets the current element's value.
    +00717  * @param map
    +00718  * @returns A pointer to the stats struct. If the current element is not set 
    +00719  * or doesn't exist, returns NULL.
    +00720  */
    +00721 
    +00722 stat *_stp_map_get_stat(MAP map)
    +00723 {
    +00724         struct map_node_stat *m;
    +00725         if (map == NULL || map->create || map->key == NULL)
    +00726                 return NULL;
    +00727         dbug ("%lx\n", (long)map->key);
    +00728         m = (struct map_node_stat *)map->key;
    +00729         return &m->stats;
    +00730 }
    +00731 
    +00732 /** Add to the current element's statistics.
    +00733  * Increments the statistics counter by one and the sum by <i>val</i>.
    +00734  * Adjusts minimum, maximum, and histogram.
    +00735  *
    +00736  * If the element doesn't exist, it is created.  If no current element (key)
    +00737  * is set for the map, this function does nothing.
    +00738  * @param map
    +00739  * @param val value to add to the statistics
    +00740  * @todo Histograms don't work yet.
    +00741  */
    +00742 
    +00743 void _stp_map_stat_add(MAP map, int64_t val)
    +00744 {
    +00745         struct map_node_stat *m;
    +00746         if (map == NULL)
    +00747                 return;
     00748 
    -00749         if (map->key == NULL)
    -00750                 return;
    -00751 
    -00752         dbug ("add_stat %lx\n", (long)map->key);
    -00753         m = (struct map_node_stat *)map->key;
    -00754         m->stats.count++;
    -00755         m->stats.sum += val;
    -00756         if (val > m->stats.max)
    -00757                 m->stats.max = val;
    -00758         if (val < m->stats.min)
    -00759                 m->stats.min = val;
    -00760         /* histogram */
    -00761 }
    -00762 
    -00763 /**********************  List Functions *********************/
    -00764 
    -00776 MAP _stp_list_new(unsigned max_entries, enum valtype type)
    -00777 {
    -00778   MAP map = _stp_map_new (max_entries, type);
    -00779   map->no_wrap = 1;
    -00780   return map;
    -00781 }
    +00749         if (map->create) {
    +00750                 stat st = { 1, val, val, val };
    +00751                 /* histogram */
    +00752                 _stp_map_set_stat(map, &st);
    +00753                 return;
    +00754         }
    +00755 
    +00756         if (map->key == NULL)
    +00757                 return;
    +00758 
    +00759         dbug ("add_stat %lx\n", (long)map->key);
    +00760         m = (struct map_node_stat *)map->key;
    +00761         m->stats.count++;
    +00762         m->stats.sum += val;
    +00763         if (val > m->stats.max)
    +00764                 m->stats.max = val;
    +00765         if (val < m->stats.min)
    +00766                 m->stats.min = val;
    +00767         /* histogram */
    +00768 }
    +00769 
    +00770 /**********************  List Functions *********************/
    +00771 
    +00772 /** Create a new list.
    +00773  * A list is a map that internally has an incrementing long key for each member.
    +00774  * Lists do not wrap if elements are added to exceed their maximum size.
    +00775  * @param max_entries The maximum number of entries allowed. Currently that number will
    +00776  * be preallocated.  If max_entries is 0, there will be no maximum and entries
    +00777  * will be allocated dynamically.
    +00778  * @param type Type of values stored in this list. 
    +00779  * @return A MAP on success or NULL on failure.
    +00780  * @sa foreach
    +00781  */
     00782 
    -00788 inline void _stp_list_clear(MAP map)
    -00789 {
    -00790         if (map == NULL)
    -00791                 return;
    -00792 
    -00793         if (!list_empty(&map->head)) {
    -00794                 struct map_node *ptr = (struct map_node *)map->head.next;
    -00795 
    -00796                 while (ptr && ptr != (struct map_node *)&map->head) {
    -00797                         struct map_node *next = (struct map_node *)ptr->lnode.next;
    -00798 
    -00799                         /* remove node from old hash list */
    -00800                         hlist_del_init(&ptr->hnode);
    -00801 
    -00802                         /* remove from entry list */
    -00803                         list_del(&ptr->lnode);
    -00804                         
    -00805                         /* remove any allocated string storage */
    -00806                         map_free_strings(map, ptr);
    -00807                         
    -00808                         if (map->maxnum)
    -00809                                 list_add(&ptr->lnode, &map->pool);
    -00810                         else
    -00811                                 _stp_free(ptr);
    -00812 
    -00813                         map->num--;
    -00814                         ptr = next;
    -00815                 }
    -00816         }
    -00817 
    -00818         if (map->num != 0) {
    -00819                 dlog ("ERROR: list is supposed to be empty (has %d)\n", map->num);
    -00820         }
    -00821 }
    -00822 
    -00828 inline void _stp_list_add_str(MAP map, char *str)
    -00829 {
    -00830         _stp_map_key_long(map, map->num);
    -00831         _stp_map_set_str(map, str);
    -00832 }
    -00833 
    -00839 inline void _stp_list_add_int64(MAP map, int64_t val)
    -00840 {
    -00841         _stp_map_key_long(map, map->num);
    -00842         _stp_map_set_int64(map, val);
    -00843 }
    -00844 
    -00850 inline int _stp_list_size(MAP map)
    -00851 {
    -00852         return map->num;
    -00853 }
    -

    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +00783 MAP _stp_list_new(unsigned max_entries, enum valtype type) +00784 { +00785 MAP map = _stp_map_new (max_entries, type); +00786 map->no_wrap = 1; +00787 return map; +00788 } +00789 +00790 /** Clears a list. +00791 * All elements in the list are deleted. +00792 * @param map +00793 */ +00794 +00795 void _stp_list_clear(MAP map) +00796 { +00797 if (map == NULL) +00798 return; +00799 +00800 if (!list_empty(&map->head)) { +00801 struct map_node *ptr = (struct map_node *)map->head.next; +00802 +00803 while (ptr && ptr != (struct map_node *)&map->head) { +00804 struct map_node *next = (struct map_node *)ptr->lnode.next; +00805 +00806 /* remove node from old hash list */ +00807 hlist_del_init(&ptr->hnode); +00808 +00809 /* remove from entry list */ +00810 list_del(&ptr->lnode); +00811 +00812 /* remove any allocated string storage */ +00813 map_free_strings(map, ptr); +00814 +00815 if (map->maxnum) +00816 list_add(&ptr->lnode, &map->pool); +00817 else +00818 _stp_free(ptr); +00819 +00820 map->num--; +00821 ptr = next; +00822 } +00823 } +00824 +00825 if (map->num != 0) { +00826 dlog ("ERROR: list is supposed to be empty (has %d)\n", map->num); +00827 } +00828 } +00829 +00830 /** Adds a string to a list. +00831 * @param map +00832 * @param str +00833 */ +00834 +00835 inline void _stp_list_add_str(MAP map, char *str) +00836 { +00837 _stp_map_key_long(map, map->num); +00838 _stp_map_set_str(map, str); +00839 } +00840 +00841 /** Adds an int64 to a list. +00842 * @param map +00843 * @param val +00844 */ +00845 +00846 inline void _stp_list_add_int64(MAP map, int64_t val) +00847 { +00848 _stp_map_key_long(map, map->num); +00849 _stp_map_set_int64(map, val); +00850 } +00851 +00852 /** Get the number of elements in a list. +00853 * @param map +00854 * @returns The number of elements in a list. +00855 */ +00856 +00857 inline int _stp_list_size(MAP map) +00858 { +00859 return map->num; +00860 } +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/map_8c.html b/runtime/docs/html/map_8c.html index d69f77a8..22df45e4 100644 --- a/runtime/docs/html/map_8c.html +++ b/runtime/docs/html/map_8c.html @@ -1,17 +1,18 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map.c File Reference - - -

    map.c File Reference

    + +

    map.c File Reference

    Implements maps (associative arrays) and lists. More... +

    +

    Go to the source code of this file. - + @@ -68,7 +69,7 @@ - + @@ -84,7 +85,12 @@

    Functions

    MAP _stp_map_new (unsigned max_entries, enum valtype type)
    MAP _stp_map_new (unsigned max_entries, enum valtype type)
     Create a new map.
    void _stp_map_key_del (MAP map)
    void _stp_map_stat_add (MAP map, int64_t val)
     Add to the current element's statistics.
    MAP _stp_list_new (unsigned max_entries, enum valtype type)
    MAP _stp_list_new (unsigned max_entries, enum valtype type)
     Create a new list.
    void _stp_list_clear (MAP map)
     Get the number of elements in a list.
    -


    Function Documentation

    +

    Detailed Description

    +Implements maps (associative arrays) and lists. +

    + +

    +Definition in file map.c.


    Function Documentation

    @@ -129,9 +135,9 @@ Adds an int64 to a list.

    -Definition at line 839 of file map.c. +Definition at line 846 of file map.c.

    -References _stp_map_key_long(), _stp_map_set_int64(), and map_root::num. +References _stp_map_key_long(), _stp_map_set_int64(), and map_root::num.

    @@ -178,11 +184,9 @@ Adds a string to a list.

    -Definition at line 828 of file map.c. -

    -References _stp_map_key_long(), _stp_map_set_str(), and map_root::num. +Definition at line 835 of file map.c.

    -Referenced by _stp_copy_argv_from_user(). +References _stp_map_key_long(), _stp_map_set_str(), and map_root::num.

    @@ -196,7 +200,7 @@ Referenced by _stp_copy_argv_fro MAP  map  )  - [inline] + @@ -219,9 +223,9 @@ All elements in the list are deleted.

    Parameters:

    -Definition at line 788 of file map.c. +Definition at line 795 of file map.c.

    -References _stp_free(), dlog(), map_root::head, map_node::hnode, map_node::lnode, map_root::maxnum, map_root::num, and map_root::pool. +References map_root::head, map_node::hnode, map_node::lnode, map_root::maxnum, map_root::num, and map_root::pool.

    @@ -238,7 +242,7 @@ References _stp_free(), - enum valtype  + enum valtype  type @@ -270,9 +274,9 @@ A list is a map that internally has an incrementing long key for each member. Li

    See also:
    foreach

    -Definition at line 776 of file map.c. +Definition at line 783 of file map.c.

    -References _stp_map_new(), and map_root::no_wrap. +References _stp_map_new(), and map_root::no_wrap.

    @@ -310,9 +314,9 @@ Get the number of elements in a list.

    Returns:
    The number of elements in a list.

    -Definition at line 850 of file map.c. +Definition at line 857 of file map.c.

    -References map_root::num. +References map_root::num.

    @@ -358,9 +362,10 @@ If the element doesn't exist, it is created. If no current element (key) is set val value

    +
    See also:
    _stp_map_set_int64

    -Definition at line 541 of file map.c. +Definition at line 548 of file map.c.

    @@ -397,9 +402,9 @@ Deletes a map, freeing all memory in all elements. Normally done only when the m

    -Definition at line 190 of file map.c. +Definition at line 195 of file map.c.

    -References _stp_vfree(), map_root::head, map_node::lnode, and map_root::membuf. +References map_root::head, map_node::lnode, and map_root::membuf.

    @@ -437,9 +442,9 @@ Gets the current element's value.

    Returns:
    The value. If the current element is not set or doesn't exist, returns 0.

    -Definition at line 551 of file map.c. +Definition at line 558 of file map.c.

    -References map_root::create, dbug, map_root::key, and map_node_int64::val. +References map_root::create, and map_root::key.

    @@ -477,9 +482,9 @@ Gets the current element's value.

    Returns:
    A pointer to the stats struct. If the current element is not set or doesn't exist, returns NULL.

    -Definition at line 715 of file map.c. +Definition at line 722 of file map.c.

    -References map_root::create, dbug, map_root::key, and map_node_stat::stats. +References map_root::create, and map_root::key.

    @@ -517,9 +522,9 @@ Gets the current element's value.

    Returns:
    A string pointer. If the current element is not set or doesn't exist, returns NULL.

    -Definition at line 632 of file map.c. +Definition at line 639 of file map.c.

    -References map_root::create, dbug, map_root::key, and map_node_str::str. +References map_root::create, and map_root::key.

    @@ -568,9 +573,9 @@ Get the next element in a map.

    See also:
    foreach

    -Definition at line 172 of file map.c. +Definition at line 176 of file map.c.

    -References dbug, map_root::head, and map_node::lnode. +References map_root::head, and map_node::lnode.

    @@ -607,11 +612,11 @@ If no current element (key) for this map is set, this function does nothing.

    -Definition at line 104 of file map.c. +Definition at line 108 of file map.c.

    -References _stp_free(), dbug, map_node::hnode, and map_node::lnode. +References map_root::create, map_node::hnode, map_root::key, and map_node::lnode.

    -Referenced by _stp_map_set_stat(), and _stp_map_set_str(). +Referenced by _stp_map_set_stat(), and _stp_map_set_str().

    @@ -658,11 +663,11 @@ This sets the current element based on a long key. If the key is not found, a ne

    -Definition at line 415 of file map.c. +Definition at line 420 of file map.c.

    -References _stp_map_key_long_long(), map_root::c_key2type, and NONE. +References _stp_map_key_long_long(), and map_root::c_key2type.

    -Referenced by _stp_list_add_int64(), and _stp_list_add_str(). +Referenced by _stp_list_add_int64(), and _stp_list_add_str().

    @@ -716,11 +721,11 @@ This sets the current element based on a key of two strings. If the keys are not

    -Definition at line 218 of file map.c. +Definition at line 223 of file map.c.

    -References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, LONG, and key_data::val. +References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, and key_data::val.

    -Referenced by _stp_map_key_long(). +Referenced by _stp_map_key_long().

    @@ -774,9 +779,9 @@ This sets the current element based on a key of a long and a string. If the keys

    -Definition at line 358 of file map.c. +Definition at line 363 of file map.c.

    -References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, map_node::key2, LONG, STR, key_data::str, and key_data::val. +References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

    @@ -823,9 +828,9 @@ This sets the current element based on a string key. If the key is not found, a

    -Definition at line 399 of file map.c. +Definition at line 404 of file map.c.

    -References _stp_map_key_str_str(), map_root::c_key2type, and NONE. +References _stp_map_key_str_str(), and map_root::c_key2type.

    @@ -879,9 +884,9 @@ This sets the current element based on a key of a string and a long. If the keys

    -Definition at line 310 of file map.c. +Definition at line 315 of file map.c.

    -References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, map_node::key2, LONG, STR, key_data::str, and key_data::val. +References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

    @@ -935,11 +940,11 @@ This sets the current element based on a key of two strings. If the keys are not

    -Definition at line 261 of file map.c. +Definition at line 266 of file map.c.

    -References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, map_node::key2, STR, and key_data::str. +References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, and key_data::str.

    -Referenced by _stp_map_key_str(). +Referenced by _stp_map_key_str().

    @@ -956,7 +961,7 @@ Referenced by _stp_map_key_str()< - enum valtype  + enum valtype  type @@ -987,11 +992,11 @@ Maps must be created at module initialization time.

    Parameter
    Returns:
    A MAP on success or NULL on failure.

    -Definition at line 43 of file map.c. +Definition at line 47 of file map.c.

    -References _stp_valloc(), dbug, END, map_root::head, map_root::maxnum, map_root::membuf, map_root::pool, and map_root::type. +References map_root::head, map_root::maxnum, map_root::membuf, map_root::pool, and map_root::type.

    -Referenced by _stp_list_new(). +Referenced by _stp_list_new().

    @@ -1037,11 +1042,12 @@ If the element doesn't exist, it is created. If no current element (key) is set val new value

    +
    See also:
    _stp_map_add_int64

    -Definition at line 525 of file map.c. +Definition at line 531 of file map.c.

    -Referenced by _stp_list_add_int64(). +Referenced by _stp_list_add_int64().

    @@ -1090,11 +1096,11 @@ If the element doesn't exist, it is created. If no current element (key) is set

    Todo:
    Histograms don't work yet.

    -Definition at line 656 of file map.c. +Definition at line 663 of file map.c.

    -References _stp_calloc(), _stp_map_key_del(), map_root::create, dbug, map_root::head, map_node::hnode, map_root::key, map_node::lnode, map_root::maxnum, map_node_stat::n, map_root::no_wrap, map_root::pool, and map_node_stat::stats. +References _stp_map_key_del(), map_root::create, map_root::head, map_root::key, map_root::maxnum, map_root::no_wrap, and map_root::pool.

    -Referenced by _stp_map_stat_add(). +Referenced by _stp_map_stat_add().

    @@ -1142,11 +1148,11 @@ If the element doesn't exist, it is created. If no current element (key) is set

    -Definition at line 571 of file map.c. +Definition at line 578 of file map.c.

    -References _stp_alloc(), _stp_calloc(), _stp_free(), _stp_map_key_del(), map_root::create, dbug, map_root::head, map_node::hnode, map_root::key, map_node::lnode, map_root::maxnum, map_node_str::n, map_root::no_wrap, map_root::pool, and map_node_str::str. +References _stp_map_key_del(), map_root::create, map_root::head, map_root::key, map_root::maxnum, map_root::no_wrap, and map_root::pool.

    -Referenced by _stp_list_add_str(). +Referenced by _stp_list_add_str().

    @@ -1185,9 +1191,9 @@ Get the first element in a map.

    See also:
    foreach

    -Definition at line 149 of file map.c. +Definition at line 153 of file map.c.

    -References dbug, and map_root::head. +References map_root::head.

    @@ -1236,13 +1242,11 @@ If the element doesn't exist, it is created. If no current element (key) is set

    Todo:
    Histograms don't work yet.

    -Definition at line 736 of file map.c. +Definition at line 743 of file map.c.

    -References _stp_map_set_stat(), stat::count, map_root::create, dbug, map_root::key, stat::max, stat::min, map_node_stat::stats, and stat::sum. +References _stp_map_set_stat(), map_root::create, and map_root::key. -


    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/map_8h-source.html b/runtime/docs/html/map_8h-source.html index 7ecc890f..443fb9c9 100644 --- a/runtime/docs/html/map_8h-source.html +++ b/runtime/docs/html/map_8h-source.html @@ -1,146 +1,162 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map.h Source File - - -

    map.h

    Go to the documentation of this file.
    00001 /* -*- linux-c -*- */
    -00002 #include <linux/types.h>
    -00003 
    -00004 typedef struct {
    -00005         int64_t count;
    -00006         int64_t sum;
    -00007         int64_t min, max;
    -00008         int64_t histogram[BUCKETS];
    -00009 } stat;
    -00010 
    -00011 union key_data {
    -00012         long val;
    -00013         char *str;
    -00014 };
    -00015 
    -00016 enum keytype { NONE, LONG, STR } __attribute__ ((packed));
    -00017 enum valtype { INT64, STAT, STRING, END };
    -00018 
    -00019 /* all map nodes have the following structure */
    -00020 struct map_node {
    -00021         struct list_head lnode;
    -00022         struct hlist_node hnode;
    -00023         union key_data key1;
    -00024         union key_data key2;
    -00025         enum keytype key1type;
    -00026         enum keytype key2type;
    -00027 };
    -00028 
    -00029 /* specific map nodes with data attached */
    -00030 struct map_node_int64 {
    -00031         struct map_node n;
    -00032         int64_t val;
    -00033 };
    -00034 
    -00035 struct map_node_str {
    -00036         struct map_node n;
    -00037         char *str;
    -00038 };
    -00039 
    -00040 struct map_node_stat {
    -00041         struct map_node n;
    -00042         stat stats;
    -00043 };
    -00044 
    -00045 struct map_root {
    -00046         /* type of the values stored in the array */
    -00047         enum valtype type;
    +
    +

    map.h

    Go to the documentation of this file.
    00001 /* -*- linux-c -*- */
    +00002 /** @file map.h
    +00003  * @brief Header file for maps and lists
    +00004  */
    +00005 
    +00006 #include <linux/types.h>
    +00007 
    +00008 /** Statistics are stored in this struct
    +00009 */
    +00010 typedef struct {
    +00011         int64_t count;
    +00012         int64_t sum;
    +00013         int64_t min, max;
    +00014         int64_t histogram[BUCKETS];
    +00015 } stat;
    +00016 
    +00017 /** Keys are either longs or char *
    +00018  */
    +00019 union key_data {
    +00020         long val;
    +00021         char *str;
    +00022 };
    +00023 
    +00024 enum keytype { NONE, LONG, STR } __attribute__ ((packed));
    +00025 enum valtype { INT64, STAT, STRING, END };
    +00026 
    +00027 /** all map nodes have the following structure 
    +00028 */
    +00029 struct map_node {
    +00030         struct list_head lnode;
    +00031         struct hlist_node hnode;
    +00032         union key_data key1;
    +00033         union key_data key2;
    +00034         enum keytype key1type;
    +00035         enum keytype key2type;
    +00036 };
    +00037 
    +00038 /* specific map nodes with data attached */
    +00039 struct map_node_int64 {
    +00040         struct map_node n;
    +00041         int64_t val;
    +00042 };
    +00043 
    +00044 struct map_node_str {
    +00045         struct map_node n;
    +00046         char *str;
    +00047 };
     00048 
    -00049         /* maximum number of elements allowed in the array. */
    -00050         int maxnum;
    -00051 
    -00052         /* current number of elements */
    -00053         int num;
    -00054 
    -00055         /* when more than maxnum elements, wrap or discard */
    -00056         int no_wrap;
    -00057 
    -00058         /* linked list of current entries */
    -00059         struct list_head head;
    +00049 struct map_node_stat {
    +00050         struct map_node n;
    +00051         stat stats;
    +00052 };
    +00053 
    +00054 /** This structure contains all information about a map.
    +00055  * It is allocated once when _stp_map_new() is called.
    +00056  */
    +00057 struct map_root {
    +00058         enum valtype type;  /** type of the values stored in the array */
    +00059         int maxnum;     /** maximum number of elements allowed in the array. */
     00060 
    -00061         /* pool of unused entries.  Used only when entries are statically allocated */
    -00062         /* at startup. */
    -00063         struct list_head pool;
    -00064 
    -00065         /* saved key entry for lookups */
    -00066         struct map_node *key;
    -00067 
    -00068         /* this is the creation data saved between the key functions and the */
    -00069         /* set/get functions */
    -00070         u_int8_t create;
    -00071         enum keytype c_key1type;
    -00072         enum keytype c_key2type;
    -00073         struct hlist_head *c_keyhead;
    -00074         union key_data c_key1;
    -00075         union key_data c_key2;
    +00061         /* current number of elements */
    +00062         int num;
    +00063 
    +00064         /* when more than maxnum elements, wrap or discard */
    +00065         int no_wrap;
    +00066 
    +00067         /* linked list of current entries */
    +00068         struct list_head head;
    +00069 
    +00070         /* pool of unused entries.  Used only when entries are statically allocated */
    +00071         /* at startup. */
    +00072         struct list_head pool;
    +00073 
    +00074         /* saved key entry for lookups */
    +00075         struct map_node *key;
     00076 
    -00077         /* the hash table for this array */
    -00078         struct hlist_head hashes[HASH_TABLE_SIZE];
    -00079 
    -00080         /* pointer to allocated memory space */
    -00081         void *membuf;
    -00082 };
    -00083 
    -00084 typedef struct map_root *MAP;
    +00077         /* this is the creation data saved between the key functions and the */
    +00078         /* set/get functions */
    +00079         u_int8_t create;
    +00080         enum keytype c_key1type;
    +00081         enum keytype c_key2type;
    +00082         struct hlist_head *c_keyhead;
    +00083         union key_data c_key1;
    +00084         union key_data c_key2;
     00085 
    -00086 #define key1str(ptr) (ptr->n.key1.str)
    -00087 #define key2str(ptr) (ptr->n.key2.str)
    -00088 #define key1int(ptr) (ptr->n.key1.val)
    -00089 #define key2int(ptr) (ptr->n.key2.val)
    -00090 
    -00091 #define _stp_map_key2(map, key1, key2)                          \
    -00092   ({                                                            \
    -00093     if (__builtin_types_compatible_p (typeof (key1), char[]))   \
    -00094       if (__builtin_types_compatible_p (typeof (key2), char[])) \
    -00095         _stp_map_key_str_str (map, (char *)(key1), (char *)(key2));     \
    -00096       else                                                      \
    -00097         _stp_map_key_str_long (map, (char *)(key1), (long)(key2));      \
    -00098     else                                                        \
    -00099       if (__builtin_types_compatible_p (typeof (key2), char[])) \
    -00100         _stp_map_key_long_str (map, (long)(key1), (char *)(key2));      \
    -00101       else                                                      \
    -00102         _stp_map_key_long_long (map, (long)(key1), (long)(key2));       \
    -00103   })
    -00104 
    -00105 #define _stp_map_key(map, key)                          \
    -00106   ({                                                            \
    -00107     if (__builtin_types_compatible_p (typeof (key), char[]))    \
    -00108       _stp_map_key_str (map, (char *)(key));                            \
    +00086         /* the hash table for this array */
    +00087         struct hlist_head hashes[HASH_TABLE_SIZE];
    +00088 
    +00089         /* pointer to allocated memory space */
    +00090         void *membuf;
    +00091 };
    +00092 
    +00093 /** All maps are of this type.
    +00094  */
    +00095 typedef struct map_root *MAP;
    +00096 
    +00097 #define key1str(ptr) (ptr->n.key1.str)
    +00098 #define key2str(ptr) (ptr->n.key2.str)
    +00099 #define key1int(ptr) (ptr->n.key1.val)
    +00100 #define key2int(ptr) (ptr->n.key2.val)
    +00101 
    +00102 #define _stp_map_key2(map, key1, key2)                          \
    +00103   ({                                                            \
    +00104     if (__builtin_types_compatible_p (typeof (key1), char[]))   \
    +00105       if (__builtin_types_compatible_p (typeof (key2), char[])) \
    +00106         _stp_map_key_str_str (map, (char *)(key1), (char *)(key2));     \
    +00107       else                                                      \
    +00108         _stp_map_key_str_long (map, (char *)(key1), (long)(key2));      \
     00109     else                                                        \
    -00110       _stp_map_key_long (map, (long)(key));                             \
    -00111   })
    -00112 
    -00113 #define _stp_map_set(map, val)                          \
    -00114   ({                                                            \
    -00115     if (__builtin_types_compatible_p (typeof (val), char[]))    \
    -00116       _stp_map_set_str (map, (char *)(val));                            \
    -00117     else                                                        \
    -00118       _stp_map_set_int64 (map, (int64_t)(val));                 \
    -00119   })
    -00120 
    -00121 #define _stp_list_add(map, val)                         \
    -00122   ({                                                            \
    -00123     if (__builtin_types_compatible_p (typeof (val), char[]))    \
    -00124       _stp_list_add_str (map, (char *)(val));                           \
    -00125     else                                                        \
    -00126       _stp_list_add_int64 (map, (int64_t)(val));                        \
    -00127   })
    -00128 
    -00129 
    -00138 #define foreach(map, ptr)                               \
    -00139   for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \
    -00140        ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr))
    -00141 
    -

    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +00110 if (__builtin_types_compatible_p (typeof (key2), char[])) \ +00111 _stp_map_key_long_str (map, (long)(key1), (char *)(key2)); \ +00112 else \ +00113 _stp_map_key_long_long (map, (long)(key1), (long)(key2)); \ +00114 }) +00115 +00116 #define _stp_map_key(map, key) \ +00117 ({ \ +00118 if (__builtin_types_compatible_p (typeof (key), char[])) \ +00119 _stp_map_key_str (map, (char *)(key)); \ +00120 else \ +00121 _stp_map_key_long (map, (long)(key)); \ +00122 }) +00123 +00124 #define _stp_map_set(map, val) \ +00125 ({ \ +00126 if (__builtin_types_compatible_p (typeof (val), char[])) \ +00127 _stp_map_set_str (map, (char *)(val)); \ +00128 else \ +00129 _stp_map_set_int64 (map, (int64_t)(val)); \ +00130 }) +00131 +00132 #define _stp_list_add(map, val) \ +00133 ({ \ +00134 if (__builtin_types_compatible_p (typeof (val), char[])) \ +00135 _stp_list_add_str (map, (char *)(val)); \ +00136 else \ +00137 _stp_list_add_int64 (map, (int64_t)(val)); \ +00138 }) +00139 +00140 +00141 /** Loop through all elements of a map. +00142 * @param map +00143 * @param ptr pointer to a map_node_stat, map_node_int64 or map_node_str +00144 * +00145 * @b Example: +00146 * @include foreach.c +00147 */ +00148 +00149 #define foreach(map, ptr) \ +00150 for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \ +00151 ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr)) +00152 +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/map_8h.html b/runtime/docs/html/map_8h.html index 2d35515b..ae26cf69 100644 --- a/runtime/docs/html/map_8h.html +++ b/runtime/docs/html/map_8h.html @@ -1,56 +1,69 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map.h File Reference - - -

    map.h File Reference

    #include <linux/types.h>
    + +

    map.h File Reference

    Header file for maps and lists. More... +

    +#include <linux/types.h>

    Go to the source code of this file. - + - + - + - + - + - + - + - + - + + - - - +

    Defines

    #define key1str(ptr)   (ptr->n.key1.str)
    +#define key1str(ptr)   (ptr->n.key1.str)
    #define key2str(ptr)   (ptr->n.key2.str)
    +#define key2str(ptr)   (ptr->n.key2.str)
    #define key1int(ptr)   (ptr->n.key1.val)
    +#define key1int(ptr)   (ptr->n.key1.val)
    #define key2int(ptr)   (ptr->n.key2.val)
    +#define key2int(ptr)   (ptr->n.key2.val)
    #define _stp_map_key2(map, key1, key2)
    #define _stp_map_key2(map, key1, key2)
    #define _stp_map_key(map, key)
    #define _stp_map_key(map, key)
    #define _stp_map_set(map, val)
    #define _stp_map_set(map, val)
    #define _stp_list_add(map, val)
    #define _stp_list_add(map, val)
    #define foreach(map, ptr)
     Loop through all elements of a map.

    Typedefs

    typedef map_rootMAP
    +typedef map_rootMAP
     All maps are of this type.

    Enumerations

    enum  keytype { NONE, -LONG, -STR +
    enum  keytype { NONE, +LONG, +STR }
    enum  valtype { INT64, -STAT, -STRING, -END +
    enum  valtype { INT64, +STAT, +STRING, +END }

    Variables

    enum keytype packed
    +enum keytype packed
    -


    Define Documentation

    +

    Detailed Description

    +Header file for maps and lists. +

    + +

    +Definition in file map.h.


    Define Documentation

    @@ -87,7 +100,7 @@ })

    -Definition at line 121 of file map.h. +Definition at line 132 of file map.h.

    @@ -126,7 +139,7 @@ Definition at line 121 of fil })

    -Definition at line 105 of file map.h. +Definition at line 116 of file map.h.

    @@ -174,7 +187,7 @@ Definition at line 105 of fil })

    -Definition at line 91 of file map.h. +Definition at line 102 of file map.h.

    @@ -213,7 +226,7 @@ Definition at line 91 of file })

    -Definition at line 113 of file map.h. +Definition at line 124 of file map.h.

    @@ -251,12 +264,12 @@ Definition at line 113 of fil

    Parameters:
    - +
    map 
    ptr pointer to a map_node_stat, map_node_int64 or map_node_str
    ptr pointer to a map_node_stat, map_node_int64 or map_node_str
    Example:
    /* example showing how to print all the stats in a map using foreach() */
     
    -struct map_node_stat *ptr;
    +struct map_node_stat *ptr;
     
     foreach (map, ptr)
          printf ("map[%s,%ld] = [c=%lld s=%lld min=%lld max=%lld]\n", key1str(ptr), 
    @@ -265,254 +278,9 @@ Definition at line 113 of fil
     
     

    -Definition at line 138 of file map.h. - - -

    - - - - -
    - - - - - - - - - -
    #define key1int ptr   )    (ptr->n.key1.val)
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 88 of file map.h.

    -

    - - - - -
    - - - - - - - - - -
    #define key1str ptr   )    (ptr->n.key1.str)
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 86 of file map.h.

    -

    - - - - -
    - - - - - - - - - -
    #define key2int ptr   )    (ptr->n.key2.val)
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 89 of file map.h.

    -

    - - - - -
    - - - - - - - - - -
    #define key2str ptr   )    (ptr->n.key2.str)
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 87 of file map.h.

    -


    Typedef Documentation

    -

    - - - - -
    - - - - -
    typedef struct map_root* MAP
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 84 of file map.h.

    -


    Enumeration Type Documentation

    -

    - - - - -
    - - - - -
    enum keytype
    -
    - - - - - -
    -   - - -

    -

    Enumeration values:
    - - - - -
    NONE  -
    LONG  -
    STR  -
    -
    - -

    -Definition at line 16 of file map.h.

    -

    - - - - -
    - - - - -
    enum valtype
    -
    - - - - - -
    -   - - -

    -

    Enumeration values:
    - - - - - -
    INT64  -
    STAT  -
    STRING  -
    END  -
    -
    - -

    -Definition at line 17 of file map.h.

    -


    Variable Documentation

    -

    - - - - -
    - - - - -
    enum keytype packed
    -
    - - - - +Definition at line 149 of file map.h.
    -   - - -

    -

    -


    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/pages.html b/runtime/docs/html/pages.html index d79b953e..0760af31 100644 --- a/runtime/docs/html/pages.html +++ b/runtime/docs/html/pages.html @@ -1,19 +1,14 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Page Index - - +

    SystemTap Related Pages

    Here is a list of all related documentation pages: -
    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/probes.html b/runtime/docs/html/probes.html new file mode 100644 index 00000000..b25bf2c7 --- /dev/null +++ b/runtime/docs/html/probes.html @@ -0,0 +1,10 @@ + + +SystemTap: Example Probes + + + + +

    Example Probes


    +Generated on Mon Mar 21 23:24:22 2005 for SystemTap. + diff --git a/runtime/docs/html/probes_2README-source.html b/runtime/docs/html/probes_2README-source.html new file mode 100644 index 00000000..2f787b1a --- /dev/null +++ b/runtime/docs/html/probes_2README-source.html @@ -0,0 +1,16 @@ + + +SystemTap: probes/README Source File + + + + + +

    README

    00001 /** @dir probes
    +00002 This directory contains working example probes that demonstrate and test
    +00003 the runtime library. They are tested on i386 and x86_64.
    +00004 */
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/probes_2shellsnoop_2README-source.html b/runtime/docs/html/probes_2shellsnoop_2README-source.html new file mode 100644 index 00000000..2a2ac71d --- /dev/null +++ b/runtime/docs/html/probes_2shellsnoop_2README-source.html @@ -0,0 +1,85 @@ + + +SystemTap: probes/shellsnoop/README Source File + + + + + +

    README

    00001 /** @dir shellsnoop
    +00002 Snoops on what commands are being run by shells.
    +00003 
    +00004 This is a translation of on an old dtr probe. It demonstrates maps,
    +00005 lists, and how to use _stp_copy_argv_from_user() and  _stp_strncpy_from_user().
    +00006 
    +00007 Original dtr source:
    +00008 
    +00009 \verbatim
    +00010 # shellsnoop.probe - snoop shell execution as it occurs.
    +00011 # clone of dtrace shellsnoop example
    +00012 
    +00013 global {
    +00014   long @pids[long];
    +00015 }
    +00016 
    +00017 probe do_execve:entry {
    +00018   char __user *vstr;
    +00019   char str[256];
    +00020   int len;
    +00021 
    +00022   /* watch shells only */
    +00023   /* FIXME: detect more shells, like csh, tcsh, zsh */
    +00024 
    +00025   if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh")
    +00026       || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh"))
    +00027     {
    +00028       dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename);
    +00029       @pids[current->pid] = 1;
    +00030 
    +00031       /* print out argv, ignoring argv[0] */
    +00032       if (argv) argv++;
    +00033       while (argv != NULL)
    +00034         {
    +00035           if (get_user (vstr, argv))
    +00036             break;
    +00037           if (!vstr)
    +00038             break;
    +00039           len = dtr_strncpy_from_user(str, vstr, 256);
    +00040           str[len] = 0;
    +00041           printk ("%s ", str);
    +00042           argv++;
    +00043         }
    +00044       printk ("\n");
    +00045     }
    +00046 }
    +00047 
    +00048 # use filp_open because copy_from_user not needed there
    +00049 probe filp_open:entry {
    +00050   if (@pids[current->pid])
    +00051     dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename);
    +00052 }
    +00053 
    +00054 probe sys_read:entry {
    +00055   if (@pids[current->pid])
    +00056     dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd);
    +00057 }
    +00058 
    +00059 probe sys_write:entry {
    +00060   size_t len;
    +00061   char str[256];
    +00062   if (@pids[current->pid])
    +00063     {
    +00064       if (count < 64) len = count;
    +00065       else len = 64;
    +00066       if (len = dtr_strncpy_from_user(str, buf, len)) {
    +00067         str[len] = 0;
    +00068         dlog ("%d\t%d\t%s\tW %s\n", current->pid, current->parent->pid, current->comm, str);
    +00069         }
    +00070     }
    +00071 }
    +00072 \endverbatim
    +00073 */
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/probes_2tasklet_2README-source.html b/runtime/docs/html/probes_2tasklet_2README-source.html new file mode 100644 index 00000000..bef82d09 --- /dev/null +++ b/runtime/docs/html/probes_2tasklet_2README-source.html @@ -0,0 +1,22 @@ + + +SystemTap: probes/tasklet/README Source File + + + + + +

    README

    00001 /** @dir tasklet
    +00002 Sample probe in a tasklet.  Useful for interrupt context testing.
    +00003 
    +00004 \verbatim
    +00005 > ./build
    +00006 > insmod stp_tasklet.ko
    +00007 > rmmod stp_tasklet.ko
    +00008 \endverbatim
    +00009 
    +00010 */
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/probes_2test4_2README-source.html b/runtime/docs/html/probes_2test4_2README-source.html new file mode 100644 index 00000000..2a5a48f3 --- /dev/null +++ b/runtime/docs/html/probes_2test4_2README-source.html @@ -0,0 +1,36 @@ + + +SystemTap: probes/test4/README Source File + + + + + +

    README

    00001 /** @dir test4
    +00002 This example probe tracks file opens, reads and writes.
    +00003 It demonstrates maps, stats, and iterators.
    +00004 
    +00005 This is a translation of on an old dtr probe.  Original source is
    +00006 \verbatim
    +00007 global {
    +00008   long @opens[string];
    +00009   sum @reads[string], @writes[string];
    +00010 }
    +00011 
    +00012 probe sys_open:entry {
    +00013   @opens[current->comm]++;
    +00014 }
    +00015 
    +00016 probe sys_read:entry {
    +00017   @reads[current->comm] << count;
    +00018 }
    +00019 
    +00020 probe sys_write:entry {
    +00021   @writes[current->comm] << count;
    +00022 }
    +00023 \endverbatim
    +00024 */
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/probes_2where__func_2README-source.html b/runtime/docs/html/probes_2where__func_2README-source.html new file mode 100644 index 00000000..a9995043 --- /dev/null +++ b/runtime/docs/html/probes_2where__func_2README-source.html @@ -0,0 +1,38 @@ + + +SystemTap: probes/where_func/README Source File + + + + + +

    README

    00001 /** @dir where_func
    +00002 This is a silly little instrumentation routine to instrument functions
    +00003 entry by name. It makes use of the SystemTap runtime libraries to break
    +00004 down the number of times the function by caller. 
    +00005 
    +00006 It demonstrates kprobes, passing a module parameter, using the print buffer,
    +00007 and using _stp_print_symbol() to map the addresses back to locations 
    +00008 in functions.
    +00009 
    +00010 By default it instruments schedule().
    +00011 
    +00012 The instrumentation module is built by having the kernel that is going
    +00013 to be instrumented currently on the machine and doing 
    +00014 \code
    +00015 ./build
    +00016 \endcode
    +00017 The instrumentation is inserted as root with:
    +00018 \code
    +00019 /sbin/insmod kprobe_funct_where.ko funct_name=function_name
    +00020 \endcode
    +00021 The instrumentation is removed as root with:
    +00022 \code
    +00023 /sbin/rmmod kprobe_funct_where
    +00024 \endcode
    +00025 -Will Cohen
    +00026 */
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/probes_8c-source.html b/runtime/docs/html/probes_8c-source.html index 58c3fa98..3446e997 100644 --- a/runtime/docs/html/probes_8c-source.html +++ b/runtime/docs/html/probes_8c-source.html @@ -1,24 +1,32 @@ -SystemTap: SystemTap Runtime Library +SystemTap: probes.c Source File - - -

    probes.c

    Go to the documentation of this file.
    00001 /* -*- linux-c -*- */
    -00002 
    +
    +

    probes.c

    00001 /* -*- linux-c -*- */
    +00002 
    +00003 /** Create a new map.
    +00004  * Maps must be created at module initialization time.
    +00005  * @param max_entries The maximum number of entries allowed. Currently that 
    +00006  * will be allocated dynamically.
    +00007  * @param type Type of values stored in this map. 
    +00008  * @return A MAP on success or NULL on failure.
    +00009  */
    +00010 
    +00011 
     00012 static unsigned long (*_stp_lookup_name)(char *name)=(void *)KALLSYMS_LOOKUP_NAME;
     00013 
    -00014 void _stp_unregister_jprobes (struct jprobe *probes, int num_probes)
    +00014 void _stp_unregister_jprobes (struct jprobe *probes, int num_probes)
     00015 {
     00016         int i;
     00017         for (i = 0; i < num_probes; i++)
     00018                 unregister_jprobe(&probes[i]);
    -00019         dlog ("All jprobes removed\n");
    +00019         dlog ("All jprobes removed\n");
     00020 }
     00021 
    -00022 int _stp_register_jprobes (struct jprobe *probes, int num_probes)
    +00022 int _stp_register_jprobes (struct jprobe *probes, int num_probes)
     00023 {
     00024         int i, ret ;
     00025         unsigned long addr;
    @@ -26,33 +34,33 @@
     00027         for (i = 0; i < num_probes; i++) {
     00028                 addr =_stp_lookup_name((char *)probes[i].kp.addr);
     00029                 if (addr == 0) {
    -00030                         dlog ("ERROR: function %s not found!\n", 
    +00030                         dlog ("ERROR: function %s not found!\n", 
     00031                               (char *)probes[i].kp.addr);
     00032                         ret = -1; /* FIXME */
     00033                         goto out;
     00034                 }
    -00035                 dlog("inserting jprobe at %s (%p)\n", probes[i].kp.addr, addr);
    +00035                 dlog("inserting jprobe at %s (%p)\n", probes[i].kp.addr, addr);
     00036                 probes[i].kp.addr = (kprobe_opcode_t *)addr;
     00037                 ret = register_jprobe(&probes[i]);
     00038                 if (ret)
    -00039                         goto out;
    +00039                         goto out;
     00040         }
    -00041         return 0;
    +00041         return 0;
     00042 out:
    -00043         dlog ("probe module initialization failed.  Exiting...\n");
    -00044         _stp_unregister_jprobes(probes, i);
    -00045         return ret;
    +00043         dlog ("probe module initialization failed.  Exiting...\n");
    +00044         _stp_unregister_jprobes(probes, i);
    +00045         return ret;
     00046 }
     00047 
    -00048 void _stp_unregister_kprobes (struct kprobe *probes, int num_probes)
    +00048 void _stp_unregister_kprobes (struct kprobe *probes, int num_probes)
     00049 {
     00050         int i;
     00051         for (i = 0; i < num_probes; i++)
     00052                 unregister_kprobe(&probes[i]);
    -00053         dlog ("All kprobes removed\n");
    +00053         dlog ("All kprobes removed\n");
     00054 }
     00055 
    -00056 int _stp_register_kprobes (struct kprobe *probes, int num_probes)
    +00056 int _stp_register_kprobes (struct kprobe *probes, int num_probes)
     00057 {
     00058         int i, ret ;
     00059         unsigned long addr;
    @@ -60,26 +68,24 @@
     00061         for (i = 0; i < num_probes; i++) {
     00062                 addr =_stp_lookup_name((char *)probes[i].addr);
     00063                 if (addr == 0) {
    -00064                         dlog ("ERROR: function %s not found!\n", 
    +00064                         dlog ("ERROR: function %s not found!\n", 
     00065                               (char *)probes[i].addr);
     00066                         ret = -1; /* FIXME */
     00067                         goto out;
     00068                 }
    -00069                 dlog("inserting kprobe at %s (%p)\n", probes[i].addr, addr);
    +00069                 dlog("inserting kprobe at %s (%p)\n", probes[i].addr, addr);
     00070                 probes[i].addr = (kprobe_opcode_t *)addr;
     00071                 ret = register_kprobe(&probes[i]);
     00072                 if (ret)
    -00073                         goto out;
    +00073                         goto out;
     00074         }
    -00075         return 0;
    +00075         return 0;
     00076 out:
    -00077         dlog ("probe module initialization failed.  Exiting...\n");
    -00078         _stp_unregister_kprobes(probes, i);
    -00079         return ret;
    +00077         dlog ("probe module initialization failed.  Exiting...\n");
    +00078         _stp_unregister_kprobes(probes, i);
    +00079         return ret;
     00080 }
     00081 
    -

    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/runtime_8h-source.html b/runtime/docs/html/runtime_8h-source.html index 10312ec7..ec00eb2b 100644 --- a/runtime/docs/html/runtime_8h-source.html +++ b/runtime/docs/html/runtime_8h-source.html @@ -1,12 +1,11 @@ -SystemTap: SystemTap Runtime Library +SystemTap: runtime.h Source File - - -

    runtime.h

    Go to the documentation of this file.
    00001 
    +
    +

    runtime.h

    00001 
     00002 #include <linux/module.h>
     00003 #include <linux/kernel.h>
     00004 #include <linux/miscdevice.h>
    @@ -22,13 +21,11 @@
     00014 #include <asm/uaccess.h>
     00015 #include <linux/kallsyms.h>
     00016 
    -00017 #include "alloc.h"
    +00017 #include "alloc.h"
     00018 #include "map.h"
     00019 
    -00020 #define dbug(args...) ;
    +00020 #define dbug(args...) ;
     00021 
    -

    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/shellsnoop_2dtr_8c-source.html b/runtime/docs/html/shellsnoop_2dtr_8c-source.html new file mode 100644 index 00000000..7f6aa12c --- /dev/null +++ b/runtime/docs/html/shellsnoop_2dtr_8c-source.html @@ -0,0 +1,138 @@ + + +SystemTap: probes/shellsnoop/dtr.c Source File + + + + + +

    dtr.c

    00001 #define HASH_TABLE_BITS 8
    +00002 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
    +00003 #define BUCKETS 16 /* largest histogram width */
    +00004 
    +00005 #include "runtime.h"
    +00006 #include "io.c"
    +00007 #include "map.c"
    +00008 #include "copy.c"
    +00009 #include "probes.c"
    +00010 
    +00011 MODULE_DESCRIPTION("SystemTap probe: shellsnoop");
    +00012 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
    +00013 
    +00014 MAP pids, arglist ;
    +00015 
    +00016 int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs)
    +00017 {
    +00018   struct map_node_str *ptr;
    +00019 
    +00020   /* watch shells only */
    +00021   /* FIXME: detect more shells, like csh, tcsh, zsh */
    +00022   
    +00023   if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh")
    +00024       || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh"))
    +00025     {
    +00026       dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename);
    +00027 
    +00028       _stp_map_key_long (pids, current->pid);
    +00029       _stp_map_set_int64 (pids, 1);
    +00030       
    +00031       _stp_list_clear (arglist);
    +00032       _stp_copy_argv_from_user (arglist, argv);
    +00033       foreach (arglist, ptr)
    +00034         printk ("%s ", ptr->str);
    +00035       printk ("\n");
    +00036     }
    +00037   jprobe_return();
    +00038   return 0;
    +00039 }
    +00040 
    +00041 struct file * inst_filp_open (const char * filename, int flags, int mode)
    +00042 {
    +00043   _stp_map_key_long (pids, current->pid);
    +00044   if (_stp_map_get_int64 (pids))
    +00045     dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename);
    +00046   
    +00047   jprobe_return();
    +00048   return 0;
    +00049 }
    +00050 
    +00051 asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count)
    +00052 {
    +00053   _stp_map_key_long (pids, current->pid);
    +00054   if (_stp_map_get_int64 (pids))
    +00055     dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd);
    +00056   
    +00057   jprobe_return();
    +00058   return 0;
    +00059 }
    +00060 
    +00061 asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count)
    +00062 {
    +00063   size_t len;
    +00064   char str[256];
    +00065   _stp_map_key_long (pids, current->pid);
    +00066   if (_stp_map_get_int64 (pids))
    +00067     {
    +00068       if (count < 64) 
    +00069         len = count;
    +00070       else 
    +00071         len = 64;
    +00072       len = _stp_strncpy_from_user(str, buf, len);
    +00073       if (len < 0) len = 0;
    +00074       str[len] = 0;
    +00075       dlog ("%d\t%d\t%s\tW %s\n", current->pid, current->parent->pid, current->comm, str);
    +00076     }
    +00077   
    +00078   jprobe_return();
    +00079   return 0;
    +00080 }
    +00081 
    +00082 static struct jprobe dtr_probes[] = {
    +00083   {
    +00084     .kp.addr = (kprobe_opcode_t *)"do_execve",
    +00085     .entry = (kprobe_opcode_t *) inst_do_execve
    +00086   },
    +00087   {
    +00088     .kp.addr = (kprobe_opcode_t *)"filp_open",
    +00089     .entry = (kprobe_opcode_t *) inst_filp_open
    +00090   },
    +00091   {
    +00092     .kp.addr = (kprobe_opcode_t *)"sys_read",
    +00093     .entry = (kprobe_opcode_t *) inst_sys_read
    +00094   },
    +00095   {
    +00096     .kp.addr = (kprobe_opcode_t *)"sys_write",
    +00097     .entry = (kprobe_opcode_t *) inst_sys_write
    +00098   },
    +00099 };
    +00100 
    +00101 #define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe))
    +00102 
    +00103 static int init_dtr(void)
    +00104 {
    +00105   int ret;
    +00106 
    +00107   pids = _stp_map_new (10000, INT64);
    +00108   arglist = _stp_list_new (10, STRING);
    +00109 
    +00110   ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE);
    +00111 
    +00112   dlog("instrumentation is enabled...\n");
    +00113   return ret;
    +00114 }
    +00115 
    +00116 static void cleanup_dtr(void)
    +00117 {
    +00118   _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE);
    +00119   _stp_map_del (pids);
    +00120   dlog("EXIT\n");
    +00121 }
    +00122 
    +00123 module_init(init_dtr);
    +00124 module_exit(cleanup_dtr);
    +00125 MODULE_LICENSE("GPL");
    +00126 
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/stack_8c-source.html b/runtime/docs/html/stack_8c-source.html index 34f7b76e..d6b1e224 100644 --- a/runtime/docs/html/stack_8c-source.html +++ b/runtime/docs/html/stack_8c-source.html @@ -1,12 +1,11 @@ -SystemTap: SystemTap Runtime Library +SystemTap: stack.c Source File - - -

    stack.c

    Go to the documentation of this file.
    00001 
    +
    +

    stack.c

    00001 /* -*- linux-c -*- */
     00002 
     00003 #ifdef __x86_64__
     00004 /* ripped out of arch/x86_64/kernel/traps.c */
    @@ -14,19 +13,19 @@
     00006 
     00007 static int _stp_printk_address(unsigned long address)
     00008 { 
    -00009   unsigned long offset = 0, symsize;
    -00010   const char *symname;
    -00011   char *modname;
    -00012   char *delim = ":"; 
    -00013   char namebuf[128];
    -00014   
    -00015   symname = _stp_kallsyms_lookup(address, &symsize, &offset, &modname, namebuf); 
    -00016   if (!symname) 
    -00017     return printk("[<%016lx>]", address);
    -00018   if (!modname)
    -00019     modname = delim = "";               
    -00020   return printk("<%016lx>{%s%s%s%s%+ld}",
    -00021                 address,delim,modname,delim,symname,offset); 
    +00009         unsigned long offset = 0, symsize;
    +00010         const char *symname;
    +00011         char *modname;
    +00012         char *delim = ":"; 
    +00013         char namebuf[128];
    +00014         
    +00015         symname = _stp_kallsyms_lookup(address, &symsize, &offset, &modname, namebuf); 
    +00016         if (!symname) 
    +00017                 return printk("[<%016lx>]", address);
    +00018         if (!modname)
    +00019                 modname = delim = "";           
    +00020         return printk("<%016lx>{%s%s%s%s%+ld}",
    +00021                       address,delim,modname,delim,symname,offset); 
     00022 }
     00023 
     00024 void _stp_show_trace(unsigned long *stack)
    @@ -114,7 +113,7 @@
     00106                 p < (void *)tinfo + THREAD_SIZE - 3;
     00107 }
     00108 
    -00109 int __kernel_text_address(unsigned long addr)
    +00109 int __kernel_text_address(unsigned long addr)
     00110 {
     00111         if (core_kernel_text(addr))
     00112                 return 1;
    @@ -147,7 +146,7 @@
     00139         return ebp;
     00140 }
     00141 
    -00142 void show_trace(struct task_struct *task, unsigned long * stack)
    +00142 void show_trace(struct task_struct *task, unsigned long * stack)
     00143 {
     00144         unsigned long ebp;
     00145 
    @@ -174,14 +173,12 @@
     00166         }
     00167 }
     00168 
    -00169 void dump_stack(void)
    +00169 void dump_stack(void)
     00170 {
     00171         unsigned long stack;
     00172         show_trace(current, &stack);
     00173 }
     00174 #endif
    -

    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. diff --git a/runtime/docs/html/stp__tasklet_8c-source.html b/runtime/docs/html/stp__tasklet_8c-source.html new file mode 100644 index 00000000..5e9413ae --- /dev/null +++ b/runtime/docs/html/stp__tasklet_8c-source.html @@ -0,0 +1,60 @@ + + +SystemTap: probes/tasklet/stp_tasklet.c Source File + + + + + +

    stp_tasklet.c

    00001 /* Framework for putting a jprobe in a tasklet. */
    +00002 /* Useful for testing probes in interrupt context. */
    +00003 /* Doesn't do anything useful as is.  Put test code in the inst func */
    +00004 
    +00005 #define HASH_TABLE_BITS 8
    +00006 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
    +00007 #define BUCKETS 16 /* largest histogram width */
    +00008 
    +00009 #include "runtime.h"
    +00010 #include "io.c"
    +00011 #include "probes.c"
    +00012 
    +00013 MODULE_DESCRIPTION("test jprobes of tasklets");
    +00014 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
    +00015 
    +00016 void inst__rcu_process_callbacks(struct rcu_ctrlblk *rcp,
    +00017                                  struct rcu_state *rsp, struct rcu_data *rdp)
    +00018 {
    +00019   dlog ("interrupt=%d\n", in_interrupt());
    +00020   jprobe_return();
    +00021 }
    +00022 
    +00023 static struct jprobe stp_probes[] = {
    +00024   {
    +00025     .kp.addr =  (kprobe_opcode_t *)"__rcu_process_callbacks",
    +00026     .entry = (kprobe_opcode_t *) inst__rcu_process_callbacks
    +00027   },
    +00028 };
    +00029 #define MAX_STP_PROBES (sizeof(stp_probes)/sizeof(struct jprobe))
    +00030 
    +00031 
    +00032 static int init_stp(void)
    +00033 {
    +00034   int ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES);
    +00035   dlog("instrumentation is enabled...\n");
    +00036   return ret;
    +00037 }
    +00038 
    +00039 static void cleanup_stp(void)
    +00040 {
    +00041   _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES);
    +00042   dlog ("EXIT\n");
    +00043 }
    +00044 
    +00045 module_init(init_stp);
    +00046 module_exit(cleanup_stp);
    +00047 MODULE_LICENSE("GPL");
    +00048 
    +

    +Generated on Tue Mar 22 00:32:02 2005 for SystemTap. + diff --git a/runtime/docs/html/structmap__node.html b/runtime/docs/html/structmap__node.html index 1d8a69ea..9902b165 100644 --- a/runtime/docs/html/structmap__node.html +++ b/runtime/docs/html/structmap__node.html @@ -1,192 +1,44 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map_node Struct Reference - - -

    map_node Struct Reference

    #include <map.h> + +

    map_node Struct Reference

    all map nodes have the following structure +More... +

    +#include <map.h>

    - - - - - - - + - + - + -

    Data Fields

    list_head lnode
    hlist_node hnode
    key_data key1
    key_data key2
    +list_head lnode
    enum keytype key1type
    +hlist_node hnode
    enum keytype key2type
    +key_data key1
    -


    Field Documentation

    -

    - - - - -
    - - - - -
    struct hlist_node map_node::hnode
    -
    - - - - -

    - -

    -Definition at line 22 of file map.h. -

    -Referenced by _stp_list_clear(), _stp_map_key_del(), _stp_map_set_stat(), and _stp_map_set_str(). - -

    -   - +
    +key_data key2
    -

    - - - - -
    - - - - -
    union key_data map_node::key1
    -
    - - - - -

    +

    -

    -Definition at line 23 of file map.h. -

    -Referenced by _stp_map_key_long_long(), _stp_map_key_long_str(), _stp_map_key_str_long(), and _stp_map_key_str_str(). - -

    -   - +
    +enum keytype key1type
    +enum keytype key2type
    -

    - - - -
    - - - - -
    enum keytype map_node::key1type
    -
    - - - - - -
    -   - - +

    Detailed Description

    +all map nodes have the following structure

    -Definition at line 25 of file map.h.

    -

    - - - - -
    - - - - -
    union key_data map_node::key2
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 24 of file map.h. -

    -Referenced by _stp_map_key_long_str(), _stp_map_key_str_long(), and _stp_map_key_str_str().

    -

    - - - - -
    - - - - -
    enum keytype map_node::key2type
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 26 of file map.h.

    -

    - - - - -
    - - - - -
    struct list_head map_node::lnode
    -
    - - - - - -
    -   - - -

    - -

    -Definition at line 21 of file map.h. -

    -Referenced by _stp_list_clear(), _stp_map_del(), _stp_map_iter(), _stp_map_key_del(), _stp_map_set_stat(), and _stp_map_set_str().

    -


    The documentation for this struct was generated from the following file: