|
actf 0.0.1
An acute CTF reader
|
actf is a C library for decoding Common Trace Format (CTF) Version 2 traces. The goal of actf is to be a lightweight, fast and spec-compliant CTF2 decoding library. It additionally includes a command-line utility actf that can read and print a CTF 2 trace stored on a file system.
actf is written for C11 and POSIX 2008. It has a single mandatory dependency, json-c, to facilitate the parsing of the JSON fragment based CTF2 metadata, and an optional dependency, lua 5.4, to allow for easy event processing through scripting.
actf provides you with the trace events and fields without imposing implicit costs for convenience sake: integer mappings and bit map flags are only looked up on demand, and strings and blobs are exposed in a zero-copy fashion. For strings, this means that the raw string you get access to from a field might not be null-terminated and this is the origin of the acute in the library name. If this worries you, I would advise you to check out the reference decoder babeltrace instead.
Since CTF2 is still in its infancy with regards to producers, this library is mainly built based on the specification. Perhaps it works or perhaps I have invented a decoder for a new custom binary format.
actf does not support CTF version 1.X
actf is built with cmake:
The following options are supported by cmake:
| Variable | Type | Default | Desc |
|---|---|---|---|
| BUILD_BIN | BOOL | ON | Whether to build the actf application |
| BUILD_TESTS | BOOL | ON | Whether to build unit tests |
| BUILD_DOC | BOOL | ON | Whether to build doxygen documentation |
| USE_LUA | BOOL | ON | Whether to include lua support |
Unit tests are cunit-based and can be executed by building a test executable (cmake option BUILD_TESTS) and then executing it. Here shown using build-directory build:
actf is heavily tested using functional tests which are diffed against a reference-file. First make sure the test application is built (cmake option BUILD_BIN). The functional tests can then be executed with the runtests.sh script as follows (build-directory build):
The public API of actf is documented using doxygen. It is built by enabling cmake option BUILD_DOC and then running make on the target doc.
Link to actf however you please and include the header actf/actf.h in your code.
See the examples folder for example applications and how to build them.
actf has support for lua scripting if built with USE_LUA=ON. This allows you to write lua scripts to filter and/or analyze CTF events. The lua API is designed for ease of use and supports a subset of the actf API focused on accessing events and their fields. It is implemented as a lua filter that can be hooked up to any other event generator (such as from a CTF trace on the file system). If using the command-line tool actf you can pass a lua script with the -x flag and arguments with the -z flag.
For example, the following lua filter will filter out all events whose names are not matching the input arguments:
This could be run as actf -x <filter-file> -z <event-name0> -z <event-name1> <ctfpath>.
You can also use the lua filter for analyzing the trace data, see the dining philosopher example.
The lua API is documented in actf_lua_filter.h.
actf is single-threaded itself but uses no mutable static or global variables, so as long as each thread has their own mutable structs, it will be fine. E.g. two threads can run two separate actf_decoder in parallel using the same actf_metadata.
The specification allows fixed-length floating point numbers to have the following lengths (bits):
In actf, only lengths 32 and 64 is supported.
The specification does not put a limit on the number of bits a fixed-length bit array can represent.
In actf, the maximum length of a fixed-length bit array field is limited to 64.
This affects the following field classes:
The specification does not limit the size of a variable-length integer.
In actf, a variable-length integer will be truncated to 64 bits.
A range consists of two JSON integers which represent the lower and upper bound. JSON integers are not limited in size by a specification, so the actual bounds differ per implementation.
In actf, the following applies:
LGPLv3.0 or later, see COPYING and COPYING.LESSER.