core: Introduce a context serial number.

* src/context.h: Include stdint.h.
(struct gpgme_context): Add field 'serial'.
(CTXSERIAL): New.
* src/gpgme.c: (last_ctx_serial): New.
(gpgme_new): Set serial.

* src/gpgme.c: Change trace calls to use the serial.
* src/wait.c (_gpgme_add_io_cb): Ditto
(_gpgme_remove_io_cb): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-06-07 12:10:40 +02:00
parent 52d8ed8dfb
commit 92883efe71
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 135 additions and 97 deletions

View File

@ -21,6 +21,8 @@
#ifndef CONTEXT_H #ifndef CONTEXT_H
#define CONTEXT_H #define CONTEXT_H
#include <stdint.h>
#include "gpgme.h" #include "gpgme.h"
#include "engine.h" #include "engine.h"
#include "wait.h" #include "wait.h"
@ -78,6 +80,12 @@ struct gpgme_context
{ {
DECLARE_LOCK (lock); DECLARE_LOCK (lock);
/* The unique serial number of this context object. This is used
* for a weak reference of the context. Using the address of the
* context is not always possible becuase it might have already been
* freed and reused. */
uint64_t serial;
/* True if the context was canceled asynchronously. */ /* True if the context was canceled asynchronously. */
int canceled; int canceled;
@ -186,4 +194,9 @@ struct gpgme_context
struct gpgme_io_cbs io_cbs; struct gpgme_io_cbs io_cbs;
}; };
/* Macro to retrieve the serial number. Returns 0 if CTX is NULL. */
#define CTXSERIAL(ctx) (ctx? (unsigned long)ctx->serial : 0)
#endif /* CONTEXT_H */ #endif /* CONTEXT_H */

View File

@ -42,11 +42,19 @@
#include "mbox-util.h" #include "mbox-util.h"
/* The default locale. */ /* The default locale and its lock. This lock is also used for the
* context serial number. */
DEFINE_STATIC_LOCK (def_lc_lock); DEFINE_STATIC_LOCK (def_lc_lock);
static char *def_lc_ctype; static char *def_lc_ctype;
static char *def_lc_messages; static char *def_lc_messages;
/* A serial number to identify a context. To make debugging easier by
* distinguishing this from the data object s/n we initialize it with
* an arbitrary offset. Debug output of this should be done using
* decimal notation. Updates are protected by the DEF_LC_LOCK. */
static uint64_t last_ctx_serial = 200000;
gpgme_error_t _gpgme_selftest = GPG_ERR_NOT_OPERATIONAL; gpgme_error_t _gpgme_selftest = GPG_ERR_NOT_OPERATIONAL;
@ -94,7 +102,7 @@ gpgme_new (gpgme_ctx_t *r_ctx)
{ {
gpgme_error_t err; gpgme_error_t err;
gpgme_ctx_t ctx; gpgme_ctx_t ctx;
TRACE_BEG (DEBUG_CTX, "gpgme_new", r_ctx, ""); TRACE_BEG (DEBUG_CTX, "gpgme_new", NULL, "");
if (_gpgme_selftest) if (_gpgme_selftest)
return TRACE_ERR (_gpgme_selftest); return TRACE_ERR (_gpgme_selftest);
@ -155,11 +163,14 @@ gpgme_new (gpgme_ctx_t *r_ctx)
} }
else else
def_lc_messages = NULL; def_lc_messages = NULL;
ctx->serial = ++last_ctx_serial;
UNLOCK (def_lc_lock); UNLOCK (def_lc_lock);
*r_ctx = ctx; *r_ctx = ctx;
TRACE_SUC ("ctx=%p", ctx); TRACE_SUC ("ctx=%lu (%p)", CTXSERIAL(ctx), ctx);
return 0; return 0;
} }
@ -171,8 +182,9 @@ _gpgme_cancel_with_err (gpgme_ctx_t ctx, gpg_error_t ctx_err,
gpgme_error_t err; gpgme_error_t err;
struct gpgme_io_event_done_data data; struct gpgme_io_event_done_data data;
TRACE_BEG (DEBUG_CTX, "_gpgme_cancel_with_err", ctx, "ctx_err=%i, op_err=%i", TRACE_BEG (DEBUG_CTX, "_gpgme_cancel_with_err", NULL,
ctx_err, op_err); "ctx=%lu ctx_err=%i op_err=%i",
CTXSERIAL (ctx), ctx_err, op_err);
if (ctx_err) if (ctx_err)
{ {
@ -202,7 +214,7 @@ gpgme_cancel (gpgme_ctx_t ctx)
{ {
gpg_error_t err; gpg_error_t err;
TRACE_BEG (DEBUG_CTX, "gpgme_cancel", ctx, ""); TRACE_BEG (DEBUG_CTX, "gpgme_cancel", NULL, "ctx=%lu", CTXSERIAL (ctx));
if (!ctx) if (!ctx)
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
@ -217,7 +229,8 @@ gpgme_cancel (gpgme_ctx_t ctx)
gpgme_error_t gpgme_error_t
gpgme_cancel_async (gpgme_ctx_t ctx) gpgme_cancel_async (gpgme_ctx_t ctx)
{ {
TRACE_BEG (DEBUG_CTX, "gpgme_cancel_async", ctx, ""); TRACE_BEG (DEBUG_CTX, "gpgme_cancel_async", NULL,
"ctx=%lu", CTXSERIAL (ctx));
if (!ctx) if (!ctx)
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
@ -234,7 +247,7 @@ gpgme_cancel_async (gpgme_ctx_t ctx)
void void
gpgme_release (gpgme_ctx_t ctx) gpgme_release (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_release", ctx, ""); TRACE (DEBUG_CTX, "gpgme_release", NULL, "ctx=%lu", CTXSERIAL (ctx));
if (!ctx) if (!ctx)
return; return;
@ -325,8 +338,8 @@ _gpgme_release_result (gpgme_ctx_t ctx)
gpgme_error_t gpgme_error_t
gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol) gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
{ {
TRACE_BEG (DEBUG_CTX, "gpgme_set_protocol", ctx, "protocol=%i (%s)", TRACE_BEG (DEBUG_CTX, "gpgme_set_protocol", NULL, "ctx=%lu protocol=%i (%s)",
protocol, gpgme_get_protocol_name (protocol) CTXSERIAL (ctx), protocol, gpgme_get_protocol_name (protocol)
? gpgme_get_protocol_name (protocol) : "invalid"); ? gpgme_get_protocol_name (protocol) : "invalid");
if (protocol != GPGME_PROTOCOL_OpenPGP if (protocol != GPGME_PROTOCOL_OpenPGP
@ -360,8 +373,8 @@ gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
gpgme_protocol_t gpgme_protocol_t
gpgme_get_protocol (gpgme_ctx_t ctx) gpgme_get_protocol (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_protocol", ctx, TRACE (DEBUG_CTX, "gpgme_get_protocol", NULL,
"ctx->protocol=%i (%s)", ctx->protocol, "ctx=%lu protocol=%i (%s)", CTXSERIAL (ctx), ctx->protocol,
gpgme_get_protocol_name (ctx->protocol) gpgme_get_protocol_name (ctx->protocol)
? gpgme_get_protocol_name (ctx->protocol) : "invalid"); ? gpgme_get_protocol_name (ctx->protocol) : "invalid");
@ -372,9 +385,9 @@ gpgme_get_protocol (gpgme_ctx_t ctx)
gpgme_error_t gpgme_error_t
gpgme_set_sub_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol) gpgme_set_sub_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
{ {
TRACE (DEBUG_CTX, "gpgme_set_sub_protocol", ctx, "protocol=%i (%s)", TRACE (DEBUG_CTX, "gpgme_set_sub_protocol", NULL, "ctx=%lu protocol=%i (%s)",
protocol, gpgme_get_protocol_name (protocol) CTXSERIAL (ctx), protocol, gpgme_get_protocol_name (protocol)
? gpgme_get_protocol_name (protocol) : "invalid"); ? gpgme_get_protocol_name (protocol) : "invalid");
if (!ctx) if (!ctx)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
@ -387,10 +400,11 @@ gpgme_set_sub_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
gpgme_protocol_t gpgme_protocol_t
gpgme_get_sub_protocol (gpgme_ctx_t ctx) gpgme_get_sub_protocol (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_sub_protocol", ctx, TRACE (DEBUG_CTX, "gpgme_get_sub_protocol", NULL,
"ctx->sub_protocol=%i (%s)", ctx->sub_protocol, "ctx=%lu sub_protocol=%i (%s)",
gpgme_get_protocol_name (ctx->sub_protocol) CTXSERIAL (ctx), ctx->sub_protocol,
? gpgme_get_protocol_name (ctx->sub_protocol) : "invalid"); gpgme_get_protocol_name (ctx->sub_protocol)
? gpgme_get_protocol_name (ctx->sub_protocol) : "invalid");
return ctx->sub_protocol; return ctx->sub_protocol;
} }
@ -444,8 +458,8 @@ gpgme_set_sender (gpgme_ctx_t ctx, const char *address)
{ {
char *p = NULL; char *p = NULL;
TRACE_BEG (DEBUG_CTX, "gpgme_set_sender", ctx, "sender='%s'", TRACE_BEG (DEBUG_CTX, "gpgme_set_sender", NULL, "ctx=%lu sender='%s'",
address?address:"(null)"); CTXSERIAL (ctx), address?address:"(null)");
if (!ctx || (address && !(p = _gpgme_mailbox_from_userid (address)))) if (!ctx || (address && !(p = _gpgme_mailbox_from_userid (address))))
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
@ -462,8 +476,8 @@ gpgme_set_sender (gpgme_ctx_t ctx, const char *address)
const char * const char *
gpgme_get_sender (gpgme_ctx_t ctx) gpgme_get_sender (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_sender", ctx, "sender='%s'", TRACE (DEBUG_CTX, "gpgme_get_sender", NULL, "ctx=%lu sender='%s'",
ctx?ctx->sender:""); CTXSERIAL (ctx), ctx?ctx->sender:"");
return ctx->sender; return ctx->sender;
} }
@ -473,8 +487,8 @@ gpgme_get_sender (gpgme_ctx_t ctx)
void void
gpgme_set_armor (gpgme_ctx_t ctx, int use_armor) gpgme_set_armor (gpgme_ctx_t ctx, int use_armor)
{ {
TRACE (DEBUG_CTX, "gpgme_set_armor", ctx, "use_armor=%i (%s)", TRACE (DEBUG_CTX, "gpgme_set_armor", NULL, "ctx=%lu use_armor=%i (%s)",
use_armor, use_armor ? "yes" : "no"); CTXSERIAL (ctx), use_armor, use_armor ? "yes" : "no");
if (!ctx) if (!ctx)
return; return;
@ -487,8 +501,8 @@ gpgme_set_armor (gpgme_ctx_t ctx, int use_armor)
int int
gpgme_get_armor (gpgme_ctx_t ctx) gpgme_get_armor (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_armor", ctx, "ctx->use_armor=%i (%s)", TRACE (DEBUG_CTX, "gpgme_get_armor", NULL, "ctx=%lu use_armor=%i (%s)",
ctx->use_armor, ctx->use_armor ? "yes" : "no"); CTXSERIAL (ctx), ctx->use_armor, ctx->use_armor ? "yes" : "no");
return ctx->use_armor; return ctx->use_armor;
} }
@ -502,9 +516,9 @@ gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)
gpgme_error_t err = 0; gpgme_error_t err = 0;
int abool; int abool;
TRACE (DEBUG_CTX, "gpgme_set_ctx_flag", ctx, TRACE (DEBUG_CTX, "gpgme_set_ctx_flag", NULL,
"name='%s' value='%s'", "ctx=%lu name='%s' value='%s'",
name? name:"(null)", value?value:"(null)"); CTXSERIAL (ctx), name? name:"(null)", value?value:"(null)");
abool = (value && *value)? !!atoi (value) : 0; abool = (value && *value)? !!atoi (value) : 0;
@ -635,8 +649,8 @@ gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name)
void void
gpgme_set_textmode (gpgme_ctx_t ctx, int use_textmode) gpgme_set_textmode (gpgme_ctx_t ctx, int use_textmode)
{ {
TRACE (DEBUG_CTX, "gpgme_set_textmode", ctx, "use_textmode=%i (%s)", TRACE (DEBUG_CTX, "gpgme_set_textmode", NULL, "ctx=%lu use_textmode=%i (%s)",
use_textmode, use_textmode ? "yes" : "no"); CTXSERIAL (ctx), use_textmode, use_textmode ? "yes" : "no");
if (!ctx) if (!ctx)
return; return;
@ -648,8 +662,8 @@ gpgme_set_textmode (gpgme_ctx_t ctx, int use_textmode)
int int
gpgme_get_textmode (gpgme_ctx_t ctx) gpgme_get_textmode (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_textmode", ctx, "ctx->use_textmode=%i (%s)", TRACE (DEBUG_CTX, "gpgme_get_textmode", NULL, "ctx=%lu use_textmode=%i (%s)",
ctx->use_textmode, ctx->use_textmode ? "yes" : "no"); CTXSERIAL (ctx), ctx->use_textmode, ctx->use_textmode ? "yes" : "no");
return ctx->use_textmode; return ctx->use_textmode;
} }
@ -659,8 +673,8 @@ gpgme_get_textmode (gpgme_ctx_t ctx)
void void
gpgme_set_offline (gpgme_ctx_t ctx, int offline) gpgme_set_offline (gpgme_ctx_t ctx, int offline)
{ {
TRACE (DEBUG_CTX, "gpgme_set_offline", ctx, "offline=%i (%s)", TRACE (DEBUG_CTX, "gpgme_set_offline", NULL, "ctx=%lu offline=%i (%s)",
offline, offline ? "yes" : "no"); CTXSERIAL (ctx), offline, offline ? "yes" : "no");
if (!ctx) if (!ctx)
return; return;
@ -672,8 +686,8 @@ gpgme_set_offline (gpgme_ctx_t ctx, int offline)
int int
gpgme_get_offline (gpgme_ctx_t ctx) gpgme_get_offline (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_offline", ctx, "ctx->offline=%i (%s)", TRACE (DEBUG_CTX, "gpgme_get_offline", NULL, "ctx=%lu offline=%i (%s)",
ctx->offline, ctx->offline ? "yes" : "no"); CTXSERIAL (ctx), ctx->offline, ctx->offline ? "yes" : "no");
return ctx->offline; return ctx->offline;
} }
@ -694,8 +708,9 @@ gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs)
else else
ctx->include_certs = nr_of_certs; ctx->include_certs = nr_of_certs;
TRACE (DEBUG_CTX, "gpgme_set_include_certs", ctx, "nr_of_certs=%i%s", TRACE (DEBUG_CTX, "gpgme_set_include_certs", NULL, "ctx=%lu nr_of_certs=%i%s",
nr_of_certs, nr_of_certs == ctx->include_certs ? "" : " (-2)"); CTXSERIAL (ctx),
nr_of_certs, nr_of_certs == ctx->include_certs ? "" : " (-2)");
} }
@ -704,8 +719,8 @@ gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs)
int int
gpgme_get_include_certs (gpgme_ctx_t ctx) gpgme_get_include_certs (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_include_certs", ctx, "ctx->include_certs=%i", TRACE (DEBUG_CTX, "gpgme_get_include_certs", NULL, "ctx=%lu include_certs=%i",
ctx->include_certs); CTXSERIAL (ctx), ctx->include_certs);
return ctx->include_certs; return ctx->include_certs;
} }
@ -716,8 +731,8 @@ gpgme_get_include_certs (gpgme_ctx_t ctx)
gpgme_error_t gpgme_error_t
gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode) gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode)
{ {
TRACE (DEBUG_CTX, "gpgme_set_keylist_mode", ctx, "keylist_mode=0x%x", TRACE (DEBUG_CTX, "gpgme_set_keylist_mode", NULL, "ctx=%lu keylist_mode=0x%x",
mode); CTXSERIAL (ctx), mode);
if (!ctx) if (!ctx)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
@ -731,8 +746,8 @@ gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode)
gpgme_keylist_mode_t gpgme_keylist_mode_t
gpgme_get_keylist_mode (gpgme_ctx_t ctx) gpgme_get_keylist_mode (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_keylist_mode", ctx, TRACE (DEBUG_CTX, "gpgme_get_keylist_mode", NULL,
"ctx->keylist_mode=0x%x", ctx->keylist_mode); "ctx=%lu keylist_mode=0x%x", CTXSERIAL (ctx), ctx->keylist_mode);
return ctx->keylist_mode; return ctx->keylist_mode;
} }
@ -741,8 +756,8 @@ gpgme_get_keylist_mode (gpgme_ctx_t ctx)
gpgme_error_t gpgme_error_t
gpgme_set_pinentry_mode (gpgme_ctx_t ctx, gpgme_pinentry_mode_t mode) gpgme_set_pinentry_mode (gpgme_ctx_t ctx, gpgme_pinentry_mode_t mode)
{ {
TRACE (DEBUG_CTX, "gpgme_set_pinentry_mode", ctx, "pinentry_mode=%u", TRACE (DEBUG_CTX, "gpgme_set_pinentry_mode", NULL, "ctx=%lu pinentry_mode=%u",
(unsigned int)mode); CTXSERIAL (ctx), (unsigned int)mode);
if (!ctx) if (!ctx)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
@ -768,8 +783,8 @@ gpgme_set_pinentry_mode (gpgme_ctx_t ctx, gpgme_pinentry_mode_t mode)
gpgme_pinentry_mode_t gpgme_pinentry_mode_t
gpgme_get_pinentry_mode (gpgme_ctx_t ctx) gpgme_get_pinentry_mode (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_get_pinentry_mode", ctx, TRACE (DEBUG_CTX, "gpgme_get_pinentry_mode", NULL, "ctx=%lu pinentry_mode=%u",
"ctx->pinentry_mode=%u", (unsigned int)ctx->pinentry_mode); CTXSERIAL (ctx), (unsigned int)ctx->pinentry_mode);
return ctx->pinentry_mode; return ctx->pinentry_mode;
} }
@ -780,8 +795,8 @@ void
gpgme_set_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb, gpgme_set_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb,
void *cb_value) void *cb_value)
{ {
TRACE (DEBUG_CTX, "gpgme_set_passphrase_cb", ctx, TRACE (DEBUG_CTX, "gpgme_set_passphrase_cb", NULL,
"passphrase_cb=%p/%p", cb, cb_value); "ctx=%lu passphrase_cb=%p/%p", CTXSERIAL (ctx), cb, cb_value);
if (!ctx) if (!ctx)
return; return;
@ -797,9 +812,9 @@ void
gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb, gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb,
void **r_cb_value) void **r_cb_value)
{ {
TRACE (DEBUG_CTX, "gpgme_get_passphrase_cb", ctx, TRACE (DEBUG_CTX, "gpgme_get_passphrase_cb", NULL,
"ctx->passphrase_cb=%p/%p", "ctx=%lu passphrase_cb=%p/%p",
ctx->passphrase_cb, ctx->passphrase_cb_value); CTXSERIAL (ctx), ctx->passphrase_cb, ctx->passphrase_cb_value);
if (r_cb) if (r_cb)
*r_cb = ctx->passphrase_cb; *r_cb = ctx->passphrase_cb;
if (r_cb_value) if (r_cb_value)
@ -812,8 +827,8 @@ gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb,
void void
gpgme_set_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t cb, void *cb_value) gpgme_set_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t cb, void *cb_value)
{ {
TRACE (DEBUG_CTX, "gpgme_set_progress_cb", ctx, "progress_cb=%p/%p", TRACE (DEBUG_CTX, "gpgme_set_progress_cb", NULL, "ctx=%lu progress_cb=%p/%p",
cb, cb_value); CTXSERIAL (ctx), cb, cb_value);
if (!ctx) if (!ctx)
return; return;
@ -829,8 +844,8 @@ void
gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb, gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb,
void **r_cb_value) void **r_cb_value)
{ {
TRACE (DEBUG_CTX, "gpgme_get_progress_cb", ctx, "ctx->progress_cb=%p/%p", TRACE (DEBUG_CTX, "gpgme_get_progress_cb", NULL, "ctx=%lu progress_cb=%p/%p",
ctx->progress_cb, ctx->progress_cb_value); CTXSERIAL (ctx), ctx->progress_cb, ctx->progress_cb_value);
if (r_cb) if (r_cb)
*r_cb = ctx->progress_cb; *r_cb = ctx->progress_cb;
if (r_cb_value) if (r_cb_value)
@ -843,8 +858,8 @@ gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb,
void void
gpgme_set_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t cb, void *cb_value) gpgme_set_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t cb, void *cb_value)
{ {
TRACE (DEBUG_CTX, "gpgme_set_status_cb", ctx, "status_cb=%p/%p", TRACE (DEBUG_CTX, "gpgme_set_status_cb", NULL, "ctx=%lu status_cb=%p/%p",
cb, cb_value); CTXSERIAL (ctx), cb, cb_value);
if (!ctx) if (!ctx)
return; return;
@ -860,8 +875,9 @@ void
gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *r_cb, gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *r_cb,
void **r_cb_value) void **r_cb_value)
{ {
TRACE (DEBUG_CTX, "gpgme_get_status_cb", ctx, "ctx->status_cb=%p/%p", TRACE (DEBUG_CTX, "gpgme_get_status_cb", NULL, "ctx=%lu status_cb=%p/%p",
ctx ? ctx->status_cb : NULL, ctx ? ctx->status_cb_value : NULL); CTXSERIAL (ctx),
ctx ? ctx->status_cb : NULL, ctx ? ctx->status_cb_value : NULL);
if (r_cb) if (r_cb)
*r_cb = NULL; *r_cb = NULL;
@ -888,16 +904,17 @@ gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
if (io_cbs) if (io_cbs)
{ {
TRACE (DEBUG_CTX, "gpgme_set_io_cbs", ctx, TRACE (DEBUG_CTX, "gpgme_set_io_cbs", NULL,
"io_cbs=%p (add=%p/%p, remove=%p, event=%p/%p", "ctx=%lu io_cbs=%p (add=%p/%p, remove=%p, event=%p/%p",
io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove, CTXSERIAL (ctx),
io_cbs->event, io_cbs->event_priv); io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove,
io_cbs->event, io_cbs->event_priv);
ctx->io_cbs = *io_cbs; ctx->io_cbs = *io_cbs;
} }
else else
{ {
TRACE (DEBUG_CTX, "gpgme_set_io_cbs", ctx, TRACE (DEBUG_CTX, "gpgme_set_io_cbs", NULL,
"io_cbs=%p (default)", io_cbs); "ctx=%lu io_cbs=%p (default)", CTXSERIAL (ctx), io_cbs);
ctx->io_cbs.add = NULL; ctx->io_cbs.add = NULL;
ctx->io_cbs.add_priv = NULL; ctx->io_cbs.add_priv = NULL;
ctx->io_cbs.remove = NULL; ctx->io_cbs.remove = NULL;
@ -913,8 +930,8 @@ gpgme_ssize_t
gpgme_io_read (int fd, void *buffer, size_t count) gpgme_io_read (int fd, void *buffer, size_t count)
{ {
int ret; int ret;
TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_read", fd, TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_read", NULL,
"buffer=%p, count=%zu", buffer, count); "fd=%d buffer=%p count=%zu", fd, buffer, count);
ret = _gpgme_io_read (fd, buffer, count); ret = _gpgme_io_read (fd, buffer, count);
@ -929,8 +946,8 @@ gpgme_ssize_t
gpgme_io_write (int fd, const void *buffer, size_t count) gpgme_io_write (int fd, const void *buffer, size_t count)
{ {
int ret; int ret;
TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_write", fd, TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_write", NULL,
"buffer=%p, count=%zu", buffer, count); "fd=%d buffer=%p count=%zu", fd, buffer, count);
ret = _gpgme_io_write (fd, buffer, count); ret = _gpgme_io_write (fd, buffer, count);
@ -948,8 +965,9 @@ gpgme_io_writen (int fd, const void *buffer_arg, size_t count)
{ {
const char *buffer = buffer_arg; const char *buffer = buffer_arg;
int ret = 0; int ret = 0;
TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_writen", fd, TRACE_BEG (DEBUG_GLOBAL, "gpgme_io_writen", NULL,
"buffer=%p, count=%zu", buffer, count); "fd=%d buffer=%p count=%zu", fd, buffer, count);
while (count) while (count)
{ {
ret = _gpgme_io_write (fd, buffer, count); ret = _gpgme_io_write (fd, buffer, count);
@ -967,10 +985,11 @@ gpgme_io_writen (int fd, const void *buffer_arg, size_t count)
void void
gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs) gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
{ {
TRACE (DEBUG_CTX, "gpgme_get_io_cbs", ctx, TRACE (DEBUG_CTX, "gpgme_get_io_cbs", NULL,
"io_cbs=%p, ctx->io_cbs.add=%p/%p, .remove=%p, .event=%p/%p", "ctx=%lu io_cbs=%p ctx->io_cbs.add=%p/%p .remove=%p, .event=%p/%p",
io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove, CTXSERIAL (ctx),
io_cbs->event, io_cbs->event_priv); io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove,
io_cbs->event, io_cbs->event_priv);
*io_cbs = ctx->io_cbs; *io_cbs = ctx->io_cbs;
} }
@ -985,8 +1004,9 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
char *new_lc_ctype = NULL; char *new_lc_ctype = NULL;
char *new_lc_messages = NULL; char *new_lc_messages = NULL;
TRACE_BEG (DEBUG_CTX, "gpgme_set_locale", ctx, TRACE_BEG (DEBUG_CTX, "gpgme_set_locale", NULL,
"category=%i, value=%s", category, value ? value : "(null)"); "ctx=%lu category=%i value=%s",
CTXSERIAL (ctx), category, value ? value : "(null)");
#define PREPARE_ONE_LOCALE(lcat, ucat) \ #define PREPARE_ONE_LOCALE(lcat, ucat) \
if (!failed && value \ if (!failed && value \
@ -1054,8 +1074,8 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
gpgme_engine_info_t gpgme_engine_info_t
gpgme_ctx_get_engine_info (gpgme_ctx_t ctx) gpgme_ctx_get_engine_info (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_ctx_get_engine_info", ctx, TRACE (DEBUG_CTX, "gpgme_ctx_get_engine_info", NULL,
"ctx->engine_info=%p", ctx->engine_info); "ctx=%lu engine_info=%p", CTXSERIAL (ctx), ctx->engine_info);
return ctx->engine_info; return ctx->engine_info;
} }
@ -1067,9 +1087,9 @@ gpgme_ctx_set_engine_info (gpgme_ctx_t ctx, gpgme_protocol_t proto,
const char *file_name, const char *home_dir) const char *file_name, const char *home_dir)
{ {
gpgme_error_t err; gpgme_error_t err;
TRACE_BEG (DEBUG_CTX, "gpgme_ctx_set_engine_info", ctx, TRACE_BEG (DEBUG_CTX, "gpgme_ctx_set_engine_info", NULL,
"protocol=%i (%s), file_name=%s, home_dir=%s", "ctx=%lu protocol=%i (%s), file_name=%s, home_dir=%s",
proto, gpgme_get_protocol_name (proto) CTXSERIAL (ctx), proto, gpgme_get_protocol_name (proto)
? gpgme_get_protocol_name (proto) : "unknown", ? gpgme_get_protocol_name (proto) : "unknown",
file_name ? file_name : "(default)", file_name ? file_name : "(default)",
home_dir ? home_dir : "(default)"); home_dir ? home_dir : "(default)");
@ -1112,7 +1132,8 @@ _gpgme_sig_notation_clear (gpgme_ctx_t ctx)
void void
gpgme_sig_notation_clear (gpgme_ctx_t ctx) gpgme_sig_notation_clear (gpgme_ctx_t ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_sig_notation_clear", ctx, ""); TRACE (DEBUG_CTX, "gpgme_sig_notation_clear", NULL, "ctx=%lu",
CTXSERIAL (ctx));
if (!ctx) if (!ctx)
return; return;
@ -1134,8 +1155,9 @@ gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
gpgme_sig_notation_t notation; gpgme_sig_notation_t notation;
gpgme_sig_notation_t *lastp; gpgme_sig_notation_t *lastp;
TRACE_BEG (DEBUG_CTX, "gpgme_sig_notation_add", ctx, TRACE_BEG (DEBUG_CTX, "gpgme_sig_notation_add", NULL,
"name=%s, value=%s, flags=0x%x", "ctx=%lu name=%s value=%s flags=0x%x",
CTXSERIAL (ctx),
name ? name : "(null)", value ? value : "(null)", name ? name : "(null)", value ? value : "(null)",
flags); flags);
@ -1167,11 +1189,12 @@ gpgme_sig_notation_get (gpgme_ctx_t ctx)
{ {
if (!ctx) if (!ctx)
{ {
TRACE (DEBUG_CTX, "gpgme_sig_notation_get", ctx, ""); TRACE (DEBUG_CTX, "gpgme_sig_notation_get", NULL, "ctx=%lu",
CTXSERIAL (ctx));
return NULL; return NULL;
} }
TRACE (DEBUG_CTX, "gpgme_sig_notation_get", ctx, TRACE (DEBUG_CTX, "gpgme_sig_notation_get", NULL,
"ctx->sig_notations=%p", ctx->sig_notations); "ctx=%lu sig_notations=%p", CTXSERIAL (ctx), ctx->sig_notations);
return ctx->sig_notations; return ctx->sig_notations;
} }

View File

@ -136,8 +136,8 @@ _gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc,
return err; return err;
} }
TRACE (DEBUG_CTX, "_gpgme_add_io_cb", ctx, TRACE (DEBUG_CTX, "_gpgme_add_io_cb", NULL,
"fd=%d, dir=%d -> tag=%p", fd, dir, tag); "ctx=%lu fd=%d dir=%d -> tag=%p", CTXSERIAL (ctx), fd, dir, tag);
*r_tag = tag; *r_tag = tag;
return 0; return 0;
@ -159,9 +159,11 @@ _gpgme_remove_io_cb (void *data)
assert (fdt); assert (fdt);
idx = tag->idx; idx = tag->idx;
TRACE (DEBUG_CTX, "_gpgme_remove_io_cb", data, TRACE (DEBUG_CTX, "_gpgme_remove_io_cb", NULL,
"setting fd 0x%x (item=%p) done", fdt->fds[idx].fd, "ctx=%lu setting fd=%d (item=%p data=%p) done",
fdt->fds[idx].opaque); CTXSERIAL (ctx),
fdt->fds[idx].fd,
fdt->fds[idx].opaque, data);
free (fdt->fds[idx].opaque); free (fdt->fds[idx].opaque);
free (tag); free (tag);