Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

SystemTap Runtime Library

0.1

Introduction

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

Design

Implementation

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

Maps (Associative Arrays)

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

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

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.

Lists

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

Status

Example Probes

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

ToDo

Click Here for Complete List

Links

SystemTap Project Page