udebug assists whole-system debugging by making it easy to provide ring buffers with debug data and make them accessible through a unified API. Through the CLI, you can either create snapshots of data with a specific duration, or stream data in real time. The data itself is stored in .pcapng files, which can contain a mix of packets and log messages.
In order to parse log messages in .pcapng files, you need to change the Wireshark
configuration.
Under Preferences
-> Protocols
-> DLT_USER
-> Encapsulations Table
,
add an entry for User 0 (DLT=147)
with Payload protocol syslog
.
Initializes the udebug context. Must be called before adding buffers.
Connect to udebugd and submit any buffers that were added using udebug_buf_add
.
Connects and automatically reconnects to udebugd. Uses uloop and calls udebug_add_uloop
.
Frees the udebug context and all added created buffers.
Allocates a buffer with a given size. Entries and size are rounded up internally to the nearest power-of-2.
Submits the buffer to udebugd and makes it visible.
Removes the buffer from udebugd and frees it.
Initializes a new entry on the ring buffer.
Appends data to the ring buffer. When called with data == NULL, space is only reserved, and the return value provides a pointer with len bytes that can be written to.
Appends a string to the buffer, based on format string + arguments (like printf)
Like udebug_entry_printf()
Finalizes and publishes the entry on the ring buffer.
static struct udebug ud;
static struct udebug_buf udb;
/* ... */
uloop_init();
udebug_init(&ud);
udebug_auto_connect(&ud, NULL);
static const struct udebug_buf_meta buf_meta = {
.name = "counter",
.format = UDEBUG_FORMAT_STRING,
};
int entries = 128;
int data_size = 1024;
udebug_buf_init(&udb, entries, data_size);
udebug_buf_add(&ud, &udb, &buf_meta);
/* ... */
udebug_entry_init(&udb); // initialize entry
udebug_entry_printf(&udb, "count=%d", count++);
udebug_entry_add(&udb); // finalize the entry
Usage: udebug-cli [<options>] <command> [<args>]
Options:
-f Ignore errors on opening rings
-d <duration>: Only fetch data up to <duration> seconds old
-o <file>|- Set output file for snapshot/stream (or '-' for stdout)
-i <process>[:<name>] Select debug buffer for snapshot/stream
-s <path> Use udebug socket <path>
-q Suppress warnings/error messages
Commands:
list: List available debug buffers
snapshot: Create a pcapng snapshot of debug buffers
set_flag [<name>=0|1 ...] Set ring buffer flags
get_flags Get ring buffer flags