From c848fa0514b9b8170d6a0a3c93663f4a6a30a581 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Thu, 17 Apr 2025 11:30:45 +0200 Subject: [PATCH] proj: Add tid to msg() --- proj/intercept/src/intercept.c | 2 +- proj/server/src/intercept/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/proj/intercept/src/intercept.c b/proj/intercept/src/intercept.c index eb0e086..efb77b8 100644 --- a/proj/intercept/src/intercept.c +++ b/proj/intercept/src/intercept.c @@ -602,7 +602,7 @@ static void msg(const char *fmt, ...) { struct timespec spec; clock_gettime(CLOCK_REALTIME, &spec); - size_t offset = snprintf(buf, sizeof(buf), "%li.%09li %i ", spec.tv_sec, spec.tv_nsec, getpid()); + size_t offset = snprintf(buf, sizeof(buf), "%li.%09li %i %i ", spec.tv_sec, spec.tv_nsec, getpid(), gettid()); for (char ch, state = 0; (ch = *fmt) != 0 && offset < sizeof(buf); fmt++) { if (state == '%') { if (ch == '%') { diff --git a/proj/server/src/intercept/__init__.py b/proj/server/src/intercept/__init__.py index 9c32ae2..c8fab8c 100644 --- a/proj/server/src/intercept/__init__.py +++ b/proj/server/src/intercept/__init__.py @@ -38,7 +38,7 @@ class Handler(StreamRequestHandler): def handle(self): first = self.rfile.readline() - meta = {a[0]: a[1] for a in [tuple(p.decode('utf-8').split(':', 1)) for p in first.split(b' ', 2)[2].strip().split(b';')]} + meta = {a[0]: a[1] for a in [tuple(p.decode('utf-8').split(':', 1)) for p in first.split(b' ', 3)[3].strip().split(b';')]} self.pid = int(meta['PID']) if 'PID' in meta else None self.path = meta['PATH'] if 'PATH' in meta else None self.stack = [] @@ -163,7 +163,7 @@ class Handler(StreamRequestHandler): return tuple(args), idx def handle_msg(self, msg: bytes): - timestamp, pid, data = msg.rstrip(b'\n').split(b' ', 2) + timestamp, pid, tid, data = msg.rstrip(b'\n').split(b' ', 3) if not data.startswith(b'return ') and not data == b'return': call = data.decode('utf-8') print(f'[{self.pid}] {call}')