core: Print a dump of the I/O data only at level 8.

* src/debug.h (TRACE_SUC3): New.
(TRACE_LOGBUFX): New.
* src/posix-io.c: Use TRACE_LOGBUFX instead of TRACE_LOGBUF.
* src/w32-glib-io.c: Ditto.
--

This will also be changed for w32-io as part of another commit.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-11-02 09:03:43 +01:00
parent acef4f775f
commit 337c108255
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 18 additions and 7 deletions

View File

@ -34,7 +34,11 @@
#define XSTRINGIFY(v) STRINGIFY(v)
/* The debug levels. */
/*
* The debug levels.
*
* Note that TRACE_LOGBUFX uses the current debug level + 1.
*/
#define DEBUG_INIT 1
#define DEBUG_GLOBAL 2
@ -211,6 +215,9 @@ _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
#define TRACE_SUC2(fmt, arg1, arg2) \
_gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n", \
_gpgme_trace_func, arg1, arg2), _gpgme_debug_frame_end ()
#define TRACE_SUC3(fmt, arg1, arg2, arg3) \
_gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n", \
_gpgme_trace_func, arg1, arg2, arg3), _gpgme_debug_frame_end ()
#define TRACE_SUC4(fmt, arg1, arg2, arg3, arg4) \
_gpgme_debug (_gpgme_trace_level, "%s: leave: " fmt "\n", \
_gpgme_trace_func, arg1, arg2, arg3, arg4), \
@ -256,6 +263,10 @@ _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
_gpgme_debug_buffer (_gpgme_trace_level, "%s: check: %s", \
_gpgme_trace_func, buf, len)
#define TRACE_LOGBUFX(buf, len) \
_gpgme_debug_buffer (_gpgme_trace_level+1, "%s: check: %s", \
_gpgme_trace_func, buf, len)
#define TRACE_SEQ(hlp,fmt) \
_gpgme_debug_begin (&(hlp), _gpgme_trace_level, \
"%s: check: %s=%p, " fmt, _gpgme_trace_func, \

View File

@ -117,7 +117,7 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
}
while (nread == -1 && errno == EINTR);
TRACE_LOGBUF (buffer, nread);
TRACE_LOGBUFX (buffer, nread);
return TRACE_SYSRES (nread);
}
@ -128,7 +128,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
int nwritten;
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd,
"buffer=%p, count=%u", buffer, count);
TRACE_LOGBUF (buffer, count);
TRACE_LOGBUFX (buffer, count);
do
{
@ -785,7 +785,7 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags)
while (nr > 0)
{
int len = nr > iov->iov_len ? iov->iov_len : nr;
TRACE_LOGBUF (msg->msg_iov->iov_base, len);
TRACE_LOGBUFX (msg->msg_iov->iov_base, len);
iov++;
nr -= len;
}
@ -816,7 +816,7 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
while (nwritten > 0)
{
int len = nwritten > iov->iov_len ? iov->iov_len : nwritten;
TRACE_LOGBUF (msg->msg_iov->iov_base, len);
TRACE_LOGBUFX (msg->msg_iov->iov_base, len);
iov++;
nwritten -= len;
}

View File

@ -301,7 +301,7 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
}
if (nread != 0 && nread != -1)
TRACE_LOGBUF (buffer, nread);
TRACE_LOGBUFX (buffer, nread);
errno = saved_errno;
return TRACE_SYSRES (nread);
@ -319,7 +319,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
TRACE_BEG2 (DEBUG_SYSIO, "_gpgme_io_write", fd,
"buffer=%p, count=%u", buffer, count);
TRACE_LOGBUF (buffer, count);
TRACE_LOGBUFX (buffer, count);
chan = find_channel (fd);
if (!chan)