core: Improve the debug messages even more.

* src/debug.c (_gpgme_debug): Add arg LINE.  Chnage all callers.
(_gpgme_debug_begin): Remove.
* src/debug.h (TRACE_SEQ): Use the LINE arg of _gpgme_debug.
--

This includes chnages to always print fds in decimal as weel as
tweaking the TARCE_SEQ function to make use of the new machinery.

The standard 'tag' can now always be NULL and no tag information will
be printed.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-06-05 15:48:33 +02:00
parent 856d2e8d64
commit 8f9f3224aa
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
18 changed files with 116 additions and 140 deletions

View File

@ -54,7 +54,7 @@ _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook,
if (msg == NULL) if (msg == NULL)
return 1; return 1;
_gpgme_debug (DEBUG_ASSUAN, -1, NULL, NULL, NULL, "%s", msg); _gpgme_debug (NULL, DEBUG_ASSUAN, -1, NULL, NULL, NULL, "%s", msg);
return 0; return 0;
} }

View File

@ -160,7 +160,7 @@ gpgme_error_to_errno (gpgme_error_t err)
break; break;
} }
} }
TRACE (DEBUG_DATA, "gpgme:gpgme_error_to_errno", 0, TRACE (DEBUG_DATA, "gpgme:gpgme_error_to_errno", NULL,
"mapping %s <%s> to: %s", gpgme_strerror (err), "mapping %s <%s> to: %s", gpgme_strerror (err),
gpgme_strsource (err), strerror (res)); gpgme_strsource (err), strerror (res));
gpg_err_set_errno (res); gpg_err_set_errno (res);

View File

@ -75,7 +75,7 @@ gpgme_error_t
gpgme_data_new_from_fd (gpgme_data_t *r_dh, int fd) gpgme_data_new_from_fd (gpgme_data_t *r_dh, int fd)
{ {
gpgme_error_t err; gpgme_error_t err;
TRACE_BEG (DEBUG_DATA, "gpgme_data_new_from_fd", r_dh, "fd=0x%x", fd); TRACE_BEG (DEBUG_DATA, "gpgme_data_new_from_fd", r_dh, "fd=%d", fd);
err = _gpgme_data_new (r_dh, &fd_cbs); err = _gpgme_data_new (r_dh, &fd_cbs);
if (err) if (err)

View File

@ -296,7 +296,7 @@ gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len)
void void
gpgme_free (void *buffer) gpgme_free (void *buffer)
{ {
TRACE (DEBUG_DATA, "gpgme_free", buffer, ""); TRACE (DEBUG_DATA, "gpgme_free", NULL, "p=%p", buffer);
if (buffer) if (buffer)
free (buffer); free (buffer);

View File

@ -574,7 +574,7 @@ _gpgme_data_inbound_handler (void *opaque, int fd)
char *bufp = buffer; char *bufp = buffer;
gpgme_ssize_t buflen; gpgme_ssize_t buflen;
TRACE_BEG (DEBUG_CTX, "_gpgme_data_inbound_handler", dh, TRACE_BEG (DEBUG_CTX, "_gpgme_data_inbound_handler", dh,
"fd=0x%x", fd); "fd=%d", fd);
buflen = _gpgme_io_read (fd, buffer, BUFFER_SIZE); buflen = _gpgme_io_read (fd, buffer, BUFFER_SIZE);
if (buflen < 0) if (buflen < 0)
@ -605,7 +605,7 @@ _gpgme_data_outbound_handler (void *opaque, int fd)
gpgme_data_t dh = (gpgme_data_t) data->handler_value; gpgme_data_t dh = (gpgme_data_t) data->handler_value;
gpgme_ssize_t nwritten; gpgme_ssize_t nwritten;
TRACE_BEG (DEBUG_CTX, "_gpgme_data_outbound_handler", dh, TRACE_BEG (DEBUG_CTX, "_gpgme_data_outbound_handler", dh,
"fd=0x%x", fd); "fd=%d", fd);
if (!dh->pending_len) if (!dh->pending_len)
{ {

View File

@ -196,12 +196,12 @@ debug_init (void)
if (debug_level > 0) if (debug_level > 0)
{ {
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme_debug: level=%d\n", debug_level); "gpgme_debug: level=%d\n", debug_level);
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
{ {
const char *name = _gpgme_get_inst_dir (); const char *name = _gpgme_get_inst_dir ();
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme_debug: gpgme='%s'\n", name? name: "?"); "gpgme_debug: gpgme='%s'\n", name? name: "?");
} }
#endif #endif
@ -231,6 +231,10 @@ _gpgme_debug_subsystem_init (void)
* 2 = debug a function (used by macro TRACE_LOG) * 2 = debug a function (used by macro TRACE_LOG)
* 3 = leave a function (used by macro TRACE_SUC) * 3 = leave a function (used by macro TRACE_SUC)
* *
* If LINE is not NULL the output will be stored in that variabale but
* without a LF. _gpgme_debug_add can be used to add more and
* _gpgme_debug_end to finally output it.
*
* Returns: 0 * Returns: 0
* *
* Note that we always return 0 because the old TRACE macro evaluated * Note that we always return 0 because the old TRACE macro evaluated
@ -240,7 +244,8 @@ _gpgme_debug_subsystem_init (void)
* value from the TRACE macros are actually used somewhere. * value from the TRACE macros are actually used somewhere.
*/ */
int int
_gpgme_debug (int level, int mode, const char *func, const char *tagname, _gpgme_debug (void **line, int level, int mode,
const char *func, const char *tagname,
const char *tagvalue, const char *format, ...) const char *tagvalue, const char *format, ...)
{ {
va_list arg_ptr; va_list arg_ptr;
@ -248,7 +253,7 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname,
int need_lf; int need_lf;
int indent; int indent;
char *prefix, *stdinfo, *userinfo; char *prefix, *stdinfo, *userinfo;
int no_stdinfo = 0; const char *modestr;
if (debug_level < level) if (debug_level < level)
return 0; return 0;
@ -275,31 +280,21 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname,
switch (mode) switch (mode)
{ {
case -1: /* Do nothing. */ case -1: modestr = NULL; break; /* Do nothing. */
stdinfo = NULL; case 0: modestr = "call"; break;
no_stdinfo = 1; case 1: modestr = "enter"; break;
break; case 2: modestr = "check"; break;
case 0: case 3: modestr = "leave"; break;
stdinfo = gpgrt_bsprintf ("%s: call: %s=%p ", func, tagname, tagvalue); default: modestr = "mode?"; break;
break;
case 1:
stdinfo = gpgrt_bsprintf ("%s: enter: %s=%p ", func, tagname, tagvalue);
break;
case 2:
stdinfo = gpgrt_bsprintf ("%s: check: %s=%p ", func, tagname, tagvalue);
break;
case 3:
if (tagname)
stdinfo = gpgrt_bsprintf ("%s: leave: %s=%p ", func, tagname, tagvalue);
else
stdinfo = gpgrt_bsprintf ("%s: leave: ", func);
break;
default:
stdinfo = gpgrt_bsprintf ("%s: ?(mode=%d): %s=%p ",
func, mode, tagname, tagvalue);
break;
} }
if (!modestr)
stdinfo = NULL;
else if (tagname && strcmp (tagname, XSTRINGIFY (NULL)))
stdinfo = gpgrt_bsprintf ("%s: %s: %s=%p ", func,modestr,tagname,tagvalue);
else
stdinfo = gpgrt_bsprintf ("%s: %s: ", func, modestr);
userinfo = gpgrt_vbsprintf (format, arg_ptr); userinfo = gpgrt_vbsprintf (format, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
@ -310,13 +305,22 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname,
else else
need_lf = 0; need_lf = 0;
if (line)
fprintf (errfp, "%s%s%s%s", *line = gpgrt_bsprintf ("%s%s%s",
prefix? prefix : "GPGME out-of-core ", prefix? prefix : "GPGME out-of-core ",
no_stdinfo? "" : stdinfo? stdinfo : "out-of-core ", !modestr? "" : stdinfo? stdinfo :
userinfo? userinfo : "out-of-core", (!format || !*format)? "" :"out-of-core ",
need_lf? "\n":""); userinfo? userinfo : "out-of-core");
fflush (errfp); else
{
fprintf (errfp, "%s%s%s%s",
prefix? prefix : "GPGME out-of-core ",
!modestr? "" : stdinfo? stdinfo :
(!format || !*format)? "" :"out-of-core ",
userinfo? userinfo : "out-of-core",
need_lf? "\n":"");
fflush (errfp);
}
gpgrt_free (userinfo); gpgrt_free (userinfo);
gpgrt_free (stdinfo); gpgrt_free (stdinfo);
@ -326,29 +330,6 @@ _gpgme_debug (int level, int mode, const char *func, const char *tagname,
} }
/* Start a new debug line in *LINE, logged at level LEVEL or higher,
and starting with the formatted string FORMAT. */
void
_gpgme_debug_begin (void **line, int level, const char *format, ...)
{
va_list arg_ptr;
int res;
if (debug_level < level)
{
/* Disable logging of this line. */
*line = NULL;
return;
}
va_start (arg_ptr, format);
res = gpgrt_vasprintf ((char **) line, format, arg_ptr);
va_end (arg_ptr);
if (res < 0)
*line = NULL;
}
/* Add the formatted string FORMAT to the debug line *LINE. */ /* Add the formatted string FORMAT to the debug line *LINE. */
void void
_gpgme_debug_add (void **line, const char *format, ...) _gpgme_debug_add (void **line, const char *format, ...)
@ -389,7 +370,7 @@ _gpgme_debug_end (void **line)
/* The smallest possible level is 1, so force logging here by /* The smallest possible level is 1, so force logging here by
using that. */ using that. */
_gpgme_debug (1, -1, NULL, NULL, NULL, "%s", (char*)*line); _gpgme_debug (NULL, 1, -1, NULL, NULL, NULL, "%s", (char*)*line);
gpgrt_free (*line); gpgrt_free (*line);
*line = NULL; *line = NULL;
} }
@ -438,6 +419,6 @@ _gpgme_debug_buffer (int lvl, const char *const fmt,
*(strp++) = ' '; *(strp++) = ' ';
*(strp2) = '\0'; *(strp2) = '\0';
_gpgme_debug (lvl, -1, NULL, NULL, NULL, fmt, func, str); _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL, fmt, func, str);
} }
} }

View File

@ -68,15 +68,11 @@ int _gpgme_debug_set_debug_envvar (const char *value);
void _gpgme_debug_subsystem_init (void); void _gpgme_debug_subsystem_init (void);
/* Log the formatted string FORMAT at debug level LEVEL or higher. */ /* Log the formatted string FORMAT at debug level LEVEL or higher. */
int _gpgme_debug (int level, int mode, int _gpgme_debug (void **line, int level, int mode,
const char *func, const char *tagname, const char *tagvalue, const char *func, const char *tagname, const char *tagvalue,
const char *format, ...) GPGRT_ATTR_PRINTF(6,7); const char *format, ...) GPGRT_ATTR_PRINTF(7,8);
/* Start a new debug line in *LINE, logged at level LEVEL or higher,
and starting with the formatted string FORMAT. */
void _gpgme_debug_begin (void **helper, int level, const char *format, ...);
/* Add the formatted string FORMAT to the debug line *LINE. */ /* Add the formatted string FORMAT to the debug line *LINE. */
void _gpgme_debug_add (void **helper, const char *format, ...); void _gpgme_debug_add (void **helper, const char *format, ...);
@ -94,7 +90,7 @@ int _gpgme_debug_frame_end (void);
static inline gpgme_error_t static inline gpgme_error_t
_gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line) _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
{ {
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL,
"%s:%d: returning error: %s\n", "%s:%d: returning error: %s\n",
_gpgme_debug_srcname (file), line, gpgme_strerror (err)); _gpgme_debug_srcname (file), line, gpgme_strerror (err));
return err; return err;
@ -116,13 +112,13 @@ _gpgme_trace_gpgme_error (gpgme_error_t err, const char *file, int line)
/* Note: We can't protect this with a do-while block. */ /* Note: We can't protect this with a do-while block. */
#define TRACE_BEG(lvl, name, tag, ...) \ #define TRACE_BEG(lvl, name, tag, ...) \
_TRACE (lvl, name, tag); \ _TRACE (lvl, name, tag); \
_gpgme_debug (_gpgme_trace_level, 1, \ _gpgme_debug (NULL, _gpgme_trace_level, 1, \
_gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \
__VA_ARGS__) __VA_ARGS__)
#define TRACE(lvl, name, tag, ...) do { \ #define TRACE(lvl, name, tag, ...) do { \
_gpgme_debug_frame_begin (); \ _gpgme_debug_frame_begin (); \
_gpgme_debug (lvl, 0, name, STRINGIFY (tag), (void *)(uintptr_t)tag, \ _gpgme_debug (NULL, lvl, 0, name, STRINGIFY (tag), (void *)(uintptr_t)tag, \
__VA_ARGS__); \ __VA_ARGS__); \
_gpgme_debug_frame_end (); \ _gpgme_debug_frame_end (); \
} while (0) } while (0)
@ -135,9 +131,9 @@ static inline gpg_error_t
_trace_err (gpg_error_t err, int lvl, const char *func, int line) _trace_err (gpg_error_t err, int lvl, const char *func, int line)
{ {
if (!err) if (!err)
_gpgme_debug (lvl, 3, func, NULL, NULL, ""); _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, "");
else else
_gpgme_debug (lvl, -1, NULL, NULL, NULL, _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL,
"%s:%d: error: %s <%s>\n", "%s:%d: error: %s <%s>\n",
func, line, gpgme_strerror (err), gpgme_strsource (err)); func, line, gpgme_strerror (err), gpgme_strsource (err));
_gpgme_debug_frame_end (); _gpgme_debug_frame_end ();
@ -151,9 +147,9 @@ static inline int
_trace_sysres (int res, int lvl, const char *func, int line) _trace_sysres (int res, int lvl, const char *func, int line)
{ {
if (res >= 0) if (res >= 0)
_gpgme_debug (lvl, 3, func, NULL, NULL, "result=%d", res); _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, "result=%d", res);
else else
_gpgme_debug (lvl, -1, NULL, NULL, NULL, _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL,
"%s:%d: error: %s (%d)\n", "%s:%d: error: %s (%d)\n",
func, line, strerror (res), res); func, line, strerror (res), res);
_gpgme_debug_frame_end (); _gpgme_debug_frame_end ();
@ -167,9 +163,9 @@ static inline int
_trace_syserr (int rc, int lvl, const char *func, int line) _trace_syserr (int rc, int lvl, const char *func, int line)
{ {
if (!rc) if (!rc)
_gpgme_debug (lvl, 3, func, NULL, NULL, "result=0"); _gpgme_debug (NULL, lvl, 3, func, NULL, NULL, "result=0");
else else
_gpgme_debug (lvl, -1, NULL, NULL, NULL, _gpgme_debug (NULL, lvl, -1, NULL, NULL, NULL,
"%s:%d: error: %s (%d)\n", "%s:%d: error: %s (%d)\n",
func, line, strerror (rc), rc); func, line, strerror (rc), rc);
_gpgme_debug_frame_end (); _gpgme_debug_frame_end ();
@ -177,13 +173,13 @@ _trace_syserr (int rc, int lvl, const char *func, int line)
} }
#define TRACE_SUC(...) do { \ #define TRACE_SUC(...) do { \
_gpgme_debug (_gpgme_trace_level, 3, _gpgme_trace_func, NULL, NULL, \ _gpgme_debug (NULL, _gpgme_trace_level, 3, _gpgme_trace_func, NULL, NULL, \
__VA_ARGS__); \ __VA_ARGS__); \
_gpgme_debug_frame_end (); \ _gpgme_debug_frame_end (); \
} while (0) } while (0)
#define TRACE_LOG(...) do { \ #define TRACE_LOG(...) do { \
_gpgme_debug (_gpgme_trace_level, 2, \ _gpgme_debug (NULL, _gpgme_trace_level, 2, \
_gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \ _gpgme_trace_func, _gpgme_trace_tagname, _gpgme_trace_tag, \
__VA_ARGS__); \ __VA_ARGS__); \
} while (0) } while (0)
@ -198,10 +194,9 @@ _trace_syserr (int rc, int lvl, const char *func, int line)
_gpgme_trace_func, buf, len); \ _gpgme_trace_func, buf, len); \
} while (0) } while (0)
#define TRACE_SEQ(hlp,fmt) do { \ #define TRACE_SEQ(hlp,...) do { \
_gpgme_debug_begin (&(hlp), _gpgme_trace_level, \ _gpgme_debug (&(hlp), _gpgme_trace_level, 2, _gpgme_trace_func, \
"%s: check: %s=%p, " fmt, _gpgme_trace_func, \ _gpgme_trace_tagname, _gpgme_trace_tag, __VA_ARGS__); \
_gpgme_trace_tagname, _gpgme_trace_tag); \
} while (0) } while (0)
#define TRACE_ADD0(hlp,fmt) \ #define TRACE_ADD0(hlp,fmt) \

View File

@ -262,13 +262,13 @@ get_gpgconf_item (int what)
pgmname = dirinfo.disable_gpgconf? NULL : _gpgme_get_gpgconf_path (); pgmname = dirinfo.disable_gpgconf? NULL : _gpgme_get_gpgconf_path ();
if (pgmname && _gpgme_access (pgmname, F_OK)) if (pgmname && _gpgme_access (pgmname, F_OK))
{ {
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: gpgconf='%s' [not installed]\n", pgmname); "gpgme-dinfo: gpgconf='%s' [not installed]\n", pgmname);
free (pgmname); free (pgmname);
pgmname = NULL; /* Not available. */ pgmname = NULL; /* Not available. */
} }
else else
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: gpgconf='%s'\n", "gpgme-dinfo: gpgconf='%s'\n",
pgmname? pgmname : "[null]"); pgmname? pgmname : "[null]");
if (!pgmname) if (!pgmname)
@ -295,35 +295,35 @@ get_gpgconf_item (int what)
allocated. */ allocated. */
dirinfo.valid = 1; dirinfo.valid = 1;
if (dirinfo.gpg_name) if (dirinfo.gpg_name)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: gpg='%s'\n", "gpgme-dinfo: gpg='%s'\n",
dirinfo.gpg_name); dirinfo.gpg_name);
if (dirinfo.g13_name) if (dirinfo.g13_name)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: g13='%s'\n", "gpgme-dinfo: g13='%s'\n",
dirinfo.g13_name); dirinfo.g13_name);
if (dirinfo.gpgsm_name) if (dirinfo.gpgsm_name)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: gpgsm='%s'\n", "gpgme-dinfo: gpgsm='%s'\n",
dirinfo.gpgsm_name); dirinfo.gpgsm_name);
if (dirinfo.homedir) if (dirinfo.homedir)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: homedir='%s'\n", "gpgme-dinfo: homedir='%s'\n",
dirinfo.homedir); dirinfo.homedir);
if (dirinfo.agent_socket) if (dirinfo.agent_socket)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL,DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: agent='%s'\n", "gpgme-dinfo: agent='%s'\n",
dirinfo.agent_socket); dirinfo.agent_socket);
if (dirinfo.agent_ssh_socket) if (dirinfo.agent_ssh_socket)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: ssh='%s'\n", "gpgme-dinfo: ssh='%s'\n",
dirinfo.agent_ssh_socket); dirinfo.agent_ssh_socket);
if (dirinfo.dirmngr_socket) if (dirinfo.dirmngr_socket)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: dirmngr='%s'\n", "gpgme-dinfo: dirmngr='%s'\n",
dirinfo.dirmngr_socket); dirinfo.dirmngr_socket);
if (dirinfo.uisrv_socket) if (dirinfo.uisrv_socket)
_gpgme_debug (DEBUG_INIT, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_INIT, -1, NULL, NULL, NULL,
"gpgme-dinfo: uisrv='%s'\n", "gpgme-dinfo: uisrv='%s'\n",
dirinfo.uisrv_socket); dirinfo.uisrv_socket);
} }

View File

@ -658,7 +658,7 @@ add_io_cb (engine_llass_t llass, iocb_data_t *iocbd, gpgme_io_cb_t handler)
gpgme_error_t err; gpgme_error_t err;
TRACE_BEG (DEBUG_ENGINE, "engine-assuan:add_io_cb", llass, TRACE_BEG (DEBUG_ENGINE, "engine-assuan:add_io_cb", llass,
"fd %d, dir %d", iocbd->fd, iocbd->dir); "fd=%d, dir %d", iocbd->fd, iocbd->dir);
err = (*llass->io_cbs.add) (llass->io_cbs.add_priv, err = (*llass->io_cbs.add) (llass->io_cbs.add_priv,
iocbd->fd, iocbd->dir, iocbd->fd, iocbd->dir,
handler, iocbd->data, &iocbd->tag); handler, iocbd->data, &iocbd->tag);

View File

@ -639,7 +639,7 @@ add_io_cb (engine_g13_t g13, iocb_data_t *iocbd, gpgme_io_cb_t handler)
gpgme_error_t err; gpgme_error_t err;
TRACE_BEG (DEBUG_ENGINE, "engine-g13:add_io_cb", g13, TRACE_BEG (DEBUG_ENGINE, "engine-g13:add_io_cb", g13,
"fd %d, dir %d", iocbd->fd, iocbd->dir); "fd=%d, dir %d", iocbd->fd, iocbd->dir);
err = (*g13->io_cbs.add) (g13->io_cbs.add_priv, err = (*g13->io_cbs.add) (g13->io_cbs.add_priv,
iocbd->fd, iocbd->dir, iocbd->fd, iocbd->dir,
handler, iocbd->data, &iocbd->tag); handler, iocbd->data, &iocbd->tag);

View File

@ -1127,7 +1127,7 @@ add_io_cb (engine_gpgsm_t gpgsm, iocb_data_t *iocbd, gpgme_io_cb_t handler)
gpgme_error_t err; gpgme_error_t err;
TRACE_BEG (DEBUG_ENGINE, "engine-gpgsm:add_io_cb", gpgsm, TRACE_BEG (DEBUG_ENGINE, "engine-gpgsm:add_io_cb", gpgsm,
"fd %d, dir %d", iocbd->fd, iocbd->dir); "fd=%d, dir %d", iocbd->fd, iocbd->dir);
err = (*gpgsm->io_cbs.add) (gpgsm->io_cbs.add_priv, err = (*gpgsm->io_cbs.add) (gpgsm->io_cbs.add_priv,
iocbd->fd, iocbd->dir, iocbd->fd, iocbd->dir,
handler, iocbd->data, &iocbd->tag); handler, iocbd->data, &iocbd->tag);

View File

@ -879,7 +879,7 @@ add_io_cb (engine_uiserver_t uiserver, iocb_data_t *iocbd, gpgme_io_cb_t handler
gpgme_error_t err; gpgme_error_t err;
TRACE_BEG (DEBUG_ENGINE, "engine-uiserver:add_io_cb", uiserver, TRACE_BEG (DEBUG_ENGINE, "engine-uiserver:add_io_cb", uiserver,
"fd %d, dir %d", iocbd->fd, iocbd->dir); "fd=%d, dir %d", iocbd->fd, iocbd->dir);
err = (*uiserver->io_cbs.add) (uiserver->io_cbs.add_priv, err = (*uiserver->io_cbs.add) (uiserver->io_cbs.add_priv,
iocbd->fd, iocbd->dir, iocbd->fd, iocbd->dir,
handler, iocbd->data, &iocbd->tag); handler, iocbd->data, &iocbd->tag);

View File

@ -109,8 +109,8 @@ int
_gpgme_io_read (int fd, void *buffer, size_t count) _gpgme_io_read (int fd, void *buffer, size_t count)
{ {
int nread; int nread;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_read", fd, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_read", NULL,
"buffer=%p, count=%zu", buffer, count); "fd=%d buffer=%p count=%zu", fd, buffer, count);
do do
{ {
@ -127,8 +127,8 @@ int
_gpgme_io_write (int fd, const void *buffer, size_t count) _gpgme_io_write (int fd, const void *buffer, size_t count)
{ {
int nwritten; int nwritten;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_write", fd, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_write", NULL,
"buffer=%p, count=%zu", buffer, count); "fd=%d buffer=%p count=%zu", fd, buffer, count);
TRACE_LOGBUFX (buffer, count); TRACE_LOGBUFX (buffer, count);
do do
@ -146,7 +146,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
{ {
int saved_errno; int saved_errno;
int err; int err;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_pipe", filedes, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_pipe", NULL,
"inherit_idx=%i (GPGME uses it for %s)", "inherit_idx=%i (GPGME uses it for %s)",
inherit_idx, inherit_idx ? "reading" : "writing"); inherit_idx, inherit_idx ? "reading" : "writing");
@ -166,7 +166,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
if (err) if (err)
return TRACE_SYSRES (err); return TRACE_SYSRES (err);
TRACE_SUC ("read=0x%x, write=0x%x", filedes[0], filedes[1]); TRACE_SUC ("read fd=%d write fd=%d", filedes[0], filedes[1]);
return 0; return 0;
} }
@ -179,7 +179,7 @@ _gpgme_io_close (int fd)
void *handler_value; void *handler_value;
int idx; int idx;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", fd, ""); TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_close", NULL, "fd=%d", fd);
if (fd == -1) if (fd == -1)
{ {
@ -221,8 +221,8 @@ _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
int res = 0; int res = 0;
int idx; int idx;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_close_notify", fd, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_close_notify", NULL,
"close_handler=%p/%p", handler, value); "fd=%d close_handler=%p/%p", fd, handler, value);
assert (fd != -1); assert (fd != -1);
@ -272,7 +272,7 @@ _gpgme_io_set_nonblocking (int fd)
{ {
int flags; int flags;
int res; int res;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd, ""); TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", NULL, "fd=%d", fd);
flags = fcntl (fd, F_GETFL, 0); flags = fcntl (fd, F_GETFL, 0);
if (flags == -1) if (flags == -1)
@ -428,7 +428,7 @@ get_max_fds (void)
} }
#endif #endif
TRACE (DEBUG_SYSIO, "gpgme:max_fds", 0, "max fds=%ld (%s)", fds, source); TRACE (DEBUG_SYSIO, "gpgme:max_fds", NULL, "max fds=%ld (%s)", fds, source);
return fds; return fds;
} }
@ -474,7 +474,7 @@ _gpgme_io_spawn (const char *path, char *const argv[], unsigned int flags,
int status; int status;
int signo; int signo;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_spawn", path, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_spawn", NULL,
"path=%s", path); "path=%s", path);
i = 0; i = 0;
while (argv[i]) while (argv[i])
@ -654,7 +654,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
/* Use a 1s timeout. */ /* Use a 1s timeout. */
struct timeval timeout = { 1, 0 }; struct timeval timeout = { 1, 0 };
void *dbg_help = NULL; void *dbg_help = NULL;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_select", fds, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_select", NULL,
"nfds=%zu, nonblock=%u", nfds, nonblock); "nfds=%zu, nonblock=%u", nfds, nonblock);
FD_ZERO (&readfds); FD_ZERO (&readfds);
@ -682,7 +682,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
FD_SET (fds[i].fd, &readfds); FD_SET (fds[i].fd, &readfds);
if (fds[i].fd > max_fd) if (fds[i].fd > max_fd)
max_fd = fds[i].fd; max_fd = fds[i].fd;
TRACE_ADD1 (dbg_help, "r0x%x ", fds[i].fd); TRACE_ADD1 (dbg_help, "r=%d ", fds[i].fd);
any = 1; any = 1;
} }
else if (fds[i].for_write) else if (fds[i].for_write)
@ -697,7 +697,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
FD_SET (fds[i].fd, &writefds); FD_SET (fds[i].fd, &writefds);
if (fds[i].fd > max_fd) if (fds[i].fd > max_fd)
max_fd = fds[i].fd; max_fd = fds[i].fd;
TRACE_ADD1 (dbg_help, "w0x%x ", fds[i].fd); TRACE_ADD1 (dbg_help, "w=%d ", fds[i].fd);
any = 1; any = 1;
} }
fds[i].signaled = 0; fds[i].signaled = 0;
@ -721,9 +721,9 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
for (i = 0; i <= max_fd; i++) for (i = 0; i <= max_fd; i++)
{ {
if (FD_ISSET (i, &readfds)) if (FD_ISSET (i, &readfds))
TRACE_ADD1 (dbg_help, "r0x%x ", i); TRACE_ADD1 (dbg_help, "r=%d ", i);
if (FD_ISSET (i, &writefds)) if (FD_ISSET (i, &writefds))
TRACE_ADD1 (dbg_help, "w0x%x ", i); TRACE_ADD1 (dbg_help, "w=%d ", i);
} }
TRACE_END (dbg_help, "]"); TRACE_END (dbg_help, "]");
} }
@ -760,8 +760,8 @@ _gpgme_io_recvmsg (int fd, struct msghdr *msg, int flags)
int nread; int nread;
int saved_errno; int saved_errno;
struct iovec *iov; struct iovec *iov;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_recvmsg", fd, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_recvmsg", NULL,
"msg=%p, flags=%i", msg, flags); "fd=%d msg=%p flags=%i", fd, msg, flags);
nread = 0; nread = 0;
iov = msg->msg_iov; iov = msg->msg_iov;
@ -802,8 +802,8 @@ _gpgme_io_sendmsg (int fd, const struct msghdr *msg, int flags)
{ {
int nwritten; int nwritten;
struct iovec *iov; struct iovec *iov;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_sendmsg", fd, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_sendmsg", NULL,
"msg=%p, flags=%i", msg, flags); "fd=%d msg=%p flags=%i", fd, msg, flags);
nwritten = 0; nwritten = 0;
iov = msg->msg_iov; iov = msg->msg_iov;
@ -841,7 +841,7 @@ _gpgme_io_dup (int fd)
new_fd = dup (fd); new_fd = dup (fd);
while (new_fd == -1 && errno == EINTR); while (new_fd == -1 && errno == EINTR);
TRACE (DEBUG_SYSIO, "_gpgme_io_dup", fd, "new fd==%i", new_fd); TRACE (DEBUG_SYSIO, "_gpgme_io_dup", NULL, "fd=%d -> fd=%d", fd, new_fd);
return new_fd; return new_fd;
} }
@ -852,8 +852,8 @@ _gpgme_io_socket (int domain, int type, int proto)
{ {
int res; int res;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_socket", domain, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_socket", NULL,
"type=%i, proto=%i", type, proto); "domain=%d type=%i proto=%i", domain, type, proto);
res = socket (domain, type, proto); res = socket (domain, type, proto);
@ -866,8 +866,8 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)
{ {
int res; int res;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_connect", fd, TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_connect", NULL,
"addr=%p, addrlen=%i", addr, addrlen); "fd=%d addr=%p addrlen=%i", fd, addr, addrlen);
do do
res = ath_connect (fd, addr, addrlen); res = ath_connect (fd, addr, addrlen);

View File

@ -114,7 +114,7 @@ walk_path (const char *pgm)
path = s + 1; path = s + 1;
} }
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL,
"gpgme-walk_path: '%s' not found in '%s'", "gpgme-walk_path: '%s' not found in '%s'",
pgm, orig_path); pgm, orig_path);

View File

@ -202,7 +202,7 @@ gpgme_check_version (const char *req_version)
before using the trace facility. If we won't the trace would before using the trace facility. If we won't the trace would
automagically initialize the debug system with out the locks automagically initialize the debug system with out the locks
being initialized and missing the assuan log level setting. */ being initialized and missing the assuan log level setting. */
TRACE (DEBUG_INIT, "gpgme_check_version", 0, TRACE (DEBUG_INIT, "gpgme_check_version", NULL,
"req_version=%s, VERSION=%s", "req_version=%s, VERSION=%s",
req_version? req_version:"(null)", VERSION); req_version? req_version:"(null)", VERSION);
@ -229,13 +229,13 @@ gpgme_check_version_internal (const char *req_version,
return result; return result;
/* Catch-22, see above. */ /* Catch-22, see above. */
TRACE (DEBUG_INIT, "gpgme_check_version_internal", 0, TRACE (DEBUG_INIT, "gpgme_check_version_internal", NULL,
"req_version=%s, offset_sig_validity=%zu", "req_version=%s, offset_sig_validity=%zu",
req_version ? req_version : "(null)", offset_sig_validity); req_version ? req_version : "(null)", offset_sig_validity);
if (offset_sig_validity != offsetof (struct _gpgme_signature, validity)) if (offset_sig_validity != offsetof (struct _gpgme_signature, validity))
{ {
TRACE (DEBUG_INIT, "gpgme_check_version_internal", 0, TRACE (DEBUG_INIT, "gpgme_check_version_internal", NULL,
"offset_sig_validity mismatch: expected %i", "offset_sig_validity mismatch: expected %i",
(int)offsetof (struct _gpgme_signature, validity)); (int)offsetof (struct _gpgme_signature, validity));
_gpgme_selftest = GPG_ERR_SELFTEST_FAILED; _gpgme_selftest = GPG_ERR_SELFTEST_FAILED;

View File

@ -324,7 +324,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
chan = find_channel (fd); chan = find_channel (fd);
if (!chan) if (!chan)
{ {
TRACE_LOG ("fd %d: no channel registered"); TRACE_LOG ("fd=%d: no channel registered");
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
@ -1067,7 +1067,7 @@ _gpgme_io_connect (int fd, struct sockaddr *addr, int addrlen)
return TRACE_SYSRES (-1); return TRACE_SYSRES (-1);
} }
TRACE_LOG ("connect sockfd=0x%x", sockfd); TRACE_LOG ("connect socket fd=%d", sockfd);
res = connect (sockfd, addr, addrlen); res = connect (sockfd, addr, addrlen);
/* FIXME: Error ignored here. */ /* FIXME: Error ignored here. */

View File

@ -262,19 +262,19 @@ _gpgme_allow_set_foreground_window (pid_t pid)
if (!pid || pid == (pid_t)(-1)) if (!pid || pid == (pid_t)(-1))
{ {
TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0, TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", NULL,
"no action for pid %d", (int)pid); "no action for pid %d", (int)pid);
} }
else if (func) else if (func)
{ {
int rc = func (pid); int rc = func (pid);
TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0, TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", NULL,
"called for pid %d; result=%d", (int)pid, rc); "called for pid %d; result=%d", (int)pid, rc);
} }
else else
{ {
TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", 0, TRACE (DEBUG_ENGINE, "gpgme:AllowSetForegroundWindow", NULL,
"function not available"); "function not available");
} }
#endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */ #endif /* HAVE_ALLOW_SET_FOREGROUND_WINDOW */
@ -310,13 +310,13 @@ _gpgme_w32_cancel_synchronous_io (HANDLE thread)
{ {
if (!func (thread) && GetLastError() != ERROR_NOT_FOUND) if (!func (thread) && GetLastError() != ERROR_NOT_FOUND)
{ {
TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0, TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", NULL,
"called for thread %p: ec=%d", thread, GetLastError ()); "called for thread %p: ec=%d", thread, GetLastError ());
} }
} }
else else
{ {
TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", 0, TRACE (DEBUG_ENGINE, "gpgme:CancelSynchronousIo", NULL,
"function not available"); "function not available");
} }
} }
@ -578,7 +578,7 @@ _gpgme_get_gpg_path (void)
/* 4. Print a debug message if not found. */ /* 4. Print a debug message if not found. */
if (!gpg) if (!gpg)
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL,
"_gpgme_get_gpg_path: '%s' not found", name); "_gpgme_get_gpg_path: '%s' not found", name);
return gpg; return gpg;
@ -654,7 +654,7 @@ _gpgme_get_gpgconf_path (void)
/* 5. Print a debug message if not found. */ /* 5. Print a debug message if not found. */
if (!gpgconf) if (!gpgconf)
_gpgme_debug (DEBUG_ENGINE, -1, NULL, NULL, NULL, _gpgme_debug (NULL, DEBUG_ENGINE, -1, NULL, NULL, NULL,
"_gpgme_get_gpgconf_path: '%s' not found",name); "_gpgme_get_gpgconf_path: '%s' not found",name);
return gpgconf; return gpgconf;

View File

@ -137,7 +137,7 @@ _gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc,
} }
TRACE (DEBUG_CTX, "_gpgme_add_io_cb", ctx, TRACE (DEBUG_CTX, "_gpgme_add_io_cb", ctx,
"fd %d, dir=%d -> tag=%p", fd, dir, tag); "fd=%d, dir=%d -> tag=%p", fd, dir, tag);
*r_tag = tag; *r_tag = tag;
return 0; return 0;