aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmseq.c
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 /src/gdbmseq.c
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 'src/gdbmseq.c')
-rw-r--r--src/gdbmseq.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gdbmseq.c b/src/gdbmseq.c
index 4320366..08a8f10 100644
--- a/src/gdbmseq.c
+++ b/src/gdbmseq.c
@@ -101,6 +101,8 @@ gdbm_firstkey (GDBM_FILE dbf)
/* Set the default return value for not finding a first entry. */
return_val.dptr = NULL;
+ GDBM_DEBUG (GDBM_DEBUG_READ, "%s: getting first key", dbf->name);
+
/* Return immediately if the database needs recovery */
GDBM_ASSERT_CONSISTENCY (dbf, return_val);
@@ -113,6 +115,11 @@ gdbm_firstkey (GDBM_FILE dbf)
/* Look for first entry. */
get_next_key (dbf, -1, &return_val);
+ if (return_val.dptr)
+ GDBM_DEBUG_DATUM (GDBM_DEBUG_READ, return_val, "%s: found", dbf->name);
+ else
+ GDBM_DEBUG (GDBM_DEBUG_READ, "%s: key not found", dbf->name);
+
return return_val;
}
@@ -128,6 +135,8 @@ gdbm_nextkey (GDBM_FILE dbf, datum key)
/* Set the default return value for no next entry. */
return_val.dptr = NULL;
+ GDBM_DEBUG_DATUM (GDBM_DEBUG_READ, key, "%s: getting next key", dbf->name);
+
/* Return immediately if the database needs recovery */
GDBM_ASSERT_CONSISTENCY (dbf, return_val);
@@ -137,6 +146,7 @@ gdbm_nextkey (GDBM_FILE dbf, datum key)
/* Do we have a valid key? */
if (key.dptr == NULL)
{
+ GDBM_DEBUG (GDBM_DEBUG_READ, "%s: key not found", dbf->name);
gdbm_set_errno (dbf, GDBM_ITEM_NOT_FOUND, FALSE); /* FIXME: special error code perhaps */
return return_val;
}
@@ -148,5 +158,10 @@ gdbm_nextkey (GDBM_FILE dbf, datum key)
/* Find the next key. */
get_next_key (dbf, elem_loc, &return_val);
+ if (return_val.dptr)
+ GDBM_DEBUG_DATUM (GDBM_DEBUG_READ, return_val, "%s: found", dbf->name);
+ else
+ GDBM_DEBUG (GDBM_DEBUG_READ, "%s: key not found", dbf->name);
+
return return_val;
}

Return to:

Send suggestions and report system problems to the System administrator.