summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-05-24 14:46:07 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-05-24 15:16:01 (GMT)
commit8d2f483b28f8418703982658b3e7dda7a96ad335 (patch) (side-by-side diff)
tree731e5d6103090f835dd7602395f44fd2154c7d6b
parentb001c227fdf02e3ed1e87161cbc1dec4a1184203 (diff)
downloadgdbm-8d2f483b28f8418703982658b3e7dda7a96ad335.tar.gz
gdbm-8d2f483b28f8418703982658b3e7dda7a96ad335.tar.bz2
Various fixes
* src/input-std.c: Bugfix * doc/gdbm.texi: Document changes. * README: Update. * configure.ac: New option --enable-gdbmtool-debug. * src/Makefile.am: Conditionally augment AM_YFLAGS and AM_LFLAGS with options that enable debugging. * src/gdbmtool.c: Conditionally enable --lex-trace and --gram-trace options. * src/gram.y: Likewise. * src/lex.l: Likewise. * tests/Makefile.am: Remove architecure-dependent tests. * tests/testsuite.at: Likewise.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--README9
-rw-r--r--configure.ac28
-rw-r--r--doc/gdbm.texi62
-rw-r--r--src/Makefile.am8
-rw-r--r--src/gdbmtool.c2
-rw-r--r--src/gdbmtool.h3
-rw-r--r--src/gram.y2
-rw-r--r--src/input-std.c13
-rw-r--r--src/lex.l2
-rw-r--r--tests/Makefile.am5
-rw-r--r--tests/dump01.at38
-rw-r--r--tests/dump02.at35
-rw-r--r--tests/dump03.at38
-rw-r--r--tests/dump04.at34
-rw-r--r--tests/testsuite.at11
15 files changed, 110 insertions, 180 deletions
diff --git a/README b/README
index 4481b51..774ca00 100644
--- a/README
+++ b/README
@@ -46,6 +46,15 @@ to install them elsewhere, define the variable COMPATINCLUDEDIR, e.g.
Don't compile GNU Readline support. By default, configure enables
line-editing support if GNU Readline is available on the system.
+** --enable-gdbmtool-debug
+
+This option instruments gdbmtool for additional debugging. Configured
+with this option, gdbmtool accepts two additional arguments:
+--lex-trace, which enables tracing the operation of the lexical
+analyzer, and --gram-trace, which enables parser tracing output.
+
+Note, that this additional instrumentation requires bison and flex.
+
* Installation
make install
diff --git a/configure.ac b/configure.ac
index 25c4ff4..eff0083 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,20 +39,36 @@ AC_SUBST([GDBM_VERSION_PATCH], m4_ifdef([_GDBM_VERSION_PATCH],_GDBM_VERSION_PATC
AC_ARG_ENABLE([memory-mapped-io],
AC_HELP_STRING(
- [--enable-memory-mapped-io]
+ [--enable-memory-mapped-io],
[Use mmap(2) for disk I/O. (Default is YES.)]),
- [mapped_io=$enableval],
- [mapped_io=yes])
+ [mapped_io=$enableval],
+ [mapped_io=yes])
AC_ARG_ENABLE([libgdbm-compat],
AC_HELP_STRING(
- [--enable-libgdbm-compat]
+ [--enable-libgdbm-compat],
[Build and install libgdbm_compat. (Default is NO.)]),
- [want_compat=$enableval],
- [want_compat=no])
+ [want_compat=$enableval],
+ [want_compat=no])
AC_ARG_VAR([COMPATINCLUDEDIR],[installation directory for dbm.h and ndbm.h])
test -z "$COMPATINCLUDEDIR" && COMPATINCLUDEDIR='$(includedir)'
+AC_ARG_ENABLE([gdbmtool-debug],
+ AC_HELP_STRING(
+ [--enable-gdbmtool-debug],
+ [instrument gdbmtool for additional debugging]),
+ [want_gdbmtool_debug=$enableval],
+ [want_gdbmtool_debug=no])
+
+AC_SUBST(YFLAGS_DEBUG)
+AC_SUBST(LFLAGS_DEBUG)
+if test "$want_gdbmtool_debug" = yes; then
+ YFLAGS_DEBUG=-t
+ LFLAGS_DEBUG=-d
+fi
+
+AM_CONDITIONAL([COND_GDBMTOOL_DEBUG], [test "$want_gdbmtool_debug" = yes])
+
dnl Check for programs
AC_PROG_CC
AC_PROG_CPP
diff --git a/doc/gdbm.texi b/doc/gdbm.texi
index 0876f8d..8920839 100644
--- a/doc/gdbm.texi
+++ b/doc/gdbm.texi
@@ -1956,6 +1956,24 @@ the database already exists, it will be deleted, so use it sparingly.
@section gdbmtool invocation
@cindex command line options, @command{gdbmtool}
+When started without additional arguments, @command{gdbmtool} operates
+on the default database @file{junk.gdbm}. Otherwise, the first
+argument supplies the name of the database to operate upon. If neither
+any additional arguments nor the @option{-f} (@option{--file}) option
+are given, @command{gdbmtool} opens starts interactive shell and
+receives commands directly from the human operator.
+
+If more than one arguments are given, all arguments past the database
+name are parsed as @command{gdbmtool} commands (@pxref{shell}, for a
+description of available commands) and executed in turn. All commands,
+except the last one, should be terminated with semicolons. Semicolon
+after the last command is optional. Note, that semicolons should be
+escaped in order to prevent them from being interpreted by the shell.
+
+Finally, if the @option{-f} (@option{--file}) option is supplied, its
+argument specifies the name of the disk file with @command{gdbmtool}
+script. The program will open that file and read commands from it.
+
The following table summarizes all @command{gdbmtool} command line
options:
@@ -2022,10 +2040,11 @@ detects end-of-file on its standard input, whichever occurs first.
A @command{gdbmtool} command consists of a @dfn{command verb},
optionally followed by @dfn{arguments}, separated by any
-amount of white space. A command verb can be entered either in full
-or in an abbreviated form, as long as that abbreviation does not match
-any other verb. For example, @samp{co} can be used instead of
-@samp{count} and @samp{ca} instead of @samp{cache}.
+amount of white space and terminated with a newline or semicolon.
+A command verb can be entered either in full or in an abbreviated
+form, as long as that abbreviation does not match any other verb. For
+example, @samp{co} can be used instead of @samp{count} and @samp{ca}
+instead of @samp{cache}.
Any sequence of non-whitespace characters appearing after the command
verb forms an argument. If the argument contains whitespace or
@@ -2305,6 +2324,14 @@ Print the number of entries in the database.
Print the current bucket.
@end deffn
+@deffn {command verb} debug [[+-]@var{token}...]
+If @command{GDBM} is configured with additional debugging, this
+statement queries or sets @command{GDBM} internal debugging level.
+This is intended for debugging and testing purposes and requires
+good knowledge of @command{GDBM} internals. The use of this command is
+not recommended.
+@end deffn
+
@deffn {command verb} delete @var{key}
Delete record with the given @var{key}
@end deffn
@@ -2423,6 +2450,33 @@ Specifies the permissions to use in case a new file is created.
Close the database and quit the utility.
@end deffn
+@deffn {command verb} recover [@var{options}]
+Run database recovery. The following @var{options} are understood:
+
+@table @option
+@item backup
+Create a backup copy of the original database.
+
+@item max-failed-buckets=@var{n}
+Abort recovery process if @var{n} buckets could not be recovered.
+
+@item max-failed-keys=@var{n}
+Abort recovery process if @var{n} keys could not be recovered.
+
+@item max-failures=@var{n}
+Abort recovery process after @var{n} failures. A @dfn{failure} in this
+context is either a key or a bucket that failed to be recovered.
+
+@item summary
+Print the recovery statistics at the end of the run. The statistics
+includes number of successfully recovered, failed and duplicate keys
+and the number of recovered and failed buckets.
+
+@item verbose
+Verbosely list each error encountered.
+@end table
+@end deffn
+
@deffn {command verb} reorganize
Reorganize the database (@pxref{Reorganization}).
@end deffn
diff --git a/src/Makefile.am b/src/Makefile.am
index 766dba8..0d2ca53 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -110,8 +110,12 @@ else
gdbmtool_SOURCES += input-std.c
endif
-AM_YFLAGS = -dtv
-AM_LFLAGS = -d
+AM_YFLAGS = -dv $(YFLAGS_DEBUG)
+AM_LFLAGS = $(LFLAGS_DEBUG)
+
+if COND_GDBMTOOL_DEBUG
+ AM_CPPFLAGS += -DGDBMTOOL_DEBUG=1
+endif
gdbm_load_LDADD = ./libgdbmapp.a ./libgdbm.la
gdbm_dump_LDADD = ./libgdbmapp.a ./libgdbm.la
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 575b97b..b3055a6 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -1528,8 +1528,10 @@ struct gdbm_option optab[] = {
{ 'r', "read-only", NULL, N_("open database in read-only mode") },
{ 's', "synchronize", NULL, N_("synchronize to disk after each write") },
{ 'q', "quiet", NULL, N_("don't print initial banner") },
+#if GDBMTOOL_DEBUG
{ OPT_LEX_TRACE, "lex-trace", NULL, N_("enable lexical analyzer traces") },
{ OPT_GRAM_TRACE, "gram-trace", NULL, N_("enable grammar traces") },
+#endif
{ 0 }
};
diff --git a/src/gdbmtool.h b/src/gdbmtool.h
index c472276..aee483c 100644
--- a/src/gdbmtool.h
+++ b/src/gdbmtool.h
@@ -342,6 +342,9 @@ int yylex (void);
int yyerror (char const *s);
int yyparse (void);
+void lex_trace (int n);
+void gram_trace (int n);
+
void datum_format (FILE *fp, datum const *dat, struct dsegm *ds);
int datum_scan (datum *dat, struct dsegm *ds, struct kvpair *kv);
void dsprint (FILE *fp, int what, struct dsegm *ds);
diff --git a/src/gram.y b/src/gram.y
index 5372795..6c79c7a 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -375,5 +375,7 @@ yyerror (char const *s)
void
gram_trace (int n)
{
+#if GDBMTOOL_DEBUG
yydebug = 1;
+#endif
}
diff --git a/src/input-std.c b/src/input-std.c
index 45ae506..6a95eb6 100644
--- a/src/input-std.c
+++ b/src/input-std.c
@@ -41,15 +41,14 @@ instream_stdin_eq (instream_t a, instream_t b)
instream_t
instream_stdin_create (void)
{
- struct instream_file *istr;
+ struct instream *istr;
istr = emalloc (sizeof *istr);
- istr->base.in_name = "stdin";
- istr->base.in_inter = isatty (fileno (stdin));
- istr->base.in_read = instream_stdin_read;
- istr->base.in_close = instream_stdin_close;
- istr->base.in_eq = instream_stdin_eq;
- istr->fp = stdin;
+ istr->in_name = "stdin";
+ istr->in_inter = isatty (fileno (stdin));
+ istr->in_read = instream_stdin_read;
+ istr->in_close = instream_stdin_close;
+ istr->in_eq = instream_stdin_eq;
return istr;
}
diff --git a/src/lex.l b/src/lex.l
index 0318031..eff2ec7 100644
--- a/src/lex.l
+++ b/src/lex.l
@@ -121,7 +121,9 @@ input_context_push (instream_t input)
void
lex_trace (int n)
{
+#if GDBMTOOL_DEBUG
yy_flex_debug = n;
+#endif
}
int
diff --git a/tests/Makefile.am b/tests/Makefile.am
index feead9f..827af58 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -63,11 +63,6 @@ TESTSUITE_AT = \
dbmfetch01.at\
dbmfetch02.at\
dbmfetch03.at\
- dump00.at\
- dump01.at\
- dump02.at\
- dump03.at\
- dump04.at\
create00.at\
delete00.at\
delete01.at\
diff --git a/tests/dump01.at b/tests/dump01.at
deleted file mode 100644
index dae4f25..0000000
--- a/tests/dump01.at
+++ b/dev/null
@@ -1,38 +0,0 @@
-# This file is part of GDBM. -*- autoconf -*-
-# Copyright (C) 2018 Free Software Foundation, Inc.
-#
-# GDBM is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GDBM is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
-
-AT_SETUP([Invalid bucket size in header])
-AT_KEYWORDS([dump])
-AT_CHECK([
-AT_UNPACK([t.db],dnl
-[H4sICC3M/1oAA2lkOjAwMDAwMCxzaWc6MTEsc3JjOjAwMDAwMCxvcDpoYXZvYyxyZXA6MTI4AO1a
-XUrDQBjctUXbgrVYsEVbLdRXwSPkwRMI4gUEvUVzC8EHD+BlvIBo+6AWERSfCtV8bmtj/nbTJPub
-tgM67OTbmbGJEBfvb87rqIZQg3xNQbg84YEPZPmNcoK21nSsIuTAvygGr32ApFBLrN2OWLuUcE60
-xpuFMw+eSB7kpr5KFOj9vV5hybCRekdx/ggdP4HVkYeshorxkmUTDDgStzn2hmEL9FKOPY3Zd6l3
-DAsSauQUAPAkx/ld1htgjlDSXWCCKtfu2vwRP2yKpuSPkRXC6P9Bdw3UWRaGnhk9XN4ypEfeeJxk
-Dh6l5b8Bp48DgfWVkF4W536DuKwqr6IoZxGZLusstSnXn7yK93V/6HJ43ZAeGbhrSI9GynnthReC
-Xw3psWIhDNAD1vVDXn8svq8ONqCCOLbU5/JsnhxMKi3L5AuEEs1FGLv73HOjYyQV5KWJcs7YjOg4
-dp6qg5NunluPn7ml67NDh4CO/31wZD6KNaTiZ6ScIyr4bJ0MPpGmsfOXQa2WradAfZfbh42EPiPI
-lJtAP6XpNjDn2frAW+i9X6bp5NuIorfU9CkMEdqX6G+w3nZ1S2luK6L71p0QC84vRfVq3HxQDz+S
-ht3PWL1sWJ8kepOhcxiPWQ9eSh9bUJ/86Cqy+jHzn1JymdPXyVxsEW0wQ0/m43xlzV0QvSvKfzug
-133D0wvh8YqoXIIHQT6zf08y5fY8zzr+Ao/nJqluLwAA])
-gdbm_dump t.db t
-],
-[1],
-[],
-[gdbm_dump: gdbm_open failed: Malformed database file header
-])
-AT_CLEANUP
diff --git a/tests/dump02.at b/tests/dump02.at
deleted file mode 100644
index da0b62b..0000000
--- a/tests/dump02.at
+++ b/dev/null
@@ -1,35 +0,0 @@
-# This file is part of GDBM. -*- autoconf -*-
-# Copyright (C) 2018 Free Software Foundation, Inc.
-#
-# GDBM is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GDBM is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
-
-AT_SETUP([Invalid count of bucket elements in header])
-AT_KEYWORDS([dump])
-AT_CHECK([
-AT_UNPACK([t.db],dnl
-[H4sICC3M/1oAA2lkOjAwMDAwMSxzaWc6MTEsc3JjOjAwMDAwMCxvcDpoYXZvYyxyZXA6NjQA7ZpB
-asJQEIaf0gjVIpYWBEF4R+i6q9yix9FzuOqq6x6gd+gZ3LlxIQgSkb6mJopKXpNMZjITMj/qT/4X
-Zz6S8KJJvhdvT2ZkzPFtEr9P/SOKPUziQzo8d6bdCpwLLhZdrPJFemg4KtWV7rgBmqZJ7R1noDmD
-WVtugDZo4B2hPmPsjy9VntZ0pWE/JWjV5QZoswRs/PpPjqrGaff/xBWPLmtjUZHINsRfhHCoM3uf
-rP5nkfW6OePqMH/n59g43v5ZboVwVHJbcD31s78K4VAHeqKpEBqb3u3h58D1S52usvAxjZn6UvhI
-CEfikSPvQ1wefGhzc6jT+DNP3066eH4s4PTHmki+a9/Y+RdT39bkfx9WEM8ctX50O1ikjvPkCDzX
-egDuL3QQzTWvlq9+8Oo/drLznDo9T16Zx3uvJOc7IVVvzWXmEhjk5kNhPOS58+Tl6hR8fhWSZw0A
-jvkgK2TZ/qGI/a45Sn5An5Or8YDy2e1gWf5fmUPXK/AvAAA=])
-gdbm_dump t.db t
-],
-[1],
-[],
-[gdbm_dump: gdbm_open failed: Malformed database file header
-])
-AT_CLEANUP \ No newline at end of file
diff --git a/tests/dump03.at b/tests/dump03.at
deleted file mode 100644
index a084246..0000000
--- a/tests/dump03.at
+++ b/dev/null
@@ -1,38 +0,0 @@
-# This file is part of GDBM. -*- autoconf -*-
-# Copyright (C) 2018 Free Software Foundation, Inc.
-#
-# GDBM is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GDBM is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
-
-AT_SETUP([Negative bucket offset])
-AT_KEYWORDS([dump])
-AT_CHECK([
-AT_UNPACK([t.db],dnl
-[H4sICFRAAFsAA2lkOjAwMDAwMCxzaWc6MTEsc3JjOjAwMDA4NyswMDAwODYsb3A6c3BsaWNlLHJl
-cDoxNgDtlztOw0AQhtfCQkkIyEkaaJAxF6CkTM0FuAYFvVNzBEoKrkNNhZAAgQQRdCgF5uFH7M2u
-vbO79gzRjhT9mm9nZ35Hft5cnk5YwNjfj6Xaz/Sa2Yl3k837IhjmelLJQ35ZoHsiHgub1+oBH1xB
-qNqoK42I+KjqyEIfi5YYS36CCSKlYRXaGpvrsZ0+Q5P9AaCeTwYiDtOZ0cED92ybzNLT+47n2VDp
-JVFwhT47OvN5I6/QBo36kR6EdP1QuZdsWcebr7mvUM9wP0X1WVP4qP6gGijWqWuvVb+m2vXYSTt9
-j6D7gmrONp5b8YWiIyI+gOpJ13e7uAwstlqG4M3V1pz11POmurtfTWJsn6saS/iwnM9r+ySysGnU
-y9LiUZffO5Vj0FxSCvnHG20epbL4gvVJMP2PkeaKORkjjjvuOHVed0el5NNxx+t4aKY9w/0I6lHw
-IcZn2Lb+j14JIl16KtfeYnlcSPgFgf/OqVN99bJU/5O8Pra4XO1JNgXWt8qnEo7lxxp/I+ZneRJS
-8bN0RcmP445T44GEd+NnLOFYfhynyB8SWL0m3wTVh5za96PJP0H1ksCy/4h7ukUmfWbd+Vx3/pLA
-6tvlU6S5KLyvVL9aMG/bmOMi/g1YZ0xx+S8AAA==
-])
-gdbm_dump t.db t
-],
-[1],
-[],
-[gdbm_dump: dump error: Malformed bucket header
-])
-AT_CLEANUP \ No newline at end of file
diff --git a/tests/dump04.at b/tests/dump04.at
deleted file mode 100644
index a37ea03..0000000
--- a/tests/dump04.at
+++ b/dev/null
@@ -1,34 +0,0 @@
-# This file is part of GDBM. -*- autoconf -*-
-# Copyright (C) 2018 Free Software Foundation, Inc.
-#
-# GDBM is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GDBM is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
-
-AT_SETUP([Wrong dir_bits in header])
-AT_KEYWORDS([dump])
-AT_CHECK([
-AT_UNPACK([t.db],dnl
-[H4sICIxAAFsAA2lkOjAwMDAwMSxzaWc6MTEsc3JjOjAwMDA3OCswMDAwODgsb3A6c3BsaWNlLHJl
-cDoyAO2ZUQqCQBRFxyiCfoqEoD/bQUuINtECaiGtowW0gDbSFvpvAQVKpSmFMW8yZ/K9qXtADl6f
-etEPhdlvFqEaKHXfVO5x4W3mWR4nylN2KfojQbNFGiHmLuAlvVzXFN4iT5YvUHOxsfGKyI9W3VTH
-7vSClpOrUKTv8lR1UPsM9WnbohIAoCa/+LUGAACQcRHz8/1PRHAdC6nhjdkLwDAMwzBs9lBIDxiG
-YQ89EdLjnYNi97H+P1X2HOhD9Gpbo/nIMH/OosrXjwh3XdYt53MTrm6C3Lt8zXBf3Ro793NAjlxO
-HlaYZ6qGHPm38r6wPsiZ8tKIgD5O84iwtJ7IkX+S3wAsqaqZFzAAAA==
-])
-gdbm_dump t.db t
-],
-[1],
-[],
-[gdbm_dump: gdbm_open failed: Malformed database file header
-])
-AT_CLEANUP \ No newline at end of file
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 7ce3f53..b7b1e4e 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -27,10 +27,6 @@ m4_define([AT_COMPAT_PREREQ],[
test $COMPAT -eq 1 || AT_SKIP_TEST
])
-m4_define([AT_UNPACK],[
-test -n "$GZIP_BIN" && test -n "$BASE64_BIN" || AT_SKIP_TEST
-echo "$2" | $BASE64_BIN -d | $GZIP_BIN -d -c > $1])
-
dnl # Begin tests
AT_INIT
@@ -79,13 +75,6 @@ m4_include([cloexec01.at])
m4_include([cloexec02.at])
m4_include([cloexec03.at])
-AT_BANNER([Handling invalid input])
-m4_include([dump00.at])
-m4_include([dump01.at])
-m4_include([dump02.at])
-m4_include([dump03.at])
-m4_include([dump04.at])
-
AT_BANNER([gdbmtool])
m4_include([gdbmtool00.at])
m4_include([gdbmtool01.at])

Return to:

Send suggestions and report system problems to the System administrator.