[svn] assuan - r341 - trunk/src

svn author marcus cvs at cvs.gnupg.org
Tue Jan 5 05:09:05 CET 2010


Author: marcus
Date: 2010-01-05 05:09:05 +0100 (Tue, 05 Jan 2010)
New Revision: 341

Modified:
   trunk/src/ChangeLog
   trunk/src/debug.c
   trunk/src/debug.h
   trunk/src/system.c
Log:
2010-01-05  Marcus Brinkmann  <marcus at g10code.de>

	* debug.h (TRACE_LOG5): Add macro.
	* debug.c (_assuan_debug_buffer): Add newline
	* system.c: Add more debug output (conditioned on the compile-time
	DEBUG_SYSIO macro).


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2010-01-05 04:07:48 UTC (rev 340)
+++ trunk/src/ChangeLog	2010-01-05 04:09:05 UTC (rev 341)
@@ -1,3 +1,10 @@
+2010-01-05  Marcus Brinkmann  <marcus at g10code.de>
+
+	* debug.h (TRACE_LOG5): Add macro.
+	* debug.c (_assuan_debug_buffer): Add newline
+	* system.c: Add more debug output (conditioned on the compile-time
+	DEBUG_SYSIO macro).
+
 2009-12-14  Werner Koch  <wk at g10code.com>
 
 	* assuan.h (ASSUAN_RESPONSE_COMMENT): New.

Modified: trunk/src/debug.c
===================================================================
--- trunk/src/debug.c	2010-01-05 04:07:48 UTC (rev 340)
+++ trunk/src/debug.c	2010-01-05 04:09:05 UTC (rev 341)
@@ -173,8 +173,9 @@
 	    *(strp++) = ' ';
 	}
       *(strp++) = ' ';
+      *(strp2++) = '\n';
       *(strp2) = '\0';
-
+      
       _assuan_debug (ctx, cat, fmt, func, tagname, tag, str);
     }
 }

Modified: trunk/src/debug.h
===================================================================
--- trunk/src/debug.h	2010-01-05 04:07:48 UTC (rev 340)
+++ trunk/src/debug.h	2010-01-05 04:09:05 UTC (rev 341)
@@ -236,6 +236,11 @@
 		 "%s (%s=%p): check: " fmt "\n",		    \
 		_assuan_trace_func, _assuan_trace_tagname,	    \
 		_assuan_trace_tag, arg1, arg2, arg3, arg4), 0
+#define TRACE_LOG5(fmt, arg1, arg2, arg3, arg4, arg5)		    \
+  _assuan_debug (_assuan_trace_context, _assuan_trace_level,	    \
+		 "%s (%s=%p): check: " fmt "\n",		    \
+		_assuan_trace_func, _assuan_trace_tagname,	    \
+		 _assuan_trace_tag, arg1, arg2, arg3, arg4, arg5), 0
 #define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6)	    \
   _assuan_debug (_assuan_trace_context, _assuan_trace_level,	    \
 		 "%s (%s=%p): check: " fmt "\n",			\

Modified: trunk/src/system.c
===================================================================
--- trunk/src/system.c	2010-01-05 04:07:48 UTC (rev 340)
+++ trunk/src/system.c	2010-01-05 04:09:05 UTC (rev 341)
@@ -43,6 +43,8 @@
 #define MAX_OPEN_FDS 20
 #endif
 
+#define DEBUG_SYSIO 0
+
 
 assuan_fd_t
 assuan_fdopen (int fd)
@@ -349,7 +351,7 @@
 ssize_t
 _assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size)
 {
-#if 0
+#if DEBUG_SYSIO
   ssize_t res;
   TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_read", ctx,
 	      "fd=0x%x, buffer=%p, size=%i", fd, buffer, size);
@@ -406,7 +408,7 @@
 _assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer,
 	       size_t size)
 {
-#if 0
+#if DEBUG_SYSIO
   ssize_t res;
   TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_write", ctx,
 	      "fd=0x%x, buffer=%p, size=%i", fd, buffer, size);
@@ -440,7 +442,33 @@
 _assuan_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
 		 int flags)
 {
+#if DEBUG_SYSIO
+  ssize_t res;
+  TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_recvmsg", ctx,
+	      "fd=0x%x, msg=%p, flags=0x%x", fd, msg, flags);
+  res = (ctx->system.recvmsg) (ctx, fd, msg, flags);
+  if (res > 0)
+    {
+      struct cmsghdr *cmptr;
+
+      TRACE_LOG2 ("msg->msg_iov[0] = { iov_base=%p, iov_len=%i }",
+		  msg->msg_iov[0].iov_base, msg->msg_iov[0].iov_len);
+      TRACE_LOGBUF (msg->msg_iov[0].iov_base, res);
+
+      cmptr = CMSG_FIRSTHDR (msg);
+      if (cmptr)
+	{
+	  void *data = CMSG_DATA (cmptr);
+	  TRACE_LOG5 ("cmsg_len=0x%x (0x%x data), cmsg_level=0x%x, "
+		      "cmsg_type=0x%x, first data int=0x%x", cmptr->cmsg_len,
+		      cmptr->cmsg_len - (((char *)data) - ((char *)cmptr)),
+		      cmptr->cmsg_level, cmptr->cmsg_type, *(int *)data);
+	}
+    }    
+  return TRACE_SYSRES (res);
+#else
   return (ctx->system.recvmsg) (ctx, fd, msg, flags);
+#endif
 }
 
 
@@ -466,7 +494,32 @@
 _assuan_sendmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg,
 		 int flags)
 {
+#if DEBUG_SYSIO
+  ssize_t res;
+  TRACE_BEG3 (ctx, ASSUAN_LOG_SYSIO, "_assuan_sendmsg", ctx,
+	      "fd=0x%x, msg=%p, flags=0x%x", fd, msg, flags);
+  {
+    struct cmsghdr *cmptr;
+
+    TRACE_LOG2 ("msg->iov[0] = { iov_base=%p, iov_len=%i }",
+		msg->msg_iov[0].iov_base, msg->msg_iov[0].iov_len);
+    TRACE_LOGBUF (msg->msg_iov[0].iov_base, msg->msg_iov[0].iov_len);
+    
+    cmptr = CMSG_FIRSTHDR (msg);
+    if (cmptr)
+      {
+	void *data = CMSG_DATA (cmptr);
+	TRACE_LOG5 ("cmsg_len=0x%x (0x%x data), cmsg_level=0x%x, "
+		    "cmsg_type=0x%x, first data int=0x%x", cmptr->cmsg_len,
+		    cmptr->cmsg_len - (((char *)data) - ((char *)cmptr)),
+		    cmptr->cmsg_level, cmptr->cmsg_type, *(int *)data);
+      }
+  }
+  res = (ctx->system.sendmsg) (ctx, fd, msg, flags);
+  return TRACE_SYSRES (res);
+#else
   return (ctx->system.sendmsg) (ctx, fd, msg, flags);
+#endif
 }
 
 
@@ -877,7 +930,16 @@
 _assuan_waitpid (assuan_context_t ctx, pid_t pid, int action,
 		 int *status, int options)
 {
+#if DEBUG_SYSIO
+  ssize_t res;
+  TRACE_BEG4 (ctx, ASSUAN_LOG_SYSIO, "_assuan_waitpid", ctx,
+	      "pid=%i, action=%i, status=%p, options=%i",
+	      pid, action, status, options);
+  res = (ctx->system.waitpid) (ctx, pid, action, status, options);
+  return TRACE_SYSRES (res);
+#else
   return (ctx->system.waitpid) (ctx, pid, action, status, options);
+#endif
 }
 
 




More information about the Gnupg-commits mailing list