From e94cb46c2219da504a559d49eeda3e4134b96453 Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 22 Mar 2005 18:36:50 +0000 Subject: *** empty log message *** --- runtime/docs/html/README-source.html | 2 +- runtime/docs/html/alloc_8h-source.html | 152 +- runtime/docs/html/alloc_8h.html | 122 +- runtime/docs/html/annotated.html | 7 +- runtime/docs/html/bug.html | 11 +- runtime/docs/html/copy_8c-source.html | 278 ++-- runtime/docs/html/copy_8c.html | 32 +- runtime/docs/html/dir_000000.html | 2 +- runtime/docs/html/dir_000001.html | 6 +- runtime/docs/html/dir_000002.html | 2 +- runtime/docs/html/dir_000003.html | 2 +- runtime/docs/html/dir_000004.html | 4 +- runtime/docs/html/dirs.html | 2 +- runtime/docs/html/files.html | 11 +- runtime/docs/html/functions.html | 18 +- runtime/docs/html/functions_vars.html | 18 +- runtime/docs/html/globals.html | 66 +- runtime/docs/html/globals_defs.html | 16 +- runtime/docs/html/globals_enum.html | 16 +- runtime/docs/html/globals_func.html | 34 +- runtime/docs/html/globals_type.html | 4 +- runtime/docs/html/globals_vars.html | 19 +- runtime/docs/html/index.html | 2 +- runtime/docs/html/io_8c-source.html | 206 ++- runtime/docs/html/io_8c.html | 146 +- .../docs/html/kprobe__where__funct_8c-source.html | 22 +- runtime/docs/html/map_8c-source.html | 1711 ++++++++++---------- runtime/docs/html/map_8c.html | 174 +- runtime/docs/html/map_8h-source.html | 321 ++-- runtime/docs/html/map_8h.html | 69 +- runtime/docs/html/pages.html | 4 +- runtime/docs/html/probes_2README-source.html | 2 +- .../html/probes_2shellsnoop_2README-source.html | 6 +- .../docs/html/probes_2tasklet_2README-source.html | 2 +- .../docs/html/probes_2test4_2README-source.html | 2 +- .../html/probes_2where__func_2README-source.html | 2 +- runtime/docs/html/probes_8c-source.html | 183 ++- runtime/docs/html/probes_8c.html | 114 +- runtime/docs/html/runtime_8h-source.html | 4 +- runtime/docs/html/shellsnoop_2dtr_8c-source.html | 26 +- runtime/docs/html/stack_8c-source.html | 4 +- runtime/docs/html/stp__tasklet_8c-source.html | 16 +- runtime/docs/html/structmap__node.html | 16 +- runtime/docs/html/structmap__node__int64.html | 76 +- runtime/docs/html/structmap__node__stat.html | 78 +- runtime/docs/html/structmap__node__str.html | 78 +- runtime/docs/html/structmap__root.html | 128 +- runtime/docs/html/structstat.html | 4 +- runtime/docs/html/test4_2dtr_8c-source.html | 28 +- runtime/docs/html/todo.html | 21 +- runtime/docs/html/unionkey__data.html | 4 +- 51 files changed, 2289 insertions(+), 1984 deletions(-) (limited to 'runtime/docs/html') diff --git a/runtime/docs/html/README-source.html b/runtime/docs/html/README-source.html index 6110dbbb..e3a311ea 100644 --- a/runtime/docs/html/README-source.html +++ b/runtime/docs/html/README-source.html @@ -59,5 +59,5 @@ 00052 * \link todo Click Here for Complete List \endlink 00053 */
-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/alloc_8h-source.html b/runtime/docs/html/alloc_8h-source.html index 7d2a3310..e68fbb86 100644 --- a/runtime/docs/html/alloc_8h-source.html +++ b/runtime/docs/html/alloc_8h-source.html @@ -5,79 +5,83 @@ -

alloc.h

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

alloc.h

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

-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 0bab6a97..385d8e1a 100644 --- a/runtime/docs/html/alloc_8h.html +++ b/runtime/docs/html/alloc_8h.html @@ -1,18 +1,19 @@ -SystemTap: SystemTap Runtime Library +SystemTap: alloc.h File Reference - - -

alloc.h File Reference

+ +

alloc.h File Reference

Memory allocation functions. More... +

+

Go to the source code of this file. - @@ -32,44 +33,17 @@ - +

Enumerations

enum  errorcode { ERR_NONE = 0, -ERR_NO_MEM +
enum  errorcode { ERR_NONE = 0, +ERR_NO_MEM }

Functions

 Frees memory allocated by _stp_valloc.

Variables

enum errorcode _stp_error = ERR_NONE
+enum errorcode _stp_error = ERR_NONE
-


Enumeration Type Documentation

-

- - - - -
- - - - -
enum errorcode
-
- - - - - -
-   - - +

Detailed Description

+Memory allocation functions.

-

Enumeration values:
- - - -
ERR_NONE  -
ERR_NO_MEM  -
-
+
Todo:
Should really be alloc.c for consistency.

-Definition at line 1 of file alloc.h.

-


Function Documentation

+Definition in file alloc.h.

Function Documentation

@@ -81,7 +55,7 @@ Definition at line 1 of fil - +
size_t  len  )  [inline]
@@ -106,11 +80,9 @@ This is used for small allocations from within a running probe where the process

Bug:
Currently uses kmalloc (GFP_ATOMIC).

-Definition at line 12 of file alloc.h. -

-References _stp_error, and ERR_NO_MEM. +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().

@@ -124,7 +96,7 @@ Referenced by _stp_calloc() size_t  len  )  - [inline] + @@ -149,11 +121,11 @@ This is used for small allocations from within a running probe where the process

Bug:
Currently uses kmalloc (GFP_ATOMIC).

-Definition at line 28 of file alloc.h. +Definition at line 34 of file alloc.h.

-References _stp_alloc(). +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().

@@ -167,7 +139,7 @@ Referenced by _stp_map_set_stat() void *  ptr  )  - [inline] + @@ -190,9 +162,9 @@ Frees memory allocated by _stp_alloc or _stp_calloc.

-Definition at line 57 of file alloc.h. +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().

@@ -206,7 +178,7 @@ Referenced by _stp_list_clear()size_t  len  )  - [inline] + @@ -230,11 +202,9 @@ This is typically used in the module initialization to allocate new maps, lists,

Returns:
a valid pointer on success or NULL on failure.

-Definition at line 43 of file alloc.h. +Definition at line 49 of file alloc.h.

-References _stp_error, and ERR_NO_MEM. -

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

@@ -248,7 +218,7 @@ Referenced by _stp_map_new(). void *  ptr  )  - [inline] + @@ -271,41 +241,11 @@ Frees memory allocated by _stp_valloc.

-Definition at line 67 of file alloc.h. -

-Referenced by _stp_map_del(). - - -


Variable Documentation

-

- - - - -
- - - - -
enum errorcode _stp_error = ERR_NONE
-
- - - - +Referenced by _stp_map_del().
-   - - -

- -

-Definition at line 2 of file alloc.h. +Definition at line 73 of file alloc.h.

-Referenced by _stp_alloc(), and _stp_valloc().

-


Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +
+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 d0cf4605..49994e1a 100644 --- a/runtime/docs/html/annotated.html +++ b/runtime/docs/html/annotated.html @@ -7,10 +7,13 @@

SystemTap Data Structures

Here are the data structures with brief descriptions: - + + + +
key_dataKeys are either longs or char *
map_nodeAll map nodes have the following structure
map_nodeBasic map element
map_node_int64Map element containing int64
map_node_statMap element containing stats
map_node_strMap element containing string
map_rootThis structure contains all information about a map
statStatistics are stored in this struct

-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 30f41ef4..6c73243e 100644 --- a/runtime/docs/html/bug.html +++ b/runtime/docs/html/bug.html @@ -1,11 +1,10 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Bug List - - +

Bug List

Global _stp_alloc (size_t len)
Currently uses kmalloc (GFP_ATOMIC).
@@ -20,8 +19,6 @@
Global dlog (const char *fmt,...)
Lines are limited in length by printk buffer.
-
Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +
+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 bab47938..3456380c 100644 --- a/runtime/docs/html/copy_8c-source.html +++ b/runtime/docs/html/copy_8c-source.html @@ -5,143 +5,147 @@ -

copy.c

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

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  * @b Example:
-00112  * @include argv.c
-00113  */
-00114 
-00115 int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
-00116 {
-00117         char str[128];
-00118         char __user *vstr;
-00119         int len;
-00120 
-00121         if (argv)
-00122                 argv++;
-00123 
-00124         while (argv != NULL) {
-00125                 if (get_user (vstr, argv))
-00126                         break;
-00127                 
-00128                 if (vstr == NULL)
-00129                         break;
-00130                 
-00131                 len = _stp_strncpy_from_user(str, vstr, 128);
-00132                 str[len] = 0;
-00133                 _stp_list_add_str (list, str);
-00134                 argv++;
-00135         }
-00136         return list->num;
-00137 }
+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 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/copy_8c.html b/runtime/docs/html/copy_8c.html index 75a63237..d4e3ba26 100644 --- a/runtime/docs/html/copy_8c.html +++ b/runtime/docs/html/copy_8c.html @@ -1,12 +1,13 @@ -SystemTap: SystemTap Runtime Library +SystemTap: copy.c File Reference - - -

copy.c File Reference

+ +

copy.c File Reference

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

+

Go to the source code of this file. @@ -21,7 +22,12 @@
 Copy an argv from user space to a List.
-


Function Documentation

+

Detailed Description

+Functions to copy from user space. +

+ +

+Definition in file copy.c.


Function Documentation

@@ -79,9 +85,9 @@ Copy an argv from user space to a List. }

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

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

@@ -137,7 +143,7 @@ If some data could not be copied, this function will pad the copied data to the

Returns:
number of bytes that could not be copied. On success, this will be zero.

-Definition at line 100 of file copy.c. +Definition at line 104 of file copy.c.

@@ -192,13 +198,11 @@ If access to userspace fails, returns -EFAULT (some data may have been copied). If count is smaller than the length of the string, copies count bytes and returns count.

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

-Referenced by _stp_copy_argv_from_user(). +Referenced by _stp_copy_argv_from_user(). -


Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- +
+Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/dir_000000.html b/runtime/docs/html/dir_000000.html index 78bdc36c..f791914d 100644 --- a/runtime/docs/html/dir_000000.html +++ b/runtime/docs/html/dir_000000.html @@ -39,5 +39,5 @@ This directory contains working example probes that demonstrate and test the runtime library.

They are tested on i386 and x86_64.


-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/dir_000001.html b/runtime/docs/html/dir_000001.html index b2802585..37f053ab 100644 --- a/runtime/docs/html/dir_000001.html +++ b/runtime/docs/html/dir_000001.html @@ -13,15 +13,13 @@

Files

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

Detailed Description

Snoops on what commands are being run by shells.

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

+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.
@@ -87,5 +85,5 @@ probe sys_write:entry {
     }
 }
 

-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 7b82c65e..a22bfaa4 100644 --- a/runtime/docs/html/dir_000002.html +++ b/runtime/docs/html/dir_000002.html @@ -25,5 +25,5 @@ Useful for interrupt context testing.

> insmod stp_tasklet.ko > rmmod stp_tasklet.ko


-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 3cb48158..002ee608 100644 --- a/runtime/docs/html/dir_000003.html +++ b/runtime/docs/html/dir_000003.html @@ -38,5 +38,5 @@ probe sys_write:entry { @writes[current->comm] << count; }

-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 263e859d..de4c82b6 100644 --- a/runtime/docs/html/dir_000004.html +++ b/runtime/docs/html/dir_000004.html @@ -20,11 +20,11 @@ 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 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/dirs.html b/runtime/docs/html/dirs.html index 4b3bdc57..fdf2f363 100644 --- a/runtime/docs/html/dirs.html +++ b/runtime/docs/html/dirs.html @@ -15,5 +15,5 @@
-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/files.html b/runtime/docs/html/files.html index ecbc299e..ec707721 100644 --- a/runtime/docs/html/files.html +++ b/runtime/docs/html/files.html @@ -6,18 +6,17 @@

SystemTap File List

Here is a list of all documented files with brief descriptions: - - - + + + - + - @@ -27,5 +26,5 @@
alloc.h [code]
copy.c [code]
io.c [code]
alloc.h [code]Memory allocation functions
copy.c [code]Functions to copy from user space
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]
probes.c [code]Functions to assist loading and unloading groups of probes
README [code]
runtime.h [code]
stack.c [code]
probes/README [code]
probes/shellsnoop/dtr.c [code]
probes/shellsnoop/dtr.mod.c [code]
probes/shellsnoop/README [code]
probes/tasklet/README [code]
probes/tasklet/stp_tasklet.c [code]
probes/where_func/README [code]

-Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 b7efe33e..f81967b0 100644 --- a/runtime/docs/html/functions.html +++ b/runtime/docs/html/functions.html @@ -9,9 +9,19 @@

Here is a list of all documented struct and union fields with links to the struct/union documentation for each field:

+
  • create +: map_root
  • hashes +: map_root
  • head +: map_root
  • hnode +: map_node
  • key +: map_root
  • lnode +: map_node
  • maxnum +: map_root
  • membuf +: map_root
  • no_wrap +: map_root
  • num +: map_root
  • pool +: map_root
  • type +: map_root
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 d70b21ef..261bcd3b 100644 --- a/runtime/docs/html/functions_vars.html +++ b/runtime/docs/html/functions_vars.html @@ -9,9 +9,19 @@

    +
  • create +: map_root
  • hashes +: map_root
  • head +: map_root
  • hnode +: map_node
  • key +: map_root
  • lnode +: map_node
  • maxnum +: map_root
  • membuf +: map_root
  • no_wrap +: map_root
  • num +: map_root
  • pool +: map_root
  • type +: map_root
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 3e4cb61e..d3331603 100644 --- a/runtime/docs/html/globals.html +++ b/runtime/docs/html/globals.html @@ -5,22 +5,35 @@ - + +
    _ | c | d | f | k | m | p | v

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


    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/globals_enum.html b/runtime/docs/html/globals_enum.html index 4bc2a02e..61d85695 100644 --- a/runtime/docs/html/globals_enum.html +++ b/runtime/docs/html/globals_enum.html @@ -1,21 +1,17 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Globals - Enumerations - - - + +

    -
    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/globals_func.html b/runtime/docs/html/globals_func.html index 02c03dcb..2d0c9ba2 100644 --- a/runtime/docs/html/globals_func.html +++ b/runtime/docs/html/globals_func.html @@ -5,11 +5,19 @@ - + +
    _ | c | d

    -

    +

    - c -

      +
    • cur_ret_addr() +: io.c
    +

    - d -


    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/globals_type.html b/runtime/docs/html/globals_type.html index 7c2d40d7..da9cb0bc 100644 --- a/runtime/docs/html/globals_type.html +++ b/runtime/docs/html/globals_type.html @@ -5,12 +5,12 @@ - +


    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/globals_vars.html b/runtime/docs/html/globals_vars.html index 883ff4ee..2c1becac 100644 --- a/runtime/docs/html/globals_vars.html +++ b/runtime/docs/html/globals_vars.html @@ -1,20 +1,19 @@ -SystemTap: SystemTap Runtime Library +SystemTap: Globals - Variables - - - + +

    -
    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/index.html b/runtime/docs/html/index.html index bae6d763..458ba52a 100644 --- a/runtime/docs/html/index.html +++ b/runtime/docs/html/index.html @@ -41,5 +41,5 @@ 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 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/io_8c-source.html b/runtime/docs/html/io_8c-source.html index 246f36d8..c241bba1 100644 --- a/runtime/docs/html/io_8c-source.html +++ b/runtime/docs/html/io_8c-source.html @@ -5,89 +5,129 @@ -

    io.c

    00001 /** Logs data.
    -00002  * This function is compatible with printk.  In fact it currently
    -00003  * sends all output to vprintk, after sending "STP: ". This allows
    -00004  * us to easily detect SystemTap output in the log file.
    -00005  *
    -00006  * @param fmt A variable number of args.
    -00007  * @bug Lines are limited in length by printk buffer.
    -00008  * @todo Needs replaced with something much faster that does not
    -00009  * use the system log.
    -00010  */
    -00011 void dlog (const char *fmt, ...)
    -00012 {
    -00013   va_list args;
    -00014   printk("STP: ");
    -00015   va_start(args, fmt);
    -00016   vprintk(fmt, args);
    -00017   va_end(args);
    -00018 }
    -00019 
    -00020 
    -00021 static const char * (*_stp_kallsyms_lookup)(unsigned long addr,
    -00022                             unsigned long *symbolsize,
    -00023                             unsigned long *offset,
    -00024                             char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP;
    -00025 
    -00026 
    -00027 #define STP_BUF_LEN 8191
    -00028 
    -00029 /* FIXME. These need to be per-cpu */
    -00030 static char _stp_pbuf[STP_BUF_LEN+1];
    -00031 static int _stp_pbuf_len = STP_BUF_LEN;
    -00032 
    -00033 void _stp_print_buf (const char *fmt, ...)
    -00034 {
    -00035   int num;
    -00036   va_list args;
    -00037   char *buf = _stp_pbuf + STP_BUF_LEN - _stp_pbuf_len;
    -00038   va_start(args, fmt);
    -00039   num = vscnprintf(buf, _stp_pbuf_len, fmt, args);
    -00040   va_end(args);
    -00041   if (num > 0)
    -00042     _stp_pbuf_len -= num;
    -00043 }
    -00044 
    -00045 void _stp_print_buf_init (void)
    -00046 {
    -00047   _stp_pbuf_len = STP_BUF_LEN;
    -00048   _stp_pbuf[0] = 0;
    -00049 }
    -00050 
    -00051 void _stp_print_symbol(const char *fmt, unsigned long address)
    -00052 {
    -00053         char *modname;
    -00054         const char *name;
    -00055         unsigned long offset, size;
    -00056         char namebuf[KSYM_NAME_LEN+1];
    -00057 
    -00058         name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
    -00059 
    -00060         if (!name)
    -00061                 _stp_print_buf("0x%lx", address);
    -00062         else {
    -00063           if (modname)
    -00064             _stp_print_buf("%s+%#lx/%#lx [%s]", name, offset,
    -00065                            size, modname);
    -00066           else
    -00067             _stp_print_buf("%s+%#lx/%#lx", name, offset, size);
    -00068         }
    -00069 }
    -00070 
    -00071  
    -00072 unsigned long cur_ret_addr (struct pt_regs *regs)
    +

    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 #ifdef __x86_64__
    -00075   unsigned long *ra = (unsigned long *)regs->rsp;
    -00076 #else
    -00077   unsigned long *ra = (unsigned long *)regs->esp;
    -00078 #endif
    -00079   if (ra)
    -00080     return *ra;
    -00081   else
    -00082     return 0;
    -00083 }
    +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 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/io_8c.html b/runtime/docs/html/io_8c.html index 85784820..ca8818d3 100644 --- a/runtime/docs/html/io_8c.html +++ b/runtime/docs/html/io_8c.html @@ -1,17 +1,19 @@ -SystemTap: SystemTap Runtime Library +SystemTap: io.c File Reference - - -

    io.c File Reference

    + +

    io.c File Reference

    I/O functions. More... +

    +

    Go to the source code of this file. - + @@ -19,42 +21,34 @@ + + + -

    Defines

    #define STP_BUF_LEN   8191
    +#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)
     Print addresses symbolically into the print buffer.
    unsigned long cur_ret_addr (struct pt_regs *regs)
    -


    Define Documentation

    -

    - - - - -
    - - - - -
    #define STP_BUF_LEN   8191
    -
    - - - - + + -

    +

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


    Detailed Description

    +I/O functions.

    -Definition at line 27 of file io.c. +

    -Referenced by _stp_print_buf(), and _stp_print_buf_init(). - - -


    Function Documentation

    +Definition in file io.c.

    Function Documentation

    @@ -89,13 +83,23 @@ Referenced by _stp_print_buf() +Referenced by _stp_print_symbol().

    +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 33 of file io.c. +Definition at line 55 of file io.c.

    -References STP_BUF_LEN. +References _stp_pbuf.

    -Referenced by _stp_print_symbol().

    @@ -123,11 +127,13 @@ Referenced by _stp_print_symbol()<

    - +Clear the print buffer. +

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

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

    -References STP_BUF_LEN. +References _stp_pbuf.

    @@ -164,11 +170,20 @@ References STP_BUF_LEN.

    +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 51 of file io.c. +Definition at line 85 of file io.c.

    -References _stp_print_buf(). +References _stp_kallsyms_lookup, and _stp_print_buf().

    @@ -196,9 +211,18 @@ References _stp_print_buf().

    +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 72 of file io.c. +Definition at line 112 of file io.c.

    @@ -245,16 +269,44 @@ This function is compatible with printk. In fact it currently sends all output t

    Bug:
    Lines are limited in length by printk buffer.

    -

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

    -Definition at line 11 of file io.c. +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]
    +
    + + + + +Referenced by _stp_print_symbol().
    +   + + +

    +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_list_clear(), _stp_register_jprobes(), _stp_register_kprobes(), _stp_unregister_jprobes(), and _stp_unregister_kprobes().

    -


    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/kprobe__where__funct_8c-source.html b/runtime/docs/html/kprobe__where__funct_8c-source.html index 3d7702c1..cccc3205 100644 --- a/runtime/docs/html/kprobe__where__funct_8c-source.html +++ b/runtime/docs/html/kprobe__where__funct_8c-source.html @@ -17,9 +17,9 @@ 00008 #define BUCKETS 16 /* largest histogram width */ 00009 00010 #include "runtime.h" -00011 #include "io.c" +00011 #include "io.c" 00012 #include "map.c" -00013 #include "probes.c" +00013 #include "probes.c" 00014 00015 MODULE_DESCRIPTION("SystemTap probe: where_func"); 00016 MODULE_AUTHOR("Will Cohen and Martin Hunt"); @@ -35,7 +35,7 @@ 00026 00027 static int inst_funct(struct kprobe *p, struct pt_regs *regs) 00028 { -00029 long ret_addr = cur_ret_addr(regs); +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); @@ -67,18 +67,18 @@ 00058 00059 void cleanup_module(void) 00060 { -00061 struct map_node_int64 *ptr; +00061 struct map_node_int64 *ptr; 00062 -00063 _stp_unregister_kprobes (kp, MAX_KPROBES); +00063 _stp_unregister_kprobes (kp, MAX_KPROBES); 00064 -00065 dlog("%s() called %d times.\n", funct_name, count_funct); -00066 dlog("NUM\tCaller Addr\tCaller Name\n", funct_name); +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); +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); @@ -86,5 +86,5 @@ 00077 00078 MODULE_LICENSE("GPL");

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

    Functions

    MAP _stp_map_new (unsigned max_entries, enum valtype type)
    +static unsigned string_hash (const char *key1, const char *key2)
    +static unsigned mixed_hash (const char *key1, long key2)
    MAP _stp_map_new (unsigned max_entries, enum valtype type)
     Create a new map.
    +static void map_free_strings (MAP map, struct map_node *n)
    void _stp_map_key_del (MAP map)
     Deletes the current element.
    void _stp_map_key_long (MAP map, long key)
     Set the map's key to a long.
    +static void map_copy_keys (MAP map, struct map_node *m)
    +static void __stp_map_set_int64 (MAP map, int64_t val, int add)
    void _stp_map_set_int64 (MAP map, int64_t val)
     Set the current element's value to an int64.
    void _stp_map_stat_add (MAP map, int64_t val)
     Add to the current element's statistics.
    MAP _stp_list_new (unsigned max_entries, enum valtype type)
    MAP _stp_list_new (unsigned max_entries, enum valtype type)
     Create a new list.
    void _stp_list_clear (MAP map)
    int _stp_list_size (MAP map)
     Get the number of elements in a list.

    Variables

    static int map_sizes []

    Detailed Description

    Implements maps (associative arrays) and lists. @@ -135,9 +153,9 @@ Adds an int64 to a list.

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

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

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

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

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

    +Referenced by _stp_copy_argv_from_user().

    @@ -223,9 +243,9 @@ All elements in the list are deleted.

    Parameters:

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

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

    @@ -242,7 +262,7 @@ References map_root::head, - enum valtype  + enum valtype  type @@ -274,9 +294,9 @@ A list is a map that internally has an incrementing long key for each member. Li

    See also:
    foreach

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

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

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

    Returns:
    The number of elements in a list.

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

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

    @@ -365,7 +385,7 @@ If the element doesn't exist, it is created. If no current element (key) is set

    See also:
    _stp_map_set_int64

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    See also:
    foreach

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

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

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

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

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

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

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

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

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

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

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

    -Definition at line 223 of file map.c. +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. +References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, and key_data::val.

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

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

    -Definition at line 363 of file map.c. +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. +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.

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

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

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

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

    -Definition at line 315 of file map.c. +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. +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.

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

    -Definition at line 266 of file map.c. +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. +References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, and key_data::str.

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

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

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

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

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

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

    @@ -1045,9 +1065,9 @@ If the element doesn't exist, it is created. If no current element (key) is set

    See also:
    _stp_map_add_int64

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

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

    @@ -1093,14 +1113,14 @@ If the element doesn't exist, it is created. If no current element (key) is set stats pointer to stats struct.

    -
    Todo:
    Histograms don't work yet.
    +
    Todo:
    Histograms don't work yet.

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

    -References _stp_map_key_del(), map_root::create, map_root::head, map_root::key, map_root::maxnum, map_root::no_wrap, and map_root::pool. +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(). +Referenced by _stp_map_stat_add().

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

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

    -References _stp_map_key_del(), map_root::create, map_root::head, map_root::key, map_root::maxnum, map_root::no_wrap, and map_root::pool. +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(). +Referenced by _stp_list_add_str().

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

    See also:
    foreach

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

    -References map_root::head. +References map_root::head.

    @@ -1239,14 +1259,46 @@ If the element doesn't exist, it is created. If no current element (key) is set val value to add to the statistics -

    Todo:
    Histograms don't work yet.
    +
    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]
    +
    + + + + +Definition at line 6 of file map.c.
    +   +

    -Definition at line 743 of file map.c. +Initial value:

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

    -References _stp_map_set_stat(), map_root::create, and map_root::key.


    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/map_8h-source.html b/runtime/docs/html/map_8h-source.html index 443fb9c9..26b210d2 100644 --- a/runtime/docs/html/map_8h-source.html +++ b/runtime/docs/html/map_8h-source.html @@ -7,156 +7,183 @@

    map.h

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

    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) -#define _stp_map_key2(map, key1, key2) + Extracts int from key2 union.
    +#define _stp_map_key2(map, key1, key2) -#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) -#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) -#define _stp_list_add(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_list_add function based on the types of the argument.
    #define foreach(map, ptr)  Loop through all elements of a map.
    @@ -42,21 +50,24 @@ typedef map_root *  All maps are of this type.

    Enumerations

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

    Variables

    -enum keytype packed +enum keytype packed + keys can be longs or strings

    Detailed Description

    Header file for maps and lists. @@ -98,9 +109,12 @@ Definition in file map.h.

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

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

    Note:
    May cause compiler warning on some GCCs
    + +

    +Definition at line 159 of file map.h.

    @@ -137,9 +151,12 @@ Definition at line 132 of fil 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 116 of file map.h. +Definition at line 135 of file map.h.

    @@ -185,9 +202,12 @@ Definition at line 116 of fil 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.

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

    Note:
    May cause compiler warning on some GCCs
    + +

    +Definition at line 117 of file map.h.

    @@ -224,9 +244,12 @@ Definition at line 102 of fil 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 124 of file map.h. +Definition at line 147 of file map.h.

    @@ -264,12 +287,12 @@ Definition at line 124 of fil

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

    -Definition at line 149 of file map.h. +Definition at line 176 of file map.h.


    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/pages.html b/runtime/docs/html/pages.html index 0760af31..1357fe26 100644 --- a/runtime/docs/html/pages.html +++ b/runtime/docs/html/pages.html @@ -8,7 +8,9 @@

    SystemTap Related Pages

    Here is a list of all related documentation pages:
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 2f787b1a..9f0d714a 100644 --- a/runtime/docs/html/probes_2README-source.html +++ b/runtime/docs/html/probes_2README-source.html @@ -12,5 +12,5 @@ 00003 the runtime library. They are tested on i386 and x86_64. 00004 */
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 2a2ac71d..25dfde60 100644 --- a/runtime/docs/html/probes_2shellsnoop_2README-source.html +++ b/runtime/docs/html/probes_2shellsnoop_2README-source.html @@ -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,12 @@ 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 00:32:02 2005 for SystemTap. +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 bef82d09..c42d0a1a 100644 --- a/runtime/docs/html/probes_2tasklet_2README-source.html +++ b/runtime/docs/html/probes_2tasklet_2README-source.html @@ -18,5 +18,5 @@ 00009 00010 */
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 2a5a48f3..17cd7350 100644 --- a/runtime/docs/html/probes_2test4_2README-source.html +++ b/runtime/docs/html/probes_2test4_2README-source.html @@ -32,5 +32,5 @@ 00023 \endverbatim 00024 */
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 a9995043..7752c02d 100644 --- a/runtime/docs/html/probes_2where__func_2README-source.html +++ b/runtime/docs/html/probes_2where__func_2README-source.html @@ -34,5 +34,5 @@ 00025 -Will Cohen 00026 */
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 3446e997..5fe6164c 100644 --- a/runtime/docs/html/probes_8c-source.html +++ b/runtime/docs/html/probes_8c-source.html @@ -5,87 +5,108 @@ -

    probes.c

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

    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.
    +00004  */
    +00005 
    +00006 /** Lookup name.
    +00007  * This simply calls the kernel function kallsyms_lookup_name().
    +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;
    +00012 
    +00013 /** Unregister a group of jprobes.
    +00014  * @param probes Pointer to an array of struct jprobe.
    +00015  * @param num_probes Number of probes in the array.
    +00016  */
    +00017 
    +00018 void _stp_unregister_jprobes (struct jprobe *probes, int num_probes)
    +00019 {
    +00020         int i;
    +00021         for (i = 0; i < num_probes; i++)
    +00022                 unregister_jprobe(&probes[i]);
    +00023         dlog ("All jprobes removed\n");
    +00024 }
    +00025 
    +00026 /** Register a group of jprobes.
    +00027  * @param probes Pointer to an array of struct jprobe.
    +00028  * @param num_probes Number of probes in the array.
    +00029  * @return 0 on success.
    +00030  */
    +00031 
    +00032 int _stp_register_jprobes (struct jprobe *probes, int num_probes)
    +00033 {
    +00034         int i, ret ;
    +00035         unsigned long addr;
    +00036 
    +00037         for (i = 0; i < num_probes; i++) {
    +00038                 addr =_stp_lookup_name((char *)probes[i].kp.addr);
    +00039                 if (addr == 0) {
    +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);
    +00046                 probes[i].kp.addr = (kprobe_opcode_t *)addr;
    +00047                 ret = register_jprobe(&probes[i]);
    +00048                 if (ret)
    +00049                         goto out;
    +00050         }
    +00051         return 0;
    +00052 out:
    +00053         dlog ("probe module initialization failed.  Exiting...\n");
    +00054         _stp_unregister_jprobes(probes, i);
    +00055         return ret;
    +00056 }
    +00057 
    +00058 /** Unregister a group of kprobes.
    +00059  * @param probes Pointer to an array of struct kprobe.
    +00060  * @param num_probes Number of probes in the array.
    +00061  */
    +00062 
    +00063 void _stp_unregister_kprobes (struct kprobe *probes, int num_probes)
    +00064 {
    +00065         int i;
    +00066         for (i = 0; i < num_probes; i++)
    +00067                 unregister_kprobe(&probes[i]);
    +00068         dlog ("All kprobes removed\n");
    +00069 }
    +00070 
    +00071 /** Register a group of kprobes.
    +00072  * @param probes Pointer to an array of struct kprobe.
    +00073  * @param num_probes Number of probes in the array.
    +00074  * @return 0 on success.
    +00075  */
    +00076 
    +00077 int _stp_register_kprobes (struct kprobe *probes, int num_probes)
    +00078 {
    +00079         int i, ret ;
    +00080         unsigned long addr;
     00081 
    +00082         for (i = 0; i < num_probes; i++) {
    +00083                 addr =_stp_lookup_name((char *)probes[i].addr);
    +00084                 if (addr == 0) {
    +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);
    +00091                 probes[i].addr = (kprobe_opcode_t *)addr;
    +00092                 ret = register_kprobe(&probes[i]);
    +00093                 if (ret)
    +00094                         goto out;
    +00095         }
    +00096         return 0;
    +00097 out:
    +00098         dlog ("probe module initialization failed.  Exiting...\n");
    +00099         _stp_unregister_kprobes(probes, i);
    +00100         return ret;
    +00101 }
    +00102 
     

    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 15ceb18c..8a13bb24 100644 --- a/runtime/docs/html/probes_8c.html +++ b/runtime/docs/html/probes_8c.html @@ -1,26 +1,40 @@ -SystemTap: SystemTap Runtime Library +SystemTap: probes.c File Reference - - -

    probes.c File Reference

    + +

    probes.c File Reference

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

    +

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

    Functions

    void _stp_unregister_jprobes (struct jprobe *probes, int num_probes)
     Unregister a group of jprobes.
    int _stp_register_jprobes (struct jprobe *probes, int num_probes)
     Register a group of jprobes.
    void _stp_unregister_kprobes (struct kprobe *probes, int num_probes)
     Unregister a group of kprobes.
    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.
    -


    Function Documentation

    +

    Detailed Description

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

    + +

    +Definition in file probes.c.


    Function Documentation

    @@ -55,11 +69,20 @@ +References _stp_lookup_name, _stp_unregister_jprobes(), and dlog().

    +Register a group of jprobes. +

    +

    Parameters:
    + + + +
    probes Pointer to an array of struct jprobe.
    num_probes Number of probes in the array.
    +
    +
    Returns:
    0 on success.

    -Definition at line 22 of file probes.c. +Definition at line 32 of file probes.c.

    -References _stp_unregister_jprobes(), and dlog().

    @@ -96,11 +119,20 @@ References _stp_unregister_jpr

    +Register a group of kprobes. +

    +

    Parameters:
    + + + +
    probes Pointer to an array of struct kprobe.
    num_probes Number of probes in the array.
    +
    +
    Returns:
    0 on success.

    -Definition at line 56 of file probes.c. +Definition at line 77 of file probes.c.

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

    @@ -137,13 +169,21 @@ References _stp_unregister_kpr

    +Unregister a group of jprobes. +

    +

    Parameters:
    + + + +
    probes Pointer to an array of struct jprobe.
    num_probes Number of probes in the array.
    +

    -Definition at line 14 of file probes.c. +Definition at line 18 of file probes.c.

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

    -Referenced by _stp_register_jprobes(). +Referenced by _stp_register_jprobes().

    @@ -180,17 +220,53 @@ Referenced by _stp_register_jp

    +Unregister a group of kprobes. +

    +

    Parameters:
    + + + +
    probes Pointer to an array of struct kprobe.
    num_probes Number of probes in the array.
    +
    + +

    +Definition at line 63 of file probes.c. +

    +References dlog(). +

    +Referenced by _stp_register_kprobes(). + + +


    Variable Documentation

    +

    + + + + +
    + + + + +
    unsigned long(* _stp_lookup_name)(char *name) = (void *)KALLSYMS_LOOKUP_NAME [static]
    +
    + + + + +Referenced by _stp_register_jprobes(), and _stp_register_kprobes().
    +   +

    -Definition at line 48 of file probes.c. +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.

    -References dlog(). +Definition at line 11 of file probes.c.

    -Referenced by _stp_register_kprobes().

    -


    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - +
    +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 ec00eb2b..00feb2d8 100644 --- a/runtime/docs/html/runtime_8h-source.html +++ b/runtime/docs/html/runtime_8h-source.html @@ -21,11 +21,11 @@ 00014 #include <asm/uaccess.h> 00015 #include <linux/kallsyms.h> 00016 -00017 #include "alloc.h" +00017 #include "alloc.h" 00018 #include "map.h" 00019 00020 #define dbug(args...) ; 00021

    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/shellsnoop_2dtr_8c-source.html b/runtime/docs/html/shellsnoop_2dtr_8c-source.html index 7f6aa12c..64f58859 100644 --- a/runtime/docs/html/shellsnoop_2dtr_8c-source.html +++ b/runtime/docs/html/shellsnoop_2dtr_8c-source.html @@ -12,10 +12,10 @@ 00003 #define BUCKETS 16 /* largest histogram width */ 00004 00005 #include "runtime.h" -00006 #include "io.c" +00006 #include "io.c" 00007 #include "map.c" -00008 #include "copy.c" -00009 #include "probes.c" +00008 #include "copy.c" +00009 #include "probes.c" 00010 00011 MODULE_DESCRIPTION("SystemTap probe: shellsnoop"); 00012 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); @@ -24,7 +24,7 @@ 00015 00016 int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs) 00017 { -00018 struct map_node_str *ptr; +00018 struct map_node_str *ptr; 00019 00020 /* watch shells only */ 00021 /* FIXME: detect more shells, like csh, tcsh, zsh */ @@ -32,13 +32,13 @@ 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); 00030 00031 _stp_list_clear (arglist); -00032 _stp_copy_argv_from_user (arglist, argv); +00032 _stp_copy_argv_from_user (arglist, argv); 00033 foreach (arglist, ptr) 00034 printk ("%s ", ptr->str); 00035 printk ("\n"); @@ -51,7 +51,7 @@ 00042 { 00043 _stp_map_key_long (pids, current->pid); 00044 if (_stp_map_get_int64 (pids)) -00045 dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename); +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; @@ -61,7 +61,7 @@ 00052 { 00053 _stp_map_key_long (pids, current->pid); 00054 if (_stp_map_get_int64 (pids)) -00055 dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd); +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; @@ -116,17 +116,17 @@ 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); +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); +00118 _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE); 00119 _stp_map_del (pids); -00120 dlog("EXIT\n"); +00120 dlog("EXIT\n"); 00121 } 00122 00123 module_init(init_dtr); @@ -134,5 +134,5 @@ 00125 MODULE_LICENSE("GPL"); 00126
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 d6b1e224..dda3013a 100644 --- a/runtime/docs/html/stack_8c-source.html +++ b/runtime/docs/html/stack_8c-source.html @@ -19,7 +19,7 @@ 00012 char *delim = ":"; 00013 char namebuf[128]; 00014 -00015 symname = _stp_kallsyms_lookup(address, &symsize, &offset, &modname, namebuf); +00015 symname = _stp_kallsyms_lookup(address, &symsize, &offset, &modname, namebuf); 00016 if (!symname) 00017 return printk("[<%016lx>]", address); 00018 if (!modname) @@ -180,5 +180,5 @@ 00173 } 00174 #endif
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/stp__tasklet_8c-source.html b/runtime/docs/html/stp__tasklet_8c-source.html index 5e9413ae..93f8b84c 100644 --- a/runtime/docs/html/stp__tasklet_8c-source.html +++ b/runtime/docs/html/stp__tasklet_8c-source.html @@ -16,8 +16,8 @@ 00007 #define BUCKETS 16 /* largest histogram width */ 00008 00009 #include "runtime.h" -00010 #include "io.c" -00011 #include "probes.c" +00010 #include "io.c" +00011 #include "probes.c" 00012 00013 MODULE_DESCRIPTION("test jprobes of tasklets"); 00014 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); @@ -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 @@ -40,15 +40,15 @@ 00031 00032 static int init_stp(void) 00033 { -00034 int ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES); -00035 dlog("instrumentation is enabled...\n"); +00034 int ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES); +00035 dlog("instrumentation is enabled...\n"); 00036 return ret; 00037 } 00038 00039 static void cleanup_stp(void) 00040 { -00041 _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES); -00042 dlog ("EXIT\n"); +00041 _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES); +00042 dlog ("EXIT\n"); 00043 } 00044 00045 module_init(init_stp); @@ -56,5 +56,5 @@ 00047 MODULE_LICENSE("GPL"); 00048
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 9902b165..d2fc751c 100644 --- a/runtime/docs/html/structmap__node.html +++ b/runtime/docs/html/structmap__node.html @@ -5,7 +5,7 @@ -

    map_node Struct Reference

    all map nodes have the following structure +

    map_node Struct Reference

    basic map element More...

    #include <map.h> @@ -14,11 +14,13 @@

    Data Fields

    -list_head lnode +list_head lnode + list of other nodes in the map
    -hlist_node hnode +hlist_node hnode + list of nodes with the same hash value
    key_data key1 @@ -26,19 +28,19 @@ hlist_node hnode< key_data key2 -enum keytype key1type +enum keytype key1type -enum keytype key2type +enum keytype key2type

    Detailed Description

    -all map nodes have the following structure +basic map element

    Definition at line 29 of file map.h.


    The documentation for this struct was generated from the following file:
    -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 1ac8d35a..7dc8e5e6 100644 --- a/runtime/docs/html/structmap__node__int64.html +++ b/runtime/docs/html/structmap__node__int64.html @@ -1,78 +1,32 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map_node_int64 Struct Reference - - -

    map_node_int64 Struct Reference

    #include <map.h> + +

    map_node_int64 Struct Reference

    map element containing int64 +More... +

    +#include <map.h>

    - - - - -

    Data Fields

    map_node n
    int64_t val
    -


    Field Documentation

    -

    - - - - -
    - - - - -
    struct map_node map_node_int64::n
    -
    - - - - -

    +

    -

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

    -   - +
    +map_node n
    +int64_t val
    -

    - - - -
    - - - - -
    int64_t map_node_int64::val
    -
    - - - - - -
    -   - - +

    Detailed Description

    +map element containing int64

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

    -Referenced by _stp_map_get_int64().

    -


    The documentation for this struct was generated from the following file:
      +Definition at line 41 of file map.h.
      The documentation for this struct was generated from the following file: -
      Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
      - +
      +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 3105ecbe..a094c11d 100644 --- a/runtime/docs/html/structmap__node__stat.html +++ b/runtime/docs/html/structmap__node__stat.html @@ -1,80 +1,32 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map_node_stat Struct Reference - - -

      map_node_stat Struct Reference

      #include <map.h> + +

      map_node_stat Struct Reference

      map element containing stats +More... +

      +#include <map.h>

      - + - +

      Data Fields

      map_node n
      +map_node n
      stat stats
      +stat stats
      -


      Field Documentation

      -

      - - - - -
      - - - - -
      struct map_node map_node_stat::n
      -
      - - - - - -
      -   - - +

      Detailed Description

      +map element containing stats

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

      -Referenced by _stp_map_set_stat().

      -

      - - - - -
      - - - - -
      stat map_node_stat::stats
      -
      - - - - - -
      -   - - -

      - -

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

      -Referenced by _stp_map_get_stat(), _stp_map_set_stat(), and _stp_map_stat_add().

      -


      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 Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
        - +
        +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 e0a90676..6aa4ef38 100644 --- a/runtime/docs/html/structmap__node__str.html +++ b/runtime/docs/html/structmap__node__str.html @@ -1,80 +1,32 @@ -SystemTap: SystemTap Runtime Library +SystemTap: map_node_str Struct Reference - - -

        map_node_str Struct Reference

        #include <map.h> + +

        map_node_str Struct Reference

        map element containing string +More... +

        +#include <map.h>

        - + - +

        Data Fields

        map_node n
        +map_node n
        char * str
        +char * str
        -


        Field Documentation

        -

        - - - - -
        - - - - -
        struct map_node map_node_str::n
        -
        - - - - - -
        -   - - +

        Detailed Description

        +map element containing string

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

        -Referenced by _stp_map_set_str().

        -

        - - - - -
        - - - - -
        char* map_node_str::str
        -
        - - - - - -
        -   - - -

        - -

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

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

        -


        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 Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
          - +
          +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 a55fe7b8..0fdd005f 100644 --- a/runtime/docs/html/structmap__root.html +++ b/runtime/docs/html/structmap__root.html @@ -14,36 +14,40 @@

          Data Fields

          -enum valtype type +enum valtype type + type of the values stored in the array
          int maxnum - type of the values stored in the array
          + maximum number of elements allowed in the array.
          int num - maximum number of elements allowed in the array.
          + current number of used elements
          -int no_wrap +int no_wrap + when more than maxnum elements, wrap or discard?
          -list_head head +list_head head - -list_head pool + linked list of current entries
          +list_head pool + pool of unused entries.
          -map_nodekey +map_nodekey - -u_int8_t create + saved key entry for lookups
          +u_int8_t create + 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 @@ -55,11 +59,12 @@ hlist_head * c_keyhead key_data c_key2 -hlist_head hashes [HASH_TABLE_SIZE] +hlist_head hashes [HASH_TABLE_SIZE] - -void * membuf + the hash table for this array
          +void * membuf + pointer to allocated memory space.

          Detailed Description

          This structure contains all information about a map. @@ -68,8 +73,97 @@ It is allocated once when _stp_map_new()

          -Definition at line 57 of file map.h.


          The documentation for this struct was generated from the following file:
            +Definition at line 61 of file map.h.

            Field Documentation

            +

            + + + + +
            + + + + +
            u_int8_t map_root::create
            +
            + + + + + +
            +   + + +

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

            +Definition at line 87 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().

            +

            + + + + +
            + + + + +
            void* map_root::membuf
            +
            + + + + + +
            +   + + +

            +pointer to allocated memory space. +

            +Used for freeing memory. +

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

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

            +

            + + + + +
            + + + + +
            struct list_head map_root::pool
            +
            + + + + + +
            +   + + +

            +pool of unused entries. +

            +Used only when entries are statically allocated at startup. +

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

            +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 00:32:02 2005 for SystemTap. +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 8f010fa8..ef5b86e0 100644 --- a/runtime/docs/html/structstat.html +++ b/runtime/docs/html/structstat.html @@ -34,8 +34,8 @@ Statistics are stored in this struct.

            -Definition at line 10 of file map.h.


            The documentation for this struct was generated from the following file:
              +Definition at line 9 of file map.h.
              The documentation for this struct was generated from the following file:
              -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/test4_2dtr_8c-source.html b/runtime/docs/html/test4_2dtr_8c-source.html index 21acb158..47241e71 100644 --- a/runtime/docs/html/test4_2dtr_8c-source.html +++ b/runtime/docs/html/test4_2dtr_8c-source.html @@ -12,9 +12,9 @@ 00003 #define BUCKETS 16 /* largest histogram width */ 00004 00005 #include "runtime.h" -00006 #include "io.c" +00006 #include "io.c" 00007 #include "map.c" -00008 #include "probes.c" +00008 #include "probes.c" 00009 00010 MODULE_DESCRIPTION("SystemTap probe: test4"); 00011 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>"); @@ -70,33 +70,33 @@ 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); +00064 ret = _stp_register_jprobes (dtr_probes, MAX_DTR_ROUTINE); 00065 -00066 dlog("instrumentation is enabled...\n"); +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; +00073 struct map_node_stat *st; +00074 struct map_node_int64 *ptr; 00075 -00076 _stp_unregister_jprobes (dtr_probes, MAX_DTR_ROUTINE); +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)) +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)) +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)) +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"); @@ -113,5 +113,5 @@ 00104 MODULE_LICENSE("GPL"); 00105
              -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +Generated on Tue Mar 22 10:27:36 2005 for SystemTap. diff --git a/runtime/docs/html/todo.html b/runtime/docs/html/todo.html index f5c671f4..e3973e18 100644 --- a/runtime/docs/html/todo.html +++ b/runtime/docs/html/todo.html @@ -5,15 +5,30 @@ -

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

              +

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

              +

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

              -

              +
              Global _stp_map_stat_add (MAP map, int64_t val)
              Histograms don't work yet.

              -Generated on Tue Mar 22 00:32:02 2005 for SystemTap. +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 35c1710d..92d878af 100644 --- a/runtime/docs/html/unionkey__data.html +++ b/runtime/docs/html/unionkey__data.html @@ -25,8 +25,8 @@ Keys are either longs or char *.

              -Definition at line 19 of file map.h.


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