aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-25 12:37:52 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-07-25 12:54:39 +0300
commit364f4246159b8d338c2fafc70b868ffc83816c2f (patch)
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')
-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
@@ -122,6 +122,2 @@ 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
diff --git a/tests/gtload.c b/tests/gtload.c
index f9f1bb1..10f65c3 100644
--- a/tests/gtload.c
+++ b/tests/gtload.c
@@ -122,5 +122,19 @@ 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
@@ -148,2 +162,6 @@ main (int argc, char **argv)
progname = canonical_progname (argv[0]);
+#ifdef GDBM_DEBUG_ENABLE
+ gdbm_debug_printer = debug_printer;
+#endif
+
while (--argc)
@@ -211,2 +229,17 @@ main (int argc, char **argv)
}
+#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)

Return to:

Send suggestions and report system problems to the System administrator.