From 655ee2825121e149a9976e562946892efb20aea1 Mon Sep 17 00:00:00 2001 From: hunt Date: Thu, 7 Apr 2005 21:48:47 +0000 Subject: *** empty log message *** --- runtime/Doxyfile | 8 +- runtime/README | 165 ++-- runtime/TODO | 34 + runtime/copy.c | 13 +- runtime/docs/html/MAP-example.html | 17 - runtime/docs/html/README-source.html | 169 ++-- runtime/docs/html/README.html | 18 - runtime/docs/html/TODO-source.html | 42 + runtime/docs/html/TODO.html | 42 + runtime/docs/html/alloc_8c-source.html | 2 +- runtime/docs/html/alloc_8c.html | 2 +- runtime/docs/html/alloc_8h-source.html | 85 -- runtime/docs/html/alloc_8h.html | 249 ----- runtime/docs/html/annotated.html | 17 - runtime/docs/html/argv__example_8c-example.html | 32 - runtime/docs/html/bug.html | 11 +- runtime/docs/html/copy_8c-source.html | 332 ++++--- runtime/docs/html/copy_8c.html | 14 +- runtime/docs/html/current_8c-source.html | 2 +- runtime/docs/html/current_8c.html | 2 +- runtime/docs/html/deprecated.html | 12 + 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 | 6 +- runtime/docs/html/dir_000004.html | 4 +- runtime/docs/html/dirs.html | 2 +- .../docs/html/docs_2argv__example_8c-example.html | 20 - runtime/docs/html/dtr_8mod_8c-source.html | 60 +- runtime/docs/html/examples.html | 16 - runtime/docs/html/files.html | 11 +- runtime/docs/html/foreach_8c-example.html | 28 - runtime/docs/html/ftv2blank.png | Bin 174 -> 0 bytes runtime/docs/html/ftv2doc.png | Bin 255 -> 0 bytes runtime/docs/html/ftv2folderclosed.png | Bin 259 -> 0 bytes runtime/docs/html/ftv2folderopen.png | Bin 261 -> 0 bytes runtime/docs/html/ftv2lastnode.png | Bin 233 -> 0 bytes runtime/docs/html/ftv2link.png | Bin 358 -> 0 bytes runtime/docs/html/ftv2mlastnode.png | Bin 160 -> 0 bytes runtime/docs/html/ftv2mnode.png | Bin 194 -> 0 bytes runtime/docs/html/ftv2node.png | Bin 235 -> 0 bytes runtime/docs/html/ftv2plastnode.png | Bin 165 -> 0 bytes runtime/docs/html/ftv2pnode.png | Bin 200 -> 0 bytes runtime/docs/html/ftv2vertline.png | Bin 229 -> 0 bytes runtime/docs/html/functions.html | 25 - runtime/docs/html/functions_vars.html | 25 - runtime/docs/html/globals.html | 83 +- runtime/docs/html/globals_defs.html | 23 +- runtime/docs/html/globals_enum.html | 6 +- runtime/docs/html/globals_eval.html | 27 - runtime/docs/html/globals_func.html | 56 +- runtime/docs/html/globals_type.html | 2 +- runtime/docs/html/globals_vars.html | 2 +- runtime/docs/html/group__alloc.html | 8 +- runtime/docs/html/group__copy.html | 99 +- runtime/docs/html/group__current.html | 2 +- runtime/docs/html/group__io.html | 98 +- runtime/docs/html/group__list.html | 58 -- runtime/docs/html/group__lists.html | 141 ++- runtime/docs/html/group__maps.html | 342 ++++--- runtime/docs/html/group__print.html | 342 +++++++ runtime/docs/html/group__scbuf.html | 160 ---- runtime/docs/html/group__stack.html | 76 +- runtime/docs/html/group__string.html | 389 ++++++++ runtime/docs/html/group__sym.html | 51 +- runtime/docs/html/index.html | 37 +- runtime/docs/html/io_8c-source.html | 176 ++-- runtime/docs/html/io_8c.html | 22 +- .../docs/html/kprobe__where__funct_8c-source.html | 153 +-- runtime/docs/html/main.html | 17 - runtime/docs/html/map_8c-source.html | 1004 ++++++++++---------- runtime/docs/html/map_8c.html | 73 +- runtime/docs/html/map_8h-source.html | 232 ++--- runtime/docs/html/map_8h.html | 46 +- runtime/docs/html/modules.html | 5 +- runtime/docs/html/pages.html | 4 +- runtime/docs/html/print_8c-source.html | 208 ++++ runtime/docs/html/probes.html | 10 - 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 | 209 ++-- runtime/docs/html/probes_8c.html | 46 +- runtime/docs/html/relay-app_8h-source.html | 542 +++++++++++ runtime/docs/html/runtime_8h-source.html | 6 +- runtime/docs/html/runtime_8h.html | 3 +- runtime/docs/html/scbuf_8c-source.html | 103 -- runtime/docs/html/shellsnoop_2dtr_8c-source.html | 194 ++-- runtime/docs/html/stack_8c-source.html | 280 +++--- runtime/docs/html/stack_8c.html | 6 +- runtime/docs/html/stp__tasklet_8c-source.html | 89 +- runtime/docs/html/string_8c-source.html | 170 ++++ runtime/docs/html/string_8c.html | 52 + runtime/docs/html/structmap__node.html | 47 - runtime/docs/html/structmap__node__int64.html | 33 - runtime/docs/html/structmap__node__stat.html | 33 - runtime/docs/html/structmap__node__str.html | 33 - runtime/docs/html/structmap__root.html | 170 ---- runtime/docs/html/structstat.html | 42 - runtime/docs/html/sym_8c-source.html | 98 +- runtime/docs/html/test4_2dtr_8c-source.html | 385 +++----- runtime/docs/html/todo.html | 93 +- runtime/docs/html/tree.html | 139 --- runtime/docs/html/unionkey__data.html | 33 - runtime/io.c | 23 +- runtime/map.c | 30 +- runtime/map.h | 36 +- runtime/print.c | 54 +- runtime/probes.c | 5 +- runtime/stack.c | 17 +- runtime/string.c | 84 +- runtime/sym.c | 10 +- 114 files changed, 4750 insertions(+), 3756 deletions(-) create mode 100644 runtime/TODO delete mode 100644 runtime/docs/html/MAP-example.html delete mode 100644 runtime/docs/html/README.html create mode 100644 runtime/docs/html/TODO-source.html create mode 100644 runtime/docs/html/TODO.html delete mode 100644 runtime/docs/html/alloc_8h-source.html delete mode 100644 runtime/docs/html/alloc_8h.html delete mode 100644 runtime/docs/html/annotated.html delete mode 100644 runtime/docs/html/argv__example_8c-example.html create mode 100644 runtime/docs/html/deprecated.html delete mode 100644 runtime/docs/html/docs_2argv__example_8c-example.html delete mode 100644 runtime/docs/html/examples.html delete mode 100644 runtime/docs/html/foreach_8c-example.html delete mode 100644 runtime/docs/html/ftv2blank.png delete mode 100644 runtime/docs/html/ftv2doc.png delete mode 100644 runtime/docs/html/ftv2folderclosed.png delete mode 100644 runtime/docs/html/ftv2folderopen.png delete mode 100644 runtime/docs/html/ftv2lastnode.png delete mode 100644 runtime/docs/html/ftv2link.png delete mode 100644 runtime/docs/html/ftv2mlastnode.png delete mode 100644 runtime/docs/html/ftv2mnode.png delete mode 100644 runtime/docs/html/ftv2node.png delete mode 100644 runtime/docs/html/ftv2plastnode.png delete mode 100644 runtime/docs/html/ftv2pnode.png delete mode 100644 runtime/docs/html/ftv2vertline.png delete mode 100644 runtime/docs/html/functions.html delete mode 100644 runtime/docs/html/functions_vars.html delete mode 100644 runtime/docs/html/globals_eval.html delete mode 100644 runtime/docs/html/group__list.html create mode 100644 runtime/docs/html/group__print.html delete mode 100644 runtime/docs/html/group__scbuf.html create mode 100644 runtime/docs/html/group__string.html delete mode 100644 runtime/docs/html/main.html create mode 100644 runtime/docs/html/print_8c-source.html delete mode 100644 runtime/docs/html/probes.html create mode 100644 runtime/docs/html/relay-app_8h-source.html delete mode 100644 runtime/docs/html/scbuf_8c-source.html create mode 100644 runtime/docs/html/string_8c-source.html create mode 100644 runtime/docs/html/string_8c.html delete mode 100644 runtime/docs/html/structmap__node.html delete mode 100644 runtime/docs/html/structmap__node__int64.html delete mode 100644 runtime/docs/html/structmap__node__stat.html delete mode 100644 runtime/docs/html/structmap__node__str.html delete mode 100644 runtime/docs/html/structmap__root.html delete mode 100644 runtime/docs/html/structstat.html delete mode 100644 runtime/docs/html/tree.html delete mode 100644 runtime/docs/html/unionkey__data.html (limited to 'runtime') diff --git a/runtime/Doxyfile b/runtime/Doxyfile index 829b83e0..5854b4a8 100644 --- a/runtime/Doxyfile +++ b/runtime/Doxyfile @@ -23,7 +23,7 @@ PROJECT_NAME = SystemTap # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.1 +PROJECT_NUMBER = 0.2 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -432,7 +432,7 @@ INPUT = # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp # *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm -FILE_PATTERNS = *.c *.h README +FILE_PATTERNS = *.c *.h README TODO # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. @@ -444,7 +444,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = docs tests +EXCLUDE = docs tests relayfs stpd # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories # that are symbolic links (a Unix filesystem feature) are excluded from the input. @@ -457,7 +457,7 @@ EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = Makefile.* ChangeLog CHANGES CHANGES.* \ README.* *.png AUTHORS DESIGN DESIGN.* *.desktop \ - DESKTOP* COMMENTS HOWTO magic NOTES TODO THANKS Doxyfile + DESKTOP* COMMENTS HOWTO magic NOTES THANKS Doxyfile # The EXAMPLE_PATH tag can be used to specify one or more files or diff --git a/runtime/README b/runtime/README index cf38f882..e0e32a37 100644 --- a/runtime/README +++ b/runtime/README @@ -1,56 +1,111 @@ -/** @mainpage SystemTap Runtime Library - * - * @section intro_sec Introduction - * - * The SystemTap Runtime Library consists of all functions - * and code fragments needed by the compiler/translator to - * include in building a kernel module using kprobes. - * - * @section design_sec Design - * @subsection impl_sec Implementation - * The library is written in \c C and is really not a library but a collection of code - * That can be conditionally included in a modules. It will probably become a library later. - * - * @subsection map_sec Maps (Associative Arrays) - * Maps are implemented as hash lists. It is not expected that users will - * attempt to collect so much data in kernel space that performance problems will require - * more complex solutions such as AVL trees. - * - * Maps are created with _stp_map_new(). Each map can hold only one type of - * data; int64, string, or statistics. Each element belonging to a map can have up to 2 keys - * and a value. Implemented key types are strings and longs. - * - * To simplify the implementation, the functions to set the key and the functions to set the data are separated. - * That means we need only 4 functions to set the key and 3 functions to set the value. - * - * For example: - * @include map.c - - * All elements have a default value of 0 (or NULL). Elements are only saved to the map when their value is set - * to something nonzero. This means that querying for the existance of a key is inexpensive because - * no element is created, just a hash table lookup. - * - * @subsection list_sec Lists - * A list is a special map which has internally ascending long integer keys. Adding a value to - * a list does not require setting a key first. Create a list with _stp_list_new(). Add to it - * with _stp_list_add_str() and _stp_list_add_int64(). Clear it with _stp_list_clear(). - * - * @section status_sec Status - * @li Maps are implemented and tested. Histograms are not yet finished. - * @li Copy_From_User functions are done. - * @li If maps overflow or memory runs out for some reason, globals are set but nothing is done yet. - * I expect to implement a function to tell the system to either ignore it or unload the module and quit. - * @li Locking and per-cpu data are not yet implemented to be SMP-safe. This is not yet necessary because the - * current kprobes implementation single-threads probes for us. - * - * @section probe_sec Example Probes - * - * Working sample probe code using the runtime is in runtime/probes. - * Browse probes. - * - * @section todo_sec ToDo - * \link todo Click Here for Complete List \endlink - * - * @section links Links - * SystemTap Project Page +/** @mainpage SystemTap Runtime + +@section intro_sec Introduction + +This document describes the implementation of the SystemTap Runtime. It is intended for developers +of the SystemTap Language translator or, possibly TapSet authors. These functions are not directly +available from the SystemTap Language. + +The SystemTap Runtime Library consists of all functions +and code fragments needed by the compiler/translator to +include in building a kernel module using kprobes. It +also include I/O code to transmit its output from the kernel to userspace. + +In addition to the library, the runtime includes a SystemTap user-space daemon +(stpd). Stpd grabs data sent from the I/O code in the runtime and displays it +and/or saves it to files. Stpd (or a script invoking it) will handle other issues like +inserting and removing modules. + +Stpd and the I/O code make use of both relayfs and netlink for communication. For +kernels without relayfs builtin, it is provided as a standalone module under the runtime directory. + +@section design_sec Design +@subsection impl_sec Implementation +The library is written in C and is really not a library but a collection of code +That can be conditionally included in a modules. It may become a library later, but for now +there are some advantages to being able to change the sizes of static items with simple #defines. + +@subsection map_sec Maps (Associative Arrays) +Maps are implemented as hash lists. It is not expected that users will +attempt to collect so much data in kernel space that performance problems will require +more complex solutions such as AVL trees. + +Maps are created with _stp_map_new(). Each map can hold only one type of +data; int64, string, or statistics. Each element belonging to a map can have up to 2 keys +and a value. Implemented key types are strings and longs. + +To simplify the implementation, the functions to set the key and the functions to set the data are separated. +That means we need only 4 functions to set the key and 3 functions to set the value. + +For example: +\code +/* create a map with a max of 100 elements */ +MAP mymap = map_new(100, INT64); + +/* mymap[birth year] = 2000 */ +map_key_str (mymap, "birth year"); +map_set_int64 (mymap, 2000); +\endcode + +All elements have a default value of 0 (or NULL). Elements are only saved to the map when their value is set +to something nonzero. This means that querying for the existance of a key is inexpensive because +no element is created, just a hash table lookup. + +@subsection list_sec Lists +A list is a special map which has internally ascending long integer keys. Adding a value to +a list does not require setting a key first. Create a list with _stp_list_new(). Add to it +with _stp_list_add_str() and _stp_list_add_int64(). Clear it with _stp_list_clear(). + +@subsection string_sec Strings +One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack. +It is also not a good idea to dynamically allocate space for strings with kmalloc(). That leaves us with +statically allocated space for strings. This is what is implemented in the String module. Strings use +preallocated per-cpu buffers and are safe to use (unlike C strings). + +@subsection io_sec I/O +Generally things are written to a "print buffer" using the internal +functions _stp_print_xxx(). +\code +_stp_print ("Output is: "); +_stp_printf ("pid is %d ", current->pid); +_stp_printf ("name is %s", current->comm); +\endcode +before the probe returns it must call _stp_print_flush(). This +timestamps the accumulated print buffer and sends it to relayfs. +When relayfs fills an internal buffer, the user-space daemon is notified +data is ready and reads a bug per-cpu chunk, which contains a line like: +\verbatim +[123456.000002] Output is: pid is 1234 name is bash +\endverbatim + +The user-daemon (stpd) saves this data to a file named something like +"stpd_cpu2". When the user hits ^c, a timer expires, or the probe +module notifies stpd (through a netlink command channel) that it wants +to terminate, stpd does "system(rmmod)" then collects the last output +before exiting. +As an option, if we don't need bulk per-cpu data, we can put +\code +#define STP_NETLINK_ONLY +\endcode +at the top of the module and all output will go over a netlink channel. +In the SystemTap language, we will provide some simple functions to control the buffering policy, which +will control the use of netlink and parameters to relayfs and stpd. + +@section status_sec Status +@li Maps are implemented and tested. Histograms are not yet finished. +@li Copy_From_User functions are done. +@li If maps overflow or memory runs out for some reason, globals are set but nothing is done yet. +I expect to implement a function to tell the system to either ignore it or unload the module and quit. +@li Stack functions need much improvement. + +@section probe_sec Example Probes + +Working sample probe code using the runtime is in runtime/probes. + Browse probes. + +@section todo_sec ToDo +\link todo Click Here for Complete List \endlink + +@section links Links +SystemTap Project Page */ diff --git a/runtime/TODO b/runtime/TODO new file mode 100644 index 00000000..41938a9d --- /dev/null +++ b/runtime/TODO @@ -0,0 +1,34 @@ +/** +@file TODO +@brief To-Do List + +***** STPD ***** + +@todo stpd needs an option to disable ANSI colors. + +@todo stpd needs to be able to write netlink REALTIME_DATA to a file. + +@todo stpd/stp/io.c stpd needs better startup/shutdown integration with io.c in runtime. +Shutdown works, but isn't very clean. Currently the stp script loads the module, then +starts stpd. Data is lost until stpd is active. Maybe stpd needs to load the module. +Maybe it needs to signal the module that stpd is ready and the module can proceed to load the probes. + +@todo stpd/stp - What if there are multiple probes running? + +@todo stpd/stp - Need something to post-process relayfs files and integrate into a single file. + +@todo stpd - Implement command that runtime can send to stpd to tell it to fork a specified program and pass +the output from the probe module to it. Create example probe to use it. + +***** relayfs ***** +@todo relayfs/build - figure out how to get rid of the linker warnings when building probes. + +***** runtime ***** +@todo runtime - Clean up #defines. Need to have a clearer way to have the probe writer (translator) +see which defines affect what and all defines should have reasonable defaults. + +@todo runtime - current.c - implement a memory dump function. Does a hex dump into String or print buffer. +@todo runtime - put wrappers around current task struct entries, like pid, ppid, comm, etc. +@todo runtime - Implement stack functions for kprobes (not just jprobes) + +*/ diff --git a/runtime/copy.c b/runtime/copy.c index 6e2313f6..ef5f094d 100644 --- a/runtime/copy.c +++ b/runtime/copy.c @@ -89,6 +89,7 @@ do { \ * * If count is smaller than the length of the string, copies * count bytes and returns count. + * @deprecated I can't think of why you wouldn't use _stp_string_from_user() instead. */ long @@ -99,6 +100,16 @@ _stp_strncpy_from_user(char *dst, const char __user *src, long count) return res; } +/** Copy a String from userspace. + * Copies a string of up to \e count bytes from userspace into a String. + * If access to userspace fails, returns -EFAULT (some data may have been + * copied). + * @param str Destination String. + * @param src Source address, in user space. + * @param count Maximum number of bytes to copy, including the trailing NULL. + * + */ + void _stp_string_from_user (String str, const char __user *src, long count) { long res; @@ -124,7 +135,7 @@ void _stp_string_from_user (String str, const char __user *src, long count) * */ -unsigned long inline +unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count) { return __copy_from_user_inatomic(dst, src, count); diff --git a/runtime/docs/html/MAP-example.html b/runtime/docs/html/MAP-example.html deleted file mode 100644 index 45e6a3c3..00000000 --- a/runtime/docs/html/MAP-example.html +++ /dev/null @@ -1,17 +0,0 @@ - - -SystemTap: SystemTap Runtime Library - - -
Intro | Functions | Defines | Enumerations | Enumeration Values
- - -

MAP

arglist ;

-int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs) { struct map_node_str *ptr;

-_stp_copy_argv_from_user (arglist, argv);

-foreach (arglist, ptr) printk ("%s ", ptr->str); printk ("\n");

-


Generated on Wed Mar 9 03:32:10 2005 for SystemTap by  - -doxygen 1.3.9.1
- - diff --git a/runtime/docs/html/README-source.html b/runtime/docs/html/README-source.html index 1b03993d..1421d7e2 100644 --- a/runtime/docs/html/README-source.html +++ b/runtime/docs/html/README-source.html @@ -4,61 +4,116 @@ -
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages
-

README

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

README

00001 /** @mainpage SystemTap Runtime
+00002 
+00003 @section intro_sec Introduction
+00004 
+00005 This document describes the implementation of the SystemTap Runtime. It is intended for developers
+00006 of the SystemTap Language translator or, possibly TapSet authors. These functions are not directly
+00007 available from the SystemTap Language.
+00008 
+00009 The SystemTap Runtime Library consists of all functions
+00010 and code fragments needed by the compiler/translator to
+00011 include in building a kernel module using kprobes. It
+00012 also include I/O code to transmit its output from the kernel to userspace.
+00013  
+00014 In addition to the library, the runtime includes a SystemTap user-space daemon
+00015 (stpd).  Stpd grabs data sent from the I/O code in the runtime and displays it
+00016 and/or saves it to files. Stpd (or a script invoking it) will handle other issues like
+00017 inserting and removing modules.
+00018 
+00019 Stpd and the I/O code make use of both relayfs and netlink for communication.  For
+00020 kernels without relayfs builtin, it is provided as a standalone module under the runtime directory.
+00021 
+00022 @section design_sec Design
+00023 @subsection impl_sec Implementation
+00024 The library is written in C and is really not a library but a collection of code
+00025 That can be conditionally included in a modules. It may become a library later, but for now
+00026 there are some advantages to being able to change the sizes of static items with simple #defines.
+00027 
+00028 @subsection map_sec Maps (Associative Arrays)
+00029 Maps are implemented as hash lists. It is not expected that users will
+00030 attempt to collect so much data in kernel space that performance problems will require
+00031 more complex solutions such as AVL trees.
+00032 
+00033 Maps are created with _stp_map_new().  Each map can hold only one type of 
+00034 data; int64, string, or statistics.  Each element belonging to a map can have up to 2 keys
+00035 and a value.  Implemented key types are strings and longs.
+00036         
+00037 To simplify the implementation, the functions to set the key and the functions to set the data are separated.
+00038 That means we need only 4 functions to set the key and 3 functions to set the value. 
+00039 
+00040 For example:
+00041 \code
+00042 /* create a map with a max of 100 elements */
+00043 MAP mymap = map_new(100, INT64);
+00044 
+00045 /* mymap[birth year] = 2000 */
+00046 map_key_str (mymap, "birth year");
+00047 map_set_int64 (mymap, 2000);
+00048 \endcode
+00049 
+00050 All elements have a default value of 0 (or NULL).  Elements are only saved to the map when their value is set
+00051 to something nonzero.  This means that querying for the existance of a key is inexpensive because
+00052 no element is created, just a hash table lookup.
+00053 
+00054 @subsection list_sec Lists
+00055 A list is a special map which has internally ascending long integer keys.  Adding a value to
+00056 a list does not require setting a key first. Create a list with _stp_list_new(). Add to it
+00057 with _stp_list_add_str() and _stp_list_add_int64().  Clear it with _stp_list_clear().
+00058 
+00059 @subsection string_sec Strings
+00060 One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack.
+00061 It is also not a good idea to dynamically allocate space for strings with kmalloc().  That leaves us with 
+00062 statically allocated space for strings. This is what is implemented in the String module.  Strings use
+00063 preallocated per-cpu buffers and are safe to use (unlike C strings).
+00064 
+00065 @subsection io_sec I/O
+00066 Generally things are written to a "print buffer" using the internal
+00067 functions _stp_print_xxx().
+00068 \code
+00069 _stp_print ("Output is: ");
+00070 _stp_printf ("pid is %d ", current->pid);
+00071 _stp_printf ("name is %s", current->comm);
+00072 \endcode
+00073 before the probe returns it must call _stp_print_flush().  This
+00074 timestamps the accumulated print buffer and sends it to relayfs.
+00075 When relayfs fills an internal buffer, the user-space daemon is notified
+00076 data is ready and reads a bug per-cpu chunk, which contains a line like:
+00077 \verbatim
+00078 [123456.000002] Output is: pid is 1234 name is bash
+00079 \endverbatim
+00080 
+00081 The user-daemon (stpd) saves this data to a file named something like
+00082 "stpd_cpu2".  When the user hits ^c, a timer expires, or the probe
+00083 module notifies stpd (through a netlink command channel) that it wants
+00084 to terminate, stpd does "system(rmmod)" then collects the last output
+00085 before exiting.
+00086 As an option, if we don't need bulk per-cpu data, we can put
+00087 \code
+00088 #define STP_NETLINK_ONLY
+00089 \endcode
+00090 at the top of the module and all output will go over a netlink channel.
+00091 In the SystemTap language, we will provide some simple functions to control the buffering policy, which
+00092 will control the use of netlink and parameters to relayfs and stpd.
+00093 
+00094 @section status_sec Status
+00095 @li Maps are implemented and tested. Histograms are not yet finished.
+00096 @li Copy_From_User functions are done.
+00097 @li If maps overflow or memory runs out for some reason, globals are set but nothing is done yet.
+00098 I expect to implement a function to tell the system to either ignore it or unload the module and quit.
+00099 @li Stack functions need much improvement.
+00100 
+00101 @section probe_sec Example Probes
+00102 
+00103 Working sample probe code using the runtime is in runtime/probes.
+00104 <a href="dir_000000.html"> Browse probes.</a>
+00105 
+00106 @section todo_sec ToDo 
+00107 \link todo Click Here for Complete List \endlink
+00108 
+00109 @section links Links
+00110 <a href="http://sources.redhat.com/systemtap/">SystemTap Project Page</a>
+00111  */
 
diff --git a/runtime/docs/html/README.html b/runtime/docs/html/README.html deleted file mode 100644 index d4ddc434..00000000 --- a/runtime/docs/html/README.html +++ /dev/null @@ -1,18 +0,0 @@ - - -SystemTap: SystemTap Runtime Library - - - - - -

README File Reference

-

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


Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
- - diff --git a/runtime/docs/html/TODO-source.html b/runtime/docs/html/TODO-source.html new file mode 100644 index 00000000..ff8d219b --- /dev/null +++ b/runtime/docs/html/TODO-source.html @@ -0,0 +1,42 @@ + + +SystemTap: TODO Source File + + + + +

TODO

Go to the documentation of this file.
00001 /**
+00002 @file TODO
+00003 @brief To-Do List
+00004 
+00005 ***** STPD *****
+00006 
+00007 @todo stpd needs an option to disable ANSI colors.
+00008 
+00009 @todo stpd needs to be able to write netlink REALTIME_DATA to a file.
+00010 
+00011 @todo stpd/stp/io.c stpd needs better startup/shutdown integration with io.c in runtime. 
+00012 Shutdown works, but isn't very clean.  Currently the stp script loads the module, then
+00013 starts stpd.  Data is lost until stpd is active. Maybe stpd needs to load the module. 
+00014 Maybe it needs to signal the module that stpd is ready and the module can proceed to load the probes.
+00015 
+00016 @todo stpd/stp - What if there are multiple probes running? 
+00017 
+00018 @todo stpd/stp - Need something to post-process relayfs files and integrate into a single file.
+00019 
+00020 @todo stpd - Implement command that runtime can send to stpd to tell it to fork a specified program and pass
+00021 the output from the probe module to it.  Create example probe to use it.
+00022 
+00023 ***** relayfs *****
+00024 @todo relayfs/build - figure out how to get rid of the linker warnings when building probes. 
+00025 
+00026 ***** runtime *****
+00027 @todo runtime - Clean up #defines. Need to have a clearer way to have the probe writer (translator) 
+00028 see which defines affect what and all defines should have reasonable defaults.
+00029 
+00030 @todo runtime - current.c - implement a memory dump function. Does a hex dump into String or print buffer.
+00031 @todo runtime - put wrappers around current task struct entries, like pid, ppid, comm, etc.
+00032 @todo runtime - Implement stack functions for kprobes (not just jprobes)
+00033 
+00034 */
+
diff --git a/runtime/docs/html/TODO.html b/runtime/docs/html/TODO.html new file mode 100644 index 00000000..e5771873 --- /dev/null +++ b/runtime/docs/html/TODO.html @@ -0,0 +1,42 @@ + + +SystemTap: TODO File Reference + + + + +

TODO File Reference

To-Do List. More... +

+ +

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


Detailed Description

+To-Do List. +

+STPD *****

+

Todo:
stpd needs an option to disable ANSI colors.
+

+

Todo:
stpd needs to be able to write netlink REALTIME_DATA to a file.
+

+

Todo:
stpd/stp/io.c stpd needs better startup/shutdown integration with io.c in runtime. Shutdown works, but isn't very clean. Currently the stp script loads the module, then starts stpd. Data is lost until stpd is active. Maybe stpd needs to load the module. Maybe it needs to signal the module that stpd is ready and the module can proceed to load the probes.
+

+

Todo:
stpd/stp - What if there are multiple probes running?
+

+

Todo:
stpd/stp - Need something to post-process relayfs files and integrate into a single file.
+

+

Todo:
stpd - Implement command that runtime can send to stpd to tell it to fork a specified program and pass the output from the probe module to it. Create example probe to use it.
+relayfs *****

+

Todo:
relayfs/build - figure out how to get rid of the linker warnings when building probes.
+runtime *****

+

Todo:
runtime - Clean up #defines. Need to have a clearer way to have the probe writer (translator) see which defines affect what and all defines should have reasonable defaults.
+

+

Todo:
runtime - current.c - implement a memory dump function. Does a hex dump into String or print buffer.
+

+

Todo:
runtime - put wrappers around current task struct entries, like pid, ppid, comm, etc.
+

+

Todo:
runtime - Implement stack functions for kprobes (not just jprobes)
+ +

+Definition in file TODO. diff --git a/runtime/docs/html/alloc_8c-source.html b/runtime/docs/html/alloc_8c-source.html index 34641788..4e76adbb 100644 --- a/runtime/docs/html/alloc_8c-source.html +++ b/runtime/docs/html/alloc_8c-source.html @@ -4,7 +4,7 @@ -

+

alloc.c

Go to the documentation of this file.
00001 #ifndef _ALLOC_C_
 00002 #define _ALLOC_C_
 00003 
diff --git a/runtime/docs/html/alloc_8c.html b/runtime/docs/html/alloc_8c.html
index 358cb6a8..8e9f7d80 100644
--- a/runtime/docs/html/alloc_8c.html
+++ b/runtime/docs/html/alloc_8c.html
@@ -4,7 +4,7 @@
 
 
 
-
+
 

alloc.c File Reference

Memory functions. More...

diff --git a/runtime/docs/html/alloc_8h-source.html b/runtime/docs/html/alloc_8h-source.html deleted file mode 100644 index 551deccd..00000000 --- a/runtime/docs/html/alloc_8h-source.html +++ /dev/null @@ -1,85 +0,0 @@ - - -SystemTap: alloc.h Source File - - - -

-

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 }
-
diff --git a/runtime/docs/html/alloc_8h.html b/runtime/docs/html/alloc_8h.html deleted file mode 100644 index c8735838..00000000 --- a/runtime/docs/html/alloc_8h.html +++ /dev/null @@ -1,249 +0,0 @@ - - -SystemTap: alloc.h File Reference - - - - -

alloc.h File Reference

Memory allocation functions. More... -

- -

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

Enumerations

enum  errorcode { ERR_NONE = 0, -ERR_NO_MEM - }

Functions

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

Variables

-enum errorcode _stp_error = ERR_NONE
-


Detailed Description

-Memory allocation functions. -

-

Todo:
Should really be alloc.c for consistency.
- -

-Definition in file alloc.h.


Function Documentation

-

- - - - -
- - - - - - - - - -
void* _stp_alloc size_t  len  ) 
-
- - - - - -
-   - - -

-Allocates memory within a probe. -

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

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

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

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

-

- - - - -
- - - - - - - - - -
void* _stp_calloc size_t  len  ) 
-
- - - - - -
-   - - -

-Allocates and clears memory within a probe. -

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

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

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

-References _stp_alloc(). -

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

-

- - - - -
- - - - - - - - - -
void _stp_free void *  ptr  ) 
-
- - - - - -
-   - - -

-Frees memory allocated by _stp_alloc or _stp_calloc. -

-

Parameters:
- - -
ptr pointer to memory to free
-
- -

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

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

-

- - - - -
- - - - - - - - - -
void* _stp_valloc size_t  len  ) 
-
- - - - - -
-   - - -

-Allocates and clears memory outside a probe. -

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

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

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

-Referenced by _stp_map_new().

-

- - - - -
- - - - - - - - - -
void _stp_vfree void *  ptr  ) 
-
- - - - - -
-   - - -

-Frees memory allocated by _stp_valloc. -

-

Parameters:
- - -
ptr pointer to memory to free
-
- -

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

-Referenced by _stp_map_del().

- diff --git a/runtime/docs/html/annotated.html b/runtime/docs/html/annotated.html deleted file mode 100644 index 4359c217..00000000 --- a/runtime/docs/html/annotated.html +++ /dev/null @@ -1,17 +0,0 @@ - - -SystemTap: Data Structures - - - -

-

SystemTap Data Structures

Here are the data structures with brief descriptions: - - - - - - - -
key_dataKeys are either longs or char *
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
- diff --git a/runtime/docs/html/argv__example_8c-example.html b/runtime/docs/html/argv__example_8c-example.html deleted file mode 100644 index 1369c4c2..00000000 --- a/runtime/docs/html/argv__example_8c-example.html +++ /dev/null @@ -1,32 +0,0 @@ - - -SystemTap: SystemTap Runtime Library - - - - - -

argv_example.c

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

Generated on Wed Mar 9 03:40:33 2005 for SystemTap by  - -doxygen 1.3.9.1
- - diff --git a/runtime/docs/html/bug.html b/runtime/docs/html/bug.html index 4ed1d36b..e19f1b2e 100644 --- a/runtime/docs/html/bug.html +++ b/runtime/docs/html/bug.html @@ -4,7 +4,7 @@ - +

Bug List

Global _stp_alloc (size_t len)
Currently uses kmalloc (GFP_ATOMIC).
@@ -16,7 +16,12 @@

-
Global dlog (const char *fmt,...)
-
Lines are limited in length by printk buffer. If there is no newline in the format string, then other syslog output could get appended to the SystemTap line.
+
Global _stp_stack_print (int verbose, int levels)
+
levels parameter is not functional
+
+

+

+
Global _stp_stack_sprint (String str, int verbose, int levels)
+
levels parameter is not functional
diff --git a/runtime/docs/html/copy_8c-source.html b/runtime/docs/html/copy_8c-source.html index 1d4f8652..273aa45c 100644 --- a/runtime/docs/html/copy_8c-source.html +++ b/runtime/docs/html/copy_8c-source.html @@ -4,159 +4,183 @@ - -

copy.c

Go to the documentation of this file.
00001 #ifndef _COPY_C_
-00002 #define _COPY_C_
+
+

copy.c

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

copy.c File Reference

Functions to copy from user space. More...

+#include "string.c"

Go to the source code of this file. @@ -15,12 +16,15 @@ - + - - + + - + + + +
long _stp_strncpy_from_user (char *dst, const char __user *src, long count)
 Copy a NULL-terminated string from userspace.
unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
void _stp_string_from_user (String str, const char __user *src, long count)
 Copy a block of data from user space.
int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
 Copy a String from userspace.
unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
 Copy an argv from user space to a List.
 Copy a block of data from user space.
int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
 Copy an argv from user space to a List.


Detailed Description

Functions to copy from user space. diff --git a/runtime/docs/html/current_8c-source.html b/runtime/docs/html/current_8c-source.html index 88ad571a..cbe1bca7 100644 --- a/runtime/docs/html/current_8c-source.html +++ b/runtime/docs/html/current_8c-source.html @@ -4,7 +4,7 @@ - +

current.c

Go to the documentation of this file.
00001 #ifndef _CURRENT_C_
 00002 #define _CURRENT_C_
 00003 
diff --git a/runtime/docs/html/current_8c.html b/runtime/docs/html/current_8c.html
index bfb2b727..698a4467 100644
--- a/runtime/docs/html/current_8c.html
+++ b/runtime/docs/html/current_8c.html
@@ -4,7 +4,7 @@
 
 
 
-
+
 

current.c File Reference

Functions to get the current state. More...

diff --git a/runtime/docs/html/deprecated.html b/runtime/docs/html/deprecated.html new file mode 100644 index 00000000..fbfbb5d0 --- /dev/null +++ b/runtime/docs/html/deprecated.html @@ -0,0 +1,12 @@ + + +SystemTap: Deprecated List + + + +

+

Deprecated List

+
Global _stp_strncpy_from_user (char *dst, const char __user *src, long count)
+
I can't think of why you wouldn't use _stp_string_from_user() instead.
+
+ diff --git a/runtime/docs/html/dir_000000.html b/runtime/docs/html/dir_000000.html index acfc2d57..9ee08412 100644 --- a/runtime/docs/html/dir_000000.html +++ b/runtime/docs/html/dir_000000.html @@ -4,7 +4,7 @@ - +

probes Directory Reference

This directory contains working example probes that demonstrate and test the runtime library. diff --git a/runtime/docs/html/dir_000001.html b/runtime/docs/html/dir_000001.html index e9fac182..3e97a453 100644 --- a/runtime/docs/html/dir_000001.html +++ b/runtime/docs/html/dir_000001.html @@ -4,7 +4,7 @@ - +

shellsnoop Directory Reference

Snoops on what commands are being run by shells. @@ -13,13 +13,15 @@

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.
diff --git a/runtime/docs/html/dir_000002.html b/runtime/docs/html/dir_000002.html
index 0a007775..0fe099ec 100644
--- a/runtime/docs/html/dir_000002.html
+++ b/runtime/docs/html/dir_000002.html
@@ -4,7 +4,7 @@
 
 
 
-
+
 
 

tasklet Directory Reference

Sample probe in a tasklet. diff --git a/runtime/docs/html/dir_000003.html b/runtime/docs/html/dir_000003.html index b9e20e19..497baf4d 100644 --- a/runtime/docs/html/dir_000003.html +++ b/runtime/docs/html/dir_000003.html @@ -4,7 +4,7 @@ - +

test4 Directory Reference

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

Files

file  dtr.c [code] -file  dtr.mod.c [code] - -file  nrec.c [code] - file  README [code] diff --git a/runtime/docs/html/dir_000004.html b/runtime/docs/html/dir_000004.html index d3e72861..4eeb55a8 100644 --- a/runtime/docs/html/dir_000004.html +++ b/runtime/docs/html/dir_000004.html @@ -4,7 +4,7 @@ - +

where_func Directory Reference

This is a silly little instrumentation routine to instrument functions entry by name. @@ -13,8 +13,6 @@

Files

file  kprobe_where_funct.c [code] -file  kprobe_where_funct.mod.c [code] - file  README [code] diff --git a/runtime/docs/html/dirs.html b/runtime/docs/html/dirs.html index 36214b8b..9cc73aaf 100644 --- a/runtime/docs/html/dirs.html +++ b/runtime/docs/html/dirs.html @@ -4,7 +4,7 @@ - +

SystemTap Directories

This directory hierarchy is sorted roughly, but not completely, alphabetically:

dtr.mod.c

00001 #include <linux/module.h>
 00002 #include <linux/vermagic.h>
 00003 #include <linux/compiler.h>
@@ -27,32 +27,32 @@
 00018 __attribute_used__
 00019 __attribute__((section("__versions"))) = {
 00020         { 0x506abef7, "struct_module" },
-00021         { 0xfcdec747, "sock_release" },
-00022         { 0x8968634b, "netlink_kernel_create" },
-00023         { 0xb240ca65, "schedule_work" },
-00024         { 0x1b9aca3f, "jprobe_return" },
-00025         { 0x757b6858, "skb_dequeue" },
-00026         { 0xd4aed67a, "netlink_ack" },
-00027         { 0x5fc0695e, "__kfree_skb" },
-00028         { 0xaa1449d7, "netlink_unicast" },
-00029         { 0x3958414f, "skb_over_panic" },
-00030         { 0x559dbbb8, "alloc_skb" },
-00031         { 0x7ec9bfbc, "strncpy" },
-00032         { 0xe3b0192b, "vscnprintf" },
-00033         { 0x45e5f47f, "register_kprobe" },
-00034         { 0x1e736243, "unregister_kprobe" },
-00035         { 0xdd03a51e, "register_jprobe" },
-00036         { 0x49a83d3a, "unregister_jprobe" },
-00037         { 0x3fa03a97, "memset" },
-00038         { 0xc16fe12d, "__memcpy" },
-00039         { 0xe914e41e, "strcpy" },
-00040         { 0xe2d5255a, "strcmp" },
-00041         { 0x2fd1d81c, "vfree" },
-00042         { 0x37a0cba, "kfree" },
-00043         { 0xd6ee688f, "vmalloc" },
-00044         { 0x8ce16b3f, "__kmalloc" },
-00045         { 0x8e3c9cc3, "vprintk" },
-00046         { 0xdd132261, "printk" },
+00021         { 0x1b9aca3f, "jprobe_return" },
+00022         { 0x45e5f47f, "register_kprobe" },
+00023         { 0x1e736243, "unregister_kprobe" },
+00024         { 0xdd03a51e, "register_jprobe" },
+00025         { 0x49a83d3a, "unregister_jprobe" },
+00026         { 0xaa27f890, "__get_user_8" },
+00027         { 0x21e5679c, "copy_user_generic" },
+00028         { 0x3fa03a97, "memset" },
+00029         { 0xc16fe12d, "__memcpy" },
+00030         { 0xe914e41e, "strcpy" },
+00031         { 0xe2d5255a, "strcmp" },
+00032         { 0x2fd1d81c, "vfree" },
+00033         { 0x37a0cba, "kfree" },
+00034         { 0xd6ee688f, "vmalloc" },
+00035         { 0x8ce16b3f, "__kmalloc" },
+00036         { 0xfcdec747, "sock_release" },
+00037         { 0x8968634b, "netlink_kernel_create" },
+00038         { 0x7ec9bfbc, "strncpy" },
+00039         { 0xe3b0192b, "vscnprintf" },
+00040         { 0x757b6858, "skb_dequeue" },
+00041         { 0xd4aed67a, "netlink_ack" },
+00042         { 0xdd132261, "printk" },
+00043         { 0x5fc0695e, "__kfree_skb" },
+00044         { 0xaa1449d7, "netlink_unicast" },
+00045         { 0x3958414f, "skb_over_panic" },
+00046         { 0x559dbbb8, "alloc_skb" },
 00047 };
 00048 
 00049 static const char __module_depends[]
@@ -61,5 +61,5 @@
 00052 "depends=";
 00053 
 00054 
-00055 MODULE_INFO(srcversion, "01D3B50188E5E952DA9FD12");
+00055 MODULE_INFO(srcversion, "F330A962246F179FE15E94B");
 
diff --git a/runtime/docs/html/examples.html b/runtime/docs/html/examples.html deleted file mode 100644 index cd53f417..00000000 --- a/runtime/docs/html/examples.html +++ /dev/null @@ -1,16 +0,0 @@ - - -SystemTap: SystemTap Runtime Library - - - - - -

SystemTap Examples

Here is a list of all examples: -
Generated on Wed Mar 9 12:24:52 2005 for SystemTap by  - -doxygen 1.3.9.1
- - diff --git a/runtime/docs/html/files.html b/runtime/docs/html/files.html index f61591f6..0099797e 100644 --- a/runtime/docs/html/files.html +++ b/runtime/docs/html/files.html @@ -4,7 +4,7 @@ - +

SystemTap File List

Here is a list of all documented files with brief descriptions: @@ -12,23 +12,24 @@ + + - + + + - - -
alloc.c [code]Memory 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
print.c [code]
probes.c [code]Functions to assist loading and unloading groups of probes
README [code]
relay-app.h [code]
runtime.h [code]Main include file for runtime functions
scbuf.c [code]
stack.c [code]Stack Tracing Functions
string.c [code]Implements String type
sym.c [code]
TODO [code]To-Do List
probes/README [code]
probes/shellsnoop/dtr.c [code]
probes/shellsnoop/dtr.mod.c [code]
probes/shellsnoop/README [code]
probes/tasklet/README [code]
probes/tasklet/stp_tasklet.c [code]
probes/test4/dtr.c [code]
probes/test4/dtr.mod.c [code]
probes/test4/nrec.c [code]
probes/test4/README [code]
probes/where_func/kprobe_where_funct.c [code]
probes/where_func/kprobe_where_funct.mod.c [code]
probes/where_func/README [code]
diff --git a/runtime/docs/html/foreach_8c-example.html b/runtime/docs/html/foreach_8c-example.html deleted file mode 100644 index ccafaeeb..00000000 --- a/runtime/docs/html/foreach_8c-example.html +++ /dev/null @@ -1,28 +0,0 @@ - - -SystemTap: SystemTap Runtime Library - - - - - -

foreach.c

Parameters:
- - - -
map 
ptr pointer to a map_node_stat, map_node_int64 or map_node_str
-
-
/* example showing how to print all the stats in a map using foreach() */
-
-struct map_node_stat *ptr;
-
-foreach (map, ptr)
-     printf ("map[%s,%ld] = [c=%lld s=%lld min=%lld max=%lld]\n", key1str(ptr), 
-             key2int(ptr), ptr->stats.count, ptr->stats.sum, ptr->stats.min, 
-             ptr->stats.max);
-
-

Generated on Wed Mar 9 12:24:52 2005 for SystemTap by  - -doxygen 1.3.9.1
- - diff --git a/runtime/docs/html/ftv2blank.png b/runtime/docs/html/ftv2blank.png deleted file mode 100644 index 493c3c0b..00000000 Binary files a/runtime/docs/html/ftv2blank.png and /dev/null differ diff --git a/runtime/docs/html/ftv2doc.png b/runtime/docs/html/ftv2doc.png deleted file mode 100644 index f72999f9..00000000 Binary files a/runtime/docs/html/ftv2doc.png and /dev/null differ diff --git a/runtime/docs/html/ftv2folderclosed.png b/runtime/docs/html/ftv2folderclosed.png deleted file mode 100644 index d6d06344..00000000 Binary files a/runtime/docs/html/ftv2folderclosed.png and /dev/null differ diff --git a/runtime/docs/html/ftv2folderopen.png b/runtime/docs/html/ftv2folderopen.png deleted file mode 100644 index bbe2c913..00000000 Binary files a/runtime/docs/html/ftv2folderopen.png and /dev/null differ diff --git a/runtime/docs/html/ftv2lastnode.png b/runtime/docs/html/ftv2lastnode.png deleted file mode 100644 index e7b9ba90..00000000 Binary files a/runtime/docs/html/ftv2lastnode.png and /dev/null differ diff --git a/runtime/docs/html/ftv2link.png b/runtime/docs/html/ftv2link.png deleted file mode 100644 index 14f3fed0..00000000 Binary files a/runtime/docs/html/ftv2link.png and /dev/null differ diff --git a/runtime/docs/html/ftv2mlastnode.png b/runtime/docs/html/ftv2mlastnode.png deleted file mode 100644 index 09ceb6ad..00000000 Binary files a/runtime/docs/html/ftv2mlastnode.png and /dev/null differ diff --git a/runtime/docs/html/ftv2mnode.png b/runtime/docs/html/ftv2mnode.png deleted file mode 100644 index 3254c051..00000000 Binary files a/runtime/docs/html/ftv2mnode.png and /dev/null differ diff --git a/runtime/docs/html/ftv2node.png b/runtime/docs/html/ftv2node.png deleted file mode 100644 index c9f06a57..00000000 Binary files a/runtime/docs/html/ftv2node.png and /dev/null differ diff --git a/runtime/docs/html/ftv2plastnode.png b/runtime/docs/html/ftv2plastnode.png deleted file mode 100644 index 0b07e009..00000000 Binary files a/runtime/docs/html/ftv2plastnode.png and /dev/null differ diff --git a/runtime/docs/html/ftv2pnode.png b/runtime/docs/html/ftv2pnode.png deleted file mode 100644 index 2001b797..00000000 Binary files a/runtime/docs/html/ftv2pnode.png and /dev/null differ diff --git a/runtime/docs/html/ftv2vertline.png b/runtime/docs/html/ftv2vertline.png deleted file mode 100644 index b330f3a3..00000000 Binary files a/runtime/docs/html/ftv2vertline.png and /dev/null differ diff --git a/runtime/docs/html/functions.html b/runtime/docs/html/functions.html deleted file mode 100644 index e48ba9fa..00000000 --- a/runtime/docs/html/functions.html +++ /dev/null @@ -1,25 +0,0 @@ - - -SystemTap: Data Fields - - - - - - -

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

- diff --git a/runtime/docs/html/functions_vars.html b/runtime/docs/html/functions_vars.html deleted file mode 100644 index ed63f0fd..00000000 --- a/runtime/docs/html/functions_vars.html +++ /dev/null @@ -1,25 +0,0 @@ - - -SystemTap: Data Fields - Variables - - - - - - -

-

- diff --git a/runtime/docs/html/globals.html b/runtime/docs/html/globals.html index 7ac847b4..bc04b2aa 100644 --- a/runtime/docs/html/globals.html +++ b/runtime/docs/html/globals.html @@ -4,9 +4,9 @@ - + -
_ | d | f | k | m | p | v
+
_ | f | k | m | p | s | v

@@ -15,23 +15,25 @@ Here is a list of all documented functions, variables, defines, enums, and typed

  • _stp_alloc() : alloc.c
  • _stp_calloc() : alloc.c
  • _stp_copy_argv_from_user() -: copy.c
  • _stp_copy_from_user() -: copy.c
  • _stp_free() +: copy.c
  • _stp_copy_from_user() +: copy.c
  • _stp_free() : alloc.c
  • _stp_list_add -: map.h
  • _stp_list_add_int64() -: map.c
  • _stp_list_add_str() -: map.c
  • _stp_list_clear() +: map.h
  • _stp_list_add_int64() +: map.c
  • _stp_list_add_str() +: map.c
  • _stp_list_add_string() +: map.c
  • _stp_list_clear() : map.c
  • _stp_list_new() : map.c
  • _stp_list_size() -: map.c
  • _stp_map_add_int64() +: map.c
  • _stp_log() +: io.c
  • _stp_map_add_int64() : map.c
  • _stp_map_del() : map.c
  • _stp_map_get_int64() : map.c
  • _stp_map_get_stat() -: map.c
  • _stp_map_get_str() -: map.c
  • _stp_map_iter() +: map.c
  • _stp_map_get_str() +: map.c
  • _stp_map_iter() : map.c
  • _stp_map_key -: map.h
  • _stp_map_key2 -: map.h
  • _stp_map_key_del() +: map.h
  • _stp_map_key2 +: map.h
  • _stp_map_key_del() : map.c
  • _stp_map_key_long() : map.c
  • _stp_map_key_long_long() : map.c
  • _stp_map_key_long_str() @@ -40,43 +42,54 @@ Here is a list of all documented functions, variables, defines, enums, and typed : map.c
  • _stp_map_key_str_str() : map.c
  • _stp_map_new() : map.c
  • _stp_map_set -: map.h
  • _stp_map_set_int64() +: map.h
  • _stp_map_set_int64() : map.c
  • _stp_map_set_stat() -: map.c
  • _stp_map_set_str() -: map.c
  • _stp_map_start() +: map.c
  • _stp_map_set_str() +: map.c
  • _stp_map_set_string() +: map.c
  • _stp_map_start() : map.c
  • _stp_map_stat_add() -: map.c
  • _stp_print() -: io.c
  • _stp_print_str() -: io.c
  • _stp_register_jprobes() -: probes.c
  • _stp_register_kprobes() -: probes.c
  • _stp_ret_addr() -: current.c
  • _stp_stack_print() -: stack.c
  • _stp_strncpy_from_user() +: map.c
  • _stp_netlink_close() +: io.c
  • _stp_netlink_open() +: io.c
  • _stp_register_jprobes() +: probes.c
  • _stp_register_kprobes() +: probes.c
  • _stp_ret_addr() +: current.c
  • _stp_sprintf() +: string.c
  • _stp_stack_print() +: stack.c
  • _stp_stack_sprint() +: stack.c
  • _stp_string_cat +: string.c
  • _stp_string_cat_cstr() +: string.c
  • _stp_string_cat_string() +: string.c
  • _stp_string_from_user() +: copy.c
  • _stp_string_init() +: string.c
  • _stp_string_ptr() +: string.c
  • _stp_strncpy_from_user() : copy.c
  • _stp_unregister_jprobes() -: probes.c
  • _stp_unregister_kprobes() -: probes.c
  • _stp_valloc() +: probes.c
  • _stp_unregister_kprobes() +: probes.c
  • _stp_valloc() : alloc.c
  • _stp_vfree() -: alloc.c -

    - d -

    +: alloc.c
  • _stp_vsprintf() +: string.c

    - f -

    +: map.h

    - k -

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

    - m -

    - p -

    +

    - s -

    - v -

    +: map.h diff --git a/runtime/docs/html/globals_defs.html b/runtime/docs/html/globals_defs.html index fd07c918..93e7a777 100644 --- a/runtime/docs/html/globals_defs.html +++ b/runtime/docs/html/globals_defs.html @@ -4,19 +4,22 @@ - +

    +: map.h
  • _stp_map_key +: map.h
  • _stp_map_key2 +: map.h
  • _stp_map_set +: map.h
  • _stp_string_cat +: string.c
  • foreach +: map.h
  • key1int +: map.h
  • key1str +: map.h
  • key2int +: map.h
  • key2str +: map.h
  • STP_LOG_BUF_LEN +: io.c
  • STP_STRING_SIZE +: string.c diff --git a/runtime/docs/html/globals_enum.html b/runtime/docs/html/globals_enum.html index da3f3ac0..f283f502 100644 --- a/runtime/docs/html/globals_enum.html +++ b/runtime/docs/html/globals_enum.html @@ -4,12 +4,12 @@ - +

    +: map.h
  • valtype +: map.h diff --git a/runtime/docs/html/globals_eval.html b/runtime/docs/html/globals_eval.html deleted file mode 100644 index 4771c4a5..00000000 --- a/runtime/docs/html/globals_eval.html +++ /dev/null @@ -1,27 +0,0 @@ - - -SystemTap: SystemTap Runtime Library - - - - - - - -

    -

    -
    Generated on Mon Mar 21 13:29:45 2005 for SystemTap by  - -doxygen 1.4.1
    - - diff --git a/runtime/docs/html/globals_func.html b/runtime/docs/html/globals_func.html index 1562f9d2..a74e4ad0 100644 --- a/runtime/docs/html/globals_func.html +++ b/runtime/docs/html/globals_func.html @@ -4,9 +4,9 @@ - + -
    _ | d
    +

    @@ -15,19 +15,21 @@

  • _stp_alloc() : alloc.c
  • _stp_calloc() : alloc.c
  • _stp_copy_argv_from_user() -: copy.c
  • _stp_copy_from_user() -: copy.c
  • _stp_free() +: copy.c
  • _stp_copy_from_user() +: copy.c
  • _stp_free() : alloc.c
  • _stp_list_add_int64() -: map.c
  • _stp_list_add_str() -: map.c
  • _stp_list_clear() +: map.c
  • _stp_list_add_str() +: map.c
  • _stp_list_add_string() +: map.c
  • _stp_list_clear() : map.c
  • _stp_list_new() : map.c
  • _stp_list_size() -: map.c
  • _stp_map_add_int64() +: map.c
  • _stp_log() +: io.c
  • _stp_map_add_int64() : map.c
  • _stp_map_del() : map.c
  • _stp_map_get_int64() : map.c
  • _stp_map_get_stat() -: map.c
  • _stp_map_get_str() -: map.c
  • _stp_map_iter() +: map.c
  • _stp_map_get_str() +: map.c
  • _stp_map_iter() : map.c
  • _stp_map_key_del() : map.c
  • _stp_map_key_long() : map.c
  • _stp_map_key_long_long() @@ -38,22 +40,28 @@ : map.c
  • _stp_map_new() : map.c
  • _stp_map_set_int64() : map.c
  • _stp_map_set_stat() -: map.c
  • _stp_map_set_str() -: map.c
  • _stp_map_start() +: map.c
  • _stp_map_set_str() +: map.c
  • _stp_map_set_string() +: map.c
  • _stp_map_start() : map.c
  • _stp_map_stat_add() -: map.c
  • _stp_print() -: io.c
  • _stp_print_str() -: io.c
  • _stp_register_jprobes() -: probes.c
  • _stp_register_kprobes() -: probes.c
  • _stp_ret_addr() -: current.c
  • _stp_stack_print() -: stack.c
  • _stp_strncpy_from_user() +: map.c
  • _stp_netlink_close() +: io.c
  • _stp_netlink_open() +: io.c
  • _stp_register_jprobes() +: probes.c
  • _stp_register_kprobes() +: probes.c
  • _stp_ret_addr() +: current.c
  • _stp_sprintf() +: string.c
  • _stp_stack_print() +: stack.c
  • _stp_stack_sprint() +: stack.c
  • _stp_string_cat_cstr() +: string.c
  • _stp_string_cat_string() +: string.c
  • _stp_string_from_user() +: copy.c
  • _stp_string_init() +: string.c
  • _stp_string_ptr() +: string.c
  • _stp_strncpy_from_user() : copy.c
  • _stp_unregister_jprobes() -: probes.c
  • _stp_unregister_kprobes() -: probes.c
  • _stp_valloc() +: probes.c
  • _stp_unregister_kprobes() +: probes.c
  • _stp_valloc() : alloc.c
  • _stp_vfree() -: alloc.c -

    - d -

    +: alloc.c
  • _stp_vsprintf() +: string.c diff --git a/runtime/docs/html/globals_type.html b/runtime/docs/html/globals_type.html index ab8a7382..87f1e8a8 100644 --- a/runtime/docs/html/globals_type.html +++ b/runtime/docs/html/globals_type.html @@ -4,7 +4,7 @@ - +

    diff --git a/runtime/docs/html/globals_vars.html b/runtime/docs/html/globals_vars.html index a4674892..8c4140c4 100644 --- a/runtime/docs/html/globals_vars.html +++ b/runtime/docs/html/globals_vars.html @@ -4,7 +4,7 @@ -

    +

    diff --git a/runtime/docs/html/group__alloc.html b/runtime/docs/html/group__alloc.html index 1a3e32b2..b1151b86 100644 --- a/runtime/docs/html/group__alloc.html +++ b/runtime/docs/html/group__alloc.html @@ -4,7 +4,7 @@ -

    +

    Memory Functions

    Basic malloc/calloc/free functions. More... @@ -80,7 +80,7 @@ This is used for small allocations from within a running probe where the process

    Definition at line 31 of file alloc.c.

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

    @@ -123,7 +123,7 @@ Definition at line 47 of fi

    References _stp_alloc().

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

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

    Definition at line 76 of file alloc.c.

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

    diff --git a/runtime/docs/html/group__copy.html b/runtime/docs/html/group__copy.html index 83928d95..72321187 100644 --- a/runtime/docs/html/group__copy.html +++ b/runtime/docs/html/group__copy.html @@ -4,7 +4,7 @@ -

    +

    Functions to copy from user space.

    Functions to copy from user space. More... @@ -12,18 +12,21 @@ - + - - + + - + + + +
    long _stp_strncpy_from_user (char *dst, const char __user *src, long count)
     Copy a NULL-terminated string from userspace.
    unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
    void _stp_string_from_user (String str, const char __user *src, long count)
     Copy a block of data from user space.
    int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
     Copy a String from userspace.
    unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
     Copy an argv from user space to a List.
     Copy a block of data from user space.
    int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
     Copy an argv from user space to a List.

    Detailed Description

    Functions to copy from user space.

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


    Function Documentation

    -

    +

    - + @@ -66,27 +69,27 @@ Copy an argv from user space to a List.
    @@ -31,7 +34,7 @@ None of these functions will sleep (for example to allow pages to be swapped in)
    int _stp_copy_argv_from_user MAP MAP  list,

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

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

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

    +

    - +
    @@ -112,7 +115,7 @@ References _stp_list_add_str() [inline]
    @@ -139,7 +142,63 @@ 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 115 of file copy.c. +Definition at line 139 of file copy.c. + + +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    void _stp_string_from_user String  str,
    const char __user *  src,
    long  count
    +
    + + + +
    +   + + +

    +Copy a String from userspace. +

    +Copies a string of up to count bytes from userspace into a String. If access to userspace fails, returns -EFAULT (some data may have been copied).

    Parameters:
    + + + + +
    str Destination String.
    src Source address, in user space.
    count Maximum number of bytes to copy, including the trailing NULL.
    +
    + +

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

    +References STP_STRING_SIZE.

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

    +

    Deprecated:
    I can't think of why you wouldn't use _stp_string_from_user() instead.
    +

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

    -Referenced by _stp_copy_argv_from_user(). +Referenced by _stp_copy_argv_from_user(). diff --git a/runtime/docs/html/group__current.html b/runtime/docs/html/group__current.html index 91973e06..03008852 100644 --- a/runtime/docs/html/group__current.html +++ b/runtime/docs/html/group__current.html @@ -4,7 +4,7 @@ -

    +

    Current State

    Functions to get the current state. More... diff --git a/runtime/docs/html/group__io.html b/runtime/docs/html/group__io.html index 357e250b..76051d30 100644 --- a/runtime/docs/html/group__io.html +++ b/runtime/docs/html/group__io.html @@ -4,32 +4,37 @@ - +

    I/O

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

    Defines

    +#define STP_LOG_BUF_LEN   2047
     private buffer for _stp_log()

    Functions

    void dlog (const char *fmt,...)
    void _stp_log (const char *fmt,...)
     Logs Data.
    void _stp_print (const char *fmt,...)
     Logs Data.
    int _stp_netlink_open (void)
     Prints to the trace buffer.
    void _stp_print_str (char *str)
     Opens netlink and relayfs connections to stpd.
    void _stp_netlink_close (void)
     Prints to the trace buffer.
     Closes netlink and relayfs connections to stpd.

    Detailed Description

    I/O functions.


    Function Documentation

    -

    +

    - + @@ -173,7 +179,7 @@ References _stp_map_key_long()

    -Adds a string to a list. +Adds a C string to a list.

    Parameters:
    - + @@ -57,33 +62,34 @@ I/O functions. +Referenced by _stp_list_clear(), _stp_register_jprobes(), _stp_register_kprobes(), _stp_stack_sprint(), _stp_string_init(), _stp_unregister_jprobes(), and _stp_unregister_kprobes().
    void _stp_print void _stp_log const char *  fmt,

    -Prints to the trace buffer. +Logs Data.

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

    -

    Parameters:
    +This function prints to the system log if stpd has not connected yet. Otherwise it sends the message immediately to stpd.
    Parameters:
    fmt A variable number of args.
    -

    -

    Todo:
    Needs replaced with something much faster that does not use the system log.
    +
    Note:
    Lines are limited in length by printk buffer. If there is no newline in the format string, then other syslog output could get appended to the SystemTap line.
    +
    Todo:
    Evaluate if this function is necessary.

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

    +References STP_LOG_BUF_LEN.

    -Referenced by _stp_symbol_print().

    -

    +

    +References _stp_map_key_long(), and _stp_map_set_int64().
    - + - - + + @@ -99,42 +105,26 @@ Referenced by _stp_symbol_print() +Definition at line 103 of file io.c.
    void _stp_print_str void _stp_netlink_close char *  str void   ) 

    -Prints to the trace buffer. -

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

    -

    Parameters:
    - - -
    str String.
    -
    +Closes netlink and relayfs connections to stpd.

    -

    Todo:
    Needs replaced with something much faster that does not use the system log.
    +This must be called after all I/O is done, probably at the end of module cleanup.
    Returns:
    0 on success. -1 if there is a problem establishing a connection.

    -Definition at line 60 of file io.c.

    -

    +

    @@ -148,23 +138,11 @@ Definition at line 60 of file +Definition at line 87 of file io.c.
    - + - - - - - - - - - - - - - + + + +
    void dlog int _stp_netlink_open const char *  fmt,
      ...
    void   ) 

    -Logs Data. -

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

    -

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

    -

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

    -

    Todo:
    Either deprecate or redefine this as a way to log debug or status messages, separate from the normal program output.
    - +Opens netlink and relayfs connections to stpd.

    -Definition at line 25 of file io.c. +This must be called before any I/O is done, probably at the start of module initialization.

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

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

    -

    List

    - - - - - -

    Defines

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

    Define Documentation

    -

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

    -Value:

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

    -

    Note:
    May cause compiler warning on some GCCs
    - -

    -Definition at line 164 of file map.h.

    - diff --git a/runtime/docs/html/group__lists.html b/runtime/docs/html/group__lists.html index 49550e5c..30b83a00 100644 --- a/runtime/docs/html/group__lists.html +++ b/runtime/docs/html/group__lists.html @@ -4,50 +4,53 @@ -

    +

    Lists

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

    Defines

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

    Functions

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

    Detailed Description

    Lists are special cases of maps.

    Example:

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

    Define Documentation

    -

    +

    +Definition at line 183 of file map.h.
    @@ -75,22 +78,24 @@ Lists are special cases of maps.

    -Value:

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

    Note:
    May cause compiler warning on some GCCs

    -Definition at line 181 of file map.h.


    Function Documentation

    -

    +

    - + @@ -132,11 +137,12 @@ Adds an int64 to a list.
    @@ -98,7 +103,7 @@ Definition at line 181 of fil
    void _stp_list_add_int64 MAP MAP  map,
    val 
    +

    See also:
    _stp_list_add()

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

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

    @@ -147,7 +153,7 @@ References _stp_map_key_long()

    void _stp_list_add_str MAP MAP  map,
    @@ -181,13 +187,64 @@ Adds a string to a list.
    str 
    +

    See also:
    _stp_list_add()

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

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

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

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_list_add_string MAP  map,
    String  str
    [inline]
    +
    + + + +
    +   + + +

    +Adds a String to a list. +

    +

    Parameters:
    + + + +
    map 
    str String to add.
    +
    +
    See also:
    _stp_list_add()
    + +

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

    +References _stp_map_key_long(), and _stp_map_set_str().

    @@ -198,7 +255,7 @@ Referenced by _stp_copy_argv_fro void _stp_list_clear (  - MAP  + MAP  map  )  @@ -224,9 +281,9 @@ All elements in the list are deleted.

    Parameters:

    -Definition at line 813 of file map.c. +Definition at line 831 of file map.c.

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

    @@ -235,7 +292,7 @@ References _stp_free(), - + @@ -243,7 +300,7 @@ References _stp_free(), - + @@ -272,15 +329,15 @@ A list is a map that internally has an incrementing long key for each member. Li
    MAP _stp_list_new MAP _stp_list_new unsigned  max_entries, enum valtype enum valtype  type

    Returns:
    A MAP on success or NULL on failure.
    -
    See also:
    foreach
    +
    See also:
    foreach

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

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

    +

    - + @@ -315,9 +372,7 @@ Get the number of elements in a list.
    Returns:
    The number of elements in a list.

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

    -References map_root::num. +Definition at line 907 of file map.c.

    @@ -288,7 +345,7 @@ References _stp_map_new(), an
    int _stp_list_size MAP MAP  map  )  [inline]
    diff --git a/runtime/docs/html/group__maps.html b/runtime/docs/html/group__maps.html index 1da96a51..1b6e170e 100644 --- a/runtime/docs/html/group__maps.html +++ b/runtime/docs/html/group__maps.html @@ -4,74 +4,67 @@ -

    +

    Maps

    Implements maps (associative arrays) and lists. More... - + - - + - - + - - + - - + - - + - - + - - + - + - + - + - + - - + + - - + + - - + + - + +typedef map_root *  - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - + + + + +enum keytype 

    Data Structures

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

    Defines

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

    Typedefs

    -typedef map_rootMAP
    MAP
     All maps are of this type.

    Enumerations

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

    Functions

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

    Variables

    -enum keytype packed
    packed
     keys can be longs or strings

    Detailed Description

    Implements maps (associative arrays) and lists.

    +

    Todo:
    Needs to be made SMP-safe for when the big lock is removed from kprobes.

    Define Documentation

    -

    +

    @@ -188,7 +185,7 @@ Implements maps (associative arrays) and lists. Definition at line 141 of file map.h.
    -

    +

    @@ -239,7 +236,7 @@ Definition at line 141 of fil Definition at line 123 of file map.h.
    -

    +

    @@ -268,10 +265,12 @@ Definition at line 123 of fil

    Value:

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

    @@ -281,7 +280,7 @@ Definition at line 123 of fil Definition at line 153 of file map.h.

    -

    +

    +Definition at line 171 of file map.h.
    @@ -310,27 +309,27 @@ Definition at line 153 of fil

    Value:

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

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

    -Definition at line 169 of file map.h.


    Function Documentation

    @@ -342,7 +341,7 @@ Definition at line 169 of fil void _stp_map_add_int64 (  - MAP  + MAP  map, @@ -380,7 +379,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 558 of file map.c. +Definition at line 559 of file map.c.

    @@ -391,7 +390,7 @@ Definition at line 558 of fil void _stp_map_del (  - MAP  + MAP  map  )  @@ -419,7 +418,7 @@ Deletes a map, freeing all memory in all elements. Normally done only when the m

    Definition at line 205 of file map.c.

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

    @@ -430,7 +429,7 @@ References _stp_vfree(), int64_t _stp_map_get_int64 (  - MAP  + MAP  map  )  @@ -457,20 +456,18 @@ 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 568 of file map.c. -

    -References map_root::create, map_root::key, and map_node_int64::val. +Definition at line 569 of file map.c. -

    +

    +Definition at line 186 of file map.c.
    - + - + @@ -497,12 +494,10 @@ 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 732 of file map.c. -

    -References map_root::create, map_root::key, and map_node_stat::stats. +Definition at line 750 of file map.c.

    stat* _stp_map_get_stat stat* _stp_map_get_stat MAP MAP  map  ) 
    -

    +

    - + @@ -537,9 +532,7 @@ 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 649 of file map.c. -

    -References map_root::create, map_root::key, and map_node_str::str. +Definition at line 667 of file map.c.

    @@ -510,7 +505,7 @@ References map_root::create,
    char* _stp_map_get_str MAP MAP  map  ) 

    @@ -548,15 +541,15 @@ References map_root::create,

    - + - + - + @@ -584,13 +577,11 @@ Get the next element in a map.
    struct map_node* _stp_map_iter struct map_node* _stp_map_iter MAP MAP  map,
    struct map_nodestruct map_node *  m
    m a pointer to the current element, returned from _stp_map_start() or _stp_map_iter().
    -
    Returns:
    a pointer to the next element. This is typically used with _stp_map_start(). See the foreach() macro for typical usage. It probably does what you want anyway.
    -
    See also:
    foreach
    +
    Returns:
    a pointer to the next element. This is typically used with _stp_map_start(). See the foreach() macro for typical usage. It probably does what you want anyway.
    +
    See also:
    foreach

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

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

    @@ -601,7 +592,7 @@ References map_root::head, an void _stp_map_key_del (  - MAP  + MAP  map  )  @@ -629,9 +620,9 @@ If no current element (key) for this map is set, this function does nothing.

    Definition at line 118 of file map.c.

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

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

    @@ -642,7 +633,7 @@ Referenced by _stp_map_set_stat() void _stp_map_key_long (  - MAP  + MAP  map, @@ -680,9 +671,9 @@ This sets the current element based on a long key. If the key is not found, a ne

    Definition at line 430 of file map.c.

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

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

    @@ -693,7 +684,7 @@ Referenced by _stp_list_add_int64 void _stp_map_key_long_long (  - MAP  + MAP  map, @@ -738,8 +729,6 @@ This sets the current element based on a key of two strings. If the keys are not

    Definition at line 233 of file map.c.

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

    Referenced by _stp_map_key_long(). @@ -751,7 +740,7 @@ Referenced by _stp_map_key_long() void _stp_map_key_long_str (  - MAP  + MAP  map, @@ -794,9 +783,7 @@ This sets the current element based on a key of a long and a string. If the keys

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

    -References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val. +Definition at line 373 of file map.c.

    @@ -807,7 +794,7 @@ References map_root::c_key1, void _stp_map_key_str (  - MAP  + MAP  map, @@ -845,7 +832,7 @@ This sets the current element based on a string key. If the key is not found, a

    Definition at line 414 of file map.c.

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

    @@ -856,7 +843,7 @@ References _stp_map_key_str_str() void _stp_map_key_str_long (  - MAP  + MAP  map, @@ -899,9 +886,7 @@ This sets the current element based on a key of a string and a long. If the keys

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

    -References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val. +Definition at line 325 of file map.c.

    @@ -912,7 +897,7 @@ References map_root::c_key1, void _stp_map_key_str_str (  - MAP  + MAP  map, @@ -957,8 +942,6 @@ This sets the current element based on a key of two strings. If the keys are not

    Definition at line 276 of file map.c.

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

    Referenced by _stp_map_key_str(). @@ -968,7 +951,7 @@ Referenced by _stp_map_key_str()< - + @@ -976,7 +959,7 @@ Referenced by _stp_map_key_str()< - + @@ -1009,9 +992,9 @@ Maps must be created at module initialization time.
    Parameter

    Definition at line 57 of file map.c.

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

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

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

    @@ -1022,7 +1005,7 @@ Referenced by _stp_list_new() void _stp_map_set_int64 (  - MAP  + MAP  map, @@ -1057,15 +1040,16 @@ If the element doesn't exist, it is created. If no current element (key) is set val new value -

    See also:
    _stp_map_add_int64
    +
    See also:
    _stp_map_add_int64

    +_stp_map_set()

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

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

    +

    - + - + @@ -1101,21 +1085,21 @@ Referenced by _stp_list_add_int64

    Set the current element's value to a stat.

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

    See also:
    _stp_map_stat_add
    +This sets the current element's value to an stat struct. The map must have been created to hold stats using _stp_map_new(xxx, STAT). This function would only be used if we wanted to set stats to something other than the normal initial values (count = 0, sum = 0, etc). It may be deleted if it doesn't turn out to be useful.
    See also:
    _stp_map_stat_add
    If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.
    Parameters:
    @@ -1073,13 +1057,13 @@ Referenced by _stp_list_add_int64
    void _stp_map_set_stat MAP MAP  map,
    statstat *  stats
    map 
    stats pointer to stats struct.
    -

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

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

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

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

    @@ -1126,7 +1110,7 @@ Referenced by _stp_map_stat_add() void _stp_map_set_str (  - MAP  + MAP  map, @@ -1152,22 +1136,74 @@ Referenced by _stp_map_stat_add()

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

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

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

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

    Parameters:
    map 
    val new string
    +
    See also:
    _stp_map_set()

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

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

    -Referenced by _stp_list_add_str(). +Referenced by _stp_list_add_str(), _stp_list_add_string(), and _stp_map_set_string(). + + +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_map_set_string MAP  map,
    String  str
    +
    + + + +
    +   + + +

    +Set the current element's value to String. +

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

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

    Parameters:
    + + + +
    map 
    str String containing new value.
    +
    +
    See also:
    _stp_map_set()
    + +

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

    +References _stp_map_set_str().

    @@ -1176,9 +1212,9 @@ Referenced by _stp_list_add_str() - + - + @@ -1202,16 +1238,14 @@ Get the first element in a map.
    struct map_node* _stp_map_start struct map_node* _stp_map_start MAP MAP  map  ) 
    map 
    -

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

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

    -References map_root::head. +Definition at line 163 of file map.c. -

    +

    - + @@ -1254,12 +1288,12 @@ If the element doesn't exist, it is created. If no current element (key) is set
    @@ -1219,7 +1253,7 @@ References map_root::head.
    void _stp_map_stat_add MAP MAP  map,
    val value to add to the statistics
    -

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

    -Definition at line 753 of file map.c. +Definition at line 771 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. +References _stp_map_set_stat(). diff --git a/runtime/docs/html/group__print.html b/runtime/docs/html/group__print.html new file mode 100644 index 00000000..f18a05bf --- /dev/null +++ b/runtime/docs/html/group__print.html @@ -0,0 +1,342 @@ + + +SystemTap: Print Buffer + + + +

    +

    Print Buffer

    Print Buffer Functions. +More... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Defines

    +#define STP_PRINT_BUF_LEN   8000
     Size of buffer, not including terminating NULL.
    +#define TIMESTAMP_SIZE   19
    +#define STP_PRINT_BUF_START   (TIMESTAMP_SIZE + 1)
    #define _stp_print(str)
     Write a String or C string into the print buffer.

    Functions

    void _stp_print_flush (void)
     Send the print buffer now.
    void _stp_printf (const char *fmt,...)
     Print into the print buffer.
    void _stp_vprintf (const char *fmt, va_list args)
     Print into the print buffer.
    void _stp_print_cstr (const char *str)
     Write a C string into the print buffer.
    char * _stp_print_clear (void)
     Clear the scratch buffer.
    void _stp_print_string (String str)
     Write a String into the print buffer.
    +

    Detailed Description

    +Print Buffer Functions. +

    +The print buffer is for collecting output to send to the user daemon. This is a per-cpu static buffer. The buffer is sent when _stp_print_flush() is called.

    +The reason to do this is to allow multiple small prints to be combined then timestamped and sent together to stpd. It could flush automatically on newlines, but what about stack traces which span many lines? So try this and see how it works for us.


    Define Documentation

    +

    + + + + +
    + + + + + + + + + +
    #define _stp_print str   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    ({                                                              \
    +          if (__builtin_types_compatible_p (typeof (str), char[])) {    \
    +                  char *x = (char *)str;                                \
    +                  _stp_print_cstr(x);                                   \
    +          } else {                                                      \
    +                  String x = (String)str;                               \
    +                  _stp_print_string(x);                                 \
    +          }                                                             \
    +  })
    +
    Write a String or C string into the print buffer. +

    +This macro selects the proper function to call.

    Parameters:
    + + +
    str A String or C string (char *)
    +
    +
    See also:
    _stp_print_cstr _stp_print_string
    + +

    +Definition at line 188 of file print.c.

    +


    Function Documentation

    +

    + + + + +
    + + + + + + + + + +
    char* _stp_print_clear void   ) 
    +
    + + + + + +
    +   + + +

    +Clear the scratch buffer. +

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

    Returns:
    A pointer to the buffer.
    + +

    +Definition at line 156 of file print.c.

    +

    + + + + +
    + + + + + + + + + +
    void _stp_print_cstr const char *  str  ) 
    +
    + + + + + +
    +   + + +

    +Write a C string into the print buffer. +

    +Copies a string into a print buffer. Safe because overflowing the buffer is not allowed. Size is limited by length of print buffer, STP_PRINT_BUF_LEN. This is more efficient than using _stp_printf() if you don't need fancy formatting.

    +

    Parameters:
    + + +
    str A C string.
    +
    +
    See also:
    _stp_print
    + +

    +Definition at line 138 of file print.c. +

    +References STP_PRINT_BUF_LEN. +

    +Referenced by _stp_print_string().

    +

    + + + + +
    + + + + + + + + + +
    void _stp_print_flush void   ) 
    +
    + + + + + +
    +   + + +

    +Send the print buffer now. +

    +Output accumulates in the print buffer until this is called. Size is limited by length of print buffer, STP_PRINT_BUF_LEN. +

    +Definition at line 65 of file print.c.

    +

    + + + + +
    + + + + + + + + + +
    void _stp_print_string String  str  ) 
    +
    + + + + + +
    +   + + +

    +Write a String into the print buffer. +

    +Copies a String into a print buffer. Safe because overflowing the buffer is not allowed. Size is limited by length of print buffer, STP_PRINT_BUF_LEN. This is more efficient than using _stp_printf() if you don't need fancy formatting.

    +

    Parameters:
    + + +
    str A String.
    +
    +
    See also:
    _stp_print
    + +

    +Definition at line 176 of file print.c. +

    +References _stp_print_cstr().

    +

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

    +Print into the print buffer. +

    +Like printf, except output goes to the print buffer. Safe because overflowing the buffer is not allowed. Size is limited by length of print buffer, STP_PRINT_BUF_LEN.

    +

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

    +Definition at line 99 of file print.c. +

    +References STP_PRINT_BUF_LEN. +

    +Referenced by _stp_symbol_print().

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_vprintf const char *  fmt,
    va_list  args
    +
    + + + + + +
    +   + + +

    +Print into the print buffer. +

    +Use this if your function already has a va_list. You probably want _stp_printf(). +

    +Definition at line 117 of file print.c. +

    +References STP_PRINT_BUF_LEN.

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

    -

    Scratch Buffer

    Scratch Buffer Functions. -More... - - - - - - - - - - - - - - - -

    Defines

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

    Functions

    void _stp_sprint (const char *fmt,...)
     Sprint into the scratch buffer.
    void _stp_sprint_str (const char *str)
     Write a string into the scratch buffer.
    char * _stp_scbuf_clear (void)
     Clear the scratch buffer.
    -

    Detailed Description

    -Scratch Buffer Functions. -

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

    -

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

    Function Documentation

    -

    - - - - -
    - - - - - - - - - -
    char* _stp_scbuf_clear void   ) 
    -
    - - - - - -
    -   - - -

    -Clear the scratch buffer. -

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

    Returns:
    A pointer to the buffer.
    - -

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

    -References STP_BUF_LEN.

    -

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

    -Sprint into the scratch buffer. -

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

    -

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

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

    -References STP_BUF_LEN. -

    -Referenced by _stp_symbol_sprint().

    -

    - - - - -
    - - - - - - - - - -
    void _stp_sprint_str const char *  str  ) 
    -
    - - - - - -
    -   - - -

    -Write a string into the scratch buffer. -

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

    -

    Parameters:
    - - -
    str A string.
    -
    - -

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

    -References STP_BUF_LEN.

    - diff --git a/runtime/docs/html/group__stack.html b/runtime/docs/html/group__stack.html index 159a529f..ab4922e5 100644 --- a/runtime/docs/html/group__stack.html +++ b/runtime/docs/html/group__stack.html @@ -4,16 +4,16 @@ -

    +

    Stack Tracing Functions

    - + +

    Functions

    void _stp_stack_print (int verbose, int levels)
     Print stack dump.
    -char * _stp_stack_sprint (int verbose, int levels)
    String _stp_stack_sprint (String str, int verbose, int levels)
     Writes stack dump to a String.

    Function Documentation

    @@ -52,14 +52,78 @@ char * _stp_stack_sprint Print stack dump.

    -Prints a stack dump to the trace buffer.

    Parameters:
    +Prints a stack dump to the print buffer.
    Parameters:
    - + +
    verbose Verbosity:
    verbose Verbosity
    levels Number of levels to trace.
    +
    Todo:
    Implement verbosity and levels parameters.
    +

    +

    Bug:
    levels parameter is not functional

    -Definition at line 151 of file stack.c. +Definition at line 155 of file stack.c. + + +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    String _stp_stack_sprint String  str,
    int  verbose,
    int  levels
    +
    + + + +
    +   + + +

    +Writes stack dump to a String. +

    +

    Parameters:
    + + + + +
    str String
    verbose Verbosity
    levels Number of levels to trace.
    +
    +
    Returns:
    Same String as was input.
    +
    Todo:
    Implement verbosity and levels parameters.
    +

    +

    Bug:
    levels parameter is not functional
    + +

    +Definition at line 171 of file stack.c. +

    +References _stp_log().

    diff --git a/runtime/docs/html/group__string.html b/runtime/docs/html/group__string.html new file mode 100644 index 00000000..834b7513 --- /dev/null +++ b/runtime/docs/html/group__string.html @@ -0,0 +1,389 @@ + + +SystemTap: String Functions + + + +

    +

    String Functions

    One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack. +More... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Data Structures

    struct  string

    Defines

    +#define STP_STRING_SIZE   2048
     Maximum string size allowed in Strings.
    #define _stp_string_cat(str1, str2)
     ConCATenate (append) a String or C string to a String.

    Typedefs

    +typedef string * String

    Functions

    String _stp_string_init (int num)
     Initialize a String for our use.
    void _stp_sprintf (String str, const char *fmt,...)
     Sprintf into a String.
    void _stp_vsprintf (String str, const char *fmt, va_list args)
     Vsprintf into a String Use this if your function already has a va_list.
    void _stp_string_cat_cstr (String str1, const char *str2)
     ConCATenate (append) a C string to a String.
    void _stp_string_cat_string (String str1, String str2)
     ConCATenate (append) a String to a String.
    char * _stp_string_ptr (String str)
     Get a pointer to String's buffer For rare cases when a C string is needed and you have a String.
    +

    Detailed Description

    +One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack. +

    +It is also not a good idea to dynamically allocate space for strings with kmalloc(). That leaves us with statically allocated space for strings. This is what is implemented in the String module. Strings use preallocated per-cpu buffers and are safe to use (unlike C strings).


    Define Documentation

    +

    + + + + +
    + + + + + + + + + + + + +
    #define _stp_string_cat str1,
    str2   ) 
    +
    + + + + + +
    +   + + +

    +Value:

    ({                                                            \
    +          if (__builtin_types_compatible_p (typeof (str2), char[])) {   \
    +                  char *x = (char *)str2;                               \
    +                  _str_string_cat_cstr(str1,x);                         \
    +          } else {                                                      \
    +                  String x = (String)str2;                              \
    +                  _str_string_cat_string(str1,x);                       \
    +          }                                                             \
    +  })
    +
    ConCATenate (append) a String or C string to a String. +

    +This macro selects the proper function to call.

    Parameters:
    + + + +
    str1 A String
    str2 A String or C string (char *)
    +
    +
    See also:
    _stp_string_cat_cstr _stp_string_cat_string
    + +

    +Definition at line 150 of file string.c.

    +


    Function Documentation

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    void _stp_sprintf String  str,
    const char *  fmt,
      ...
    +
    + + + + + +
    +   + + +

    +Sprintf into a String. +

    +Like printf, except output goes into a String. Safe because overflowing the buffer is not allowed. Size is limited by length of String, STP_STRING_SIZE.

    +

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

    +Definition at line 77 of file string.c. +

    +References STP_STRING_SIZE. +

    +Referenced by _stp_symbol_sprint().

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_string_cat_cstr String  str1,
    const char *  str2
    +
    + + + + + +
    +   + + +

    +ConCATenate (append) a C string to a String. +

    +Like strcat().

    Parameters:
    + + + +
    str1 String
    str2 C string (char *)
    +
    +
    See also:
    _stp_string_cat
    + +

    +Definition at line 106 of file string.c. +

    +References STP_STRING_SIZE.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + +
    void _stp_string_cat_string String  str1,
    String  str2
    +
    + + + + + +
    +   + + +

    +ConCATenate (append) a String to a String. +

    +Like strcat().

    Parameters:
    + + + +
    str1 String
    str2 String
    +
    +
    See also:
    _stp_string_cat
    + +

    +Definition at line 121 of file string.c. +

    +References STP_STRING_SIZE.

    +

    + + + + +
    + + + + + + + + + +
    String _stp_string_init int  num  ) 
    +
    + + + + + +
    +   + + +

    +Initialize a String for our use. +

    +This grabs one of the global Strings for our use.

    +

    Parameters:
    + + +
    num Number of the preallocated String to use. #STP_NUM_STRINGS are statically allocated for our use. The translator (or author) should be sure to grab a free one.
    +
    +
    Todo:
    Global (and static) Strings not implemented yet.
    + +

    +Definition at line 42 of file string.c. +

    +References _stp_log().

    +

    + + + + +
    + + + + + + + + + +
    char* _stp_string_ptr String  str  ) 
    +
    + + + + + +
    +   + + +

    +Get a pointer to String's buffer For rare cases when a C string is needed and you have a String. +

    +One example is when you want to print a String with _stp_printf().

    Parameters:
    + + +
    str String
    +
    +
    Returns:
    A C string (char *)
    +
    Note:
    Readonly. Don't write to this pointer or it will mess up the internal String state and probably mess up your output or crash something.
    + +

    +Definition at line 138 of file string.c.

    +

    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    void _stp_vsprintf String  str,
    const char *  fmt,
    va_list  args
    +
    + + + + + +
    +   + + +

    +Vsprintf into a String Use this if your function already has a va_list. +

    +You probably want _stp_sprintf(). +

    +Definition at line 92 of file string.c. +

    +References STP_STRING_SIZE.

    + diff --git a/runtime/docs/html/group__sym.html b/runtime/docs/html/group__sym.html index eafa03c2..d5b24087 100644 --- a/runtime/docs/html/group__sym.html +++ b/runtime/docs/html/group__sym.html @@ -4,23 +4,23 @@ -

    +

    Symbolic Functions

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

    Functions

    char * _stp_symbol_sprint (unsigned long address)
    String _stp_symbol_sprint (String str, unsigned long address)
     Print addresses symbolically into a string.
    void _stp_symbol_print (unsigned long address)
     Write addresses symbolically into a String.
    void _stp_symbol_print (unsigned long address)
     Print addresses symbolically to the trace buffer.
     Print addresses symbolically to the print buffer.

    Detailed Description

    Symbolic Lookup Functions.


    Function Documentation

    -

    +

    +References _stp_printf().
    @@ -45,33 +45,42 @@ Symbolic Lookup Functions.

    -Print addresses symbolically to the trace buffer. +Print addresses symbolically to the print buffer.

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

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

    -References _stp_print().

    -

    +

    @@ -85,20 +94,20 @@ References _stp_print().

    -Print addresses symbolically into a string. +Write addresses symbolically into a String.

    Parameters:
    - + - - - - + + + + + + + + + + + + +
    char* _stp_symbol_sprint String _stp_symbol_sprint unsigned long  address  ) String  str,
    unsigned long  address
    +
    str String
    address The address to lookup.

    -
    Note:
    Symbolic lookups should not be done within a probe because it is too time-consuming. Use at module exit time.

    -Uses scbuf.

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

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

    -References _stp_sprint(). +References _stp_sprintf(). diff --git a/runtime/docs/html/index.html b/runtime/docs/html/index.html index 86c7e175..e51162e4 100644 --- a/runtime/docs/html/index.html +++ b/runtime/docs/html/index.html @@ -1,40 +1,53 @@ -SystemTap: SystemTap Runtime Library +SystemTap: SystemTap Runtime -

    -

    SystemTap Runtime Library

    + +

    SystemTap Runtime

    -

    0.1

    +

    0.2

    Introduction

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

    +This document describes the implementation of the SystemTap Runtime. It is intended for developers of the SystemTap Language translator or, possibly TapSet authors. These functions are not directly available from the SystemTap Language.

    +The SystemTap Runtime Library consists of all functions and code fragments needed by the compiler/translator to include in building a kernel module using kprobes. It also include I/O code to transmit its output from the kernel to userspace.

    +In addition to the library, the runtime includes a SystemTap user-space daemon (stpd). Stpd grabs data sent from the I/O code in the runtime and displays it and/or saves it to files. Stpd (or a script invoking it) will handle other issues like inserting and removing modules.

    +Stpd and the I/O code make use of both relayfs and netlink for communication. For kernels without relayfs builtin, it is provided as a standalone module under the runtime directory.

    Design

    Implementation

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

    +The library is written in C and is really not a library but a collection of code That can be conditionally included in a modules. It may become a library later, but for now there are some advantages to being able to change the sizes of static items with simple #defines.

    Maps (Associative Arrays)

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

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

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

    -For example:

    -/* create a map with a max of 100 elements */
    -MAP mymap = map_new(100, INT64);
    +For example: 
    /* create a map with a max of 100 elements */
    +MAP mymap = map_new(100, INT64);
     
     /* mymap[birth year] = 2000 */
     map_key_str (mymap, "birth year");
    -map_set_int64 (mymap, 2000);  
    +map_set_int64 (mymap, 2000);
     

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

    Lists

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

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

    +Strings

    +One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack. It is also not a good idea to dynamically allocate space for strings with kmalloc(). That leaves us with statically allocated space for strings. This is what is implemented in the String module. Strings use preallocated per-cpu buffers and are safe to use (unlike C strings).

    +I/O

    +Generally things are written to a "print buffer" using the internal functions _stp_print_xxx().
    _stp_print ("Output is: ");
    +_stp_printf ("pid is %d ", current->pid);
    +_stp_printf ("name is %s", current->comm);
    +
    before the probe returns it must call _stp_print_flush(). This timestamps the accumulated print buffer and sends it to relayfs. When relayfs fills an internal buffer, the user-space daemon is notified data is ready and reads a bug per-cpu chunk, which contains a line like:
    +[123456.000002] Output is: pid is 1234 name is bash
    +

    +The user-daemon (stpd) saves this data to a file named something like "stpd_cpu2". When the user hits ^c, a timer expires, or the probe module notifies stpd (through a netlink command channel) that it wants to terminate, stpd does "system(rmmod)" then collects the last output before exiting. As an option, if we don't need bulk per-cpu data, we can put

    #define STP_NETLINK_ONLY
    +
    at the top of the module and all output will go over a netlink channel. In the SystemTap language, we will provide some simple functions to control the buffering policy, which will control the use of netlink and parameters to relayfs and stpd.

    Status

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

    Example Probes

    diff --git a/runtime/docs/html/io_8c-source.html b/runtime/docs/html/io_8c-source.html index 064ef3f8..82721232 100644 --- a/runtime/docs/html/io_8c-source.html +++ b/runtime/docs/html/io_8c-source.html @@ -4,71 +4,115 @@ - -

    io.c

    Go to the documentation of this file.
    00001 #ifndef _IO_C_
    -00002 #define _IO_C_
    +
    +

    io.c

    Go to the documentation of this file.
    00001 #ifndef _IO_C_ /* -*- linux-c -*- */
    +00002 #define _IO_C_
     00003 
    -00004 /* -*- linux-c -*- */
    -00005 /** @file io.c
    -00006  * @brief I/O functions
    -00007  */
    -00008 /** @addtogroup io I/O
    -00009  * I/O functions
    -00010  * @{
    -00011  */
    -00012 
    -00013 /** Logs Data.
    -00014  * This function is compatible with printk.  In fact it currently
    -00015  * sends all output to vprintk, after sending "STP: ". This allows
    -00016  * us to easily detect SystemTap output in the log file. 
    -00017  *
    -00018  * @param fmt A variable number of args.
    -00019  * @bug Lines are limited in length by printk buffer. If there is
    -00020  * no newline in the format string, then other syslog output could
    -00021  * get appended to the SystemTap line.
    -00022  * @todo Either deprecate or redefine this as a way to log debug or 
    -00023  * status messages, separate from the normal program output.
    -00024  */
    -00025 void dlog (const char *fmt, ...)
    -00026 {
    -00027   va_list args;
    -00028   printk("STP: ");
    -00029   va_start(args, fmt);
    -00030   vprintk(fmt, args);
    -00031   va_end(args);
    -00032 }
    -00033 
    -00034 /** Prints to the trace buffer.
    -00035  * This function uses the same formatting as printk.  It currently
    -00036  * writes to the system log. 
    -00037  *
    -00038  * @param fmt A variable number of args.
    -00039  * @todo Needs replaced with something much faster that does not
    -00040  * use the system log.
    -00041  */
    -00042 
    -00043 void _stp_print (const char *fmt, ...)
    -00044 {
    -00045   va_list args;
    -00046   va_start(args, fmt);
    -00047   vprintk(fmt, args);
    -00048   va_end(args);
    -00049 }
    -00050 
    -00051 /** Prints to the trace buffer.
    -00052  * This function will write a string to the trace buffer.  It currently
    -00053  * writes to the system log. 
    -00054  *
    -00055  * @param str String.
    -00056  * @todo Needs replaced with something much faster that does not
    -00057  * use the system log.
    -00058  */
    -00059 
    -00060 void _stp_print_str (char *str)
    -00061 {
    -00062   printk ("%s", str);
    -00063 }
    -00064 
    -00065 /** @} */
    -00066 #endif /* _IO_C_ */
    +00004 #include "relay-app.h"
    +00005 #include "print.c"
    +00006 
    +00007 /** @file io.c
    +00008  * @brief I/O functions
    +00009  */
    +00010 /** @addtogroup io I/O
    +00011  * I/O functions
    +00012  * @{
    +00013  */
    +00014 
    +00015 /** private buffer for _stp_log() */
    +00016 #define STP_LOG_BUF_LEN 2047
    +00017 static char _stp_lbuf[NR_CPUS][STP_LOG_BUF_LEN + 1];
    +00018 
    +00019 /** Logs Data.
    +00020  * This function prints to the system log if stpd has not connected
    +00021  * yet.  Otherwise it sends the message immediately to stpd.
    +00022  * @param fmt A variable number of args.
    +00023  * @note Lines are limited in length by printk buffer. If there is
    +00024  * no newline in the format string, then other syslog output could
    +00025  * get appended to the SystemTap line.
    +00026  * @todo Evaluate if this function is necessary.
    +00027  */
    +00028 
    +00029 void _stp_log (const char *fmt, ...)
    +00030 {
    +00031         int num;
    +00032         char *buf = &_stp_lbuf[smp_processor_id()][0];
    +00033         va_list args;
    +00034         va_start(args, fmt);
    +00035         num = vscnprintf (buf, STP_LOG_BUF_LEN, fmt, args);
    +00036         va_end(args);
    +00037         buf[num] = '\0';
    +00038 
    +00039         if (app.logging)
    +00040                 send_reply (STP_REALTIME_DATA, buf, num + 1, stpd_pid);
    +00041         else
    +00042                 printk("STP: %s", buf);
    +00043 }
    +00044 
    +00045 static void stpd_app_started(void)
    +00046 {
    +00047         printk ("stpd has started.\n");
    +00048 }
    +00049 
    +00050 static void stpd_app_stopped(void)
    +00051 {
    +00052         printk ("stpd has stopped.\n");
    +00053 }
    +00054 
    +00055 static void probe_exit(void);
    +00056 
    +00057 #include <linux/delay.h>
    +00058 static int stpd_command (int type, void *data)
    +00059 {
    +00060         if (type == STP_EXIT) {
    +00061                 printk ("STP_EXIT received\n");
    +00062                 probe_exit();
    +00063 #ifndef STP_NETLINK_ONLY
    +00064                 relay_flush(app.chan);
    +00065                 ssleep(2); /* FIXME: time for data to be flushed */
    +00066 #endif
    +00067                 send_reply (STP_EXIT, __this_module.name, strlen(__this_module.name) + 1, stpd_pid);
    +00068                 return 1;
    +00069         }
    +00070         return 0;
    +00071 }
    +00072 
    +00073 /*
    +00074  * relay-app callbacks
    +00075  */
    +00076 static struct relay_app_callbacks stp_callbacks =
    +00077 {
    +00078         .app_started = stpd_app_started,
    +00079         .app_stopped = stpd_app_stopped,
    +00080         .user_command = stpd_command
    +00081 };
    +00082 
    +00083 /** Opens netlink and relayfs connections to stpd.
    +00084  * This must be called before any I/O is done, probably 
    +00085  * at the start of module initialization.
    +00086  */
    +00087 int _stp_netlink_open(void)
    +00088 {
    +00089         if (init_relay_app("stpd", "cpu", &stp_callbacks)) {
    +00090                 printk ("STP: couldn't init relay app\n");
    +00091                 return -1;
    +00092         }
    +00093         return 0;
    +00094 }
    +00095 
    +00096 /** Closes netlink and relayfs connections to stpd.
    +00097  * This must be called after all I/O is done, probably 
    +00098  * at the end of module cleanup.
    +00099  * @returns 0 on success.  -1 if there is a problem establishing
    +00100  * a connection.
    +00101  */
    +00102         
    +00103 void _stp_netlink_close (void)
    +00104 {
    +00105         send_reply (STP_DONE, NULL, 0, stpd_pid);
    +00106         close_relay_app();
    +00107 }
    +00108 
    +00109 /** @} */
    +00110 #endif /* _IO_C_ */
     
    diff --git a/runtime/docs/html/io_8c.html b/runtime/docs/html/io_8c.html index 3357e2f8..1aca24d7 100644 --- a/runtime/docs/html/io_8c.html +++ b/runtime/docs/html/io_8c.html @@ -4,23 +4,31 @@ - +

    io.c File Reference

    I/O functions. More...

    +#include "relay-app.h"
    +#include "print.c"
    +#include <linux/delay.h>

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

    Defines

    +#define STP_LOG_BUF_LEN   2047
     private buffer for _stp_log()

    Functions

    void dlog (const char *fmt,...)
    void _stp_log (const char *fmt,...)
     Logs Data.
    void _stp_print (const char *fmt,...)
     Logs Data.
    int _stp_netlink_open (void)
     Prints to the trace buffer.
    void _stp_print_str (char *str)
     Opens netlink and relayfs connections to stpd.
    void _stp_netlink_close (void)
     Prints to the trace buffer.
     Closes netlink and relayfs connections to stpd.


    Detailed Description

    I/O functions. diff --git a/runtime/docs/html/kprobe__where__funct_8c-source.html b/runtime/docs/html/kprobe__where__funct_8c-source.html index 7da50eda..a1d096a5 100644 --- a/runtime/docs/html/kprobe__where__funct_8c-source.html +++ b/runtime/docs/html/kprobe__where__funct_8c-source.html @@ -4,7 +4,7 @@ - +

    kprobe_where_funct.c

    00001 /* kprobe_where_funct.c
    @@ -15,76 +15,85 @@
     00006 #define HASH_TABLE_BITS 8
     00007 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
     00008 #define BUCKETS 16              /* largest histogram width */
    -00009 
    -00010 #include "runtime.h"
    -00011 #include "io.c"
    -00012 #include "map.c"
    -00013 #include "probes.c"
    -00014 #include "current.c"
    -00015 #include "sym.c"
    -00016 
    -00017 MODULE_DESCRIPTION("SystemTap probe: where_func");
    -00018 MODULE_AUTHOR("Will Cohen and Martin Hunt");
    -00019 
    -00020 static char default_name[] = "schedule";
    -00021 static char *funct_name = default_name;
    -00022 module_param(funct_name, charp, 0);
    -00023 MODULE_PARM_DESC(funct_name, "function entry name.\n");
    -00024 
    -00025 static int count_funct = 0;
    -00026 
    -00027 MAP funct_locations;
    -00028 
    -00029 static int inst_funct(struct kprobe *p, struct pt_regs *regs)
    -00030 {
    -00031         long ret_addr = _stp_ret_addr(regs);
    -00032         ++count_funct;
    -00033         _stp_map_key_long(funct_locations, ret_addr);
    -00034         _stp_map_add_int64(funct_locations, 1);
    -00035         return 0;
    -00036 }
    -00037 
    -00038 /*For each probe you need to allocate a kprobe structure*/
    -00039 static struct kprobe kp[] = {
    -00040         {
    -00041                 .addr = default_name,
    -00042                 .pre_handler = inst_funct,
    -00043         }
    -00044 };
    -00045 #define MAX_KPROBES (sizeof(kp)/sizeof(struct kprobe))
    -00046 
    -00047 int init_module(void)
    -00048 {
    -00049         int ret;
    -00050 
    -00051         funct_locations = _stp_map_new(1000, INT64);
    -00052 
    -00053         if (funct_name)
    -00054                 kp[0].addr = funct_name;
    -00055 
    -00056         ret = _stp_register_kprobes (kp, MAX_KPROBES);
    -00057 
    -00058         return ret;
    -00059 }
    -00060 
    -00061 void cleanup_module(void)
    -00062 {
    -00063         struct map_node_int64 *ptr;
    +00009 #define STP_NETLINK_ONLY
    +00010 #define STP_NUM_STRINGS 1
    +00011 
    +00012 #include "runtime.h"
    +00013 #include "map.c"
    +00014 #include "probes.c"
    +00015 #include "current.c"
    +00016 #include "sym.c"
    +00017 
    +00018 MODULE_DESCRIPTION("SystemTap probe: where_func");
    +00019 MODULE_AUTHOR("Will Cohen and Martin Hunt");
    +00020 
    +00021 static char default_name[] = "schedule";
    +00022 static char *funct_name = default_name;
    +00023 module_param(funct_name, charp, 0);
    +00024 MODULE_PARM_DESC(funct_name, "function entry name.\n");
    +00025 
    +00026 static int count_funct = 0;
    +00027 
    +00028 MAP funct_locations;
    +00029 
    +00030 static int inst_funct(struct kprobe *p, struct pt_regs *regs)
    +00031 {
    +00032         long ret_addr = _stp_ret_addr(regs);
    +00033         ++count_funct;
    +00034         _stp_map_key_long(funct_locations, ret_addr);
    +00035         _stp_map_add_int64(funct_locations, 1);
    +00036         return 0;
    +00037 }
    +00038 
    +00039 /*For each probe you need to allocate a kprobe structure*/
    +00040 static struct kprobe kp[] = {
    +00041         {
    +00042                 .addr = default_name,
    +00043                 .pre_handler = inst_funct,
    +00044         }
    +00045 };
    +00046 #define MAX_KPROBES (sizeof(kp)/sizeof(struct kprobe))
    +00047 
    +00048 int init_module(void)
    +00049 {
    +00050         int ret;
    +00051  
    +00052         if (_stp_netlink_open() < 0)
    +00053                 return -1;
    +00054   
    +00055         funct_locations = _stp_map_new(1000, INT64);
    +00056 
    +00057         if (funct_name)
    +00058                 kp[0].addr = funct_name;
    +00059 
    +00060         ret = _stp_register_kprobes (kp, MAX_KPROBES);
    +00061 
    +00062         return ret;
    +00063 }
     00064 
    -00065         _stp_unregister_kprobes (kp, MAX_KPROBES);
    -00066 
    -00067         dlog("%s() called %d times.\n", funct_name, count_funct);
    -00068         dlog("NUM\tCaller Addr\tCaller Name\n", funct_name);
    -00069 
    -00070         /* now walk the hash table and print out all the information */
    -00071         foreach(funct_locations, ptr) {
    -00072                 char *str =_stp_scbuf_clear();
    -00073                 _stp_symbol_sprint (key1int(ptr));
    -00074                 dlog("%lld\t0x%p\t(%s)\n", ptr->val, key1int(ptr), str);
    -00075         }
    -00076 
    -00077         _stp_map_del(funct_locations);
    -00078 }
    -00079 
    -00080 MODULE_LICENSE("GPL");
    +00065 static void probe_exit (void)
    +00066 {
    +00067         struct map_node_int64 *ptr;
    +00068 
    +00069         _stp_unregister_kprobes (kp, MAX_KPROBES);
    +00070 
    +00071         _stp_printf("%s() called %d times.\n", funct_name, count_funct);
    +00072         _stp_printf("NUM\tCaller\n", funct_name);
    +00073 
    +00074         /* now walk the hash table and print out all the information */
    +00075         foreach(funct_locations, ptr) {
    +00076                 _stp_printf("%lld\t", ptr->val);
    +00077                 _stp_symbol_print (key1int(ptr));
    +00078                 _stp_print_flush();
    +00079         }
    +00080         
    +00081         _stp_map_del(funct_locations);
    +00082 }
    +00083 
    +00084 void cleanup_module(void)
    +00085 {
    +00086   _stp_netlink_close(); 
    +00087 }
    +00088 
    +00089 MODULE_LICENSE("GPL");
     
    diff --git a/runtime/docs/html/main.html b/runtime/docs/html/main.html deleted file mode 100644 index 59ec4e75..00000000 --- a/runtime/docs/html/main.html +++ /dev/null @@ -1,17 +0,0 @@ - - -SystemTap: SystemTap Runtime Library - - - - - -

    SystemTap Runtime Library

    -

    -

    0.1

    -Introduction

    -The SystemTap Runtime Library consists of all functions and code fragments needed by the compiler/translator to include in building a kernel module using kprobes.
    Generated on Wed Mar 9 01:43:27 2005 for SystemTap by  - -doxygen 1.3.9.1
    - - diff --git a/runtime/docs/html/map_8c-source.html b/runtime/docs/html/map_8c-source.html index 1ff69e73..4dac0d8f 100644 --- a/runtime/docs/html/map_8c-source.html +++ b/runtime/docs/html/map_8c-source.html @@ -4,20 +4,20 @@ - -

    map.c

    Go to the documentation of this file.
    00001 #ifndef _MAP_C_
    -00002 #define _MAP_C_
    -00003 
    -00004 /* -*- linux-c -*- */
    -00005 /** @file map.c
    -00006  * @brief Implements maps (associative arrays) and lists
    -00007  */
    -00008 
    -00009 #include "map.h"
    -00010 #include "alloc.c"
    +
    +

    map.c

    Go to the documentation of this file.
    00001 #ifndef _MAP_C_ /* -*- linux-c -*- */
    +00002 #define _MAP_C_
    +00003 
    +00004 /** @file map.c
    +00005  * @brief Implements maps (associative arrays) and lists
    +00006  */
    +00007 
    +00008 #include "map.h"
    +00009 #include "alloc.c"
    +00010 #include "string.c"
     00011 
     00012 static int map_sizes[] = {
    -00013         sizeof(struct map_node_int64),
    +00013         sizeof(struct map_node_int64),
     00014         sizeof(struct map_node_stat),
     00015         sizeof(struct map_node_str),
     00016         0
    @@ -61,17 +61,17 @@
     00054  * @return A MAP on success or NULL on failure.
     00055  */
     00056 
    -00057 MAP _stp_map_new(unsigned max_entries, enum valtype type)
    +00057 MAP _stp_map_new(unsigned max_entries, enum valtype type)
     00058 {
     00059         size_t size;
    -00060         MAP m = (MAP) _stp_valloc(sizeof(struct map_root));
    +00060         MAP m = (MAP) _stp_valloc(sizeof(struct map_root));
     00061         if (m == NULL)
     00062                 return NULL;
     00063 
    -00064         INIT_LIST_HEAD(&m->head);
    +00064         INIT_LIST_HEAD(&m->head);
     00065 
    -00066         m->maxnum = max_entries;
    -00067         m->type = type;
    +00066         m->maxnum = max_entries;
    +00067         m->type = type;
     00068         if (type >= END) {
     00069                 dbug ("map_new: unknown type %d\n", type);
     00070                 return NULL;
    @@ -82,37 +82,37 @@
     00075                 int i;
     00076                 struct list_head *e;
     00077 
    -00078                 INIT_LIST_HEAD(&m->pool);
    +00078                 INIT_LIST_HEAD(&m->pool);
     00079                 size = map_sizes[type];
     00080                 tmp = _stp_valloc(max_entries * size);
     00081 
     00082                 for (i = max_entries - 1; i >= 0; i--) {
     00083                         e = i * size + tmp;
     00084                         dbug ("e=%lx\n", (long)e);
    -00085                         list_add(e, &m->pool);
    +00085                         list_add(e, &m->pool);
     00086                 }
    -00087                 m->membuf = tmp;
    +00087                 m->membuf = tmp;
     00088         }
     00089         return m;
     00090 }
     00091 
    -00092 static void map_free_strings(MAP map, struct map_node *n)
    +00092 static void map_free_strings(MAP map, struct map_node *n)
     00093 {
     00094         struct map_node_str *m = (struct map_node_str *)n;
     00095         dbug ("n = %lx\n", (long)n);
    -00096         if (map->type == STRING) {
    -00097                 dbug ("val STRING %lx\n", (long)m->str);
    -00098                 if (m->str)
    +00096         if (map->type == STRING) {
    +00097                 dbug ("val STRING %lx\n", (long)m->str);
    +00098                 if (m->str)
     00099                         _stp_free(m->str);
     00100         }
     00101         if (m->n.key1type == STR) {
    -00102                 dbug ("key1 STR %lx\n", (long)key1str(m));
    -00103                 if (key1str(m))
    +00102                 dbug ("key1 STR %lx\n", (long)key1str(m));
    +00103                 if (key1str(m))
     00104                         _stp_free(key1str(m));
     00105         }
     00106         if (m->n.key2type == STR) {
    -00107                 dbug ("key2 STR %lx\n", (long)key2str(m));
    -00108                 if (key2str(m))
    +00107                 dbug ("key2 STR %lx\n", (long)key2str(m));
    +00108                 if (key2str(m))
     00109                         _stp_free(key2str(m));
     00110         }
     00111 }
    @@ -122,9 +122,9 @@
     00115  * @param map 
     00116  */
     00117 
    -00118 void _stp_map_key_del(MAP map)
    +00118 void _stp_map_key_del(MAP map)
     00119 {
    -00120         struct map_node *m;
    +00120         struct map_node *m;
     00121 
     00122         dbug ("create=%d key=%lx\n", map->create, (long)map->key);
     00123         if (map == NULL)
    @@ -139,19 +139,19 @@
     00132         if (map->key == NULL)
     00133                 return;
     00134 
    -00135         m = (struct map_node *)map->key;
    +00135         m = (struct map_node *)map->key;
     00136 
     00137         /* remove node from old hash list */
    -00138         hlist_del_init(&m->hnode);
    +00138         hlist_del_init(&m->hnode);
     00139 
     00140         /* remove from entry list */
    -00141         list_del(&m->lnode);
    +00141         list_del(&m->lnode);
     00142 
     00143         /* remove any allocated string storage */
    -00144         map_free_strings(map, (struct map_node *)map->key);
    +00144         map_free_strings(map, (struct map_node *)map->key);
     00145 
     00146         if (map->maxnum)
    -00147                 list_add(&m->lnode, &map->pool);
    +00147                 list_add(&m->lnode, &map->pool);
     00148         else
     00149                 _stp_free(m);
     00150 
    @@ -167,17 +167,17 @@
     00160  * @sa foreach
     00161  */
     00162 
    -00163 struct map_node *_stp_map_start(MAP map)
    +00163 struct map_node *_stp_map_start(MAP map)
     00164 {
     00165         if (map == NULL)
     00166                 return NULL;
     00167 
    -00168         dbug ("%lx\n", (long)map->head.next);
    +00168         dbug ("%lx\n", (long)map->head.next);
     00169 
    -00170         if (list_empty(&map->head))
    +00170         if (list_empty(&map->head))
     00171                 return NULL;
     00172 
    -00173         return (struct map_node *)map->head.next;
    +00173         return (struct map_node *)map->head.next;
     00174 }
     00175 
     00176 /** Get the next element in a map.
    @@ -190,18 +190,18 @@
     00183  * @sa foreach
     00184  */
     00185 
    -00186 struct map_node *_stp_map_iter(MAP map, struct map_node *m)
    +00186 struct map_node *_stp_map_iter(MAP map, struct map_node *m)
     00187 {
     00188         if (map == NULL)
     00189                 return NULL;
     00190 
     00191         dbug ("%lx next=%lx  prev=%lx  map->head.next=%lx\n", (long)m, 
    -00192               (long)m->lnode.next, (long)m->lnode.prev, (long)map->head.next);
    +00192               (long)m->lnode.next, (long)m->lnode.prev, (long)map->head.next);
     00193 
    -00194         if (m->lnode.next == &map->head)
    +00194         if (m->lnode.next == &map->head)
     00195                 return NULL;
     00196 
    -00197         return (struct map_node *)m->lnode.next;
    +00197         return (struct map_node *)m->lnode.next;
     00198 }
     00199 
     00200 /** Deletes a map.
    @@ -209,19 +209,19 @@
     00202  * @param map
     00203  */
     00204 
    -00205 void _stp_map_del(MAP map)
    +00205 void _stp_map_del(MAP map)
     00206 {
     00207         if (map == NULL)
     00208                 return;
     00209 
    -00210         if (!list_empty(&map->head)) {
    -00211                 struct map_node *ptr = (struct map_node *)map->head.next;
    -00212                 while (ptr && ptr != (struct map_node *)&map->head) {
    +00210         if (!list_empty(&map->head)) {
    +00211                 struct map_node *ptr = (struct map_node *)map->head.next;
    +00212                 while (ptr && ptr != (struct map_node *)&map->head) {
     00213                         map_free_strings(map, ptr);
    -00214                         ptr = (struct map_node *)ptr->lnode.next;
    +00214                         ptr = (struct map_node *)ptr->lnode.next;
     00215                 }
     00216         }
    -00217         _stp_vfree(map->membuf);
    +00217         _stp_vfree(map->membuf);
     00218         _stp_vfree(map);
     00219 }
     00220 
    @@ -237,7 +237,7 @@
     00230  * @param key2 second key
     00231  */
     00232 
    -00233 void _stp_map_key_long_long(MAP map, long key1, long key2)
    +00233 void _stp_map_key_long_long(MAP map, long key1, long key2)
     00234 {
     00235         unsigned hv;
     00236         struct hlist_head *head;
    @@ -247,28 +247,28 @@
     00240                 return;
     00241 
     00242         hv = hash_long(key1 ^ key2, HASH_TABLE_BITS);
    -00243         head = &map->hashes[hv];
    +00243         head = &map->hashes[hv];
     00244 
     00245         dbug ("hash for %ld,%ld is %d\n", key1, key2, hv);
     00246 
     00247         hlist_for_each(e, head) {
    -00248                 struct map_node *n =
    -00249                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00250                 dbug ("n =%lx  key=%ld,%ld\n", (long)n, n->key1.val, n->key2.val);
    +00248                 struct map_node *n =
    +00249                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00250                 dbug ("n =%lx  key=%ld,%ld\n", (long)n, n->key1.val, n->key2.val);
     00251                 if (key1 == n->key1.val && key2 == n->key2.val) {
    -00252                         map->key = n;
    -00253                         dbug ("saving key %lx\n", (long)map->key);
    -00254                         map->create = 0;
    +00252                         map->key = n;
    +00253                         dbug ("saving key %lx\n", (long)map->key);
    +00254                         map->create = 0;
     00255                         return;
     00256                 }
     00257         }
     00258 
    -00259         map->c_key1.val = key1;
    -00260         map->c_key2.val = key2;
    -00261         map->c_key1type = LONG;
    -00262         map->c_key2type = LONG;
    -00263         map->c_keyhead = head;
    -00264         map->create = 1;
    +00259         map->c_key1.val = key1;
    +00260         map->c_key2.val = key2;
    +00261         map->c_key1type = LONG;
    +00262         map->c_key2type = LONG;
    +00263         map->c_keyhead = head;
    +00264         map->create = 1;
     00265 }
     00266 
     00267 /** Set the map's key to two strings.
    @@ -280,7 +280,7 @@
     00273  * @param key2 second key
     00274  */
     00275 
    -00276 void _stp_map_key_str_str(MAP map, char *key1, char *key2)
    +00276 void _stp_map_key_str_str(MAP map, char *key1, char *key2)
     00277 {
     00278         unsigned hv;
     00279         struct hlist_head *head;
    @@ -290,34 +290,34 @@
     00283                 return;
     00284 
     00285         if (key1 == NULL) {
    -00286                 map->key = NULL;
    +00286                 map->key = NULL;
     00287                 return;
     00288         }
     00289 
     00290         hv = string_hash(key1, key2);
    -00291         head = &map->hashes[hv];
    +00291         head = &map->hashes[hv];
     00292 
     00293         dbug ("hash for %s,%s is %d\n", key1, key2, hv);
     00294 
     00295         hlist_for_each(e, head) {
    -00296                 struct map_node *n =
    -00297                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00298                 dbug ("e =%lx  key=%s,%s\n", (long)e, n->key1.str,n->key2.str);
    -00299                 if (strcmp(key1, n->key1.str) == 0
    -00300                     && (key2 == NULL || strcmp(key2, n->key2.str) == 0)) {
    -00301                         map->key = n;
    -00302                         dbug ("saving key %lx\n", (long)map->key);
    -00303                         map->create = 0;
    +00296                 struct map_node *n =
    +00297                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00298                 dbug ("e =%lx  key=%s,%s\n", (long)e, n->key1.str,n->key2.str);
    +00299                 if (strcmp(key1, n->key1.str) == 0
    +00300                     && (key2 == NULL || strcmp(key2, n->key2.str) == 0)) {
    +00301                         map->key = n;
    +00302                         dbug ("saving key %lx\n", (long)map->key);
    +00303                         map->create = 0;
     00304                         return;
     00305                 }
     00306         }
     00307 
    -00308         map->c_key1.str = key1;
    -00309         map->c_key2.str = key2;
    -00310         map->c_key1type = STR;
    -00311         map->c_key2type = STR;
    -00312         map->c_keyhead = head;
    -00313         map->create = 1;
    +00308         map->c_key1.str = key1;
    +00309         map->c_key2.str = key2;
    +00310         map->c_key1type = STR;
    +00311         map->c_key2type = STR;
    +00312         map->c_keyhead = head;
    +00313         map->create = 1;
     00314 }
     00315 
     00316 /** Set the map's key to a string and a long.
    @@ -329,7 +329,7 @@
     00322  * @param key2 second key
     00323  */
     00324 
    -00325 void _stp_map_key_str_long(MAP map, char *key1, long key2)
    +00325 void _stp_map_key_str_long(MAP map, char *key1, long key2)
     00326 {
     00327         unsigned hv;
     00328         struct hlist_head *head;
    @@ -339,33 +339,33 @@
     00332                 return;
     00333 
     00334         if (key1 == NULL) {
    -00335                 map->key = NULL;
    +00335                 map->key = NULL;
     00336                 return;
     00337         }
     00338 
     00339         hv = mixed_hash(key1, key2);
    -00340         head = &map->hashes[hv];
    +00340         head = &map->hashes[hv];
     00341 
     00342         dbug ("hash for %s,%ld is %d\n", key1, key2, hv);
     00343 
     00344         hlist_for_each(e, head) {
    -00345                 struct map_node *n =
    -00346                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00347                 dbug ("e =%lx  key=%s,%ld\n", (long)e, n->key1.str,(long)n->key2.val);
    -00348                 if (strcmp(key1, n->key1.str) == 0 && key2 == n->key2.val) {
    -00349                         map->key = n;
    -00350                         dbug ("saving key %lx\n", (long)map->key);
    -00351                         map->create = 0;
    +00345                 struct map_node *n =
    +00346                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00347                 dbug ("e =%lx  key=%s,%ld\n", (long)e, n->key1.str,(long)n->key2.val);
    +00348                 if (strcmp(key1, n->key1.str) == 0 && key2 == n->key2.val) {
    +00349                         map->key = n;
    +00350                         dbug ("saving key %lx\n", (long)map->key);
    +00351                         map->create = 0;
     00352                         return;
     00353                 }
     00354         }
     00355 
    -00356         map->c_key1.str = key1;
    -00357         map->c_key2.val = key2;
    -00358         map->c_key1type = STR;
    -00359         map->c_key2type = LONG;
    -00360         map->c_keyhead = head;
    -00361         map->create = 1;
    +00356         map->c_key1.str = key1;
    +00357         map->c_key2.val = key2;
    +00358         map->c_key1type = STR;
    +00359         map->c_key2type = LONG;
    +00360         map->c_keyhead = head;
    +00361         map->create = 1;
     00362 }
     00363 
     00364 /** Set the map's key to a long and a string.
    @@ -377,7 +377,7 @@
     00370  * @param key2 second key
     00371  */
     00372 
    -00373 void _stp_map_key_long_str(MAP map, long key1, char *key2)
    +00373 void _stp_map_key_long_str(MAP map, long key1, char *key2)
     00374 {
     00375         unsigned hv;
     00376         struct hlist_head *head;
    @@ -387,27 +387,27 @@
     00380                 return;
     00381 
     00382         hv = mixed_hash(key2, key1);
    -00383         head = &map->hashes[hv];
    +00383         head = &map->hashes[hv];
     00384         dbug ("hash for %ld,%s is %d\n", key1, key2, hv);
     00385 
     00386         hlist_for_each(e, head) {
    -00387                 struct map_node *n =
    -00388                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    -00389                 dbug ("e =%lx  key=%ld,%s\n", (long)e, n->key1.val,n->key2.str);
    -00390                 if (key1 == n->key1.val && strcmp(key2, n->key2.str) == 0) {
    -00391                         map->key = n;
    -00392                         dbug ("saving key %lx\n", (long)map->key);
    -00393                         map->create = 0;
    +00387                 struct map_node *n =
    +00388                         (struct map_node *)((long)e - sizeof(struct hlist_node));
    +00389                 dbug ("e =%lx  key=%ld,%s\n", (long)e, n->key1.val,n->key2.str);
    +00390                 if (key1 == n->key1.val && strcmp(key2, n->key2.str) == 0) {
    +00391                         map->key = n;
    +00392                         dbug ("saving key %lx\n", (long)map->key);
    +00393                         map->create = 0;
     00394                         return;
     00395                 }
     00396         }
     00397 
    -00398         map->c_key1.val = key1;
    -00399         map->c_key2.str = key2;
    -00400         map->c_key1type = LONG;
    -00401         map->c_key2type = STR;
    -00402         map->c_keyhead = head;
    -00403         map->create = 1;
    +00398         map->c_key1.val = key1;
    +00399         map->c_key2.str = key2;
    +00400         map->c_key1type = LONG;
    +00401         map->c_key2type = STR;
    +00402         map->c_keyhead = head;
    +00403         map->create = 1;
     00404 }
     00405 
     00406 /** Set the map's key to a string.
    @@ -418,12 +418,12 @@
     00411  * @param key
     00412  */
     00413 
    -00414 void _stp_map_key_str(MAP map, char *key)
    +00414 void _stp_map_key_str(MAP map, char *key)
     00415 {
     00416         if (map == NULL)
     00417                 return;
     00418         _stp_map_key_str_str(map, key, NULL);
    -00419         map->c_key2type = NONE;
    +00419         map->c_key2type = NONE;
     00420 }
     00421 
     00422 /** Set the map's key to a long.
    @@ -434,55 +434,55 @@
     00427  * @param key 
     00428  */
     00429 
    -00430 void _stp_map_key_long(MAP map, long key)
    +00430 void _stp_map_key_long(MAP map, long key)
     00431 {
     00432         if (map == NULL)
     00433                 return;
     00434         _stp_map_key_long_long(map, key, 0);
    -00435         map->c_key2type = NONE;
    +00435         map->c_key2type = NONE;
     00436 }
     00437 
     00438 /**********************  SET/GET VALUES *********************/
     00439 
    -00440 static void map_copy_keys(MAP map, struct map_node *m)
    +00440 static void map_copy_keys(MAP map, struct map_node *m)
     00441 {
    -00442         m->key1type = map->c_key1type;
    -00443         m->key2type = map->c_key2type;
    -00444         switch (map->c_key1type) {
    +00442         m->key1type = map->c_key1type;
    +00443         m->key2type = map->c_key2type;
    +00444         switch (map->c_key1type) {
     00445         case STR:
    -00446                 m->key1.str = _stp_alloc(strlen(map->c_key1.str) + 1);
    -00447                 strcpy(m->key1.str, map->c_key1.str);
    +00446                 m->key1.str = _stp_alloc(strlen(map->c_key1.str) + 1);
    +00447                 strcpy(m->key1.str, map->c_key1.str);
     00448                 break;
     00449         case LONG:
    -00450                 m->key1.val = map->c_key1.val;
    +00450                 m->key1.val = map->c_key1.val;
     00451                 break;
     00452         case NONE:
     00453                 /* ERROR */
     00454                 break;
     00455         }
    -00456         switch (map->c_key2type) {
    +00456         switch (map->c_key2type) {
     00457         case STR:
    -00458                 m->key2.str = _stp_alloc(strlen(map->c_key2.str) + 1);
    -00459                 strcpy(m->key2.str, map->c_key2.str);
    +00458                 m->key2.str = _stp_alloc(strlen(map->c_key2.str) + 1);
    +00459                 strcpy(m->key2.str, map->c_key2.str);
     00460                 break;
     00461         case LONG:
    -00462                 m->key2.val = map->c_key2.val;
    +00462                 m->key2.val = map->c_key2.val;
     00463                 break;
     00464         case NONE:
     00465                 break;
     00466         }
     00467 
     00468         /* add node to new hash list */
    -00469         hlist_add_head(&m->hnode, map->c_keyhead);
    +00469         hlist_add_head(&m->hnode, map->c_keyhead);
     00470         
    -00471         map->key = m;
    -00472         map->create = 0;
    -00473         map->num++;
    +00471         map->key = m;
    +00472         map->create = 0;
    +00473         map->num++;
     00474 }
     00475 
    -00476 static void __stp_map_set_int64(MAP map, int64_t val, int add)
    +00476 static void __stp_map_set_int64(MAP map, int64_t val, int add)
     00477 {
    -00478         struct map_node_int64 *m;
    +00478         struct map_node_int64 *m;
     00479 
     00480         if (map == NULL)
     00481                 return;
    @@ -492,38 +492,38 @@
     00485                         return;
     00486 
     00487                 if (map->maxnum) {
    -00488                         if (list_empty(&map->pool)) {
    -00489                                 if (map->no_wrap) {
    +00488                         if (list_empty(&map->pool)) {
    +00489                                 if (map->no_wrap) {
     00490                                         /* ERROR. FIXME */
     00491                                         return;
     00492                                 }
    -00493                                 m = (struct map_node_int64 *)map->head.next;
    -00494                                 hlist_del_init(&m->n.hnode);
    -00495                                 map_free_strings(map, (struct map_node *)m);
    +00493                                 m = (struct map_node_int64 *)map->head.next;
    +00494                                 hlist_del_init(&m->n.hnode);
    +00495                                 map_free_strings(map, (struct map_node *)m);
     00496                                 dbug ("got %lx off head\n", (long)m);
     00497                         } else {
    -00498                                 m = (struct map_node_int64 *)map->pool.next;
    +00498                                 m = (struct map_node_int64 *)map->pool.next;
     00499                                 dbug ("got %lx off pool\n", (long)m);
     00500                         }
    -00501                         list_move_tail(&m->n.lnode, &map->head);
    +00501                         list_move_tail(&m->n.lnode, &map->head);
     00502                 } else {
    -00503                         m = (struct map_node_int64 *)
    -00504                             _stp_calloc(sizeof(struct map_node_int64));
    +00503                         m = (struct map_node_int64 *)
    +00504                             _stp_calloc(sizeof(struct map_node_int64));
     00505                         /* add node to list */
    -00506                         list_add_tail(&m->n.lnode, &map->head);
    +00506                         list_add_tail(&m->n.lnode, &map->head);
     00507                 }
     00508 
     00509                 /* copy the key(s) */
    -00510                 map_copy_keys(map, &m->n);
    +00510                 map_copy_keys(map, &m->n);
     00511 
     00512                 /* set the value */
    -00513                 m->val = val;
    +00513                 m->val = val;
     00514         } else {
    -00515                 if (map->key == NULL)
    +00515                 if (map->key == NULL)
     00516                         return;
     00517 
     00518                 if (val) {
    -00519                         m = (struct map_node_int64 *)map->key;
    +00519                         m = (struct map_node_int64 *)map->key;
     00520                         if (add)
     00521                                 m->val += val;
     00522                         else
    @@ -544,345 +544,377 @@
     00537  * @param map
     00538  * @param val new value
     00539  * @sa _stp_map_add_int64
    -00540  */
    -00541 void _stp_map_set_int64(MAP map, int64_t val)
    -00542 {
    -00543         __stp_map_set_int64 (map, val, 0);
    -00544 }
    -00545 
    -00546 
    -00547 /** Adds an int64 to the current element's value.
    -00548  * This adds an int64 to the current element's value. The map must have been created
    -00549  * to hold int64s using _stp_map_new()
    -00550  *
    -00551  * If the element doesn't exist, it is created.  If no current element (key)
    -00552  * is set for the map, this function does nothing.
    -00553  * @param map
    -00554  * @param val value
    -00555  * @sa _stp_map_set_int64
    -00556  */
    -00557 
    -00558 void _stp_map_add_int64(MAP map, int64_t val)
    -00559 {
    -00560         __stp_map_set_int64 (map, val, 1);
    -00561 }
    -00562 
    -00563 /** Gets the current element's value.
    -00564  * @param map
    -00565  * @returns The value. If the current element is not set or doesn't exist, returns 0.
    -00566  */
    -00567 
    -00568 int64_t _stp_map_get_int64(MAP map)
    -00569 {
    -00570         struct map_node_int64 *m;
    -00571         if (map == NULL || map->create || map->key == NULL)
    -00572                 return 0;
    -00573         dbug ("%lx\n", (long)map->key);
    -00574         m = (struct map_node_int64 *)map->key;
    -00575         return m->val;
    -00576 }
    -00577 
    -00578 /** Set the current element's value to a string.
    -00579  * This sets the current element's value to an string. The map must have been created
    -00580  * to hold int64s using <i>_stp_map_new(xxx, STRING)</i>
    -00581  *
    -00582  * If the element doesn't exist, it is created.  If no current element (key)
    -00583  * is set for the map, this function does nothing.
    -00584  * @param map
    -00585  * @param val new string
    -00586  */
    -00587 
    -00588 void _stp_map_set_str(MAP map, char *val)
    -00589 {
    -00590         struct map_node_str *m;
    -00591 
    -00592         if (map == NULL)
    -00593                 return;
    -00594 
    -00595         if (map->create) {
    -00596                 if (val == NULL)
    -00597                         return;
    -00598 
    -00599                 if (map->maxnum) {
    -00600                         if (list_empty(&map->pool)) {
    -00601                                 if (map->no_wrap) {
    -00602                                         /* ERROR. FIXME */
    -00603                                         return;
    -00604                                 }
    -00605                                 m = (struct map_node_str *)map->head.next;
    -00606                                 hlist_del_init(&m->n.hnode);
    -00607                                 map_free_strings(map, (struct map_node *)m);
    -00608                                 dbug ("got %lx off head\n", (long)m);
    -00609                         } else {
    -00610                                 m = (struct map_node_str *)map->pool.next;
    -00611                                 dbug ("got %lx off pool\n", (long)m);
    -00612                         }
    -00613                         list_move_tail(&m->n.lnode, &map->head);
    -00614                 } else {
    -00615                         m = (struct map_node_str *)
    -00616                             _stp_calloc(sizeof(struct map_node_str));
    -00617                         /* add node to list */
    -00618                         list_add_tail(&m->n.lnode, &map->head);
    -00619                 }
    -00620 
    -00621                 /* copy the key(s) */
    -00622                 map_copy_keys(map, &m->n);
    -00623 
    -00624                 /* set the value */
    -00625                 m->str = _stp_alloc(strlen(val) + 1);
    -00626                 strcpy(m->str, val);
    -00627         } else {
    -00628                 if (map->key == NULL)
    -00629                         return;
    -00630 
    -00631                 if (val) {
    -00632                         m = (struct map_node_str *)map->key;
    -00633                         if (m->str)
    -00634                                 _stp_free(m->str);
    -00635                         m->str = _stp_alloc(strlen(val) + 1);
    -00636                         strcpy(m->str, val);
    -00637                 } else {
    -00638                         /* setting value to 0 is the same as deleting */
    -00639                         _stp_map_key_del(map);
    -00640                 }
    -00641         }
    -00642 }
    -00643 
    -00644 /** Gets the current element's value.
    -00645  * @param map
    -00646  * @returns A string pointer. If the current element is not set or doesn't exist, returns NULL.
    -00647  */
    -00648 
    -00649 char *_stp_map_get_str(MAP map)
    -00650 {
    -00651         struct map_node_str *m;
    -00652         if (map == NULL || map->create || map->key == NULL)
    -00653                 return NULL;
    -00654         dbug ("%lx\n", (long)map->key);
    -00655         m = (struct map_node_str *)map->key;
    -00656         return m->str;
    -00657 }
    -00658 
    -00659 /** Set the current element's value to a stat.
    -00660  * This sets the current element's value to an stat struct. The map must have been created
    -00661  * to hold stats using <i>_stp_map_new(xxx, STAT)</i>.  This function would only be used
    -00662  * if we wanted to set stats to something other than the normal initial values (count = 0,
    -00663  * sum = 0, etc).  It may be deleted if it doesn't turn out to be useful.
    -00664  * @sa _stp_map_stat_add 
    -00665  *
    -00666  * If the element doesn't exist, it is created.  If no current element (key)
    -00667  * is set for the map, this function does nothing.
    -00668  * @param map
    -00669  * @param stats pointer to stats struct.
    -00670  * @todo Histograms don't work yet.
    -00671  */
    -00672 
    -00673 void _stp_map_set_stat(MAP map, stat * stats)
    -00674 {
    -00675         struct map_node_stat *m;
    -00676 
    -00677         if (map == NULL)
    -00678                 return;
    -00679         dbug ("set_stat %lx\n", (long)map->key);
    -00680 
    -00681         if (map->create) {
    -00682                 if (stats == NULL)
    -00683                         return;
    -00684 
    -00685                 if (map->maxnum) {
    -00686                         if (list_empty(&map->pool)) {
    -00687                                 if (map->no_wrap) {
    -00688                                         /* ERROR. FIXME */
    -00689                                         return;
    -00690                                 }
    -00691                                 m = (struct map_node_stat *)map->head.next;
    -00692                                 hlist_del_init(&m->n.hnode);
    -00693                                 map_free_strings(map, (struct map_node *)m);
    -00694                                 dbug ("got %lx off head\n", (long)m);
    -00695                         } else {
    -00696                                 m = (struct map_node_stat *)map->pool.next;
    -00697                                 dbug ("got %lx off pool\n", (long)m);
    -00698                         }
    -00699                         list_move_tail(&m->n.lnode, &map->head);
    -00700                 } else {
    -00701                         m = (struct map_node_stat *)
    -00702                             _stp_calloc(sizeof(struct map_node_stat));
    -00703                         /* add node to list */
    -00704                         list_add_tail(&m->n.lnode, &map->head);
    -00705                 }
    -00706 
    -00707                 /* copy the key(s) */
    -00708                 map_copy_keys(map, &m->n);
    -00709 
    -00710                 /* set the value */
    -00711                 memcpy(&m->stats, stats, sizeof(stat));
    -00712         } else {
    -00713                 if (map->key == NULL)
    -00714                         return;
    -00715 
    -00716                 if (stats) {
    -00717                         m = (struct map_node_stat *)map->key;
    -00718                         memcpy(&m->stats, stats, sizeof(stat));
    -00719                 } else {
    -00720                         /* setting value to NULL is the same as deleting */
    -00721                         _stp_map_key_del(map);
    -00722                 }
    -00723         }
    -00724 }
    -00725 
    -00726 /** Gets the current element's value.
    -00727  * @param map
    -00728  * @returns A pointer to the stats struct. If the current element is not set 
    -00729  * or doesn't exist, returns NULL.
    -00730  */
    -00731 
    -00732 stat *_stp_map_get_stat(MAP map)
    -00733 {
    -00734         struct map_node_stat *m;
    -00735         if (map == NULL || map->create || map->key == NULL)
    -00736                 return NULL;
    -00737         dbug ("%lx\n", (long)map->key);
    -00738         m = (struct map_node_stat *)map->key;
    -00739         return &m->stats;
    -00740 }
    -00741 
    -00742 /** Add to the current element's statistics.
    -00743  * Increments the statistics counter by one and the sum by <i>val</i>.
    -00744  * Adjusts minimum, maximum, and histogram.
    -00745  *
    -00746  * If the element doesn't exist, it is created.  If no current element (key)
    -00747  * is set for the map, this function does nothing.
    -00748  * @param map
    -00749  * @param val value to add to the statistics
    -00750  * @todo Histograms don't work yet.
    -00751  */
    -00752 
    -00753 void _stp_map_stat_add(MAP map, int64_t val)
    -00754 {
    -00755         struct map_node_stat *m;
    -00756         if (map == NULL)
    -00757                 return;
    -00758 
    -00759         if (map->create) {
    -00760                 stat st = { 1, val, val, val };
    -00761                 /* histogram */
    -00762                 _stp_map_set_stat(map, &st);
    -00763                 return;
    -00764         }
    -00765 
    -00766         if (map->key == NULL)
    -00767                 return;
    -00768 
    -00769         dbug ("add_stat %lx\n", (long)map->key);
    -00770         m = (struct map_node_stat *)map->key;
    -00771         m->stats.count++;
    -00772         m->stats.sum += val;
    -00773         if (val > m->stats.max)
    -00774                 m->stats.max = val;
    -00775         if (val < m->stats.min)
    -00776                 m->stats.min = val;
    -00777         /* histogram */
    -00778 }
    -00779 
    -00780 /** @} */
    -00781 
    -00782 /**********************  List Functions *********************/
    -00783 
    -00784 /** @addtogroup lists
    -00785  * Lists are special cases of maps.
    -00786  * @b Example:
    -00787  * @include list.c
    -00788  * @{ */
    -00789 
    -00790 /** Create a new list.
    -00791  * A list is a map that internally has an incrementing long key for each member.
    -00792  * Lists do not wrap if elements are added to exceed their maximum size.
    -00793  * @param max_entries The maximum number of entries allowed. Currently that number will
    -00794  * be preallocated.  If max_entries is 0, there will be no maximum and entries
    -00795  * will be allocated dynamically.
    -00796  * @param type Type of values stored in this list. 
    -00797  * @return A MAP on success or NULL on failure.
    -00798  * @sa foreach
    -00799  */
    -00800 
    -00801 MAP _stp_list_new(unsigned max_entries, enum valtype type)
    -00802 {
    -00803   MAP map = _stp_map_new (max_entries, type);
    -00804   map->no_wrap = 1;
    -00805   return map;
    -00806 }
    +00540  * @sa _stp_map_set()
    +00541  */
    +00542 void _stp_map_set_int64(MAP map, int64_t val)
    +00543 {
    +00544         __stp_map_set_int64 (map, val, 0);
    +00545 }
    +00546 
    +00547 
    +00548 /** Adds an int64 to the current element's value.
    +00549  * This adds an int64 to the current element's value. The map must have been created
    +00550  * to hold int64s using _stp_map_new()
    +00551  *
    +00552  * If the element doesn't exist, it is created.  If no current element (key)
    +00553  * is set for the map, this function does nothing.
    +00554  * @param map
    +00555  * @param val value
    +00556  * @sa _stp_map_set_int64
    +00557  */
    +00558 
    +00559 void _stp_map_add_int64(MAP map, int64_t val)
    +00560 {
    +00561         __stp_map_set_int64 (map, val, 1);
    +00562 }
    +00563 
    +00564 /** Gets the current element's value.
    +00565  * @param map
    +00566  * @returns The value. If the current element is not set or doesn't exist, returns 0.
    +00567  */
    +00568 
    +00569 int64_t _stp_map_get_int64(MAP map)
    +00570 {
    +00571         struct map_node_int64 *m;
    +00572         if (map == NULL || map->create || map->key == NULL)
    +00573                 return 0;
    +00574         dbug ("%lx\n", (long)map->key);
    +00575         m = (struct map_node_int64 *)map->key;
    +00576         return m->val;
    +00577 }
    +00578 
    +00579 /** Set the current element's value to a C string.
    +00580  * This sets the current element's value to an C string. The map must have been created
    +00581  * to hold int64s using <i>_stp_map_new(xxx, STRING)</i>
    +00582  *
    +00583  * If the element doesn't exist, it is created.  If no current element (key)
    +00584  * is set for the map, this function does nothing.
    +00585  * @param map
    +00586  * @param val new string
    +00587  * @sa _stp_map_set()
    +00588  */
    +00589 
    +00590 void _stp_map_set_str(MAP map, char *val)
    +00591 {
    +00592         struct map_node_str *m;
    +00593 
    +00594         if (map == NULL)
    +00595                 return;
    +00596 
    +00597         if (map->create) {
    +00598                 if (val == NULL)
    +00599                         return;
    +00600 
    +00601                 if (map->maxnum) {
    +00602                         if (list_empty(&map->pool)) {
    +00603                                 if (map->no_wrap) {
    +00604                                         /* ERROR. FIXME */
    +00605                                         return;
    +00606                                 }
    +00607                                 m = (struct map_node_str *)map->head.next;
    +00608                                 hlist_del_init(&m->n.hnode);
    +00609                                 map_free_strings(map, (struct map_node *)m);
    +00610                                 dbug ("got %lx off head\n", (long)m);
    +00611                         } else {
    +00612                                 m = (struct map_node_str *)map->pool.next;
    +00613                                 dbug ("got %lx off pool\n", (long)m);
    +00614                         }
    +00615                         list_move_tail(&m->n.lnode, &map->head);
    +00616                 } else {
    +00617                         m = (struct map_node_str *)
    +00618                             _stp_calloc(sizeof(struct map_node_str));
    +00619                         /* add node to list */
    +00620                         list_add_tail(&m->n.lnode, &map->head);
    +00621                 }
    +00622 
    +00623                 /* copy the key(s) */
    +00624                 map_copy_keys(map, &m->n);
    +00625 
    +00626                 /* set the value */
    +00627                 m->str = _stp_alloc(strlen(val) + 1);
    +00628                 strcpy(m->str, val);
    +00629         } else {
    +00630                 if (map->key == NULL)
    +00631                         return;
    +00632 
    +00633                 if (val) {
    +00634                         m = (struct map_node_str *)map->key;
    +00635                         if (m->str)
    +00636                                 _stp_free(m->str);
    +00637                         m->str = _stp_alloc(strlen(val) + 1);
    +00638                         strcpy(m->str, val);
    +00639                 } else {
    +00640                         /* setting value to 0 is the same as deleting */
    +00641                         _stp_map_key_del(map);
    +00642                 }
    +00643         }
    +00644 }
    +00645 
    +00646 /** Set the current element's value to String.
    +00647  * This sets the current element's value to a String. The map must have been created
    +00648  * to hold int64s using <i>_stp_map_new(xxx, STRING)</i>
    +00649  *
    +00650  * If the element doesn't exist, it is created.  If no current element (key)
    +00651  * is set for the map, this function does nothing.
    +00652  * @param map
    +00653  * @param str String containing new value.
    +00654  * @sa _stp_map_set()
    +00655  */
    +00656 
    +00657 void _stp_map_set_string (MAP map, String str)
    +00658 {
    +00659   _stp_map_set_str (map, str->buf);
    +00660 }
    +00661 
    +00662 /** Gets the current element's value.
    +00663  * @param map
    +00664  * @returns A string pointer. If the current element is not set or doesn't exist, returns NULL.
    +00665  */
    +00666 
    +00667 char *_stp_map_get_str(MAP map)
    +00668 {
    +00669         struct map_node_str *m;
    +00670         if (map == NULL || map->create || map->key == NULL)
    +00671                 return NULL;
    +00672         dbug ("%lx\n", (long)map->key);
    +00673         m = (struct map_node_str *)map->key;
    +00674         return m->str;
    +00675 }
    +00676 
    +00677 /** Set the current element's value to a stat.
    +00678  * This sets the current element's value to an stat struct. The map must have been created
    +00679  * to hold stats using <i>_stp_map_new(xxx, STAT)</i>.  This function would only be used
    +00680  * if we wanted to set stats to something other than the normal initial values (count = 0,
    +00681  * sum = 0, etc).  It may be deleted if it doesn't turn out to be useful.
    +00682  * @sa _stp_map_stat_add 
    +00683  *
    +00684  * If the element doesn't exist, it is created.  If no current element (key)
    +00685  * is set for the map, this function does nothing.
    +00686  * @param map
    +00687  * @param stats pointer to stats struct.
    +00688  * @todo Histograms don't work yet.
    +00689  */
    +00690 
    +00691 void _stp_map_set_stat(MAP map, stat * stats)
    +00692 {
    +00693         struct map_node_stat *m;
    +00694 
    +00695         if (map == NULL)
    +00696                 return;
    +00697         dbug ("set_stat %lx\n", (long)map->key);
    +00698 
    +00699         if (map->create) {
    +00700                 if (stats == NULL)
    +00701                         return;
    +00702 
    +00703                 if (map->maxnum) {
    +00704                         if (list_empty(&map->pool)) {
    +00705                                 if (map->no_wrap) {
    +00706                                         /* ERROR. FIXME */
    +00707                                         return;
    +00708                                 }
    +00709                                 m = (struct map_node_stat *)map->head.next;
    +00710                                 hlist_del_init(&m->n.hnode);
    +00711                                 map_free_strings(map, (struct map_node *)m);
    +00712                                 dbug ("got %lx off head\n", (long)m);
    +00713                         } else {
    +00714                                 m = (struct map_node_stat *)map->pool.next;
    +00715                                 dbug ("got %lx off pool\n", (long)m);
    +00716                         }
    +00717                         list_move_tail(&m->n.lnode, &map->head);
    +00718                 } else {
    +00719                         m = (struct map_node_stat *)
    +00720                             _stp_calloc(sizeof(struct map_node_stat));
    +00721                         /* add node to list */
    +00722                         list_add_tail(&m->n.lnode, &map->head);
    +00723                 }
    +00724 
    +00725                 /* copy the key(s) */
    +00726                 map_copy_keys(map, &m->n);
    +00727 
    +00728                 /* set the value */
    +00729                 memcpy(&m->stats, stats, sizeof(stat));
    +00730         } else {
    +00731                 if (map->key == NULL)
    +00732                         return;
    +00733 
    +00734                 if (stats) {
    +00735                         m = (struct map_node_stat *)map->key;
    +00736                         memcpy(&m->stats, stats, sizeof(stat));
    +00737                 } else {
    +00738                         /* setting value to NULL is the same as deleting */
    +00739                         _stp_map_key_del(map);
    +00740                 }
    +00741         }
    +00742 }
    +00743 
    +00744 /** Gets the current element's value.
    +00745  * @param map
    +00746  * @returns A pointer to the stats struct. If the current element is not set 
    +00747  * or doesn't exist, returns NULL.
    +00748  */
    +00749 
    +00750 stat *_stp_map_get_stat(MAP map)
    +00751 {
    +00752         struct map_node_stat *m;
    +00753         if (map == NULL || map->create || map->key == NULL)
    +00754                 return NULL;
    +00755         dbug ("%lx\n", (long)map->key);
    +00756         m = (struct map_node_stat *)map->key;
    +00757         return &m->stats;
    +00758 }
    +00759 
    +00760 /** Add to the current element's statistics.
    +00761  * Increments the statistics counter by one and the sum by <i>val</i>.
    +00762  * Adjusts minimum, maximum, and histogram.
    +00763  *
    +00764  * If the element doesn't exist, it is created.  If no current element (key)
    +00765  * is set for the map, this function does nothing.
    +00766  * @param map
    +00767  * @param val value to add to the statistics
    +00768  * @todo Histograms don't work yet.
    +00769  */
    +00770 
    +00771 void _stp_map_stat_add(MAP map, int64_t val)
    +00772 {
    +00773         struct map_node_stat *m;
    +00774         if (map == NULL)
    +00775                 return;
    +00776 
    +00777         if (map->create) {
    +00778                 stat st = { 1, val, val, val };
    +00779                 /* histogram */
    +00780                 _stp_map_set_stat(map, &st);
    +00781                 return;
    +00782         }
    +00783 
    +00784         if (map->key == NULL)
    +00785                 return;
    +00786 
    +00787         dbug ("add_stat %lx\n", (long)map->key);
    +00788         m = (struct map_node_stat *)map->key;
    +00789         m->stats.count++;
    +00790         m->stats.sum += val;
    +00791         if (val > m->stats.max)
    +00792                 m->stats.max = val;
    +00793         if (val < m->stats.min)
    +00794                 m->stats.min = val;
    +00795         /* histogram */
    +00796 }
    +00797 
    +00798 /** @} */
    +00799 
    +00800 /**********************  List Functions *********************/
    +00801 
    +00802 /** @addtogroup lists
    +00803  * Lists are special cases of maps.
    +00804  * @b Example:
    +00805  * @include list.c
    +00806  * @{ */
     00807 
    -00808 /** Clears a list.
    -00809  * All elements in the list are deleted.
    -00810  * @param map 
    -00811  */
    -00812 
    -00813 void _stp_list_clear(MAP map)
    -00814 {
    -00815         if (map == NULL)
    -00816                 return;
    -00817 
    -00818         if (!list_empty(&map->head)) {
    -00819                 struct map_node *ptr = (struct map_node *)map->head.next;
    -00820 
    -00821                 while (ptr && ptr != (struct map_node *)&map->head) {
    -00822                         struct map_node *next = (struct map_node *)ptr->lnode.next;
    -00823 
    -00824                         /* remove node from old hash list */
    -00825                         hlist_del_init(&ptr->hnode);
    -00826 
    -00827                         /* remove from entry list */
    -00828                         list_del(&ptr->lnode);
    -00829                         
    -00830                         /* remove any allocated string storage */
    -00831                         map_free_strings(map, ptr);
    -00832                         
    -00833                         if (map->maxnum)
    -00834                                 list_add(&ptr->lnode, &map->pool);
    -00835                         else
    -00836                                 _stp_free(ptr);
    -00837 
    -00838                         map->num--;
    -00839                         ptr = next;
    -00840                 }
    -00841         }
    -00842 
    -00843         if (map->num != 0) {
    -00844                 dlog ("ERROR: list is supposed to be empty (has %d)\n", map->num);
    -00845         }
    -00846 }
    -00847 
    -00848 /** Adds a string to a list.
    -00849  * @param map
    -00850  * @param str
    -00851  */
    -00852 
    -00853 inline void _stp_list_add_str(MAP map, char *str)
    -00854 {
    -00855         _stp_map_key_long(map, map->num);
    -00856         _stp_map_set_str(map, str);
    -00857 }
    -00858 
    -00859 /** Adds an int64 to a list.
    -00860  * @param map
    -00861  * @param val
    -00862  */
    -00863 
    -00864 inline void _stp_list_add_int64(MAP map, int64_t val)
    -00865 {
    -00866         _stp_map_key_long(map, map->num);
    -00867         _stp_map_set_int64(map, val);
    -00868 }
    -00869 
    -00870 /** Get the number of elements in a list.
    -00871  * @param map
    -00872  * @returns The number of elements in a list.
    -00873  */
    -00874 
    -00875 inline int _stp_list_size(MAP map)
    -00876 {
    -00877         return map->num;
    -00878 }
    -00879 /** @} */
    -00880 #endif /* _MAP_C_ */
    +00808 /** Create a new list.
    +00809  * A list is a map that internally has an incrementing long key for each member.
    +00810  * Lists do not wrap if elements are added to exceed their maximum size.
    +00811  * @param max_entries The maximum number of entries allowed. Currently that number will
    +00812  * be preallocated.  If max_entries is 0, there will be no maximum and entries
    +00813  * will be allocated dynamically.
    +00814  * @param type Type of values stored in this list. 
    +00815  * @return A MAP on success or NULL on failure.
    +00816  * @sa foreach
    +00817  */
    +00818 
    +00819 MAP _stp_list_new(unsigned max_entries, enum valtype type)
    +00820 {
    +00821   MAP map = _stp_map_new (max_entries, type);
    +00822   map->no_wrap = 1;
    +00823   return map;
    +00824 }
    +00825 
    +00826 /** Clears a list.
    +00827  * All elements in the list are deleted.
    +00828  * @param map 
    +00829  */
    +00830 
    +00831 void _stp_list_clear(MAP map)
    +00832 {
    +00833         if (map == NULL)
    +00834                 return;
    +00835 
    +00836         if (!list_empty(&map->head)) {
    +00837                 struct map_node *ptr = (struct map_node *)map->head.next;
    +00838 
    +00839                 while (ptr && ptr != (struct map_node *)&map->head) {
    +00840                         struct map_node *next = (struct map_node *)ptr->lnode.next;
    +00841 
    +00842                         /* remove node from old hash list */
    +00843                         hlist_del_init(&ptr->hnode);
    +00844 
    +00845                         /* remove from entry list */
    +00846                         list_del(&ptr->lnode);
    +00847                         
    +00848                         /* remove any allocated string storage */
    +00849                         map_free_strings(map, ptr);
    +00850                         
    +00851                         if (map->maxnum)
    +00852                                 list_add(&ptr->lnode, &map->pool);
    +00853                         else
    +00854                                 _stp_free(ptr);
    +00855 
    +00856                         map->num--;
    +00857                         ptr = next;
    +00858                 }
    +00859         }
    +00860 
    +00861         if (map->num != 0) {
    +00862                 _stp_log ("ERROR: list is supposed to be empty (has %d)\n", map->num);
    +00863         }
    +00864 }
    +00865 
    +00866 /** Adds a C string to a list.
    +00867  * @param map
    +00868  * @param str
    +00869  * @sa _stp_list_add()
    +00870  */
    +00871 
    +00872 inline void _stp_list_add_str(MAP map, char *str)
    +00873 {
    +00874         _stp_map_key_long(map, map->num);
    +00875         _stp_map_set_str(map, str);
    +00876 }
    +00877 
    +00878 /** Adds a String to a list.
    +00879  * @param map
    +00880  * @param str String to add.
    +00881  * @sa _stp_list_add()
    +00882  */
    +00883 
    +00884 inline void _stp_list_add_string (MAP map, String str)
    +00885 {
    +00886         _stp_map_key_long(map, map->num);
    +00887         _stp_map_set_str(map, str->buf);
    +00888 }
    +00889 
    +00890 /** Adds an int64 to a list.
    +00891  * @param map
    +00892  * @param val
    +00893  * @sa _stp_list_add()
    +00894  */
    +00895 
    +00896 inline void _stp_list_add_int64(MAP map, int64_t val)
    +00897 {
    +00898         _stp_map_key_long(map, map->num);
    +00899         _stp_map_set_int64(map, val);
    +00900 }
    +00901 
    +00902 /** Get the number of elements in a list.
    +00903  * @param map
    +00904  * @returns The number of elements in a list.
    +00905  */
    +00906 
    +00907 inline int _stp_list_size(MAP map)
    +00908 {
    +00909         return map->num;
    +00910 }
    +00911 /** @} */
    +00912 #endif /* _MAP_C_ */
     
    diff --git a/runtime/docs/html/map_8c.html b/runtime/docs/html/map_8c.html index f9bb262d..5193f3f0 100644 --- a/runtime/docs/html/map_8c.html +++ b/runtime/docs/html/map_8c.html @@ -4,88 +4,95 @@ - +

    map.c File Reference

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

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

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

    Functions

    MAP _stp_map_new (unsigned max_entries, enum valtype type)
    MAP _stp_map_new (unsigned max_entries, enum valtype type)
     Create a new map.
    void _stp_map_key_del (MAP map)
    void _stp_map_key_del (MAP map)
     Deletes the current element.
    map_node_stp_map_start (MAP map)
    map_node * _stp_map_start (MAP map)
     Get the first element in a map.
    map_node_stp_map_iter (MAP map, struct map_node *m)
    map_node * _stp_map_iter (MAP map, struct map_node *m)
     Get the next element in a map.
    void _stp_map_del (MAP map)
    void _stp_map_del (MAP map)
     Deletes a map.
    void _stp_map_key_long_long (MAP map, long key1, long key2)
    void _stp_map_key_long_long (MAP map, long key1, long key2)
     Set the map's key to two longs.
    void _stp_map_key_str_str (MAP map, char *key1, char *key2)
    void _stp_map_key_str_str (MAP map, char *key1, char *key2)
     Set the map's key to two strings.
    void _stp_map_key_str_long (MAP map, char *key1, long key2)
    void _stp_map_key_str_long (MAP map, char *key1, long key2)
     Set the map's key to a string and a long.
    void _stp_map_key_long_str (MAP map, long key1, char *key2)
    void _stp_map_key_long_str (MAP map, long key1, char *key2)
     Set the map's key to a long and a string.
    void _stp_map_key_str (MAP map, char *key)
    void _stp_map_key_str (MAP map, char *key)
     Set the map's key to a string.
    void _stp_map_key_long (MAP map, long key)
    void _stp_map_key_long (MAP map, long key)
     Set the map's key to a long.
    void _stp_map_set_int64 (MAP map, int64_t val)
    void _stp_map_set_int64 (MAP map, int64_t val)
     Set the current element's value to an int64.
    void _stp_map_add_int64 (MAP map, int64_t val)
    void _stp_map_add_int64 (MAP map, int64_t val)
     Adds an int64 to the current element's value.
    int64_t _stp_map_get_int64 (MAP map)
    int64_t _stp_map_get_int64 (MAP map)
     Gets the current element's value.
    void _stp_map_set_str (MAP map, char *val)
    void _stp_map_set_str (MAP map, char *val)
     Set the current element's value to a string.
    char * _stp_map_get_str (MAP map)
     Set the current element's value to a C string.
    void _stp_map_set_string (MAP map, String str)
     Gets the current element's value.
    void _stp_map_set_stat (MAP map, stat *stats)
     Set the current element's value to String.
    char * _stp_map_get_str (MAP map)
     Set the current element's value to a stat.
    stat_stp_map_get_stat (MAP map)
     Gets the current element's value.
    void _stp_map_set_stat (MAP map, stat *stats)
     Gets the current element's value.
    void _stp_map_stat_add (MAP map, int64_t val)
     Set the current element's value to a stat.
    stat * _stp_map_get_stat (MAP map)
     Add to the current element's statistics.
    MAP _stp_list_new (unsigned max_entries, enum valtype type)
     Gets the current element's value.
    void _stp_map_stat_add (MAP map, int64_t val)
     Add to the current element's statistics.
    MAP _stp_list_new (unsigned max_entries, enum valtype type)
     Create a new list.
    void _stp_list_clear (MAP map)
    void _stp_list_clear (MAP map)
     Clears a list.
    void _stp_list_add_str (MAP map, char *str)
    void _stp_list_add_str (MAP map, char *str)
     Adds a C string to a list.
    void _stp_list_add_string (MAP map, String str)
     Adds a string to a list.
    void _stp_list_add_int64 (MAP map, int64_t val)
     Adds a String to a list.
    void _stp_list_add_int64 (MAP map, int64_t val)
     Adds an int64 to a list.
    int _stp_list_size (MAP map)
     Adds an int64 to a list.
    int _stp_list_size (MAP map)
     Get the number of elements in a list.
     Get the number of elements in a list.


    Detailed Description

    Implements maps (associative arrays) and lists. diff --git a/runtime/docs/html/map_8h-source.html b/runtime/docs/html/map_8h-source.html index 94c29074..956ac200 100644 --- a/runtime/docs/html/map_8h-source.html +++ b/runtime/docs/html/map_8h-source.html @@ -4,130 +4,130 @@ - -

    map.h

    Go to the documentation of this file.
    00001 #ifndef _MAP_H_
    -00002 #define _MAP_H_
    -00003 /* -*- linux-c -*- */
    -00004 
    -00005 /** @file map.h
    -00006  * @brief Header file for maps and lists 
    -00007  */
    -00008 /** @addtogroup maps 
    +
    +

    map.h

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

    map.h File Reference

    Header file for maps and lists. More...

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

    Defines

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

    Typedefs

    -typedef map_rootMAP
    MAP
     All maps are of this type.

    Enumerations

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

    Variables

    -enum keytype packed
    packed
     keys can be longs or strings
    diff --git a/runtime/docs/html/modules.html b/runtime/docs/html/modules.html index 32f1541b..1c46a1f7 100644 --- a/runtime/docs/html/modules.html +++ b/runtime/docs/html/modules.html @@ -4,7 +4,7 @@ -

    +

    SystemTap Modules

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

    SystemTap Related Pages

    Here is a list of all related documentation pages: diff --git a/runtime/docs/html/print_8c-source.html b/runtime/docs/html/print_8c-source.html new file mode 100644 index 00000000..c020fff3 --- /dev/null +++ b/runtime/docs/html/print_8c-source.html @@ -0,0 +1,208 @@ + + +SystemTap: print.c Source File + + + + +

    print.c

    00001 #ifndef _PRINT_C_ /* -*- linux-c -*- */
    +00002 #define _PRINT_C_
    +00003 
    +00004 #include <linux/config.h>
    +00005 
    +00006 #include "io.c"
    +00007 
    +00008 /** @file print.c
    +00009  * @addtogroup print Print Buffer
    +00010  * Print Buffer Functions.
    +00011  * The print buffer is for collecting output to send to the user daemon.
    +00012  * This is a per-cpu static buffer.  The buffer is sent when
    +00013  * _stp_print_flush() is called.
    +00014  *
    +00015  * The reason to do this is to allow multiple small prints to be combined then
    +00016  * timestamped and sent together to stpd. It could flush automatically on newlines,
    +00017  * but what about stack traces which span many lines?  So try this and see how it works for us.
    +00018  * @{
    +00019  */
    +00020 
    +00021 /** Size of buffer, not including terminating NULL */
    +00022 #define STP_PRINT_BUF_LEN 8000
    +00023 
    +00024 static int _stp_pbuf_len[NR_CPUS];
    +00025 
    +00026 #ifdef STP_NETLINK_ONLY
    +00027 #define STP_PRINT_BUF_START 0
    +00028 static char _stp_pbuf[NR_CPUS][STP_PRINT_BUF_LEN + 1];
    +00029 
    +00030 void _stp_print_flush (void)
    +00031 {
    +00032         int cpu = smp_processor_id();
    +00033         char *buf = &_stp_pbuf[cpu][0];
    +00034         int len = _stp_pbuf_len[cpu];
    +00035 
    +00036         if (len == 0)
    +00037                 return;
    +00038 
    +00039         if ( app.logging == 0) {
    +00040                 _stp_pbuf_len[cpu] = 0;
    +00041                 return;
    +00042         }
    +00043         
    +00044         /* enforce newline at end  */
    +00045         if (buf[len - 1] != '\n') {
    +00046                 buf[len++] = '\n';
    +00047                 buf[len] = '\0';
    +00048         }
    +00049         
    +00050         send_reply (STP_REALTIME_DATA, buf, len + 1, stpd_pid);
    +00051         _stp_pbuf_len[cpu] = 0;
    +00052 }
    +00053 
    +00054 #else /* ! STP_NETLINK_ONLY */
    +00055 /* size of timestamp, in bytes, including space */
    +00056 #define TIMESTAMP_SIZE 19
    +00057 #define STP_PRINT_BUF_START (TIMESTAMP_SIZE + 1)
    +00058 static char _stp_pbuf[NR_CPUS][STP_PRINT_BUF_LEN + STP_PRINT_BUF_START + 1];
    +00059 
    +00060 /** Send the print buffer now.
    +00061  * Output accumulates in the print buffer until this is called.
    +00062  * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN.
    +00063  */
    +00064 
    +00065 void _stp_print_flush (void)
    +00066 {
    +00067         int cpu = smp_processor_id();
    +00068         char *buf = &_stp_pbuf[cpu][0];
    +00069         char *ptr = buf + STP_PRINT_BUF_START;
    +00070         struct timeval tv;
    +00071 
    +00072         if (_stp_pbuf_len[cpu] == 0)
    +00073                 return;
    +00074         
    +00075         /* enforce newline at end  */
    +00076         if (ptr[_stp_pbuf_len[cpu]-1] != '\n') {
    +00077                 ptr[_stp_pbuf_len[cpu]++] = '\n';
    +00078                 ptr[_stp_pbuf_len[cpu]] = '\0';
    +00079         }
    +00080         
    +00081         do_gettimeofday(&tv);
    +00082         scnprintf (buf, TIMESTAMP_SIZE+1, "[%li.%06li] ", tv.tv_sec, tv.tv_usec);
    +00083         buf[TIMESTAMP_SIZE] = ' ';
    +00084         relayapp_write(buf, _stp_pbuf_len[cpu] + TIMESTAMP_SIZE + 2);
    +00085         _stp_pbuf_len[cpu] = 0;
    +00086 }
    +00087 #endif /* STP_NETLINK_ONLY */
    +00088 
    +00089 /** Print into the print buffer.
    +00090  * Like printf, except output goes to the print buffer.
    +00091  * Safe because overflowing the buffer is not allowed.
    +00092  * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN.
    +00093  * 
    +00094  * @param fmt A printf-style format string followed by a 
    +00095  * variable number of args.
    +00096  * @sa _stp_print_flush()
    +00097  */
    +00098 
    +00099 void _stp_printf (const char *fmt, ...)
    +00100 {
    +00101         int num;
    +00102         va_list args;
    +00103         int cpu = smp_processor_id();
    +00104         char *buf = &_stp_pbuf[cpu][STP_PRINT_BUF_START] + _stp_pbuf_len[cpu];
    +00105         va_start(args, fmt);
    +00106         num = vscnprintf(buf, STP_PRINT_BUF_LEN - _stp_pbuf_len[cpu], fmt, args);
    +00107         va_end(args);
    +00108         if (num > 0)
    +00109                 _stp_pbuf_len[cpu] += num;
    +00110 }
    +00111 
    +00112 /** Print into the print buffer.
    +00113  * Use this if your function already has a va_list.
    +00114  * You probably want _stp_printf().
    +00115  */
    +00116 
    +00117 void _stp_vprintf (const char *fmt, va_list args)
    +00118 {
    +00119         int num;
    +00120         int cpu = smp_processor_id();
    +00121         char *buf = &_stp_pbuf[cpu][STP_PRINT_BUF_START] + _stp_pbuf_len[cpu];
    +00122         num = vscnprintf(buf, STP_PRINT_BUF_LEN -_stp_pbuf_len[cpu], fmt, args);
    +00123         if (num > 0)
    +00124                 _stp_pbuf_len[cpu] += num;
    +00125 }
    +00126 
    +00127 /** Write a C string into the print buffer.
    +00128  * Copies a string into a print buffer.
    +00129  * Safe because overflowing the buffer is not allowed.
    +00130  * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN.
    +00131  * This is more efficient than using _stp_printf() if you don't
    +00132  * need fancy formatting.
    +00133  *
    +00134  * @param str A C string.
    +00135  * @sa _stp_print
    +00136  */
    +00137 
    +00138 void _stp_print_cstr (const char *str)
    +00139 {
    +00140         int cpu = smp_processor_id();
    +00141         char *buf = &_stp_pbuf[cpu][STP_PRINT_BUF_START] + _stp_pbuf_len[cpu];
    +00142         int num = strlen (str);
    +00143         if (num > STP_PRINT_BUF_LEN - _stp_pbuf_len[cpu])
    +00144                 num = STP_PRINT_BUF_LEN - _stp_pbuf_len[cpu];
    +00145         strncpy (buf, str, num+1);
    +00146         _stp_pbuf_len[cpu] += num;
    +00147 }
    +00148 
    +00149 /** Clear the scratch buffer.
    +00150  * This function should be called before anything is written to 
    +00151  * the scratch buffer.  Output will accumulate in the buffer
    +00152  * until this function is called again.  
    +00153  * @returns A pointer to the buffer.
    +00154  */
    +00155 
    +00156 char *_stp_print_clear (void)
    +00157 {
    +00158         int cpu = smp_processor_id();
    +00159         _stp_pbuf_len[cpu] = 0;
    +00160         return &_stp_pbuf[cpu][STP_PRINT_BUF_START];
    +00161 }
    +00162 
    +00163 #include "string.c"
    +00164 
    +00165 /** Write a String into the print buffer.
    +00166  * Copies a String into a print buffer.
    +00167  * Safe because overflowing the buffer is not allowed.
    +00168  * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN.
    +00169  * This is more efficient than using _stp_printf() if you don't
    +00170  * need fancy formatting.
    +00171  *
    +00172  * @param str A String.
    +00173  * @sa _stp_print
    +00174  */
    +00175 
    +00176 void _stp_print_string (String str)
    +00177 {
    +00178         if (str->len)
    +00179                 _stp_print_cstr (str->buf);
    +00180 }
    +00181 
    +00182 /** Write a String or C string into the print buffer.
    +00183  * This macro selects the proper function to call.
    +00184  * @param str A String or C string (char *)
    +00185  * @sa _stp_print_cstr _stp_print_string
    +00186  */
    +00187 
    +00188 #define _stp_print(str)                                                 \
    +00189         ({                                                              \
    +00190           if (__builtin_types_compatible_p (typeof (str), char[])) {    \
    +00191                   char *x = (char *)str;                                \
    +00192                   _stp_print_cstr(x);                                   \
    +00193           } else {                                                      \
    +00194                   String x = (String)str;                               \
    +00195                   _stp_print_string(x);                                 \
    +00196           }                                                             \
    +00197   })
    +00198 
    +00199 /** @} */
    +00200 #endif /* _PRINT_C_ */
    +
    diff --git a/runtime/docs/html/probes.html b/runtime/docs/html/probes.html deleted file mode 100644 index b25bf2c7..00000000 --- a/runtime/docs/html/probes.html +++ /dev/null @@ -1,10 +0,0 @@ - - -SystemTap: Example Probes - - - - -

    Example Probes


    -Generated on Mon Mar 21 23:24:22 2005 for SystemTap. - diff --git a/runtime/docs/html/probes_2README-source.html b/runtime/docs/html/probes_2README-source.html index 572047bc..ee82281f 100644 --- a/runtime/docs/html/probes_2README-source.html +++ b/runtime/docs/html/probes_2README-source.html @@ -4,7 +4,7 @@ - +

    README

    00001 /** @dir probes
    diff --git a/runtime/docs/html/probes_2shellsnoop_2README-source.html b/runtime/docs/html/probes_2shellsnoop_2README-source.html
    index f629ded8..e7384ecb 100644
    --- a/runtime/docs/html/probes_2shellsnoop_2README-source.html
    +++ b/runtime/docs/html/probes_2shellsnoop_2README-source.html
    @@ -4,7 +4,7 @@
     
     
     
    -
    +
     
     

    README

    00001 /** @dir shellsnoop
    @@ -34,7 +34,7 @@
     00025   if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh")
     00026       || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh"))
     00027     {
    -00028       dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename);
    +00028       dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename);
     00029       @pids[current->pid] = 1;
     00030 
     00031       /* print out argv, ignoring argv[0] */
    @@ -74,7 +74,7 @@
     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 }
    diff --git a/runtime/docs/html/probes_2tasklet_2README-source.html b/runtime/docs/html/probes_2tasklet_2README-source.html
    index 7d09aa4e..d49f0a1f 100644
    --- a/runtime/docs/html/probes_2tasklet_2README-source.html
    +++ b/runtime/docs/html/probes_2tasklet_2README-source.html
    @@ -4,7 +4,7 @@
     
     
     
    -
    +
     
     

    README

    00001 /** @dir tasklet
    diff --git a/runtime/docs/html/probes_2test4_2README-source.html b/runtime/docs/html/probes_2test4_2README-source.html
    index 69aa4539..20ebcf80 100644
    --- a/runtime/docs/html/probes_2test4_2README-source.html
    +++ b/runtime/docs/html/probes_2test4_2README-source.html
    @@ -4,7 +4,7 @@
     
     
     
    -
    +
     
     

    README

    00001 /** @dir test4
    diff --git a/runtime/docs/html/probes_2where__func_2README-source.html b/runtime/docs/html/probes_2where__func_2README-source.html
    index 6f9699ad..eb81beda 100644
    --- a/runtime/docs/html/probes_2where__func_2README-source.html
    +++ b/runtime/docs/html/probes_2where__func_2README-source.html
    @@ -4,7 +4,7 @@
     
     
     
    -
    +
     
     

    README

    00001 /** @dir where_func
    diff --git a/runtime/docs/html/probes_8c-source.html b/runtime/docs/html/probes_8c-source.html
    index ab2b831b..6084bad3 100644
    --- a/runtime/docs/html/probes_8c-source.html
    +++ b/runtime/docs/html/probes_8c-source.html
    @@ -4,107 +4,110 @@
     
     
     
    -
    -

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

    probes.c

    Go to the documentation of this file.
    00001 #ifndef _PROBES_C_ /* -*- linux-c -*- */
    +00002 #define _PROBES_C
    +00003 
    +00004 /** @file probes.c
    +00005  * @brief Functions to assist loading and unloading groups of probes.
    +00006  */
    +00007 
    +00008 /** Lookup name.
    +00009  * This simply calls the kernel function kallsyms_lookup_name().
    +00010  * That function is not exported, so this workaround is required.
    +00011  * See the kernel source, kernel/kallsyms.c for more information.
    +00012  */
    +00013 static unsigned long (*_stp_lookup_name)(char *name)=(void *)KALLSYMS_LOOKUP_NAME;
    +00014 
    +00015 /** Unregister a group of jprobes.
    +00016  * @param probes Pointer to an array of struct jprobe.
    +00017  * @param num_probes Number of probes in the array.
    +00018  */
    +00019 
    +00020 void _stp_unregister_jprobes (struct jprobe *probes, int num_probes)
    +00021 {
    +00022         int i;
    +00023         for (i = 0; i < num_probes; i++)
    +00024                 unregister_jprobe(&probes[i]);
    +00025         _stp_log ("All jprobes removed\n");
    +00026 }
    +00027 
    +00028 /** Register a group of jprobes.
    +00029  * @param probes Pointer to an array of struct jprobe.
    +00030  * @param num_probes Number of probes in the array.
    +00031  * @return 0 on success.
    +00032  */
    +00033 
    +00034 int _stp_register_jprobes (struct jprobe *probes, int num_probes)
    +00035 {
    +00036         int i, ret ;
    +00037         unsigned long addr;
    +00038 
    +00039         for (i = 0; i < num_probes; i++) {
    +00040                 addr =_stp_lookup_name((char *)probes[i].kp.addr);
    +00041                 if (addr == 0) {
    +00042                         _stp_log ("ERROR: function %s not found!\n", 
    +00043                               (char *)probes[i].kp.addr);
    +00044                         ret = -1; /* FIXME */
    +00045                         goto out;
    +00046                 }
    +00047                 _stp_log("inserting jprobe at %s (%p)\n", probes[i].kp.addr, addr);
    +00048                 probes[i].kp.addr = (kprobe_opcode_t *)addr;
    +00049                 ret = register_jprobe(&probes[i]);
    +00050                 if (ret)
    +00051                         goto out;
    +00052         }
    +00053         return 0;
    +00054 out:
    +00055         _stp_log ("probe module initialization failed.  Exiting...\n");
    +00056         _stp_unregister_jprobes(probes, i);
    +00057         return ret;
    +00058 }
    +00059 
    +00060 /** Unregister a group of kprobes.
    +00061  * @param probes Pointer to an array of struct kprobe.
    +00062  * @param num_probes Number of probes in the array.
    +00063  */
    +00064 
    +00065 void _stp_unregister_kprobes (struct kprobe *probes, int num_probes)
    +00066 {
    +00067         int i;
    +00068         for (i = 0; i < num_probes; i++)
    +00069                 unregister_kprobe(&probes[i]);
    +00070         _stp_log ("All kprobes removed\n");
    +00071 }
    +00072 
    +00073 /** Register a group of kprobes.
    +00074  * @param probes Pointer to an array of struct kprobe.
    +00075  * @param num_probes Number of probes in the array.
    +00076  * @return 0 on success.
    +00077  */
    +00078 
    +00079 int _stp_register_kprobes (struct kprobe *probes, int num_probes)
    +00080 {
    +00081         int i, ret ;
    +00082         unsigned long addr;
    +00083 
    +00084         for (i = 0; i < num_probes; i++) {
    +00085                 addr =_stp_lookup_name((char *)probes[i].addr);
    +00086                 if (addr == 0) {
    +00087                         _stp_log ("ERROR: function %s not found!\n", 
    +00088                               (char *)probes[i].addr);
    +00089                         ret = -1; /* FIXME */
    +00090                         goto out;
    +00091                 }
    +00092                 _stp_log("inserting kprobe at %s (%p)\n", probes[i].addr, addr);
    +00093                 probes[i].addr = (kprobe_opcode_t *)addr;
    +00094                 ret = register_kprobe(&probes[i]);
    +00095                 if (ret)
    +00096                         goto out;
    +00097         }
    +00098         return 0;
    +00099 out:
    +00100         _stp_log ("probe module initialization failed.  Exiting...\n");
    +00101         _stp_unregister_kprobes(probes, i);
    +00102         return ret;
    +00103 }
    +00104 
    +00105 #endif /* _PROBES_C */
     
    diff --git a/runtime/docs/html/probes_8c.html b/runtime/docs/html/probes_8c.html index 5bdbeb43..a43b04af 100644 --- a/runtime/docs/html/probes_8c.html +++ b/runtime/docs/html/probes_8c.html @@ -4,7 +4,7 @@ - +

    probes.c File Reference

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

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

    Functions

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


    Detailed Description

    Functions to assist loading and unloading groups of probes. @@ -31,7 +31,7 @@ Functions to assist loading and unloading groups of probes.

    Definition in file probes.c.


    Function Documentation

    -

    +

    +References _stp_log(), and _stp_unregister_jprobes().
    @@ -76,12 +76,12 @@ Register a group of jprobes.
    Returns:
    0 on success.

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

    -References _stp_unregister_jprobes(), and dlog().

    -

    +

    +References _stp_log(), and _stp_unregister_kprobes().
    @@ -126,12 +126,12 @@ Register a group of kprobes.
    Returns:
    0 on success.

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

    -References _stp_unregister_kprobes(), and dlog().

    -

    +

    +Referenced by _stp_register_jprobes().
    @@ -175,14 +175,14 @@ Unregister a group of jprobes.

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

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

    -Referenced by _stp_register_jprobes().

    -

    +

    +Referenced by _stp_register_kprobes().
    @@ -226,11 +226,11 @@ Unregister a group of kprobes.

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

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

    -Referenced by _stp_register_kprobes().

    diff --git a/runtime/docs/html/relay-app_8h-source.html b/runtime/docs/html/relay-app_8h-source.html new file mode 100644 index 00000000..16feefe0 --- /dev/null +++ b/runtime/docs/html/relay-app_8h-source.html @@ -0,0 +1,542 @@ + + +SystemTap: relay-app.h Source File + + + +

    +

    relay-app.h

    00001 /*
    +00002  *  relay-app.h - kernel 'library' functions for typical relayfs applications
    +00003  *
    +00004  * This program is free software; you can redistribute it and/or modify
    +00005  * it under the terms of the GNU General Public License as published by
    +00006  * the Free Software Foundation; either version 2 of the License, or
    +00007  * (at your option) any later version.
    +00008  *
    +00009  * This program is distributed in the hope that it will be useful,
    +00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    +00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    +00012  * GNU General Public License for more details.
    +00013  *
    +00014  * You should have received a copy of the GNU General Public License
    +00015  * along with this program; if not, write to the Free Software
    +00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    +00017  *
    +00018  * Copyright (C) IBM Corporation, 2005
    +00019  *
    +00020  * 2005-Feb     Created by Tom Zanussi <zanussi@us.ibm.com>
    +00021  *
    +00022  * This header file encapsulates the details of channel setup and
    +00023  * teardown and communication between the kernel and user parts of a
    +00024  * typical and common type of relayfs application, which is that
    +00025  * kernel logging is kicked off when a userspace data collection
    +00026  * application starts and stopped when the collection app exits, and
    +00027  * data is automatically logged to disk in-between.  Channels are
    +00028  * created when the collection app is started and destroyed when it
    +00029  * exits, not when the kernel module is inserted, so different channel
    +00030  * buffer sizes can be specified for each separate run via
    +00031  * command-line options for instance.
    +00032  *
    +00033  * Writing to the channel is done using 2 macros, relayapp_write() and
    +00034  * _relayapp_write(), which are just wrappers around relay_write() and
    +00035  * _relay_write() but without the channel param.  You can safely call
    +00036  * these at any time - if there's no channel yet, they'll just be
    +00037  * ignored.
    +00038  *
    +00039  * To create a relay-app application, do the following:
    +00040  *
    +00041  * In your kernel module:
    +00042  *
    +00043  * - #include "relay-app.h"
    +00044  *
    +00045  * - Call init_relay_app() in your module_init function, with the
    +00046  *   names of the directory to create relayfs files in and the base name
    +00047  *   of the per-cpu relayfs files e.g. to have /mnt/relay/myapp/cpuXXX
    +00048  *   created call init_relay_app("myapp", "cpu", callbacks).
    +00049  *
    +00050  *   NOTE: The callbacks are entirely optional - pass NULL if you
    +00051  *   don't want to define any.  If you want to define some but not
    +00052  *   others, just set the ones you want, and ignore or NULL out the
    +00053  *   others.
    +00054  *
    +00055  *   NOTE: This won't actually create the relayfs files - that will
    +00056  *   happen when the userspace application starts (i.e. you can supply
    +00057  *   the buffer sizes on the application command-line for each new run
    +00058  *   of your program).
    +00059  *
    +00060  *   NOTE: If you pass in NULL for the directory name, the relay files
    +00061  *   will be created in the root directory of the relayfs filesystem.
    +00062  *
    +00063  * - Call close_relay_app() in your module_exit function - this cleans
    +00064  *   up the control channel and the relay files from the previous run,
    +00065  *   if any.
    +00066  *
    +00067  * - relay-apps use a control channel to communicate initialization
    +00068  *   and status information between the kernel module and user space
    +00069  *   program.  This is hidden beneath the API so you normally don't need
    +00070  *   to know anything about it, but if you want you can also use it to
    +00071  *   send user-defined commands from your user space application.  To do
    +00072  *   this, you need to define a definition for the user_command()
    +00073  *   callback and in the callback sort out and handle handle the
    +00074  *   commands you send from user space (via send_request()).  The
    +00075  *   callback must return 1 if the command was handled, or 0 if not
    +00076  *   (which will result in a send_error in the user space program,
    +00077  *   alerting you to the fact that you're sending something bogus).
    +00078  *
    +00079  *   NOTE: Currently commands can only be sent before the user space
    +00080  *   application enters relay_app_main_loop() i.e. for initialization
    +00081  *   purposes only.
    +00082  *
    +00083  * - the app_started() and app_stopped() callbacks provide an
    +00084  *   opportunity for your kernel module to perform app-specific
    +00085  *   initialization and cleanup, if desired.  They are purely
    +00086  *   informational.  app_started() is called when the user space
    +00087  *   application has started and app_stopped() is called when the user
    +00088  *   space application has stopped.
    +00089  *
    +00090  * In your user space application do the following:
    +00091  *
    +00092  * - Call init_relay_app() with the names of the relayfs file base
    +00093  *   name and the base filename of the output files that will be
    +00094  *   created, as well as the sub-buffer size and count for the current
    +00095  *   run (which can be passed in on the command-line if you want).  This
    +00096  *   will create the channel and set up the ouptut files and buffer
    +00097  *   mappings.  e.g. to set up reading from the relayfs files specified in the
    +00098  *   above example and write them to a set of per-cpu output files named
    +00099  *   myoutputXXX:
    +00100  * 
    +00101  *   init_relay_app("/mnt/relay/myapp/cpu", "myoutput",
    +00102  *                  subbuf_size_opt, n_subbufs_opt, 1);
    +00103  *
    +00104  *   (the last parameter just specifies whether or not to print out a
    +00105  *   summary of the number of buffers processed, and the maximum backlog
    +00106  *   of sub-buffers encountered e.g. if you have 4 sub-buffers, a
    +00107  *   maximum backlog of 3 would mean that you came close to having a
    +00108  *   full buffer, so you might want to use more or bigger sub-buffers
    +00109  *   next time.  Of course, if the buffers actually filled up, the
    +00110  *   maximum backlog would be 4 and you'd have lost data).
    +00111  *
    +00112  * - Call relay_app_main_loop().  This will set up an infinite loop
    +00113  *   (press Control-C to break out and finalize the data) which
    +00114  *   automatically reads the data from the relayfs buffers as it becomes
    +00115  *   available and and writes it out to per-cpu output files.
    +00116  *
    +00117  *   NOTE: The control channel is implemented as a netlink socket.
    +00118  *   relay-app defaults to using NETLINK_USERSOCK for all
    +00119  *   applications, which means that you can't have more than 1
    +00120  *   relay-app in use at a time, unless you use different netlink
    +00121  *   'units' for each one.  If you want to have more than one
    +00122  *   relay-app in use at a time, you can specify a different netlink
    +00123  *   'unit' by using the _init_relay_app() versions of the
    +00124  *   init_relay_app() functions, on both the kernel and user sides,
    +00125  *   which are the same as the init_relay_app() functions but add a
    +00126  *   netlink unit param.  See netlink.h for the currently unused
    +00127  *   numbers.
    +00128  */
    +00129 
    +00130 #include <linux/inet.h>
    +00131 #include <linux/ip.h>
    +00132 #include <linux/netlink.h>
    +00133 #include <linux/relayfs_fs.h>
    +00134 
    +00135 /* relay-app pseudo-API */
    +00136 
    +00137 /*
    +00138  * relay-app callbacks
    +00139  */
    +00140 struct relay_app_callbacks
    +00141 {
    +00142         /*
    +00143          *      user_command - app-specific command callback
    +00144          *      @command: user-defined command id
    +00145          *      @data: user-defined data associated with the command
    +00146          *
    +00147          *      Return value: 1 if this callback handled it, 0 if not
    +00148          *
    +00149          *      define this callback to handle user-defined commands sent
    +00150          *      from the user space application via send_request()
    +00151          *
    +00152          *      NOTE: user commands must be >= RELAY_APP_USERCMD_START
    +00153          */
    +00154         int (*user_command) (int command, void *data);
    +00155 
    +00156         /*
    +00157          *      app_started - the user-space application has started
    +00158          *
    +00159          *      Do app-specific initializations now, if desired
    +00160          */
    +00161         void (*app_started) (void);
    +00162 
    +00163         /*
    +00164          *      app_stopped - the user-space application has stopped
    +00165          *
    +00166          *      Do app-specific cleanup now, if desired
    +00167          */
    +00168         void (*app_stopped) (void);
    +00169 };
    +00170 
    +00171 /*
    +00172  * relay-app API functions
    +00173  */
    +00174 static int init_relay_app(const char *dirname,
    +00175                           const char *file_basename,
    +00176                           struct relay_app_callbacks *callbacks);
    +00177 static void close_relay_app(void);
    +00178 
    +00179 /*
    +00180  * relay-app write wrapper macros - use these instead of directly
    +00181  * using relay_write() and _relay_write() relayfs functions.
    +00182  */
    +00183 #define relayapp_write(data, len) \
    +00184         if (app.logging) relay_write(app.chan, data, len)
    +00185 
    +00186 #define _relayapp_write(data, len) \
    +00187         if (app.logging) _relay_write(app.chan, data, len)
    +00188 
    +00189 /* relay-app control channel command values */
    +00190 enum
    +00191 {
    +00192         RELAY_APP_BUF_INFO = 1,
    +00193         RELAY_APP_SUBBUFS_CONSUMED,
    +00194         RELAY_APP_START,
    +00195         RELAY_APP_STOP,
    +00196         RELAY_APP_CHAN_CREATE,
    +00197         RELAY_APP_CHAN_DESTROY,
    +00198         RELAY_APP_USERCMD_START = 32
    +00199 };
    +00200 
    +00201 /* SystemTap extensions */
    +00202 enum
    +00203 {
    +00204         STP_REALTIME_DATA = RELAY_APP_USERCMD_START,
    +00205         STP_EXIT,
    +00206         STP_DONE
    +00207 };
    +00208 
    +00209 /* internal stuff below here */
    +00210 
    +00211 /* netlink control channel */
    +00212 static struct sock *control;
    +00213 static int seq;
    +00214 static int stpd_pid = 0;
    +00215 
    +00216 /* info for this application */
    +00217 static struct relay_app
    +00218 {
    +00219         char dirname[1024];
    +00220         char file_basename[1024];
    +00221         struct relay_app_callbacks *cb;
    +00222         struct rchan *chan;
    +00223         struct dentry *dir;
    +00224         int logging;
    +00225         int mappings;
    +00226 } app;
    +00227 
    +00228 /*
    +00229  * subbuf_start() relayfs callback.
    +00230  */
    +00231 static int relay_app_subbuf_start(struct rchan_buf *buf,
    +00232                                   void *subbuf,
    +00233                                   unsigned prev_subbuf_idx,
    +00234                                   void *prev_subbuf)
    +00235 {
    +00236         unsigned padding = buf->padding[prev_subbuf_idx];
    +00237         if (prev_subbuf)
    +00238                 *((unsigned *)prev_subbuf) = padding;
    +00239 
    +00240         return sizeof(padding); /* reserve space for padding */
    +00241 }
    +00242 
    +00243 /*
    +00244  * buf_full() relayfs callback.
    +00245  */
    +00246 static void relay_app_buf_full(struct rchan_buf *buf,
    +00247                                unsigned subbuf_idx,
    +00248                                void *subbuf)
    +00249 {
    +00250         unsigned padding = buf->padding[subbuf_idx];
    +00251         *((unsigned *)subbuf) = padding;
    +00252 }
    +00253 
    +00254 static void relay_app_buf_mapped(struct rchan_buf *buf, struct file *filp)
    +00255 {
    +00256         if (app.cb && app.cb->app_started && !app.mappings++)
    +00257                 app.cb->app_started();
    +00258 }
    +00259 
    +00260 static void relay_app_buf_unmapped(struct rchan_buf *buf, struct file *filp)
    +00261 {
    +00262         if (app.cb && app.cb->app_started && !--app.mappings)
    +00263                 app.cb->app_stopped();
    +00264 }
    +00265 
    +00266 static struct rchan_callbacks app_rchan_callbacks =
    +00267 {
    +00268         .subbuf_start = relay_app_subbuf_start,
    +00269         .buf_full = relay_app_buf_full,
    +00270         .buf_mapped = relay_app_buf_mapped,
    +00271         .buf_unmapped = relay_app_buf_unmapped
    +00272 };
    +00273 
    +00274 /**
    +00275  *      create_app_chan - creates channel /mnt/relay/dirname/filebaseXXX
    +00276  *
    +00277  *      Returns channel on success, NULL otherwise.
    +00278  */
    +00279 static struct rchan *create_app_chan(unsigned subbuf_size,
    +00280                                      unsigned n_subbufs)
    +00281 {
    +00282         struct rchan *chan;
    +00283 
    +00284         if (strlen(app.dirname)) {
    +00285                 app.dir = relayfs_create_dir(app.dirname, NULL);
    +00286                 if (!app.dir) {
    +00287                         printk("Couldn't create relayfs app directory %s.\n", app.dirname);
    +00288                         return NULL;
    +00289                 }
    +00290         }
    +00291 
    +00292         chan = relay_open(app.file_basename, app.dir, subbuf_size,
    +00293                               n_subbufs, 0, &app_rchan_callbacks);
    +00294         
    +00295         if (!chan) {
    +00296                 printk("relay app channel creation failed\n");
    +00297                 if (app.dir)
    +00298                         relayfs_remove_dir(app.dir);
    +00299                 return NULL;
    +00300         }
    +00301 
    +00302         return chan;
    +00303 }
    +00304 
    +00305 /**
    +00306  *      destroy_app_chan - destroys channel /mnt/relay/dirname/filebaseXXX
    +00307  */
    +00308 static void destroy_app_chan(struct rchan *chan)
    +00309 {
    +00310         if (chan)
    +00311                 relay_close(chan);
    +00312         if (app.dir)
    +00313                 relayfs_remove_dir(app.dir);
    +00314 
    +00315         app.chan = NULL;
    +00316         app.dir = NULL;
    +00317 }
    +00318 
    +00319 /* netlink control channel communication with userspace */
    +00320 
    +00321 struct buf_info
    +00322 {
    +00323         int cpu;
    +00324         unsigned produced;
    +00325         unsigned consumed;
    +00326 };
    +00327 
    +00328 struct consumed_info
    +00329 {
    +00330         int cpu;
    +00331         unsigned consumed;
    +00332 };
    +00333 
    +00334 struct channel_create_info
    +00335 {
    +00336         unsigned subbuf_size;
    +00337         unsigned n_subbufs;
    +00338 };
    +00339 
    +00340 /*
    +00341  * send_reply - send reply to userspace over netlink control channel
    +00342  */
    +00343 static int send_reply(int type, void *reply, int len, int pid)
    +00344 {
    +00345         struct sk_buff *skb;
    +00346         struct nlmsghdr *nlh;
    +00347         void *data;
    +00348         int size;
    +00349         int err;
    +00350                 
    +00351         size = NLMSG_SPACE(len);
    +00352         skb = alloc_skb(size, GFP_ATOMIC);
    +00353         if (!skb)
    +00354                 return -1;
    +00355         nlh = NLMSG_PUT(skb, pid, seq++, type, size - sizeof(*nlh));
    +00356         nlh->nlmsg_flags = 0;
    +00357         data = NLMSG_DATA(nlh);
    +00358         memcpy(data, reply, len);
    +00359         err = netlink_unicast(control, skb, pid, MSG_DONTWAIT);
    +00360 
    +00361         return 0;
    +00362 
    +00363 nlmsg_failure:
    +00364         if (skb)
    +00365                 kfree_skb(skb);
    +00366         
    +00367         return -1;
    +00368 }
    +00369 
    +00370 static void handle_buf_info(struct buf_info *in, int pid)
    +00371 {
    +00372         struct buf_info out;
    +00373 
    +00374         if (!app.chan)
    +00375                 return;
    +00376 
    +00377         out.cpu = in->cpu;
    +00378         out.produced = atomic_read(&app.chan->buf[in->cpu]->subbufs_produced);
    +00379         out.consumed = atomic_read(&app.chan->buf[in->cpu]->subbufs_consumed);
    +00380 
    +00381         send_reply(RELAY_APP_BUF_INFO, &out, sizeof(out), pid);
    +00382 }
    +00383 
    +00384 static inline void handle_subbufs_consumed(struct consumed_info *info)
    +00385 {
    +00386         if (!app.chan)
    +00387                 return;
    +00388 
    +00389         relay_subbufs_consumed(app.chan, info->cpu, info->consumed);
    +00390 }
    +00391 
    +00392 static inline void handle_create(struct channel_create_info *info)
    +00393 {
    +00394         destroy_app_chan(app.chan);
    +00395         app.chan = create_app_chan(info->subbuf_size, info->n_subbufs);
    +00396         if(!app.chan)
    +00397                 return;
    +00398         app.mappings = 0;
    +00399 }
    +00400 
    +00401 /*
    +00402  * msg_rcv_skb - dispatch userspace requests from netlink control channel
    +00403  */
    +00404 static void msg_rcv_skb(struct sk_buff *skb)
    +00405 {
    +00406         struct nlmsghdr *nlh = NULL;
    +00407         int pid, flags;
    +00408         int nlmsglen, skblen;
    +00409         void *data;
    +00410         
    +00411         skblen = skb->len;
    +00412         
    +00413         if (skblen < sizeof (*nlh))
    +00414                 return; 
    +00415 
    +00416         nlh = (struct nlmsghdr *)skb->data;
    +00417         nlmsglen = nlh->nlmsg_len;
    +00418         
    +00419         if (nlmsglen < sizeof(*nlh) || skblen < nlmsglen)
    +00420                 return;
    +00421 
    +00422         stpd_pid = pid = nlh->nlmsg_pid;
    +00423         flags = nlh->nlmsg_flags;
    +00424 
    +00425         if (pid <= 0 || !(flags & NLM_F_REQUEST)) {
    +00426                 netlink_ack(skb, nlh, -EINVAL);
    +00427                 return;
    +00428         }
    +00429 
    +00430         if (flags & MSG_TRUNC) {
    +00431                 netlink_ack(skb, nlh, -ECOMM);
    +00432                 return;
    +00433         }
    +00434         
    +00435         data = NLMSG_DATA(nlh);
    +00436 
    +00437         switch (nlh->nlmsg_type) {
    +00438         case RELAY_APP_CHAN_CREATE:
    +00439                 handle_create(data);
    +00440                 break;
    +00441         case RELAY_APP_CHAN_DESTROY:
    +00442                 destroy_app_chan(app.chan);
    +00443                 break;
    +00444         case RELAY_APP_START:
    +00445                 app.logging = 1;
    +00446                 break;
    +00447         case RELAY_APP_STOP:
    +00448                 app.logging = 0;
    +00449                 relay_flush(app.chan);
    +00450                 break;
    +00451         case RELAY_APP_BUF_INFO:
    +00452                 handle_buf_info(data, pid);
    +00453                 break;
    +00454         case RELAY_APP_SUBBUFS_CONSUMED:
    +00455                 handle_subbufs_consumed(data);
    +00456                 break;
    +00457         default:
    +00458                 if (!app.cb || !app.cb->user_command ||
    +00459                     !app.cb->user_command(nlh->nlmsg_type, data))
    +00460                         netlink_ack(skb, nlh, -EINVAL);
    +00461                 return;
    +00462         }
    +00463         
    +00464         if (flags & NLM_F_ACK)
    +00465                 netlink_ack(skb, nlh, 0);
    +00466 }
    +00467 
    +00468 /*
    +00469  * msg_rcv - handle netlink control channel requests
    +00470  */
    +00471 static void msg_rcv(struct sock *sk, int len)
    +00472 {
    +00473         struct sk_buff *skb;
    +00474         
    +00475         while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
    +00476                 msg_rcv_skb(skb);
    +00477                 kfree_skb(skb);
    +00478         }
    +00479 }
    +00480 
    +00481 /*
    +00482  * _init_relay_app - adds netlink 'unit' if other than NETLINK_USERSOCK wanted
    +00483  */
    +00484 static int _init_relay_app(const char *dirname,
    +00485                            const char *file_basename,
    +00486                            struct relay_app_callbacks *callbacks,
    +00487                            int unit)
    +00488 {
    +00489         if (!file_basename)
    +00490                 return -1;
    +00491 
    +00492         if (dirname)
    +00493                 strncpy(app.dirname, dirname, 1024);
    +00494         strncpy(app.file_basename, file_basename, 1024);
    +00495         app.cb = callbacks;
    +00496 
    +00497         control = netlink_kernel_create(unit, msg_rcv);
    +00498         if (!control) {
    +00499                 printk("Couldn't create control channel\n");
    +00500                 return -1;
    +00501         }
    +00502 
    +00503         return 0;
    +00504 }
    +00505 
    +00506 /**
    +00507  *      init_relay_app - initialize /mnt/relay/dirname/file_basenameXXX
    +00508  *      @dirname: the directory to contain relayfs files for this app
    +00509  *      @file_basename: the base filename of the relayfs files for this app
    +00510  *      @callbacks: the relay_app_callbacks implemented for this app
    +00511  *
    +00512  *      Returns 0 on success, -1 otherwise.
    +00513  *
    +00514  *      NOTE: this doesn't create the relayfs files.  That happens via the
    +00515  *      control channel protocol.
    +00516  */
    +00517 static int init_relay_app(const char *dirname,
    +00518                           const char *file_basename,
    +00519                           struct relay_app_callbacks *callbacks)
    +00520 {
    +00521         return _init_relay_app(dirname, file_basename, callbacks, NETLINK_USERSOCK);
    +00522 }
    +00523 
    +00524 /**
    +00525  *      close_relay_app - close netlink socket and destroy channel if it exists
    +00526  *
    +00527  *      Returns 0 on success, -1 otherwise.
    +00528  */
    +00529 static void close_relay_app(void)
    +00530 {
    +00531         if (control)
    +00532                 sock_release(control->sk_socket);
    +00533         destroy_app_chan(app.chan);
    +00534 }
    +
    diff --git a/runtime/docs/html/runtime_8h-source.html b/runtime/docs/html/runtime_8h-source.html index a0f00a36..76c74dec 100644 --- a/runtime/docs/html/runtime_8h-source.html +++ b/runtime/docs/html/runtime_8h-source.html @@ -4,7 +4,7 @@ - +

    runtime.h

    Go to the documentation of this file.
    00001 #ifndef _RUNTIME_H_
     00002 #define _RUNTIME_H_
     00003 /** @file runtime.h
    @@ -28,5 +28,7 @@
     00021 
     00022 #define dbug(args...) ;
     00023 
    -00024 #endif /* _RUNTIME_H_ */
    +00024 #include "print.c"
    +00025 
    +00026 #endif /* _RUNTIME_H_ */
     
    diff --git a/runtime/docs/html/runtime_8h.html b/runtime/docs/html/runtime_8h.html index 450661ad..a11057b4 100644 --- a/runtime/docs/html/runtime_8h.html +++ b/runtime/docs/html/runtime_8h.html @@ -4,7 +4,7 @@ - +

    runtime.h File Reference

    Main include file for runtime functions. More...

    #include <linux/module.h>
    @@ -21,6 +21,7 @@ #include <linux/hardirq.h>
    #include <asm/uaccess.h>
    #include <linux/kallsyms.h>
    +#include "print.c"

    Go to the source code of this file. diff --git a/runtime/docs/html/scbuf_8c-source.html b/runtime/docs/html/scbuf_8c-source.html deleted file mode 100644 index ffdfaac7..00000000 --- a/runtime/docs/html/scbuf_8c-source.html +++ /dev/null @@ -1,103 +0,0 @@ - - -SystemTap: scbuf.c Source File - - - - -

    scbuf.c

    00001 #ifndef _SCBUF_C_ /* -*- linux-c -*- */
    -00002 #define _SCBUF_C_
    -00003 
    -00004 #include <linux/config.h>
    -00005 
    -00006 /** @file scbuf.c
    -00007  * @addtogroup scbuf Scratch Buffer
    -00008  * Scratch Buffer Functions.
    -00009  * The scratch buffer is for collecting output before storing in a map,
    -00010  * printing, etc. This is a per-cpu static buffer.  It is necessary because 
    -00011  * of the limited stack space available in the kernel.
    -00012  * @todo Need careful review of these to insure safety.
    -00013  * @{
    -00014  */
    -00015 
    -00016 /** Maximum size of buffer, not including terminating NULL */
    -00017 #define STP_BUF_LEN 8191
    -00018 
    -00019 /** Scratch buffer for printing, building strings, etc */
    -00020 static char _stp_scbuf[NR_CPUS][STP_BUF_LEN+1];
    -00021 static int _stp_scbuf_len[NR_CPUS];
    -00022 
    -00023 /** Sprint into the scratch buffer.
    -00024  * Like printf, except output goes into a global scratch buffer
    -00025  * which will contain the null-terminated output.
    -00026  * Safe because overflowing the buffer is not allowed.
    -00027  * Size is limited by length of scratch buffer, STP_BUF_LEN.
    -00028  *
    -00029  * @param fmt A printf-style format string followed by a 
    -00030  * variable number of args.
    -00031  * @sa _stp_scbuf_clear
    -00032  */
    -00033 
    -00034 void _stp_sprint (const char *fmt, ...)
    -00035 {
    -00036         int num;
    -00037         va_list args;
    -00038         int cpu = smp_processor_id();
    -00039         char *buf = _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
    -00040         va_start(args, fmt);
    -00041         num = vscnprintf(buf, _stp_scbuf_len[cpu], fmt, args);
    -00042         va_end(args);
    -00043         if (num > 0)
    -00044                 _stp_scbuf_len[cpu] -= num;
    -00045 }
    -00046 
    -00047 /** Write a string into the scratch buffer.
    -00048  * Copies a string into a global scratch buffer.
    -00049  * Safe because overflowing the buffer is not allowed.
    -00050  * Size is limited by length of scratch buffer, STP_BUF_LEN.
    -00051  * This is more efficient than using _stp_sprint().
    -00052  *
    -00053  * @param str A string.
    -00054  */
    -00055 
    -00056 void _stp_sprint_str (const char *str)
    -00057 {
    -00058         int cpu = smp_processor_id();
    -00059         char *buf = _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
    -00060         int num = strlen (str);
    -00061         if (num > _stp_scbuf_len[cpu])
    -00062                 num = _stp_scbuf_len[cpu];
    -00063         strncpy (buf, str, num);
    -00064         _stp_scbuf_len[cpu] -= num;
    -00065 }
    -00066 
    -00067 /** Clear the scratch buffer.
    -00068  * This function should be called before anything is written to 
    -00069  * the scratch buffer.  Output will accumulate in the buffer
    -00070  * until this function is called again.  
    -00071  * @returns A pointer to the buffer.
    -00072  */
    -00073 
    -00074 char *_stp_scbuf_clear (void)
    -00075 {
    -00076         int cpu = smp_processor_id();
    -00077         _stp_scbuf_len[cpu] = STP_BUF_LEN;
    -00078         *_stp_scbuf[cpu] = 0;
    -00079         return _stp_scbuf[cpu];
    -00080 }
    -00081 
    -00082 /** Get the current top of the scratch buffer.
    -00083  * This returns the address of the location where
    -00084  * data will be written next in the scratch buffer.
    -00085  * @returns A pointer
    -00086  */
    -00087 
    -00088 static char *_stp_scbuf_cur (void)
    -00089 {
    -00090         int cpu = smp_processor_id();
    -00091         return _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
    -00092 }
    -00093 
    -00094 /** @} */
    -00095 #endif /* _SCBUF_C_ */
    -
    diff --git a/runtime/docs/html/shellsnoop_2dtr_8c-source.html b/runtime/docs/html/shellsnoop_2dtr_8c-source.html index 7391b8ce..bbc55f7e 100644 --- a/runtime/docs/html/shellsnoop_2dtr_8c-source.html +++ b/runtime/docs/html/shellsnoop_2dtr_8c-source.html @@ -4,91 +4,91 @@ - +

    dtr.c

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

    stack.c

    Go to the documentation of this file.
    00001 #ifndef _STACK_C_
    -00002 #define _STACK_C_
    -00003 /* -*- linux-c -*- */
    +
    +

    stack.c

    Go to the documentation of this file.
    00001 #ifndef _STACK_C_ /* -*- linux-c -*- */
    +00002 #define _STACK_C_
    +00003 
     00004 
     00005 /** @file stack.c
     00006  * @brief Stack Tracing Functions
    @@ -27,148 +27,162 @@
     00020         unsigned long addr;
     00021 
     00022         if (verbose)
    -00023                 _stp_print ("trace for %d (%s)\n", current->pid, current->comm);
    +00023                 _stp_printf ("trace for %d (%s)\n", current->pid, current->comm);
     00024 
     00025         while (((long) stack & (THREAD_SIZE-1)) != 0) {
     00026                 addr = *stack++;
     00027                 if (_stp_kta(addr)) {
    -00028                         if (verbose)
    -00029                                 _stp_symbol_print (addr);
    -00030                         else
    -00031                                 _stp_print ("0x%lx ", addr);
    -00032                 }
    -00033         }
    -00034         _stp_print_str ("\n");
    -00035 }
    -00036 
    +00028                         if (verbose) {
    +00029                                 _stp_symbol_print (addr);
    +00030                                 _stp_print ("\n");
    +00031                         } else
    +00032                                 _stp_printf ("0x%lx ", addr);
    +00033                 }
    +00034         }
    +00035         _stp_print_flush();
    +00036 }
     00037 
    -00038 static char *__stp_stack_sprint (unsigned long *stack, int verbose, int levels)
    -00039 {
    -00040         unsigned long addr;
    -00041         char *ptr = _stp_scbuf_cur();
    +00038 
    +00039 static void __stp_stack_sprint (String str, unsigned long *stack, int verbose, int levels)
    +00040 {
    +00041         unsigned long addr;
     00042         while (((long) stack & (THREAD_SIZE-1)) != 0) {
     00043                 addr = *stack++;
     00044                 if (_stp_kta(addr)) {
     00045                         if (verbose)
    -00046                                 _stp_symbol_sprint (addr);
    +00046                                 _stp_symbol_sprint (str, addr);
     00047                         else
    -00048                                 _stp_sprint ("0x%lx ", addr);
    +00048                                 _stp_sprintf (str, "0x%lx ", addr);
     00049                 }
     00050         }
    -00051         return ptr;
    -00052 }
    -00053 
    -00054 #else  /* i386 */
    -00055 
    -00056 static inline int valid_stack_ptr (struct thread_info *tinfo, void *p)
    -00057 {
    -00058         return  p > (void *)tinfo &&
    -00059                 p < (void *)tinfo + THREAD_SIZE - 3;
    -00060 }
    -00061 
    -00062 static inline unsigned long _stp_print_context_stack (
    -00063         struct thread_info *tinfo,
    -00064         unsigned long *stack, 
    -00065         unsigned long ebp )
    -00066 {
    -00067         unsigned long addr;
    -00068 
    -00069 #ifdef  CONFIG_FRAME_POINTER
    -00070         while (valid_stack_ptr(tinfo, (void *)ebp)) {
    -00071                 addr = *(unsigned long *)(ebp + 4);
    -00072                 _stp_symbol_print (addr);
    -00073                 _stp_print_str("\n");
    -00074                 ebp = *(unsigned long *)ebp;
    -00075         }
    -00076 #else
    -00077         while (valid_stack_ptr(tinfo, stack)) {
    -00078                 addr = *stack++;
    -00079                 if (_stp_kta (addr)) {
    -00080                         _stp_symbol_print (addr);
    -00081                         _stp_print_str ("\n");
    -00082                 }
    -00083         }
    -00084 #endif
    -00085         return ebp;
    +00051 }
    +00052 
    +00053 #else  /* i386 */
    +00054 
    +00055 static inline int valid_stack_ptr (struct thread_info *tinfo, void *p)
    +00056 {
    +00057         return  p > (void *)tinfo &&
    +00058                 p < (void *)tinfo + THREAD_SIZE - 3;
    +00059 }
    +00060 
    +00061 static inline unsigned long _stp_print_context_stack (
    +00062         struct thread_info *tinfo,
    +00063         unsigned long *stack, 
    +00064         unsigned long ebp )
    +00065 {
    +00066         unsigned long addr;
    +00067 
    +00068 #ifdef  CONFIG_FRAME_POINTER
    +00069         while (valid_stack_ptr(tinfo, (void *)ebp)) {
    +00070                 addr = *(unsigned long *)(ebp + 4);
    +00071                 _stp_symbol_print (addr);
    +00072                 _stp_print_cstr("\n");
    +00073                 ebp = *(unsigned long *)ebp;
    +00074         }
    +00075 #else
    +00076         while (valid_stack_ptr(tinfo, stack)) {
    +00077                 addr = *stack++;
    +00078                 if (_stp_kta (addr)) {
    +00079                         _stp_symbol_print (addr);
    +00080                         _stp_print_cstr ("\n");
    +00081                 }
    +00082         }
    +00083 #endif
    +00084         _stp_print_flush();
    +00085         return ebp;
     00086 }
     00087 
     00088 static inline unsigned long _stp_sprint_context_stack (
    -00089         struct thread_info *tinfo,
    -00090         unsigned long *stack, 
    -00091         unsigned long ebp )
    -00092 {
    -00093         unsigned long addr;
    -00094 
    -00095 #ifdef  CONFIG_FRAME_POINTER
    -00096         while (valid_stack_ptr(tinfo, (void *)ebp)) {
    -00097                 addr = *(unsigned long *)(ebp + 4);
    -00098                 _stp_symbol_sprint (addr);
    -00099                 _stp_sprint_str("\n");
    -00100                 ebp = *(unsigned long *)ebp;
    -00101         }
    -00102 #else
    -00103         while (valid_stack_ptr(tinfo, stack)) {
    -00104                 addr = *stack++;
    -00105                 if (_stp_kta (addr)) {
    -00106                         _stp_symbol_sprint (addr);
    -00107                         _stp_sprint_str ("\n");
    -00108                 }
    -00109         }
    -00110 #endif
    -00111         return ebp;
    -00112 }
    -00113 
    -00114 static void __stp_stack_print (unsigned long *stack, int verbose, int levels)
    -00115 {
    -00116         unsigned long ebp;
    -00117 
    -00118         /* Grab ebp right from our regs */
    -00119         asm ("movl %%ebp, %0" : "=r" (ebp) : );
    -00120 
    -00121         while (stack) {
    -00122                 struct thread_info *context = (struct thread_info *)
    -00123                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
    -00124                 ebp = _stp_print_context_stack (context, stack, ebp);
    -00125                 stack = (unsigned long*)context->previous_esp;
    -00126         }
    -00127 }
    -00128 
    -00129 static void __stp_stack_sprint (unsigned long *stack, int verbose, int levels)
    -00130 {
    -00131         unsigned long ebp;
    -00132 
    -00133         /* Grab ebp right from our regs */
    -00134         asm ("movl %%ebp, %0" : "=r" (ebp) : );
    -00135 
    -00136         while (stack) {
    -00137                 struct thread_info *context = (struct thread_info *)
    -00138                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
    -00139                 ebp = _stp_sprint_context_stack (context, stack, ebp);
    -00140                 stack = (unsigned long*)context->previous_esp;
    -00141         }
    -00142 }
    -00143 
    -00144 #endif /* i386 */
    -00145 
    -00146 /** Print stack dump.
    -00147  * Prints a stack dump to the trace buffer.
    -00148  * @param verbose Verbosity:
    -00149  */
    -00150 
    -00151 void _stp_stack_print (int verbose, int levels)
    -00152 {
    -00153   unsigned long stack;
    -00154   return __stp_stack_print (&stack, verbose, levels);
    -00155 }
    -00156 
    -00157 char *_stp_stack_sprint (int verbose, int levels)
    -00158 {
    -00159   unsigned long stack;
    -00160   char *ptr = _stp_scbuf_cur();
    -00161   __stp_stack_sprint (&stack, verbose, levels);
    -00162   return ptr;
    -00163 }
    -00164 
    -00165 /** @} */
    -00166 #endif /* _STACK_C_ */
    +00089         String str,
    +00090         struct thread_info *tinfo,
    +00091         unsigned long *stack, 
    +00092         unsigned long ebp )
    +00093 {
    +00094         unsigned long addr;
    +00095 
    +00096 #ifdef  CONFIG_FRAME_POINTER
    +00097         while (valid_stack_ptr(tinfo, (void *)ebp)) {
    +00098                 addr = *(unsigned long *)(ebp + 4);
    +00099                 _stp_symbol_sprint (str, addr);
    +00100                 _stp_string_cat ("\n");
    +00101                 ebp = *(unsigned long *)ebp;
    +00102         }
    +00103 #else
    +00104         while (valid_stack_ptr(tinfo, stack)) {
    +00105                 addr = *stack++;
    +00106                 if (_stp_kta (addr)) {
    +00107                         _stp_symbol_sprint (addr);
    +00108                         _stp_string_cat ("\n");
    +00109                 }
    +00110         }
    +00111 #endif
    +00112         return ebp;
    +00113 }
    +00114 
    +00115 static void __stp_stack_print (unsigned long *stack, int verbose, int levels)
    +00116 {
    +00117         unsigned long ebp;
    +00118 
    +00119         /* Grab ebp right from our regs */
    +00120         asm ("movl %%ebp, %0" : "=r" (ebp) : );
    +00121 
    +00122         while (stack) {
    +00123                 struct thread_info *context = (struct thread_info *)
    +00124                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
    +00125                 ebp = _stp_print_context_stack (context, stack, ebp);
    +00126                 stack = (unsigned long*)context->previous_esp;
    +00127         }
    +00128 }
    +00129 
    +00130 static void __stp_stack_sprint (String str, unsigned long *stack, int verbose, int levels)
    +00131 {
    +00132         unsigned long ebp;
    +00133 
    +00134         /* Grab ebp right from our regs */
    +00135         asm ("movl %%ebp, %0" : "=r" (ebp) : );
    +00136 
    +00137         while (stack) {
    +00138                 struct thread_info *context = (struct thread_info *)
    +00139                         ((unsigned long)stack & (~(THREAD_SIZE - 1)));
    +00140                 ebp = _stp_sprint_context_stack (str, context, stack, ebp);
    +00141                 stack = (unsigned long*)context->previous_esp;
    +00142         }
    +00143 }
    +00144 
    +00145 #endif /* i386 */
    +00146 
    +00147 /** Print stack dump.
    +00148  * Prints a stack dump to the print buffer.
    +00149  * @param verbose Verbosity
    +00150  * @param levels Number of levels to trace.
    +00151  * @todo Implement verbosity and levels parameters.
    +00152  * @bug levels parameter is not functional
    +00153  */
    +00154 
    +00155 void _stp_stack_print (int verbose, int levels)
    +00156 {
    +00157   unsigned long stack;
    +00158   __stp_stack_print (&stack, verbose, levels);
    +00159 }
    +00160 
    +00161 /** Writes stack dump to a String
    +00162  *
    +00163  * @param str String
    +00164  * @param verbose Verbosity
    +00165  * @param levels Number of levels to trace.
    +00166  * @returns Same String as was input.
    +00167  * @todo Implement verbosity and levels parameters.
    +00168  * @bug levels parameter is not functional
    +00169  */
    +00170 
    +00171 String _stp_stack_sprint (String str, int verbose, int levels)
    +00172 {
    +00173   unsigned long stack;
    +00174   __stp_stack_sprint (str, &stack, verbose, levels);
    +00175   _stp_log ("sss: str=%s\n", str->buf);
    +00176   return str;
    +00177 }
    +00178 
    +00179 /** @} */
    +00180 #endif /* _STACK_C_ */
     
    diff --git a/runtime/docs/html/stack_8c.html b/runtime/docs/html/stack_8c.html index 093cc186..4c769ce8 100644 --- a/runtime/docs/html/stack_8c.html +++ b/runtime/docs/html/stack_8c.html @@ -4,7 +4,7 @@ - +

    stack.c File Reference

    Stack Tracing Functions. More...

    #include "sym.c"
    @@ -16,9 +16,9 @@

    - + +
    void _stp_stack_print (int verbose, int levels)
     Print stack dump.
    -char * _stp_stack_sprint (int verbose, int levels)
    String _stp_stack_sprint (String str, int verbose, int levels)
     Writes stack dump to a String.


    Detailed Description

    Stack Tracing Functions. diff --git a/runtime/docs/html/stp__tasklet_8c-source.html b/runtime/docs/html/stp__tasklet_8c-source.html index 1156b265..16fdfdf7 100644 --- a/runtime/docs/html/stp__tasklet_8c-source.html +++ b/runtime/docs/html/stp__tasklet_8c-source.html @@ -4,7 +4,7 @@ - +

    stp_tasklet.c

    00001 /* Framework for putting a jprobe in a tasklet. */
    @@ -15,44 +15,55 @@
     00006 #define HASH_TABLE_SIZE (1<<HASH_TABLE_BITS)
     00007 #define BUCKETS 16 /* largest histogram width */
     00008 
    -00009 #include "runtime.h"
    -00010 #include "io.c"
    -00011 #include "probes.c"
    -00012 
    -00013 MODULE_DESCRIPTION("test jprobes of tasklets");
    -00014 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
    -00015 
    -00016 void inst__rcu_process_callbacks(struct rcu_ctrlblk *rcp,
    -00017                                  struct rcu_state *rsp, struct rcu_data *rdp)
    -00018 {
    -00019   dlog ("interrupt=%d\n", in_interrupt());
    -00020   jprobe_return();
    -00021 }
    -00022 
    -00023 static struct jprobe stp_probes[] = {
    -00024   {
    -00025     .kp.addr =  (kprobe_opcode_t *)"__rcu_process_callbacks",
    -00026     .entry = (kprobe_opcode_t *) inst__rcu_process_callbacks
    -00027   },
    -00028 };
    -00029 #define MAX_STP_PROBES (sizeof(stp_probes)/sizeof(struct jprobe))
    -00030 
    -00031 
    -00032 static int init_stp(void)
    -00033 {
    -00034   int ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES);
    -00035   dlog("instrumentation is enabled...\n");
    -00036   return ret;
    -00037 }
    -00038 
    -00039 static void cleanup_stp(void)
    -00040 {
    -00041   _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES);
    -00042   dlog ("EXIT\n");
    +00009 #define STP_NETLINK_ONLY
    +00010 #define STP_NUM_STRINGS 1
    +00011 
    +00012 #include "runtime.h"
    +00013 #include "probes.c"
    +00014 
    +00015 MODULE_DESCRIPTION("test jprobes of tasklets");
    +00016 MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");
    +00017 
    +00018 void inst__rcu_process_callbacks(struct rcu_ctrlblk *rcp,
    +00019                                  struct rcu_state *rsp, struct rcu_data *rdp)
    +00020 {
    +00021   _stp_log ("interrupt=%d\n", in_interrupt());
    +00022   jprobe_return();
    +00023 }
    +00024 
    +00025 static struct jprobe stp_probes[] = {
    +00026   {
    +00027     .kp.addr =  (kprobe_opcode_t *)"__rcu_process_callbacks",
    +00028     .entry = (kprobe_opcode_t *) inst__rcu_process_callbacks
    +00029   },
    +00030 };
    +00031 #define MAX_STP_PROBES (sizeof(stp_probes)/sizeof(struct jprobe))
    +00032 
    +00033 
    +00034 static int init_stp(void)
    +00035 {
    +00036   int ret;
    +00037 
    +00038   if (_stp_netlink_open() < 0)
    +00039     return -1;
    +00040   ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES);
    +00041   _stp_log ("instrumentation is enabled...\n");
    +00042   return ret;
     00043 }
     00044 
    -00045 module_init(init_stp);
    -00046 module_exit(cleanup_stp);
    -00047 MODULE_LICENSE("GPL");
    -00048 
    +00045 static void probe_exit (void)
    +00046 {
    +00047   _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES);
    +00048   _stp_log ("EXIT\n");
    +00049 
    +00050 }
    +00051 static void cleanup_stp(void)
    +00052 {
    +00053   _stp_netlink_close();
    +00054 }
    +00055 
    +00056 module_init(init_stp);
    +00057 module_exit(cleanup_stp);
    +00058 MODULE_LICENSE("GPL");
    +00059 
     
    diff --git a/runtime/docs/html/string_8c-source.html b/runtime/docs/html/string_8c-source.html new file mode 100644 index 00000000..462913e3 --- /dev/null +++ b/runtime/docs/html/string_8c-source.html @@ -0,0 +1,170 @@ + + +SystemTap: string.c Source File + + + + +

    string.c

    Go to the documentation of this file.
    00001 #ifndef _STRING_C_ /* -*- linux-c -*- */
    +00002 #define _STRING_C_
    +00003 
    +00004 #include <linux/config.h>
    +00005 
    +00006 /** @file string.c
    +00007  * @brief Implements String type.
    +00008  */
    +00009 /** @addtogroup string String Functions
    +00010  *
    +00011  * One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack.
    +00012  * It is also not a good idea to dynamically allocate space for strings with kmalloc().  That leaves us with 
    +00013  * statically allocated space for strings. This is what is implemented in the String module.  Strings use
    +00014  * preallocated per-cpu buffers and are safe to use (unlike C strings).
    +00015  * @{
    +00016  */
    +00017 
    +00018 /** Maximum string size allowed in Strings */
    +00019 #ifndef STP_STRING_SIZE
    +00020 #define STP_STRING_SIZE 2048
    +00021 #endif
    +00022 
    +00023 struct string {
    +00024         short len;
    +00025         short global;
    +00026         char buf[STP_STRING_SIZE];
    +00027 };
    +00028 
    +00029 static struct string _stp_string[STP_NUM_STRINGS][NR_CPUS];
    +00030 
    +00031 typedef struct string *String;
    +00032 
    +00033 /** Initialize a String for our use.
    +00034  * This grabs one of the global Strings for our use.
    +00035  *
    +00036  * @param num Number of the preallocated String to use. 
    +00037  * #STP_NUM_STRINGS are statically allocated for our use. The
    +00038  * translator (or author) should be sure to grab a free one.
    +00039  * @todo Global (and static) Strings not implemented yet. 
    +00040  */
    +00041 
    +00042 String _stp_string_init (int num)
    +00043 {
    +00044         int global = 0;
    +00045         String str;
    +00046 
    +00047         if (num  < 0) {
    +00048                 num = -num;
    +00049                 global = 1;
    +00050         }
    +00051         
    +00052         if (num >= STP_NUM_STRINGS) {
    +00053                 _stp_log ("_stp_string_init internal error: requested string exceeded allocated number");
    +00054                 return NULL;
    +00055         }
    +00056 
    +00057         if (global)
    +00058                 str = &_stp_string[num][0];
    +00059         else
    +00060                 str = &_stp_string[num][smp_processor_id()];
    +00061 
    +00062         str->global = global;
    +00063         str->len = 0;
    +00064         return str;
    +00065 }
    +00066 
    +00067 
    +00068 /** Sprintf into a String.
    +00069  * Like printf, except output goes into a String.
    +00070  * Safe because overflowing the buffer is not allowed.
    +00071  * Size is limited by length of String, #STP_STRING_SIZE.
    +00072  *
    +00073  * @param str String
    +00074  * @param fmt A printf-style format string followed by a 
    +00075  * variable number of args.
    +00076  */
    +00077 void _stp_sprintf (String str, const char *fmt, ...)
    +00078 {
    +00079         int num;
    +00080         va_list args;
    +00081         va_start(args, fmt);
    +00082         num = vscnprintf(str->buf + str->len, STP_STRING_SIZE - str->len - 1, fmt, args);
    +00083         va_end(args);
    +00084         if (num > 0)
    +00085                 str->len += num;
    +00086 }
    +00087 
    +00088 /** Vsprintf into a String
    +00089  * Use this if your function already has a va_list.
    +00090  * You probably want _stp_sprintf().
    +00091  */
    +00092 void _stp_vsprintf (String str, const char *fmt, va_list args)
    +00093 {
    +00094         int num;
    +00095         num = vscnprintf(str->buf + str->len, STP_STRING_SIZE - str->len - 1, fmt, args);
    +00096         if (num > 0)
    +00097                 str->len += num;
    +00098 }
    +00099 
    +00100 /** ConCATenate (append) a C string to a String.
    +00101  * Like strcat().
    +00102  * @param str1 String
    +00103  * @param str2 C string (char *)
    +00104  * @sa _stp_string_cat
    +00105  */
    +00106 void _stp_string_cat_cstr (String str1, const char *str2)
    +00107 {
    +00108         int num = strlen (str2);
    +00109         if (num > STP_STRING_SIZE - str1->len - 1)
    +00110                 num = STP_STRING_SIZE - str1->len - 1;
    +00111         strncpy (str1->buf + str1->len, str2, num+1);
    +00112         str1->len += num;
    +00113 }
    +00114 
    +00115 /** ConCATenate (append) a String to a String.
    +00116  * Like strcat().
    +00117  * @param str1 String
    +00118  * @param str2 String
    +00119  * @sa _stp_string_cat
    +00120  */
    +00121 void _stp_string_cat_string (String str1, String str2)
    +00122 {
    +00123         int num = str2->len;
    +00124         if (num > STP_STRING_SIZE - str1->len - 1)
    +00125                 num = STP_STRING_SIZE - str1->len - 1;
    +00126         strncpy (str1->buf + str1->len, str2->buf, num);
    +00127         str1->len += num;
    +00128 }
    +00129 
    +00130 /** Get a pointer to String's buffer
    +00131  * For rare cases when a C string is needed and you have a String.
    +00132  * One example is when you want to print a String with _stp_printf().
    +00133  * @param str String
    +00134  * @returns A C string (char *)
    +00135  * @note Readonly. Don't write to this pointer or it will mess up
    +00136  * the internal String state and probably mess up your output or crash something.
    +00137  */
    +00138 char * _stp_string_ptr (String str)
    +00139 {
    +00140         return str->buf;
    +00141 }
    +00142 
    +00143 
    +00144 /** ConCATenate (append) a String or C string to a String.
    +00145  * This macro selects the proper function to call.
    +00146  * @param str1 A String
    +00147  * @param str2 A String or C string (char *)
    +00148  * @sa _stp_string_cat_cstr _stp_string_cat_string
    +00149  */
    +00150 #define _stp_string_cat(str1, str2)                                     \
    +00151   ({                                                            \
    +00152           if (__builtin_types_compatible_p (typeof (str2), char[])) {   \
    +00153                   char *x = (char *)str2;                               \
    +00154                   _str_string_cat_cstr(str1,x);                         \
    +00155           } else {                                                      \
    +00156                   String x = (String)str2;                              \
    +00157                   _str_string_cat_string(str1,x);                       \
    +00158           }                                                             \
    +00159   })
    +00160 
    +00161 /** @} */
    +00162 #endif /* _STRING_C_ */
    +
    diff --git a/runtime/docs/html/string_8c.html b/runtime/docs/html/string_8c.html new file mode 100644 index 00000000..07151c62 --- /dev/null +++ b/runtime/docs/html/string_8c.html @@ -0,0 +1,52 @@ + + +SystemTap: string.c File Reference + + + + +

    string.c File Reference

    Implements String type. More... +

    +#include <linux/config.h>
    + +

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

    Defines

    +#define STP_STRING_SIZE   2048
     Maximum string size allowed in Strings.
    #define _stp_string_cat(str1, str2)
     ConCATenate (append) a String or C string to a String.

    Typedefs

    +typedef string * String

    Functions

    String _stp_string_init (int num)
     Initialize a String for our use.
    void _stp_sprintf (String str, const char *fmt,...)
     Sprintf into a String.
    void _stp_vsprintf (String str, const char *fmt, va_list args)
     Vsprintf into a String Use this if your function already has a va_list.
    void _stp_string_cat_cstr (String str1, const char *str2)
     ConCATenate (append) a C string to a String.
    void _stp_string_cat_string (String str1, String str2)
     ConCATenate (append) a String to a String.
    char * _stp_string_ptr (String str)
     Get a pointer to String's buffer For rare cases when a C string is needed and you have a String.
    +


    Detailed Description

    +Implements String type. +

    + +

    +Definition in file string.c. diff --git a/runtime/docs/html/structmap__node.html b/runtime/docs/html/structmap__node.html deleted file mode 100644 index c4c387ee..00000000 --- a/runtime/docs/html/structmap__node.html +++ /dev/null @@ -1,47 +0,0 @@ - - -SystemTap: map_node Struct Reference - - - -

    -

    map_node Struct Reference
    - -[Maps] -

    basic map element -More... -

    -#include <map.h> -

    - - - - - - - - - - - - - - - - - -

    Data Fields

    -list_head lnode
     list of other nodes in the map
    -hlist_node hnode
     list of nodes with the same hash value
    -key_data key1
    -key_data key2
    -enum keytype key1type
    -enum keytype key2type
    -


    Detailed Description

    -basic map element -

    - -

    -Definition at line 35 of file map.h.


    The documentation for this struct was generated from the following file: - diff --git a/runtime/docs/html/structmap__node__int64.html b/runtime/docs/html/structmap__node__int64.html deleted file mode 100644 index 4a8c3edc..00000000 --- a/runtime/docs/html/structmap__node__int64.html +++ /dev/null @@ -1,33 +0,0 @@ - - -SystemTap: map_node_int64 Struct Reference - - - - -

    map_node_int64 Struct Reference
    - -[Maps] -

    map element containing int64 -More... -

    -#include <map.h> -

    - - - - - - - -

    Data Fields

    -map_node n
    -int64_t val
    -


    Detailed Description

    -map element containing int64 -

    - -

    -Definition at line 47 of file map.h.


    The documentation for this struct was generated from the following file: - diff --git a/runtime/docs/html/structmap__node__stat.html b/runtime/docs/html/structmap__node__stat.html deleted file mode 100644 index fe581573..00000000 --- a/runtime/docs/html/structmap__node__stat.html +++ /dev/null @@ -1,33 +0,0 @@ - - -SystemTap: map_node_stat Struct Reference - - - - -

    map_node_stat Struct Reference
    - -[Maps] -

    map element containing stats -More... -

    -#include <map.h> -

    - - - - - - - -

    Data Fields

    -map_node n
    -stat stats
    -


    Detailed Description

    -map element containing stats -

    - -

    -Definition at line 59 of file map.h.


    The documentation for this struct was generated from the following file: - diff --git a/runtime/docs/html/structmap__node__str.html b/runtime/docs/html/structmap__node__str.html deleted file mode 100644 index fa970680..00000000 --- a/runtime/docs/html/structmap__node__str.html +++ /dev/null @@ -1,33 +0,0 @@ - - -SystemTap: map_node_str Struct Reference - - - - -

    map_node_str Struct Reference
    - -[Maps] -

    map element containing string -More... -

    -#include <map.h> -

    - - - - - - - -

    Data Fields

    -map_node n
    -char * str
    -


    Detailed Description

    -map element containing string -

    - -

    -Definition at line 53 of file map.h.


    The documentation for this struct was generated from the following file: - diff --git a/runtime/docs/html/structmap__root.html b/runtime/docs/html/structmap__root.html deleted file mode 100644 index 2a4eb819..00000000 --- a/runtime/docs/html/structmap__root.html +++ /dev/null @@ -1,170 +0,0 @@ - - -SystemTap: map_root Struct Reference - - - - -

    map_root Struct Reference
    - -[Maps] -

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

    -#include <map.h> -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Data Fields

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


    Detailed Description

    -This structure contains all information about a map. -

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

    - -

    -Definition at line 67 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 93 of file map.h. -

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

    -

    - - - - -
    - - - - -
    void* map_root::membuf
    -
    - - - - - -
    -   - - -

    -pointer to allocated memory space. -

    -Used for freeing memory. -

    -Definition at line 104 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 85 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: - diff --git a/runtime/docs/html/structstat.html b/runtime/docs/html/structstat.html deleted file mode 100644 index 16155517..00000000 --- a/runtime/docs/html/structstat.html +++ /dev/null @@ -1,42 +0,0 @@ - - -SystemTap: stat Struct Reference - - - - -

    stat Struct Reference
    - -[Maps] -

    Statistics are stored in this struct. -More... -

    -#include <map.h> -

    - - - - - - - - - - - - - -

    Data Fields

    -int64_t count
    -int64_t sum
    -int64_t min
    -int64_t max
    -int64_t histogram [BUCKETS]
    -


    Detailed Description

    -Statistics are stored in this struct. -

    - -

    -Definition at line 15 of file map.h.


    The documentation for this struct was generated from the following file: - diff --git a/runtime/docs/html/sym_8c-source.html b/runtime/docs/html/sym_8c-source.html index 2e8ffc8a..8e7f21b8 100644 --- a/runtime/docs/html/sym_8c-source.html +++ b/runtime/docs/html/sym_8c-source.html @@ -4,11 +4,11 @@ - +

    sym.c

    00001 #ifndef _SYM_C_ /* -*- linux-c -*- */
     00002 #define _SYM_C_
     00003 
    -00004 #include "scbuf.c"
    +00004 #include "string.c"
     00005 
     00006 /** @file sym.c
     00007  * @addtogroup sym Symbolic Functions
    @@ -26,48 +26,54 @@
     00019                             unsigned long *offset,
     00020                             char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP;
     00021 
    -00022 static void __stp_symbol_print (unsigned long address, void (*prtfunc)(const char *fmt, ...))
    -00023 {
    -00024         char *modname;
    -00025         const char *name;
    -00026         unsigned long offset, size;
    -00027         char namebuf[KSYM_NAME_LEN+1];
    -00028 
    -00029         name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
    -00030 
    -00031         (*prtfunc)("0x%lx : ", address);
    -00032         if (modname)
    -00033                 (*prtfunc)("%s+%#lx/%#lx [%s]", name, offset, size, modname);
    -00034         else
    -00035                 (*prtfunc)("%s+%#lx/%#lx", name, offset, size);
    -00036 }
    -00037 
    -00038 /** Print addresses symbolically into a string
    -00039  * @param address The address to lookup.
    -00040  * @note Symbolic lookups should not be done within
    -00041  * a probe because it is too time-consuming. Use at module exit time.
    -00042  * @note Uses scbuf.
    -00043  */
    -00044 
    -00045 char * _stp_symbol_sprint (unsigned long address)
    -00046 { 
    -00047         char *ptr = _stp_scbuf_cur();
    -00048         __stp_symbol_print (address, _stp_sprint);
    -00049         return ptr;
    -00050 }
    -00051 
    -00052 
    -00053 /** Print addresses symbolically to the trace buffer.
    -00054  * @param address The address to lookup.
    -00055  * @note Symbolic lookups should not be done within
    -00056  * a probe because it is too time-consuming. Use at module exit time.
    -00057  */
    -00058 
    -00059 void _stp_symbol_print (unsigned long address)
    -00060 {
    -00061         __stp_symbol_print (address, _stp_print);
    -00062 }
    -00063 
    -00064 /** @} */
    -00065 #endif /* _SYM_C_ */
    +00022 
    +00023 /** Write addresses symbolically into a String
    +00024  * @param str String
    +00025  * @param address The address to lookup.
    +00026  * @note Symbolic lookups should not normally be done within
    +00027  * a probe because it is too time-consuming. Use at module exit time.
    +00028  */
    +00029 
    +00030 String _stp_symbol_sprint (String str, unsigned long address)
    +00031 { 
    +00032         char *modname;
    +00033         const char *name;
    +00034         unsigned long offset, size;
    +00035         char namebuf[KSYM_NAME_LEN+1];
    +00036 
    +00037         name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
    +00038 
    +00039         _stp_sprintf (str, "0x%lx : ", address);
    +00040         if (modname)
    +00041                 _stp_sprintf (str, "%s+%#lx/%#lx [%s]", name, offset, size, modname);
    +00042         else
    +00043                 _stp_sprintf (str, "%s+%#lx/%#lx", name, offset, size);
    +00044         return str;
    +00045 }
    +00046 
    +00047 
    +00048 /** Print addresses symbolically to the print buffer.
    +00049  * @param address The address to lookup.
    +00050  * @note Symbolic lookups should not normally be done within
    +00051  * a probe because it is too time-consuming. Use at module exit time.
    +00052  */
    +00053 
    +00054 void _stp_symbol_print (unsigned long address)
    +00055 {
    +00056         char *modname;
    +00057         const char *name;
    +00058         unsigned long offset, size;
    +00059         char namebuf[KSYM_NAME_LEN+1];
    +00060 
    +00061         name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf);
    +00062 
    +00063         _stp_printf ("0x%lx : ", address);
    +00064         if (modname)
    +00065                 _stp_printf ("%s+%#lx/%#lx [%s]", name, offset, size, modname);
    +00066         else
    +00067                 _stp_printf ("%s+%#lx/%#lx", name, offset, size);
    +00068 }
    +00069 
    +00070 /** @} */
    +00071 #endif /* _SYM_C_ */
     
    diff --git a/runtime/docs/html/test4_2dtr_8c-source.html b/runtime/docs/html/test4_2dtr_8c-source.html index af19db1a..c3d65197 100644 --- a/runtime/docs/html/test4_2dtr_8c-source.html +++ b/runtime/docs/html/test4_2dtr_8c-source.html @@ -4,260 +4,149 @@ - +

    dtr.c

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

    Todo List

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

    Todo List

    +
    File TODO
    +
    stpd needs an option to disable ANSI colors.
    +
    +

    +

    +
    File TODO
    +
    stpd needs to be able to write netlink REALTIME_DATA to a file.
    +
    +

    +

    +
    File TODO
    +
    stpd/stp/io.c stpd needs better startup/shutdown integration with io.c in runtime. Shutdown works, but isn't very clean. Currently the stp script loads the module, then starts stpd. Data is lost until stpd is active. Maybe stpd needs to load the module. Maybe it needs to signal the module that stpd is ready and the module can proceed to load the probes.
    +
    +

    +

    +
    File TODO
    +
    stpd/stp - What if there are multiple probes running?
    +
    +

    +

    +
    File TODO
    +
    stpd/stp - Need something to post-process relayfs files and integrate into a single file.
    +
    +

    +

    +
    File TODO
    +
    stpd - Implement command that runtime can send to stpd to tell it to fork a specified program and pass the output from the probe module to it. Create example probe to use it.
    +
    +

    +

    +
    File TODO
    +
    relayfs/build - figure out how to get rid of the linker warnings when building probes.
    +
    +

    +

    +
    File TODO
    +
    runtime - Clean up #defines. Need to have a clearer way to have the probe writer (translator) see which defines affect what and all defines should have reasonable defaults.
    +
    +

    +

    +
    File TODO
    +
    runtime - current.c - implement a memory dump function. Does a hex dump into String or print buffer.
    +
    +

    +

    +
    File TODO
    +
    runtime - put wrappers around current task struct entries, like pid, ppid, comm, etc.
    +
    +

    +

    +
    File TODO
    +
    runtime - Implement stack functions for kprobes (not just jprobes)

    @@ -20,33 +70,38 @@
    Some of these currently use kmalloc (GFP_ATOMIC) for small allocations. This should be evaluated for performance and stability.

    -

    -
    Global _stp_print (const char *fmt,...)
    -
    Needs replaced with something much faster that does not use the system log.
    +
    +
    Global _stp_log (const char *fmt,...)
    +
    Evaluate if this function is necessary.

    -

    -
    Global _stp_print_str (char *str)
    -
    Needs replaced with something much faster that does not use the system log.
    +
    +
    Group maps
    +
    Needs to be made SMP-safe for when the big lock is removed from kprobes.

    -

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

    -

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

    -
    Global _stp_map_stat_add (MAP map, int64_t val)
    -
    Histograms don't work yet.
    +
    Global _stp_stack_print (int verbose, int levels)
    +
    Implement verbosity and levels parameters.

    -
    Group scbuf
    -
    Need careful review of these to insure safety.
    +
    Global _stp_stack_sprint (String str, int verbose, int levels)
    +
    Implement verbosity and levels parameters.
    +
    +

    +

    +
    Global _stp_string_init (int num)
    +
    Global (and static) Strings not implemented yet.
    diff --git a/runtime/docs/html/tree.html b/runtime/docs/html/tree.html deleted file mode 100644 index 1d3f49b0..00000000 --- a/runtime/docs/html/tree.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - TreeView - - - - - - - - diff --git a/runtime/docs/html/unionkey__data.html b/runtime/docs/html/unionkey__data.html deleted file mode 100644 index f6fed5cb..00000000 --- a/runtime/docs/html/unionkey__data.html +++ /dev/null @@ -1,33 +0,0 @@ - - -SystemTap: key_data Union Reference - - - - -

    key_data Union Reference
    - -[Maps] -

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

    -#include <map.h> -

    - - - - - - - -

    Data Fields

    -long val
    -char * str
    -


    Detailed Description

    -Keys are either longs or char *. -

    - -

    -Definition at line 23 of file map.h.


    The documentation for this union was generated from the following file: - diff --git a/runtime/io.c b/runtime/io.c index f5e640e9..0b409ead 100644 --- a/runtime/io.c +++ b/runtime/io.c @@ -12,20 +12,18 @@ * @{ */ +/** private buffer for _stp_log() */ #define STP_LOG_BUF_LEN 2047 static char _stp_lbuf[NR_CPUS][STP_LOG_BUF_LEN + 1]; /** Logs Data. - * This function is compatible with printk. In fact it currently - * sends all output to vprintk, after sending "STP: ". This allows - * us to easily detect SystemTap output in the log file. - * + * This function prints to the system log if stpd has not connected + * yet. Otherwise it sends the message immediately to stpd. * @param fmt A variable number of args. - * @bug Lines are limited in length by printk buffer. If there is + * @note Lines are limited in length by printk buffer. If there is * no newline in the format string, then other syslog output could * get appended to the SystemTap line. - * @todo Either deprecate or redefine this as a way to log debug or - * status messages, separate from the normal program output. + * @todo Evaluate if this function is necessary. */ void _stp_log (const char *fmt, ...) @@ -82,6 +80,10 @@ static struct relay_app_callbacks stp_callbacks = .user_command = stpd_command }; +/** Opens netlink and relayfs connections to stpd. + * This must be called before any I/O is done, probably + * at the start of module initialization. + */ int _stp_netlink_open(void) { if (init_relay_app("stpd", "cpu", &stp_callbacks)) { @@ -90,6 +92,13 @@ int _stp_netlink_open(void) } return 0; } + +/** Closes netlink and relayfs connections to stpd. + * This must be called after all I/O is done, probably + * at the end of module cleanup. + * @returns 0 on success. -1 if there is a problem establishing + * a connection. + */ void _stp_netlink_close (void) { diff --git a/runtime/map.c b/runtime/map.c index 7e5caa49..25ad8620 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -1,7 +1,6 @@ -#ifndef _MAP_C_ +#ifndef _MAP_C_ /* -*- linux-c -*- */ #define _MAP_C_ -/* -*- linux-c -*- */ /** @file map.c * @brief Implements maps (associative arrays) and lists */ @@ -538,6 +537,7 @@ static void __stp_map_set_int64(MAP map, int64_t val, int add) * @param map * @param val new value * @sa _stp_map_add_int64 + * @sa _stp_map_set() */ void _stp_map_set_int64(MAP map, int64_t val) { @@ -576,14 +576,15 @@ int64_t _stp_map_get_int64(MAP map) return m->val; } -/** Set the current element's value to a string. - * This sets the current element's value to an string. The map must have been created +/** Set the current element's value to a C string. + * This sets the current element's value to an C string. The map must have been created * to hold int64s using _stp_map_new(xxx, STRING) * * If the element doesn't exist, it is created. If no current element (key) * is set for the map, this function does nothing. * @param map * @param val new string + * @sa _stp_map_set() */ void _stp_map_set_str(MAP map, char *val) @@ -642,6 +643,17 @@ void _stp_map_set_str(MAP map, char *val) } } +/** Set the current element's value to String. + * This sets the current element's value to a String. The map must have been created + * to hold int64s using _stp_map_new(xxx, STRING) + * + * If the element doesn't exist, it is created. If no current element (key) + * is set for the map, this function does nothing. + * @param map + * @param str String containing new value. + * @sa _stp_map_set() + */ + void _stp_map_set_string (MAP map, String str) { _stp_map_set_str (map, str->buf); @@ -851,9 +863,10 @@ void _stp_list_clear(MAP map) } } -/** Adds a string to a list. +/** Adds a C string to a list. * @param map * @param str + * @sa _stp_list_add() */ inline void _stp_list_add_str(MAP map, char *str) @@ -862,6 +875,12 @@ inline void _stp_list_add_str(MAP map, char *str) _stp_map_set_str(map, str); } +/** Adds a String to a list. + * @param map + * @param str String to add. + * @sa _stp_list_add() + */ + inline void _stp_list_add_string (MAP map, String str) { _stp_map_key_long(map, map->num); @@ -871,6 +890,7 @@ inline void _stp_list_add_string (MAP map, String str) /** Adds an int64 to a list. * @param map * @param val + * @sa _stp_list_add() */ inline void _stp_list_add_int64(MAP map, int64_t val) diff --git a/runtime/map.h b/runtime/map.h index 65ed0674..6b21e299 100644 --- a/runtime/map.h +++ b/runtime/map.h @@ -1,17 +1,17 @@ -#ifndef _MAP_H_ +#ifndef _MAP_H_ /* -*- linux-c -*- */ #define _MAP_H_ -/* -*- linux-c -*- */ /** @file map.h * @brief Header file for maps and lists */ /** @addtogroup maps + * @todo Needs to be made SMP-safe for when the big lock is removed from kprobes. * @{ */ #include -/** Statistics are stored in this struct */ +/* Statistics are stored in this struct */ typedef struct { int64_t count; int64_t sum; @@ -19,7 +19,7 @@ typedef struct { int64_t histogram[BUCKETS]; } stat; -/** Keys are either longs or char * */ +/* Keys are either longs or char * */ union key_data { long val; char *str; @@ -31,11 +31,11 @@ enum keytype { NONE, LONG, STR } __attribute__ ((packed)); enum valtype { INT64, STAT, STRING, END }; -/** basic map element */ +/* basic map element */ struct map_node { - /** list of other nodes in the map */ + /* list of other nodes in the map */ struct list_head lnode; - /** list of nodes with the same hash value */ + /* list of nodes with the same hash value */ struct hlist_node hnode; union key_data key1; union key_data key2; @@ -43,48 +43,48 @@ struct map_node { enum keytype key2type; }; -/** map element containing int64 */ +/* map element containing int64 */ struct map_node_int64 { struct map_node n; int64_t val; }; -/** map element containing string */ +/* map element containing string */ struct map_node_str { struct map_node n; char *str; }; -/** map element containing stats */ +/* map element containing stats */ struct map_node_stat { struct map_node n; stat stats; }; -/** This structure contains all information about a map. +/* This structure contains all information about a map. * It is allocated once when _stp_map_new() is called. */ struct map_root { - /** type of the values stored in the array */ + /* type of the values stored in the array */ enum valtype type; - /** maximum number of elements allowed in the array. */ + /* maximum number of elements allowed in the array. */ int maxnum; - /** current number of used elements */ + /* current number of used elements */ int num; - /** when more than maxnum elements, wrap or discard? */ + /* when more than maxnum elements, wrap or discard? */ int no_wrap; - /** linked list of current entries */ + /* linked list of current entries */ struct list_head head; - /** pool of unused entries. Used only when entries are statically allocated + /* pool of unused entries. Used only when entries are statically allocated at startup. */ struct list_head pool; - /** saved key entry for lookups */ + /* saved key entry for lookups */ struct map_node *key; /** this is the creation data saved between the key functions and the diff --git a/runtime/print.c b/runtime/print.c index 8b0d267d..bb738d14 100644 --- a/runtime/print.c +++ b/runtime/print.c @@ -11,6 +11,10 @@ * The print buffer is for collecting output to send to the user daemon. * This is a per-cpu static buffer. The buffer is sent when * _stp_print_flush() is called. + * + * The reason to do this is to allow multiple small prints to be combined then + * timestamped and sent together to stpd. It could flush automatically on newlines, + * but what about stack traces which span many lines? So try this and see how it works for us. * @{ */ @@ -53,6 +57,11 @@ void _stp_print_flush (void) #define STP_PRINT_BUF_START (TIMESTAMP_SIZE + 1) static char _stp_pbuf[NR_CPUS][STP_PRINT_BUF_LEN + STP_PRINT_BUF_START + 1]; +/** Send the print buffer now. + * Output accumulates in the print buffer until this is called. + * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN. + */ + void _stp_print_flush (void) { int cpu = smp_processor_id(); @@ -77,15 +86,14 @@ void _stp_print_flush (void) } #endif /* STP_NETLINK_ONLY */ -/** Sprint into the scratch buffer. - * Like printf, except output goes into a global scratch buffer - * which will contain the null-terminated output. +/** Print into the print buffer. + * Like printf, except output goes to the print buffer. * Safe because overflowing the buffer is not allowed. - * Size is limited by length of scratch buffer, STP_BUF_LEN. - * + * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN. + * * @param fmt A printf-style format string followed by a * variable number of args. - * @sa _stp_pbuf_clear + * @sa _stp_print_flush() */ void _stp_printf (const char *fmt, ...) @@ -101,6 +109,11 @@ void _stp_printf (const char *fmt, ...) _stp_pbuf_len[cpu] += num; } +/** Print into the print buffer. + * Use this if your function already has a va_list. + * You probably want _stp_printf(). + */ + void _stp_vprintf (const char *fmt, va_list args) { int num; @@ -111,13 +124,15 @@ void _stp_vprintf (const char *fmt, va_list args) _stp_pbuf_len[cpu] += num; } -/** Write a string into the scratch buffer. - * Copies a string into a global scratch buffer. +/** Write a C string into the print buffer. + * Copies a string into a print buffer. * Safe because overflowing the buffer is not allowed. - * Size is limited by length of scratch buffer, STP_BUF_LEN. - * This is more efficient than using _stp_sprint(). + * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN. + * This is more efficient than using _stp_printf() if you don't + * need fancy formatting. * - * @param str A string. + * @param str A C string. + * @sa _stp_print */ void _stp_print_cstr (const char *str) @@ -147,12 +162,29 @@ char *_stp_print_clear (void) #include "string.c" +/** Write a String into the print buffer. + * Copies a String into a print buffer. + * Safe because overflowing the buffer is not allowed. + * Size is limited by length of print buffer, #STP_PRINT_BUF_LEN. + * This is more efficient than using _stp_printf() if you don't + * need fancy formatting. + * + * @param str A String. + * @sa _stp_print + */ + void _stp_print_string (String str) { if (str->len) _stp_print_cstr (str->buf); } +/** Write a String or C string into the print buffer. + * This macro selects the proper function to call. + * @param str A String or C string (char *) + * @sa _stp_print_cstr _stp_print_string + */ + #define _stp_print(str) \ ({ \ if (__builtin_types_compatible_p (typeof (str), char[])) { \ diff --git a/runtime/probes.c b/runtime/probes.c index 62819901..144445d6 100644 --- a/runtime/probes.c +++ b/runtime/probes.c @@ -1,4 +1,6 @@ -/* -*- linux-c -*- */ +#ifndef _PROBES_C_ /* -*- linux-c -*- */ +#define _PROBES_C + /** @file probes.c * @brief Functions to assist loading and unloading groups of probes. */ @@ -100,3 +102,4 @@ out: return ret; } +#endif /* _PROBES_C */ diff --git a/runtime/stack.c b/runtime/stack.c index 758013cb..4aca6c54 100644 --- a/runtime/stack.c +++ b/runtime/stack.c @@ -145,8 +145,11 @@ static void __stp_stack_sprint (String str, unsigned long *stack, int verbose, i #endif /* i386 */ /** Print stack dump. - * Prints a stack dump to the trace buffer. - * @param verbose Verbosity: + * Prints a stack dump to the print buffer. + * @param verbose Verbosity + * @param levels Number of levels to trace. + * @todo Implement verbosity and levels parameters. + * @bug levels parameter is not functional */ void _stp_stack_print (int verbose, int levels) @@ -155,6 +158,16 @@ void _stp_stack_print (int verbose, int levels) __stp_stack_print (&stack, verbose, levels); } +/** Writes stack dump to a String + * + * @param str String + * @param verbose Verbosity + * @param levels Number of levels to trace. + * @returns Same String as was input. + * @todo Implement verbosity and levels parameters. + * @bug levels parameter is not functional + */ + String _stp_stack_sprint (String str, int verbose, int levels) { unsigned long stack; diff --git a/runtime/string.c b/runtime/string.c index a44cabc1..1975b70c 100644 --- a/runtime/string.c +++ b/runtime/string.c @@ -4,15 +4,18 @@ #include /** @file string.c - * @addtogroup scbuf Scratch Buffer - * Scratch Buffer Functions. - * The scratch buffer is for collecting output before storing in a map, - * printing, etc. This is a per-cpu static buffer. It is necessary because - * of the limited stack space available in the kernel. - * @todo Need careful review of these to insure safety. + * @brief Implements String type. + */ +/** @addtogroup string String Functions + * + * One of the biggest restrictions the library has is that it cannot allocate things like strings off the stack. + * It is also not a good idea to dynamically allocate space for strings with kmalloc(). That leaves us with + * statically allocated space for strings. This is what is implemented in the String module. Strings use + * preallocated per-cpu buffers and are safe to use (unlike C strings). * @{ */ +/** Maximum string size allowed in Strings */ #ifndef STP_STRING_SIZE #define STP_STRING_SIZE 2048 #endif @@ -27,6 +30,15 @@ static struct string _stp_string[STP_NUM_STRINGS][NR_CPUS]; typedef struct string *String; +/** Initialize a String for our use. + * This grabs one of the global Strings for our use. + * + * @param num Number of the preallocated String to use. + * #STP_NUM_STRINGS are statically allocated for our use. The + * translator (or author) should be sure to grab a free one. + * @todo Global (and static) Strings not implemented yet. + */ + String _stp_string_init (int num) { int global = 0; @@ -53,17 +65,15 @@ String _stp_string_init (int num) } -/** Sprint into the scratch buffer. - * Like printf, except output goes into a global scratch buffer - * which will contain the null-terminated output. +/** Sprintf into a String. + * Like printf, except output goes into a String. * Safe because overflowing the buffer is not allowed. - * Size is limited by length of scratch buffer, STP_BUF_LEN. + * Size is limited by length of String, #STP_STRING_SIZE. * + * @param str String * @param fmt A printf-style format string followed by a * variable number of args. - * @sa _stp_scbuf_clear */ - void _stp_sprintf (String str, const char *fmt, ...) { int num; @@ -75,6 +85,10 @@ void _stp_sprintf (String str, const char *fmt, ...) str->len += num; } +/** Vsprintf into a String + * Use this if your function already has a va_list. + * You probably want _stp_sprintf(). + */ void _stp_vsprintf (String str, const char *fmt, va_list args) { int num; @@ -83,24 +97,27 @@ void _stp_vsprintf (String str, const char *fmt, va_list args) str->len += num; } -/** Write a string into the scratch buffer. - * Copies a string into a global scratch buffer. - * Safe because overflowing the buffer is not allowed. - * Size is limited by length of scratch buffer, STP_BUF_LEN. - * This is more efficient than using _stp_sprint(). - * - * @param str A string. +/** ConCATenate (append) a C string to a String. + * Like strcat(). + * @param str1 String + * @param str2 C string (char *) + * @sa _stp_string_cat */ - -void _stp_string_cat_cstr (String str, const char *newstr) +void _stp_string_cat_cstr (String str1, const char *str2) { - int num = strlen (newstr); - if (num > STP_STRING_SIZE - str->len - 1) - num = STP_STRING_SIZE - str->len - 1; - strncpy (str->buf + str->len, newstr, num+1); - str->len += num; + int num = strlen (str2); + if (num > STP_STRING_SIZE - str1->len - 1) + num = STP_STRING_SIZE - str1->len - 1; + strncpy (str1->buf + str1->len, str2, num+1); + str1->len += num; } +/** ConCATenate (append) a String to a String. + * Like strcat(). + * @param str1 String + * @param str2 String + * @sa _stp_string_cat + */ void _stp_string_cat_string (String str1, String str2) { int num = str2->len; @@ -110,11 +127,26 @@ void _stp_string_cat_string (String str1, String str2) str1->len += num; } +/** Get a pointer to String's buffer + * For rare cases when a C string is needed and you have a String. + * One example is when you want to print a String with _stp_printf(). + * @param str String + * @returns A C string (char *) + * @note Readonly. Don't write to this pointer or it will mess up + * the internal String state and probably mess up your output or crash something. + */ char * _stp_string_ptr (String str) { return str->buf; } + +/** ConCATenate (append) a String or C string to a String. + * This macro selects the proper function to call. + * @param str1 A String + * @param str2 A String or C string (char *) + * @sa _stp_string_cat_cstr _stp_string_cat_string + */ #define _stp_string_cat(str1, str2) \ ({ \ if (__builtin_types_compatible_p (typeof (str2), char[])) { \ diff --git a/runtime/sym.c b/runtime/sym.c index 85662954..1eec0d1d 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -20,11 +20,11 @@ static const char * (*_stp_kallsyms_lookup)(unsigned long addr, char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP; -/** Print addresses symbolically into a string +/** Write addresses symbolically into a String + * @param str String * @param address The address to lookup. - * @note Symbolic lookups should not be done within + * @note Symbolic lookups should not normally be done within * a probe because it is too time-consuming. Use at module exit time. - * @note Uses scbuf. */ String _stp_symbol_sprint (String str, unsigned long address) @@ -45,9 +45,9 @@ String _stp_symbol_sprint (String str, unsigned long address) } -/** Print addresses symbolically to the trace buffer. +/** Print addresses symbolically to the print buffer. * @param address The address to lookup. - * @note Symbolic lookups should not be done within + * @note Symbolic lookups should not normally be done within * a probe because it is too time-consuming. Use at module exit time. */ -- cgit