summaryrefslogtreecommitdiffabout
path: root/tests
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-25 09:37:52 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-07-25 09:54:39 (GMT)
commit364f4246159b8d338c2fafc70b868ffc83816c2f (patch) (side-by-side diff)
treed6609a1a066d657df4d7615f55834a29f45c6c6f /tests
parentde7834e96602695db1cb6efd6238398b84d2ca60 (diff)
downloadgdbm-364f4246159b8d338c2fafc70b868ffc83816c2f.tar.gz
gdbm-364f4246159b8d338c2fafc70b868ffc83816c2f.tar.bz2
Add debug info.
* configure.ac: Fix description wording. * src/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Don't define GDBM_DEBUG_ENABLE. * tests/Makefile.am: Likewise. * src/debug.c (gdbm_debug_printer) (gdbm_debug_flags): New globals. (gdbm_debug_token, gdbm_debug_parse_state) (gdbm_debug_datum): New functions. * src/gdbm.h.in [@GDBM_DEBUG_ENABLE@]: Define GDBM_DEBUG_ENABLE. (gdbm_debug_printer_t): New typedef. (gdbm_debug_printer, gdbm_debug_flags): New externs. (GDBM_DEBUG_ERR,GDBM_DEBUG_OPEN) (GDBM_DEBUG_READ,GDBM_DEBUG_STORE) (GDBM_DEBUG_LOOKUP,GDBM_DEBUG_ALL): New defines. (gdbm_debug_token,gdbm_debug_parse_state) (gdbm_debug_datum): New protos. * src/gdbmdefs.h (GDBM_DEBUG,GDBM_DEBUG_DATUM): New macros. * src/findkey.c: Add debugging info. * src/gdbmfetch.c: Likewise. * src/gdbmopen.c: Likewise. * src/gdbmseq.c: Likewise. * src/gdbmstore.c: Likewise. * src/gdbmtool.c (open_handler): Allow the use of ~/ (command) <repeat,variadic>: New members. (run_command): Handle variadic functions. (run_last_command): New command. In interactive mode, repeats the last command if it was marked with repeat=1 (currently, only "next"). New command: "debug". (all functions): Use terror instead of fprintf(stderr,...); * src/gdbmtool.h (handler_param) <vararg>: New member. (run_last_command): New proto. * src/gram.y: Call run_last_command) on empty input. * tests/gtload.c: New option: -debug=
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/gtload.c33
2 files changed, 33 insertions, 4 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ae6cbb9..2e68e69 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -120,10 +120,6 @@ check_PROGRAMS = \
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(DBMINCLUDES)
-if GDBM_COND_DEBUG_ENABLE
- AM_CPPFLAGS += -DGDBM_DEBUG_ENABLE=1
-endif
-
noinst_HEADERS=progname.h
LDADD = ../src/libgdbm.la
diff --git a/tests/gtload.c b/tests/gtload.c
index f9f1bb1..10f65c3 100644
--- a/tests/gtload.c
+++ b/tests/gtload.c
@@ -120,9 +120,23 @@ install_hook (char *id)
}
}
}
+#ifdef GDBM_DEBUG_ENABLE
_gdbm_debug_hook_install (id, hookfn, clos);
+#endif
}
+#ifdef GDBM_DEBUG_ENABLE
+void
+debug_printer (char const *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+}
+#endif
+
int
main (int argc, char **argv)
{
@@ -146,6 +160,10 @@ main (int argc, char **argv)
int rcvr_flags = 0;
progname = canonical_progname (argv[0]);
+#ifdef GDBM_DEBUG_ENABLE
+ gdbm_debug_printer = debug_printer;
+#endif
+
while (--argc)
{
char *arg = *++argv;
@@ -209,6 +227,21 @@ main (int argc, char **argv)
rcvr.max_failures = read_size (arg + 20);
rcvr_flags |= GDBM_RCVR_MAX_FAILED_BUCKETS;
}
+#ifdef GDBM_DEBUG_ENABLE
+ else if (strncmp (arg, "-debug=", 7) == 0)
+ {
+ char *p;
+
+ for (p = strtok (arg + 7, ","); p; p = strtok (NULL, ","))
+ {
+ int f = gdbm_debug_token (p);
+ if (!f)
+ fprintf (stderr, "%s: unknown flag: %s\n", progname, p);
+ else
+ gdbm_debug_flags |= f;
+ }
+ }
+#endif
else if (strcmp (arg, "--") == 0)
{
--argc;

Return to:

Send suggestions and report system problems to the System administrator.