1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-20 01:02:44 +02:00

gpg: Print available debug flags using "--debug-level help".

* g10/gpg.c (set_debug): Add "help" option and use a table for the
flags.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2015-06-19 14:56:46 +02:00
parent c5604eeee4
commit 663a31f1ea
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 46 additions and 18 deletions

View File

@ -2320,6 +2320,8 @@ a numeric value or by a keyword:
All of the debug messages you can get. A value greater than 8 may be All of the debug messages you can get. A value greater than 8 may be
used instead of the keyword. The creation of hash tracing files is used instead of the keyword. The creation of hash tracing files is
only enabled if the keyword is used. only enabled if the keyword is used.
@item help
List all available debug flags (see @option{debug}) and stop.
@end table @end table
How these messages are mapped to the actual debugging flags is not How these messages are mapped to the actual debugging flags is not

View File

@ -1084,8 +1084,27 @@ set_opt_session_env (const char *name, const char *value)
static void static void
set_debug (const char *level) set_debug (const char *level)
{ {
static struct { unsigned short val; const char *name; } flags [] = {
{ DBG_PACKET_VALUE , "packet" },
{ DBG_MPI_VALUE , "mpi" },
{ DBG_CRYPTO_VALUE , "crypto" },
{ DBG_FILTER_VALUE , "filter" },
{ DBG_IOBUF_VALUE , "iobuf" },
{ DBG_MEMORY_VALUE , "memory" },
{ DBG_CACHE_VALUE , "cache" },
{ DBG_MEMSTAT_VALUE, "memstat" },
{ DBG_TRUST_VALUE , "trust" },
{ DBG_HASHING_VALUE, "hashing" },
{ DBG_CARD_IO_VALUE, "cardio" },
{ DBG_IPC_VALUE , "ipc" },
{ DBG_CLOCK_VALUE , "clock" },
{ DBG_LOOKUP_VALUE , "lookup"},
{ DBG_EXTPROG_VALUE, "extprog" },
{ 0, NULL }
};
int numok = (level && digitp (level)); int numok = (level && digitp (level));
int numlvl = numok? atoi (level) : 0; int numlvl = numok? atoi (level) : 0;
int i;
if (!level) if (!level)
; ;
@ -1108,10 +1127,26 @@ set_debug (const char *level)
if (numok) if (numok)
opt.debug &= ~(DBG_HASHING_VALUE); opt.debug &= ~(DBG_HASHING_VALUE);
} }
else if (!strcmp (level, "help"))
{
es_printf ("Available debug flags:\n");
for (i=0; flags[i].name; i++)
es_printf (" %5hu %s\n", flags[i].val, flags[i].name);
g10_exit (0);
}
else else
{ {
log_error (_("invalid debug-level '%s' given\n"), level); for (i=0; flags[i].name; i++)
g10_exit (2); if (!strcmp (level, flags[i].name))
{
opt.debug |= flags[i].val;
break;
}
if (!flags[i].name)
{
log_error (_("invalid debug-level '%s' given\n"), level);
g10_exit (2);
}
} }
if (opt.debug & DBG_MEMORY_VALUE ) if (opt.debug & DBG_MEMORY_VALUE )
@ -1127,22 +1162,13 @@ set_debug (const char *level)
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose); gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
if (opt.debug) if (opt.debug)
log_info ("enabled debug flags:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", {
(opt.debug & DBG_PACKET_VALUE )? " packet":"", log_info ("enabled debug flags:");
(opt.debug & DBG_MPI_VALUE )? " mpi":"", for (i=0; flags[i].name; i++)
(opt.debug & DBG_CRYPTO_VALUE )? " crypto":"", if ((opt.debug & flags[i].val))
(opt.debug & DBG_FILTER_VALUE )? " filter":"", log_printf (" %s", flags[i].name);
(opt.debug & DBG_IOBUF_VALUE )? " iobuf":"", log_printf ("\n");
(opt.debug & DBG_MEMORY_VALUE )? " memory":"", }
(opt.debug & DBG_CACHE_VALUE )? " cache":"",
(opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"",
(opt.debug & DBG_TRUST_VALUE )? " trust":"",
(opt.debug & DBG_HASHING_VALUE)? " hashing":"",
(opt.debug & DBG_EXTPROG_VALUE)? " extprog":"",
(opt.debug & DBG_CARD_IO_VALUE)? " cardio":"",
(opt.debug & DBG_IPC_VALUE )? " ipc":"",
(opt.debug & DBG_CLOCK_VALUE )? " clock":"",
(opt.debug & DBG_LOOKUP_VALUE )? " lookup":"");
} }