All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 8/8] trace-cmd: Override tracecmd_debug() to show thread id
Date: Sat, 16 Apr 2022 21:19:58 -0400	[thread overview]
Message-ID: <20220417011958.1013591-9-rostedt@goodmis.org> (raw)
In-Reply-To: <20220417011958.1013591-1-rostedt@goodmis.org>

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

To differentiate threads, have tracecmd_debug() show the thread id of
the debug prints.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 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


      parent reply	other threads:[~2022-04-17  1:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-17  1:19 [PATCH 0/8] trace-cmd: Allow agent to use networking Steven Rostedt
2022-04-17  1:19 ` [PATCH 1/8] trace-cmd record: Move port_type into instance Steven Rostedt
2022-04-17  1:19 ` [PATCH 2/8] trace-cmd library: Add network roles for time sync Steven Rostedt
2022-04-17  1:19 ` [PATCH 3/8] trace-cmd record: Allow for ip connections to agents Steven Rostedt
2022-04-17  1:19 ` [PATCH 4/8] trace-cmd agent: Allow for ip connections from the agent Steven Rostedt
2022-04-17  1:19 ` [PATCH 5/8] trace-cmd library: Create tracecmd_debug() for debug printing Steven Rostedt
2022-04-17  1:19 ` [PATCH 6/8] trace-cmd: Add debug prints for network connections Steven Rostedt
2022-04-17  1:19 ` [PATCH 7/8] trace-cmd: Add print helpers to show connections Steven Rostedt
2022-04-17  1:19 ` Steven Rostedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220417011958.1013591-9-rostedt@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.