From 204b456c7c08bc40ffe1f21575461d92a544e92b Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 9 Mar 2005 21:30:05 +0000 Subject: [PATCH] Initial runtime checkin. --- runtime/Doxyfile | 1161 ++++++++++++++++ runtime/README | 45 + runtime/alloc.h | 71 + runtime/copy.c | 137 ++ runtime/docs/examples/argv.c | 12 + runtime/docs/examples/foreach.c | 9 + runtime/docs/examples/map.c | 7 + runtime/docs/header.html | 7 + runtime/docs/html/MAP-example.html | 17 + runtime/docs/html/README-source.html | 14 + runtime/docs/html/README.html | 18 + runtime/docs/html/alloc_8h-source.html | 53 + runtime/docs/html/alloc_8h.html | 276 ++++ runtime/docs/html/annotated.html | 22 + .../docs/html/argv__example_8c-example.html | 32 + runtime/docs/html/bug.html | 27 + runtime/docs/html/copy_8c-source.html | 111 ++ runtime/docs/html/copy_8c.html | 204 +++ .../html/docs_2argv__example_8c-example.html | 20 + runtime/docs/html/doxygen.css | 271 ++++ runtime/docs/html/doxygen.png | Bin 0 -> 1281 bytes runtime/docs/html/examples.html | 16 + runtime/docs/html/files.html | 22 + runtime/docs/html/foreach_8c-example.html | 28 + runtime/docs/html/ftv2blank.png | Bin 0 -> 174 bytes runtime/docs/html/ftv2doc.png | Bin 0 -> 255 bytes runtime/docs/html/ftv2folderclosed.png | Bin 0 -> 259 bytes runtime/docs/html/ftv2folderopen.png | Bin 0 -> 261 bytes runtime/docs/html/ftv2lastnode.png | Bin 0 -> 233 bytes runtime/docs/html/ftv2link.png | Bin 0 -> 358 bytes runtime/docs/html/ftv2mlastnode.png | Bin 0 -> 160 bytes runtime/docs/html/ftv2mnode.png | Bin 0 -> 194 bytes runtime/docs/html/ftv2node.png | Bin 0 -> 235 bytes runtime/docs/html/ftv2plastnode.png | Bin 0 -> 165 bytes runtime/docs/html/ftv2pnode.png | Bin 0 -> 200 bytes runtime/docs/html/ftv2vertline.png | Bin 0 -> 229 bytes runtime/docs/html/functions.html | 43 + runtime/docs/html/functions_vars.html | 43 + runtime/docs/html/globals.html | 99 ++ runtime/docs/html/globals_defs.html | 28 + runtime/docs/html/globals_enum.html | 21 + runtime/docs/html/globals_eval.html | 27 + runtime/docs/html/globals_func.html | 55 + runtime/docs/html/globals_type.html | 19 + runtime/docs/html/globals_vars.html | 19 + runtime/docs/html/index.html | 40 + runtime/docs/html/io_8c-source.html | 23 + runtime/docs/html/io_8c.html | 75 ++ runtime/docs/html/main.html | 17 + runtime/docs/html/map_8c-source.html | 661 +++++++++ runtime/docs/html/map_8c.html | 1199 +++++++++++++++++ runtime/docs/html/map_8h-source.html | 146 ++ runtime/docs/html/map_8h.html | 535 ++++++++ runtime/docs/html/pages.html | 19 + runtime/docs/html/runtime_8h-source.html | 31 + runtime/docs/html/runtime_8h.html | 67 + runtime/docs/html/structmap__node.html | 138 ++ runtime/docs/html/structmap__node__int64.html | 80 ++ runtime/docs/html/structmap__node__stat.html | 80 ++ runtime/docs/html/structmap__node__str.html | 80 ++ runtime/docs/html/structmap__root.html | 370 +++++ runtime/docs/html/structstat.html | 165 +++ runtime/docs/html/todo.html | 32 + runtime/docs/html/tree.html | 139 ++ runtime/docs/html/unionkey__data.html | 80 ++ runtime/io.c | 19 + runtime/map.c | 830 ++++++++++++ runtime/map.h | 141 ++ runtime/runtime.h | 18 + runtime/tests/Makefile | 3 + runtime/tests/README | 4 + runtime/tests/all.tcl | 11 + runtime/tests/map.test | 385 ++++++ runtime/tests/shellsnoop/Makefile | 9 + runtime/tests/shellsnoop/README | 70 + runtime/tests/shellsnoop/buildit | 1 + runtime/tests/shellsnoop/dtr.c | 130 ++ runtime/tests/test.h | 233 ++++ runtime/tests/test4_probe/Makefile | 9 + runtime/tests/test4_probe/README | 23 + runtime/tests/test4_probe/buildit | 1 + runtime/tests/test4_probe/dtr.c | 108 ++ runtime/tests/testl64.c | 134 ++ runtime/tests/testl64R.c | 50 + runtime/tests/testl64_alloc.c | 139 ++ runtime/tests/testlist.c | 63 + runtime/tests/testll64.c | 111 ++ runtime/tests/testlongstr.c | 120 ++ runtime/tests/teststat.c | 72 + runtime/tests/teststr.c | 117 ++ runtime/tests/teststrlong.c | 114 ++ runtime/tests/teststrstr.c | 103 ++ runtime/tests/teststrstrstr.c | 121 ++ 93 files changed, 10050 insertions(+) create mode 100644 runtime/Doxyfile create mode 100644 runtime/README create mode 100644 runtime/alloc.h create mode 100644 runtime/copy.c create mode 100644 runtime/docs/examples/argv.c create mode 100644 runtime/docs/examples/foreach.c create mode 100644 runtime/docs/examples/map.c create mode 100644 runtime/docs/header.html create mode 100644 runtime/docs/html/MAP-example.html create mode 100644 runtime/docs/html/README-source.html create mode 100644 runtime/docs/html/README.html create mode 100644 runtime/docs/html/alloc_8h-source.html create mode 100644 runtime/docs/html/alloc_8h.html create mode 100644 runtime/docs/html/annotated.html create mode 100644 runtime/docs/html/argv__example_8c-example.html create mode 100644 runtime/docs/html/bug.html create mode 100644 runtime/docs/html/copy_8c-source.html create mode 100644 runtime/docs/html/copy_8c.html create mode 100644 runtime/docs/html/docs_2argv__example_8c-example.html create mode 100644 runtime/docs/html/doxygen.css create mode 100644 runtime/docs/html/doxygen.png create mode 100644 runtime/docs/html/examples.html create mode 100644 runtime/docs/html/files.html create mode 100644 runtime/docs/html/foreach_8c-example.html create mode 100644 runtime/docs/html/ftv2blank.png create mode 100644 runtime/docs/html/ftv2doc.png create mode 100644 runtime/docs/html/ftv2folderclosed.png create mode 100644 runtime/docs/html/ftv2folderopen.png create mode 100644 runtime/docs/html/ftv2lastnode.png create mode 100644 runtime/docs/html/ftv2link.png create mode 100644 runtime/docs/html/ftv2mlastnode.png create mode 100644 runtime/docs/html/ftv2mnode.png create mode 100644 runtime/docs/html/ftv2node.png create mode 100644 runtime/docs/html/ftv2plastnode.png create mode 100644 runtime/docs/html/ftv2pnode.png create mode 100644 runtime/docs/html/ftv2vertline.png create mode 100644 runtime/docs/html/functions.html create mode 100644 runtime/docs/html/functions_vars.html create mode 100644 runtime/docs/html/globals.html create mode 100644 runtime/docs/html/globals_defs.html create mode 100644 runtime/docs/html/globals_enum.html create mode 100644 runtime/docs/html/globals_eval.html create mode 100644 runtime/docs/html/globals_func.html create mode 100644 runtime/docs/html/globals_type.html create mode 100644 runtime/docs/html/globals_vars.html create mode 100644 runtime/docs/html/index.html create mode 100644 runtime/docs/html/io_8c-source.html create mode 100644 runtime/docs/html/io_8c.html create mode 100644 runtime/docs/html/main.html create mode 100644 runtime/docs/html/map_8c-source.html create mode 100644 runtime/docs/html/map_8c.html create mode 100644 runtime/docs/html/map_8h-source.html create mode 100644 runtime/docs/html/map_8h.html create mode 100644 runtime/docs/html/pages.html create mode 100644 runtime/docs/html/runtime_8h-source.html create mode 100644 runtime/docs/html/runtime_8h.html create mode 100644 runtime/docs/html/structmap__node.html create mode 100644 runtime/docs/html/structmap__node__int64.html create mode 100644 runtime/docs/html/structmap__node__stat.html create mode 100644 runtime/docs/html/structmap__node__str.html create mode 100644 runtime/docs/html/structmap__root.html create mode 100644 runtime/docs/html/structstat.html create mode 100644 runtime/docs/html/todo.html create mode 100644 runtime/docs/html/tree.html create mode 100644 runtime/docs/html/unionkey__data.html create mode 100644 runtime/io.c create mode 100644 runtime/map.c create mode 100644 runtime/map.h create mode 100644 runtime/runtime.h create mode 100644 runtime/tests/Makefile create mode 100644 runtime/tests/README create mode 100644 runtime/tests/all.tcl create mode 100644 runtime/tests/map.test create mode 100644 runtime/tests/shellsnoop/Makefile create mode 100644 runtime/tests/shellsnoop/README create mode 100644 runtime/tests/shellsnoop/buildit create mode 100644 runtime/tests/shellsnoop/dtr.c create mode 100644 runtime/tests/test.h create mode 100644 runtime/tests/test4_probe/Makefile create mode 100644 runtime/tests/test4_probe/README create mode 100644 runtime/tests/test4_probe/buildit create mode 100644 runtime/tests/test4_probe/dtr.c create mode 100644 runtime/tests/testl64.c create mode 100644 runtime/tests/testl64R.c create mode 100644 runtime/tests/testl64_alloc.c create mode 100644 runtime/tests/testlist.c create mode 100644 runtime/tests/testll64.c create mode 100644 runtime/tests/testlongstr.c create mode 100644 runtime/tests/teststat.c create mode 100644 runtime/tests/teststr.c create mode 100644 runtime/tests/teststrlong.c create mode 100644 runtime/tests/teststrstr.c create mode 100644 runtime/tests/teststrstrstr.c diff --git a/runtime/Doxyfile b/runtime/Doxyfile new file mode 100644 index 000000000..050d44499 --- /dev/null +++ b/runtime/Doxyfile @@ -0,0 +1,1161 @@ +# Doxyfile 1.3.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = SystemTap + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 0.1 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of source +# files, where putting all generated files in the same directory would otherwise +# cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, +# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, +# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, +# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, +# Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is used +# as the annotated text. Otherwise, the brief description is used as-is. If left +# blank, the following values are used ("$name" is automatically replaced with the +# name of the entity): "The $name class" "The $name widget" "The $name file" +# "is" "provides" "specifies" "contains" "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited +# members of a class in the documentation of that class as if those members were +# ordinary class members. Constructors, destructors and assignment operators of +# the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = NO + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. + +SHOW_DIRECTORIES = YES + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.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 + +# 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. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# 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 = + +# 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. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = docs/examples + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = docs/header.html + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = YES + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse the +# parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = NO + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or +# super classes. Setting the tag to NO turns the diagrams off. Note that this +# option is superseded by the HAVE_DOT option below. This is only a fallback. It is +# recommended to install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found on the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes that +# lay further from the root node will be omitted. Note that setting this option to +# 1 or 2 may greatly reduce the computation time needed for large code bases. Also +# note that a graph may be further truncated if the graph's image dimensions are +# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). +# If 0 is used for the depth value (the default), the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/runtime/README b/runtime/README new file mode 100644 index 000000000..d71466556 --- /dev/null +++ b/runtime/README @@ -0,0 +1,45 @@ +/** @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 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. + * + * A list is a special map which has internally ascending long integer keys. Adding a value to + * a list does not require setting a key first. See _stp_list_add_str() and _stp_list_add_int64(). + * + * @section status_sec 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. + * + * Working sample probe code using the runtime is in tests/test4_probe and tests/shellprobe. + * + * @todo The Runtime Library is not actually a library yet. It is just a collection of functions + * included in the probe boilerplate. + * + */ diff --git a/runtime/alloc.h b/runtime/alloc.h new file mode 100644 index 000000000..13bd6766e --- /dev/null +++ b/runtime/alloc.h @@ -0,0 +1,71 @@ +enum errorcode { ERR_NONE=0, ERR_NO_MEM }; +enum errorcode _stp_error = ERR_NONE; + +/** Allocates memory within a probe. + * This is used for small allocations from within a running + * probe where the process cannot sleep. + * @param len Number of bytes to allocate. + * @return a valid pointer on success or NULL on failure. + * @bug Currently uses kmalloc (GFP_ATOMIC). + */ + +inline void *_stp_alloc(size_t len) +{ + void *ptr = kmalloc(len, GFP_ATOMIC); + if (ptr == NULL) + _stp_error = ERR_NO_MEM; + return ptr; +} + +/** Allocates and clears memory within a probe. + * This is used for small allocations from within a running + * probe where the process cannot sleep. + * @param len Number of bytes to allocate. + * @return a valid pointer on success or NULL on failure. + * @bug Currently uses kmalloc (GFP_ATOMIC). + */ + +inline void *_stp_calloc(size_t len) +{ + void *ptr = _stp_alloc(len); + if (ptr) + memset(ptr, 0, len); + return ptr; +} + +/** Allocates and clears memory outside a probe. + * This is typically used in the module initialization to + * allocate new maps, lists, etc. + * @param len Number of bytes to allocate. + * @return a valid pointer on success or NULL on failure. + */ + +inline void *_stp_valloc(size_t len) +{ + void *ptr = vmalloc(len); + if (ptr) + memset(ptr, 0, len); + else + _stp_error = ERR_NO_MEM; + return ptr; +} + +/** Frees memory allocated by _stp_alloc or _stp_calloc. + * @param ptr pointer to memory to free + */ + +inline void _stp_free(void *ptr) +{ + if (ptr) + kfree(ptr); +} + +/** Frees memory allocated by _stp_valloc. + * @param ptr pointer to memory to free + */ + +inline void _stp_vfree(void *ptr) +{ + if (ptr) + vfree(ptr); +} diff --git a/runtime/copy.c b/runtime/copy.c new file mode 100644 index 000000000..28880c089 --- /dev/null +++ b/runtime/copy.c @@ -0,0 +1,137 @@ +long _stp_strncpy_from_user(char *dst, const char __user *src, long count); +//static long __stp_strncpy_from_user(char *dst, const char __user *src, long count); + +#if defined (__i386__) +#define __stp_strncpy_from_user(dst,src,count,res) \ +do { \ + int __d0, __d1, __d2; \ + __asm__ __volatile__( \ + " testl %1,%1\n" \ + " jz 2f\n" \ + "0: lodsb\n" \ + " stosb\n" \ + " testb %%al,%%al\n" \ + " jz 1f\n" \ + " decl %1\n" \ + " jnz 0b\n" \ + "1: subl %1,%0\n" \ + "2:\n" \ + ".section .fixup,\"ax\"\n" \ + "3: movl %5,%0\n" \ + " jmp 2b\n" \ + ".previous\n" \ + ".section __ex_table,\"a\"\n" \ + " .align 4\n" \ + " .long 0b,3b\n" \ + ".previous" \ + : "=d"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1), \ + "=&D" (__d2) \ + : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ + : "memory"); \ +} while (0) +#elif defined (__x86_64__) +#define __stp_strncpy_from_user(dst,src,count,res) \ +do { \ + long __d0, __d1, __d2; \ + __asm__ __volatile__( \ + " testq %1,%1\n" \ + " jz 2f\n" \ + "0: lodsb\n" \ + " stosb\n" \ + " testb %%al,%%al\n" \ + " jz 1f\n" \ + " decq %1\n" \ + " jnz 0b\n" \ + "1: subq %1,%0\n" \ + "2:\n" \ + ".section .fixup,\"ax\"\n" \ + "3: movq %5,%0\n" \ + " jmp 2b\n" \ + ".previous\n" \ + ".section __ex_table,\"a\"\n" \ + " .align 8\n" \ + " .quad 0b,3b\n" \ + ".previous" \ + : "=r"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1), \ + "=&D" (__d2) \ + : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \ + : "memory"); \ +} while (0) +#endif + +/** Copy a NULL-terminated string from userspace. + * On success, returns the length of the string (not including the trailing + * NULL). + * + * If access to userspace fails, returns -EFAULT (some data may have been + * copied). + * @param dst Destination address, in kernel space. This buffer must be at + * least count bytes long. + * @param src Source address, in user space. + * @param 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. + */ + + +long +_stp_strncpy_from_user(char *dst, const char __user *src, long count) +{ + long res; + __stp_strncpy_from_user(dst, src, count, res); + return res; +} + +/** Copy a block of data from user space. + * + * If some data could not be copied, this function will pad the copied + * data to the requested size using zero bytes. + + * @param dst Destination address, in kernel space. + * @param src Source address, in user space. + * @param count Number of bytes to copy. + * @return number of bytes that could not be copied. On success, + * this will be zero. + * + */ + +unsigned long inline +_stp_copy_from_user (char *dst, const char __user *src, unsigned long count) +{ + return __copy_from_user_inatomic(dst, src, count); +} + +/** Copy an argv from user space to a List. + * + * @param list A list. + * @param argv Source argv, in user space. + * @return number of elements in list + * + * @b Example: + * @include argv.c + */ + +int _stp_copy_argv_from_user (MAP list, char __user *__user *argv) +{ + char str[128]; + char __user *vstr; + int len; + + if (argv) + argv++; + + while (argv != NULL) { + if (get_user (vstr, argv)) + break; + + if (vstr == NULL) + break; + + len = _stp_strncpy_from_user(str, vstr, 128); + str[len] = 0; + _stp_list_add_str (list, str); + argv++; + } + return list->num; +} diff --git a/runtime/docs/examples/argv.c b/runtime/docs/examples/argv.c new file mode 100644 index 000000000..5200c350a --- /dev/null +++ b/runtime/docs/examples/argv.c @@ -0,0 +1,12 @@ +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"); +} diff --git a/runtime/docs/examples/foreach.c b/runtime/docs/examples/foreach.c new file mode 100644 index 000000000..fc1106743 --- /dev/null +++ b/runtime/docs/examples/foreach.c @@ -0,0 +1,9 @@ +/* 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); + diff --git a/runtime/docs/examples/map.c b/runtime/docs/examples/map.c new file mode 100644 index 000000000..ca661d054 --- /dev/null +++ b/runtime/docs/examples/map.c @@ -0,0 +1,7 @@ + +/* 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); diff --git a/runtime/docs/header.html b/runtime/docs/header.html new file mode 100644 index 000000000..f47a1c4f1 --- /dev/null +++ b/runtime/docs/header.html @@ -0,0 +1,7 @@ + + +SystemTap: SystemTap Runtime Library + + + + diff --git a/runtime/docs/html/MAP-example.html b/runtime/docs/html/MAP-example.html new file mode 100644 index 000000000..45e6a3c3b --- /dev/null +++ b/runtime/docs/html/MAP-example.html @@ -0,0 +1,17 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

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 new file mode 100644 index 000000000..2b8a1dfd8 --- /dev/null +++ b/runtime/docs/html/README-source.html @@ -0,0 +1,14 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

README

Go to the documentation of this file.
00001 
+

Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/README.html b/runtime/docs/html/README.html new file mode 100644 index 000000000..0da9fbaf6 --- /dev/null +++ b/runtime/docs/html/README.html @@ -0,0 +1,18 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

README File Reference

+

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


Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/alloc_8h-source.html b/runtime/docs/html/alloc_8h-source.html new file mode 100644 index 000000000..ba908655e --- /dev/null +++ b/runtime/docs/html/alloc_8h-source.html @@ -0,0 +1,53 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

alloc.h

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

Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/alloc_8h.html b/runtime/docs/html/alloc_8h.html new file mode 100644 index 000000000..6a5db5ab2 --- /dev/null +++ b/runtime/docs/html/alloc_8h.html @@ -0,0 +1,276 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

alloc.h File Reference

+

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


Enumeration Type Documentation

+

+ + + + +
+ + + + +
enum errorcode
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + +
ERR_NONE  +
ERR_NO_MEM  +
+
+ +

+Definition at line 1 of file alloc.h.

+


Function Documentation

+

+ + + + +
+ + + + + + + + + +
void* _stp_alloc size_t  len  )  [inline]
+
+ + + + + +
+   + + +

+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 12 of file alloc.h. +

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

+

+ + + + +
+ + + + + + + + + +
void* _stp_calloc size_t  len  )  [inline]
+
+ + + + + +
+   + + +

+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 28 of file alloc.h. +

+References _stp_alloc(). +

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

+

+ + + + +
+ + + + + + + + + +
void _stp_free void *  ptr  )  [inline]
+
+ + + + + +
+   + + +

+Frees memory allocated by _stp_alloc or _stp_calloc. +

+

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

+Definition at line 57 of file alloc.h. +

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

+

+ + + + +
+ + + + + + + + + +
void* _stp_valloc size_t  len  )  [inline]
+
+ + + + + +
+   + + +

+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 43 of file alloc.h. +

+Referenced by _stp_map_new().

+

+ + + + +
+ + + + + + + + + +
void _stp_vfree void *  ptr  )  [inline]
+
+ + + + + +
+   + + +

+Frees memory allocated by _stp_valloc. +

+

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

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

+Referenced by _stp_map_del().

+


Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/annotated.html b/runtime/docs/html/annotated.html new file mode 100644 index 000000000..77bc2e381 --- /dev/null +++ b/runtime/docs/html/annotated.html @@ -0,0 +1,22 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

SystemTap Data Structures

Here are the data structures with brief descriptions: + + + + + + + +
key_data
map_node
map_node_int64
map_node_stat
map_node_str
map_root
stat
+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/argv__example_8c-example.html b/runtime/docs/html/argv__example_8c-example.html new file mode 100644 index 000000000..1369c4c2b --- /dev/null +++ b/runtime/docs/html/argv__example_8c-example.html @@ -0,0 +1,32 @@ + + +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 new file mode 100644 index 000000000..a2be5f086 --- /dev/null +++ b/runtime/docs/html/bug.html @@ -0,0 +1,27 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

Bug List

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

+

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

+

+
Global dlog (const char *fmt,...)
+
Lines are limited in length by printk buffer.
+
+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/copy_8c-source.html b/runtime/docs/html/copy_8c-source.html new file mode 100644 index 000000000..2e21314cd --- /dev/null +++ b/runtime/docs/html/copy_8c-source.html @@ -0,0 +1,111 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

copy.c

Go to the documentation of this file.
00001 long _stp_strncpy_from_user(char *dst, const char __user *src, long count);
+00002 //static long __stp_strncpy_from_user(char *dst, const char __user *src, long count);
+00003 
+00004 #if defined (__i386__)
+00005 #define __stp_strncpy_from_user(dst,src,count,res)                         \
+00006 do {                                                                       \
+00007         int __d0, __d1, __d2;                                              \
+00008         __asm__ __volatile__(                                              \
+00009                 "       testl %1,%1\n"                                     \
+00010                 "       jz 2f\n"                                           \
+00011                 "0:     lodsb\n"                                           \
+00012                 "       stosb\n"                                           \
+00013                 "       testb %%al,%%al\n"                                 \
+00014                 "       jz 1f\n"                                           \
+00015                 "       decl %1\n"                                         \
+00016                 "       jnz 0b\n"                                          \
+00017                 "1:     subl %1,%0\n"                                      \
+00018                 "2:\n"                                                     \
+00019                 ".section .fixup,\"ax\"\n"                                 \
+00020                 "3:     movl %5,%0\n"                                      \
+00021                 "       jmp 2b\n"                                          \
+00022                 ".previous\n"                                              \
+00023                 ".section __ex_table,\"a\"\n"                              \
+00024                 "       .align 4\n"                                        \
+00025                 "       .long 0b,3b\n"                                     \
+00026                 ".previous"                                                \
+00027                 : "=d"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1),      \
+00028                   "=&D" (__d2)                                             \
+00029                 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
+00030                 : "memory");                                               \
+00031 } while (0)
+00032 #elif defined (__x86_64__)
+00033 #define __stp_strncpy_from_user(dst,src,count,res)                         \
+00034 do {                                                                       \
+00035         long __d0, __d1, __d2;                                             \
+00036         __asm__ __volatile__(                                              \
+00037                 "       testq %1,%1\n"                                     \
+00038                 "       jz 2f\n"                                           \
+00039                 "0:     lodsb\n"                                           \
+00040                 "       stosb\n"                                           \
+00041                 "       testb %%al,%%al\n"                                 \
+00042                 "       jz 1f\n"                                           \
+00043                 "       decq %1\n"                                         \
+00044                 "       jnz 0b\n"                                          \
+00045                 "1:     subq %1,%0\n"                                      \
+00046                 "2:\n"                                                     \
+00047                 ".section .fixup,\"ax\"\n"                                 \
+00048                 "3:     movq %5,%0\n"                                      \
+00049                 "       jmp 2b\n"                                          \
+00050                 ".previous\n"                                              \
+00051                 ".section __ex_table,\"a\"\n"                              \
+00052                 "       .align 8\n"                                        \
+00053                 "       .quad 0b,3b\n"                                     \
+00054                 ".previous"                                                \
+00055                 : "=r"(res), "=c"(count), "=&a" (__d0), "=&S" (__d1),      \
+00056                   "=&D" (__d2)                                             \
+00057                 : "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
+00058                 : "memory");                                               \
+00059 } while (0)
+00060 #endif
+00061 
+00078 long
+00079 _stp_strncpy_from_user(char *dst, const char __user *src, long count)
+00080 {
+00081         long res;
+00082         __stp_strncpy_from_user(dst, src, count, res);
+00083         return res;
+00084 }
+00085 
+00099 unsigned long inline
+00100 _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
+00101 {
+00102         return __copy_from_user_inatomic(dst, src, count);
+00103 }
+00104 
+00115 int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
+00116 {
+00117         char str[128];
+00118         char __user *vstr;
+00119         int len;
+00120 
+00121         if (argv)
+00122                 argv++;
+00123 
+00124         while (argv != NULL) {
+00125                 if (get_user (vstr, argv))
+00126                         break;
+00127 
+00128                 if (vstr == NULL)
+00129                         break;
+00130                 
+00131                 len = _stp_strncpy_from_user(str, vstr, 128);
+00132                 str[len] = 0;
+00133                 _stp_list_add_str (list, str);
+00134                 argv++;
+00135         }
+00136         return list->num;
+00137 }
+

Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/copy_8c.html b/runtime/docs/html/copy_8c.html new file mode 100644 index 000000000..0febb9ab4 --- /dev/null +++ b/runtime/docs/html/copy_8c.html @@ -0,0 +1,204 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

copy.c File Reference

+

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

Functions

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


Function Documentation

+

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

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

+

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

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

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

+

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

+Copy a block of data from user space. +

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

+

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

+Definition at line 100 of file copy.c.

+

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

+Copy a NULL-terminated string from userspace. +

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

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

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

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

+Referenced by _stp_copy_argv_from_user().

+


Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/docs_2argv__example_8c-example.html b/runtime/docs/html/docs_2argv__example_8c-example.html new file mode 100644 index 000000000..0ad61d6dc --- /dev/null +++ b/runtime/docs/html/docs_2argv__example_8c-example.html @@ -0,0 +1,20 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

docs/argv_example.c

Parameters:
+ + + +
list A list.
argv Source argv, in user space.
+
+
Returns:
number of elements in list
+

Generated on Wed Mar 9 03:35:02 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/doxygen.css b/runtime/docs/html/doxygen.css new file mode 100644 index 000000000..1d4d63117 --- /dev/null +++ b/runtime/docs/html/doxygen.css @@ -0,0 +1,271 @@ +BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { + font-family: Geneva, Arial, Helvetica, sans-serif; +} +H1 { + text-align: center; +} +CAPTION { font-weight: bold } +DIV.qindex { + width: 100%; + background-color: #eeeeff; + border: 1px solid #b0b0b0; + text-align: center; + margin: 2px; + padding: 2px; + line-height: 140%; +} +DIV.nav { + width: 100%; + background-color: #eeeeff; + border: 1px solid #b0b0b0; + text-align: center; + margin: 2px; + padding: 2px; + line-height: 140%; +} +A.qindex { + text-decoration: none; + font-weight: bold; + color: #1A419D; +} +A.qindex:visited { + text-decoration: none; + font-weight: bold; + color: #1A419D +} +A.qindex:hover { + text-decoration: none; + background-color: #ddddff; +} +A.qindexHL { + text-decoration: none; + font-weight: bold; + background-color: #6666cc; + color: #ffffff; + border: 1px double #9295C2; +} +A.qindexHL:hover { + text-decoration: none; + background-color: #6666cc; + color: #ffffff; +} +A.qindexHL:visited { text-decoration: none; background-color: #6666cc; color: #ffffff } +A.el { text-decoration: none; font-weight: bold } +A.elRef { font-weight: bold } +A.code:link { text-decoration: none; font-weight: normal; color: #0000FF} +A.code:visited { text-decoration: none; font-weight: normal; color: #0000FF} +A.codeRef:link { font-weight: normal; color: #0000FF} +A.codeRef:visited { font-weight: normal; color: #0000FF} +A:hover { text-decoration: none; background-color: #f2f2ff } +DL.el { margin-left: -1cm } +.fragment { + font-family: monospace +} +PRE.fragment { + border: 1px solid #CCCCCC; + background-color: #f5f5f5; + margin-top: 4px; + margin-bottom: 4px; + margin-left: 2px; + margin-right: 8px; + padding-left: 6px; + padding-right: 6px; + padding-top: 4px; + padding-bottom: 4px; +} +DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } +TD.md { background-color: #F4F4FB; font-weight: bold; } +TD.mdname1 { background-color: #F4F4FB; font-weight: bold; color: #602020; } +TD.mdname { background-color: #F4F4FB; font-weight: bold; color: #602020; width: 600px; } +DIV.groupHeader { + margin-left: 16px; + margin-top: 12px; + margin-bottom: 6px; + font-weight: bold; +} +DIV.groupText { margin-left: 16px; font-style: italic; font-size: 14px } +BODY { + background: white; + color: black; + margin-right: 20px; + margin-left: 20px; +} +TD.indexkey { + background-color: #eeeeff; + font-weight: bold; + padding-right : 10px; + padding-top : 2px; + padding-left : 10px; + padding-bottom : 2px; + margin-left : 0px; + margin-right : 0px; + margin-top : 2px; + margin-bottom : 2px; + border: 1px solid #CCCCCC; +} +TD.indexvalue { + background-color: #eeeeff; + font-style: italic; + padding-right : 10px; + padding-top : 2px; + padding-left : 10px; + padding-bottom : 2px; + margin-left : 0px; + margin-right : 0px; + margin-top : 2px; + margin-bottom : 2px; + border: 1px solid #CCCCCC; +} +TR.memlist { + background-color: #f0f0f0; +} +P.formulaDsp { text-align: center; } +IMG.formulaDsp { } +IMG.formulaInl { vertical-align: middle; } +SPAN.keyword { color: #008000 } +SPAN.keywordtype { color: #604020 } +SPAN.keywordflow { color: #e08000 } +SPAN.comment { color: #800000 } +SPAN.preprocessor { color: #806020 } +SPAN.stringliteral { color: #002080 } +SPAN.charliteral { color: #008080 } +.mdTable { + border: 1px solid #868686; + background-color: #F4F4FB; +} +.mdRow { + padding: 8px 10px; +} +.mdescLeft { + padding: 0px 8px 4px 8px; + font-size: 12px; + font-style: italic; + background-color: #FAFAFA; + border-top: 1px none #E0E0E0; + border-right: 1px none #E0E0E0; + border-bottom: 1px none #E0E0E0; + border-left: 1px none #E0E0E0; + margin: 0px; +} +.mdescRight { + padding: 0px 8px 4px 8px; + font-size: 12px; + font-style: italic; + background-color: #FAFAFA; + border-top: 1px none #E0E0E0; + border-right: 1px none #E0E0E0; + border-bottom: 1px none #E0E0E0; + border-left: 1px none #E0E0E0; + margin: 0px; +} +.memItemLeft { + padding: 1px 0px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: solid; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 12px; +} +.memItemRight { + padding: 1px 8px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: solid; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 13px; +} +.memTemplItemLeft { + padding: 1px 0px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: none; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 12px; +} +.memTemplItemRight { + padding: 1px 8px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: none; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + background-color: #FAFAFA; + font-size: 13px; +} +.memTemplParams { + padding: 1px 0px 0px 8px; + margin: 4px; + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-color: #E0E0E0; + border-right-color: #E0E0E0; + border-bottom-color: #E0E0E0; + border-left-color: #E0E0E0; + border-top-style: solid; + border-right-style: none; + border-bottom-style: none; + border-left-style: none; + color: #606060; + background-color: #FAFAFA; + font-size: 12px; +} +.search { color: #003399; + font-weight: bold; +} +FORM.search { + margin-bottom: 0px; + margin-top: 0px; +} +INPUT.search { font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #eeeeff; +} +TD.tiny { font-size: 75%; +} +a { + color: #252E78; +} +a:visited { + color: #3D2185; +} diff --git a/runtime/docs/html/doxygen.png b/runtime/docs/html/doxygen.png new file mode 100644 index 0000000000000000000000000000000000000000..f0a274bbaffdd67f6d784c894d9cf28729db0e14 GIT binary patch literal 1281 zcmaJ>ZA?>F7(Vx-ms?uoS`b@hdRtpo6o^%HU>M$hfGrBvQnk$LE?p^P!kn&ikhyq! zX~V@&tPF5Qt@V?oTL96Bi%aRiwbe1)9DWQI#?)=HxS7QSw`J`5fAJ*eJbB;uNuKA& zdERDo*{Y<(If(#(B$Lr#;nB(8Y#ia=ZCeW?JfPLuQY`=@cW$k}Rivq|vbxGrRq1Tl9;+(gNt?}UtVKM2`T5t1jLzuL@0UIs`S#vlhl4)^ zLgSYrPj@$+`|j?eSbXTmiHGkWxV8V}BzNR?pl9k_s4pDu9vd5a_UzZEPk)}Ad{AV_ zzddrjrh4=Imr`E06;LY{)YYt?o}L~H@7C}F^WB!Ra=v`Q0bj{>5&$66CWF>mf6vjP z2N>RRY6ZYa=K`76>+|_)Xdwko+7wv}7cN|btOhWb(*{sta~6b?S8Omrxw}!4`NhGr zZVpNqpu1@BE`QGWNTpEpcJVW5izu~2B^GlM?1(OPg)zwW;QcP@Ltcclm>XbJL9C|j z=9!2?ua=uIlf0%AndzHsRC}IyTL$EhAee(fdKB`?27KeS^2M8M_7b~PiCFO&r5LC7 z7gl1*a<8;SjNaw#h=843_AV9iZbWQOAp5YOC^&_F*9K0> zB|6%IDb?aM#3viTxkLU4aXg&@+CkNTOnQ1iMP*^?b|^lJy$4C)Zk4isV!|RZ*XhXh zw8q3$=*0LeGC!XI_Wc?dkT~3+*Gu%%yIqP+Wr3H$=&ROMQU6q}Ag^P~>c5vAEO;a- z_dK-3PPeKar%)6$j~vI2#*-YH!1h6HYVtwCX5_wM`iF#UKz&&@9Oo5w3%XGYrX zW>dY~)SG-((Yim%`InwgTvyRC?e=Wh^8KCao!R6Eg&TpVWUY1sN~4G}V?nFnEGo-; zHZ_$eW9-GnC%^WS9b z@p;-$oH#MtC0v>Q$HX%4^JdFdO$0cbv-W)Q TtK}Eh@>>I#ipmV1>S*>q-hkC} literal 0 HcmV?d00001 diff --git a/runtime/docs/html/examples.html b/runtime/docs/html/examples.html new file mode 100644 index 000000000..cd53f4174 --- /dev/null +++ b/runtime/docs/html/examples.html @@ -0,0 +1,16 @@ + + +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 new file mode 100644 index 000000000..599ee02da --- /dev/null +++ b/runtime/docs/html/files.html @@ -0,0 +1,22 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

SystemTap File List

Here is a list of all files with brief descriptions: + + + + + + + +
alloc.h [code]
copy.c [code]
io.c [code]
map.c [code]
map.h [code]
README [code]
runtime.h [code]
+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/foreach_8c-example.html b/runtime/docs/html/foreach_8c-example.html new file mode 100644 index 000000000..ccafaeeb8 --- /dev/null +++ b/runtime/docs/html/foreach_8c-example.html @@ -0,0 +1,28 @@ + + +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 new file mode 100644 index 0000000000000000000000000000000000000000..493c3c0b615ade5b22027bde773faf2c0e076d66 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr2qYM%T@!Q%(o7{me!&ckj8p!u14)&*MwA5S zr6z#mEsk^N1FBF3sc_EE%}vcKVF=AhO-xa6_jFST&P^;T z2~I3aEm8;rVk12R#UIz>f`J-DJY5_^DsClP9B62eH+WF*G=YJMp~A-KbWwke5Kx}M M)78&qol`;+0EL(^EC2ui literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2doc.png b/runtime/docs/html/ftv2doc.png new file mode 100644 index 0000000000000000000000000000000000000000..f72999f92172cca6edaa2538286b3e369bec9f49 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^5yjnX4egh%q=bp-`Pe zR7&bp17l3gfhmh7Fm(iZ2eAfco|q!h5)>qKG?UBh!IC9QGMbJAHf6IEiufk_g|d7~ qkWqJ4k(|I-Aeo-5U~n{Fnc?dN!3Uwu?t6hQVDNPHb6Mw<&;$TLIZ`G7 literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2folderclosed.png b/runtime/docs/html/ftv2folderclosed.png new file mode 100644 index 0000000000000000000000000000000000000000..d6d063440cbf13c4128dacd96661b6fce58abf26 GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^55uo^`BphW;jCHO69?}tw{JfcdnZ<*@N=4I z?xF5Qc|QYEmKAIZ;JRGVHe=bn*tx1_|J^^vyg*oVM#A1kZlFULJYD@<);T3K0RTgB BWg7qh literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2folderopen.png b/runtime/docs/html/ftv2folderopen.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe2c913cf493ee37ad8e3a5132382138d93ac92 GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^5u(C zYP)Mg%H-DB+{J~>rPn_#pYTax?r*V6ubqGX{lvROQ{?n5_cbm+cQAOm`njxgN@xNA D92;js literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2lastnode.png b/runtime/docs/html/ftv2lastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..e7b9ba90cb0cf71c8ce662956bfee7d64cf60fa6 GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6UZ?L@CkAK|NlRbNhD}!Xpp$P zU;Pg)ksC(lf|p%(p+w2Gk+!>EaktaVt4N i!r*{E4>QXNV>t$uAA#a^n)TVt_DW*G8-srQl%FeIsRSdYm zeDdtWec}u&7@8h5rqv#p7g*pRdwwmugmlS-+cHV~j}#7`Nwj9m+AU)JGGo`8z_}`K z?s#Xsy%Z;1_jl5Y+?Gum8WyK6`MBvup0SAOKJ)mWcHyteJ?WLL>>-)=?&<$H&t5oH Vd!azZ1yDdSc)I$ztaD0e0sw}(dc*(# literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2mlastnode.png b/runtime/docs/html/ftv2mlastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..09ceb6adb01054ce799ad20c0e818ab9272f2df2 GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr#LU3Jc=+&fg$isFPOjJ*AaIJQGm()YSDb0rfjgNefXW#>UHx3vIVCg! E0ORy6RsaA1 literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2mnode.png b/runtime/docs/html/ftv2mnode.png new file mode 100644 index 0000000000000000000000000000000000000000..3254c05112199fbc80aad313611c58a5b388792d GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6Ub2s@Ck7}aNq!ti3c<^Gz9OH zn+a6GSQ6wH%;50sMjDVKR^l2_5}cn_Ql40p%8;I!W>k=uu3)5RqGz-?&YcgaLd(;| zF{I*Fa>4?=2W(CyOv{5p*uLi}G<-ambjQcb>&~4!CzK3KXWY6d$*{eWU47N}X+XCz OFnGH9xvXPg)ksC(lf|p%(p+w2Gk+y>EaktaVt4N l!r*{E4>Lv;t literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2plastnode.png b/runtime/docs/html/ftv2plastnode.png new file mode 100644 index 0000000000000000000000000000000000000000..0b07e00913d8069ebbb51bd7fd6d70d8bba88f75 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr#LU3Jc=+&MJ literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2pnode.png b/runtime/docs/html/ftv2pnode.png new file mode 100644 index 0000000000000000000000000000000000000000..2001b797ba2b98a4127f1d3efca64aef08bf6d51 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6Ub2s@Ck7}aNq!ti3c<^Gz9OH zn+a6GSQ6wH%;50sMjDVKR^l2_5}cn_Ql40p%8;I!W>k=uu3)5RqGz-?&Ycga!obtT zF{I*Fa>4?=2W(Dkd1@Anj~<0|oqBMOmqox%*rjK-r)THv+0v0L%h-agt(X~hWwYzA SIxU|Ma*U^|pUXO@geCywmoZiV literal 0 HcmV?d00001 diff --git a/runtime/docs/html/ftv2vertline.png b/runtime/docs/html/ftv2vertline.png new file mode 100644 index 0000000000000000000000000000000000000000..b330f3a33c0085c183ff39fc56b1b274160c1da0 GIT binary patch literal 229 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRr!py+H=+kU?6UZ?L@CkAK|NlRbNhD}!Xpp$P zU;Pg)ksC(lf|p%(p+w2Gqgt>EaktaVt4N e!r*{^G#i7W2*a|cHZQDzQVgE1elF{r5}E+)J2fZ( literal 0 HcmV?d00001 diff --git a/runtime/docs/html/functions.html b/runtime/docs/html/functions.html new file mode 100644 index 000000000..60b6cf164 --- /dev/null +++ b/runtime/docs/html/functions.html @@ -0,0 +1,43 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + + +

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

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/functions_vars.html b/runtime/docs/html/functions_vars.html new file mode 100644 index 000000000..aa0ebe5a6 --- /dev/null +++ b/runtime/docs/html/functions_vars.html @@ -0,0 +1,43 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + + +

+

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/globals.html b/runtime/docs/html/globals.html new file mode 100644 index 000000000..9c4c693fd --- /dev/null +++ b/runtime/docs/html/globals.html @@ -0,0 +1,99 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + +
_ | d | e | f | i | k | l | m | n | p | s | v
+ +

+ +

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

- _ -

+

- d -

+

- e -

+

- f -

+

- i -

+

- k -

+

- l -

+

- m -

+

- n -

+

- p -

+

- s -

+

- v -

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/globals_defs.html b/runtime/docs/html/globals_defs.html new file mode 100644 index 000000000..ed1d24244 --- /dev/null +++ b/runtime/docs/html/globals_defs.html @@ -0,0 +1,28 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + + +

+

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/globals_enum.html b/runtime/docs/html/globals_enum.html new file mode 100644 index 000000000..f12861a2a --- /dev/null +++ b/runtime/docs/html/globals_enum.html @@ -0,0 +1,21 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + + +

+

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/globals_eval.html b/runtime/docs/html/globals_eval.html new file mode 100644 index 000000000..f697e2e02 --- /dev/null +++ b/runtime/docs/html/globals_eval.html @@ -0,0 +1,27 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + + +

+

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/globals_func.html b/runtime/docs/html/globals_func.html new file mode 100644 index 000000000..3ef3fd400 --- /dev/null +++ b/runtime/docs/html/globals_func.html @@ -0,0 +1,55 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + +
_ | d
+ +

+ +

+

- _ -

    +
  • _stp_alloc() +: alloc.h
  • _stp_calloc() +: alloc.h
  • _stp_copy_argv_from_user() +: copy.c
  • _stp_copy_from_user() +: copy.c
  • _stp_free() +: alloc.h
  • _stp_list_add_int64() +: map.c
  • _stp_list_add_str() +: map.c
  • _stp_list_clear() +: map.c
  • _stp_list_new() +: map.c
  • _stp_list_size() +: map.c
  • _stp_map_del() +: map.c
  • _stp_map_get_int64() +: map.c
  • _stp_map_get_stat() +: map.c
  • _stp_map_get_str() +: map.c
  • _stp_map_iter() +: map.c
  • _stp_map_key_del() +: map.c
  • _stp_map_key_long() +: map.c
  • _stp_map_key_long_long() +: map.c
  • _stp_map_key_long_str() +: map.c
  • _stp_map_key_str() +: map.c
  • _stp_map_key_str_long() +: map.c
  • _stp_map_key_str_str() +: map.c
  • _stp_map_new() +: map.c
  • _stp_map_set_int64() +: map.c
  • _stp_map_set_stat() +: map.c
  • _stp_map_set_str() +: map.c
  • _stp_map_start() +: map.c
  • _stp_map_stat_add() +: map.c
  • _stp_strncpy_from_user() +: copy.c
  • _stp_valloc() +: alloc.h
  • _stp_vfree() +: alloc.h
+

- d -

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/globals_type.html b/runtime/docs/html/globals_type.html new file mode 100644 index 000000000..194983d0a --- /dev/null +++ b/runtime/docs/html/globals_type.html @@ -0,0 +1,19 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + + +

+

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/globals_vars.html b/runtime/docs/html/globals_vars.html new file mode 100644 index 000000000..f0282f637 --- /dev/null +++ b/runtime/docs/html/globals_vars.html @@ -0,0 +1,19 @@ + + +SystemTap: SystemTap Runtime Library + + + + + + + +

+

+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/index.html b/runtime/docs/html/index.html new file mode 100644 index 000000000..3796e861f --- /dev/null +++ b/runtime/docs/html/index.html @@ -0,0 +1,40 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

SystemTap Runtime Library

+

+

0.1

+Introduction

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

+Design

+

+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);
+
+/* mymap[birth year] = 2000 */
+map_key_str (mymap, "birth year");
+map_set_int64 (mymap, 2000);  
+

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

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

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

+Working sample probe code using the runtime is in tests/test4_probe and tests/shellprobe.

+

Todo:
The Runtime Library is not actually a library yet. It is just a collection of functions included in the probe boilerplate.
+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/io_8c-source.html b/runtime/docs/html/io_8c-source.html new file mode 100644 index 000000000..5a5c1fe39 --- /dev/null +++ b/runtime/docs/html/io_8c-source.html @@ -0,0 +1,23 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

io.c

Go to the documentation of this file.
00001 
+00011 void dlog (const char *fmt, ...)
+00012 {
+00013   va_list args;
+00014   printk("STP: ");
+00015   va_start(args, fmt);
+00016   vprintk(fmt, args);
+00017   va_end(args);
+00018 }
+00019 
+

Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/io_8c.html b/runtime/docs/html/io_8c.html new file mode 100644 index 000000000..1419497c2 --- /dev/null +++ b/runtime/docs/html/io_8c.html @@ -0,0 +1,75 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

io.c File Reference

+

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

Functions

void dlog (const char *fmt,...)
 Logs data.
+


Function Documentation

+

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

+Logs data. +

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

+

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

+

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

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

+Referenced by _stp_list_clear().

+


Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/main.html b/runtime/docs/html/main.html new file mode 100644 index 000000000..59ec4e754 --- /dev/null +++ b/runtime/docs/html/main.html @@ -0,0 +1,17 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

SystemTap Runtime Library

+

+

0.1

+Introduction

+The SystemTap Runtime Library consists of all functions and code fragments needed by the compiler/translator to include in building a kernel module using kprobes.
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 new file mode 100644 index 000000000..301087fbb --- /dev/null +++ b/runtime/docs/html/map_8c-source.html @@ -0,0 +1,661 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map.c

Go to the documentation of this file.
00001 /* -*- linux-c -*- */
+00002 
+00003 static int map_sizes[] = {
+00004         sizeof(struct map_node_int64),
+00005         sizeof(struct map_node_stat),
+00006         sizeof(struct map_node_str),
+00007         0
+00008 };
+00009 
+00010 static inline unsigned string_hash(const char *key1, const char *key2)
+00011 {
+00012         int hash = 0, count = 0;
+00013         char *v1 = (char *)key1;
+00014         char *v2 = (char *)key2;
+00015         while (*v1 && count++ < 5) {
+00016                 hash += *v1++;
+00017         }
+00018         while (v2 && *v2 && count++ < 5) {
+00019                 hash += *v2++;
+00020         }
+00021         return hash_long((unsigned long)hash, HASH_TABLE_BITS);
+00022 }
+00023 
+00024 static inline unsigned mixed_hash(const char *key1, long key2)
+00025 {
+00026         int hash = 0, count = 0;
+00027         char *v = (char *)key1;
+00028         while (v && *v && count++ < 5)
+00029                 hash += *v++;
+00030         return hash_long((unsigned long)(hash ^ key2), HASH_TABLE_BITS);
+00031 }
+00032 
+00043 MAP _stp_map_new(unsigned max_entries, enum valtype type)
+00044 {
+00045         size_t size;
+00046         MAP m = (MAP) _stp_valloc(sizeof(struct map_root));
+00047         if (m == NULL)
+00048                 return NULL;
+00049 
+00050         INIT_LIST_HEAD(&m->head);
+00051 
+00052         m->maxnum = max_entries;
+00053         m->type = type;
+00054         if (type >= END) {
+00055                 dbug ("map_new: unknown type %d\n", type);
+00056                 return NULL;
+00057         }
+00058 
+00059         if (max_entries) {
+00060                 void *tmp;
+00061                 int i;
+00062                 struct list_head *e;
+00063 
+00064                 INIT_LIST_HEAD(&m->pool);
+00065                 size = map_sizes[type];
+00066                 tmp = _stp_valloc(max_entries * size);
+00067 
+00068                 for (i = max_entries - 1; i >= 0; i--) {
+00069                         e = i * size + tmp;
+00070                         dbug ("e=%lx\n", (long)e);
+00071                         list_add(e, &m->pool);
+00072                 }
+00073                 m->membuf = tmp;
+00074         }
+00075         return m;
+00076 }
+00077 
+00078 static void map_free_strings(MAP map, struct map_node *n)
+00079 {
+00080         struct map_node_str *m = (struct map_node_str *)n;
+00081         dbug ("n = %lx\n", (long)n);
+00082         if (map->type == STRING) {
+00083                 dbug ("val STRING %lx\n", (long)m->str);
+00084                 if (m->str)
+00085                         _stp_free(m->str);
+00086         }
+00087         if (m->n.key1type == STR) {
+00088                 dbug ("key1 STR %lx\n", (long)key1str(m));
+00089                 if (key1str(m))
+00090                         _stp_free(key1str(m));
+00091         }
+00092         if (m->n.key2type == STR) {
+00093                 dbug ("key2 STR %lx\n", (long)key2str(m));
+00094                 if (key2str(m))
+00095                         _stp_free(key2str(m));
+00096         }
+00097 }
+00098 
+00104 void _stp_map_key_del(MAP map)
+00105 {
+00106         struct map_node *m;
+00107 
+00108         dbug ("create=%d key=%lx\n", map->create, (long)map->key);
+00109         if (map == NULL)
+00110                 return;
+00111 
+00112         if (map->create) {
+00113                 map->create = 0;
+00114                 map->key = NULL;
+00115                 return;
+00116         }
+00117 
+00118         if (map->key == NULL)
+00119                 return;
+00120 
+00121         m = (struct map_node *)map->key;
+00122 
+00123         /* remove node from old hash list */
+00124         hlist_del_init(&m->hnode);
+00125 
+00126         /* remove from entry list */
+00127         list_del(&m->lnode);
+00128 
+00129         /* remove any allocated string storage */
+00130         map_free_strings(map, (struct map_node *)map->key);
+00131 
+00132         if (map->maxnum)
+00133                 list_add(&m->lnode, &map->pool);
+00134         else
+00135                 _stp_free(m);
+00136 
+00137         map->key = NULL;
+00138         map->num--;
+00139 }
+00140 
+00149 struct map_node *_stp_map_start(MAP map)
+00150 {
+00151         if (map == NULL)
+00152                 return NULL;
+00153 
+00154         dbug ("%lx\n", (long)map->head.next);
+00155 
+00156         if (list_empty(&map->head))
+00157                 return NULL;
+00158 
+00159         return (struct map_node *)map->head.next;
+00160 }
+00161 
+00172 struct map_node *_stp_map_iter(MAP map, struct map_node *m)
+00173 {
+00174         if (map == NULL)
+00175                 return NULL;
+00176 
+00177         dbug ("%lx next=%lx  prev=%lx  map->head.next=%lx\n", (long)m, (long)m->lnode.next, (long)m->lnode.prev, (long)map->head.next);
+00178 
+00179         if (m->lnode.next == &map->head)
+00180                 return NULL;
+00181 
+00182         return (struct map_node *)m->lnode.next;
+00183 }
+00184 
+00190 void _stp_map_del(MAP map)
+00191 {
+00192         if (map == NULL)
+00193                 return;
+00194 
+00195         if (!list_empty(&map->head)) {
+00196                 struct map_node *ptr = (struct map_node *)map->head.next;
+00197                 while (ptr && ptr != (struct map_node *)&map->head) {
+00198                         map_free_strings(map, ptr);
+00199                         ptr = (struct map_node *)ptr->lnode.next;
+00200                 }
+00201         }
+00202         _stp_vfree(map->membuf);
+00203         _stp_vfree(map);
+00204 }
+00205 
+00206 /**********************  KEY FUNCTIONS *********************/
+00207 
+00208 
+00218 void _stp_map_key_long_long(MAP map, long key1, long key2)
+00219 {
+00220         unsigned hv;
+00221         struct hlist_head *head;
+00222         struct hlist_node *e;
+00223 
+00224         if (map == NULL)
+00225                 return;
+00226 
+00227         hv = hash_long(key1 ^ key2, HASH_TABLE_BITS);
+00228         head = &map->hashes[hv];
+00229 
+00230         dbug ("hash for %ld,%ld is %d\n", key1, key2, hv);
+00231 
+00232         hlist_for_each(e, head) {
+00233                 struct map_node *n =
+00234                         (struct map_node *)((long)e - sizeof(struct hlist_node));
+00235                 dbug ("n =%lx  key=%ld,%ld\n", (long)n, n->key1.val, n->key2.val);
+00236                 if (key1 == n->key1.val && key2 == n->key2.val) {
+00237                         map->key = n;
+00238                         dbug ("saving key %lx\n", (long)map->key);
+00239                         map->create = 0;
+00240                         return;
+00241                 }
+00242         }
+00243 
+00244         map->c_key1.val = key1;
+00245         map->c_key2.val = key2;
+00246         map->c_key1type = LONG;
+00247         map->c_key2type = LONG;
+00248         map->c_keyhead = head;
+00249         map->create = 1;
+00250 }
+00251 
+00261 void _stp_map_key_str_str(MAP map, char *key1, char *key2)
+00262 {
+00263         unsigned hv;
+00264         struct hlist_head *head;
+00265         struct hlist_node *e;
+00266 
+00267         if (map == NULL)
+00268                 return;
+00269 
+00270         if (key1 == NULL) {
+00271                 map->key = NULL;
+00272                 return;
+00273         }
+00274 
+00275         hv = string_hash(key1, key2);
+00276         head = &map->hashes[hv];
+00277 
+00278         dbug ("hash for %s,%s is %d\n", key1, key2, hv);
+00279 
+00280         hlist_for_each(e, head) {
+00281                 struct map_node *n =
+00282                         (struct map_node *)((long)e - sizeof(struct hlist_node));
+00283                 dbug ("e =%lx  key=%s,%s\n", (long)e, n->key1.str,n->key2.str);
+00284                 if (strcmp(key1, n->key1.str) == 0
+00285                     && (key2 == NULL || strcmp(key2, n->key2.str) == 0)) {
+00286                         map->key = n;
+00287                         dbug ("saving key %lx\n", (long)map->key);
+00288                         map->create = 0;
+00289                         return;
+00290                 }
+00291         }
+00292 
+00293         map->c_key1.str = key1;
+00294         map->c_key2.str = key2;
+00295         map->c_key1type = STR;
+00296         map->c_key2type = STR;
+00297         map->c_keyhead = head;
+00298         map->create = 1;
+00299 }
+00300 
+00310 void _stp_map_key_str_long(MAP map, char *key1, long key2)
+00311 {
+00312         unsigned hv;
+00313         struct hlist_head *head;
+00314         struct hlist_node *e;
+00315 
+00316         if (map == NULL)
+00317                 return;
+00318 
+00319         if (key1 == NULL) {
+00320                 map->key = NULL;
+00321                 return;
+00322         }
+00323 
+00324         hv = mixed_hash(key1, key2);
+00325         head = &map->hashes[hv];
+00326 
+00327         dbug ("hash for %s,%ld is %d\n", key1, key2, hv);
+00328 
+00329         hlist_for_each(e, head) {
+00330                 struct map_node *n =
+00331                         (struct map_node *)((long)e - sizeof(struct hlist_node));
+00332                 dbug ("e =%lx  key=%s,%ld\n", (long)e, n->key1.str,(long)n->key2.val);
+00333                 if (strcmp(key1, n->key1.str) == 0 && key2 == n->key2.val) {
+00334                         map->key = n;
+00335                         dbug ("saving key %lx\n", (long)map->key);
+00336                         map->create = 0;
+00337                         return;
+00338                 }
+00339         }
+00340 
+00341         map->c_key1.str = key1;
+00342         map->c_key2.val = key2;
+00343         map->c_key1type = STR;
+00344         map->c_key2type = LONG;
+00345         map->c_keyhead = head;
+00346         map->create = 1;
+00347 }
+00348 
+00358 void _stp_map_key_long_str(MAP map, long key1, char *key2)
+00359 {
+00360         unsigned hv;
+00361         struct hlist_head *head;
+00362         struct hlist_node *e;
+00363 
+00364         if (map == NULL)
+00365                 return;
+00366 
+00367         hv = mixed_hash(key2, key1);
+00368         head = &map->hashes[hv];
+00369         dbug ("hash for %ld,%s is %d\n", key1, key2, hv);
+00370 
+00371         hlist_for_each(e, head) {
+00372                 struct map_node *n =
+00373                         (struct map_node *)((long)e - sizeof(struct hlist_node));
+00374                 dbug ("e =%lx  key=%ld,%s\n", (long)e, n->key1.val,n->key2.str);
+00375                 if (key1 == n->key1.val && strcmp(key2, n->key2.str) == 0) {
+00376                         map->key = n;
+00377                         dbug ("saving key %lx\n", (long)map->key);
+00378                         map->create = 0;
+00379                         return;
+00380                 }
+00381         }
+00382 
+00383         map->c_key1.val = key1;
+00384         map->c_key2.str = key2;
+00385         map->c_key1type = LONG;
+00386         map->c_key2type = STR;
+00387         map->c_keyhead = head;
+00388         map->create = 1;
+00389 }
+00390 
+00399 void _stp_map_key_str(MAP map, char *key)
+00400 {
+00401         if (map == NULL)
+00402                 return;
+00403         _stp_map_key_str_str(map, key, NULL);
+00404         map->c_key2type = NONE;
+00405 }
+00406 
+00415 void _stp_map_key_long(MAP map, long key)
+00416 {
+00417         if (map == NULL)
+00418                 return;
+00419         _stp_map_key_long_long(map, key, 0);
+00420         map->c_key2type = NONE;
+00421 }
+00422 
+00423 /**********************  SET/GET VALUES *********************/
+00424 
+00425 static void map_copy_keys(MAP map, struct map_node *m)
+00426 {
+00427         m->key1type = map->c_key1type;
+00428         m->key2type = map->c_key2type;
+00429         switch (map->c_key1type) {
+00430         case STR:
+00431                 m->key1.str = _stp_alloc(strlen(map->c_key1.str) + 1);
+00432                 strcpy(m->key1.str, map->c_key1.str);
+00433                 break;
+00434         case LONG:
+00435                 m->key1.val = map->c_key1.val;
+00436                 break;
+00437         case NONE:
+00438                 /* ERROR */
+00439                 break;
+00440         }
+00441         switch (map->c_key2type) {
+00442         case STR:
+00443                 m->key2.str = _stp_alloc(strlen(map->c_key2.str) + 1);
+00444                 strcpy(m->key2.str, map->c_key2.str);
+00445                 break;
+00446         case LONG:
+00447                 m->key2.val = map->c_key2.val;
+00448                 break;
+00449         case NONE:
+00450                 break;
+00451         }
+00452 
+00453         /* add node to new hash list */
+00454         hlist_add_head(&m->hnode, map->c_keyhead);
+00455         
+00456         map->key = m;
+00457         map->create = 0;
+00458         map->num++;
+00459 }
+00460 
+00471 void _stp_map_set_int64(MAP map, int64_t val)
+00472 {
+00473         struct map_node_int64 *m;
+00474 
+00475         if (map == NULL)
+00476                 return;
+00477 
+00478         if (map->create) {
+00479                 if (val == 0)
+00480                         return;
+00481 
+00482                 if (map->maxnum) {
+00483                         if (list_empty(&map->pool)) {
+00484                                 if (map->no_wrap) {
+00485                                         /* ERROR. FIXME */
+00486                                         return;
+00487                                 }
+00488                                 m = (struct map_node_int64 *)map->head.next;
+00489                                 hlist_del_init(&m->n.hnode);
+00490                                 map_free_strings(map, (struct map_node *)m);
+00491                                 dbug ("got %lx off head\n", (long)m);
+00492                         } else {
+00493                                 m = (struct map_node_int64 *)map->pool.next;
+00494                                 dbug ("got %lx off pool\n", (long)m);
+00495                         }
+00496                         list_move_tail(&m->n.lnode, &map->head);
+00497                 } else {
+00498                         m = (struct map_node_int64 *)
+00499                             _stp_calloc(sizeof(struct map_node_int64));
+00500                         /* add node to list */
+00501                         list_add_tail(&m->n.lnode, &map->head);
+00502                 }
+00503 
+00504                 /* copy the key(s) */
+00505                 map_copy_keys(map, &m->n);
+00506 
+00507                 /* set the value */
+00508                 m->val = val;
+00509         } else {
+00510                 if (map->key == NULL)
+00511                         return;
+00512 
+00513                 if (val) {
+00514                         m = (struct map_node_int64 *)map->key;
+00515                         m->val = val;
+00516                 } else {
+00517                         /* setting value to 0 is the same as deleting */
+00518                         _stp_map_key_del(map);
+00519                 }
+00520         }
+00521 }
+00522 
+00528 int64_t _stp_map_get_int64(MAP map)
+00529 {
+00530         struct map_node_int64 *m;
+00531         if (map == NULL || map->create || map->key == NULL)
+00532                 return 0;
+00533         dbug ("%lx\n", (long)map->key);
+00534         m = (struct map_node_int64 *)map->key;
+00535         return m->val;
+00536 }
+00537 
+00548 void _stp_map_set_str(MAP map, char *val)
+00549 {
+00550         struct map_node_str *m;
+00551 
+00552         if (map == NULL)
+00553                 return;
+00554 
+00555         if (map->create) {
+00556                 if (val == NULL)
+00557                         return;
+00558 
+00559                 if (map->maxnum) {
+00560                         if (list_empty(&map->pool)) {
+00561                                 if (map->no_wrap) {
+00562                                         /* ERROR. FIXME */
+00563                                         return;
+00564                                 }
+00565                                 m = (struct map_node_str *)map->head.next;
+00566                                 hlist_del_init(&m->n.hnode);
+00567                                 map_free_strings(map, (struct map_node *)m);
+00568                                 dbug ("got %lx off head\n", (long)m);
+00569                         } else {
+00570                                 m = (struct map_node_str *)map->pool.next;
+00571                                 dbug ("got %lx off pool\n", (long)m);
+00572                         }
+00573                         list_move_tail(&m->n.lnode, &map->head);
+00574                 } else {
+00575                         m = (struct map_node_str *)
+00576                             _stp_calloc(sizeof(struct map_node_str));
+00577                         /* add node to list */
+00578                         list_add_tail(&m->n.lnode, &map->head);
+00579                 }
+00580 
+00581                 /* copy the key(s) */
+00582                 map_copy_keys(map, &m->n);
+00583 
+00584                 /* set the value */
+00585                 m->str = _stp_alloc(strlen(val) + 1);
+00586                 strcpy(m->str, val);
+00587         } else {
+00588                 if (map->key == NULL)
+00589                         return;
+00590 
+00591                 if (val) {
+00592                         m = (struct map_node_str *)map->key;
+00593                         if (m->str)
+00594                                 _stp_free(m->str);
+00595                         m->str = _stp_alloc(strlen(val) + 1);
+00596                         strcpy(m->str, val);
+00597                 } else {
+00598                         /* setting value to 0 is the same as deleting */
+00599                         _stp_map_key_del(map);
+00600                 }
+00601         }
+00602 }
+00603 
+00609 char *_stp_map_get_str(MAP map)
+00610 {
+00611         struct map_node_str *m;
+00612         if (map == NULL || map->create || map->key == NULL)
+00613                 return NULL;
+00614         dbug ("%lx\n", (long)map->key);
+00615         m = (struct map_node_str *)map->key;
+00616         return m->str;
+00617 }
+00618 
+00633 void _stp_map_set_stat(MAP map, stat * stats)
+00634 {
+00635         struct map_node_stat *m;
+00636 
+00637         if (map == NULL)
+00638                 return;
+00639         dbug ("set_stat %lx\n", (long)map->key);
+00640 
+00641         if (map->create) {
+00642                 if (stats == NULL)
+00643                         return;
+00644 
+00645                 if (map->maxnum) {
+00646                         if (list_empty(&map->pool)) {
+00647                                 if (map->no_wrap) {
+00648                                         /* ERROR. FIXME */
+00649                                         return;
+00650                                 }
+00651                                 m = (struct map_node_stat *)map->head.next;
+00652                                 hlist_del_init(&m->n.hnode);
+00653                                 map_free_strings(map, (struct map_node *)m);
+00654                                 dbug ("got %lx off head\n", (long)m);
+00655                         } else {
+00656                                 m = (struct map_node_stat *)map->pool.next;
+00657                                 dbug ("got %lx off pool\n", (long)m);
+00658                         }
+00659                         list_move_tail(&m->n.lnode, &map->head);
+00660                 } else {
+00661                         m = (struct map_node_stat *)
+00662                             _stp_calloc(sizeof(struct map_node_stat));
+00663                         /* add node to list */
+00664                         list_add_tail(&m->n.lnode, &map->head);
+00665                 }
+00666 
+00667                 /* copy the key(s) */
+00668                 map_copy_keys(map, &m->n);
+00669 
+00670                 /* set the value */
+00671                 memcpy(&m->stats, stats, sizeof(stat));
+00672         } else {
+00673                 if (map->key == NULL)
+00674                         return;
+00675 
+00676                 if (stats) {
+00677                         m = (struct map_node_stat *)map->key;
+00678                         memcpy(&m->stats, stats, sizeof(stat));
+00679                 } else {
+00680                         /* setting value to NULL is the same as deleting */
+00681                         _stp_map_key_del(map);
+00682                 }
+00683         }
+00684 }
+00685 
+00692 stat *_stp_map_get_stat(MAP map)
+00693 {
+00694         struct map_node_stat *m;
+00695         if (map == NULL || map->create || map->key == NULL)
+00696                 return NULL;
+00697         dbug ("%lx\n", (long)map->key);
+00698         m = (struct map_node_stat *)map->key;
+00699         return &m->stats;
+00700 }
+00701 
+00713 void _stp_map_stat_add(MAP map, int64_t val)
+00714 {
+00715         struct map_node_stat *m;
+00716         if (map == NULL)
+00717                 return;
+00718 
+00719         if (map->create) {
+00720                 stat st = { 1, val, val, val };
+00721                 /* histogram */
+00722                 _stp_map_set_stat(map, &st);
+00723                 return;
+00724         }
+00725 
+00726         if (map->key == NULL)
+00727                 return;
+00728 
+00729         dbug ("add_stat %lx\n", (long)map->key);
+00730         m = (struct map_node_stat *)map->key;
+00731         m->stats.count++;
+00732         m->stats.sum += val;
+00733         if (val > m->stats.max)
+00734                 m->stats.max = val;
+00735         if (val < m->stats.min)
+00736                 m->stats.min = val;
+00737         /* histogram */
+00738 }
+00739 
+00740 /**********************  List Functions *********************/
+00741 
+00753 MAP _stp_list_new(unsigned max_entries, enum valtype type)
+00754 {
+00755   MAP map = _stp_map_new (max_entries, type);
+00756   map->no_wrap = 1;
+00757   return map;
+00758 }
+00759 
+00765 inline void _stp_list_clear(MAP map)
+00766 {
+00767         if (map == NULL)
+00768                 return;
+00769 
+00770         if (!list_empty(&map->head)) {
+00771                 struct map_node *ptr = (struct map_node *)map->head.next;
+00772 
+00773                 while (ptr && ptr != (struct map_node *)&map->head) {
+00774                         struct map_node *next = (struct map_node *)ptr->lnode.next;
+00775 
+00776                         /* remove node from old hash list */
+00777                         hlist_del_init(&ptr->hnode);
+00778 
+00779                         /* remove from entry list */
+00780                         list_del(&ptr->lnode);
+00781                         
+00782                         /* remove any allocated string storage */
+00783                         map_free_strings(map, ptr);
+00784                         
+00785                         if (map->maxnum)
+00786                                 list_add(&ptr->lnode, &map->pool);
+00787                         else
+00788                                 _stp_free(ptr);
+00789 
+00790                         map->num--;
+00791                         ptr = next;
+00792                 }
+00793         }
+00794 
+00795         if (map->num != 0) {
+00796                 dlog ("ERROR: list is supposed to be empty (has %d)\n", map->num);
+00797         }
+00798 }
+00799 
+00805 inline void _stp_list_add_str(MAP map, char *str)
+00806 {
+00807         _stp_map_key_long(map, map->num);
+00808         _stp_map_set_str(map, str);
+00809 }
+00810 
+00816 inline void _stp_list_add_int64(MAP map, int64_t val)
+00817 {
+00818         _stp_map_key_long(map, map->num);
+00819         _stp_map_set_int64(map, val);
+00820 }
+00821 
+00827 inline int _stp_list_size(MAP map)
+00828 {
+00829         return map->num;
+00830 }
+

Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/map_8c.html b/runtime/docs/html/map_8c.html new file mode 100644 index 000000000..d4982cac8 --- /dev/null +++ b/runtime/docs/html/map_8c.html @@ -0,0 +1,1199 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map.c File Reference

+

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

Functions

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


Function Documentation

+

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

+Adds an int64 to a list. +

+

Parameters:
+ + + +
map 
val 
+
+ +

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

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

+

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

+Adds a string to a list. +

+

Parameters:
+ + + +
map 
str 
+
+ +

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

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

+Referenced by _stp_copy_argv_from_user().

+

+ + + + +
+ + + + + + + + + +
void _stp_list_clear MAP  map  )  [inline]
+
+ + + + + +
+   + + +

+Clears a list. +

+All elements in the list are deleted.

Parameters:
+ + +
map 
+
+ +

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

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

+

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

+Create a new list. +

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

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

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

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

+

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

+Get the number of elements in a list. +

+

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

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

+References MAP, and map_root::num.

+

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

+Deletes a map. +

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

Parameters:
+ + +
map 
+
+ +

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

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

+

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

+Gets the current element's value. +

+

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

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

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

+

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

+Gets the current element's value. +

+

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

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

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

+

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

+Gets the current element's value. +

+

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

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

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

+

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

+Get the next element in a map. +

+

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

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

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

+

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

+Deletes the current element. +

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

Parameters:
+ + +
map 
+
+ +

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

+References _stp_free(), map_root::create, dbug, map_node::hnode, map_root::key, map_node::lnode, MAP, map_root::maxnum, map_root::num, and map_root::pool. +

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

+

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

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

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

Parameters:
+ + + +
map 
key 
+
+ +

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

+References _stp_map_key_long_long(), and MAP. +

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

+

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

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

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

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

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

+References map_root::c_key1, map_root::c_key2, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, MAP, and key_data::val. +

+Referenced by _stp_map_key_long().

+

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

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

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

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

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

+References map_root::c_key1, map_root::c_key2, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, map_node::key2, MAP, key_data::str, and key_data::val.

+

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

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

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

Parameters:
+ + + +
map 
key 
+
+ +

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

+References _stp_map_key_str_str(), and MAP.

+

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

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

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

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

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

+References map_root::c_key1, map_root::c_key2, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, map_node::key2, MAP, key_data::str, and key_data::val.

+

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

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

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

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

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

+References map_root::c_key1, map_root::c_key2, map_root::c_keyhead, map_root::create, dbug, map_root::hashes, map_root::key, map_node::key1, map_node::key2, MAP, and key_data::str. +

+Referenced by _stp_map_key_str().

+

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

+Create a new map. +

+Maps must be created at module initialization time.

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

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

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

+Referenced by _stp_list_new().

+

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

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

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

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

Parameters:
+ + + +
map 
val new value
+
+ +

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

+References _stp_calloc(), _stp_map_key_del(), map_root::create, dbug, map_root::head, map_node::hnode, map_root::key, map_node::lnode, MAP, map_root::maxnum, map_node_int64::n, map_root::no_wrap, map_root::pool, and map_node_int64::val. +

+Referenced by _stp_list_add_int64().

+

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

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

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

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

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

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

+Referenced by _stp_map_stat_add().

+

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

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

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

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

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

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

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

+Referenced by _stp_list_add_str().

+

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

+Get the first element in a map. +

+

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

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

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

+

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

+Add to the current element's statistics. +

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

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

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

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

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

+


Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/map_8h-source.html b/runtime/docs/html/map_8h-source.html new file mode 100644 index 000000000..9a49236c5 --- /dev/null +++ b/runtime/docs/html/map_8h-source.html @@ -0,0 +1,146 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map.h

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

Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/map_8h.html b/runtime/docs/html/map_8h.html new file mode 100644 index 000000000..def7be23b --- /dev/null +++ b/runtime/docs/html/map_8h.html @@ -0,0 +1,535 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map.h File Reference

#include <linux/types.h>
+ +

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

Data Structures

struct  stat
union  key_data
struct  map_node
struct  map_node_int64
struct  map_node_str
struct  map_node_stat
struct  map_root

Defines

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

Typedefs

typedef map_rootMAP

Enumerations

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

Variables

enum keytype packed
+


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));                        \
+  })
+
+

+Definition at line 121 of file map.h.

+

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

+Value:

({                                                              \
+    if (__builtin_types_compatible_p (typeof (key), char[]))    \
+      _stp_map_key_str (map, (char *)(key));                            \
+    else                                                        \
+      _stp_map_key_long (map, (long)(key));                             \
+  })
+
+

+Definition at line 105 of file map.h.

+

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

+Value:

({                                                              \
+    if (__builtin_types_compatible_p (typeof (key1), char[]))   \
+      if (__builtin_types_compatible_p (typeof (key2), char[])) \
+        _stp_map_key_str_str (map, (char *)(key1), (char *)(key2));     \
+      else                                                      \
+        _stp_map_key_str_long (map, (char *)(key1), (long)(key2));      \
+    else                                                        \
+      if (__builtin_types_compatible_p (typeof (key2), char[])) \
+        _stp_map_key_long_str (map, (long)(key1), (char *)(key2));      \
+      else                                                      \
+        _stp_map_key_long_long (map, (long)(key1), (long)(key2));       \
+  })
+
+

+Definition at line 91 of file map.h.

+

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

+Value:

({                                                              \
+    if (__builtin_types_compatible_p (typeof (val), char[]))    \
+      _stp_map_set_str (map, (char *)(val));                            \
+    else                                                        \
+      _stp_map_set_int64 (map, (int64_t)(val));                 \
+  })
+
+

+Definition at line 113 of file map.h.

+

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

+Value:

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

+

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

+Definition at line 138 of file map.h.

+

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

+ +

+Definition at line 88 of file map.h.

+

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

+ +

+Definition at line 86 of file map.h.

+

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

+ +

+Definition at line 89 of file map.h.

+

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

+ +

+Definition at line 87 of file map.h.

+


Typedef Documentation

+

+ + + + +
+ + + + +
typedef struct map_root* MAP
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_copy_argv_from_user(), _stp_list_add_int64(), _stp_list_add_str(), _stp_list_clear(), _stp_list_new(), _stp_list_size(), _stp_map_del(), _stp_map_get_int64(), _stp_map_get_stat(), _stp_map_get_str(), _stp_map_iter(), _stp_map_key_del(), _stp_map_key_long(), _stp_map_key_long_long(), _stp_map_key_long_str(), _stp_map_key_str(), _stp_map_key_str_long(), _stp_map_key_str_str(), _stp_map_new(), _stp_map_set_int64(), _stp_map_set_stat(), _stp_map_set_str(), _stp_map_start(), and _stp_map_stat_add().

+


Enumeration Type Documentation

+

+ + + + +
+ + + + +
enum keytype
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + +
NONE  +
LONG  +
STR  +
+
+ +

+Definition at line 16 of file map.h.

+

+ + + + +
+ + + + +
enum valtype
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + +
INT64  +
STAT  +
STRING  +
END  +
+
+ +

+Definition at line 17 of file map.h.

+


Variable Documentation

+

+ + + + +
+ + + + +
enum keytype packed
+
+ + + + + +
+   + + +

+

+


Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/pages.html b/runtime/docs/html/pages.html new file mode 100644 index 000000000..108385342 --- /dev/null +++ b/runtime/docs/html/pages.html @@ -0,0 +1,19 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

SystemTap Related Pages

Here is a list of all related documentation pages: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/runtime_8h-source.html b/runtime/docs/html/runtime_8h-source.html new file mode 100644 index 000000000..b688d3512 --- /dev/null +++ b/runtime/docs/html/runtime_8h-source.html @@ -0,0 +1,31 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

runtime.h

Go to the documentation of this file.
00001 
+00002 #include <linux/module.h>
+00003 #include <linux/miscdevice.h>
+00004 #include <linux/init.h>
+00005 #include <linux/hash.h>
+00006 #include <linux/string.h>
+00007 #include <linux/kprobes.h>
+00008 #include <linux/proc_fs.h>
+00009 #include <linux/vmalloc.h>
+00010 #include <linux/time.h>
+00011 #include <linux/spinlock.h>
+00012 #include <asm/uaccess.h>
+00013 
+00014 #include "alloc.h"
+00015 #include "map.h"
+00016 
+00017 #define dbug(args...) ;
+00018 
+

Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/runtime_8h.html b/runtime/docs/html/runtime_8h.html new file mode 100644 index 000000000..89b240973 --- /dev/null +++ b/runtime/docs/html/runtime_8h.html @@ -0,0 +1,67 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

runtime.h File Reference

#include <linux/module.h>
+#include <linux/miscdevice.h>
+#include <linux/init.h>
+#include <linux/hash.h>
+#include <linux/string.h>
+#include <linux/kprobes.h>
+#include <linux/proc_fs.h>
+#include <linux/vmalloc.h>
+#include <linux/time.h>
+#include <linux/spinlock.h>
+#include <asm/uaccess.h>
+#include "alloc.h"
+#include "map.h"
+ +

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

Defines

#define dbug(args...)   ;
+


Define Documentation

+

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

+ +

+Definition at line 17 of file runtime.h. +

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

+


Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/structmap__node.html b/runtime/docs/html/structmap__node.html new file mode 100644 index 000000000..0f1dbc424 --- /dev/null +++ b/runtime/docs/html/structmap__node.html @@ -0,0 +1,138 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map_node Struct Reference

#include <map.h> +

+ + + + + + + + + + + +

Data Fields

list_head lnode
hlist_node hnode
key_data key1
key_data key2
+


Field Documentation

+

+ + + + +
+ + + + +
struct hlist_node map_node::hnode
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
union key_data map_node::key1
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
union key_data map_node::key2
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
struct list_head map_node::lnode
+
+ + + + + +
+   + + +

+ +

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

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

+


The documentation for this struct was generated from the following file: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/structmap__node__int64.html b/runtime/docs/html/structmap__node__int64.html new file mode 100644 index 000000000..d2ec73172 --- /dev/null +++ b/runtime/docs/html/structmap__node__int64.html @@ -0,0 +1,80 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map_node_int64 Struct Reference

#include <map.h> +

+ + + + + + + +

Data Fields

map_node n
int64_t val
+


Field Documentation

+

+ + + + +
+ + + + +
struct map_node map_node_int64::n
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_map_set_int64().

+

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

+ +

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

+Referenced by _stp_map_get_int64(), and _stp_map_set_int64().

+


The documentation for this struct was generated from the following file: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/structmap__node__stat.html b/runtime/docs/html/structmap__node__stat.html new file mode 100644 index 000000000..0d8fdb95d --- /dev/null +++ b/runtime/docs/html/structmap__node__stat.html @@ -0,0 +1,80 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map_node_stat Struct Reference

#include <map.h> +

+ + + + + + + +

Data Fields

map_node n
stat stats
+


Field Documentation

+

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

+ +

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

+Referenced by _stp_map_set_stat().

+

+ + + + +
+ + + + +
stat map_node_stat::stats
+
+ + + + + +
+   + + +

+ +

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

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

+


The documentation for this struct was generated from the following file: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/structmap__node__str.html b/runtime/docs/html/structmap__node__str.html new file mode 100644 index 000000000..a7d78bed0 --- /dev/null +++ b/runtime/docs/html/structmap__node__str.html @@ -0,0 +1,80 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map_node_str Struct Reference

#include <map.h> +

+ + + + + + + +

Data Fields

map_node n
char * str
+


Field Documentation

+

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

+ +

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

+Referenced by _stp_map_set_str().

+

+ + + + +
+ + + + +
char* map_node_str::str
+
+ + + + + +
+   + + +

+ +

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

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

+


The documentation for this struct was generated from the following file: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/structmap__root.html b/runtime/docs/html/structmap__root.html new file mode 100644 index 000000000..d6a7418a8 --- /dev/null +++ b/runtime/docs/html/structmap__root.html @@ -0,0 +1,370 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

map_root Struct Reference

#include <map.h> +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +

Data Fields

int maxnum
int num
int no_wrap
list_head head
list_head pool
map_nodekey
u_int8_t create
hlist_head * c_keyhead
key_data c_key1
key_data c_key2
hlist_head hashes [HASH_TABLE_SIZE]
void * membuf
+


Field Documentation

+

+ + + + +
+ + + + +
union key_data map_root::c_key1
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
union key_data map_root::c_key2
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
struct hlist_head* map_root::c_keyhead
+
+ + + + + +
+   + + +

+ +

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

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

+

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

+ +

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

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

+

+ + + + +
+ + + + +
struct hlist_head map_root::hashes[HASH_TABLE_SIZE]
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
struct list_head map_root::head
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_list_clear(), _stp_map_del(), _stp_map_iter(), _stp_map_new(), _stp_map_set_int64(), _stp_map_set_stat(), _stp_map_set_str(), and _stp_map_start().

+

+ + + + +
+ + + + +
struct map_node* map_root::key
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
int map_root::maxnum
+
+ + + + + +
+   + + +

+ +

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

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

+

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

+ +

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

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

+

+ + + + +
+ + + + +
int map_root::no_wrap
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
int map_root::num
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_copy_argv_from_user(), _stp_list_add_int64(), _stp_list_add_str(), _stp_list_clear(), _stp_list_size(), and _stp_map_key_del().

+

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

+ +

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

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

+


The documentation for this struct was generated from the following file: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/structstat.html b/runtime/docs/html/structstat.html new file mode 100644 index 000000000..476276575 --- /dev/null +++ b/runtime/docs/html/structstat.html @@ -0,0 +1,165 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

stat Struct Reference

#include <map.h> +

+ + + + + + + + + + + + + +

Data Fields

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


Field Documentation

+

+ + + + +
+ + + + +
int64_t stat::count
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_map_stat_add().

+

+ + + + +
+ + + + +
int64_t stat::histogram[BUCKETS]
+
+ + + + + +
+   + + +

+ +

+Definition at line 8 of file map.h.

+

+ + + + +
+ + + + +
int64_t stat::max
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_map_stat_add().

+

+ + + + +
+ + + + +
int64_t stat::min
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_map_stat_add().

+

+ + + + +
+ + + + +
int64_t stat::sum
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_map_stat_add().

+


The documentation for this struct was generated from the following file: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/todo.html b/runtime/docs/html/todo.html new file mode 100644 index 000000000..d4f0d0513 --- /dev/null +++ b/runtime/docs/html/todo.html @@ -0,0 +1,32 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

Todo List

+
page SystemTap Runtime Library
+
The Runtime Library is not actually a library yet. It is just a collection of functions included in the probe boilerplate.
+
+

+

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

+

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

+

+
Global _stp_map_stat_add (MAP map, int64_t val)
+
Histograms don't work yet.
+
+
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/docs/html/tree.html b/runtime/docs/html/tree.html new file mode 100644 index 000000000..1d3f49b02 --- /dev/null +++ b/runtime/docs/html/tree.html @@ -0,0 +1,139 @@ + + + + + + + TreeView + + + + + + + + diff --git a/runtime/docs/html/unionkey__data.html b/runtime/docs/html/unionkey__data.html new file mode 100644 index 000000000..e2f2a66eb --- /dev/null +++ b/runtime/docs/html/unionkey__data.html @@ -0,0 +1,80 @@ + + +SystemTap: SystemTap Runtime Library + + + + + +

key_data Union Reference

#include <map.h> +

+ + + + + + + +

Data Fields

long val
char * str
+


Field Documentation

+

+ + + + +
+ + + + +
char* key_data::str
+
+ + + + + +
+   + + +

+ +

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

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

+

+ + + + +
+ + + + +
long key_data::val
+
+ + + + + +
+   + + +

+ +

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

+Referenced by _stp_map_key_long_long(), _stp_map_key_long_str(), and _stp_map_key_str_long().

+


The documentation for this union was generated from the following file: +
Generated on Wed Mar 9 13:21:28 2005 for SystemTap by  + +doxygen 1.3.9.1
+ + diff --git a/runtime/io.c b/runtime/io.c new file mode 100644 index 000000000..3371df160 --- /dev/null +++ b/runtime/io.c @@ -0,0 +1,19 @@ +/** 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. + * + * @param fmt A variable number of args. + * @bug Lines are limited in length by printk buffer. + * @todo Needs replaced with something much faster that does not + * use the system log. + */ +void dlog (const char *fmt, ...) +{ + va_list args; + printk("STP: "); + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); +} + diff --git a/runtime/map.c b/runtime/map.c new file mode 100644 index 000000000..9b264c3ad --- /dev/null +++ b/runtime/map.c @@ -0,0 +1,830 @@ +/* -*- linux-c -*- */ + +static int map_sizes[] = { + sizeof(struct map_node_int64), + sizeof(struct map_node_stat), + sizeof(struct map_node_str), + 0 +}; + +static inline unsigned string_hash(const char *key1, const char *key2) +{ + int hash = 0, count = 0; + char *v1 = (char *)key1; + char *v2 = (char *)key2; + while (*v1 && count++ < 5) { + hash += *v1++; + } + while (v2 && *v2 && count++ < 5) { + hash += *v2++; + } + return hash_long((unsigned long)hash, HASH_TABLE_BITS); +} + +static inline unsigned mixed_hash(const char *key1, long key2) +{ + int hash = 0, count = 0; + char *v = (char *)key1; + while (v && *v && count++ < 5) + hash += *v++; + return hash_long((unsigned long)(hash ^ key2), HASH_TABLE_BITS); +} + +/** Create a new map. + * Maps must be created at module initialization time. + * @param max_entries The maximum number of entries allowed. Currently that number will + * be preallocated. If more entries are required, the oldest ones will be deleted. This makes + * it effectively a circular buffer. If max_entries is 0, there will be no maximum and entries + * will be allocated dynamically. + * @param type Type of values stored in this map. + * @return A MAP on success or NULL on failure. + */ + +MAP _stp_map_new(unsigned max_entries, enum valtype type) +{ + size_t size; + MAP m = (MAP) _stp_valloc(sizeof(struct map_root)); + if (m == NULL) + return NULL; + + INIT_LIST_HEAD(&m->head); + + m->maxnum = max_entries; + m->type = type; + if (type >= END) { + dbug ("map_new: unknown type %d\n", type); + return NULL; + } + + if (max_entries) { + void *tmp; + int i; + struct list_head *e; + + INIT_LIST_HEAD(&m->pool); + size = map_sizes[type]; + tmp = _stp_valloc(max_entries * size); + + for (i = max_entries - 1; i >= 0; i--) { + e = i * size + tmp; + dbug ("e=%lx\n", (long)e); + list_add(e, &m->pool); + } + m->membuf = tmp; + } + return m; +} + +static void map_free_strings(MAP map, struct map_node *n) +{ + struct map_node_str *m = (struct map_node_str *)n; + dbug ("n = %lx\n", (long)n); + if (map->type == STRING) { + dbug ("val STRING %lx\n", (long)m->str); + if (m->str) + _stp_free(m->str); + } + if (m->n.key1type == STR) { + dbug ("key1 STR %lx\n", (long)key1str(m)); + if (key1str(m)) + _stp_free(key1str(m)); + } + if (m->n.key2type == STR) { + dbug ("key2 STR %lx\n", (long)key2str(m)); + if (key2str(m)) + _stp_free(key2str(m)); + } +} + +/** Deletes the current element. + * If no current element (key) for this map is set, this function does nothing. + * @param map + */ + +void _stp_map_key_del(MAP map) +{ + struct map_node *m; + + dbug ("create=%d key=%lx\n", map->create, (long)map->key); + if (map == NULL) + return; + + if (map->create) { + map->create = 0; + map->key = NULL; + return; + } + + if (map->key == NULL) + return; + + m = (struct map_node *)map->key; + + /* remove node from old hash list */ + hlist_del_init(&m->hnode); + + /* remove from entry list */ + list_del(&m->lnode); + + /* remove any allocated string storage */ + map_free_strings(map, (struct map_node *)map->key); + + if (map->maxnum) + list_add(&m->lnode, &map->pool); + else + _stp_free(m); + + map->key = NULL; + map->num--; +} + +/** Get the first element in a map. + * @param 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. + * @sa foreach + */ + +struct map_node *_stp_map_start(MAP map) +{ + if (map == NULL) + return NULL; + + dbug ("%lx\n", (long)map->head.next); + + if (list_empty(&map->head)) + return NULL; + + return (struct map_node *)map->head.next; +} + +/** Get the next element in a map. + * @param map + * @param 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. + * @sa foreach + */ + +struct map_node *_stp_map_iter(MAP map, struct map_node *m) +{ + if (map == NULL) + return NULL; + + dbug ("%lx next=%lx prev=%lx map->head.next=%lx\n", (long)m, (long)m->lnode.next, (long)m->lnode.prev, (long)map->head.next); + + if (m->lnode.next == &map->head) + return NULL; + + return (struct map_node *)m->lnode.next; +} + +/** Deletes a map. + * Deletes a map, freeing all memory in all elements. Normally done only when the module exits. + * @param map + */ + +void _stp_map_del(MAP map) +{ + if (map == NULL) + return; + + if (!list_empty(&map->head)) { + struct map_node *ptr = (struct map_node *)map->head.next; + while (ptr && ptr != (struct map_node *)&map->head) { + map_free_strings(map, ptr); + ptr = (struct map_node *)ptr->lnode.next; + } + } + _stp_vfree(map->membuf); + _stp_vfree(map); +} + +/********************** KEY FUNCTIONS *********************/ + + +/** Set the map's key to two longs. + * This sets the current element based on a key of two strings. If the keys are + * not found, a new element will not be created until a _stp_map_set_xxx + * call. + * @param map + * @param key1 first key + * @param key2 second key + */ + +void _stp_map_key_long_long(MAP map, long key1, long key2) +{ + unsigned hv; + struct hlist_head *head; + struct hlist_node *e; + + if (map == NULL) + return; + + hv = hash_long(key1 ^ key2, HASH_TABLE_BITS); + head = &map->hashes[hv]; + + dbug ("hash for %ld,%ld is %d\n", key1, key2, hv); + + hlist_for_each(e, head) { + struct map_node *n = + (struct map_node *)((long)e - sizeof(struct hlist_node)); + dbug ("n =%lx key=%ld,%ld\n", (long)n, n->key1.val, n->key2.val); + if (key1 == n->key1.val && key2 == n->key2.val) { + map->key = n; + dbug ("saving key %lx\n", (long)map->key); + map->create = 0; + return; + } + } + + map->c_key1.val = key1; + map->c_key2.val = key2; + map->c_key1type = LONG; + map->c_key2type = LONG; + map->c_keyhead = head; + map->create = 1; +} + +/** Set the map's key to two strings. + * This sets the current element based on a key of two strings. If the keys are + * not found, a new element will not be created until a _stp_map_set_xxx + * call. + * @param map + * @param key1 first key + * @param key2 second key + */ + +void _stp_map_key_str_str(MAP map, char *key1, char *key2) +{ + unsigned hv; + struct hlist_head *head; + struct hlist_node *e; + + if (map == NULL) + return; + + if (key1 == NULL) { + map->key = NULL; + return; + } + + hv = string_hash(key1, key2); + head = &map->hashes[hv]; + + dbug ("hash for %s,%s is %d\n", key1, key2, hv); + + hlist_for_each(e, head) { + struct map_node *n = + (struct map_node *)((long)e - sizeof(struct hlist_node)); + dbug ("e =%lx key=%s,%s\n", (long)e, n->key1.str,n->key2.str); + if (strcmp(key1, n->key1.str) == 0 + && (key2 == NULL || strcmp(key2, n->key2.str) == 0)) { + map->key = n; + dbug ("saving key %lx\n", (long)map->key); + map->create = 0; + return; + } + } + + map->c_key1.str = key1; + map->c_key2.str = key2; + map->c_key1type = STR; + map->c_key2type = STR; + map->c_keyhead = head; + map->create = 1; +} + +/** Set the map's key to a string and a long. + * This sets the current element based on a key of a string and a long. If the keys are + * not found, a new element will not be created until a _stp_map_set_xxx + * call. + * @param map + * @param key1 first key + * @param key2 second key + */ + +void _stp_map_key_str_long(MAP map, char *key1, long key2) +{ + unsigned hv; + struct hlist_head *head; + struct hlist_node *e; + + if (map == NULL) + return; + + if (key1 == NULL) { + map->key = NULL; + return; + } + + hv = mixed_hash(key1, key2); + head = &map->hashes[hv]; + + dbug ("hash for %s,%ld is %d\n", key1, key2, hv); + + hlist_for_each(e, head) { + struct map_node *n = + (struct map_node *)((long)e - sizeof(struct hlist_node)); + dbug ("e =%lx key=%s,%ld\n", (long)e, n->key1.str,(long)n->key2.val); + if (strcmp(key1, n->key1.str) == 0 && key2 == n->key2.val) { + map->key = n; + dbug ("saving key %lx\n", (long)map->key); + map->create = 0; + return; + } + } + + map->c_key1.str = key1; + map->c_key2.val = key2; + map->c_key1type = STR; + map->c_key2type = LONG; + map->c_keyhead = head; + map->create = 1; +} + +/** Set the map's key to a long and a string. + * This sets the current element based on a key of a long and a string. If the keys are + * not found, a new element will not be created until a _stp_map_set_xxx + * call. + * @param map + * @param key1 first key + * @param key2 second key + */ + +void _stp_map_key_long_str(MAP map, long key1, char *key2) +{ + unsigned hv; + struct hlist_head *head; + struct hlist_node *e; + + if (map == NULL) + return; + + hv = mixed_hash(key2, key1); + head = &map->hashes[hv]; + dbug ("hash for %ld,%s is %d\n", key1, key2, hv); + + hlist_for_each(e, head) { + struct map_node *n = + (struct map_node *)((long)e - sizeof(struct hlist_node)); + dbug ("e =%lx key=%ld,%s\n", (long)e, n->key1.val,n->key2.str); + if (key1 == n->key1.val && strcmp(key2, n->key2.str) == 0) { + map->key = n; + dbug ("saving key %lx\n", (long)map->key); + map->create = 0; + return; + } + } + + map->c_key1.val = key1; + map->c_key2.str = key2; + map->c_key1type = LONG; + map->c_key2type = STR; + map->c_keyhead = head; + map->create = 1; +} + +/** Set the map's key to a string. + * This sets the current element based on a string key. If the key is + * not found, a new element will not be created until a _stp_map_set_xxx + * call. + * @param map + * @param key + */ + +void _stp_map_key_str(MAP map, char *key) +{ + if (map == NULL) + return; + _stp_map_key_str_str(map, key, NULL); + map->c_key2type = NONE; +} + +/** Set the map's key to a long. + * This sets the current element based on a long key. If the key is + * not found, a new element will not be created until a _stp_map_set_xxx + * call. + * @param map + * @param key + */ + +void _stp_map_key_long(MAP map, long key) +{ + if (map == NULL) + return; + _stp_map_key_long_long(map, key, 0); + map->c_key2type = NONE; +} + +/********************** SET/GET VALUES *********************/ + +static void map_copy_keys(MAP map, struct map_node *m) +{ + m->key1type = map->c_key1type; + m->key2type = map->c_key2type; + switch (map->c_key1type) { + case STR: + m->key1.str = _stp_alloc(strlen(map->c_key1.str) + 1); + strcpy(m->key1.str, map->c_key1.str); + break; + case LONG: + m->key1.val = map->c_key1.val; + break; + case NONE: + /* ERROR */ + break; + } + switch (map->c_key2type) { + case STR: + m->key2.str = _stp_alloc(strlen(map->c_key2.str) + 1); + strcpy(m->key2.str, map->c_key2.str); + break; + case LONG: + m->key2.val = map->c_key2.val; + break; + case NONE: + break; + } + + /* add node to new hash list */ + hlist_add_head(&m->hnode, map->c_keyhead); + + map->key = m; + map->create = 0; + map->num++; +} + +/** Set the current element's value to an int64. + * This sets the current element's value to an int64. The map must have been created + * to hold int64s using _stp_map_new() + * + * If the element doesn't exist, it is created. If no current element (key) + * is set for the map, this function does nothing. + * @param map + * @param val new value + */ + +void _stp_map_set_int64(MAP map, int64_t val) +{ + struct map_node_int64 *m; + + if (map == NULL) + return; + + if (map->create) { + if (val == 0) + return; + + if (map->maxnum) { + if (list_empty(&map->pool)) { + if (map->no_wrap) { + /* ERROR. FIXME */ + return; + } + m = (struct map_node_int64 *)map->head.next; + hlist_del_init(&m->n.hnode); + map_free_strings(map, (struct map_node *)m); + dbug ("got %lx off head\n", (long)m); + } else { + m = (struct map_node_int64 *)map->pool.next; + dbug ("got %lx off pool\n", (long)m); + } + list_move_tail(&m->n.lnode, &map->head); + } else { + m = (struct map_node_int64 *) + _stp_calloc(sizeof(struct map_node_int64)); + /* add node to list */ + list_add_tail(&m->n.lnode, &map->head); + } + + /* copy the key(s) */ + map_copy_keys(map, &m->n); + + /* set the value */ + m->val = val; + } else { + if (map->key == NULL) + return; + + if (val) { + m = (struct map_node_int64 *)map->key; + m->val = val; + } else { + /* setting value to 0 is the same as deleting */ + _stp_map_key_del(map); + } + } +} + +/** Gets the current element's value. + * @param map + * @returns The value. If the current element is not set or doesn't exist, returns 0. + */ + +int64_t _stp_map_get_int64(MAP map) +{ + struct map_node_int64 *m; + if (map == NULL || map->create || map->key == NULL) + return 0; + dbug ("%lx\n", (long)map->key); + m = (struct map_node_int64 *)map->key; + 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 + * 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 + */ + +void _stp_map_set_str(MAP map, char *val) +{ + struct map_node_str *m; + + if (map == NULL) + return; + + if (map->create) { + if (val == NULL) + return; + + if (map->maxnum) { + if (list_empty(&map->pool)) { + if (map->no_wrap) { + /* ERROR. FIXME */ + return; + } + m = (struct map_node_str *)map->head.next; + hlist_del_init(&m->n.hnode); + map_free_strings(map, (struct map_node *)m); + dbug ("got %lx off head\n", (long)m); + } else { + m = (struct map_node_str *)map->pool.next; + dbug ("got %lx off pool\n", (long)m); + } + list_move_tail(&m->n.lnode, &map->head); + } else { + m = (struct map_node_str *) + _stp_calloc(sizeof(struct map_node_str)); + /* add node to list */ + list_add_tail(&m->n.lnode, &map->head); + } + + /* copy the key(s) */ + map_copy_keys(map, &m->n); + + /* set the value */ + m->str = _stp_alloc(strlen(val) + 1); + strcpy(m->str, val); + } else { + if (map->key == NULL) + return; + + if (val) { + m = (struct map_node_str *)map->key; + if (m->str) + _stp_free(m->str); + m->str = _stp_alloc(strlen(val) + 1); + strcpy(m->str, val); + } else { + /* setting value to 0 is the same as deleting */ + _stp_map_key_del(map); + } + } +} + +/** Gets the current element's value. + * @param map + * @returns A string pointer. If the current element is not set or doesn't exist, returns NULL. + */ + +char *_stp_map_get_str(MAP map) +{ + struct map_node_str *m; + if (map == NULL || map->create || map->key == NULL) + return NULL; + dbug ("%lx\n", (long)map->key); + m = (struct map_node_str *)map->key; + return m->str; +} + +/** 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. + * @sa _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. + * @param map + * @param stats pointer to stats struct. + * @todo Histograms don't work yet. + */ + +void _stp_map_set_stat(MAP map, stat * stats) +{ + struct map_node_stat *m; + + if (map == NULL) + return; + dbug ("set_stat %lx\n", (long)map->key); + + if (map->create) { + if (stats == NULL) + return; + + if (map->maxnum) { + if (list_empty(&map->pool)) { + if (map->no_wrap) { + /* ERROR. FIXME */ + return; + } + m = (struct map_node_stat *)map->head.next; + hlist_del_init(&m->n.hnode); + map_free_strings(map, (struct map_node *)m); + dbug ("got %lx off head\n", (long)m); + } else { + m = (struct map_node_stat *)map->pool.next; + dbug ("got %lx off pool\n", (long)m); + } + list_move_tail(&m->n.lnode, &map->head); + } else { + m = (struct map_node_stat *) + _stp_calloc(sizeof(struct map_node_stat)); + /* add node to list */ + list_add_tail(&m->n.lnode, &map->head); + } + + /* copy the key(s) */ + map_copy_keys(map, &m->n); + + /* set the value */ + memcpy(&m->stats, stats, sizeof(stat)); + } else { + if (map->key == NULL) + return; + + if (stats) { + m = (struct map_node_stat *)map->key; + memcpy(&m->stats, stats, sizeof(stat)); + } else { + /* setting value to NULL is the same as deleting */ + _stp_map_key_del(map); + } + } +} + +/** Gets the current element's value. + * @param map + * @returns A pointer to the stats struct. If the current element is not set + * or doesn't exist, returns NULL. + */ + +stat *_stp_map_get_stat(MAP map) +{ + struct map_node_stat *m; + if (map == NULL || map->create || map->key == NULL) + return NULL; + dbug ("%lx\n", (long)map->key); + m = (struct map_node_stat *)map->key; + return &m->stats; +} + +/** Add to the current element's statistics. + * Increments the statistics counter by one and the sum by val. + * Adjusts minimum, maximum, and histogram. + * + * If the element doesn't exist, it is created. If no current element (key) + * is set for the map, this function does nothing. + * @param map + * @param val value to add to the statistics + * @todo Histograms don't work yet. + */ + +void _stp_map_stat_add(MAP map, int64_t val) +{ + struct map_node_stat *m; + if (map == NULL) + return; + + if (map->create) { + stat st = { 1, val, val, val }; + /* histogram */ + _stp_map_set_stat(map, &st); + return; + } + + if (map->key == NULL) + return; + + dbug ("add_stat %lx\n", (long)map->key); + m = (struct map_node_stat *)map->key; + m->stats.count++; + m->stats.sum += val; + if (val > m->stats.max) + m->stats.max = val; + if (val < m->stats.min) + m->stats.min = val; + /* histogram */ +} + +/********************** List Functions *********************/ + +/** Create a new list. + * A list is a map that internally has an incrementing long key for each member. + * Lists do not wrap if elements are added to exceed their maximum size. + * @param max_entries The maximum number of entries allowed. Currently that number will + * be preallocated. If max_entries is 0, there will be no maximum and entries + * will be allocated dynamically. + * @param type Type of values stored in this list. + * @return A MAP on success or NULL on failure. + * @sa foreach + */ + +MAP _stp_list_new(unsigned max_entries, enum valtype type) +{ + MAP map = _stp_map_new (max_entries, type); + map->no_wrap = 1; + return map; +} + +/** Clears a list. + * All elements in the list are deleted. + * @param map + */ + +inline void _stp_list_clear(MAP map) +{ + if (map == NULL) + return; + + if (!list_empty(&map->head)) { + struct map_node *ptr = (struct map_node *)map->head.next; + + while (ptr && ptr != (struct map_node *)&map->head) { + struct map_node *next = (struct map_node *)ptr->lnode.next; + + /* remove node from old hash list */ + hlist_del_init(&ptr->hnode); + + /* remove from entry list */ + list_del(&ptr->lnode); + + /* remove any allocated string storage */ + map_free_strings(map, ptr); + + if (map->maxnum) + list_add(&ptr->lnode, &map->pool); + else + _stp_free(ptr); + + map->num--; + ptr = next; + } + } + + if (map->num != 0) { + dlog ("ERROR: list is supposed to be empty (has %d)\n", map->num); + } +} + +/** Adds a string to a list. + * @param map + * @param str + */ + +inline void _stp_list_add_str(MAP map, char *str) +{ + _stp_map_key_long(map, map->num); + _stp_map_set_str(map, str); +} + +/** Adds an int64 to a list. + * @param map + * @param val + */ + +inline void _stp_list_add_int64(MAP map, int64_t val) +{ + _stp_map_key_long(map, map->num); + _stp_map_set_int64(map, val); +} + +/** Get the number of elements in a list. + * @param map + * @returns The number of elements in a list. + */ + +inline int _stp_list_size(MAP map) +{ + return map->num; +} diff --git a/runtime/map.h b/runtime/map.h new file mode 100644 index 000000000..617ff3e2b --- /dev/null +++ b/runtime/map.h @@ -0,0 +1,141 @@ +/* -*- linux-c -*- */ +#include + +typedef struct { + int64_t count; + int64_t sum; + int64_t min, max; + int64_t histogram[BUCKETS]; +} stat; + +union key_data { + long val; + char *str; +}; + +enum keytype { NONE, LONG, STR } __attribute__ ((packed)); +enum valtype { INT64, STAT, STRING, END }; + +/* all map nodes have the following structure */ +struct map_node { + struct list_head lnode; + struct hlist_node hnode; + union key_data key1; + union key_data key2; + enum keytype key1type; + enum keytype key2type; +}; + +/* specific map nodes with data attached */ +struct map_node_int64 { + struct map_node n; + int64_t val; +}; + +struct map_node_str { + struct map_node n; + char *str; +}; + +struct map_node_stat { + struct map_node n; + stat stats; +}; + +struct map_root { + /* type of the values stored in the array */ + enum valtype type; + + /* maximum number of elements allowed in the array. */ + int maxnum; + + /* current number of elements */ + int num; + + /* when more than maxnum elements, wrap or discard */ + int no_wrap; + + /* linked list of current entries */ + struct list_head head; + + /* pool of unused entries. Used only when entries are statically allocated */ + /* at startup. */ + struct list_head pool; + + /* saved key entry for lookups */ + struct map_node *key; + + /* this is the creation data saved between the key functions and the */ + /* set/get functions */ + u_int8_t create; + enum keytype c_key1type; + enum keytype c_key2type; + struct hlist_head *c_keyhead; + union key_data c_key1; + union key_data c_key2; + + /* the hash table for this array */ + struct hlist_head hashes[HASH_TABLE_SIZE]; + + /* pointer to allocated memory space */ + void *membuf; +}; + +typedef struct map_root *MAP; + +#define key1str(ptr) (ptr->n.key1.str) +#define key2str(ptr) (ptr->n.key2.str) +#define key1int(ptr) (ptr->n.key1.val) +#define key2int(ptr) (ptr->n.key2.val) + +#define _stp_map_key2(map, key1, key2) \ + ({ \ + if (__builtin_types_compatible_p (typeof (key1), char[])) \ + if (__builtin_types_compatible_p (typeof (key2), char[])) \ + _stp_map_key_str_str (map, (char *)(key1), (char *)(key2)); \ + else \ + _stp_map_key_str_long (map, (char *)(key1), (long)(key2)); \ + else \ + if (__builtin_types_compatible_p (typeof (key2), char[])) \ + _stp_map_key_long_str (map, (long)(key1), (char *)(key2)); \ + else \ + _stp_map_key_long_long (map, (long)(key1), (long)(key2)); \ + }) + +#define _stp_map_key(map, key) \ + ({ \ + if (__builtin_types_compatible_p (typeof (key), char[])) \ + _stp_map_key_str (map, (char *)(key)); \ + else \ + _stp_map_key_long (map, (long)(key)); \ + }) + +#define _stp_map_set(map, val) \ + ({ \ + if (__builtin_types_compatible_p (typeof (val), char[])) \ + _stp_map_set_str (map, (char *)(val)); \ + else \ + _stp_map_set_int64 (map, (int64_t)(val)); \ + }) + +#define _stp_list_add(map, val) \ + ({ \ + if (__builtin_types_compatible_p (typeof (val), char[])) \ + _stp_list_add_str (map, (char *)(val)); \ + else \ + _stp_list_add_int64 (map, (int64_t)(val)); \ + }) + + +/** Loop through all elements of a map. + * @param map + * @param ptr pointer to a map_node_stat, map_node_int64 or map_node_str + * + * @b Example: + * @include foreach.c + */ + +#define foreach(map, ptr) \ + for (ptr = (typeof(ptr))_stp_map_start(map); ptr; \ + ptr = (typeof(ptr))_stp_map_iter (map, (struct map_node *)ptr)) + diff --git a/runtime/runtime.h b/runtime/runtime.h new file mode 100644 index 000000000..0876512f7 --- /dev/null +++ b/runtime/runtime.h @@ -0,0 +1,18 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "alloc.h" +#include "map.h" + +#define dbug(args...) ; + diff --git a/runtime/tests/Makefile b/runtime/tests/Makefile new file mode 100644 index 000000000..4e744d258 --- /dev/null +++ b/runtime/tests/Makefile @@ -0,0 +1,3 @@ +tests: + tclsh all.tcl + diff --git a/runtime/tests/README b/runtime/tests/README new file mode 100644 index 000000000..a94570115 --- /dev/null +++ b/runtime/tests/README @@ -0,0 +1,4 @@ +The *.c files test associative arrays (maps). "make tests" to run. + +test4_probe and shellsnoop are sample probes that use the new runtime. + diff --git a/runtime/tests/all.tcl b/runtime/tests/all.tcl new file mode 100644 index 000000000..2d44d6bbd --- /dev/null +++ b/runtime/tests/all.tcl @@ -0,0 +1,11 @@ +package require tcltest +namespace import -force tcltest::* + +puts "Running all SystemTap tests" + +#puts [tcltest::configure] +#puts [tcltest::configure -file] + +tcltest::runAllTests + +puts "All tests completed" diff --git a/runtime/tests/map.test b/runtime/tests/map.test new file mode 100644 index 000000000..1cbb73670 --- /dev/null +++ b/runtime/tests/map.test @@ -0,0 +1,385 @@ +package require tcltest +namespace import -force tcltest::* + +set CFLAGS {-O3} + +test long_int64_1 {Test of long keys and int64 values} -setup { + exec gcc $CFLAGS -o test testl64.c +} -body { + exec ./test +} -result {mymap[1]=2 +mymap[101]=202 mymap[1]=2 mymap[42]=83 +mymap[42]=84 +mymap[1024]=2048 +mymap[1024]=0 +mymap[10]=0 + +mymap[1] = 2 +mymap[42] = 84 +mymap[101] = 202 + +mymap[42] = 84 +mymap[101] = 202 + +mymap[101] = 202 + + +mymap[10]=20 +mymap[0] = 100 +mymap[1] = 102 +mymap[2] = 104 +mymap[3] = 106 + +mymap[5] = 1005 +mymap[382] = 1382 +mymap[526] = 1526 +mymap[903] = 1903 + +mymap[5] = 1005 +mymap[526] = 1526 +mymap[903] = 1903 + +mymap[526] = 1526 +mymap[903] = 1903 + +mymap[526] = 1526 +} + +test long_int64_2 {Range test of long keys and int64 values} -setup { + exec gcc $CFLAGS -o test testl64R.c +} -body { + exec ./test +} -result {mymap[1] = -9223372036854775808 +mymap[2] = 9223372036854775807 +mymap[4] = -1 +mymap[5] = 5 +mymap[999996] = 1999992 +mymap[999997] = 1999994 +mymap[999998] = 1999996 +mymap[999999] = 1999998} + +# same test as long_int64_1, except dynamic alloc +test long_int64_3 {Test of long keys and int64 values, dynamic allocation} -setup { + exec gcc $CFLAGS -o test testl64_alloc.c +} -body { + exec ./test +} -result {mymap[1]=2 +mymap[101]=202 mymap[1]=2 mymap[42]=83 +mymap[42]=84 +mymap[1024]=2048 +mymap[1024]=0 +mymap[10]=0 + +mymap[1] = 2 +mymap[42] = 84 +mymap[101] = 202 + +mymap[42] = 84 +mymap[101] = 202 + +mymap[101] = 202 + + +mymap[10]=20 +mymap[10] = 20 +mymap[0] = 100 +mymap[1] = 102 +mymap[2] = 104 +mymap[3] = 106 + +mymap[5] = 1005 +mymap[382] = 1382 +mymap[526] = 1526 +mymap[903] = 1903 + +mymap[5] = 1005 +mymap[526] = 1526 +mymap[903] = 1903 + +mymap[526] = 1526 +mymap[903] = 1903 + +mymap[526] = 1526 +} + +test long_long_int64_1 {Test of long,long keys and int64 values} -setup { + exec gcc $CFLAGS -o test testll64.c +} -body { + exec ./test +} -result {mymap[1,1]=1 +mymap[1,2]=2 +mymap[2,1]=3 +mymap[1,1] = 1 +mymap[1,2] = 2 +mymap[2,1] = 3} + +test str_int64_4 {Test of string keys and int64 values} -setup { + exec gcc $CFLAGS -o test teststr.c +} -body { + exec ./test +} -result {mymap[two]=2 +mymap[two-oh-two]=202 mymap[two]=2 mymap[eighty-four]=83 +mymap[eighty-four]=84 + +mymap[two] = 2 +mymap[eighty-four] = 84 +mymap[two-oh-two] = 202 +mymap[0123456789] = 1000000 +mymap[2048]=2048 +mymap[2048]=0 +mymap[10]=0 + +mymap[eighty-four] = 84 +mymap[two-oh-two] = 202 +mymap[0123456789] = 1000000 + +mymap[eighty-four] = 84 +mymap[0123456789] = 1000000 + +mymap[0123456789] = 1000000 + + +mymap[Ohio]=10123456 +mymap[Ohio] = 10123456 + +mymap[test_number_0] = 1000 +mymap[test_number_1] = 1001 +mymap[test_number_2] = 1002 +mymap[test_number_3] = 1003} + +test str_str_int64_1 {Test of string,string keys and int64 values} -setup { + exec gcc $CFLAGS -o test teststrstr.c +} -body { + exec ./test +} -result {mymap[two,three]=6 +mymap[two-oh-two,four]=808 mymap[two,three]=6 mymap[eighty-four,two]=167 +mymap[eighty-four,two]=168 + +mymap[two,three] = 6 +mymap[eighty-four,two] = 168 +mymap[two-oh-two,four] = 808 +mymap[0123456789,foo] = 1000000 +mymap[2048,2]=4096 +mymap[2048,2]=0 +mymap[10,six]=0 + +mymap[eighty-four,two] = 168 +mymap[two-oh-two,four] = 808 +mymap[0123456789,foo] = 1000000 + +mymap[eighty-four,two] = 168 +mymap[0123456789,foo] = 1000000 + +mymap[eighty-four,two] = 168 +mymap[0123456789,foo] = 1000000 +mymap[Ohio,1801] = 10123456 + +mymap[test_number_2,**test number 4**] = 8 +mymap[test_number_3,**test number 9**] = 27 +mymap[test_number_4,**test number 16**] = 64 +mymap[test_number_5,**test number 25**] = 125} + + +test str_long_int64_1 {Test of string,long keys and int64 values} -setup { + exec gcc $CFLAGS -o test teststrlong.c +} -body { + exec ./test +} -result {map[two,3]=6 +map[two-oh-two,4]=808 +map[two,3]=6 +map[eighty-four,2]=167 +map[eighty-four,2]=168 + +map[two,3] = 6 +map[eighty-four,2] = 168 +map[two-oh-two,4] = 808 +map[0123456789,4444] = 1000000 + +map[2048,2]=4096 +mymap[2048,2]=0 +mymap[six,10]=0 + +map[eighty-four,2] = 168 +map[two-oh-two,4] = 808 +map[0123456789,4444] = 1000000 + + +map[eighty-four,2] = 168 +map[0123456789,4444] = 1000000 + + +map[eighty-four,2] = 168 +map[0123456789,4444] = 1000000 +map[Ohio,1801] = 10123456 + + +map[test_number_2,2] = 8 +map[test_number_3,3] = 27 +map[test_number_4,4] = 64 +map[test_number_5,5] = 125 + +Should be empty: +} + + +test long_str_int64_1 {Test of long,string keys and int64 values} -setup { + exec gcc $CFLAGS -o test testlongstr.c +} -body { + exec ./test +} -result {map[3,two]=6 +map[4,two-oh-two]=808 +map[3,two]=6 +map[2,eighty-four]=167 +map[2,eighty-four]=168 + +map[3,two] = 6 +map[2,eighty-four] = 168 +map[4,two-oh-two] = 808 +map[4444,0123456789] = 1000000 + +map[2048,2]=4096 +mymap[2048,2]=0 +mymap[10,six]=0 + +map[2,eighty-four] = 168 +map[4,two-oh-two] = 808 +map[4444,0123456789] = 1000000 + + +map[2,eighty-four] = 168 +map[4444,0123456789] = 1000000 + + +map[2,eighty-four] = 168 + + + + +map[1801,Ohio] = 10123456 + + +map[2,test_number_2] = 8 +map[3,test_number_3] = 27 +map[4,test_number_4] = 64 +map[5,test_number_5] = 125 + +Should be empty: +} + +test str_str_str_1 {Test of string,string keys and string values} -setup { + exec gcc $CFLAGS -o test teststrstrstr.c +} -body { + exec ./test +} -result {map[two,2]=four +map[two-two-one-B,Baker Street]=7% solution +map[two,2]=four +map[eighty-four,nineteen hundred]=nineteen hundred and eighty-three +map[eighty-four,nineteen hundred]=nineteen hundred and eighty-four + +map[two,2] = four +map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four +map[two-two-one-B,Baker Street] = 7% solution +map[0123456789,4444] = 1000000 + +map[2048,2]=4096 +mymap[2048,2]=(null) +mymap[six,10]=(null) + +map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four +map[two-two-one-B,Baker Street] = 7% solution +map[0123456789,4444] = 1000000 + + +map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four +map[0123456789,4444] = 1000000 + + +map[eighty-four,nineteen hundred] = nineteen hundred and eighty-four +map[0123456789,4444] = 1000000 +map[abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,(null)] = TESTING 1,2,3 +map[abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZhiasdhgfiudsgfiusdgfisdugfisdugfsdiufgsdfiugsdifugsdiufgsdiufgisdugfisdugfigsdfiusdgfiugsdifu sdfigsdifugsdifugsdiufgsdiufgisdugfiudsgfisudgfiusdgfiusdgfisdugfisdufgiusdfgsdiufgdsiufgsdiufgsdiufgsdiufgwiugfw89e4rf98yf897ywef98wyef98wyf98wyf89ys9d8yfsd sdfysd98fy9s8fyds98fy98dsfy89sdfy,yw98fty98sfts98d7fts89d7f9sdfoooooooooooooooooooooooooooooooooooooooooooof8eo7stfew87fwet8tw87rf7fpowft7ewfptpwefpwetfpwepwfwetfp8we] = TESTING 1,2,3 ***************************************************************************************************************************************************************************************************************************************************************************** 4,5,6 + + +map[test_number_2,TEST_NUMBER_4] = TEST_NUMBER_8 +map[test_number_3,TEST_NUMBER_9] = TEST_NUMBER_27 +map[test_number_4,TEST_NUMBER_16] = TEST_NUMBER_64 +map[test_number_5,TEST_NUMBER_25] = TEST_NUMBER_125 + +Should be empty: +} + +test stat_1 {Test of string,long keys and stat values} -setup { + exec gcc $CFLAGS -o test teststat.c +} -body { + exec ./test +} -result {map[created with set,2001] = [c=5 s=125 minmax =2,42] +map[created with set,2001] = [c=6 s=142 minmax =2,42] +map[created with add,2020] = [c=1 s=1700 minmax =1700,1700] +map[created with add,2020] = [c=2 s=1702 minmax =2,1700] +map[created with add,2020] = [c=3 s=4047 minmax =2,2345] + +map[created with set,2001] = [c=6 s=142 minmax =2,42] +map[created with add,2020] = [c=3 s=4047 minmax =2,2345] + + +map[created with add,2020] = [c=3 s=4047 minmax =2,2345] + + +map[created with add,2020] = [c=5 s=123456 minmax =2,42] + + + +map[created with add,1234] = [c=2 s=100 minmax =42,58] + +map[created with add,1234] = [c=2 s=100 minmax =42,58] +} + +test list_1 {Test of List of string values} -setup { + exec gcc $CFLAGS -o test testlist.c +} -body { + exec ./test +} -result {map[0] = Item0 +map[1] = Item1 +map[2] = Item2 +map[3] = Item3 +map[4] = Item4 +map[5] = Item5 +map[6] = Item6 +map[7] = Item7 +map[8] = Item8 +map[9] = Item9 + +size is 10 +map[0] = Item0 +map[1] = Item1 +map[2] = Item2 +map[3] = Item3 +map[4] = Item4 +map[5] = Item5 +map[6] = Item6 +map[7] = Item7 +map[8] = Item8 +map[9] = Item9 + +map[0] = Item0 +map[1] = Item1 +map[2] = Item2 +map[3] = Item3 +map[4] = Item4 +map[5] = Item5 +map[6] = Item6 +map[7] = Item7 +map[8] = Item8 +map[9] = Item9 + + +map[0] = Item50 +map[1] = Item51 +map[2] = Item52 +map[3] = Item53 +map[4] = Item54 +} + +exec rm test + +cleanupTests diff --git a/runtime/tests/shellsnoop/Makefile b/runtime/tests/shellsnoop/Makefile new file mode 100644 index 000000000..86d612662 --- /dev/null +++ b/runtime/tests/shellsnoop/Makefile @@ -0,0 +1,9 @@ +# Makefile +# +# make -C path/to/kernel/src M=`pwd` modules + +obj-m := dtr.o + + + + diff --git a/runtime/tests/shellsnoop/README b/runtime/tests/shellsnoop/README new file mode 100644 index 000000000..ce37a2db8 --- /dev/null +++ b/runtime/tests/shellsnoop/README @@ -0,0 +1,70 @@ +Sample probe. + +To build, edit the path in buildit and the addresses in struct dtr_probes +in dtr.c Then "source buildit" + +This is a translation of on an old dtr probe: + +# shellsnoop.probe - snoop shell execution as it occurs. +# clone of dtrace shellsnoop example + +global { + long @pids[long]; +} + +probe do_execve:entry { + char __user *vstr; + char str[256]; + int len; + + /* watch shells only */ + /* FIXME: detect more shells, like csh, tcsh, zsh */ + + if (!strcmp(current->comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh") + || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh")) + { + dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename); + @pids[current->pid] = 1; + + /* print out argv, ignoring argv[0] */ + if (argv) argv++; + while (argv != NULL) + { + if (get_user (vstr, argv)) + break; + if (!vstr) + break; + len = dtr_strncpy_from_user(str, vstr, 256); + str[len] = 0; + printk ("%s ", str); + argv++; + } + printk ("\n"); + } +} + +# use filp_open because copy_from_user not needed there +probe filp_open:entry { + if (@pids[current->pid]) + dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename); +} + +probe sys_read:entry { + if (@pids[current->pid]) + dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd); +} + +probe sys_write:entry { + size_t len; + char str[256]; + if (@pids[current->pid]) + { + if (count < 64) len = count; + else len = 64; + if (len = dtr_strncpy_from_user(str, buf, len)) { + str[len] = 0; + dlog ("%d\t%d\t%s\tW %s\n", current->pid, current->parent->pid, current->comm, str); + } + } +} + diff --git a/runtime/tests/shellsnoop/buildit b/runtime/tests/shellsnoop/buildit new file mode 100644 index 000000000..8d90a0ec8 --- /dev/null +++ b/runtime/tests/shellsnoop/buildit @@ -0,0 +1 @@ +make -C /lib/modules/2.6.10-1.770_FC3smp/build M=`pwd` diff --git a/runtime/tests/shellsnoop/dtr.c b/runtime/tests/shellsnoop/dtr.c new file mode 100644 index 000000000..790a907a0 --- /dev/null +++ b/runtime/tests/shellsnoop/dtr.c @@ -0,0 +1,130 @@ +#define HASH_TABLE_BITS 8 +#define HASH_TABLE_SIZE (1<comm,"bash") || !strcmp(current->comm,"sh") || !strcmp(current->comm, "zsh") + || !strcmp(current->comm, "tcsh") || !strcmp(current->comm, "pdksh")) + { + dlog ("%d\t%d\t%d\t%s ", current->uid, current->pid, current->parent->pid, filename); + + _stp_map_key_long (pids, current->pid); + _stp_map_set_int64 (pids, 1); + + _stp_copy_argv_from_user (arglist, argv); + foreach (arglist, ptr) + printk ("%s ", ptr->str); + printk ("\n"); + } + jprobe_return(); + return 0; +} + +struct file * inst_filp_open (const char * filename, int flags, int mode) +{ + _stp_map_key_long (pids, current->pid); + if (_stp_map_get_int64 (pids)) + dlog ("%d\t%d\t%s\tO %s\n", current->pid, current->parent->pid, current->comm, filename); + + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) +{ + _stp_map_key_long (pids, current->pid); + if (_stp_map_get_int64 (pids)) + dlog ("%d\t%d\t%s\tR %d\n", current->pid, current->parent->pid, current->comm, fd); + + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) +{ + size_t len; + char str[256]; + _stp_map_key_long (pids, current->pid); + if (_stp_map_get_int64 (pids)) + { + if (count < 64) + len = count; + else + len = 64; + len = _stp_strncpy_from_user(str, buf, len); + if (len < 0) len = 0; + str[len] = 0; + dlog ("%d\t%d\t%s\tW %s\n", current->pid, current->parent->pid, current->comm, str); + } + + jprobe_return(); + return 0; +} + +static struct jprobe dtr_probes[] = { + { + .kp.addr = (kprobe_opcode_t *)0xffffffff8017b034, + .entry = (kprobe_opcode_t *) inst_do_execve + }, + { + .kp.addr = (kprobe_opcode_t *)0xffffffff80170706, + .entry = (kprobe_opcode_t *) inst_filp_open + }, + { + .kp.addr = (kprobe_opcode_t *)0xffffffff801711dd, + .entry = (kprobe_opcode_t *) inst_sys_read + }, + { + .kp.addr = (kprobe_opcode_t *)0xffffffff8017124b, + .entry = (kprobe_opcode_t *) inst_sys_write + }, +}; + +#define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe)) + +static int init_dtr(void) +{ + int i; + + pids = _stp_map_new (10000, INT64); + arglist = _stp_list_new (10, STRING); + + for (i = 0; i < MAX_DTR_ROUTINE; i++) { + printk("DTR: plant jprobe at %p, handler addr %p\n", + dtr_probes[i].kp.addr, dtr_probes[i].entry); + register_jprobe(&dtr_probes[i]); + } + printk("DTR: instrumentation is enabled...\n"); + return 0; +} + +static void cleanup_dtr(void) +{ + int i; + + for (i = 0; i < MAX_DTR_ROUTINE; i++) + unregister_jprobe(&dtr_probes[i]); + + _stp_map_del (pids); + printk("DTR: EXIT\n"); +} + +module_init(init_dtr); +module_exit(cleanup_dtr); +MODULE_LICENSE("GPL"); + diff --git a/runtime/tests/test.h b/runtime/tests/test.h new file mode 100644 index 000000000..8eed16bd9 --- /dev/null +++ b/runtime/tests/test.h @@ -0,0 +1,233 @@ +/* include file for testing maps without running in the kernel */ + +#include +#include +#include +#include +#include +#include +#include + +static inline unsigned long hash_long(unsigned long val, unsigned int bits) +{ + unsigned long hash = val; + +#if __WORDSIZE == 64 + /* Sigh, gcc can't optimise this alone like it does for 32 bits. */ + unsigned long n = hash; + n <<= 18; + hash -= n; + n <<= 33; + hash -= n; + n <<= 3; + hash += n; + n <<= 3; + hash -= n; + n <<= 4; + hash += n; + n <<= 2; + hash += n; +#else + /* On some cpus multiply is faster, on others gcc will do shifts */ + hash *= 0x9e370001UL; +#endif + + /* High bits are more random, so use them. */ + return hash >> (8*sizeof(long) - bits); +} + + +#define STRINGLEN 128 +#define HASH_ELEM_NUM 5000 +#define HASH_TABLE_BITS 8 +#define HASH_TABLE_SIZE (1<next = (ptr); (ptr)->prev = (ptr); \ +} while (0) + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; +} + +static inline void list_add(struct list_head *new, struct list_head *head) +{ + __list_add(new, head, head->next); +} + + +static inline void list_add_tail(struct list_head *new, struct list_head *head) +{ + __list_add(new, head->prev, head); +} +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_head * prev, struct list_head * next) +{ + next->prev = prev; + prev->next = next; +} + +static inline void list_del(struct list_head *entry) +{ + __list_del(entry->prev, entry->next); + entry->next = LIST_POISON1; + entry->prev = LIST_POISON2; +} + +static inline int list_empty(const struct list_head *head) +{ + return head->next == head; +} + +static inline void list_move_tail(struct list_head *list, + struct list_head *head) +{ + __list_del(list->prev, list->next); + list_add_tail(list, head); +} + + +struct hlist_head { + struct hlist_node *first; +}; + +struct hlist_node { + struct hlist_node *next, **pprev; +}; +#define HLIST_HEAD_INIT { .first = NULL } +#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } +#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) +#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL) + +static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) +{ + struct hlist_node *first = h->first; + n->next = first; + if (first) + first->pprev = &n->next; + h->first = n; + n->pprev = &h->first; +} + +#define hlist_for_each(pos, head) \ + for (pos = (head)->first; pos; pos = pos->next) + +#define hlist_entry(ptr, type, member) container_of(ptr,type,member) + +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +static inline void __hlist_del(struct hlist_node *n) +{ + struct hlist_node *next = n->next; + struct hlist_node **pprev = n->pprev; + *pprev = next; + if (next) + next->pprev = pprev; +} + +static inline void hlist_del(struct hlist_node *n) +{ + __hlist_del(n); + n->next = LIST_POISON1; + n->pprev = LIST_POISON2; +} + +static inline void hlist_del_init(struct hlist_node *n) +{ + if (n->pprev) { + __hlist_del(n); + INIT_HLIST_NODE(n); + } +} + +static inline void hlist_add_before(struct hlist_node *n, + struct hlist_node *next) +{ + n->pprev = next->pprev; + n->next = next; + next->pprev = &n->next; + *(n->pprev) = n; +} + +#define GFP_ATOMIC 0 + +void *kmalloc (size_t len, int flags) +{ + return malloc (len); +} + +void *vmalloc (size_t len) +{ + return malloc (len); +} + +#define kfree(x) free(x) +#define vfree(x) free(x) + +/***** END OF KERNEL STUFF ********/ + +#ifdef DEBUG +#define dbug(args...) \ + { \ + printf("%s:%d: ", __FUNCTION__, __LINE__); \ + printf(args); \ + } +#else +#define dbug(args...) ; +#endif + +#define dlog(args...) printf(args); + +#include "../alloc.h" +#include "../map.h" +#include "../map.c" + +/* handle renamed functions */ +#define map_new _stp_map_new +#define map_key_del _stp_map_key_del +#define map_start _stp_map_start +#define map_iter _stp_map_iter +#define map_get_str _stp_map_get_str +#define map_set_int64 _stp_map_set_int64 +#define map_get_int64 _stp_map_get_int64 +#define map_key_str_str _stp_map_key_str_str +#define map_key_str _stp_map_key_str +#define map_key_long _stp_map_key_long +#define map_key_long_long _stp_map_key_long_long +#define map_set_stat _stp_map_set_stat diff --git a/runtime/tests/test4_probe/Makefile b/runtime/tests/test4_probe/Makefile new file mode 100644 index 000000000..86d612662 --- /dev/null +++ b/runtime/tests/test4_probe/Makefile @@ -0,0 +1,9 @@ +# Makefile +# +# make -C path/to/kernel/src M=`pwd` modules + +obj-m := dtr.o + + + + diff --git a/runtime/tests/test4_probe/README b/runtime/tests/test4_probe/README new file mode 100644 index 000000000..a503c28e2 --- /dev/null +++ b/runtime/tests/test4_probe/README @@ -0,0 +1,23 @@ +Sample probe. + +To build, edit the path in buildit and the addresses in struct dtr_probes +in dtr.c Then "source buildit" + +This is a translation of on an old dtr probe: + +global { + long @opens[string]; + sum @reads[string], @writes[string]; +} + +probe sys_open:entry { + @opens[current->comm]++; +} + +probe sys_read:entry { + @reads[current->comm] << count; +} + +probe sys_write:entry { + @writes[current->comm] << count; +} diff --git a/runtime/tests/test4_probe/buildit b/runtime/tests/test4_probe/buildit new file mode 100644 index 000000000..8d90a0ec8 --- /dev/null +++ b/runtime/tests/test4_probe/buildit @@ -0,0 +1 @@ +make -C /lib/modules/2.6.10-1.770_FC3smp/build M=`pwd` diff --git a/runtime/tests/test4_probe/dtr.c b/runtime/tests/test4_probe/dtr.c new file mode 100644 index 000000000..0396da896 --- /dev/null +++ b/runtime/tests/test4_probe/dtr.c @@ -0,0 +1,108 @@ +#define HASH_TABLE_BITS 8 +#define HASH_TABLE_SIZE (1<comm); + _stp_map_set_int64 (opens, _stp_map_get_int64(opens) + 1); + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_read (unsigned int fd, char __user * buf, size_t count) +{ + _stp_map_key_str (reads, current->comm); + _stp_map_stat_add (reads, count); + jprobe_return(); + return 0; +} + +asmlinkage ssize_t inst_sys_write (unsigned int fd, const char __user * buf, size_t count) +{ + _stp_map_key_str (writes, current->comm); + _stp_map_stat_add (writes, count); + jprobe_return(); + return 0; +} + +static struct jprobe dtr_probes[] = { + { + .kp.addr = (kprobe_opcode_t *)0xc0166f32, + .entry = (kprobe_opcode_t *) inst_sys_open + }, + { + .kp.addr = (kprobe_opcode_t *)0xc0167b93, + .entry = (kprobe_opcode_t *) inst_sys_read + }, + { + .kp.addr = (kprobe_opcode_t *)0xc0167bf5, + .entry = (kprobe_opcode_t *) inst_sys_write + }, +}; + +#define MAX_DTR_ROUTINE (sizeof(dtr_probes)/sizeof(struct jprobe)) + +static int init_dtr(void) +{ + int i; + + opens = _stp_map_new (1000, INT64); + reads = _stp_map_new (1000, STAT); + writes = _stp_map_new (1000, STAT); + + for (i = 0; i < MAX_DTR_ROUTINE; i++) { + printk("DTR: plant jprobe at %p, handler addr %p\n", + dtr_probes[i].kp.addr, dtr_probes[i].entry); + register_jprobe(&dtr_probes[i]); + } + printk("DTR: instrumentation is enabled...\n"); + return 0; +} + +static void cleanup_dtr(void) +{ + int i; + struct map_node_stat *st; + struct map_node_int64 *ptr; + + for (i = 0; i < MAX_DTR_ROUTINE; i++) + unregister_jprobe(&dtr_probes[i]); + + for (ptr = (struct map_node_int64 *)_stp_map_start(opens); ptr; + ptr = (struct map_node_int64 *)_stp_map_iter (opens,(struct map_node *)ptr)) + dlog ("opens[%s] = %lld\n", key1str(ptr), ptr->val); + dlog ("\n"); + + for (st = (struct map_node_stat *)_stp_map_start(reads); st; + st = (struct map_node_stat *)_stp_map_iter (reads,(struct map_node *)st)) + dlog ("reads[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), st->stats.count, st->stats.sum, + st->stats.min, st->stats.max); + dlog ("\n"); + + for (st = (struct map_node_stat *)_stp_map_start(writes); st; + st = (struct map_node_stat *)_stp_map_iter (writes,(struct map_node *)st)) + dlog ("writes[%s] = [count=%lld sum=%lld min=%lld max=%lld]\n", key1str(st), st->stats.count, st->stats.sum, + st->stats.min, st->stats.max); + dlog ("\n"); + + _stp_map_del (opens); + _stp_map_del (reads); + _stp_map_del (writes); + + printk("DTR: EXIT\n"); +} + +module_init(init_dtr); +module_exit(cleanup_dtr); +MODULE_LICENSE("GPL"); + diff --git a/runtime/tests/testl64.c b/runtime/tests/testl64.c new file mode 100644 index 000000000..62b436411 --- /dev/null +++ b/runtime/tests/testl64.c @@ -0,0 +1,134 @@ +#include "test.h" + +/* testl64.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - long + val - INT64 + + Testing circular buffers, set, get +*/ + +int main () +{ + MAP mymap = map_new(4, INT64); + + map_key_long (mymap, 1); + map_set_int64 (mymap, 2); + printf ("mymap[%d]=%ld\n", 1, map_get_int64(mymap)); + + map_key_long (mymap, 42); + map_set_int64 (mymap, 83); + + map_key_long (mymap, 101); + map_set_int64 (mymap, 202); + /* at this point, we have 1, 42, and 101 in the array */ + + printf ("mymap[%d]=%ld ", 101, map_get_int64(mymap)); + map_key_long (mymap, 1); + printf ("mymap[%d]=%ld ", 1, map_get_int64(mymap)); + map_key_long (mymap, 42); + printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap)); + + map_set_int64 (mymap, 84); + printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap)); + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + map_key_long (mymap, 0); + map_key_del (mymap); + map_key_long (mymap, 77); + map_key_del (mymap); + map_key_del (mymap); + map_set_int64 (mymap,1000000); + + /* create and delete a key */ + map_key_long (mymap, 1024); + map_set_int64 (mymap, 2048); + map_key_long (mymap, 1024); + printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap)); + map_key_del (mymap); + printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap)); + map_key_long (mymap, 10); + printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap)); + + printf ("\n"); + struct map_node_int64 *ptr; + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + + printf ("\n"); + map_key_long (mymap, 1); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + printf ("\n"); + map_key_long (mymap, 42); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + + printf ("\n"); + map_key_long (mymap, 101); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + printf ("\n"); + + map_key_long (mymap, 10); map_set_int64 (mymap, 20); + printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap)); + + /* add 4 new entries, pushing "10" out */ + int i; + for (i = 0; i < 4; i++) + { + map_key_long (mymap, i); + map_set_int64 (mymap, 100 + 2 * i); + } + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + printf ("\n"); + /* 5, 382, 526, and 903 all hash to the same value (23) */ + /* use them to test the hash chain */ + map_key_long (mymap, 5); map_set_int64 (mymap, 1005); + map_key_long (mymap, 382); map_set_int64 (mymap, 1382); + map_key_long (mymap, 526); map_set_int64 (mymap, 1526); + map_key_long (mymap, 903); map_set_int64 (mymap, 1903); + + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 382); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 5); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 903); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 526); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + return 0; +} diff --git a/runtime/tests/testl64R.c b/runtime/tests/testl64R.c new file mode 100644 index 000000000..b5db72280 --- /dev/null +++ b/runtime/tests/testl64R.c @@ -0,0 +1,50 @@ +#include "test.h" + +#define LLONG_MAX 9223372036854775807LL +#define LLONG_MIN (-LLONG_MAX - 1LL) + +/* testl64R.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - long + val - INT64 + + Testing range of values +*/ + +int main () +{ + struct map_node_int64 *ptr; + MAP mymap = map_new(4, INT64); + + map_key_long (mymap, 1); + map_set_int64 (mymap, LLONG_MIN); + map_key_long (mymap, 2); + map_set_int64 (mymap, LLONG_MAX); + map_key_long (mymap, 3); + map_set_int64 (mymap, 0); /* will not be saved */ + map_key_long (mymap, 4); + map_set_int64 (mymap, -1); + map_key_long (mymap, 5); + map_set_int64 (mymap, 5); + + + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %lld\n", key1int(ptr), (long long)ptr->val); + + + /* stress test - create a million entries then print last 4 */ + int i; + for (i = 0; i < 1000000; i++) + { + map_key_long (mymap, i); + map_set_int64 (mymap, i+i); + } + + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %lld\n", key1int(ptr), (long long)ptr->val); + + return 0; +} diff --git a/runtime/tests/testl64_alloc.c b/runtime/tests/testl64_alloc.c new file mode 100644 index 000000000..fcfa6cf54 --- /dev/null +++ b/runtime/tests/testl64_alloc.c @@ -0,0 +1,139 @@ +#include "test.h" + +/* testl64_alloc.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - long + val - INT64 + uses kalloc to allocate buffers dynamically. No circular buffers +*/ + +int main () +{ + MAP mymap = map_new(0, INT64); + + map_key_long (mymap, 1); + map_set_int64 (mymap, 2); + printf ("mymap[%d]=%ld\n", 1, map_get_int64(mymap)); + + map_key_long (mymap, 42); + map_set_int64 (mymap, 83); + + map_key_long (mymap, 101); + map_set_int64 (mymap, 202); + /* at this point, we have 1, 42, and 101 in the array */ + + printf ("mymap[%d]=%ld ", 101, map_get_int64(mymap)); + map_key_long (mymap, 1); + printf ("mymap[%d]=%ld ", 1, map_get_int64(mymap)); + map_key_long (mymap, 42); + printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap)); + + map_set_int64 (mymap, 84); + printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap)); + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + map_key_long (mymap, 0); + map_key_del (mymap); + map_key_long (mymap, 77); + map_key_del (mymap); + map_key_del (mymap); + map_set_int64 (mymap,1000000); + + /* create and delete a key */ + map_key_long (mymap, 1024); + map_set_int64 (mymap, 2048); + map_key_long (mymap, 1024); + printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap)); + map_key_del (mymap); + printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap)); + map_key_long (mymap, 10); + printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap)); + + printf ("\n"); + struct map_node_int64 *ptr; + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + + printf ("\n"); + map_key_long (mymap, 1); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + printf ("\n"); + map_key_long (mymap, 42); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + + printf ("\n"); + map_key_long (mymap, 101); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + printf ("\n"); + + map_key_long (mymap, 10); map_set_int64 (mymap, 20); + printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap)); + + /* add 4 new entries, NOT pushing "10" out */ + int i; + for (i = 0; i < 4; i++) + { + map_key_long (mymap, i); + map_set_int64 (mymap, 100 + 2 * i); + } + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 10); map_key_del (mymap); + map_key_long (mymap, 3); map_key_del (mymap); + map_key_long (mymap, 2); map_key_del (mymap); + map_key_long (mymap, 1); map_key_del (mymap); + map_key_long (mymap, 0); map_key_del (mymap); + + /* 5, 382, 526, and 903 all hash to the same value (23) */ + /* use them to test the hash chain */ + map_key_long (mymap, 5); map_set_int64 (mymap, 1005); + map_key_long (mymap, 382); map_set_int64 (mymap, 1382); + map_key_long (mymap, 526); map_set_int64 (mymap, 1526); + map_key_long (mymap, 903); map_set_int64 (mymap, 1903); + + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 382); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 5); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 903); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + map_key_long (mymap, 526); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", key1int(ptr), (int)ptr->val); + + return 0; +} diff --git a/runtime/tests/testlist.c b/runtime/tests/testlist.c new file mode 100644 index 000000000..7086ff9bf --- /dev/null +++ b/runtime/tests/testlist.c @@ -0,0 +1,63 @@ +#include "test.h" + +/* testliat.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + Tests maps acting as Lists +*/ + + + +static void +map_dump (MAP map) +{ + struct map_node_str *ptr; + foreach (map, ptr) + printf ("map[%ld] = %s\n", key1int(ptr), ptr->str); + printf ("\n"); +} + + +int main () +{ + char buf[32]; + int i; + MAP map = _stp_list_new(10, STRING); + + for (i = 0; i < 10; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + + map_dump(map); + printf ("size is %d\n", _stp_list_size(map)); + + /* we set a limit of 10 elements so these push */ + /* the first entries out of the list */ + for (i = 50; i < 55; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + + map_dump(map); + + for (i = 0; i < 10; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + + map_dump(map); + _stp_list_clear (map); + map_dump(map); + for (i = 50; i < 55; i++) + { + sprintf (buf, "Item%d", i); + _stp_list_add_str (map, buf); + } + map_dump(map); + _stp_map_del (map); + return 0; +} diff --git a/runtime/tests/testll64.c b/runtime/tests/testll64.c new file mode 100644 index 000000000..bfe4ae940 --- /dev/null +++ b/runtime/tests/testll64.c @@ -0,0 +1,111 @@ +#include "test.h" + +/* testll64.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - long,long + val - INT64 + + Testing circular buffers, set, get +*/ + +int main () +{ + struct map_node_int64 *ptr; + MAP mymap = map_new(4, INT64); + + map_key_long_long (mymap, 1,1); + map_set_int64 (mymap, 1); + map_key_long_long (mymap, 1,2); + map_set_int64 (mymap, 2); + map_key_long_long (mymap, 2,1); + map_set_int64 (mymap, 3); + + map_key_long_long (mymap, 1,1); + printf ("mymap[1,1]=%ld\n", map_get_int64(mymap)); + map_key_long_long (mymap, 1,2); + printf ("mymap[1,2]=%ld\n", map_get_int64(mymap)); + map_key_long_long (mymap, 2,1); + printf ("mymap[2,1]=%ld\n", map_get_int64(mymap)); + +#if 0 + map_key_long (mymap, 42); + map_set_int64 (mymap, 83); + + map_key_long (mymap, 101); + map_set_int64 (mymap, 202); + /* at this point, we have 1, 42, and 101 in the array */ + + printf ("mymap[%d]=%ld ", 101, map_get_int64(mymap)); + map_key_long (mymap, 1); + printf ("mymap[%d]=%ld ", 1, map_get_int64(mymap)); + map_key_long (mymap, 42); + printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap)); + + map_set_int64 (mymap, 84); + printf ("mymap[%d]=%ld\n", 42, map_get_int64(mymap)); + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + map_key_long (mymap, 0); + map_key_del (mymap); + map_key_long (mymap, 77); + map_key_del (mymap); + map_key_del (mymap); + map_set_int64 (mymap,1000000); + + /* create and delete a key */ + map_key_long (mymap, 1024); + map_set_int64 (mymap, 2048); + map_key_long (mymap, 1024); + printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap)); + map_key_del (mymap); + printf ("mymap[%d]=%ld\n", 1024, map_get_int64(mymap)); + map_key_long (mymap, 10); + printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap)); + + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val); + + + printf ("\n"); + map_key_long (mymap, 1); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val); + + printf ("\n"); + map_key_long (mymap, 42); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val); + + + printf ("\n"); + map_key_long (mymap, 101); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld] = %d\n", ptr->key1.val, (int)ptr->val); + + printf ("\n"); + + map_key_long (mymap, 10); map_set_int64 (mymap, 20); + printf ("mymap[%d]=%ld\n", 10, map_get_int64(mymap)); + + /* add 4 new entries, pushing "10" out */ + int i; + for (i = 0; i < 4; i++) + { + map_key_long (mymap, i); + map_set_int64 (mymap, 100 + 2 * i); + } +#endif + + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%ld,%ld] = %d\n", key1int(ptr), key2int(ptr),(int)ptr->val); + + return 0; +} diff --git a/runtime/tests/testlongstr.c b/runtime/tests/testlongstr.c new file mode 100644 index 000000000..6dcfaf8b1 --- /dev/null +++ b/runtime/tests/testlongstr.c @@ -0,0 +1,120 @@ +#include "test.h" + +/* testlongstr.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - long,str + val - INT64 +*/ + + + +static void +map_dump (MAP map) +{ + struct map_node_int64 *ptr; + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(map); ptr; + ptr = (struct map_node_int64 *)map_iter (map, (struct map_node *)ptr)) + printf ("map[%ld,%s] = %lld\n", key1int(ptr), key2str(ptr), + (long long)ptr->val); + printf ("\n"); +} + +static void m_print (MAP map) +{ + struct map_node_int64 *m = (struct map_node_int64 *)map->key; + printf ("map[%ld,%s]=%lld\n", key1int(m), key2str(m), + (long long)map_get_int64(map)); +} +int main () +{ + MAP mymap = map_new(4, INT64); + + _stp_map_key2 (mymap, 3, "two"); + _stp_map_set (mymap, 6); + m_print (mymap); + + _stp_map_key2 (mymap, 2, "eighty-four"); + map_set_int64 (mymap, 167); + + _stp_map_key2 (mymap, 4, "two-oh-two"); + map_set_int64 (mymap, 808); + /* at this point, we have 6, 167, and 808 in the array */ + + m_print (mymap); + _stp_map_key2 (mymap, 3, "two"); + m_print (mymap); + _stp_map_key2 (mymap, 2, "eighty-four"); + m_print (mymap); + + map_set_int64 (mymap, 168); + m_print (mymap); + + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + _stp_map_key2 (mymap, 0, NULL); + map_key_del (mymap); + + _stp_map_key2 (mymap, 4444, "0123456789"); + map_set_int64 (mymap,1000000); + + map_dump (mymap); + + _stp_map_key2 (mymap, 77, "66"); + map_key_del (mymap); + map_key_del (mymap); + map_set_int64 (mymap,99999999); + + /* create and delete a key */ + _stp_map_key2 (mymap, 2048, "2"); + map_set_int64 (mymap, 4096); + + _stp_map_key2 (mymap, 2048, "2"); + m_print (mymap); + map_key_del (mymap); + + printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap)); + _stp_map_key2 (mymap, 10, "six"); + printf ("mymap[10,six]=%ld\n", map_get_int64(mymap)); + + map_dump(mymap); + + _stp_map_key2 (mymap, 4, "two-oh-two"); map_key_del (mymap); + map_dump(mymap); + + _stp_map_key2 (mymap, 4444, "0123456789"); map_key_del (mymap); + map_dump(mymap); + + _stp_map_key2 (mymap, 2, "eighty-four"); map_key_del (mymap); + map_dump(mymap); + + + _stp_map_key2 (mymap, 1801, "Ohio"); map_set_int64 (mymap, 10123456); + map_dump(mymap); + + /* add 4 new entries, pushing "Ohio" out */ + int i; + for (i = 2; i < 6; i++) + { + char buf[32]; + sprintf (buf, "test_number_%d", i); + _stp_map_key2 (mymap, (long)i, buf); + _stp_map_set_int64 (mymap, i*i*i); + } + map_dump (mymap); + + /* delete all entries */ + for (i = 2; i < 6; i++) + { + char buf[32]; + sprintf (buf, "test_number_%d", i); + _stp_map_key2 (mymap, (long)i, buf); + map_key_del (mymap); + } + + printf ("Should be empty: "); + map_dump (mymap); + return 0; +} diff --git a/runtime/tests/teststat.c b/runtime/tests/teststat.c new file mode 100644 index 000000000..d204a5850 --- /dev/null +++ b/runtime/tests/teststat.c @@ -0,0 +1,72 @@ +#include "test.h" + +/* teststat.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - str,long + val - stat +*/ + + + +static void +map_dump (MAP map) +{ + struct map_node_stat *ptr; + printf ("\n"); + foreach (map, ptr) + printf ("map[%s,%ld] = [c=%lld s=%lld minmax =%lld,%lld]\n", key1str(ptr), + key2int(ptr), ptr->stats.count, ptr->stats.sum, ptr->stats.min, ptr->stats.max); + printf ("\n"); +} + +static void m_print (MAP map) +{ + struct map_node_stat *m = (struct map_node_stat *)map->key; + stat *st = _stp_map_get_stat (map); + printf ("map[%s,%ld] = [c=%ld s=%ld minmax =%ld,%ld]\n", key1str(m), key2int(m), + (long)st->count, (long)st->sum, (long)st->min, (long)st->max); +} +int main () +{ + stat st, *stp; + + MAP mymap = map_new(4, STAT); + + st.count = 5; st.sum = 125; st.min = 2; st.max = 42; + _stp_map_key2 (mymap, "created with set", 2001 ); + map_set_stat (mymap, &st); + m_print (mymap); + + _stp_map_stat_add (mymap, 17); + m_print (mymap); + + _stp_map_key2 (mymap, "created with add", 2020 ); + _stp_map_stat_add (mymap, 1700); + m_print (mymap); + _stp_map_stat_add (mymap, 2); + m_print (mymap); + _stp_map_stat_add (mymap, 2345); + m_print (mymap); + + map_dump(mymap); + _stp_map_key2 (mymap, "created with set", 2001 ); map_key_del (mymap); + map_dump(mymap); + _stp_map_key2 (mymap, "created with add", 2020 ); + st.sum=123456; + map_set_stat (mymap, &st); + map_dump(mymap); + map_key_del (mymap); + map_dump(mymap); + + mymap = map_new(4, STAT); + _stp_map_key2 (mymap, "created with add", 1234 ); + _stp_map_stat_add (mymap, 42); + _stp_map_stat_add (mymap, 58); + stp = _stp_map_get_stat (mymap); + m_print(mymap); + map_dump(mymap); + _stp_map_del (mymap); + + return 0; +} diff --git a/runtime/tests/teststr.c b/runtime/tests/teststr.c new file mode 100644 index 000000000..e7b06a171 --- /dev/null +++ b/runtime/tests/teststr.c @@ -0,0 +1,117 @@ +#include "test.h" + +/* teststr.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - str + val - INT64 + + Testing circular buffers, set, get +*/ + +int main () +{ + struct map_node_int64 *ptr; + + MAP mymap = map_new(4, INT64); + + map_key_str (mymap, "two"); + map_set_int64 (mymap, 2); + printf ("mymap[two]=%ld\n", map_get_int64(mymap)); + + map_key_str (mymap, "eighty-four"); + map_set_int64 (mymap, 83); + + map_key_str (mymap, "two-oh-two"); + map_set_int64 (mymap, 202); + /* at this point, we have 2, 83, and 202 in the array */ + + printf ("mymap[two-oh-two]=%ld ",map_get_int64(mymap)); + map_key_str (mymap, "two"); + printf ("mymap[two]=%ld ", map_get_int64(mymap)); + map_key_str (mymap, "eighty-four"); + printf ("mymap[eighty-four]=%ld\n", map_get_int64(mymap)); + + map_set_int64 (mymap, 84); + printf ("mymap[eighty-four]=%ld\n", map_get_int64(mymap)); + + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + map_key_str (mymap, NULL); + map_key_del (mymap); + + map_key_str (mymap, "0123456789"); + map_set_int64 (mymap,1000000); + + printf ("\n"); + + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val); + + map_key_str (mymap, "77"); + map_key_del (mymap); + map_key_del (mymap); + map_set_int64 (mymap,99999999); + + /* create and delete a key */ + map_key_str (mymap, "2048"); + map_set_int64 (mymap, 2048); + + //map_key_str (mymap, "2048"); + printf ("mymap[2048]=%ld\n", map_get_int64(mymap)); + map_key_del (mymap); + + printf ("mymap[2048]=%ld\n", map_get_int64(mymap)); + map_key_str (mymap, "10"); + printf ("mymap[10]=%ld\n", map_get_int64(mymap)); + + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val); + + printf ("\n"); + map_key_str (mymap, "two-oh-two"); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val); + + printf ("\n"); + map_key_str (mymap, "eighty-four"); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val); + + printf ("\n"); + map_key_str (mymap, "0123456789"); map_key_del (mymap); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val); + + printf ("\n"); + + map_key_str (mymap, "Ohio"); map_set_int64 (mymap, 10123456); + printf ("mymap[Ohio]=%ld\n",map_get_int64(mymap)); + + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val); + printf ("\n"); + + /* add 4 new entries, pushing "Ohio" out */ + int i; + for (i = 0; i < 4; i++) + { + char buf[32]; + sprintf (buf, "test_number_%d", i); + map_key_str (mymap, buf); + map_set_int64 (mymap, 1000 + i); + } + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s] = %d\n", key1str(ptr), (int)ptr->val); + + return 0; +} diff --git a/runtime/tests/teststrlong.c b/runtime/tests/teststrlong.c new file mode 100644 index 000000000..83301d128 --- /dev/null +++ b/runtime/tests/teststrlong.c @@ -0,0 +1,114 @@ +#include "test.h" + +/* teststrlong.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - str,long + val - INT64 +*/ + + + +static void +map_dump (MAP map) +{ + struct map_node_int64 *ptr; + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(map); ptr; + ptr = (struct map_node_int64 *)map_iter (map, (struct map_node *)ptr)) + printf ("map[%s,%ld] = %lld\n", key1str(ptr), key2int(ptr), + (long long)ptr->val); + printf ("\n"); +} + +static void m_print (MAP map) +{ + struct map_node_int64 *m = (struct map_node_int64 *)map->key; + printf ("map[%s,%ld]=%lld\n", key1str(m), key2int(m), + (long long)map_get_int64(map)); +} +int main () +{ + MAP mymap = map_new(4, INT64); + + _stp_map_key2 (mymap, "two", 3); + _stp_map_set (mymap, 6); + m_print (mymap); + + _stp_map_key2 (mymap, "eighty-four", 2); + map_set_int64 (mymap, 167); + + _stp_map_key2 (mymap, "two-oh-two", 4); + map_set_int64 (mymap, 808); + /* at this point, we have 6, 167, and 808 in the array */ + + m_print (mymap); + _stp_map_key2 (mymap, "two", 3); + m_print (mymap); + _stp_map_key2 (mymap, "eighty-four", 2); + m_print (mymap); + + map_set_int64 (mymap, 168); + m_print (mymap); + + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + _stp_map_key2 (mymap, NULL, 0); + map_key_del (mymap); + + _stp_map_key2 (mymap, "0123456789", 4444); + map_set_int64 (mymap,1000000); + + map_dump (mymap); + + _stp_map_key2 (mymap, "77", 66); + map_key_del (mymap); + map_key_del (mymap); + map_set_int64 (mymap,99999999); + + /* create and delete a key */ + _stp_map_key2 (mymap, "2048", 2); + map_set_int64 (mymap, 4096); + + _stp_map_key2 (mymap, "2048", 2); + m_print (mymap); + map_key_del (mymap); + + printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap)); + _stp_map_key2 (mymap, "six", 10); + printf ("mymap[six,10]=%ld\n", map_get_int64(mymap)); + + map_dump(mymap); + + _stp_map_key2 (mymap, "two-oh-two", 4); map_key_del (mymap); + map_dump(mymap); + + + _stp_map_key2 (mymap, "Ohio", 1801); map_set_int64 (mymap, 10123456); + map_dump(mymap); + + /* add 4 new entries, pushing "Ohio" out */ + int i; + for (i = 2; i < 6; i++) + { + char buf[32]; + sprintf (buf, "test_number_%d", i); + _stp_map_key2 (mymap, buf, (long)i); + _stp_map_set_int64 (mymap, i*i*i); + } + map_dump (mymap); + + /* delete all entries */ + for (i = 2; i < 6; i++) + { + char buf[32]; + sprintf (buf, "test_number_%d", i); + _stp_map_key2 (mymap, buf, (long)i); + map_key_del (mymap); + } + + printf ("Should be empty: "); + map_dump (mymap); + return 0; +} diff --git a/runtime/tests/teststrstr.c b/runtime/tests/teststrstr.c new file mode 100644 index 000000000..86a2419b7 --- /dev/null +++ b/runtime/tests/teststrstr.c @@ -0,0 +1,103 @@ +#include "test.h" + +/* teststrstr.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - str,str + val - INT64 + + Testing circular buffers, set, get +*/ + +int main () +{ + struct map_node_int64 *ptr; + MAP mymap = map_new(4, INT64); + + map_key_str_str (mymap, "two", "three"); + map_set_int64 (mymap, 6); + printf ("mymap[two,three]=%ld\n", map_get_int64(mymap)); + + map_key_str_str (mymap, "eighty-four", "two"); + map_set_int64 (mymap, 167); + + map_key_str_str (mymap, "two-oh-two", "four"); + map_set_int64 (mymap, 808); + /* at this point, we have 6, 167, and 808 in the array */ + + printf ("mymap[two-oh-two,four]=%ld ",map_get_int64(mymap)); + map_key_str_str (mymap, "two", "three"); + printf ("mymap[two,three]=%ld ", map_get_int64(mymap)); + map_key_str_str (mymap, "eighty-four", "two"); + printf ("mymap[eighty-four,two]=%ld\n", map_get_int64(mymap)); + + map_set_int64 (mymap, 168); + printf ("mymap[eighty-four,two]=%ld\n", map_get_int64(mymap)); + + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + map_key_str_str (mymap, NULL, NULL); + map_key_del (mymap); + + map_key_str_str (mymap, "0123456789", "foo"); + map_set_int64 (mymap,1000000); + + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val); + + map_key_str_str (mymap, "77", "66"); + map_key_del (mymap); + map_key_del (mymap); + map_set_int64 (mymap,99999999); + + /* create and delete a key */ + map_key_str_str (mymap, "2048", "2"); + map_set_int64 (mymap, 4096); + + map_key_str_str (mymap, "2048", "2"); + printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap)); + map_key_del (mymap); + + printf ("mymap[2048,2]=%ld\n", map_get_int64(mymap)); + map_key_str_str (mymap, "10", "six"); + printf ("mymap[10,six]=%ld\n", map_get_int64(mymap)); + + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val); + + map_key_str_str (mymap, "two-oh-two", "four"); map_key_del (mymap); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val); + + + map_key_str_str (mymap, "Ohio", "1801"); map_set_int64 (mymap, 10123456); + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val); + + /* add 4 new entries, pushing "Ohio" out */ + int i; + for (i = 2; i < 6; i++) + { + char buf[32], buf2[32]; + sprintf (buf, "test_number_%d", i); + sprintf (buf2, "**test number %d**", i*i); + map_key_str_str (mymap, buf, buf2); + map_set_int64 (mymap, i*i*i); + } + printf ("\n"); + for (ptr = (struct map_node_int64 *)map_start(mymap); ptr; + ptr = (struct map_node_int64 *)map_iter (mymap, (struct map_node *)ptr)) + printf ("mymap[%s,%s] = %d\n", key1str(ptr), key2str(ptr), (int)ptr->val); + + + return 0; +} diff --git a/runtime/tests/teststrstrstr.c b/runtime/tests/teststrstrstr.c new file mode 100644 index 000000000..95ffc1a28 --- /dev/null +++ b/runtime/tests/teststrstrstr.c @@ -0,0 +1,121 @@ +#include "test.h" + +/* teststrstrstr.c - DO NOT EDIT without updating the expected results in map.test. */ + +/* + key - str,str + val - str +*/ + + + +static void +map_dump (MAP map) +{ + struct map_node_str *ptr; + printf ("\n"); + for (ptr = (struct map_node_str *)map_start(map); ptr; + ptr = (struct map_node_str *)map_iter (map, (struct map_node *)ptr)) + printf ("map[%s,%s] = %s\n", key1str(ptr), key2str(ptr), ptr->str); + printf ("\n"); +} + +static void m_print (MAP map) +{ + struct map_node_str *m = (struct map_node_str *)map->key; + printf ("map[%s,%s]=%s\n", key1str(m), key2str(m), map_get_str(map)); +} +int main () +{ + MAP mymap = map_new(4, STRING); + + _stp_map_key2 (mymap, "two", "2" ); + _stp_map_set (mymap, "four"); + m_print (mymap); + + _stp_map_key2 (mymap, "eighty-four", "nineteen hundred"); + _stp_map_set (mymap, "nineteen hundred and eighty-three"); + + _stp_map_key2 (mymap, "two-two-one-B", "Baker Street"); + _stp_map_set (mymap, "7% solution"); + + m_print (mymap); + _stp_map_key2 (mymap, "two", "2"); + m_print (mymap); + _stp_map_key2 (mymap, "eighty-four", "nineteen hundred"); + m_print (mymap); + + _stp_map_set (mymap, "nineteen hundred and eighty-four"); + m_print (mymap); + + + /* now try to confuse things */ + /* These won't do anything useful, but shouldn't crash */ + _stp_map_key2 (mymap, NULL, NULL); + map_key_del (mymap); + + _stp_map_key2 (mymap, "0123456789", "4444"); + _stp_map_set (mymap,"1000000"); + + map_dump (mymap); + + _stp_map_key2 (mymap, "77", "66"); + map_key_del (mymap); + map_key_del (mymap); + _stp_map_set (mymap,"99999999"); + + /* create and delete a key */ + _stp_map_key2 (mymap, "2048", "2"); + _stp_map_set (mymap, "4096"); + + _stp_map_key2 (mymap, "2048", "2"); + m_print (mymap); + map_key_del (mymap); + + printf ("mymap[2048,2]=%s\n", map_get_str(mymap)); + _stp_map_key2 (mymap, "six", "10"); + printf ("mymap[six,10]=%s\n", map_get_str(mymap)); + + map_dump(mymap); + + _stp_map_key2 (mymap, "two-two-one-B", "Baker Street"); map_key_del (mymap); + map_dump(mymap); + + + _stp_map_key2 (mymap, "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", NULL); + _stp_map_set (mymap, "TESTING 1,2,3"); + + _stp_map_key2 (mymap, "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZhiasdhgfiudsgfiusdgfisdugfisdugfsdiufgsdfiugsdifugsdiufgsdiufgisdugfisdugfigsdfiusdgfiugsdifu sdfigsdifugsdifugsdiufgsdiufgisdugfiudsgfisudgfiusdgfiusdgfisdugfisdufgiusdfgsdiufgdsiufgsdiufgsdiufgsdiufgwiugfw89e4rf98yf897ywef98wyef98wyf98wyf89ys9d8yfsd sdfysd98fy9s8fyds98fy98dsfy89sdfy", "yw98fty98sfts98d7fts89d7f9sdfoooooooooooooooooooooooooooooooooooooooooooof8eo7stfew87fwet8tw87rf7fpowft7ewfptpwefpwetfpwepwfwetfp8we"); + + _stp_map_set (mymap, "TESTING 1,2,3 ***************************************************************************************************************************************************************************************************************************************************************************** 4,5,6"); + map_dump(mymap); + + /* add 4 new entries, pushing "Ohio" out */ + int i; + for (i = 2; i < 6; i++) + { + char buf[32], buf2[32], buf3[32]; + sprintf (buf, "test_number_%d", i); + sprintf (buf2, "TEST_NUMBER_%d", i*i); + sprintf (buf3, "TEST_NUMBER_%d", i*i*i); + _stp_map_key2 (mymap, buf, buf2); + _stp_map_set_str (mymap, buf3); + } + map_dump (mymap); + + /* delete all entries */ + for (i = 2; i < 6; i++) + { + char buf[32], buf2[32], buf3[32]; + sprintf (buf, "test_number_%d", i); + sprintf (buf2, "TEST_NUMBER_%d", i*i); + sprintf (buf3, "TEST_NUMBER_%d", i*i*i); + _stp_map_key2 (mymap, buf, buf2); + map_key_del (mymap); + } + + printf ("Should be empty: "); + map_dump (mymap); + _stp_map_del (mymap); + return 0; +} -- 2.43.5