From e32551b18f4560056d2d482f5e1505b1b98fa82a Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 29 Mar 2005 18:07:58 +0000 Subject: *** empty log message *** --- runtime/docs/html/README-source.html | 13 +- runtime/docs/html/alloc_8c-source.html | 101 ++ runtime/docs/html/alloc_8c.html | 45 + runtime/docs/html/alloc_8h-source.html | 6 +- runtime/docs/html/alloc_8h.html | 16 +- runtime/docs/html/annotated.html | 6 +- runtime/docs/html/bug.html | 14 +- runtime/docs/html/copy_8c-source.html | 301 ++-- runtime/docs/html/copy_8c.html | 194 +-- runtime/docs/html/current_8c-source.html | 42 + runtime/docs/html/current_8c.html | 24 + runtime/docs/html/dir_000000.html | 6 +- runtime/docs/html/dir_000001.html | 8 +- runtime/docs/html/dir_000002.html | 6 +- runtime/docs/html/dir_000003.html | 8 +- runtime/docs/html/dir_000004.html | 8 +- runtime/docs/html/dirs.html | 6 +- runtime/docs/html/dtr_8mod_8c-source.html | 55 +- runtime/docs/html/files.html | 16 +- runtime/docs/html/functions.html | 6 +- runtime/docs/html/functions_vars.html | 6 +- runtime/docs/html/globals.html | 114 +- runtime/docs/html/globals_defs.html | 24 +- runtime/docs/html/globals_enum.html | 10 +- runtime/docs/html/globals_func.html | 85 +- runtime/docs/html/globals_type.html | 8 +- runtime/docs/html/globals_vars.html | 13 +- runtime/docs/html/group__alloc.html | 247 +++ runtime/docs/html/group__copy.html | 202 +++ runtime/docs/html/group__current.html | 59 + runtime/docs/html/group__io.html | 170 ++ runtime/docs/html/group__list.html | 58 + runtime/docs/html/group__lists.html | 323 ++++ runtime/docs/html/group__maps.html | 1265 +++++++++++++++ runtime/docs/html/group__scbuf.html | 122 ++ runtime/docs/html/group__stack.html | 18 + runtime/docs/html/group__sym.html | 104 ++ runtime/docs/html/index.html | 12 +- runtime/docs/html/io_8c-source.html | 195 +-- runtime/docs/html/io_8c.html | 298 +--- .../docs/html/kprobe__where__funct_8c-source.html | 130 +- runtime/docs/html/map_8c-source.html | 1711 ++++++++++---------- runtime/docs/html/map_8c.html | 1313 +-------------- runtime/docs/html/map_8h-source.html | 350 ++-- runtime/docs/html/map_8h.html | 284 +--- runtime/docs/html/modules.html | 19 + runtime/docs/html/pages.html | 6 +- runtime/docs/html/probes_2README-source.html | 6 +- .../html/probes_2shellsnoop_2README-source.html | 10 +- .../docs/html/probes_2tasklet_2README-source.html | 6 +- .../docs/html/probes_2test4_2README-source.html | 6 +- .../html/probes_2where__func_2README-source.html | 6 +- runtime/docs/html/probes_8c-source.html | 28 +- runtime/docs/html/probes_8c.html | 48 +- runtime/docs/html/runtime_8h-source.html | 51 +- runtime/docs/html/runtime_8h.html | 52 +- runtime/docs/html/scbuf_8c-source.html | 79 + runtime/docs/html/shellsnoop_2dtr_8c-source.html | 40 +- runtime/docs/html/stack_8c-source.html | 341 ++-- runtime/docs/html/stack_8c.html | 123 +- runtime/docs/html/stp__tasklet_8c-source.html | 14 +- runtime/docs/html/structmap__node.html | 17 +- runtime/docs/html/structmap__node__int64.html | 13 +- runtime/docs/html/structmap__node__stat.html | 13 +- runtime/docs/html/structmap__node__str.html | 13 +- runtime/docs/html/structmap__root.html | 35 +- runtime/docs/html/structstat.html | 13 +- runtime/docs/html/sym_8c-source.html | 73 + runtime/docs/html/test4_2dtr_8c-source.html | 245 +-- runtime/docs/html/todo.html | 37 +- runtime/docs/html/unionkey__data.html | 13 +- 71 files changed, 5074 insertions(+), 4235 deletions(-) create mode 100644 runtime/docs/html/alloc_8c-source.html create mode 100644 runtime/docs/html/alloc_8c.html create mode 100644 runtime/docs/html/current_8c-source.html create mode 100644 runtime/docs/html/current_8c.html create mode 100644 runtime/docs/html/group__alloc.html create mode 100644 runtime/docs/html/group__copy.html create mode 100644 runtime/docs/html/group__current.html create mode 100644 runtime/docs/html/group__io.html create mode 100644 runtime/docs/html/group__list.html create mode 100644 runtime/docs/html/group__lists.html create mode 100644 runtime/docs/html/group__maps.html create mode 100644 runtime/docs/html/group__scbuf.html create mode 100644 runtime/docs/html/group__stack.html create mode 100644 runtime/docs/html/group__sym.html create mode 100644 runtime/docs/html/modules.html create mode 100644 runtime/docs/html/scbuf_8c-source.html create mode 100644 runtime/docs/html/sym_8c-source.html (limited to 'runtime/docs/html') diff --git a/runtime/docs/html/README-source.html b/runtime/docs/html/README-source.html index e3a311ea..1b03993d 100644 --- a/runtime/docs/html/README-source.html +++ b/runtime/docs/html/README-source.html @@ -4,7 +4,7 @@ -
Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages
+
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

README

00001 /** @mainpage SystemTap Runtime Library
 00002  *
 00003  * @section intro_sec Introduction
@@ -39,7 +39,7 @@
 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
+00035  * a list does not require setting a key first. Create a list with _stp_list_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
@@ -57,7 +57,8 @@
 00050  * 
 00051  * @section todo_sec ToDo 
 00052  * \link todo Click Here for Complete List \endlink
-00053  */
-

-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +00053 * +00054 * @section links Links +00055 * <a href="http://sources.redhat.com/systemtap/">SystemTap Project Page</a> +00056 */ + diff --git a/runtime/docs/html/alloc_8c-source.html b/runtime/docs/html/alloc_8c-source.html new file mode 100644 index 00000000..34641788 --- /dev/null +++ b/runtime/docs/html/alloc_8c-source.html @@ -0,0 +1,101 @@ + + +SystemTap: alloc.c Source File + + + + +

alloc.c

Go to the documentation of this file.
00001 #ifndef _ALLOC_C_
+00002 #define _ALLOC_C_
+00003 
+00004 /* -*- linux-c -*- */
+00005 /** @file alloc.c
+00006  * @brief Memory functions.
+00007  */
+00008 /** @addtogroup alloc Memory Functions
+00009  * Basic malloc/calloc/free functions. These will be changed so 
+00010  * that memory allocation errors will call a handler.  The default will
+00011  * send a signal to the user-space daemon that will trigger the module to
+00012  * be unloaded.
+00013  * @todo Need error handling for memory allocations
+00014  * @todo Some of these currently use kmalloc (GFP_ATOMIC) for
+00015  * small allocations.  This should be evaluated for performance
+00016  * and stability.
+00017  * @{
+00018  */
+00019 
+00020 enum errorcode { ERR_NONE=0, ERR_NO_MEM };
+00021 enum errorcode _stp_error = ERR_NONE;
+00022 
+00023 /** Allocates memory within a probe.
+00024  * This is used for small allocations from within a running
+00025  * probe where the process cannot sleep. 
+00026  * @param len Number of bytes to allocate.
+00027  * @return a valid pointer on success or NULL on failure.
+00028  * @bug Currently uses kmalloc (GFP_ATOMIC).
+00029  */
+00030 
+00031 void *_stp_alloc(size_t len)
+00032 {
+00033         void *ptr = kmalloc(len, GFP_ATOMIC);
+00034         if (unlikely(ptr == NULL))
+00035                 _stp_error = ERR_NO_MEM;
+00036         return ptr;
+00037 }
+00038 
+00039 /** Allocates and clears memory within a probe.
+00040  * This is used for small allocations from within a running
+00041  * probe where the process cannot sleep. 
+00042  * @param len Number of bytes to allocate.
+00043  * @return a valid pointer on success or NULL on failure.
+00044  * @bug Currently uses kmalloc (GFP_ATOMIC).
+00045  */
+00046 
+00047 void *_stp_calloc(size_t len)
+00048 {
+00049         void *ptr = _stp_alloc(len);
+00050         if (likely(ptr))
+00051                 memset(ptr, 0, len);
+00052         return ptr;
+00053 }
+00054 
+00055 /** Allocates and clears memory outside a probe.
+00056  * This is typically used in the module initialization to
+00057  * allocate new maps, lists, etc.
+00058  * @param len Number of bytes to allocate.
+00059  * @return a valid pointer on success or NULL on failure.
+00060  */
+00061 
+00062 void *_stp_valloc(size_t len)
+00063 {
+00064         void *ptr = vmalloc(len);
+00065         if (likely(ptr))
+00066                 memset(ptr, 0, len);
+00067         else
+00068                 _stp_error = ERR_NO_MEM;
+00069         return ptr;
+00070 }
+00071 
+00072 /** Frees memory allocated by _stp_alloc or _stp_calloc.
+00073  * @param ptr pointer to memory to free
+00074  */
+00075 
+00076 void _stp_free(void *ptr)
+00077 {
+00078         if (likely(ptr))
+00079                 kfree(ptr);
+00080 }
+00081 
+00082 /** Frees memory allocated by _stp_valloc.
+00083  * @param ptr pointer to memory to free
+00084  */
+00085 
+00086 void _stp_vfree(void *ptr)
+00087 {
+00088         if (likely(ptr))
+00089                 vfree(ptr);
+00090 }
+00091 
+00092 /** @} */
+00093 #endif /* _ALLOC_C_ */
+
diff --git a/runtime/docs/html/alloc_8c.html b/runtime/docs/html/alloc_8c.html new file mode 100644 index 00000000..358cb6a8 --- /dev/null +++ b/runtime/docs/html/alloc_8c.html @@ -0,0 +1,45 @@ + + +SystemTap: alloc.c File Reference + + + + +

alloc.c File Reference

Memory functions. More... +

+ +

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

Enumerations

enum  errorcode { ERR_NONE = 0, +ERR_NO_MEM + }

Functions

void * _stp_alloc (size_t len)
 Allocates memory within a probe.
void * _stp_calloc (size_t len)
 Allocates and clears memory within a probe.
void * _stp_valloc (size_t len)
 Allocates and clears memory outside a probe.
void _stp_free (void *ptr)
 Frees memory allocated by _stp_alloc or _stp_calloc.
void _stp_vfree (void *ptr)
 Frees memory allocated by _stp_valloc.

Variables

+enum errorcode _stp_error = ERR_NONE
+


Detailed Description

+Memory functions. +

+ +

+Definition in file alloc.c. diff --git a/runtime/docs/html/alloc_8h-source.html b/runtime/docs/html/alloc_8h-source.html index e68fbb86..551deccd 100644 --- a/runtime/docs/html/alloc_8h-source.html +++ b/runtime/docs/html/alloc_8h-source.html @@ -4,7 +4,7 @@ -

+

alloc.h

Go to the documentation of this file.
00001 /* -*- linux-c -*- */
 00002 /** @file alloc.h
 00003  * @brief Memory allocation functions.
@@ -82,6 +82,4 @@
 00075         if (likely(ptr))
 00076                 vfree(ptr);
 00077 }
-

-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/alloc_8h.html b/runtime/docs/html/alloc_8h.html index 385d8e1a..c8735838 100644 --- a/runtime/docs/html/alloc_8h.html +++ b/runtime/docs/html/alloc_8h.html @@ -4,7 +4,7 @@ - +

alloc.h File Reference

Memory allocation functions. More...

@@ -82,7 +82,7 @@ This is used for small allocations from within a running probe where the process

Definition at line 18 of file alloc.h.

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

@@ -125,7 +125,7 @@ Definition at line 34 of fi

References _stp_alloc().

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

@@ -164,7 +164,7 @@ Frees memory allocated by _stp_alloc or _stp_calloc.

Definition at line 63 of file alloc.h.

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

@@ -204,7 +204,7 @@ This is typically used in the module initialization to allocate new maps, lists,

Definition at line 49 of file alloc.h.

-Referenced by _stp_map_new(). +Referenced by _stp_map_new().

@@ -243,9 +243,7 @@ Frees memory allocated by _stp_valloc.

Definition at line 73 of file alloc.h.

-Referenced by _stp_map_del(). +Referenced by _stp_map_del(). -


-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/annotated.html b/runtime/docs/html/annotated.html index 49994e1a..4359c217 100644 --- a/runtime/docs/html/annotated.html +++ b/runtime/docs/html/annotated.html @@ -4,7 +4,7 @@ - +

SystemTap Data Structures

Here are the data structures with brief descriptions: @@ -14,6 +14,4 @@
key_dataKeys are either longs or char *
map_nodeBasic map element
map_rootThis structure contains all information about a map
statStatistics are stored in this struct
-
-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/bug.html b/runtime/docs/html/bug.html index 6c73243e..4ed1d36b 100644 --- a/runtime/docs/html/bug.html +++ b/runtime/docs/html/bug.html @@ -4,21 +4,19 @@ - +

Bug List

-
Global _stp_alloc (size_t len)
+
Global _stp_alloc (size_t len)
Currently uses kmalloc (GFP_ATOMIC).

-
Global _stp_calloc (size_t len)
+
Global _stp_calloc (size_t len)
Currently uses kmalloc (GFP_ATOMIC).

-
Global dlog (const char *fmt,...)
-
Lines are limited in length by printk buffer.
+
Global dlog (const char *fmt,...)
+
Lines are limited in length by printk buffer. If there is no newline in the format string, then other syslog output could get appended to the SystemTap line.
-
-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/copy_8c-source.html b/runtime/docs/html/copy_8c-source.html index 3456380c..1d4f8652 100644 --- a/runtime/docs/html/copy_8c-source.html +++ b/runtime/docs/html/copy_8c-source.html @@ -4,148 +4,159 @@ - -

copy.c

Go to the documentation of this file.
00001 /* -*- linux-c -*- */
-00002 /** @file copy.c
-00003  * @brief Functions to copy from user space.
-00004  */
-00005 
-00006 long _stp_strncpy_from_user(char *dst, const char __user *src, long count);
-00007 //static long __stp_strncpy_from_user(char *dst, const char __user *src, long count);
-00008 
-00009 #if defined (__i386__)
-00010 #define __stp_strncpy_from_user(dst,src,count,res)                         \
-00011 do {                                                                       \
-00012         int __d0, __d1, __d2;                                              \
-00013         __asm__ __volatile__(                                              \
-00014                 "       testl %1,%1\n"                                     \
-00015                 "       jz 2f\n"                                           \
-00016                 "0:     lodsb\n"                                           \
-00017                 "       stosb\n"                                           \
-00018                 "       testb %%al,%%al\n"                                 \
-00019                 "       jz 1f\n"                                           \
-00020                 "       decl %1\n"                                         \
-00021                 "       jnz 0b\n"                                          \
-00022                 "1:     subl %1,%0\n"                                      \
-00023                 "2:\n"                                                     \
-00024                 ".section .fixup,\"ax\"\n"                                 \
-00025                 "3:     movl %5,%0\n"                                      \
-00026                 "       jmp 2b\n"                                          \
-00027                 ".previous\n"                                              \
-00028                 ".section __ex_table,\"a\"\n"                              \
-00029                 "       .align 4\n"                                        \
-00030                 "       .long 0b,3b\n"                                     \
-00031                 ".previous"                                                \
-00032                 : "=d"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1),      \
-00033                   "=&D" (__d2)                                             \
-00034                 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
-00035                 : "memory");                                               \
-00036 } while (0)
-00037 #elif defined (__x86_64__)
-00038 #define __stp_strncpy_from_user(dst,src,count,res)                         \
-00039 do {                                                                       \
-00040         long __d0, __d1, __d2;                                             \
-00041         __asm__ __volatile__(                                              \
-00042                 "       testq %1,%1\n"                                     \
-00043                 "       jz 2f\n"                                           \
-00044                 "0:     lodsb\n"                                           \
-00045                 "       stosb\n"                                           \
-00046                 "       testb %%al,%%al\n"                                 \
-00047                 "       jz 1f\n"                                           \
-00048                 "       decq %1\n"                                         \
-00049                 "       jnz 0b\n"                                          \
-00050                 "1:     subq %1,%0\n"                                      \
-00051                 "2:\n"                                                     \
-00052                 ".section .fixup,\"ax\"\n"                                 \
-00053                 "3:     movq %5,%0\n"                                      \
-00054                 "       jmp 2b\n"                                          \
-00055                 ".previous\n"                                              \
-00056                 ".section __ex_table,\"a\"\n"                              \
-00057                 "       .align 8\n"                                        \
-00058                 "       .quad 0b,3b\n"                                     \
-00059                 ".previous"                                                \
-00060                 : "=r"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1),      \
-00061                   "=&D" (__d2)                                             \
-00062                 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
-00063                 : "memory");                                               \
-00064 } while (0)
-00065 #endif
-00066 
-00067 /** Copy a NULL-terminated string from userspace.
-00068  * On success, returns the length of the string (not including the trailing
-00069  * NULL).
-00070  *
-00071  * If access to userspace fails, returns -EFAULT (some data may have been
-00072  * copied).
-00073  * @param dst Destination address, in kernel space.  This buffer must be at
-00074  *         least <i>count</i> bytes long.
-00075  * @param src Source address, in user space.
-00076  * @param count Maximum number of bytes to copy, including the trailing NULL.
-00077  * 
-00078  * If <i>count</i> is smaller than the length of the string, copies 
-00079  * <i>count</i> bytes and returns <i>count</i>.
-00080  */
-00081 
-00082 long
-00083 _stp_strncpy_from_user(char *dst, const char __user *src, long count)
-00084 {
-00085         long res;
-00086         __stp_strncpy_from_user(dst, src, count, res);
-00087         return res;
-00088 }
-00089 
-00090 /** Copy a block of data from user space.
-00091  *
-00092  * If some data could not be copied, this function will pad the copied
-00093  * data to the requested size using zero bytes.
-00094 
-00095  * @param dst Destination address, in kernel space.
-00096  * @param src Source address, in user space.
-00097  * @param count Number of bytes to copy.
-00098  * @return number of bytes that could not be copied. On success, 
-00099  * this will be zero.
-00100  *
-00101  */
-00102 
-00103 unsigned long inline
-00104 _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
-00105 {
-00106         return __copy_from_user_inatomic(dst, src, count);
-00107 }
-00108 
-00109 /** Copy an argv from user space to a List.
-00110  *
-00111  * @param list A list.
-00112  * @param argv Source argv, in user space.
-00113  * @return number of elements in <i>list</i>
-00114  *
-00115  * @b Example:
-00116  * @include argv.c
-00117  */
-00118 
-00119 int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
-00120 {
-00121         char str[128];
-00122         char __user *vstr;
-00123         int len;
-00124 
-00125         if (argv)
-00126                 argv++;
-00127 
-00128         while (argv != NULL) {
-00129                 if (get_user (vstr, argv))
-00130                         break;
-00131                 
-00132                 if (vstr == NULL)
-00133                         break;
-00134                 
-00135                 len = _stp_strncpy_from_user(str, vstr, 128);
-00136                 str[len] = 0;
-00137                 _stp_list_add_str (list, str);
-00138                 argv++;
-00139         }
-00140         return list->num;
-00141 }
-

-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + +

copy.c

Go to the documentation of this file.
00001 #ifndef _COPY_C_
+00002 #define _COPY_C_
+00003 
+00004 /* -*- linux-c -*- */
+00005 /** @file copy.c
+00006  * @brief Functions to copy from user space.
+00007  */
+00008 
+00009 /** @addtogroup copy Functions to copy from user space.
+00010  * Functions to copy from user space.
+00011  * None of these functions will sleep (for example to allow pages
+00012  * to be swapped in). It is possible (although rare) that the data
+00013  * in user space will not present and these functions will return an error.
+00014  * @{
+00015  */
+00016 
+00017 long _stp_strncpy_from_user(char *dst, const char __user *src, long count);
+00018 //static long __stp_strncpy_from_user(char *dst, const char __user *src, long count);
+00019 
+00020 #if defined (__i386__)
+00021 #define __stp_strncpy_from_user(dst,src,count,res)                         \
+00022 do {                                                                       \
+00023         int __d0, __d1, __d2;                                              \
+00024         __asm__ __volatile__(                                              \
+00025                 "       testl %1,%1\n"                                     \
+00026                 "       jz 2f\n"                                           \
+00027                 "0:     lodsb\n"                                           \
+00028                 "       stosb\n"                                           \
+00029                 "       testb %%al,%%al\n"                                 \
+00030                 "       jz 1f\n"                                           \
+00031                 "       decl %1\n"                                         \
+00032                 "       jnz 0b\n"                                          \
+00033                 "1:     subl %1,%0\n"                                      \
+00034                 "2:\n"                                                     \
+00035                 ".section .fixup,\"ax\"\n"                                 \
+00036                 "3:     movl %5,%0\n"                                      \
+00037                 "       jmp 2b\n"                                          \
+00038                 ".previous\n"                                              \
+00039                 ".section __ex_table,\"a\"\n"                              \
+00040                 "       .align 4\n"                                        \
+00041                 "       .long 0b,3b\n"                                     \
+00042                 ".previous"                                                \
+00043                 : "=d"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1),      \
+00044                   "=&D" (__d2)                                             \
+00045                 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
+00046                 : "memory");                                               \
+00047 } while (0)
+00048 #elif defined (__x86_64__)
+00049 #define __stp_strncpy_from_user(dst,src,count,res)                         \
+00050 do {                                                                       \
+00051         long __d0, __d1, __d2;                                             \
+00052         __asm__ __volatile__(                                              \
+00053                 "       testq %1,%1\n"                                     \
+00054                 "       jz 2f\n"                                           \
+00055                 "0:     lodsb\n"                                           \
+00056                 "       stosb\n"                                           \
+00057                 "       testb %%al,%%al\n"                                 \
+00058                 "       jz 1f\n"                                           \
+00059                 "       decq %1\n"                                         \
+00060                 "       jnz 0b\n"                                          \
+00061                 "1:     subq %1,%0\n"                                      \
+00062                 "2:\n"                                                     \
+00063                 ".section .fixup,\"ax\"\n"                                 \
+00064                 "3:     movq %5,%0\n"                                      \
+00065                 "       jmp 2b\n"                                          \
+00066                 ".previous\n"                                              \
+00067                 ".section __ex_table,\"a\"\n"                              \
+00068                 "       .align 8\n"                                        \
+00069                 "       .quad 0b,3b\n"                                     \
+00070                 ".previous"                                                \
+00071                 : "=r"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1),      \
+00072                   "=&D" (__d2)                                             \
+00073                 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
+00074                 : "memory");                                               \
+00075 } while (0)
+00076 #endif
+00077 
+00078 /** Copy a NULL-terminated string from userspace.
+00079  * On success, returns the length of the string (not including the trailing
+00080  * NULL).
+00081  *
+00082  * If access to userspace fails, returns -EFAULT (some data may have been
+00083  * copied).
+00084  * @param dst Destination address, in kernel space.  This buffer must be at
+00085  *         least <i>count</i> bytes long.
+00086  * @param src Source address, in user space.
+00087  * @param count Maximum number of bytes to copy, including the trailing NULL.
+00088  * 
+00089  * If <i>count</i> is smaller than the length of the string, copies 
+00090  * <i>count</i> bytes and returns <i>count</i>.
+00091  */
+00092 
+00093 long
+00094 _stp_strncpy_from_user(char *dst, const char __user *src, long count)
+00095 {
+00096         long res;
+00097         __stp_strncpy_from_user(dst, src, count, res);
+00098         return res;
+00099 }
+00100 
+00101 /** Copy a block of data from user space.
+00102  *
+00103  * If some data could not be copied, this function will pad the copied
+00104  * data to the requested size using zero bytes.
+00105 
+00106  * @param dst Destination address, in kernel space.
+00107  * @param src Source address, in user space.
+00108  * @param count Number of bytes to copy.
+00109  * @return number of bytes that could not be copied. On success, 
+00110  * this will be zero.
+00111  *
+00112  */
+00113 
+00114 unsigned long inline
+00115 _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
+00116 {
+00117         return __copy_from_user_inatomic(dst, src, count);
+00118 }
+00119 
+00120 /** Copy an argv from user space to a List.
+00121  *
+00122  * @param list A list.
+00123  * @param argv Source argv, in user space.
+00124  * @return number of elements in <i>list</i>
+00125  *
+00126  * @b Example:
+00127  * @include argv.c
+00128  */
+00129 
+00130 int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
+00131 {
+00132         char str[128];
+00133         char __user *vstr;
+00134         int len;
+00135 
+00136         if (argv)
+00137                 argv++;
+00138 
+00139         while (argv != NULL) {
+00140                 if (get_user (vstr, argv))
+00141                         break;
+00142                 
+00143                 if (vstr == NULL)
+00144                         break;
+00145                 
+00146                 len = _stp_strncpy_from_user(str, vstr, 128);
+00147                 str[len] = 0;
+00148                 _stp_list_add_str (list, str);
+00149                 argv++;
+00150         }
+00151         return list->num;
+00152 }
+00153 /** @} */
+00154 #endif /* _COPY_C_ */
+
diff --git a/runtime/docs/html/copy_8c.html b/runtime/docs/html/copy_8c.html index d4e3ba26..6877dc73 100644 --- a/runtime/docs/html/copy_8c.html +++ b/runtime/docs/html/copy_8c.html @@ -4,7 +4,7 @@ - +

copy.c File Reference

Functions to copy from user space. More...

@@ -12,197 +12,19 @@ Go to the source code of this file. - + - - + + - - + + - +

Functions

long _stp_strncpy_from_user (char *dst, const char __user *src, long count)
long _stp_strncpy_from_user (char *dst, const char __user *src, long count)
 Copy a NULL-terminated string from userspace.
unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
 Copy a NULL-terminated string from userspace.
unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
 Copy a block of data from user space.
int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
 Copy a block of data from user space.
int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
 Copy an argv from user space to a List.
 Copy an argv from user space to a List.


Detailed Description

Functions to copy from user space.

-Definition in file copy.c.


Function Documentation

-

- - - - -
- - - - - - - - - - - - - - - - - - -
int _stp_copy_argv_from_user MAP  list,
char __user *__user *  argv
-
- - - - - -
-   - - -

-Copy an argv from user space to a List. -

-

Parameters:
- - - -
list A list.
argv Source argv, in user space.
-
-
Returns:
number of elements in list
-Example:
MAP arglist ;
-
-int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs)
-{
-  struct map_node_str *ptr;
-
-  _stp_copy_argv_from_user (arglist, argv);
-
-  foreach (arglist, ptr)
-    printk ("%s ", ptr->str);
-  printk ("\n");
-}
-
-

-Definition at line 119 of file copy.c. -

-References _stp_list_add_str(), _stp_strncpy_from_user(), and map_root::num.

-

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
unsigned long _stp_copy_from_user char *  dst,
const char __user *  src,
unsigned long  count
[inline]
-
- - - - - -
-   - - -

-Copy a block of data from user space. -

-If some data could not be copied, this function will pad the copied data to the requested size using zero bytes.

-

Parameters:
- - - - -
dst Destination address, in kernel space.
src Source address, in user space.
count Number of bytes to copy.
-
-
Returns:
number of bytes that could not be copied. On success, this will be zero.
- -

-Definition at line 104 of file copy.c.

-

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
long _stp_strncpy_from_user char *  dst,
const char __user *  src,
long  count
-
- - - - - -
-   - - -

-Copy a NULL-terminated string from userspace. -

-On success, returns the length of the string (not including the trailing NULL).

-If access to userspace fails, returns -EFAULT (some data may have been copied).

Parameters:
- - - - -
dst Destination address, in kernel space. This buffer must be at least count bytes long.
src Source address, in user space.
count Maximum number of bytes to copy, including the trailing NULL.
-
-If count is smaller than the length of the string, copies count bytes and returns count. -

-Definition at line 83 of file copy.c. -

-Referenced by _stp_copy_argv_from_user().

-


-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +Definition in file copy.c. diff --git a/runtime/docs/html/current_8c-source.html b/runtime/docs/html/current_8c-source.html new file mode 100644 index 00000000..88ad571a --- /dev/null +++ b/runtime/docs/html/current_8c-source.html @@ -0,0 +1,42 @@ + + +SystemTap: current.c Source File + + + + +

current.c

Go to the documentation of this file.
00001 #ifndef _CURRENT_C_
+00002 #define _CURRENT_C_
+00003 
+00004 /* -*- linux-c -*- */
+00005 /** @file current.c
+00006  * @brief Functions to get the current state.
+00007  */
+00008 /** @addtogroup current Current State
+00009  * Functions to get the current state.
+00010  * @{
+00011  */
+00012 
+00013 
+00014 /** Get the current return address.
+00015  * Call from kprobes (not jprobes).
+00016  * @param regs The pt_regs saved by the kprobe.
+00017  * @return The return address saved in esp or rsp.
+00018  * @note i386 and x86_64 only so far.
+00019  */
+00020  
+00021 unsigned long _stp_ret_addr (struct pt_regs *regs)
+00022 {
+00023 #ifdef __x86_64__
+00024   unsigned long *ra = (unsigned long *)regs->rsp;
+00025 #else
+00026   unsigned long *ra = (unsigned long *)regs->esp;
+00027 #endif
+00028   if (ra)
+00029     return *ra;
+00030   else
+00031     return 0;
+00032 }
+00033 /** @} */
+00034 #endif /* _CURRENT_C_ */
+
diff --git a/runtime/docs/html/current_8c.html b/runtime/docs/html/current_8c.html new file mode 100644 index 00000000..bfb2b727 --- /dev/null +++ b/runtime/docs/html/current_8c.html @@ -0,0 +1,24 @@ + + +SystemTap: current.c File Reference + + + + +

current.c File Reference

Functions to get the current state. More... +

+ +

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

Functions

unsigned long _stp_ret_addr (struct pt_regs *regs)
 Get the current return address.
+


Detailed Description

+Functions to get the current state. +

+ +

+Definition in file current.c. diff --git a/runtime/docs/html/dir_000000.html b/runtime/docs/html/dir_000000.html index f791914d..acfc2d57 100644 --- a/runtime/docs/html/dir_000000.html +++ b/runtime/docs/html/dir_000000.html @@ -4,7 +4,7 @@ -

+

probes Directory Reference

This directory contains working example probes that demonstrate and test the runtime library. @@ -38,6 +38,4 @@

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 10:27:36 2005 for SystemTap. - +They are tested on i386 and x86_64. diff --git a/runtime/docs/html/dir_000001.html b/runtime/docs/html/dir_000001.html index 37f053ab..e9fac182 100644 --- a/runtime/docs/html/dir_000001.html +++ b/runtime/docs/html/dir_000001.html @@ -4,7 +4,7 @@ - +

shellsnoop Directory Reference

Snoops on what commands are being run by shells. @@ -19,7 +19,7 @@

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().

+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.
@@ -84,6 +84,4 @@ probe sys_write:entry {
         }
     }
 }
-

-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/dir_000002.html b/runtime/docs/html/dir_000002.html index a22bfaa4..0a007775 100644 --- a/runtime/docs/html/dir_000002.html +++ b/runtime/docs/html/dir_000002.html @@ -4,7 +4,7 @@ - +

tasklet Directory Reference

Sample probe in a tasklet. @@ -24,6 +24,4 @@ Useful for interrupt context testing.

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


-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/dir_000003.html b/runtime/docs/html/dir_000003.html index 002ee608..173623b3 100644 --- a/runtime/docs/html/dir_000003.html +++ b/runtime/docs/html/dir_000003.html @@ -4,7 +4,7 @@ - +

test4 Directory Reference

This example probe tracks file opens, reads and writes. @@ -13,6 +13,8 @@

Files

file  dtr.c [code] +file  nrec.c [code] + file  README [code] @@ -37,6 +39,4 @@ probe sys_read:entry { probe sys_write:entry { @writes[current->comm] << count; } -
-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/dir_000004.html b/runtime/docs/html/dir_000004.html index de4c82b6..f2294de2 100644 --- a/runtime/docs/html/dir_000004.html +++ b/runtime/docs/html/dir_000004.html @@ -4,7 +4,7 @@ - +

where_func Directory Reference

This is a silly little instrumentation routine to instrument functions entry by name. @@ -20,11 +20,9 @@ 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.

+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 10:27:36 2005 for SystemTap. - + -Will Cohen diff --git a/runtime/docs/html/dirs.html b/runtime/docs/html/dirs.html index fdf2f363..36214b8b 100644 --- a/runtime/docs/html/dirs.html +++ b/runtime/docs/html/dirs.html @@ -4,7 +4,7 @@ - +

SystemTap Directories

This directory hierarchy is sorted roughly, but not completely, alphabetically: -
-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/dtr_8mod_8c-source.html b/runtime/docs/html/dtr_8mod_8c-source.html index 38f5967a..1deec9c6 100644 --- a/runtime/docs/html/dtr_8mod_8c-source.html +++ b/runtime/docs/html/dtr_8mod_8c-source.html @@ -1,12 +1,12 @@ -SystemTap: probes/shellsnoop/dtr.mod.c Source File +SystemTap: probes/test4/dtr.mod.c Source File - - + + +probes / test4

dtr.mod.c

00001 #include <linux/module.h>
 00002 #include <linux/vermagic.h>
 00003 #include <linux/compiler.h>
@@ -27,33 +27,30 @@
 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" },
+00021         { 0xb240ca65, "schedule_work" },
+00022         { 0x1b9aca3f, "jprobe_return" },
+00023         { 0xe3b0192b, "vscnprintf" },
+00024         { 0x45e5f47f, "register_kprobe" },
+00025         { 0x1e736243, "unregister_kprobe" },
+00026         { 0xdd03a51e, "register_jprobe" },
+00027         { 0x49a83d3a, "unregister_jprobe" },
 00028         { 0x3fa03a97, "memset" },
 00029         { 0xc16fe12d, "__memcpy" },
 00030         { 0xe914e41e, "strcpy" },
 00031         { 0xe2d5255a, "strcmp" },
-00032         { 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=";
+00032         { 0x2fd1d81c, "vfree" },
+00033         { 0x37a0cba, "kfree" },
+00034         { 0xd6ee688f, "vmalloc" },
+00035         { 0x8ce16b3f, "__kmalloc" },
+00036         { 0x8e3c9cc3, "vprintk" },
+00037         { 0xdd132261, "printk" },
+00038 };
+00039 
+00040 static const char __module_depends[]
+00041 __attribute_used__
+00042 __attribute__((section(".modinfo"))) =
+00043 "depends=";
+00044 
 00045 
-00046 
-00047 MODULE_INFO(srcversion, "D6A3BE8A54CB181A59924B3");
-

-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. - +00046 MODULE_INFO(srcversion, "3CC4F9300C5C4E353BD2804"); + diff --git a/runtime/docs/html/files.html b/runtime/docs/html/files.html index ec707721..ef853864 100644 --- a/runtime/docs/html/files.html +++ b/runtime/docs/html/files.html @@ -4,27 +4,29 @@ - +

SystemTap File List

Here is a list of all documented files with brief descriptions: - + + - - + + + + +
alloc.h [code]Memory allocation functions
alloc.c [code]Memory functions
copy.c [code]Functions to copy from user space
current.c [code]Functions to get the current state
io.c [code]I/O functions
map.c [code]Implements maps (associative arrays) and lists
map.h [code]Header file for maps and lists
probes.c [code]Functions to assist loading and unloading groups of probes
README [code]
runtime.h [code]
stack.c [code]
runtime.h [code]Main include file for runtime functions
scbuf.c [code]
stack.c [code]Stack Tracing Functions
sym.c [code]
probes/README [code]
probes/shellsnoop/dtr.c [code]
probes/shellsnoop/README [code]
probes/tasklet/README [code]
probes/tasklet/stp_tasklet.c [code]
probes/test4/dtr.c [code]
probes/test4/nrec.c [code]
probes/test4/README [code]
probes/where_func/kprobe_where_funct.c [code]
probes/where_func/README [code]
-
-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/functions.html b/runtime/docs/html/functions.html index f81967b0..e48ba9fa 100644 --- a/runtime/docs/html/functions.html +++ b/runtime/docs/html/functions.html @@ -4,7 +4,7 @@ - +

@@ -22,6 +22,4 @@ Here is a list of all documented struct and union fields with links to the struc : map_root

  • pool : map_root
  • type : map_root -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/functions_vars.html b/runtime/docs/html/functions_vars.html index 261bcd3b..ed63f0fd 100644 --- a/runtime/docs/html/functions_vars.html +++ b/runtime/docs/html/functions_vars.html @@ -4,7 +4,7 @@ - +

    @@ -22,6 +22,4 @@ : map_root

  • pool : map_root
  • type : map_root -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/globals.html b/runtime/docs/html/globals.html index d3331603..74f0f2e2 100644 --- a/runtime/docs/html/globals.html +++ b/runtime/docs/html/globals.html @@ -4,86 +4,78 @@ - + -
    _ | c | d | f | k | m | p | v
    +
    _ | d | f | k | m | p | v

    Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:

    - _ -

    • _stp_alloc() -: alloc.h
    • _stp_calloc() -: alloc.h
    • _stp_copy_argv_from_user() -: copy.c
    • _stp_copy_from_user() -: copy.c
    • _stp_free() -: alloc.h
    • _stp_kallsyms_lookup -: io.c
    • _stp_list_add -: map.h
    • _stp_list_add_int64() -: map.c
    • _stp_list_add_str() -: map.c
    • _stp_list_clear() -: map.c
    • _stp_list_new() -: map.c
    • _stp_list_size() -: map.c
    • _stp_lookup_name -: probes.c
    • _stp_map_add_int64() -: map.c
    • _stp_map_del() -: map.c
    • _stp_map_get_int64() -: map.c
    • _stp_map_get_stat() -: map.c
    • _stp_map_get_str() -: map.c
    • _stp_map_iter() -: map.c
    • _stp_map_key -: map.h
    • _stp_map_key2 -: map.h
    • _stp_map_key_del() -: map.c
    • _stp_map_key_long() -: map.c
    • _stp_map_key_long_long() -: map.c
    • _stp_map_key_long_str() -: map.c
    • _stp_map_key_str() -: map.c
    • _stp_map_key_str_long() -: map.c
    • _stp_map_key_str_str() -: map.c
    • _stp_map_new() -: map.c
    • _stp_map_set -: map.h
    • _stp_map_set_int64() -: map.c
    • _stp_map_set_stat() -: map.c
    • _stp_map_set_str() -: map.c
    • _stp_map_start() -: map.c
    • _stp_map_stat_add() -: map.c
    • _stp_pbuf -: io.c
    • _stp_print_buf() -: io.c
    • _stp_print_buf_init() -: io.c
    • _stp_print_symbol() -: io.c
    • _stp_register_jprobes() +: alloc.c
    • _stp_calloc() +: alloc.c
    • _stp_copy_argv_from_user() +: copy.c
    • _stp_copy_from_user() +: copy.c
    • _stp_free() +: alloc.c
    • _stp_list_add +: map.h
    • _stp_list_add_int64() +: map.c
    • _stp_list_add_str() +: map.c
    • _stp_list_clear() +: map.c
    • _stp_list_new() +: map.c
    • _stp_list_size() +: map.c
    • _stp_map_add_int64() +: map.c
    • _stp_map_del() +: map.c
    • _stp_map_get_int64() +: map.c
    • _stp_map_get_stat() +: map.c
    • _stp_map_get_str() +: map.c
    • _stp_map_iter() +: map.c
    • _stp_map_key +: map.h
    • _stp_map_key2 +: map.h
    • _stp_map_key_del() +: map.c
    • _stp_map_key_long() +: map.c
    • _stp_map_key_long_long() +: map.c
    • _stp_map_key_long_str() +: map.c
    • _stp_map_key_str() +: map.c
    • _stp_map_key_str_long() +: map.c
    • _stp_map_key_str_str() +: map.c
    • _stp_map_new() +: map.c
    • _stp_map_set +: map.h
    • _stp_map_set_int64() +: map.c
    • _stp_map_set_stat() +: map.c
    • _stp_map_set_str() +: map.c
    • _stp_map_start() +: map.c
    • _stp_map_stat_add() +: map.c
    • _stp_print() +: io.c
    • _stp_print_str() +: io.c
    • _stp_register_jprobes() : probes.c
    • _stp_register_kprobes() -: probes.c
    • _stp_strncpy_from_user() -: copy.c
    • _stp_unregister_jprobes() +: probes.c
    • _stp_ret_addr() +: current.c
    • _stp_strncpy_from_user() +: copy.c
    • _stp_unregister_jprobes() : probes.c
    • _stp_unregister_kprobes() : probes.c
    • _stp_valloc() -: alloc.h
    • _stp_vfree() -: alloc.h
    -

    - c -

      -
    • cur_ret_addr() -: io.c
    +: alloc.c
  • _stp_vfree() +: alloc.c

    - d -

    +: io.c

    - f -

    +: map.h

    - k -

    +: map.h
  • key1str +: map.h
  • key2int +: map.h
  • key2str +: map.h
  • keytype +: map.h

    - m -

    +: map.h

    - p -

    +: map.h

    - v -

    -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +: map.h + diff --git a/runtime/docs/html/globals_defs.html b/runtime/docs/html/globals_defs.html index b612ab13..fd07c918 100644 --- a/runtime/docs/html/globals_defs.html +++ b/runtime/docs/html/globals_defs.html @@ -4,21 +4,19 @@ - +

    -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +: map.h
  • _stp_map_key +: map.h
  • _stp_map_key2 +: map.h
  • _stp_map_set +: map.h
  • foreach +: map.h
  • key1int +: map.h
  • key1str +: map.h
  • key2int +: map.h
  • key2str +: map.h + diff --git a/runtime/docs/html/globals_enum.html b/runtime/docs/html/globals_enum.html index 61d85695..da3f3ac0 100644 --- a/runtime/docs/html/globals_enum.html +++ b/runtime/docs/html/globals_enum.html @@ -4,14 +4,12 @@ - +

    -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +: map.h
  • valtype +: map.h + diff --git a/runtime/docs/html/globals_func.html b/runtime/docs/html/globals_func.html index 2d0c9ba2..051cf88c 100644 --- a/runtime/docs/html/globals_func.html +++ b/runtime/docs/html/globals_func.html @@ -4,60 +4,55 @@ - + -
    _ | c | d
    +
    _ | d

    - _ -

    • _stp_alloc() -: alloc.h
    • _stp_calloc() -: alloc.h
    • _stp_copy_argv_from_user() -: copy.c
    • _stp_copy_from_user() -: copy.c
    • _stp_free() -: alloc.h
    • _stp_list_add_int64() -: map.c
    • _stp_list_add_str() -: map.c
    • _stp_list_clear() -: map.c
    • _stp_list_new() -: map.c
    • _stp_list_size() -: map.c
    • _stp_map_add_int64() -: map.c
    • _stp_map_del() -: map.c
    • _stp_map_get_int64() -: map.c
    • _stp_map_get_stat() -: map.c
    • _stp_map_get_str() -: map.c
    • _stp_map_iter() -: map.c
    • _stp_map_key_del() -: map.c
    • _stp_map_key_long() -: map.c
    • _stp_map_key_long_long() -: map.c
    • _stp_map_key_long_str() -: map.c
    • _stp_map_key_str() -: map.c
    • _stp_map_key_str_long() -: map.c
    • _stp_map_key_str_str() -: map.c
    • _stp_map_new() -: map.c
    • _stp_map_set_int64() -: map.c
    • _stp_map_set_stat() -: map.c
    • _stp_map_set_str() -: map.c
    • _stp_map_start() -: map.c
    • _stp_map_stat_add() -: map.c
    • _stp_print_buf() -: io.c
    • _stp_print_buf_init() -: io.c
    • _stp_print_symbol() -: io.c
    • _stp_register_jprobes() +: alloc.c
    • _stp_calloc() +: alloc.c
    • _stp_copy_argv_from_user() +: copy.c
    • _stp_copy_from_user() +: copy.c
    • _stp_free() +: alloc.c
    • _stp_list_add_int64() +: map.c
    • _stp_list_add_str() +: map.c
    • _stp_list_clear() +: map.c
    • _stp_list_new() +: map.c
    • _stp_list_size() +: map.c
    • _stp_map_add_int64() +: map.c
    • _stp_map_del() +: map.c
    • _stp_map_get_int64() +: map.c
    • _stp_map_get_stat() +: map.c
    • _stp_map_get_str() +: map.c
    • _stp_map_iter() +: map.c
    • _stp_map_key_del() +: map.c
    • _stp_map_key_long() +: map.c
    • _stp_map_key_long_long() +: map.c
    • _stp_map_key_long_str() +: map.c
    • _stp_map_key_str() +: map.c
    • _stp_map_key_str_long() +: map.c
    • _stp_map_key_str_str() +: map.c
    • _stp_map_new() +: map.c
    • _stp_map_set_int64() +: map.c
    • _stp_map_set_stat() +: map.c
    • _stp_map_set_str() +: map.c
    • _stp_map_start() +: map.c
    • _stp_map_stat_add() +: map.c
    • _stp_print() +: io.c
    • _stp_print_str() +: io.c
    • _stp_register_jprobes() : probes.c
    • _stp_register_kprobes() -: probes.c
    • _stp_strncpy_from_user() -: copy.c
    • _stp_unregister_jprobes() +: probes.c
    • _stp_ret_addr() +: current.c
    • _stp_strncpy_from_user() +: copy.c
    • _stp_unregister_jprobes() : probes.c
    • _stp_unregister_kprobes() : probes.c
    • _stp_valloc() -: alloc.h
    • _stp_vfree() -: alloc.h
    -

    - c -

      -
    • cur_ret_addr() -: io.c
    +: alloc.c
  • _stp_vfree() +: alloc.c

    - d -

    -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +: io.c + diff --git a/runtime/docs/html/globals_type.html b/runtime/docs/html/globals_type.html index da9cb0bc..ab8a7382 100644 --- a/runtime/docs/html/globals_type.html +++ b/runtime/docs/html/globals_type.html @@ -4,13 +4,11 @@ - +

    -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +: map.h + diff --git a/runtime/docs/html/globals_vars.html b/runtime/docs/html/globals_vars.html index 2c1becac..a4674892 100644 --- a/runtime/docs/html/globals_vars.html +++ b/runtime/docs/html/globals_vars.html @@ -4,16 +4,11 @@ - +

    -
    -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +
  • packed +: map.h + diff --git a/runtime/docs/html/group__alloc.html b/runtime/docs/html/group__alloc.html new file mode 100644 index 00000000..1a3e32b2 --- /dev/null +++ b/runtime/docs/html/group__alloc.html @@ -0,0 +1,247 @@ + + +SystemTap: Memory Functions + + + + +

    Memory Functions

    Basic malloc/calloc/free functions. +More... + + + + + + + + + + + + + + + + + + + + + + + +

    Enumerations

    enum  errorcode { ERR_NONE = 0, +ERR_NO_MEM + }

    Functions

    void * _stp_alloc (size_t len)
     Allocates memory within a probe.
    void * _stp_calloc (size_t len)
     Allocates and clears memory within a probe.
    void * _stp_valloc (size_t len)
     Allocates and clears memory outside a probe.
    void _stp_free (void *ptr)
     Frees memory allocated by _stp_alloc or _stp_calloc.
    void _stp_vfree (void *ptr)
     Frees memory allocated by _stp_valloc.

    Variables

    +enum errorcode _stp_error = ERR_NONE
    +

    Detailed Description

    +Basic malloc/calloc/free functions. +

    +These will be changed so that memory allocation errors will call a handler. The default will send a signal to the user-space daemon that will trigger the module to be unloaded.

    +

    Todo:
    Need error handling for memory allocations
    +

    +

    Todo:
    Some of these currently use kmalloc (GFP_ATOMIC) for small allocations. This should be evaluated for performance and stability.
    +

    Function Documentation

    +

    + + + + +
    + + + + + + + + + +
    void* _stp_alloc size_t  len  ) 
    +
    + + + + + +
    +   + + +

    +Allocates memory within a probe. +

    +This is used for small allocations from within a running probe where the process cannot sleep.

    Parameters:
    + + +
    len Number of bytes to allocate.
    +
    +
    Returns:
    a valid pointer on success or NULL on failure.
    +
    Bug:
    Currently uses kmalloc (GFP_ATOMIC).
    + +

    +Definition at line 31 of file alloc.c. +

    +Referenced by _stp_calloc(), and _stp_map_set_str().

    +

    + + + + +
    + + + + + + + + + +
    void* _stp_calloc size_t  len  ) 
    +
    + + + + + +
    +   + + +

    +Allocates and clears memory within a probe. +

    +This is used for small allocations from within a running probe where the process cannot sleep.

    Parameters:
    + + +
    len Number of bytes to allocate.
    +
    +
    Returns:
    a valid pointer on success or NULL on failure.
    +
    Bug:
    Currently uses kmalloc (GFP_ATOMIC).
    + +

    +Definition at line 47 of file alloc.c. +

    +References _stp_alloc(). +

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

    +

    + + + + +
    + + + + + + + + + +
    void _stp_free void *  ptr  ) 
    +
    + + + + + +
    +   + + +

    +Frees memory allocated by _stp_alloc or _stp_calloc. +

    +

    Parameters:
    + + +
    ptr pointer to memory to free
    +
    + +

    +Definition at line 76 of file alloc.c. +

    +Referenced by _stp_list_clear(), _stp_map_key_del(), and _stp_map_set_str().

    +

    + + + + +
    + + + + + + + + + +
    void* _stp_valloc size_t  len  ) 
    +
    + + + + + +
    +   + + +

    +Allocates and clears memory outside a probe. +

    +This is typically used in the module initialization to allocate new maps, lists, etc.

    Parameters:
    + + +
    len Number of bytes to allocate.
    +
    +
    Returns:
    a valid pointer on success or NULL on failure.
    + +

    +Definition at line 62 of file alloc.c. +

    +Referenced by _stp_map_new().

    +

    + + + + +
    + + + + + + + + + +
    void _stp_vfree void *  ptr  ) 
    +
    + + + + + +
    +   + + +

    +Frees memory allocated by _stp_valloc. +

    +

    Parameters:
    + + +
    ptr pointer to memory to free
    +
    + +

    +Definition at line 86 of file alloc.c. +

    +Referenced by _stp_map_del().

    + diff --git a/runtime/docs/html/group__copy.html b/runtime/docs/html/group__copy.html new file mode 100644 index 00000000..83928d95 --- /dev/null +++ b/runtime/docs/html/group__copy.html @@ -0,0 +1,202 @@ + + +SystemTap: Functions to copy from user space. + + + +

    +

    Functions to copy from user space.

    Functions to copy from user space. +More... + + + + + + + + + + + +

    Functions

    long _stp_strncpy_from_user (char *dst, const char __user *src, long count)
     Copy a NULL-terminated string from userspace.
    unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
     Copy a block of data from user space.
    int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
     Copy an argv from user space to a List.
    +

    Detailed Description

    +Functions to copy from user space. +

    +None of these functions will sleep (for example to allow pages to be swapped in). It is possible (although rare) that the data in user space will not present and these functions will return an error.


    Function Documentation

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    int _stp_copy_argv_from_user MAP  list,
    char __user *__user *  argv
    +
    + + + + + +
    +   + + +

    +Copy an argv from user space to a List. +

    +

    Parameters:
    + + + +
    list A list.
    argv Source argv, in user space.
    +
    +
    Returns:
    number of elements in list
    +Example:
    MAP arglist ;
    +
    +int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs)
    +{
    +  struct map_node_str *ptr;
    +
    +  _stp_list_clear (arglist);
    +  _stp_copy_argv_from_user (arglist, argv);
    +
    +  foreach (arglist, ptr)
    +    printk ("%s ", ptr->str);
    +  printk ("\n");
    +}
    +
    +

    +Definition at line 130 of file copy.c. +

    +References _stp_list_add_str(), _stp_strncpy_from_user(), and map_root::num.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    unsigned long _stp_copy_from_user char *  dst,
    const char __user *  src,
    unsigned long  count
    [inline]
    +
    + + + + + +
    +   + + +

    +Copy a block of data from user space. +

    +If some data could not be copied, this function will pad the copied data to the requested size using zero bytes.

    +

    Parameters:
    + + + + +
    dst Destination address, in kernel space.
    src Source address, in user space.
    count Number of bytes to copy.
    +
    +
    Returns:
    number of bytes that could not be copied. On success, this will be zero.
    + +

    +Definition at line 115 of file copy.c.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    long _stp_strncpy_from_user char *  dst,
    const char __user *  src,
    long  count
    +
    + + + + + +
    +   + + +

    +Copy a NULL-terminated string from userspace. +

    +On success, returns the length of the string (not including the trailing NULL).

    +If access to userspace fails, returns -EFAULT (some data may have been copied).

    Parameters:
    + + + + +
    dst Destination address, in kernel space. This buffer must be at least count bytes long.
    src Source address, in user space.
    count Maximum number of bytes to copy, including the trailing NULL.
    +
    +If count is smaller than the length of the string, copies count bytes and returns count. +

    +Definition at line 94 of file copy.c. +

    +Referenced by _stp_copy_argv_from_user().

    + diff --git a/runtime/docs/html/group__current.html b/runtime/docs/html/group__current.html new file mode 100644 index 00000000..91973e06 --- /dev/null +++ b/runtime/docs/html/group__current.html @@ -0,0 +1,59 @@ + + +SystemTap: Current State + + + +

    +

    Current State

    Functions to get the current state. +More... + + + + + +

    Functions

    unsigned long _stp_ret_addr (struct pt_regs *regs)
     Get the current return address.
    +

    Detailed Description

    +Functions to get the current state. +

    +


    Function Documentation

    +

    + + + + +
    + + + + + + + + + +
    unsigned long _stp_ret_addr struct pt_regs *  regs  ) 
    +
    + + + + + +
    +   + + +

    +Get the current return address. +

    +Call from kprobes (not jprobes).

    Parameters:
    + + +
    regs The pt_regs saved by the kprobe.
    +
    +
    Returns:
    The return address saved in esp or rsp.
    +
    Note:
    i386 and x86_64 only so far.
    + +

    +Definition at line 21 of file current.c.

    + diff --git a/runtime/docs/html/group__io.html b/runtime/docs/html/group__io.html new file mode 100644 index 00000000..357e250b --- /dev/null +++ b/runtime/docs/html/group__io.html @@ -0,0 +1,170 @@ + + +SystemTap: I/O + + + +

    +

    I/O

    I/O functions. +More... + + + + + + + + + + + +

    Functions

    void dlog (const char *fmt,...)
     Logs Data.
    void _stp_print (const char *fmt,...)
     Prints to the trace buffer.
    void _stp_print_str (char *str)
     Prints to the trace buffer.
    +

    Detailed Description

    +I/O functions. +

    +


    Function Documentation

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_print const char *  fmt,
      ...
    +
    + + + + + +
    +   + + +

    +Prints to the trace buffer. +

    +This function uses the same formatting as printk. It currently writes to the system log.

    +

    Parameters:
    + + +
    fmt A variable number of args.
    +
    +

    +

    Todo:
    Needs replaced with something much faster that does not use the system log.
    + +

    +Definition at line 43 of file io.c. +

    +Referenced by _stp_symbol_print().

    +

    + + + + +
    + + + + + + + + + +
    void _stp_print_str char *  str  ) 
    +
    + + + + + +
    +   + + +

    +Prints to the trace buffer. +

    +This function will write a string to the trace buffer. It currently writes to the system log.

    +

    Parameters:
    + + +
    str String.
    +
    +

    +

    Todo:
    Needs replaced with something much faster that does not use the system log.
    + +

    +Definition at line 60 of file io.c.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void dlog const char *  fmt,
      ...
    +
    + + + + + +
    +   + + +

    +Logs Data. +

    +This function is compatible with printk. In fact it currently sends all output to vprintk, after sending "STP: ". This allows us to easily detect SystemTap output in the log file.

    +

    Parameters:
    + + +
    fmt A variable number of args.
    +
    +

    +

    Bug:
    Lines are limited in length by printk buffer. If there is no newline in the format string, then other syslog output could get appended to the SystemTap line.
    +

    +

    Todo:
    Either deprecate or redefine this as a way to log debug or status messages, separate from the normal program output.
    + +

    +Definition at line 25 of file io.c. +

    +Referenced by _stp_list_clear(), _stp_register_jprobes(), _stp_register_kprobes(), _stp_unregister_jprobes(), and _stp_unregister_kprobes().

    + diff --git a/runtime/docs/html/group__list.html b/runtime/docs/html/group__list.html new file mode 100644 index 00000000..3e9f1eb0 --- /dev/null +++ b/runtime/docs/html/group__list.html @@ -0,0 +1,58 @@ + + +SystemTap: List + + + +

    +

    List

    + + + + + +

    Defines

    #define _stp_list_add(map, val)
     Macro to call the proper _stp_list_add function based on the types of the argument.
    +

    Define Documentation

    +

    + + + + +
    + + + + + + + + + + + + +
    #define _stp_list_add map,
    val   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    ({                                                              \
    +    if (__builtin_types_compatible_p (typeof (val), char[]))    \
    +      _stp_list_add_str (map, (char *)(val));                           \
    +    else                                                        \
    +      _stp_list_add_int64 (map, (int64_t)(val));                        \
    +  })
    +
    Macro to call the proper _stp_list_add function based on the types of the argument. +

    +

    Note:
    May cause compiler warning on some GCCs
    + +

    +Definition at line 164 of file map.h.

    + diff --git a/runtime/docs/html/group__lists.html b/runtime/docs/html/group__lists.html new file mode 100644 index 00000000..49550e5c --- /dev/null +++ b/runtime/docs/html/group__lists.html @@ -0,0 +1,323 @@ + + +SystemTap: Lists + + + +

    +

    Lists

    Lists are special cases of maps. +More... + + + + + + + + + + + + + + + + + + + + + +

    Defines

    #define _stp_list_add(map, val)
     Macro to call the proper _stp_list_add function based on the types of the argument.

    Functions

    MAP _stp_list_new (unsigned max_entries, enum valtype type)
     Create a new list.
    void _stp_list_clear (MAP map)
     Clears a list.
    void _stp_list_add_str (MAP map, char *str)
     Adds a string to a list.
    void _stp_list_add_int64 (MAP map, int64_t val)
     Adds an int64 to a list.
    int _stp_list_size (MAP map)
     Get the number of elements in a list.
    +

    Detailed Description

    +Lists are special cases of maps. +

    +Example:

    +struct map_node_str *ptr;
    +
    +MAP map = _stp_list_new(10, STRING);
    +
    +for (i = 0; i < 10; i++) {
    +     sprintf (buf, "Item%d", i);
    +     _stp_list_add (map, buf);
    + }
    +
    +foreach (map, ptr)
    +     printf ("map[%ld] = %s\n", key1int(ptr), ptr->str);
    +
    +
    +

    Define Documentation

    +

    + + + + +
    + + + + + + + + + + + + +
    #define _stp_list_add map,
    val   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    ({                                                              \
    +    if (__builtin_types_compatible_p (typeof (val), char[]))    \
    +      _stp_list_add_str (map, (char *)(val));                           \
    +    else                                                        \
    +      _stp_list_add_int64 (map, (int64_t)(val));                        \
    +  })
    +
    Macro to call the proper _stp_list_add function based on the types of the argument. +

    +

    Note:
    May cause compiler warning on some GCCs
    + +

    +Definition at line 181 of file map.h.

    +


    Function Documentation

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_list_add_int64 MAP  map,
    int64_t  val
    [inline]
    +
    + + + + + +
    +   + + +

    +Adds an int64 to a list. +

    +

    Parameters:
    + + + +
    map 
    val 
    +
    + +

    +Definition at line 864 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_list_add_str MAP  map,
    char *  str
    [inline]
    +
    + + + + + +
    +   + + +

    +Adds a string to a list. +

    +

    Parameters:
    + + + +
    map 
    str 
    +
    + +

    +Definition at line 853 of file map.c. +

    +References _stp_map_key_long(), _stp_map_set_str(), and map_root::num. +

    +Referenced by _stp_copy_argv_from_user().

    +

    + + + + +
    + + + + + + + + + +
    void _stp_list_clear MAP  map  ) 
    +
    + + + + + +
    +   + + +

    +Clears a list. +

    +All elements in the list are deleted.

    Parameters:
    + + +
    map 
    +
    + +

    +Definition at line 813 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.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    MAP _stp_list_new unsigned  max_entries,
    enum valtype  type
    +
    + + + + + +
    +   + + +

    +Create a new list. +

    +A list is a map that internally has an incrementing long key for each member. Lists do not wrap if elements are added to exceed their maximum size.

    Parameters:
    + + + +
    max_entries The maximum number of entries allowed. Currently that number will be preallocated. If max_entries is 0, there will be no maximum and entries will be allocated dynamically.
    type Type of values stored in this list.
    +
    +
    Returns:
    A MAP on success or NULL on failure.
    +
    See also:
    foreach
    + +

    +Definition at line 801 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + +
    int _stp_list_size MAP  map  )  [inline]
    +
    + + + + + +
    +   + + +

    +Get the number of elements in a list. +

    +

    Parameters:
    + + +
    map 
    +
    +
    Returns:
    The number of elements in a list.
    + +

    +Definition at line 875 of file map.c. +

    +References map_root::num.

    + diff --git a/runtime/docs/html/group__maps.html b/runtime/docs/html/group__maps.html new file mode 100644 index 00000000..1da96a51 --- /dev/null +++ b/runtime/docs/html/group__maps.html @@ -0,0 +1,1265 @@ + + +SystemTap: Maps + + + +

    +

    Maps

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

    Data Structures

    struct  stat
     Statistics are stored in this struct. More...
    union  key_data
     Keys are either longs or char *. More...
    struct  map_node
     basic map element More...
    struct  map_node_int64
     map element containing int64 More...
    struct  map_node_str
     map element containing string More...
    struct  map_node_stat
     map element containing stats More...
    struct  map_root
     This structure contains all information about a map. More...

    Defines

    +#define key1str(ptr)   (ptr->n.key1.str)
     Extracts string from key1 union.
    +#define key2str(ptr)   (ptr->n.key2.str)
     Extracts string from key2 union.
    +#define key1int(ptr)   (ptr->n.key1.val)
     Extracts int from key1 union.
    +#define key2int(ptr)   (ptr->n.key2.val)
     Extracts int from key2 union.
    #define _stp_map_key2(map, key1, key2)
     Macro to call the proper _stp_map_key functions based on the types of the arguments.
    #define _stp_map_key(map, key)
     Macro to call the proper _stp_map_key function based on the type of the argument.
    #define _stp_map_set(map, val)
     Macro to call the proper _stp_map_set function based on the type of the argument.
    #define foreach(map, ptr)
     Loop through all elements of a map or list.

    Typedefs

    +typedef map_rootMAP
     All maps are of this type.

    Enumerations

    enum  keytype { NONE, +LONG, +STR + }
     keys can be longs or strings
    enum  valtype { INT64, +STAT, +STRING, +END + }
     values can be either int64, stats or strings

    Functions

    MAP _stp_map_new (unsigned max_entries, enum valtype type)
     Create a new map.
    void _stp_map_key_del (MAP map)
     Deletes the current element.
    map_node_stp_map_start (MAP map)
     Get the first element in a map.
    map_node_stp_map_iter (MAP map, struct map_node *m)
     Get the next element in a map.
    void _stp_map_del (MAP map)
     Deletes a map.
    void _stp_map_key_long_long (MAP map, long key1, long key2)
     Set the map's key to two longs.
    void _stp_map_key_str_str (MAP map, char *key1, char *key2)
     Set the map's key to two strings.
    void _stp_map_key_str_long (MAP map, char *key1, long key2)
     Set the map's key to a string and a long.
    void _stp_map_key_long_str (MAP map, long key1, char *key2)
     Set the map's key to a long and a string.
    void _stp_map_key_str (MAP map, char *key)
     Set the map's key to a string.
    void _stp_map_key_long (MAP map, long key)
     Set the map's key to a long.
    void _stp_map_set_int64 (MAP map, int64_t val)
     Set the current element's value to an int64.
    void _stp_map_add_int64 (MAP map, int64_t val)
     Adds an int64 to the current element's value.
    int64_t _stp_map_get_int64 (MAP map)
     Gets the current element's value.
    void _stp_map_set_str (MAP map, char *val)
     Set the current element's value to a string.
    char * _stp_map_get_str (MAP map)
     Gets the current element's value.
    void _stp_map_set_stat (MAP map, stat *stats)
     Set the current element's value to a stat.
    stat_stp_map_get_stat (MAP map)
     Gets the current element's value.
    void _stp_map_stat_add (MAP map, int64_t val)
     Add to the current element's statistics.

    Variables

    +enum keytype packed
     keys can be longs or strings
    +

    Detailed Description

    +Implements maps (associative arrays) and lists. +

    +


    Define Documentation

    +

    + + + + +
    + + + + + + + + + + + + +
    #define _stp_map_key map,
    key   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    ({                                                              \
    +    if (__builtin_types_compatible_p (typeof (key), char[]))    \
    +      _stp_map_key_str (map, (char *)(key));                            \
    +    else                                                        \
    +      _stp_map_key_long (map, (long)(key));                             \
    +  })
    +
    Macro to call the proper _stp_map_key function based on the type of the argument. +

    +

    Note:
    May cause compiler warning on some GCCs
    + +

    +Definition at line 141 of file map.h.

    +

    + + + + +
    + + + + + + + + + + + + + + + +
    #define _stp_map_key2 map,
    key1,
    key2   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    ({                                                              \
    +    if (__builtin_types_compatible_p (typeof (key1), char[]))   \
    +      if (__builtin_types_compatible_p (typeof (key2), char[])) \
    +        _stp_map_key_str_str (map, (char *)(key1), (char *)(key2));     \
    +      else                                                      \
    +        _stp_map_key_str_long (map, (char *)(key1), (long)(key2));      \
    +    else                                                        \
    +      if (__builtin_types_compatible_p (typeof (key2), char[])) \
    +        _stp_map_key_long_str (map, (long)(key1), (char *)(key2));      \
    +      else                                                      \
    +        _stp_map_key_long_long (map, (long)(key1), (long)(key2));       \
    +  })
    +
    Macro to call the proper _stp_map_key functions based on the types of the arguments. +

    +

    Note:
    May cause compiler warning on some GCCs
    + +

    +Definition at line 123 of file map.h.

    +

    + + + + +
    + + + + + + + + + + + + +
    #define _stp_map_set map,
    val   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    ({                                                              \
    +    if (__builtin_types_compatible_p (typeof (val), char[]))    \
    +      _stp_map_set_str (map, (char *)(val));                            \
    +    else                                                        \
    +      _stp_map_set_int64 (map, (int64_t)(val));                 \
    +  })
    +
    Macro to call the proper _stp_map_set function based on the type of the argument. +

    +

    Note:
    May cause compiler warning on some GCCs
    + +

    +Definition at line 153 of file map.h.

    +

    + + + + +
    + + + + + + + + + + + + +
    #define foreach map,
    ptr   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \
    +       ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr))
    +
    Loop through all elements of a map or list. +

    +

    Parameters:
    + + + +
    map 
    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;
    +
    +foreach (map, ptr)
    +     printf ("map[%s,%ld] = [c=%lld s=%lld min=%lld max=%lld]\n", key1str(ptr), 
    +             key2int(ptr), ptr->stats.count, ptr->stats.sum, ptr->stats.min, 
    +             ptr->stats.max);
    +
    +
    +

    +Definition at line 169 of file map.h.

    +


    Function Documentation

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_add_int64 MAP  map,
    int64_t  val
    +
    + + + + + +
    +   + + +

    +Adds an int64 to the current element's value. +

    +This adds an int64 to the current element's value. The map must have been created to hold int64s using _stp_map_new()

    +If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

    Parameters:
    + + + +
    map 
    val value
    +
    +
    See also:
    _stp_map_set_int64
    + +

    +Definition at line 558 of file map.c.

    +

    + + + + +
    + + + + + + + + + +
    void _stp_map_del MAP  map  ) 
    +
    + + + + + +
    +   + + +

    +Deletes a map. +

    +Deletes a map, freeing all memory in all elements. Normally done only when the module exits.

    Parameters:
    + + +
    map 
    +
    + +

    +Definition at line 205 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + +
    int64_t _stp_map_get_int64 MAP  map  ) 
    +
    + + + + + +
    +   + + +

    +Gets the current element's value. +

    +

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

    +Definition at line 568 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + +
    stat* _stp_map_get_stat MAP  map  ) 
    +
    + + + + + +
    +   + + +

    +Gets the current element's value. +

    +

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

    +Definition at line 732 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + +
    char* _stp_map_get_str MAP  map  ) 
    +
    + + + + + +
    +   + + +

    +Gets the current element's value. +

    +

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

    +Definition at line 649 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    struct map_node* _stp_map_iter MAP  map,
    struct map_node m
    +
    + + + + + +
    +   + + +

    +Get the next element in a map. +

    +

    Parameters:
    + + + +
    map 
    m a pointer to the current element, returned from _stp_map_start() or _stp_map_iter().
    +
    +
    Returns:
    a pointer to the next element. This is typically used with _stp_map_start(). See the foreach() macro for typical usage. It probably does what you want anyway.
    +
    See also:
    foreach
    + +

    +Definition at line 186 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + +
    void _stp_map_key_del MAP  map  ) 
    +
    + + + + + +
    +   + + +

    +Deletes the current element. +

    +If no current element (key) for this map is set, this function does nothing.

    Parameters:
    + + +
    map 
    +
    + +

    +Definition at line 118 of file map.c. +

    +References _stp_free(), map_node::hnode, and map_node::lnode. +

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

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_key_long MAP  map,
    long  key
    +
    + + + + + +
    +   + + +

    +Set the map's key to a long. +

    +This sets the current element based on a long key. If the key is not found, a new element will not be created until a _stp_map_set_xxx call.

    Parameters:
    + + + +
    map 
    key 
    +
    + +

    +Definition at line 430 of file map.c. +

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

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

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    void _stp_map_key_long_long MAP  map,
    long  key1,
    long  key2
    +
    + + + + + +
    +   + + +

    +Set the map's key to two longs. +

    +This sets the current element based on a key of two strings. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

    Parameters:
    + + + + +
    map 
    key1 first key
    key2 second key
    +
    + +

    +Definition at line 233 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, map_root::hashes, map_root::key, map_node::key1, and key_data::val. +

    +Referenced by _stp_map_key_long().

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    void _stp_map_key_long_str MAP  map,
    long  key1,
    char *  key2
    +
    + + + + + +
    +   + + +

    +Set the map's key to a long and a string. +

    +This sets the current element based on a key of a long and a string. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

    Parameters:
    + + + + +
    map 
    key1 first key
    key2 second key
    +
    + +

    +Definition at line 373 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, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_key_str MAP  map,
    char *  key
    +
    + + + + + +
    +   + + +

    +Set the map's key to a string. +

    +This sets the current element based on a string key. If the key is not found, a new element will not be created until a _stp_map_set_xxx call.

    Parameters:
    + + + +
    map 
    key 
    +
    + +

    +Definition at line 414 of file map.c. +

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

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    void _stp_map_key_str_long MAP  map,
    char *  key1,
    long  key2
    +
    + + + + + +
    +   + + +

    +Set the map's key to a string and a long. +

    +This sets the current element based on a key of a string and a long. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

    Parameters:
    + + + + +
    map 
    key1 first key
    key2 second key
    +
    + +

    +Definition at line 325 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, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    void _stp_map_key_str_str MAP  map,
    char *  key1,
    char *  key2
    +
    + + + + + +
    +   + + +

    +Set the map's key to two strings. +

    +This sets the current element based on a key of two strings. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

    Parameters:
    + + + + +
    map 
    key1 first key
    key2 second key
    +
    + +

    +Definition at line 276 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, map_root::hashes, map_root::key, map_node::key1, map_node::key2, and key_data::str. +

    +Referenced by _stp_map_key_str().

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    MAP _stp_map_new unsigned  max_entries,
    enum valtype  type
    +
    + + + + + +
    +   + + +

    +Create a new map. +

    +Maps must be created at module initialization time.

    Parameters:
    + + + +
    max_entries The maximum number of entries allowed. Currently that number will be preallocated. If more entries are required, the oldest ones will be deleted. This makes it effectively a circular buffer. If max_entries is 0, there will be no maximum and entries will be allocated dynamically.
    type Type of values stored in this map.
    +
    +
    Returns:
    A MAP on success or NULL on failure.
    + +

    +Definition at line 57 of file map.c. +

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

    +Referenced by _stp_list_new().

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_set_int64 MAP  map,
    int64_t  val
    +
    + + + + + +
    +   + + +

    +Set the current element's value to an int64. +

    +This sets the current element's value to an int64. The map must have been created to hold int64s using _stp_map_new()

    +If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

    Parameters:
    + + + +
    map 
    val new value
    +
    +
    See also:
    _stp_map_add_int64
    + +

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

    +Referenced by _stp_list_add_int64().

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_set_stat MAP  map,
    stat stats
    +
    + + + + + +
    +   + + +

    +Set the current element's value to a stat. +

    +This sets the current element's value to an stat struct. The map must have been created to hold stats using _stp_map_new(xxx, STAT). This function would only be used if we wanted to set stats to something other than the normal initial values (count = 0, sum = 0, etc). It may be deleted if it doesn't turn out to be useful.

    See also:
    _stp_map_stat_add
    +If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.
    Parameters:
    + + + +
    map 
    stats pointer to stats struct.
    +
    +
    Todo:
    Histograms don't work yet.
    + +

    +Definition at line 673 of file map.c. +

    +References _stp_calloc(), _stp_map_key_del(), map_root::create, 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. +

    +Referenced by _stp_map_stat_add().

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_set_str MAP  map,
    char *  val
    +
    + + + + + +
    +   + + +

    +Set the current element's value to a string. +

    +This sets the current element's value to an string. The map must have been created to hold int64s using _stp_map_new(xxx, STRING)

    +If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

    Parameters:
    + + + +
    map 
    val new string
    +
    + +

    +Definition at line 588 of file map.c. +

    +References _stp_alloc(), _stp_calloc(), _stp_free(), _stp_map_key_del(), map_root::create, 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. +

    +Referenced by _stp_list_add_str().

    +

    + + + + +
    + + + + + + + + + +
    struct map_node* _stp_map_start MAP  map  ) 
    +
    + + + + + +
    +   + + +

    +Get the first element in a map. +

    +

    Parameters:
    + + +
    map 
    +
    +
    Returns:
    a pointer to the first element. This is typically used with _stp_map_iter(). See the foreach() macro for typical usage. It probably does what you want anyway.
    +
    See also:
    foreach
    + +

    +Definition at line 163 of file map.c. +

    +References map_root::head.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_stat_add MAP  map,
    int64_t  val
    +
    + + + + + +
    +   + + +

    +Add to the current element's statistics. +

    +Increments the statistics counter by one and the sum by val. Adjusts minimum, maximum, and histogram.

    +If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

    Parameters:
    + + + +
    map 
    val value to add to the statistics
    +
    +
    Todo:
    Histograms don't work yet.
    + +

    +Definition at line 753 of file map.c. +

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

    + diff --git a/runtime/docs/html/group__scbuf.html b/runtime/docs/html/group__scbuf.html new file mode 100644 index 00000000..c5e0d6e0 --- /dev/null +++ b/runtime/docs/html/group__scbuf.html @@ -0,0 +1,122 @@ + + +SystemTap: Scratch Buffer + + + +

    +

    Scratch Buffer

    Scratch Buffer Functions. +More... + + + + + + + + + + + + + + + + + + +

    Defines

    +#define STP_BUF_LEN   8191
     Maximum size of buffer, not including terminating NULL.

    Functions

    void _stp_sprint (const char *fmt,...)
     Sprint into the scratch buffer.
    +void _stp_sprint_str (const char *str)
    void _stp_scbuf_clear (void)
     Clear the scratch buffer.

    Variables

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

    Detailed Description

    +Scratch Buffer Functions. +

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


    Function Documentation

    +

    + + + + +
    + + + + + + + + + +
    void _stp_scbuf_clear void   ) 
    +
    + + + + + +
    +   + + +

    +Clear the scratch buffer. +

    +Output from _stp_sprint() will accumulate in the buffer until this is called. +

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

    +References _stp_scbuf, and STP_BUF_LEN.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_sprint const char *  fmt,
      ...
    +
    + + + + + +
    +   + + +

    +Sprint into the scratch buffer. +

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

    +

    Parameters:
    + + +
    fmt A printf-style format string followed by a variable number of args.
    +
    +
    See also:
    _stp_scbuf_clear
    + +

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

    +References _stp_scbuf, and STP_BUF_LEN. +

    +Referenced by _stp_symbol_sprint().

    + diff --git a/runtime/docs/html/group__stack.html b/runtime/docs/html/group__stack.html new file mode 100644 index 00000000..bf112d0a --- /dev/null +++ b/runtime/docs/html/group__stack.html @@ -0,0 +1,18 @@ + + +SystemTap: Stack Tracing Functions + + + +

    +

    Stack Tracing Functions

    + + + + + + +

    Functions

    +void _stp_stack_print (int verbose, int levels)
    +char * _stp_stack_sprint (int verbose, int levels)
    + diff --git a/runtime/docs/html/group__sym.html b/runtime/docs/html/group__sym.html new file mode 100644 index 00000000..c5301602 --- /dev/null +++ b/runtime/docs/html/group__sym.html @@ -0,0 +1,104 @@ + + +SystemTap: Symbolic Functions + + + + +

    Symbolic Functions

    Symbolic Lookup Functions. +More... + + + + + + + + +

    Functions

    char * _stp_symbol_sprint (unsigned long address)
     Print addresses symbolically into a string.
    void _stp_symbol_print (unsigned long address)
     Print addresses symbolically to the trace buffer.
    +

    Detailed Description

    +Symbolic Lookup Functions. +

    +


    Function Documentation

    +

    + + + + +
    + + + + + + + + + +
    void _stp_symbol_print unsigned long  address  ) 
    +
    + + + + + +
    +   + + +

    +Print addresses symbolically to the trace buffer. +

    +

    Parameters:
    + + +
    address The address to lookup.
    +
    +
    Note:
    Symbolic lookups should not be done within a probe because it is too time-consuming. Use at module exit time.
    + +

    +Definition at line 59 of file sym.c. +

    +References _stp_print().

    +

    + + + + +
    + + + + + + + + + +
    char* _stp_symbol_sprint unsigned long  address  ) 
    +
    + + + + + +
    +   + + +

    +Print addresses symbolically into a string. +

    +

    Parameters:
    + + +
    address The address to lookup.
    +
    +
    Note:
    Symbolic lookups should not be done within a probe because it is too time-consuming. Use at module exit time.

    +Uses scbuf.

    + +

    +Definition at line 45 of file sym.c. +

    +References _stp_sprint().

    + diff --git a/runtime/docs/html/index.html b/runtime/docs/html/index.html index 458ba52a..86c7e175 100644 --- a/runtime/docs/html/index.html +++ b/runtime/docs/html/index.html @@ -4,7 +4,7 @@ -

    +

    SystemTap Runtime Library

    0.1

    @@ -16,7 +16,7 @@ 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.

    +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.

    To simplify the implementation, the functions to set the key and the functions to set the data are separated. That means we need only 4 functions to set the key and 3 functions to set the value.

    For example:

     /* create a map with a max of 100 elements */
    @@ -28,7 +28,7 @@ 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.

    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().

    +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_list_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.
    • @@ -40,6 +40,6 @@ Status Example Probes Working sample probe code using the runtime is in runtime/probes. Browse probes.

      ToDo

      -Click Here for Complete List
      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +Click Here for Complete List

      +Links

      +SystemTap Project Page diff --git a/runtime/docs/html/io_8c-source.html b/runtime/docs/html/io_8c-source.html index c241bba1..064ef3f8 100644 --- a/runtime/docs/html/io_8c-source.html +++ b/runtime/docs/html/io_8c-source.html @@ -4,130 +4,71 @@ - -

      io.c

      Go to the documentation of this file.
      00001 /* -*- linux-c -*- */
      -00002 /** @file io.c
      -00003  * @brief I/O functions
      -00004  */
      -00005 
      -00006 /** Logs data.
      -00007  * This function is compatible with printk.  In fact it currently
      -00008  * sends all output to vprintk, after sending "STP: ". This allows
      -00009  * us to easily detect SystemTap output in the log file.
      -00010  *
      -00011  * @param fmt A variable number of args.
      -00012  * @bug Lines are limited in length by printk buffer.
      -00013  * @todo Needs replaced with something much faster that does not
      -00014  * use the system log.
      -00015  */
      -00016 void dlog (const char *fmt, ...)
      -00017 {
      -00018   va_list args;
      -00019   printk("STP: ");
      -00020   va_start(args, fmt);
      -00021   vprintk(fmt, args);
      -00022   va_end(args);
      -00023 }
      -00024 
      -00025 
      -00026 /** Lookup symbol.
      -00027  * This simply calls the kernel function kallsyms_lookup().
      -00028  * That function is not exported, so this workaround is required.
      -00029  * See the kernel source, kernel/kallsyms.c for more information.
      -00030  */
      -00031 static const char * (*_stp_kallsyms_lookup)(unsigned long addr,
      -00032                             unsigned long *symbolsize,
      -00033                             unsigned long *offset,
      -00034                             char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP;
      -00035 
      -00036 
      -00037 #define STP_BUF_LEN 8191
      -00038 
      -00039 /** Static buffer for printing */
      -00040 static char _stp_pbuf[STP_BUF_LEN+1];
      -00041 static int _stp_pbuf_len = STP_BUF_LEN;
      -00042 
      -00043 /** Print into the print buffer.
      -00044  * Like printf, except output goes into  _stp_pbuf,
      -00045  * which will contain the null-terminated output.
      -00046  * Safe because overflowing _stp_pbuf is not allowed.
      -00047  * Size is limited by length of print buffer.
      -00048  *
      -00049  * @param fmt A variable number of args.
      -00050  * @note Formatting output should never be done within
      -00051  * a probe. Use at module exit time.
      -00052  * @sa _stp_print_buf_init
      -00053  */
      -00054 
      -00055 void _stp_print_buf (const char *fmt, ...)
      -00056 {
      -00057   int num;
      -00058   va_list args;
      -00059   char *buf = _stp_pbuf + STP_BUF_LEN - _stp_pbuf_len;
      -00060   va_start(args, fmt);
      -00061   num = vscnprintf(buf, _stp_pbuf_len, fmt, args);
      -00062   va_end(args);
      -00063   if (num > 0)
      -00064     _stp_pbuf_len -= num;
      -00065 }
      -00066 
      -00067 /** Clear the print buffer.
      -00068  * Output from _stp_print_buf() will accumulate in the buffer
      -00069  * until this is called.
      -00070  */
      -00071 
      -00072 void _stp_print_buf_init (void)
      -00073 {
      -00074   _stp_pbuf_len = STP_BUF_LEN;
      -00075   _stp_pbuf[0] = 0;
      -00076 }
      -00077 
      -00078 /** Print addresses symbolically into the print buffer.
      -00079  * @param fmt A variable number of args.
      -00080  * @param address The address to lookup.
      -00081  * @note Formatting output should never be done within
      -00082  * a probe. Use at module exit time.
      -00083  */
      -00084 
      -00085 void _stp_print_symbol(const char *fmt, unsigned long address)
      -00086 {
      -00087         char *modname;
      -00088         const char *name;
      -00089         unsigned long offset, size;
      -00090         char namebuf[KSYM_NAME_LEN+1];
      -00091 
      -00092         name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
      -00093 
      -00094         if (!name)
      -00095                 _stp_print_buf("0x%lx", address);
      -00096         else {
      -00097           if (modname)
      -00098             _stp_print_buf("%s+%#lx/%#lx [%s]", name, offset,
      -00099                            size, modname);
      -00100           else
      -00101             _stp_print_buf("%s+%#lx/%#lx", name, offset, size);
      -00102         }
      -00103 }
      -00104 
      -00105 /** Get the current return address.
      -00106  * Call from kprobes (not jprobes).
      -00107  * @param regs The pt_regs saved by the kprobe.
      -00108  * @return The return address saved in esp or rsp.
      -00109  * @note i386 and x86_64 only.
      -00110  */
      -00111  
      -00112 unsigned long cur_ret_addr (struct pt_regs *regs)
      -00113 {
      -00114 #ifdef __x86_64__
      -00115   unsigned long *ra = (unsigned long *)regs->rsp;
      -00116 #else
      -00117   unsigned long *ra = (unsigned long *)regs->esp;
      -00118 #endif
      -00119   if (ra)
      -00120     return *ra;
      -00121   else
      -00122     return 0;
      -00123 }
      -

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + +

      io.c

      Go to the documentation of this file.
      00001 #ifndef _IO_C_
      +00002 #define _IO_C_
      +00003 
      +00004 /* -*- linux-c -*- */
      +00005 /** @file io.c
      +00006  * @brief I/O functions
      +00007  */
      +00008 /** @addtogroup io I/O
      +00009  * I/O functions
      +00010  * @{
      +00011  */
      +00012 
      +00013 /** Logs Data.
      +00014  * This function is compatible with printk.  In fact it currently
      +00015  * sends all output to vprintk, after sending "STP: ". This allows
      +00016  * us to easily detect SystemTap output in the log file. 
      +00017  *
      +00018  * @param fmt A variable number of args.
      +00019  * @bug Lines are limited in length by printk buffer. If there is
      +00020  * no newline in the format string, then other syslog output could
      +00021  * get appended to the SystemTap line.
      +00022  * @todo Either deprecate or redefine this as a way to log debug or 
      +00023  * status messages, separate from the normal program output.
      +00024  */
      +00025 void dlog (const char *fmt, ...)
      +00026 {
      +00027   va_list args;
      +00028   printk("STP: ");
      +00029   va_start(args, fmt);
      +00030   vprintk(fmt, args);
      +00031   va_end(args);
      +00032 }
      +00033 
      +00034 /** Prints to the trace buffer.
      +00035  * This function uses the same formatting as printk.  It currently
      +00036  * writes to the system log. 
      +00037  *
      +00038  * @param fmt A variable number of args.
      +00039  * @todo Needs replaced with something much faster that does not
      +00040  * use the system log.
      +00041  */
      +00042 
      +00043 void _stp_print (const char *fmt, ...)
      +00044 {
      +00045   va_list args;
      +00046   va_start(args, fmt);
      +00047   vprintk(fmt, args);
      +00048   va_end(args);
      +00049 }
      +00050 
      +00051 /** Prints to the trace buffer.
      +00052  * This function will write a string to the trace buffer.  It currently
      +00053  * writes to the system log. 
      +00054  *
      +00055  * @param str String.
      +00056  * @todo Needs replaced with something much faster that does not
      +00057  * use the system log.
      +00058  */
      +00059 
      +00060 void _stp_print_str (char *str)
      +00061 {
      +00062   printk ("%s", str);
      +00063 }
      +00064 
      +00065 /** @} */
      +00066 #endif /* _IO_C_ */
      +
      diff --git a/runtime/docs/html/io_8c.html b/runtime/docs/html/io_8c.html index ca8818d3..3357e2f8 100644 --- a/runtime/docs/html/io_8c.html +++ b/runtime/docs/html/io_8c.html @@ -4,309 +4,27 @@ - +

      io.c File Reference

      I/O functions. More...

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

      Defines

      -#define STP_BUF_LEN   8191

      Functions

      void dlog (const char *fmt,...)
       Logs data.
      void _stp_print_buf (const char *fmt,...)
       Print into the print buffer.
      void _stp_print_buf_init (void)
       Clear the print buffer.
      void _stp_print_symbol (const char *fmt, unsigned long address)
      void dlog (const char *fmt,...)
       Print addresses symbolically into the print buffer.
      unsigned long cur_ret_addr (struct pt_regs *regs)
       Logs Data.
      void _stp_print (const char *fmt,...)
       Get the current return address.

      Variables

      static const char *(* _stp_kallsyms_lookup )(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf) = (void *)KALLSYMS_LOOKUP
       Lookup symbol.
      -static char _stp_pbuf [8191+1]
       Static buffer for printing.
      -static int _stp_pbuf_len = 8191
       Prints to the trace buffer.
      void _stp_print_str (char *str)
       Prints to the trace buffer.


      Detailed Description

      I/O functions.

      -Definition in file io.c.


      Function Documentation

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_print_buf const char *  fmt,
        ...
      -
      - - - - - -
      -   - - -

      -Print into the print buffer. -

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

      -

      Parameters:
      - - -
      fmt A variable number of args.
      -
      -
      Note:
      Formatting output should never be done within a probe. Use at module exit time.
      -
      See also:
      _stp_print_buf_init
      - -

      -Definition at line 55 of file io.c. -

      -References _stp_pbuf. -

      -Referenced by _stp_print_symbol().

      -

      - - - - -
      - - - - - - - - - -
      void _stp_print_buf_init void   ) 
      -
      - - - - - -
      -   - - -

      -Clear the print buffer. -

      -Output from _stp_print_buf() will accumulate in the buffer until this is called. -

      -Definition at line 72 of file io.c. -

      -References _stp_pbuf.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_print_symbol const char *  fmt,
      unsigned long  address
      -
      - - - - - -
      -   - - -

      -Print addresses symbolically into the print buffer. -

      -

      Parameters:
      - - - -
      fmt A variable number of args.
      address The address to lookup.
      -
      -
      Note:
      Formatting output should never be done within a probe. Use at module exit time.
      - -

      -Definition at line 85 of file io.c. -

      -References _stp_kallsyms_lookup, and _stp_print_buf().

      -

      - - - - -
      - - - - - - - - - -
      unsigned long cur_ret_addr struct pt_regs *  regs  ) 
      -
      - - - - - -
      -   - - -

      -Get the current return address. -

      -Call from kprobes (not jprobes).

      Parameters:
      - - -
      regs The pt_regs saved by the kprobe.
      -
      -
      Returns:
      The return address saved in esp or rsp.
      -
      Note:
      i386 and x86_64 only.
      - -

      -Definition at line 112 of file io.c.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void dlog const char *  fmt,
        ...
      -
      - - - - - -
      -   - - -

      -Logs data. -

      -This function is compatible with printk. In fact it currently sends all output to vprintk, after sending "STP: ". This allows us to easily detect SystemTap output in the log file.

      -

      Parameters:
      - - -
      fmt A variable number of args.
      -
      -
      Bug:
      Lines are limited in length by printk buffer.
      -

      -

      Todo:
      Needs replaced with something much faster that does not use the system log.
      - -

      -Definition at line 16 of file io.c. -

      -Referenced by _stp_list_clear(), _stp_register_jprobes(), _stp_register_kprobes(), _stp_unregister_jprobes(), and _stp_unregister_kprobes().

      -


      Variable Documentation

      -

      - - - - -
      - - - - -
      const char*(* _stp_kallsyms_lookup)(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf) = (void *)KALLSYMS_LOOKUP [static]
      -
      - - - - - -
      -   - - -

      -Lookup symbol. -

      -This simply calls the kernel function kallsyms_lookup(). That function is not exported, so this workaround is required. See the kernel source, kernel/kallsyms.c for more information. -

      -Definition at line 31 of file io.c. -

      -Referenced by _stp_print_symbol().

      -


      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +Definition in file io.c. diff --git a/runtime/docs/html/kprobe__where__funct_8c-source.html b/runtime/docs/html/kprobe__where__funct_8c-source.html index cccc3205..dbe9ac74 100644 --- a/runtime/docs/html/kprobe__where__funct_8c-source.html +++ b/runtime/docs/html/kprobe__where__funct_8c-source.html @@ -4,7 +4,7 @@ - +

      kprobe_where_funct.c

      00001 /* kprobe_where_funct.c
      @@ -16,75 +16,75 @@
       00007 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
       00008 #define BUCKETS 16              /* largest histogram width */
       00009 
      -00010 #include "runtime.h"
      +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;
      +00014 #include "current.c"
      +00015 #include "sym.c"
      +00016 
      +00017 MODULE_DESCRIPTION("SystemTap probe: where_func");
      +00018 MODULE_AUTHOR("Will Cohen and Martin Hunt");
      +00019 
      +00020 static char default_name[] = "schedule";
      +00021 static char *funct_name = default_name;
      +00022 module_param(funct_name, charp, 0);
      +00023 MODULE_PARM_DESC(funct_name, "function entry name.\n");
       00024 
      -00025 MAP funct_locations;
      +00025 static int count_funct = 0;
       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);
      +00027 MAP funct_locations;
      +00028 
      +00029 static int inst_funct(struct kprobe *p, struct pt_regs *regs)
      +00030 {
      +00031         long ret_addr = _stp_ret_addr(regs);
      +00032         ++count_funct;
      +00033         _stp_map_key_long(funct_locations, ret_addr);
      +00034         _stp_map_add_int64(funct_locations, 1);
      +00035         return 0;
      +00036 }
      +00037 
      +00038 /*For each probe you need to allocate a kprobe structure*/
      +00039 static struct kprobe kp[] = {
      +00040         {
      +00041                 .addr = default_name,
      +00042                 .pre_handler = inst_funct,
      +00043         }
      +00044 };
      +00045 #define MAX_KPROBES (sizeof(kp)/sizeof(struct kprobe))
      +00046 
      +00047 int init_module(void)
      +00048 {
      +00049         int ret;
       00050 
      -00051         if (funct_name)
      -00052                 kp[0].addr = funct_name;
      -00053 
      -00054         ret = _stp_register_kprobes (kp, MAX_KPROBES);
      +00051         funct_locations = _stp_map_new(1000, INT64);
      +00052 
      +00053         if (funct_name)
      +00054                 kp[0].addr = funct_name;
       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);
      +00056         ret = _stp_register_kprobes (kp, MAX_KPROBES);
      +00057 
      +00058         return ret;
      +00059 }
      +00060 
      +00061 void cleanup_module(void)
      +00062 {
      +00063         struct map_node_int64 *ptr;
       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 10:27:36 2005 for SystemTap. - +00065 _stp_unregister_kprobes (kp, MAX_KPROBES); +00066 +00067 dlog("%s() called %d times.\n", funct_name, count_funct); +00068 dlog("NUM\tCaller Addr\tCaller Name\n", funct_name); +00069 +00070 /* now walk the hash table and print out all the information */ +00071 foreach(funct_locations, ptr) { +00072 _stp_scbuf_clear(); +00073 _stp_symbol_sprint (key1int(ptr)); +00074 dlog("%lld\t0x%p\t(%s)\n", ptr->val, key1int(ptr), _stp_scbuf); +00075 } +00076 +00077 _stp_map_del(funct_locations); +00078 } +00079 +00080 MODULE_LICENSE("GPL"); + diff --git a/runtime/docs/html/map_8c-source.html b/runtime/docs/html/map_8c-source.html index 9d91bd68..1ff69e73 100644 --- a/runtime/docs/html/map_8c-source.html +++ b/runtime/docs/html/map_8c-source.html @@ -4,866 +4,885 @@ - -

      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 static int map_sizes[] = {
      -00007         sizeof(struct map_node_int64),
      -00008         sizeof(struct map_node_stat),
      -00009         sizeof(struct map_node_str),
      -00010         0
      -00011 };
      -00012 
      -00013 static unsigned string_hash(const char *key1, const char *key2)
      -00014 {
      -00015         int hash = 0, count = 0;
      -00016         char *v1 = (char *)key1;
      -00017         char *v2 = (char *)key2;
      -00018         while (*v1 && count++ < 5) {
      -00019                 hash += *v1++;
      -00020         }
      -00021         while (v2 && *v2 && count++ < 5) {
      -00022                 hash += *v2++;
      -00023         }
      -00024         return hash_long((unsigned long)hash, HASH_TABLE_BITS);
      -00025 }
      -00026 
      -00027 static unsigned mixed_hash(const char *key1, long key2)
      -00028 {
      -00029         int hash = 0, count = 0;
      -00030         char *v = (char *)key1;
      -00031         while (v && *v && count++ < 5)
      -00032                 hash += *v++;
      -00033         return hash_long((unsigned long)(hash ^ key2), HASH_TABLE_BITS);
      -00034 }
      -00035 
      -00036 /** Create a new map.
      -00037  * Maps must be created at module initialization time.
      -00038  * @param max_entries The maximum number of entries allowed. Currently that number will
      -00039  * be preallocated.  If more entries are required, the oldest ones will be deleted. This makes
      -00040  * it effectively a circular buffer.  If max_entries is 0, there will be no maximum and entries
      -00041  * will be allocated dynamically.
      -00042  * @param type Type of values stored in this map. 
      -00043  * @return A MAP on success or NULL on failure.
      -00044  */
      -00045 
      -00046 MAP _stp_map_new(unsigned max_entries, enum valtype type)
      -00047 {
      -00048         size_t size;
      -00049         MAP m = (MAP) _stp_valloc(sizeof(struct map_root));
      -00050         if (m == NULL)
      -00051                 return NULL;
      -00052 
      -00053         INIT_LIST_HEAD(&m->head);
      -00054 
      -00055         m->maxnum = max_entries;
      -00056         m->type = type;
      -00057         if (type >= END) {
      -00058                 dbug ("map_new: unknown type %d\n", type);
      -00059                 return NULL;
      -00060         }
      -00061 
      -00062         if (max_entries) {
      -00063                 void *tmp;
      -00064                 int i;
      -00065                 struct list_head *e;
      -00066 
      -00067                 INIT_LIST_HEAD(&m->pool);
      -00068                 size = map_sizes[type];
      -00069                 tmp = _stp_valloc(max_entries * size);
      -00070 
      -00071                 for (i = max_entries - 1; i >= 0; i--) {
      -00072                         e = i * size + tmp;
      -00073                         dbug ("e=%lx\n", (long)e);
      -00074                         list_add(e, &m->pool);
      -00075                 }
      -00076                 m->membuf = tmp;
      -00077         }
      -00078         return m;
      -00079 }
      -00080 
      -00081 static void map_free_strings(MAP map, struct map_node *n)
      -00082 {
      -00083         struct map_node_str *m = (struct map_node_str *)n;
      -00084         dbug ("n = %lx\n", (long)n);
      -00085         if (map->type == STRING) {
      -00086                 dbug ("val STRING %lx\n", (long)m->str);
      -00087                 if (m->str)
      -00088                         _stp_free(m->str);
      -00089         }
      -00090         if (m->n.key1type == STR) {
      -00091                 dbug ("key1 STR %lx\n", (long)key1str(m));
      -00092                 if (key1str(m))
      -00093                         _stp_free(key1str(m));
      -00094         }
      -00095         if (m->n.key2type == STR) {
      -00096                 dbug ("key2 STR %lx\n", (long)key2str(m));
      -00097                 if (key2str(m))
      -00098                         _stp_free(key2str(m));
      -00099         }
      -00100 }
      -00101 
      -00102 /** Deletes the current element.
      -00103  * If no current element (key) for this map is set, this function does nothing.
      -00104  * @param map 
      -00105  */
      -00106 
      -00107 void _stp_map_key_del(MAP map)
      -00108 {
      -00109         struct map_node *m;
      -00110 
      -00111         dbug ("create=%d key=%lx\n", map->create, (long)map->key);
      -00112         if (map == NULL)
      -00113                 return;
      -00114 
      -00115         if (map->create) {
      -00116                 map->create = 0;
      -00117                 map->key = NULL;
      -00118                 return;
      -00119         }
      -00120 
      -00121         if (map->key == NULL)
      -00122                 return;
      -00123 
      -00124         m = (struct map_node *)map->key;
      +
      +

      map.c

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

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +00824 /* remove node from old hash list */ +00825 hlist_del_init(&ptr->hnode); +00826 +00827 /* remove from entry list */ +00828 list_del(&ptr->lnode); +00829 +00830 /* remove any allocated string storage */ +00831 map_free_strings(map, ptr); +00832 +00833 if (map->maxnum) +00834 list_add(&ptr->lnode, &map->pool); +00835 else +00836 _stp_free(ptr); +00837 +00838 map->num--; +00839 ptr = next; +00840 } +00841 } +00842 +00843 if (map->num != 0) { +00844 dlog ("ERROR: list is supposed to be empty (has %d)\n", map->num); +00845 } +00846 } +00847 +00848 /** Adds a string to a list. +00849 * @param map +00850 * @param str +00851 */ +00852 +00853 inline void _stp_list_add_str(MAP map, char *str) +00854 { +00855 _stp_map_key_long(map, map->num); +00856 _stp_map_set_str(map, str); +00857 } +00858 +00859 /** Adds an int64 to a list. +00860 * @param map +00861 * @param val +00862 */ +00863 +00864 inline void _stp_list_add_int64(MAP map, int64_t val) +00865 { +00866 _stp_map_key_long(map, map->num); +00867 _stp_map_set_int64(map, val); +00868 } +00869 +00870 /** Get the number of elements in a list. +00871 * @param map +00872 * @returns The number of elements in a list. +00873 */ +00874 +00875 inline int _stp_list_size(MAP map) +00876 { +00877 return map->num; +00878 } +00879 /** @} */ +00880 #endif /* _MAP_C_ */ +
      diff --git a/runtime/docs/html/map_8c.html b/runtime/docs/html/map_8c.html index 6865ae63..f9bb262d 100644 --- a/runtime/docs/html/map_8c.html +++ b/runtime/docs/html/map_8c.html @@ -4,1301 +4,92 @@ - +

      map.c File Reference

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

      +#include "map.h"
      +#include "alloc.c"

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

      Functions

      -static unsigned string_hash (const char *key1, const char *key2)
      MAP _stp_map_new (unsigned max_entries, enum valtype type)
      -static unsigned mixed_hash (const char *key1, long key2)
       Create a new map.
      void _stp_map_key_del (MAP map)
      MAP _stp_map_new (unsigned max_entries, enum valtype type)
       Deletes the current element.
      map_node_stp_map_start (MAP map)
       Create a new map.
      -static void map_free_strings (MAP map, struct map_node *n)
       Get the first element in a map.
      map_node_stp_map_iter (MAP map, struct map_node *m)
      void _stp_map_key_del (MAP map)
       Get the next element in a map.
      void _stp_map_del (MAP map)
       Deletes the current element.
      map_node_stp_map_start (MAP map)
       Deletes a map.
      void _stp_map_key_long_long (MAP map, long key1, long key2)
       Get the first element in a map.
      map_node_stp_map_iter (MAP map, struct map_node *m)
       Set the map's key to two longs.
      void _stp_map_key_str_str (MAP map, char *key1, char *key2)
       Get the next element in a map.
      void _stp_map_del (MAP map)
       Set the map's key to two strings.
      void _stp_map_key_str_long (MAP map, char *key1, long key2)
       Deletes a map.
      void _stp_map_key_long_long (MAP map, long key1, long key2)
       Set the map's key to a string and a long.
      void _stp_map_key_long_str (MAP map, long key1, char *key2)
       Set the map's key to two longs.
      void _stp_map_key_str_str (MAP map, char *key1, char *key2)
       Set the map's key to a long and a string.
      void _stp_map_key_str (MAP map, char *key)
       Set the map's key to two strings.
      void _stp_map_key_str_long (MAP map, char *key1, long key2)
       Set the map's key to a string.
      void _stp_map_key_long (MAP map, long key)
       Set the map's key to a string and a long.
      void _stp_map_key_long_str (MAP map, long key1, char *key2)
       Set the map's key to a long.
      void _stp_map_set_int64 (MAP map, int64_t val)
       Set the map's key to a long and a string.
      void _stp_map_key_str (MAP map, char *key)
       Set the current element's value to an int64.
      void _stp_map_add_int64 (MAP map, int64_t val)
       Set the map's key to a string.
      void _stp_map_key_long (MAP map, long key)
       Adds an int64 to the current element's value.
      int64_t _stp_map_get_int64 (MAP map)
       Set the map's key to a long.
      -static void map_copy_keys (MAP map, struct map_node *m)
       Gets the current element's value.
      void _stp_map_set_str (MAP map, char *val)
      -static void __stp_map_set_int64 (MAP map, int64_t val, int add)
       Set the current element's value to a string.
      char * _stp_map_get_str (MAP map)
      void _stp_map_set_int64 (MAP map, int64_t val)
       Gets the current element's value.
      void _stp_map_set_stat (MAP map, stat *stats)
       Set the current element's value to an int64.
      void _stp_map_add_int64 (MAP map, int64_t val)
       Set the current element's value to a stat.
      stat_stp_map_get_stat (MAP map)
       Adds an int64 to the current element's value.
      int64_t _stp_map_get_int64 (MAP map)
       Gets the current element's value.
      void _stp_map_stat_add (MAP map, int64_t val)
       Gets the current element's value.
      void _stp_map_set_str (MAP map, char *val)
       Add to the current element's statistics.
      MAP _stp_list_new (unsigned max_entries, enum valtype type)
       Set the current element's value to a string.
      char * _stp_map_get_str (MAP map)
       Create a new list.
      void _stp_list_clear (MAP map)
       Gets the current element's value.
      void _stp_map_set_stat (MAP map, stat *stats)
       Clears a list.
      void _stp_list_add_str (MAP map, char *str)
       Set the current element's value to a stat.
      stat_stp_map_get_stat (MAP map)
       Adds a string to a list.
      void _stp_list_add_int64 (MAP map, int64_t val)
       Gets the current element's value.
      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)
       Create a new list.
      void _stp_list_clear (MAP map)
       Clears a list.
      void _stp_list_add_str (MAP map, char *str)
       Adds a string to a list.
      void _stp_list_add_int64 (MAP map, int64_t val)
       Adds an int64 to a list.
      int _stp_list_size (MAP map)
       Get the number of elements in a list.

      Variables

      static int map_sizes []
       Adds an int64 to a list.
      int _stp_list_size (MAP map)
       Get the number of elements in a list.


      Detailed Description

      Implements maps (associative arrays) and lists.

      -Definition in file map.c.


      Function Documentation

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_list_add_int64 MAP  map,
      int64_t  val
      [inline]
      -
      - - - - - -
      -   - - -

      -Adds an int64 to a list. -

      -

      Parameters:
      - - - -
      map 
      val 
      -
      - -

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

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

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_list_add_str MAP  map,
      char *  str
      [inline]
      -
      - - - - - -
      -   - - -

      -Adds a string to a list. -

      -

      Parameters:
      - - - -
      map 
      str 
      -
      - -

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

      -References _stp_map_key_long(), _stp_map_set_str(), and map_root::num. -

      -Referenced by _stp_copy_argv_from_user().

      -

      - - - - -
      - - - - - - - - - -
      void _stp_list_clear MAP  map  ) 
      -
      - - - - - -
      -   - - -

      -Clears a list. -

      -All elements in the list are deleted.

      Parameters:
      - - -
      map 
      -
      - -

      -Definition at line 794 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.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      MAP _stp_list_new unsigned  max_entries,
      enum valtype  type
      -
      - - - - - -
      -   - - -

      -Create a new list. -

      -A list is a map that internally has an incrementing long key for each member. Lists do not wrap if elements are added to exceed their maximum size.

      Parameters:
      - - - -
      max_entries The maximum number of entries allowed. Currently that number will be preallocated. If max_entries is 0, there will be no maximum and entries will be allocated dynamically.
      type Type of values stored in this list.
      -
      -
      Returns:
      A MAP on success or NULL on failure.
      -
      See also:
      foreach
      - -

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

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

      -

      - - - - -
      - - - - - - - - - -
      int _stp_list_size MAP  map  )  [inline]
      -
      - - - - - -
      -   - - -

      -Get the number of elements in a list. -

      -

      Parameters:
      - - -
      map 
      -
      -
      Returns:
      The number of elements in a list.
      - -

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

      -References map_root::num.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_map_add_int64 MAP  map,
      int64_t  val
      -
      - - - - - -
      -   - - -

      -Adds an int64 to the current element's value. -

      -This adds an int64 to the current element's value. The map must have been created to hold int64s using _stp_map_new()

      -If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

      Parameters:
      - - - -
      map 
      val value
      -
      -
      See also:
      _stp_map_set_int64
      - -

      -Definition at line 547 of file map.c.

      -

      - - - - -
      - - - - - - - - - -
      void _stp_map_del MAP  map  ) 
      -
      - - - - - -
      -   - - -

      -Deletes a map. -

      -Deletes a map, freeing all memory in all elements. Normally done only when the module exits.

      Parameters:
      - - -
      map 
      -
      - -

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

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

      -

      - - - - -
      - - - - - - - - - -
      int64_t _stp_map_get_int64 MAP  map  ) 
      -
      - - - - - -
      -   - - -

      -Gets the current element's value. -

      -

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

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

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

      -

      - - - - -
      - - - - - - - - - -
      stat* _stp_map_get_stat MAP  map  ) 
      -
      - - - - - -
      -   - - -

      -Gets the current element's value. -

      -

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

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

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

      -

      - - - - -
      - - - - - - - - - -
      char* _stp_map_get_str MAP  map  ) 
      -
      - - - - - -
      -   - - -

      -Gets the current element's value. -

      -

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

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

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

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      struct map_node* _stp_map_iter MAP  map,
      struct map_node m
      -
      - - - - - -
      -   - - -

      -Get the next element in a map. -

      -

      Parameters:
      - - - -
      map 
      m a pointer to the current element, returned from _stp_map_start() or _stp_map_iter().
      -
      -
      Returns:
      a pointer to the next element. This is typically used with _stp_map_start(). See the foreach() macro for typical usage. It probably does what you want anyway.
      -
      See also:
      foreach
      - -

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

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

      -

      - - - - -
      - - - - - - - - - -
      void _stp_map_key_del MAP  map  ) 
      -
      - - - - - -
      -   - - -

      -Deletes the current element. -

      -If no current element (key) for this map is set, this function does nothing.

      Parameters:
      - - -
      map 
      -
      - -

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

      -References _stp_free(), map_node::hnode, and map_node::lnode. -

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

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_map_key_long MAP  map,
      long  key
      -
      - - - - - -
      -   - - -

      -Set the map's key to a long. -

      -This sets the current element based on a long key. If the key is not found, a new element will not be created until a _stp_map_set_xxx call.

      Parameters:
      - - - -
      map 
      key 
      -
      - -

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

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

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

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - -
      void _stp_map_key_long_long MAP  map,
      long  key1,
      long  key2
      -
      - - - - - -
      -   - - -

      -Set the map's key to two longs. -

      -This sets the current element based on a key of two strings. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

      Parameters:
      - - - - -
      map 
      key1 first key
      key2 second key
      -
      - -

      -Definition at line 222 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, map_root::hashes, map_root::key, map_node::key1, and key_data::val. -

      -Referenced by _stp_map_key_long().

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - -
      void _stp_map_key_long_str MAP  map,
      long  key1,
      char *  key2
      -
      - - - - - -
      -   - - -

      -Set the map's key to a long and a string. -

      -This sets the current element based on a key of a long and a string. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

      Parameters:
      - - - - -
      map 
      key1 first key
      key2 second key
      -
      - -

      -Definition at line 362 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, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_map_key_str MAP  map,
      char *  key
      -
      - - - - - -
      -   - - -

      -Set the map's key to a string. -

      -This sets the current element based on a string key. If the key is not found, a new element will not be created until a _stp_map_set_xxx call.

      Parameters:
      - - - -
      map 
      key 
      -
      - -

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

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

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - -
      void _stp_map_key_str_long MAP  map,
      char *  key1,
      long  key2
      -
      - - - - - -
      -   - - -

      -Set the map's key to a string and a long. -

      -This sets the current element based on a key of a string and a long. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

      Parameters:
      - - - - -
      map 
      key1 first key
      key2 second key
      -
      - -

      -Definition at line 314 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, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - - - - - - - -
      void _stp_map_key_str_str MAP  map,
      char *  key1,
      char *  key2
      -
      - - - - - -
      -   - - -

      -Set the map's key to two strings. -

      -This sets the current element based on a key of two strings. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

      Parameters:
      - - - - -
      map 
      key1 first key
      key2 second key
      -
      - -

      -Definition at line 265 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, map_root::hashes, map_root::key, map_node::key1, map_node::key2, and key_data::str. -

      -Referenced by _stp_map_key_str().

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      MAP _stp_map_new unsigned  max_entries,
      enum valtype  type
      -
      - - - - - -
      -   - - -

      -Create a new map. -

      -Maps must be created at module initialization time.

      Parameters:
      - - - -
      max_entries The maximum number of entries allowed. Currently that number will be preallocated. If more entries are required, the oldest ones will be deleted. This makes it effectively a circular buffer. If max_entries is 0, there will be no maximum and entries will be allocated dynamically.
      type Type of values stored in this map.
      -
      -
      Returns:
      A MAP on success or NULL on failure.
      - -

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

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

      -Referenced by _stp_list_new().

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_map_set_int64 MAP  map,
      int64_t  val
      -
      - - - - - -
      -   - - -

      -Set the current element's value to an int64. -

      -This sets the current element's value to an int64. The map must have been created to hold int64s using _stp_map_new()

      -If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

      Parameters:
      - - - -
      map 
      val new value
      -
      -
      See also:
      _stp_map_add_int64
      - -

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

      -Referenced by _stp_list_add_int64().

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_map_set_stat MAP  map,
      stat stats
      -
      - - - - - -
      -   - - -

      -Set the current element's value to a stat. -

      -This sets the current element's value to an stat struct. The map must have been created to hold stats using _stp_map_new(xxx, STAT). This function would only be used if we wanted to set stats to something other than the normal initial values (count = 0, sum = 0, etc). It may be deleted if it doesn't turn out to be useful.

      See also:
      _stp_map_stat_add
      -If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.
      Parameters:
      - - - -
      map 
      stats pointer to stats struct.
      -
      -
      Todo:
      Histograms don't work yet.
      - -

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

      -References _stp_calloc(), _stp_map_key_del(), map_root::create, 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. -

      -Referenced by _stp_map_stat_add().

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_map_set_str MAP  map,
      char *  val
      -
      - - - - - -
      -   - - -

      -Set the current element's value to a string. -

      -This sets the current element's value to an string. The map must have been created to hold int64s using _stp_map_new(xxx, STRING)

      -If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

      Parameters:
      - - - -
      map 
      val new string
      -
      - -

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

      -References _stp_alloc(), _stp_calloc(), _stp_free(), _stp_map_key_del(), map_root::create, 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. -

      -Referenced by _stp_list_add_str().

      -

      - - - - -
      - - - - - - - - - -
      struct map_node* _stp_map_start MAP  map  ) 
      -
      - - - - - -
      -   - - -

      -Get the first element in a map. -

      -

      Parameters:
      - - -
      map 
      -
      -
      Returns:
      a pointer to the first element. This is typically used with _stp_map_iter(). See the foreach() macro for typical usage. It probably does what you want anyway.
      -
      See also:
      foreach
      - -

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

      -References map_root::head.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void _stp_map_stat_add MAP  map,
      int64_t  val
      -
      - - - - - -
      -   - - -

      -Add to the current element's statistics. -

      -Increments the statistics counter by one and the sum by val. Adjusts minimum, maximum, and histogram.

      -If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

      Parameters:
      - - - -
      map 
      val value to add to the statistics
      -
      -
      Todo:
      Histograms don't work yet.
      - -

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

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

      -


      Variable Documentation

      -

      - - - - -
      - - - - -
      int map_sizes[] [static]
      -
      - - - - - -
      -   - - -

      -Initial value:

       {
      -        sizeof(struct map_node_int64),
      -        sizeof(struct map_node_stat),
      -        sizeof(struct map_node_str),
      -        0
      -}
      -
      -

      -Definition at line 6 of file map.c.

      -


      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +Definition in file map.c. diff --git a/runtime/docs/html/map_8h-source.html b/runtime/docs/html/map_8h-source.html index 26b210d2..94c29074 100644 --- a/runtime/docs/html/map_8h-source.html +++ b/runtime/docs/html/map_8h-source.html @@ -4,186 +4,194 @@ - -

      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 typedef struct {
      -00010         int64_t count;
      -00011         int64_t sum;
      -00012         int64_t min, max;
      -00013         int64_t histogram[BUCKETS];
      -00014 } stat;
      -00015 
      -00016 /** Keys are either longs or char * */
      -00017 union key_data {
      -00018         long val;
      -00019         char *str;
      -00020 };
      +
      +

      map.h

      Go to the documentation of this file.
      00001 #ifndef _MAP_H_
      +00002 #define _MAP_H_
      +00003 /* -*- linux-c -*- */
      +00004 
      +00005 /** @file map.h
      +00006  * @brief Header file for maps and lists 
      +00007  */
      +00008 /** @addtogroup maps 
      +00009  * @{ 
      +00010  */
      +00011 
      +00012 #include <linux/types.h>
      +00013 
      +00014 /** Statistics are stored in this struct */
      +00015 typedef struct {
      +00016         int64_t count;
      +00017         int64_t sum;
      +00018         int64_t min, max;
      +00019         int64_t histogram[BUCKETS];
      +00020 } stat;
       00021 
      -00022 /** keys can be longs or strings */
      -00023 enum keytype { NONE, LONG, STR } __attribute__ ((packed));
      -00024 /** values can be either int64, stats or strings */
      -00025 enum valtype { INT64, STAT, STRING, END };
      -00026 
      +00022 /** Keys are either longs or char * */
      +00023 union key_data {
      +00024         long val;
      +00025         char *str;
      +00026 };
       00027 
      -00028 /** basic map element */
      -00029 struct map_node {
      -00030         /** list of other nodes in the map */
      -00031         struct list_head lnode;
      -00032         /** list of nodes with the same hash value */
      -00033         struct hlist_node hnode; 
      -00034         union key_data key1;
      -00035         union key_data key2;
      -00036         enum keytype key1type;
      -00037         enum keytype key2type;
      -00038 };
      -00039 
      -00040 /** map element containing int64 */
      -00041 struct map_node_int64 {
      -00042         struct map_node n;
      -00043         int64_t val;
      +00028 /** keys can be longs or strings */
      +00029 enum keytype { NONE, LONG, STR } __attribute__ ((packed));
      +00030 /** values can be either int64, stats or strings */
      +00031 enum valtype { INT64, STAT, STRING, END };
      +00032 
      +00033 
      +00034 /** basic map element */
      +00035 struct map_node {
      +00036         /** list of other nodes in the map */
      +00037         struct list_head lnode;
      +00038         /** list of nodes with the same hash value */
      +00039         struct hlist_node hnode; 
      +00040         union key_data key1;
      +00041         union key_data key2;
      +00042         enum keytype key1type;
      +00043         enum keytype key2type;
       00044 };
       00045 
      -00046 /** map element containing string */
      -00047 struct map_node_str {
      +00046 /** map element containing int64 */
      +00047 struct map_node_int64 {
       00048         struct map_node n;
      -00049         char *str;
      +00049         int64_t val;
       00050 };
       00051 
      -00052 /** map element containing stats */
      -00053 struct map_node_stat {
      +00052 /** map element containing string */
      +00053 struct map_node_str {
       00054         struct map_node n;
      -00055         stat stats;
      +00055         char *str;
       00056 };
       00057 
      -00058 /** This structure contains all information about a map.
      -00059  * It is allocated once when _stp_map_new() is called. 
      -00060  */
      -00061 struct map_root {
      -00062         /** type of the values stored in the array */
      -00063         enum valtype type;
      -00064         
      -00065         /** maximum number of elements allowed in the array. */
      -00066         int maxnum;
      -00067 
      -00068         /** current number of used elements */
      -00069         int num;
      -00070 
      -00071         /** when more than maxnum elements, wrap or discard? */
      -00072         int no_wrap;
      +00058 /** map element containing stats */
      +00059 struct map_node_stat {
      +00060         struct map_node n;
      +00061         stat stats;
      +00062 };
      +00063 
      +00064 /** This structure contains all information about a map.
      +00065  * It is allocated once when _stp_map_new() is called. 
      +00066  */
      +00067 struct map_root {
      +00068         /** type of the values stored in the array */
      +00069         enum valtype type;
      +00070         
      +00071         /** maximum number of elements allowed in the array. */
      +00072         int maxnum;
       00073 
      -00074         /** linked list of current entries */
      -00075         struct list_head head;
      +00074         /** current number of used elements */
      +00075         int num;
       00076 
      -00077         /** pool of unused entries.  Used only when entries are statically allocated
      -00078             at startup. */
      -00079         struct list_head pool;
      -00080 
      -00081         /** saved key entry for lookups */
      -00082         struct map_node *key;
      -00083 
      -00084         /** this is the creation data saved between the key functions and the
      -00085             set/get functions 
      -00086             @todo Needs to be per-cpu data for SMP support */
      -00087         u_int8_t create;
      -00088         enum keytype c_key1type;
      -00089         enum keytype c_key2type;
      -00090         struct hlist_head *c_keyhead;
      -00091         union key_data c_key1;
      -00092         union key_data c_key2;
      -00093 
      -00094         /** the hash table for this array */
      -00095         struct hlist_head hashes[HASH_TABLE_SIZE];
      -00096 
      -00097         /** pointer to allocated memory space. Used for freeing memory. */
      -00098         void *membuf;
      -00099 };
      -00100 
      -00101 /** All maps are of this type. */
      -00102 typedef struct map_root *MAP;
      -00103 
      -00104 /** Extracts string from key1 union */
      -00105 #define key1str(ptr) (ptr->n.key1.str)
      -00106 /** Extracts string from key2 union */
      -00107 #define key2str(ptr) (ptr->n.key2.str)
      -00108 /** Extracts int from key1 union */
      -00109 #define key1int(ptr) (ptr->n.key1.val)
      -00110 /** Extracts int from key2 union */
      -00111 #define key2int(ptr) (ptr->n.key2.val)
      -00112 
      -00113 /** Macro to call the proper _stp_map_key functions based on the
      -00114  * types of the arguments. 
      -00115  * @note May cause compiler warning on some GCCs 
      -00116  */
      -00117 #define _stp_map_key2(map, key1, key2)                          \
      -00118   ({                                                            \
      -00119     if (__builtin_types_compatible_p (typeof (key1), char[]))   \
      -00120       if (__builtin_types_compatible_p (typeof (key2), char[])) \
      -00121         _stp_map_key_str_str (map, (char *)(key1), (char *)(key2));     \
      -00122       else                                                      \
      -00123         _stp_map_key_str_long (map, (char *)(key1), (long)(key2));      \
      -00124     else                                                        \
      -00125       if (__builtin_types_compatible_p (typeof (key2), char[])) \
      -00126         _stp_map_key_long_str (map, (long)(key1), (char *)(key2));      \
      -00127       else                                                      \
      -00128         _stp_map_key_long_long (map, (long)(key1), (long)(key2));       \
      -00129   })
      -00130 
      -00131 /** Macro to call the proper _stp_map_key function based on the
      -00132  * type of the argument. 
      -00133  * @note May cause compiler warning on some GCCs 
      -00134  */
      -00135 #define _stp_map_key(map, key)                          \
      -00136   ({                                                            \
      -00137     if (__builtin_types_compatible_p (typeof (key), char[]))    \
      -00138       _stp_map_key_str (map, (char *)(key));                            \
      -00139     else                                                        \
      -00140       _stp_map_key_long (map, (long)(key));                             \
      -00141   })
      -00142 
      -00143 /** Macro to call the proper _stp_map_set function based on the
      -00144  * type of the argument. 
      -00145  * @note May cause compiler warning on some GCCs 
      -00146  */
      -00147 #define _stp_map_set(map, val)                          \
      -00148   ({                                                            \
      -00149     if (__builtin_types_compatible_p (typeof (val), char[]))    \
      -00150       _stp_map_set_str (map, (char *)(val));                            \
      -00151     else                                                        \
      -00152       _stp_map_set_int64 (map, (int64_t)(val));                 \
      -00153   })
      -00154 
      -00155 /** Macro to call the proper _stp_list_add function based on the
      -00156  * types of the argument. 
      -00157  * @note May cause compiler warning on some GCCs 
      -00158  */
      -00159 #define _stp_list_add(map, val)                         \
      -00160   ({                                                            \
      -00161     if (__builtin_types_compatible_p (typeof (val), char[]))    \
      -00162       _stp_list_add_str (map, (char *)(val));                           \
      -00163     else                                                        \
      -00164       _stp_list_add_int64 (map, (int64_t)(val));                        \
      -00165   })
      -00166 
      -00167 
      -00168 /** Loop through all elements of a map.
      -00169  * @param map 
      -00170  * @param ptr pointer to a map_node_stat, map_node_int64 or map_node_str
      -00171  *
      -00172  * @b Example:
      -00173  * @include foreach.c
      -00174  */
      -00175 
      -00176 #define foreach(map, ptr)                               \
      -00177   for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \
      -00178        ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr))
      -00179 
      -

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +00077 /** when more than maxnum elements, wrap or discard? */ +00078 int no_wrap; +00079 +00080 /** linked list of current entries */ +00081 struct list_head head; +00082 +00083 /** pool of unused entries. Used only when entries are statically allocated +00084 at startup. */ +00085 struct list_head pool; +00086 +00087 /** saved key entry for lookups */ +00088 struct map_node *key; +00089 +00090 /** this is the creation data saved between the key functions and the +00091 set/get functions +00092 @todo Needs to be per-cpu data for SMP support */ +00093 u_int8_t create; +00094 enum keytype c_key1type; +00095 enum keytype c_key2type; +00096 struct hlist_head *c_keyhead; +00097 union key_data c_key1; +00098 union key_data c_key2; +00099 +00100 /** the hash table for this array */ +00101 struct hlist_head hashes[HASH_TABLE_SIZE]; +00102 +00103 /** pointer to allocated memory space. Used for freeing memory. */ +00104 void *membuf; +00105 }; +00106 +00107 /** All maps are of this type. */ +00108 typedef struct map_root *MAP; +00109 +00110 /** Extracts string from key1 union */ +00111 #define key1str(ptr) (ptr->n.key1.str) +00112 /** Extracts string from key2 union */ +00113 #define key2str(ptr) (ptr->n.key2.str) +00114 /** Extracts int from key1 union */ +00115 #define key1int(ptr) (ptr->n.key1.val) +00116 /** Extracts int from key2 union */ +00117 #define key2int(ptr) (ptr->n.key2.val) +00118 +00119 /** Macro to call the proper _stp_map_key functions based on the +00120 * types of the arguments. +00121 * @note May cause compiler warning on some GCCs +00122 */ +00123 #define _stp_map_key2(map, key1, key2) \ +00124 ({ \ +00125 if (__builtin_types_compatible_p (typeof (key1), char[])) \ +00126 if (__builtin_types_compatible_p (typeof (key2), char[])) \ +00127 _stp_map_key_str_str (map, (char *)(key1), (char *)(key2)); \ +00128 else \ +00129 _stp_map_key_str_long (map, (char *)(key1), (long)(key2)); \ +00130 else \ +00131 if (__builtin_types_compatible_p (typeof (key2), char[])) \ +00132 _stp_map_key_long_str (map, (long)(key1), (char *)(key2)); \ +00133 else \ +00134 _stp_map_key_long_long (map, (long)(key1), (long)(key2)); \ +00135 }) +00136 +00137 /** Macro to call the proper _stp_map_key function based on the +00138 * type of the argument. +00139 * @note May cause compiler warning on some GCCs +00140 */ +00141 #define _stp_map_key(map, key) \ +00142 ({ \ +00143 if (__builtin_types_compatible_p (typeof (key), char[])) \ +00144 _stp_map_key_str (map, (char *)(key)); \ +00145 else \ +00146 _stp_map_key_long (map, (long)(key)); \ +00147 }) +00148 +00149 /** Macro to call the proper _stp_map_set function based on the +00150 * type of the argument. +00151 * @note May cause compiler warning on some GCCs +00152 */ +00153 #define _stp_map_set(map, val) \ +00154 ({ \ +00155 if (__builtin_types_compatible_p (typeof (val), char[])) \ +00156 _stp_map_set_str (map, (char *)(val)); \ +00157 else \ +00158 _stp_map_set_int64 (map, (int64_t)(val)); \ +00159 }) +00160 +00161 /** Loop through all elements of a map or list. +00162 * @param map +00163 * @param ptr pointer to a map_node_stat, map_node_int64 or map_node_str +00164 * +00165 * @b Example: +00166 * @include foreach.c +00167 */ +00168 +00169 #define foreach(map, ptr) \ +00170 for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \ +00171 ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr)) +00172 +00173 /** @} */ +00174 +00175 /** @ingroup lists +00176 * @brief Macro to call the proper _stp_list_add function based on the +00177 * types of the argument. +00178 * +00179 * @note May cause compiler warning on some GCCs +00180 */ +00181 #define _stp_list_add(map, val) \ +00182 ({ \ +00183 if (__builtin_types_compatible_p (typeof (val), char[])) \ +00184 _stp_list_add_str (map, (char *)(val)); \ +00185 else \ +00186 _stp_list_add_int64 (map, (int64_t)(val)); \ +00187 }) +00188 +00189 #endif /* _MAP_H_ */ +
      diff --git a/runtime/docs/html/map_8h.html b/runtime/docs/html/map_8h.html index 849dfff4..8bede3a0 100644 --- a/runtime/docs/html/map_8h.html +++ b/runtime/docs/html/map_8h.html @@ -4,7 +4,7 @@ - +

      map.h File Reference

      Header file for maps and lists. More...

      #include <linux/types.h>
      @@ -13,50 +13,50 @@ Go to the source code of this file. - + - + - + - + - + - - + + - - + + - - + + - - + + - + - + - - - +

      Defines

      -#define key1str(ptr)   (ptr->n.key1.str)
      +#define key1str(ptr)   (ptr->n.key1.str)
       Extracts string from key1 union.
      -#define key2str(ptr)   (ptr->n.key2.str)
      +#define key2str(ptr)   (ptr->n.key2.str)
       Extracts string from key2 union.
      -#define key1int(ptr)   (ptr->n.key1.val)
      +#define key1int(ptr)   (ptr->n.key1.val)
       Extracts int from key1 union.
      -#define key2int(ptr)   (ptr->n.key2.val)
      +#define key2int(ptr)   (ptr->n.key2.val)
       Extracts int from key2 union.
      #define _stp_map_key2(map, key1, key2)
      #define _stp_map_key2(map, key1, key2)
       Macro to call the proper _stp_map_key functions based on the types of the arguments.
      #define _stp_map_key(map, key)
       Macro to call the proper _stp_map_key functions based on the types of the arguments.
      #define _stp_map_key(map, key)
       Macro to call the proper _stp_map_key function based on the type of the argument.
      #define _stp_map_set(map, val)
       Macro to call the proper _stp_map_key function based on the type of the argument.
      #define _stp_map_set(map, val)
       Macro to call the proper _stp_map_set function based on the type of the argument.
      #define _stp_list_add(map, val)
       Macro to call the proper _stp_map_set function based on the type of the argument.
      #define foreach(map, ptr)
       Macro to call the proper _stp_list_add function based on the types of the argument.
      #define foreach(map, ptr)
       Loop through all elements of a map or list.
      #define _stp_list_add(map, val)
       Loop through all elements of a map.
       Macro to call the proper _stp_list_add function based on the types of the argument.

      Typedefs

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

      Enumerations

      enum  keytype { NONE, +
      enum  keytype { NONE, LONG, STR }
       keys can be longs or strings
      enum  valtype { INT64, +
      enum  valtype { INT64, STAT, STRING, END @@ -64,8 +64,8 @@ typedef map_root values can be either int64, stats or strings

      Variables

      -enum keytype packed
      +enum keytype packed
       keys can be longs or strings
      @@ -74,236 +74,4 @@ Header file for maps and lists.

      -Definition in file map.h.


      Define Documentation

      -

      - - - - -
      - - - - - - - - - - - - -
      #define _stp_list_add map,
      val   ) 
      -
      - - - - - -
      -   - - -

      -Value:

      ({                                                              \
      -    if (__builtin_types_compatible_p (typeof (val), char[]))    \
      -      _stp_list_add_str (map, (char *)(val));                           \
      -    else                                                        \
      -      _stp_list_add_int64 (map, (int64_t)(val));                        \
      -  })
      -
      Macro to call the proper _stp_list_add function based on the types of the argument. -

      -

      Note:
      May cause compiler warning on some GCCs
      - -

      -Definition at line 159 of file map.h.

      -

      - - - - -
      - - - - - - - - - - - - -
      #define _stp_map_key map,
      key   ) 
      -
      - - - - - -
      -   - - -

      -Value:

      ({                                                              \
      -    if (__builtin_types_compatible_p (typeof (key), char[]))    \
      -      _stp_map_key_str (map, (char *)(key));                            \
      -    else                                                        \
      -      _stp_map_key_long (map, (long)(key));                             \
      -  })
      -
      Macro to call the proper _stp_map_key function based on the type of the argument. -

      -

      Note:
      May cause compiler warning on some GCCs
      - -

      -Definition at line 135 of file map.h.

      -

      - - - - -
      - - - - - - - - - - - - - - - -
      #define _stp_map_key2 map,
      key1,
      key2   ) 
      -
      - - - - - -
      -   - - -

      -Value:

      ({                                                              \
      -    if (__builtin_types_compatible_p (typeof (key1), char[]))   \
      -      if (__builtin_types_compatible_p (typeof (key2), char[])) \
      -        _stp_map_key_str_str (map, (char *)(key1), (char *)(key2));     \
      -      else                                                      \
      -        _stp_map_key_str_long (map, (char *)(key1), (long)(key2));      \
      -    else                                                        \
      -      if (__builtin_types_compatible_p (typeof (key2), char[])) \
      -        _stp_map_key_long_str (map, (long)(key1), (char *)(key2));      \
      -      else                                                      \
      -        _stp_map_key_long_long (map, (long)(key1), (long)(key2));       \
      -  })
      -
      Macro to call the proper _stp_map_key functions based on the types of the arguments. -

      -

      Note:
      May cause compiler warning on some GCCs
      - -

      -Definition at line 117 of file map.h.

      -

      - - - - -
      - - - - - - - - - - - - -
      #define _stp_map_set map,
      val   ) 
      -
      - - - - - -
      -   - - -

      -Value:

      ({                                                              \
      -    if (__builtin_types_compatible_p (typeof (val), char[]))    \
      -      _stp_map_set_str (map, (char *)(val));                            \
      -    else                                                        \
      -      _stp_map_set_int64 (map, (int64_t)(val));                 \
      -  })
      -
      Macro to call the proper _stp_map_set function based on the type of the argument. -

      -

      Note:
      May cause compiler warning on some GCCs
      - -

      -Definition at line 147 of file map.h.

      -

      - - - - -
      - - - - - - - - - - - - -
      #define foreach map,
      ptr   ) 
      -
      - - - - - -
      -   - - -

      -Value:

      for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \
      -       ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr))
      -
      Loop through all elements of a map. -

      -

      Parameters:
      - - - -
      map 
      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;
      -
      -foreach (map, ptr)
      -     printf ("map[%s,%ld] = [c=%lld s=%lld min=%lld max=%lld]\n", key1str(ptr), 
      -             key2int(ptr), ptr->stats.count, ptr->stats.sum, ptr->stats.min, 
      -             ptr->stats.max);
      -
      -
      -

      -Definition at line 176 of file map.h.

      -


      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +Definition in file map.h. diff --git a/runtime/docs/html/modules.html b/runtime/docs/html/modules.html new file mode 100644 index 00000000..32f1541b --- /dev/null +++ b/runtime/docs/html/modules.html @@ -0,0 +1,19 @@ + + +SystemTap: Module Index + + + + +

      SystemTap Modules

      Here is a list of all modules: + diff --git a/runtime/docs/html/pages.html b/runtime/docs/html/pages.html index 1357fe26..bca54ad4 100644 --- a/runtime/docs/html/pages.html +++ b/runtime/docs/html/pages.html @@ -4,13 +4,11 @@ - +

      SystemTap Related Pages

      Here is a list of all related documentation pages: -
      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/probes_2README-source.html b/runtime/docs/html/probes_2README-source.html index 9f0d714a..572047bc 100644 --- a/runtime/docs/html/probes_2README-source.html +++ b/runtime/docs/html/probes_2README-source.html @@ -4,13 +4,11 @@ - +

      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 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/probes_2shellsnoop_2README-source.html b/runtime/docs/html/probes_2shellsnoop_2README-source.html index 25dfde60..f629ded8 100644 --- a/runtime/docs/html/probes_2shellsnoop_2README-source.html +++ b/runtime/docs/html/probes_2shellsnoop_2README-source.html @@ -4,7 +4,7 @@ - +

      README

      00001 /** @dir shellsnoop
      @@ -34,7 +34,7 @@
       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);
      +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] */
      @@ -74,12 +74,10 @@
       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);
      +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 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/probes_2tasklet_2README-source.html b/runtime/docs/html/probes_2tasklet_2README-source.html index c42d0a1a..7d09aa4e 100644 --- a/runtime/docs/html/probes_2tasklet_2README-source.html +++ b/runtime/docs/html/probes_2tasklet_2README-source.html @@ -4,7 +4,7 @@ - +

      README

      00001 /** @dir tasklet
      @@ -17,6 +17,4 @@
       00008 \endverbatim
       00009 
       00010 */
      -

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/probes_2test4_2README-source.html b/runtime/docs/html/probes_2test4_2README-source.html index 17cd7350..69aa4539 100644 --- a/runtime/docs/html/probes_2test4_2README-source.html +++ b/runtime/docs/html/probes_2test4_2README-source.html @@ -4,7 +4,7 @@ - +

      README

      00001 /** @dir test4
      @@ -31,6 +31,4 @@
       00022 }
       00023 \endverbatim
       00024 */
      -

      -Generated on Tue Mar 22 10:27:36 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 index 7752c02d..6f9699ad 100644 --- a/runtime/docs/html/probes_2where__func_2README-source.html +++ b/runtime/docs/html/probes_2where__func_2README-source.html @@ -4,7 +4,7 @@ - +

      README

      00001 /** @dir where_func
      @@ -33,6 +33,4 @@
       00024 \endcode
       00025 -Will Cohen
       00026 */
      -

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/probes_8c-source.html b/runtime/docs/html/probes_8c-source.html index 5fe6164c..ab2b831b 100644 --- a/runtime/docs/html/probes_8c-source.html +++ b/runtime/docs/html/probes_8c-source.html @@ -4,7 +4,7 @@ - +

      probes.c

      Go to the documentation of this file.
      00001 /* -*- linux-c -*- */
       00002 /** @file probes.c
       00003  * @brief Functions to assist loading and unloading groups of probes.
      @@ -15,7 +15,7 @@
       00008  * That function is not exported, so this workaround is required.
       00009  * See the kernel source, kernel/kallsyms.c for more information.
       00010  */
      -00011 static unsigned long (*_stp_lookup_name)(char *name)=(void *)KALLSYMS_LOOKUP_NAME;
      +00011 static unsigned long (*_stp_lookup_name)(char *name)=(void *)KALLSYMS_LOOKUP_NAME;
       00012 
       00013 /** Unregister a group of jprobes.
       00014  * @param probes Pointer to an array of struct jprobe.
      @@ -27,7 +27,7 @@
       00020         int i;
       00021         for (i = 0; i < num_probes; i++)
       00022                 unregister_jprobe(&probes[i]);
      -00023         dlog ("All jprobes removed\n");
      +00023         dlog ("All jprobes removed\n");
       00024 }
       00025 
       00026 /** Register a group of jprobes.
      @@ -42,14 +42,14 @@
       00035         unsigned long addr;
       00036 
       00037         for (i = 0; i < num_probes; i++) {
      -00038                 addr =_stp_lookup_name((char *)probes[i].kp.addr);
      +00038                 addr =_stp_lookup_name((char *)probes[i].kp.addr);
       00039                 if (addr == 0) {
      -00040                         dlog ("ERROR: function %s not found!\n", 
      +00040                         dlog ("ERROR: function %s not found!\n", 
       00041                               (char *)probes[i].kp.addr);
       00042                         ret = -1; /* FIXME */
       00043                         goto out;
       00044                 }
      -00045                 dlog("inserting jprobe at %s (%p)\n", probes[i].kp.addr, addr);
      +00045                 dlog("inserting jprobe at %s (%p)\n", probes[i].kp.addr, addr);
       00046                 probes[i].kp.addr = (kprobe_opcode_t *)addr;
       00047                 ret = register_jprobe(&probes[i]);
       00048                 if (ret)
      @@ -57,7 +57,7 @@
       00050         }
       00051         return 0;
       00052 out:
      -00053         dlog ("probe module initialization failed.  Exiting...\n");
      +00053         dlog ("probe module initialization failed.  Exiting...\n");
       00054         _stp_unregister_jprobes(probes, i);
       00055         return ret;
       00056 }
      @@ -72,7 +72,7 @@
       00065         int i;
       00066         for (i = 0; i < num_probes; i++)
       00067                 unregister_kprobe(&probes[i]);
      -00068         dlog ("All kprobes removed\n");
      +00068         dlog ("All kprobes removed\n");
       00069 }
       00070 
       00071 /** Register a group of kprobes.
      @@ -87,14 +87,14 @@
       00080         unsigned long addr;
       00081 
       00082         for (i = 0; i < num_probes; i++) {
      -00083                 addr =_stp_lookup_name((char *)probes[i].addr);
      +00083                 addr =_stp_lookup_name((char *)probes[i].addr);
       00084                 if (addr == 0) {
      -00085                         dlog ("ERROR: function %s not found!\n", 
      +00085                         dlog ("ERROR: function %s not found!\n", 
       00086                               (char *)probes[i].addr);
       00087                         ret = -1; /* FIXME */
       00088                         goto out;
       00089                 }
      -00090                 dlog("inserting kprobe at %s (%p)\n", probes[i].addr, addr);
      +00090                 dlog("inserting kprobe at %s (%p)\n", probes[i].addr, addr);
       00091                 probes[i].addr = (kprobe_opcode_t *)addr;
       00092                 ret = register_kprobe(&probes[i]);
       00093                 if (ret)
      @@ -102,11 +102,9 @@
       00095         }
       00096         return 0;
       00097 out:
      -00098         dlog ("probe module initialization failed.  Exiting...\n");
      +00098         dlog ("probe module initialization failed.  Exiting...\n");
       00099         _stp_unregister_kprobes(probes, i);
       00100         return ret;
       00101 }
       00102 
      -

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/probes_8c.html b/runtime/docs/html/probes_8c.html index 8a13bb24..5bdbeb43 100644 --- a/runtime/docs/html/probes_8c.html +++ b/runtime/docs/html/probes_8c.html @@ -4,7 +4,7 @@ - +

      probes.c File Reference

      Functions to assist loading and unloading groups of probes. More...

      @@ -24,10 +24,6 @@ int _stp_register_kprobes (struct kprobe *probes, int num_probes)  Register a group of kprobes.
      -

      Variables

      -static unsigned long(* _stp_lookup_name )(char *name) = (void *)KALLSYMS_LOOKUP_NAME - - Lookup name.

      Detailed Description

      Functions to assist loading and unloading groups of probes. @@ -82,7 +78,7 @@ Register a group of jprobes.

      Definition at line 32 of file probes.c.

      -References _stp_lookup_name, _stp_unregister_jprobes(), and dlog(). +References _stp_unregister_jprobes(), and dlog().

      @@ -132,7 +128,7 @@ Register a group of kprobes.

      Definition at line 77 of file probes.c.

      -References _stp_lookup_name, _stp_unregister_kprobes(), and dlog(). +References _stp_unregister_kprobes(), and dlog().

      @@ -181,7 +177,7 @@ Unregister a group of jprobes.

      Definition at line 18 of file probes.c.

      -References dlog(). +References dlog().

      Referenced by _stp_register_jprobes(). @@ -232,41 +228,9 @@ Unregister a group of kprobes.

      Definition at line 63 of file probes.c.

      -References dlog(). +References dlog().

      Referenced by _stp_register_kprobes(). -


      Variable Documentation

      -

      - - - - -
      - - - - -
      unsigned long(* _stp_lookup_name)(char *name) = (void *)KALLSYMS_LOOKUP_NAME [static]
      -
      - - - - - -
      -   - - -

      -Lookup name. -

      -This simply calls the kernel function kallsyms_lookup_name(). That function is not exported, so this workaround is required. See the kernel source, kernel/kallsyms.c for more information. -

      -Definition at line 11 of file probes.c. -

      -Referenced by _stp_register_jprobes(), and _stp_register_kprobes().

      -


      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/runtime_8h-source.html b/runtime/docs/html/runtime_8h-source.html index 00feb2d8..a0f00a36 100644 --- a/runtime/docs/html/runtime_8h-source.html +++ b/runtime/docs/html/runtime_8h-source.html @@ -4,28 +4,29 @@ - -

      runtime.h

      00001 
      -00002 #include <linux/module.h>
      -00003 #include <linux/kernel.h>
      -00004 #include <linux/miscdevice.h>
      -00005 #include <linux/init.h>
      -00006 #include <linux/hash.h>
      -00007 #include <linux/string.h>
      -00008 #include <linux/kprobes.h>
      -00009 #include <linux/proc_fs.h>
      -00010 #include <linux/vmalloc.h>
      -00011 #include <linux/time.h>
      -00012 #include <linux/spinlock.h>
      -00013 #include <linux/hardirq.h>
      -00014 #include <asm/uaccess.h>
      -00015 #include <linux/kallsyms.h>
      -00016 
      -00017 #include "alloc.h"
      -00018 #include "map.h"
      -00019 
      -00020 #define dbug(args...) ;
      -00021 
      -

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + +

      runtime.h

      Go to the documentation of this file.
      00001 #ifndef _RUNTIME_H_
      +00002 #define _RUNTIME_H_
      +00003 /** @file runtime.h
      +00004  * @brief Main include file for runtime functions.
      +00005  */
      +00006 
      +00007 #include <linux/module.h>
      +00008 #include <linux/kernel.h>
      +00009 #include <linux/miscdevice.h>
      +00010 #include <linux/init.h>
      +00011 #include <linux/hash.h>
      +00012 #include <linux/string.h>
      +00013 #include <linux/kprobes.h>
      +00014 #include <linux/proc_fs.h>
      +00015 #include <linux/vmalloc.h>
      +00016 #include <linux/time.h>
      +00017 #include <linux/spinlock.h>
      +00018 #include <linux/hardirq.h>
      +00019 #include <asm/uaccess.h>
      +00020 #include <linux/kallsyms.h>
      +00021 
      +00022 #define dbug(args...) ;
      +00023 
      +00024 #endif /* _RUNTIME_H_ */
      +
      diff --git a/runtime/docs/html/runtime_8h.html b/runtime/docs/html/runtime_8h.html index 43b0f402..450661ad 100644 --- a/runtime/docs/html/runtime_8h.html +++ b/runtime/docs/html/runtime_8h.html @@ -1,12 +1,13 @@ -SystemTap: SystemTap Runtime Library +SystemTap: runtime.h File Reference - - -

      runtime.h File Reference

      #include <linux/module.h>
      + +

      runtime.h File Reference

      Main include file for runtime functions. More... +

      +#include <linux/module.h>
      #include <linux/kernel.h>
      #include <linux/miscdevice.h>
      #include <linux/init.h>
      @@ -20,51 +21,18 @@ #include <linux/hardirq.h>
      #include <asm/uaccess.h>
      #include <linux/kallsyms.h>
      -#include "alloc.h"
      -#include "map.h"

      Go to the source code of this file. - +

      Defines

      #define dbug(args...)   ;
      +#define dbug(args...)   ;
      -


      Define Documentation

      -

      - - - - -
      - - - - - - - - - -
      #define dbug args...   )    ;
      -
      - - - - - -
      -   - - +

      Detailed Description

      +Main include file for runtime functions.

      -Definition at line 20 of file runtime.h. -

      -Referenced by _stp_map_get_int64(), _stp_map_get_stat(), _stp_map_get_str(), _stp_map_iter(), _stp_map_key_del(), _stp_map_key_long_long(), _stp_map_key_long_str(), _stp_map_key_str_long(), _stp_map_key_str_str(), _stp_map_new(), _stp_map_set_stat(), _stp_map_set_str(), _stp_map_start(), and _stp_map_stat_add().

      -


      Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
      - - +Definition in file runtime.h. diff --git a/runtime/docs/html/scbuf_8c-source.html b/runtime/docs/html/scbuf_8c-source.html new file mode 100644 index 00000000..a9e9ddc8 --- /dev/null +++ b/runtime/docs/html/scbuf_8c-source.html @@ -0,0 +1,79 @@ + + +SystemTap: scbuf.c Source File + + + + +

      scbuf.c

      00001 #ifndef _SCBUF_C_
      +00002 #define _SCBUF_C_
      +00003 
      +00004 /* -*- linux-c -*- */
      +00005 /** @file scbuf.c
      +00006  * @addtogroup scbuf Scratch Buffer
      +00007  * Scratch Buffer Functions.
      +00008  * The scratch buffer is for collecting output before storing in a map,
      +00009  * printing, etc. This is a per-cpu static buffer.  It is necessary because 
      +00010  * of the limited stack space available in the kernel.
      +00011  * @{
      +00012  */
      +00013 
      +00014 /** Maximum size of buffer, not including terminating NULL */
      +00015 #define STP_BUF_LEN 8191
      +00016 
      +00017 /** Scratch buffer for printing, building strings, etc */
      +00018 char _stp_scbuf[STP_BUF_LEN+1];
      +00019 static int _stp_scbuf_len = STP_BUF_LEN;
      +00020 
      +00021 /** Sprint into the scratch buffer.
      +00022  * Like printf, except output goes into  #_stp_scbuf,
      +00023  * which will contain the null-terminated output.
      +00024  * Safe because overflowing #_stp_scbuf is not allowed.
      +00025  * Size is limited by length of scratch buffer, STP_BUF_LEN.
      +00026  *
      +00027  * @param fmt A printf-style format string followed by a 
      +00028  * variable number of args.
      +00029  * @sa _stp_scbuf_clear
      +00030  */
      +00031 
      +00032 void _stp_sprint (const char *fmt, ...)
      +00033 {
      +00034   int num;
      +00035   va_list args;
      +00036   char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
      +00037   va_start(args, fmt);
      +00038   num = vscnprintf(buf, _stp_scbuf_len, fmt, args);
      +00039   va_end(args);
      +00040   if (num > 0)
      +00041     _stp_scbuf_len -= num;
      +00042 }
      +00043 
      +00044 void _stp_sprint_str (const char *str)
      +00045 {
      +00046   char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
      +00047   int num = strlen (str);
      +00048   if (num > _stp_scbuf_len)
      +00049     num = _stp_scbuf_len;
      +00050   strncpy (buf, str, num);
      +00051   _stp_scbuf_len -= num;
      +00052 }
      +00053 
      +00054 /** Clear the scratch buffer.
      +00055  * Output from _stp_sprint() will accumulate in the buffer
      +00056  * until this is called.
      +00057  */
      +00058 
      +00059 void _stp_scbuf_clear (void)
      +00060 {
      +00061   _stp_scbuf_len = STP_BUF_LEN;
      +00062   _stp_scbuf[0] = 0;
      +00063 }
      +00064 
      +00065 static char *_stp_scbuf_cur (void)
      +00066 {
      +00067   return _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
      +00068 }
      +00069 
      +00070 /** @} */
      +00071 #endif /* _SCBUF_C_ */
      +
      diff --git a/runtime/docs/html/shellsnoop_2dtr_8c-source.html b/runtime/docs/html/shellsnoop_2dtr_8c-source.html index 64f58859..7391b8ce 100644 --- a/runtime/docs/html/shellsnoop_2dtr_8c-source.html +++ b/runtime/docs/html/shellsnoop_2dtr_8c-source.html @@ -4,14 +4,14 @@ - +

      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"
      +00005 #include "runtime.h"
       00006 #include "io.c"
       00007 #include "map.c"
       00008 #include "copy.c"
      @@ -32,14 +32,14 @@
       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);
      +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);
      +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)
      +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     }
      @@ -49,9 +49,9 @@
       00040 
       00041 struct file * inst_filp_open (const char * filename, int flags, int mode)
       00042 {
      -00043   _stp_map_key_long (pids, current->pid);
      +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);
      +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;
      @@ -59,9 +59,9 @@
       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);
      +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);
      +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;
      @@ -71,7 +71,7 @@
       00062 {
       00063   size_t len;
       00064   char str[256];
      -00065   _stp_map_key_long (pids, current->pid);
      +00065   _stp_map_key_long (pids, current->pid);
       00066   if (_stp_map_get_int64 (pids))
       00067     {
       00068       if (count < 64) 
      @@ -113,26 +113,24 @@
       00104 {
       00105   int ret;
       00106 
      -00107   pids = _stp_map_new (10000, INT64);
      -00108   arglist = _stp_list_new (10, STRING);
      +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");
      +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");
      +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 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/stack_8c-source.html b/runtime/docs/html/stack_8c-source.html index dda3013a..f4df8413 100644 --- a/runtime/docs/html/stack_8c-source.html +++ b/runtime/docs/html/stack_8c-source.html @@ -4,181 +4,166 @@ - -

      stack.c

      00001 /* -*- linux-c -*- */
      -00002 
      -00003 #ifdef __x86_64__
      -00004 /* ripped out of arch/x86_64/kernel/traps.c */
      -00005 #include <linux/kallsyms.h> 
      -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); 
      -00022 }
      -00023 
      -00024 void _stp_show_trace(unsigned long *stack)
      -00025 {
      -00026         unsigned long addr;
      -00027         unsigned long *irqstack, *irqstack_end, *estack_end;
      -00028         const int cpu = safe_smp_processor_id();
      -00029         int i;
      -00030 
      -00031         printk("\nCall Trace:");
      -00032         i = 0; 
      -00033         
      -00034         estack_end = in_exception_stack(cpu, (unsigned long)stack); 
      -00035         if (estack_end) { 
      -00036                 while (stack < estack_end) { 
      -00037                         addr = *stack++; 
      -00038                         if (__kernel_text_address(addr)) {
      -00039                                 i += printk_address(addr);
      -00040                                 i += printk(" "); 
      -00041                                 if (i > 50) {
      -00042                                         printk("\n"); 
      -00043                                         i = 0;
      -00044                                 }
      -00045                         }
      -00046                 }
      -00047                 i += printk(" <EOE> "); 
      -00048                 i += 7;
      -00049                 stack = (unsigned long *) estack_end[-2]; 
      -00050         }  
      -00051 
      -00052         irqstack_end = (unsigned long *) (cpu_pda[cpu].irqstackptr);
      -00053         irqstack = (unsigned long *) (cpu_pda[cpu].irqstackptr - IRQSTACKSIZE + 64);
      -00054 
      -00055         if (stack >= irqstack && stack < irqstack_end) {
      -00056                 printk("<IRQ> ");  
      -00057                 while (stack < irqstack_end) {
      -00058                         addr = *stack++;
      -00059                         /*
      -00060                          * If the address is either in the text segment of the
      -00061                          * kernel, or in the region which contains vmalloc'ed
      -00062                          * memory, it *may* be the address of a calling
      -00063                          * routine; if so, print it so that someone tracing
      -00064                          * down the cause of the crash will be able to figure
      -00065                          * out the call path that was taken.
      -00066                          */
      -00067                          if (__kernel_text_address(addr)) {
      -00068                                  i += printk_address(addr);
      -00069                                  i += printk(" "); 
      -00070                                  if (i > 50) { 
      -00071                                         printk("\n       ");
      -00072                                          i = 0;
      -00073                                  } 
      -00074                         }
      -00075                 } 
      -00076                 stack = (unsigned long *) (irqstack_end[-1]);
      -00077                 printk(" <EOI> ");
      -00078                 i += 7;
      -00079         } 
      -00080 
      -00081         while (((long) stack & (THREAD_SIZE-1)) != 0) {
      -00082                 addr = *stack++;
      -00083                 if (__kernel_text_address(addr)) {
      -00084                         i += printk_address(addr);
      -00085                         i += printk(" "); 
      -00086                         if (i > 50) { 
      -00087                                 printk("\n       ");
      -00088                                          i = 0;
      -00089                         } 
      -00090                 }
      -00091         }
      -00092         printk("\n");
      -00093 }
      -00094 
      -00095 void _stp_dump_stack(void)
      -00096 {
      -00097   unsigned long dummy;
      -00098   show_trace(&dummy);
      -00099 }
      -00100 
      -00101 #else  /* i386 */
      -00102 
      -00103 static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
      -00104 {
      -00105         return  p > (void *)tinfo &&
      -00106                 p < (void *)tinfo + THREAD_SIZE - 3;
      -00107 }
      -00108 
      -00109 int __kernel_text_address(unsigned long addr)
      -00110 {
      -00111         if (core_kernel_text(addr))
      -00112                 return 1;
      -00113         return __module_text_address(addr) != NULL;
      -00114 }
      -00115 
      -00116 static inline unsigned long _stp_print_context_stack(struct thread_info *tinfo,
      -00117                                 unsigned long *stack, unsigned long ebp)
      -00118 {
      -00119         unsigned long addr;
      -00120 
      -00121 #ifdef  CONFIG_FRAME_POINTER
      -00122         while (valid_stack_ptr(tinfo, (void *)ebp)) {
      -00123                 addr = *(unsigned long *)(ebp + 4);
      -00124                 _stp_print_buf(" [<%08lx>] ", addr);
      -00125                 _stp_print_symbol("%s", addr);
      -00126                 _stp_print_buf("\n");
      -00127                 ebp = *(unsigned long *)ebp;
      -00128         }
      -00129 #else
      -00130         while (valid_stack_ptr(tinfo, stack)) {
      -00131                 addr = *stack++;
      -00132                 if (__kernel_text_address(addr)) {
      -00133                         _stp_print_buf(" [<%08lx>]", addr);
      -00134                         _stp_print_symbol(" %s", addr);
      -00135                         _stp_print_buf("\n");
      -00136                 }
      -00137         }
      -00138 #endif
      -00139         return ebp;
      -00140 }
      -00141 
      -00142 void show_trace(struct task_struct *task, unsigned long * stack)
      -00143 {
      -00144         unsigned long ebp;
      -00145 
      -00146         if (!task)
      -00147                 task = current;
      -00148 
      -00149         if (task == current) {
      -00150                 /* Grab ebp right from our regs */
      -00151                 asm ("movl %%ebp, %0" : "=r" (ebp) : );
      -00152         } else {
      -00153                 /* ebp is the last reg pushed by switch_to */
      -00154                 ebp = *(unsigned long *) task->thread.esp;
      -00155         }
      -00156 
      -00157         while (1) {
      -00158                 struct thread_info *context;
      -00159                 context = (struct thread_info *)
      -00160                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
      -00161                 ebp = _stp_print_context_stack(context, stack, ebp);
      -00162                 stack = (unsigned long*)context->previous_esp;
      -00163                 if (!stack)
      -00164                         break;
      -00165                 _stp_print_buf(" =======================\n");
      -00166         }
      -00167 }
      -00168 
      -00169 void dump_stack(void)
      -00170 {
      -00171         unsigned long stack;
      -00172         show_trace(current, &stack);
      -00173 }
      -00174 #endif
      -

      -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + +

      stack.c

      Go to the documentation of this file.
      00001 #ifndef _STACK_C_
      +00002 #define _STACK_C_
      +00003 /* -*- linux-c -*- */
      +00004 
      +00005 /** @file stack.c
      +00006  * @brief Stack Tracing Functions
      +00007  */
      +00008 
      +00009 /** @addtogroup stack Stack Tracing Functions
      +00010  * @{
      +00011  */
      +00012 
      +00013 #include "sym.c"
      +00014 
      +00015 static int (*_stp_kta)(unsigned long addr)=(void *)KTA;
      +00016 
      +00017 #ifdef __x86_64__
      +00018 static void __stp_stack_print (unsigned long *stack, int verbose, int levels)
      +00019 {
      +00020         unsigned long addr;
      +00021 
      +00022         if (verbose)
      +00023                 _stp_print ("trace for %d (%s)\n", current->pid, current->comm);
      +00024 
      +00025         while (((long) stack & (THREAD_SIZE-1)) != 0) {
      +00026                 addr = *stack++;
      +00027                 if (_stp_kta(addr)) {
      +00028                         if (verbose)
      +00029                                 _stp_symbol_print (addr);
      +00030                         else
      +00031                                 _stp_print ("0x%lx ", addr);
      +00032                 }
      +00033         }
      +00034         _stp_print_str ("\n");
      +00035 }
      +00036 
      +00037 
      +00038 static char *__stp_stack_sprint (unsigned long *stack, int verbose, int levels)
      +00039 {
      +00040         unsigned long addr;
      +00041         char *ptr = _stp_scbuf_cur();
      +00042         while (((long) stack & (THREAD_SIZE-1)) != 0) {
      +00043                 addr = *stack++;
      +00044                 if (_stp_kta(addr)) {
      +00045                         if (verbose)
      +00046                                 _stp_symbol_sprint (addr);
      +00047                         else
      +00048                                 _stp_sprint ("0x%lx ", addr);
      +00049                 }
      +00050         }
      +00051         return ptr;
      +00052 }
      +00053 
      +00054 #else  /* i386 */
      +00055 
      +00056 static inline int valid_stack_ptr (struct thread_info *tinfo, void *p)
      +00057 {
      +00058         return  p > (void *)tinfo &&
      +00059                 p < (void *)tinfo + THREAD_SIZE - 3;
      +00060 }
      +00061 
      +00062 static inline unsigned long _stp_print_context_stack (
      +00063         struct thread_info *tinfo,
      +00064         unsigned long *stack, 
      +00065         unsigned long ebp )
      +00066 {
      +00067         unsigned long addr;
      +00068 
      +00069 #ifdef  CONFIG_FRAME_POINTER
      +00070         while (valid_stack_ptr(tinfo, (void *)ebp)) {
      +00071                 addr = *(unsigned long *)(ebp + 4);
      +00072                 _stp_symbol_print (addr);
      +00073                 _stp_print_str("\n");
      +00074                 ebp = *(unsigned long *)ebp;
      +00075         }
      +00076 #else
      +00077         while (valid_stack_ptr(tinfo, stack)) {
      +00078                 addr = *stack++;
      +00079                 if (_stp_kta (addr)) {
      +00080                         _stp_symbol_print (addr);
      +00081                         _stp_print_str ("\n");
      +00082                 }
      +00083         }
      +00084 #endif
      +00085         return ebp;
      +00086 }
      +00087 
      +00088 static inline unsigned long _stp_sprint_context_stack (
      +00089         struct thread_info *tinfo,
      +00090         unsigned long *stack, 
      +00091         unsigned long ebp )
      +00092 {
      +00093         unsigned long addr;
      +00094 
      +00095 #ifdef  CONFIG_FRAME_POINTER
      +00096         while (valid_stack_ptr(tinfo, (void *)ebp)) {
      +00097                 addr = *(unsigned long *)(ebp + 4);
      +00098                 _stp_symbol_sprint (addr);
      +00099                 _stp_sprint_str("\n");
      +00100                 ebp = *(unsigned long *)ebp;
      +00101         }
      +00102 #else
      +00103         while (valid_stack_ptr(tinfo, stack)) {
      +00104                 addr = *stack++;
      +00105                 if (_stp_kta (addr)) {
      +00106                         _stp_symbol_sprint (addr);
      +00107                         _stp_sprint_str ("\n");
      +00108                 }
      +00109         }
      +00110 #endif
      +00111         return ebp;
      +00112 }
      +00113 
      +00114 static void __stp_stack_print (unsigned long *stack, int verbose, int levels)
      +00115 {
      +00116         unsigned long ebp;
      +00117 
      +00118         /* Grab ebp right from our regs */
      +00119         asm ("movl %%ebp, %0" : "=r" (ebp) : );
      +00120 
      +00121         while (stack) {
      +00122                 struct thread_info *context = (struct thread_info *)
      +00123                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
      +00124                 ebp = _stp_print_context_stack (context, stack, ebp);
      +00125                 stack = (unsigned long*)context->previous_esp;
      +00126         }
      +00127 }
      +00128 
      +00129 static void __stp_stack_sprint (unsigned long *stack, int verbose, int levels)
      +00130 {
      +00131         unsigned long ebp;
      +00132 
      +00133         /* Grab ebp right from our regs */
      +00134         asm ("movl %%ebp, %0" : "=r" (ebp) : );
      +00135 
      +00136         while (stack) {
      +00137                 struct thread_info *context = (struct thread_info *)
      +00138                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
      +00139                 ebp = _stp_sprint_context_stack (context, stack, ebp);
      +00140                 stack = (unsigned long*)context->previous_esp;
      +00141         }
      +00142 }
      +00143 
      +00144 #endif /* i386 */
      +00145 
      +00146 void _stp_stack_print (int verbose, int levels)
      +00147 {
      +00148   unsigned long stack;
      +00149   return __stp_stack_print (&stack, verbose, levels);
      +00150 }
      +00151 
      +00152 char *_stp_stack_sprint (int verbose, int levels)
      +00153 {
      +00154   unsigned long stack;
      +00155   char *ptr = _stp_scbuf_cur();
      +00156   __stp_stack_sprint (&stack, verbose, levels);
      +00157   return ptr;
      +00158 }
      +00159 
      +00160 /** @} */
      +00161 #endif /* _STACK_C_ */
      +
      diff --git a/runtime/docs/html/stack_8c.html b/runtime/docs/html/stack_8c.html index 0b8cc43d..65cb258e 100644 --- a/runtime/docs/html/stack_8c.html +++ b/runtime/docs/html/stack_8c.html @@ -1,125 +1,28 @@ -SystemTap: SystemTap Runtime Library +SystemTap: stack.c File Reference - - -

      stack.c File Reference

      + +

      stack.c File Reference

      Stack Tracing Functions. More... +

      +#include "sym.c"
      +

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

      Functions

      int __kernel_text_address (unsigned long addr)
      +void _stp_stack_print (int verbose, int levels)
      void show_trace (struct task_struct *task, unsigned long *stack)
      +char * _stp_stack_sprint (int verbose, int levels)
      void dump_stack (void)
      -


      Function Documentation

      -

      - - - -
      - - - - - - - - - -
      int __kernel_text_address unsigned long  addr  ) 
      -
      - - - - - -
      -   - - -

      - +


      Detailed Description

      +Stack Tracing Functions.

      -Definition at line 109 of file stack.c.

      -

      - - - - -
      - - - - - - - - - -
      void dump_stack void   ) 
      -
      - - - - - -
      -   -

      - -

      -Definition at line 169 of file stack.c.

      -

      - - - - -
      - - - - - - - - - - - - - - - - - - -
      void show_trace struct task_struct *  task,
      unsigned long *  stack
      -
      - - - - - -
      -   - - -

      - -

      -Definition at line 142 of file stack.c.

      -


      Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
      - - +Definition in file stack.c. diff --git a/runtime/docs/html/stp__tasklet_8c-source.html b/runtime/docs/html/stp__tasklet_8c-source.html index 93f8b84c..1156b265 100644 --- a/runtime/docs/html/stp__tasklet_8c-source.html +++ b/runtime/docs/html/stp__tasklet_8c-source.html @@ -4,7 +4,7 @@ - +

      stp_tasklet.c

      00001 /* Framework for putting a jprobe in a tasklet. */
      @@ -15,7 +15,7 @@
       00006 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
       00007 #define BUCKETS 16 /* largest histogram width */
       00008 
      -00009 #include "runtime.h"
      +00009 #include "runtime.h"
       00010 #include "io.c"
       00011 #include "probes.c"
       00012 
      @@ -25,7 +25,7 @@
       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());
      +00019   dlog ("interrupt=%d\n", in_interrupt());
       00020   jprobe_return();
       00021 }
       00022 
      @@ -41,20 +41,18 @@
       00032 static int init_stp(void)
       00033 {
       00034   int ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES);
      -00035   dlog("instrumentation is enabled...\n");
      +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");
      +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 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/structmap__node.html b/runtime/docs/html/structmap__node.html index d2fc751c..c4c387ee 100644 --- a/runtime/docs/html/structmap__node.html +++ b/runtime/docs/html/structmap__node.html @@ -4,8 +4,11 @@ - -

      map_node Struct Reference

      basic map element + +

      map_node Struct Reference
      + +[Maps] +

      basic map element More...

      #include <map.h> @@ -28,10 +31,10 @@ hlist_node key_data key2 -enum keytype key1type +enum keytype key1type -enum keytype key2type +enum keytype key2type


      Detailed Description

      @@ -39,8 +42,6 @@ basic map element

      -Definition at line 29 of file map.h.


      The documentation for this struct was generated from the following file:
        +Definition at line 35 of file map.h.
        The documentation for this struct was generated from the following file: -
        -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/structmap__node__int64.html b/runtime/docs/html/structmap__node__int64.html index 7dc8e5e6..4a8c3edc 100644 --- a/runtime/docs/html/structmap__node__int64.html +++ b/runtime/docs/html/structmap__node__int64.html @@ -4,8 +4,11 @@ - -

        map_node_int64 Struct Reference

        map element containing int64 + +

        map_node_int64 Struct Reference
        + +[Maps] +

        map element containing int64 More...

        #include <map.h> @@ -25,8 +28,6 @@ map element containing int64

        -Definition at line 41 of file map.h.


        The documentation for this struct was generated from the following file:
          +Definition at line 47 of file map.h.
          The documentation for this struct was generated from the following file: -
          -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/structmap__node__stat.html b/runtime/docs/html/structmap__node__stat.html index a094c11d..fe581573 100644 --- a/runtime/docs/html/structmap__node__stat.html +++ b/runtime/docs/html/structmap__node__stat.html @@ -4,8 +4,11 @@ - -

          map_node_stat Struct Reference

          map element containing stats + +

          map_node_stat Struct Reference
          + +[Maps] +

          map element containing stats More...

          #include <map.h> @@ -25,8 +28,6 @@ map element containing stats

          -Definition at line 53 of file map.h.


          The documentation for this struct was generated from the following file:
            +Definition at line 59 of file map.h.
            The documentation for this struct was generated from the following file: -
            -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/structmap__node__str.html b/runtime/docs/html/structmap__node__str.html index 6aa4ef38..fa970680 100644 --- a/runtime/docs/html/structmap__node__str.html +++ b/runtime/docs/html/structmap__node__str.html @@ -4,8 +4,11 @@ - -

            map_node_str Struct Reference

            map element containing string + +

            map_node_str Struct Reference
            + +[Maps] +

            map element containing string More...

            #include <map.h> @@ -25,8 +28,6 @@ map element containing string

            -Definition at line 47 of file map.h.


            The documentation for this struct was generated from the following file:
              +Definition at line 53 of file map.h.
              The documentation for this struct was generated from the following file: -
              -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/structmap__root.html b/runtime/docs/html/structmap__root.html index 0fdd005f..d6e95bd6 100644 --- a/runtime/docs/html/structmap__root.html +++ b/runtime/docs/html/structmap__root.html @@ -4,8 +4,11 @@ - -

              map_root Struct Reference

              This structure contains all information about a map. + +

              map_root Struct Reference
              + +[Maps] +

              This structure contains all information about a map. More...

              #include <map.h> @@ -14,7 +17,7 @@

              Data Fields

              -enum valtype type +enum valtype type  type of the values stored in the array
              @@ -44,10 +47,10 @@ list_head  this is the creation data saved between the key functions and the set/get functions
              -enum keytype c_key1type +enum keytype c_key1type -enum keytype c_key2type +enum keytype c_key2type hlist_head * c_keyhead @@ -69,11 +72,11 @@ hlist_head 

              Detailed Description

              This structure contains all information about a map.

              -It is allocated once when _stp_map_new() is called. +It is allocated once when _stp_map_new() is called.

              -Definition at line 61 of file map.h.


              Field Documentation

              +Definition at line 67 of file map.h.

              Field Documentation

              @@ -96,12 +99,12 @@ Definition at line 61 of file

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

              -

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

              -Definition at line 87 of file map.h. +Definition at line 93 of file map.h.

              -Referenced by _stp_map_get_int64(), _stp_map_get_stat(), _stp_map_get_str(), _stp_map_key_long_long(), _stp_map_key_long_str(), _stp_map_key_str_long(), _stp_map_key_str_str(), _stp_map_set_stat(), _stp_map_set_str(), and _stp_map_stat_add(). +Referenced by _stp_map_get_int64(), _stp_map_get_stat(), _stp_map_get_str(), _stp_map_key_long_long(), _stp_map_key_long_str(), _stp_map_key_str_long(), _stp_map_key_str_str(), _stp_map_set_stat(), _stp_map_set_str(), and _stp_map_stat_add().

              @@ -128,9 +131,9 @@ pointer to allocated memory space.

              Used for freeing memory.

              -Definition at line 98 of file map.h. +Definition at line 104 of file map.h.

              -Referenced by _stp_map_del(), and _stp_map_new(). +Referenced by _stp_map_del(), and _stp_map_new().

              @@ -157,13 +160,11 @@ pool of unused entries.

              Used only when entries are statically allocated at startup.

              -Definition at line 79 of file map.h. +Definition at line 85 of file map.h.

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


              The documentation for this struct was generated from the following file: -
              -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/structstat.html b/runtime/docs/html/structstat.html index ef5b86e0..16155517 100644 --- a/runtime/docs/html/structstat.html +++ b/runtime/docs/html/structstat.html @@ -4,8 +4,11 @@ - -

              stat Struct Reference

              Statistics are stored in this struct. + +

              stat Struct Reference
              + +[Maps] +

              Statistics are stored in this struct. More...

              #include <map.h> @@ -34,8 +37,6 @@ Statistics are stored in this struct.

              -Definition at line 9 of file map.h.


              The documentation for this struct was generated from the following file:
                +Definition at line 15 of file map.h.
                The documentation for this struct was generated from the following file: -
                -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/sym_8c-source.html b/runtime/docs/html/sym_8c-source.html new file mode 100644 index 00000000..2e8ffc8a --- /dev/null +++ b/runtime/docs/html/sym_8c-source.html @@ -0,0 +1,73 @@ + + +SystemTap: sym.c Source File + + + + +

                sym.c

                00001 #ifndef _SYM_C_ /* -*- linux-c -*- */
                +00002 #define _SYM_C_
                +00003 
                +00004 #include "scbuf.c"
                +00005 
                +00006 /** @file sym.c
                +00007  * @addtogroup sym Symbolic Functions
                +00008  * Symbolic Lookup Functions
                +00009  * @{
                +00010  */
                +00011 
                +00012 /** Lookup symbol.
                +00013  * This simply calls the kernel function kallsyms_lookup().
                +00014  * That function is not exported, so this workaround is required.
                +00015  * See the kernel source, kernel/kallsyms.c for more information.
                +00016  */
                +00017 static const char * (*_stp_kallsyms_lookup)(unsigned long addr,
                +00018                             unsigned long *symbolsize,
                +00019                             unsigned long *offset,
                +00020                             char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP;
                +00021 
                +00022 static void __stp_symbol_print (unsigned long address, void (*prtfunc)(const char *fmt, ...))
                +00023 {
                +00024         char *modname;
                +00025         const char *name;
                +00026         unsigned long offset, size;
                +00027         char namebuf[KSYM_NAME_LEN+1];
                +00028 
                +00029         name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
                +00030 
                +00031         (*prtfunc)("0x%lx : ", address);
                +00032         if (modname)
                +00033                 (*prtfunc)("%s+%#lx/%#lx [%s]", name, offset, size, modname);
                +00034         else
                +00035                 (*prtfunc)("%s+%#lx/%#lx", name, offset, size);
                +00036 }
                +00037 
                +00038 /** Print addresses symbolically into a string
                +00039  * @param address The address to lookup.
                +00040  * @note Symbolic lookups should not be done within
                +00041  * a probe because it is too time-consuming. Use at module exit time.
                +00042  * @note Uses scbuf.
                +00043  */
                +00044 
                +00045 char * _stp_symbol_sprint (unsigned long address)
                +00046 { 
                +00047         char *ptr = _stp_scbuf_cur();
                +00048         __stp_symbol_print (address, _stp_sprint);
                +00049         return ptr;
                +00050 }
                +00051 
                +00052 
                +00053 /** Print addresses symbolically to the trace buffer.
                +00054  * @param address The address to lookup.
                +00055  * @note Symbolic lookups should not be done within
                +00056  * a probe because it is too time-consuming. Use at module exit time.
                +00057  */
                +00058 
                +00059 void _stp_symbol_print (unsigned long address)
                +00060 {
                +00061         __stp_symbol_print (address, _stp_print);
                +00062 }
                +00063 
                +00064 /** @} */
                +00065 #endif /* _SYM_C_ */
                +
                diff --git a/runtime/docs/html/test4_2dtr_8c-source.html b/runtime/docs/html/test4_2dtr_8c-source.html index 47241e71..2847b88a 100644 --- a/runtime/docs/html/test4_2dtr_8c-source.html +++ b/runtime/docs/html/test4_2dtr_8c-source.html @@ -4,114 +4,147 @@ - +

                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 "probes.c"
                -00009 
                -00010 MODULE_DESCRIPTION("SystemTap probe: test4");
                -00011 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
                -00012 
                -00013 MAP opens, reads, writes;
                -00014 
                -00015 asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode)
                -00016 {
                -00017   _stp_map_key_str (opens, current->comm);
                -00018   _stp_map_add_int64 (opens, 1);
                -00019   jprobe_return();
                -00020   return 0;
                -00021 }
                -00022 
                -00023 asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count)
                -00024 {
                -00025   _stp_map_key_str (reads, current->comm);
                -00026   _stp_map_stat_add (reads, count);
                -00027   jprobe_return();
                -00028   return 0;
                -00029 }
                -00030 
                -00031 asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count)
                -00032 {
                -00033   _stp_map_key_str (writes, current->comm);
                -00034   _stp_map_stat_add (writes, count);
                -00035   jprobe_return();
                -00036   return 0;
                -00037 }
                -00038 
                -00039 static struct jprobe dtr_probes[] = {
                -00040   {
                -00041     .kp.addr = (kprobe_opcode_t *)"sys_open",
                -00042     .entry = (kprobe_opcode_t *) inst_sys_open
                -00043   },
                -00044   {
                -00045     .kp.addr = (kprobe_opcode_t *)"sys_read",
                -00046     .entry = (kprobe_opcode_t *) inst_sys_read
                -00047   },
                -00048   {
                -00049     .kp.addr = (kprobe_opcode_t *)"sys_write",
                -00050     .entry = (kprobe_opcode_t *) inst_sys_write
                -00051   },
                -00052 };
                -00053 
                -00054 #define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe))
                -00055 
                -00056 static int init_dtr(void)
                -00057 {
                -00058   int ret;
                -00059   
                -00060   opens = _stp_map_new (1000, INT64);
                -00061   reads = _stp_map_new (1000, STAT);
                -00062   writes = _stp_map_new (1000, STAT);
                -00063 
                -00064   ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE);
                -00065 
                -00066   dlog("instrumentation is enabled...\n");
                -00067   return ret;
                -00068 
                -00069 }
                -00070 
                -00071 static void cleanup_dtr(void)
                -00072 {
                -00073   struct map_node_stat *st;
                -00074   struct map_node_int64 *ptr;
                -00075 
                -00076   _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE);
                -00077 
                -00078   for (ptr = (struct map_node_int64 *)_stp_map_start(opens); ptr; 
                -00079        ptr = (struct map_node_int64 *)_stp_map_iter (opens,(struct map_node *)ptr))
                -00080     dlog ("opens[%s] = %lld\n", key1str(ptr), ptr->val); 
                -00081   dlog ("\n");
                -00082 
                -00083   for (st = (struct map_node_stat *)_stp_map_start(reads); st; 
                -00084        st = (struct map_node_stat *)_stp_map_iter (reads,(struct map_node *)st))
                -00085     dlog ("reads[%s] = [count=%lld  sum=%lld   min=%lld   max=%lld]\n", key1str(st), st->stats.count, st->stats.sum,
                -00086             st->stats.min, st->stats.max);
                -00087   dlog ("\n");
                -00088 
                -00089   for (st = (struct map_node_stat *)_stp_map_start(writes); st; 
                -00090        st = (struct map_node_stat *)_stp_map_iter (writes,(struct map_node *)st))
                -00091     dlog ("writes[%s] = [count=%lld  sum=%lld   min=%lld   max=%lld]\n", key1str(st), st->stats.count, st->stats.sum,
                -00092             st->stats.min, st->stats.max);
                -00093   dlog ("\n");
                -00094 
                -00095   _stp_map_del (opens);
                -00096   _stp_map_del (reads);
                -00097   _stp_map_del (writes);
                -00098 
                -00099   dlog("EXIT\n");
                -00100 }
                -00101 
                -00102 module_init(init_dtr);
                -00103 module_exit(cleanup_dtr);
                -00104 MODULE_LICENSE("GPL");
                -00105 
                -

                -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +00004 #include <linux/module.h> +00005 #include <linux/interrupt.h> +00006 #include <net/sock.h> +00007 +00008 #include "runtime.h" +00009 #include "io.c" +00010 #include "map.c" +00011 #include "probes.c" +00012 #include "stack.c" +00013 +00014 MODULE_DESCRIPTION("SystemTap probe: test4"); +00015 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); +00016 +00017 static char tbuffer[2][50000]; +00018 static void stp_helper(void *); +00019 static DECLARE_WORK(stp_work, stp_helper, tbuffer); +00020 +00021 MAP opens, reads, writes, traces; +00022 static int bufcount = 0; +00023 +00024 static void stp_helper (void *data) +00025 { +00026 dlog ("HELPER\n"); +00027 } +00028 +00029 asmlinkage long inst_sys_open (const char __user * filename, int flags, int mode) +00030 { +00031 _stp_map_key_str (opens, current->comm); +00032 _stp_map_add_int64 (opens, 1); +00033 jprobe_return(); +00034 return 0; +00035 } +00036 +00037 asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) +00038 { +00039 _stp_map_key_str (reads, current->comm); +00040 _stp_map_stat_add (reads, count); +00041 jprobe_return(); +00042 return 0; +00043 } +00044 +00045 asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) +00046 { +00047 _stp_map_key_str (writes, current->comm); +00048 _stp_map_stat_add (writes, count); +00049 jprobe_return(); +00050 return 0; +00051 } +00052 +00053 int inst_show_cpuinfo(struct seq_file *m, void *v) +00054 { +00055 _stp_stack_print (0,0); +00056 _stp_stack_print (1,0); +00057 +00058 _stp_scbuf_clear(); +00059 _stp_list_add (traces, _stp_stack_sprint(0,0)); +00060 if (bufcount++ == 0) +00061 schedule_work (&stp_work); +00062 +00063 jprobe_return(); +00064 return 0; +00065 } +00066 +00067 +00068 static struct jprobe dtr_probes[] = { +00069 { +00070 .kp.addr = (kprobe_opcode_t *)"sys_open", +00071 .entry = (kprobe_opcode_t *) inst_sys_open +00072 }, +00073 { +00074 .kp.addr = (kprobe_opcode_t *)"sys_read", +00075 .entry = (kprobe_opcode_t *) inst_sys_read +00076 }, +00077 { +00078 .kp.addr = (kprobe_opcode_t *)"sys_write", +00079 .entry = (kprobe_opcode_t *) inst_sys_write +00080 }, +00081 { +00082 .kp.addr = (kprobe_opcode_t *)"show_cpuinfo", +00083 .entry = (kprobe_opcode_t *) inst_show_cpuinfo, +00084 }, +00085 }; +00086 +00087 #define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe)) +00088 +00089 static int init_dtr(void) +00090 { +00091 int ret; +00092 +00093 opens = _stp_map_new (1000, INT64); +00094 reads = _stp_map_new (1000, STAT); +00095 writes = _stp_map_new (1000, STAT); +00096 traces = _stp_list_new (1000, STRING); +00097 +00098 ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE); +00099 +00100 dlog("instrumentation is enabled...\n"); +00101 return ret; +00102 +00103 } +00104 +00105 static void cleanup_dtr(void) +00106 { +00107 struct map_node_stat *st; +00108 struct map_node_int64 *ptr; +00109 struct map_node_str *sptr; +00110 +00111 _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE); +00112 +00113 foreach (traces, sptr) +00114 dlog ("trace: %s\n", sptr->str); +00115 +00116 foreach (opens, ptr) +00117 dlog ("opens[%s] = %lld\n", key1str(ptr), ptr->val); +00118 dlog ("\n"); +00119 +00120 foreach (reads, st) +00121 dlog ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), +00122 st->stats.count, st->stats.sum, st->stats.min, st->stats.max); +00123 dlog ("\n"); +00124 +00125 foreach (writes, st) +00126 dlog ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), +00127 st->stats.count, st->stats.sum, st->stats.min, st->stats.max); +00128 dlog ("\n"); +00129 +00130 _stp_map_del (opens); +00131 _stp_map_del (reads); +00132 _stp_map_del (writes); +00133 +00134 dlog("EXIT\n"); +00135 } +00136 +00137 module_init(init_dtr); +00138 module_exit(cleanup_dtr); +00139 MODULE_LICENSE("GPL"); +00140 + diff --git a/runtime/docs/html/todo.html b/runtime/docs/html/todo.html index e3973e18..7435d106 100644 --- a/runtime/docs/html/todo.html +++ b/runtime/docs/html/todo.html @@ -4,31 +4,44 @@ - -

                Todo List

                + +

                Todo List

                Global map_root::create
                Needs to be per-cpu data for SMP support

                -
                File alloc.h
                -
                Should really be alloc.c for consistency.
                +
                Group alloc
                +
                Need error handling for memory allocations

                -

                -
                Global dlog (const char *fmt,...)
                +
                +
                Group alloc
                +
                Some of these currently use kmalloc (GFP_ATOMIC) for small allocations. This should be evaluated for performance and stability.
                +
                +

                +

                +
                Global _stp_print (const char *fmt,...)
                +
                Needs replaced with something much faster that does not use the system log.
                +
                +

                +

                +
                Global _stp_print_str (char *str)
                Needs replaced with something much faster that does not use the system log.

                -
                Global _stp_map_set_stat (MAP map, stat *stats)
                +
                Global dlog (const char *fmt,...)
                +
                Either deprecate or redefine this as a way to log debug or status messages, separate from the normal program output.
                +
                +

                +

                +
                Global _stp_map_set_stat (MAP map, stat *stats)
                Histograms don't work yet.

                -

                -
                Global _stp_map_stat_add (MAP map, int64_t val)
                +
                +
                Global _stp_map_stat_add (MAP map, int64_t val)
                Histograms don't work yet.
                -
                -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + diff --git a/runtime/docs/html/unionkey__data.html b/runtime/docs/html/unionkey__data.html index 92d878af..f6fed5cb 100644 --- a/runtime/docs/html/unionkey__data.html +++ b/runtime/docs/html/unionkey__data.html @@ -4,8 +4,11 @@ - -

                key_data Union Reference

                Keys are either longs or char *. + +

                key_data Union Reference
                + +[Maps] +

                Keys are either longs or char *. More...

                #include <map.h> @@ -25,8 +28,6 @@ Keys are either longs or char *.

                -Definition at line 17 of file map.h.


                The documentation for this union was generated from the following file:
                  +Definition at line 23 of file map.h.
                  The documentation for this union was generated from the following file: -
                  -Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - + -- cgit