summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-08-24 04:32:57 +0000
committerFelix Fietkau2025-08-24 05:03:54 +0000
commitedeb4d6dc690acb476a47e6b11633b5632b08437 (patch)
treee08f34195fd44c53a6d9576aab047e2b90c60c9a
parenta62edd89255b1b5302abd3322421c834b1157c35 (diff)
downloadudebug-edeb4d6dc690acb476a47e6b11633b5632b08437.tar.gz
udebug-cli: add support for streaming tracing data
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rwxr-xr-xudebug-cli22
1 files changed, 21 insertions, 1 deletions
diff --git a/udebug-cli b/udebug-cli
index ce80412..1f59684 100755
--- a/udebug-cli
+++ b/udebug-cli
@@ -1,6 +1,6 @@
#!/usr/bin/env ucode
'use strict';
-import { basename, open, stdout } from "fs";
+import { basename, readlink, open, stdout } from "fs";
let udebug = require("udebug");
let uloop = require("uloop");
let libubus = require("ubus");
@@ -11,6 +11,7 @@ let opts = {
select: []
};
let service_config;
+let trace_config;
const usage_message = `
Usage: ${basename(sourcepath())} [<options>] <command> [<args>]
@@ -66,6 +67,13 @@ function parse_service_value(svc, option, val)
function parse_service_entry(name, option, val)
{
+ if (wildcard(name, "kernel:*")) {
+ name = substr(name, 7);
+ trace_config ??= [];
+ push(trace_config, name);
+ return;
+ }
+
if (index(name, "*") >= 0) {
for (let svcname, svc in service_config) {
if (!wildcard(svcname, name))
@@ -211,6 +219,15 @@ function open_ring(ring, poll) {
return ring;
}
+function open_trace() {
+ let ring = udebug.trace_ring("udebug-" + readlink("/proc/self"));
+
+ ring.set_file("trace_clock", "tai");
+ ring.set_file("set_event", join("\n", trace_config));
+ ring.set_poll_cb(poll_data);
+ rings.kernel = [ "kernel", ring ];
+}
+
function open_log_out() {
let out = opts.output_file;
if (!opts.output_file || out == "-")
@@ -272,6 +289,9 @@ function stream_data(log) {
}
}
+ if (trace_config)
+ open_trace();
+
let done = () => { uloop.end(); };
signal('SIGINT', done);
signal('SIGTERM', done);