From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> To differentiate threads, have tracecmd_debug() show the thread id of the debug prints. Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- tracecmd/trace-cmd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tracecmd/trace-cmd.c b/tracecmd/trace-cmd.c index a83a8d0bb9e4..3f3e69a7f1e2 100644 --- a/tracecmd/trace-cmd.c +++ b/tracecmd/trace-cmd.c @@ -10,12 +10,17 @@ #include <dirent.h> #include <errno.h> #include <stdlib.h> +#include <sys/syscall.h> #include "trace-local.h" int silence_warnings; int show_status; +#ifndef gettid +#define gettid() syscall(__NR_gettid) +#endif + void warning(const char *fmt, ...) { va_list ap; @@ -45,6 +50,19 @@ void *malloc_or_die(unsigned int size) return data; } +void tracecmd_debug(const char *fmt, ...) +{ + va_list ap; + + if (!tracecmd_get_debug()) + return; + + va_start(ap, fmt); + printf("[%d] ", (int)gettid()); + vprintf(fmt, ap); + va_end(ap); +} + static struct trace_log_severity { int id; const char *name; -- 2.35.1