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 v3 06/11] trace-cmd: Add debug prints for network connections
Date: Wed, 20 Apr 2022 11:26:32 -0400	[thread overview]
Message-ID: <20220420152637.13105-7-rostedt@goodmis.org> (raw)
In-Reply-To: <20220420152637.13105-1-rostedt@goodmis.org>

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

To help debug the network agent and listener, add some debug prints that
are enabled when --debug option is used.

Link: https://lore.kernel.org/linux-trace-devel/20220417184538.1044417-7-rostedt@goodmis.org

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-timesync.c | 2 ++
 tracecmd/trace-agent.c         | 3 +++
 tracecmd/trace-listen.c        | 4 ++++
 tracecmd/trace-record.c        | 9 +++++++++
 4 files changed, 18 insertions(+)

diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c
index 14cf20c870cb..cc44af38e8ad 100644
--- a/lib/trace-cmd/trace-timesync.c
+++ b/lib/trace-cmd/trace-timesync.c
@@ -925,7 +925,9 @@ static void *tsync_agent_thread(void *data)
 	int sd;
 
 	while (true) {
+		tracecmd_debug("Listening on fd:%d\n", tsync->msg_handle->fd);
 		sd = accept(tsync->msg_handle->fd, NULL, NULL);
+		tracecmd_debug("Accepted fd:%d\n", sd);
 		if (sd < 0) {
 			if (errno == EINTR)
 				continue;
diff --git a/tracecmd/trace-agent.c b/tracecmd/trace-agent.c
index cd201ad948ad..819ac016612f 100644
--- a/tracecmd/trace-agent.c
+++ b/tracecmd/trace-agent.c
@@ -22,6 +22,8 @@
 #include "trace-local.h"
 #include "trace-msg.h"
 
+#define dprint(fmt, ...)	tracecmd_debug(fmt, ##__VA_ARGS__)
+
 static void make_vsocks(int nr, int *fds, unsigned int *ports)
 {
 	unsigned int port;
@@ -55,6 +57,7 @@ static void make_net(int nr, int *fds, unsigned int *ports)
 			die("Failed to listen on port %d\n", port);
 		fds[i] = fd;
 		ports[i] = port;
+		dprint("CPU[%d]: fd:%d port:%d\n", i, fd, port);
 		start_port = port + 1;
 	}
 }
diff --git a/tracecmd/trace-listen.c b/tracecmd/trace-listen.c
index 8476fa51dadd..3b446acea972 100644
--- a/tracecmd/trace-listen.c
+++ b/tracecmd/trace-listen.c
@@ -26,6 +26,8 @@
 #include "trace-local.h"
 #include "trace-msg.h"
 
+#define dprint(fmt, ...)	tracecmd_debug(fmt, ##__VA_ARGS__)
+
 #define MAX_OPTION_SIZE 4096
 
 #define _VAR_DIR_Q(dir)		#dir
@@ -279,6 +281,8 @@ int trace_net_make(int port, enum port_type type)
 	if (rp == NULL)
 		return -1;
 
+	dprint("Create listen port: %d fd:%d\n", port, sd);
+
 	return sd;
 }
 
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index dfcf3d494053..9c930920c89e 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -56,6 +56,8 @@
 #define FUNC_STACK_TRACE "func_stack_trace"
 #define TSC_CLOCK	"x86-tsc"
 
+#define dprint(fmt, ...)	tracecmd_debug(fmt, ##__VA_ARGS__)
+
 enum trace_type {
 	TRACE_TYPE_RECORD	= 1,
 	TRACE_TYPE_START	= (1 << 1),
@@ -3139,6 +3141,9 @@ static struct addrinfo *do_getaddrinfo(const char *host, unsigned int port,
 		return NULL;
 	}
 
+	dprint("Attached port %s: %d to results: %p\n",
+	       type == USE_TCP ? "TCP" : "UDP", port, results);
+
 	return results;
 }
 
@@ -3160,6 +3165,8 @@ static int connect_addr(struct addrinfo *results)
 	if (rp == NULL)
 		return -1;
 
+	dprint("connect results: %p with fd: %d\n", results, sfd);
+
 	return sfd;
 }
 
@@ -3193,7 +3200,9 @@ static int do_accept(int sd)
 	int cd;
 
 	for (;;) {
+		dprint("Wait on accept: %d\n", sd);
 		cd = accept(sd, NULL, NULL);
+		dprint("accepted: %d\n", cd);
 		if (cd < 0) {
 			if (errno == EINTR)
 				continue;
-- 
2.35.1


  parent reply	other threads:[~2022-04-20 15:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 15:26 [PATCH v3 00/11] trace-cmd: Allow agent to use networking Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 01/11] trace-cmd record: Move port_type into instance Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 02/11] trace-cmd library: Add network roles for time sync Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 03/11] trace-cmd record: Allow for ip connections to agents Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 04/11] trace-cmd agent: Allow for ip connections from the agent Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 05/11] trace-cmd library: Create tracecmd_debug() for debug printing Steven Rostedt
2022-04-20 15:26 ` Steven Rostedt [this message]
2022-04-20 15:26 ` [PATCH v3 07/11] trace-cmd: Add print helpers to show connections Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 08/11] trace-cmd: Override tracecmd_debug() to show thread id Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 09/11] trace-cmd agent: Have agent work without vsockets available Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 10/11] trace-cmd agent: Have -N take a host name Steven Rostedt
2022-04-20 15:26 ` [PATCH v3 11/11] trace-cmd agent: Add documentation Steven Rostedt

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=20220420152637.13105-7-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.