summaryrefslogtreecommitdiffabout
path: root/src/gdbmstore.c
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 /src/gdbmstore.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/gdbmstore.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/gdbmstore.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index 1d7c648..050b0a9 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -47,12 +47,16 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
int new_size; /* Used in allocating space. */
int rc;
+ GDBM_DEBUG_DATUM (GDBM_DEBUG_STORE, key, "%s: storing key:", dbf->name);
+
/* Return immediately if the database needs recovery */
GDBM_ASSERT_CONSISTENCY (dbf, -1);
/* First check to make sure this guy is a writer. */
if (dbf->read_write == GDBM_READER)
{
+ GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
+ "%s: can't store: not a writer", dbf->name);
gdbm_set_errno (dbf, GDBM_READER_CANT_STORE, FALSE);
return -1;
}
@@ -61,6 +65,8 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
NULL dptr returned by a lookup procedure indicates an error. */
if ((key.dptr == NULL) || (content.dptr == NULL))
{
+ GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
+ "%s: can't store: invalid key or content", dbf->name);
gdbm_set_errno (dbf, GDBM_ILLEGAL_DATA, FALSE);
return -1;
}
@@ -97,6 +103,8 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
}
else
{
+ GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
+ "%s: cannot replace", dbf->name);
gdbm_set_errno (dbf, GDBM_CANNOT_REPLACE, FALSE);
return 1;
}
@@ -148,6 +156,8 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
__lseek (dbf, file_adr, SEEK_SET));
if (file_pos != file_adr)
{
+ GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
+ "%s: lseek: %s", dbf->name, strerror (errno));
gdbm_set_errno (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
_gdbm_fatal (dbf, _("lseek error"));
return -1;
@@ -157,6 +167,8 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
_gdbm_full_write (dbf, key.dptr, key.dsize));
if (rc)
{
+ GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
+ "%s: writing key: %s", dbf->name, strerror (errno));
gdbm_set_errno (dbf, rc, TRUE);
_gdbm_fatal (dbf, gdbm_strerror (rc));
return -1;
@@ -167,6 +179,9 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
content.dptr, content.dsize));
if (rc)
{
+ GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR,
+ "%s: writing content: %s",
+ dbf->name, strerror (errno));
gdbm_set_errno (dbf, rc, TRUE);
_gdbm_fatal (dbf, gdbm_strerror (rc));
return -1;

Return to:

Send suggestions and report system problems to the System administrator.