From 213138a7b72f1a6df4b252037faf074a68650e9c Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Tue, 31 Dec 2024 12:50:15 -0500 Subject: [PATCH] Split the "-ds" debug flag into "-ds" and "-dh" -ds prints parsed expressions -dh dumps hash-table statistics on exit. --- man/remind.1.in | 3 +++ src/init.c | 1 + src/main.c | 8 +++++++- src/types.h | 1 + tests/expr.rem | 2 +- tests/test.rem | 2 +- tests/torture2.rem | 2 +- 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/man/remind.1.in b/man/remind.1.in index eb8a62b7..a0e6deca 100644 --- a/man/remind.1.in +++ b/man/remind.1.in @@ -315,6 +315,9 @@ Trace the reading of reminder files Trace expression parsing and display the internal expression node tree. This is unlikely to be useful unless you are working on \fBRemind\fR's expression evaluation engine. +.TP +.B h +Dump hash-table statistics on exit. .RE .TP \fB\-g\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR]]]] diff --git a/src/init.c b/src/init.c index a4f1d896..2245bc93 100644 --- a/src/init.c +++ b/src/init.c @@ -634,6 +634,7 @@ void InitRemind(int argc, char const *argv[]) while (*arg) { switch(*arg++) { case 's': case 'S': DebugFlag |= DB_PARSE_EXPR; break; + case 'h': case 'H': DebugFlag |= DB_HASHSTATS; break; case 'e': case 'E': DebugFlag |= DB_ECHO_LINE; break; case 'x': case 'X': DebugFlag |= DB_PRTEXPR; break; case 't': case 'T': DebugFlag |= DB_PRTTRIG; break; diff --git a/src/main.c b/src/main.c index 4e57c813..7987763d 100644 --- a/src/main.c +++ b/src/main.c @@ -60,7 +60,7 @@ exitfunc(void) /* Kill any execution-time-limiter process */ unlimit_execution_time(); - if (DebugFlag & DB_PARSE_EXPR) { + if (DebugFlag & DB_HASHSTATS) { fflush(stdout); fflush(ErrFp); fprintf(ErrFp, "Variable hash table statistics:\n"); @@ -1273,6 +1273,12 @@ int DoDebug(ParsePtr p) else DebugFlag &= ~DB_PARSE_EXPR; break; + case 'h': + case 'H': + if (val) DebugFlag |= DB_HASHSTATS; + else DebugFlag &= ~DB_HASHSTATS; + break; + case 'x': case 'X': if (val) DebugFlag |= DB_PRTEXPR; diff --git a/src/types.h b/src/types.h index 0b081919..61269cae 100644 --- a/src/types.h +++ b/src/types.h @@ -207,6 +207,7 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */ #define DB_ECHO_LINE 16 #define DB_TRACE_FILES 32 #define DB_PARSE_EXPR 64 +#define DB_HASHSTATS 128 /* Enumeration of the tokens */ enum TokTypes diff --git a/tests/expr.rem b/tests/expr.rem index eabfa456..a50a88fb 100644 --- a/tests/expr.rem +++ b/tests/expr.rem @@ -1,4 +1,4 @@ -debug +sx +debug +hsx set a 1 diff --git a/tests/test.rem b/tests/test.rem index c93b5439..5146c12e 100644 --- a/tests/test.rem +++ b/tests/test.rem @@ -1440,7 +1440,7 @@ do "with space.rem" DEBUG -e # Output expression-node stats -DEBUG +s +DEBUG +h # Don't want Remind to queue reminders EXIT diff --git a/tests/torture2.rem b/tests/torture2.rem index 63711e1f..a61ab581 100644 --- a/tests/torture2.rem +++ b/tests/torture2.rem @@ -600001,4 +600001,4 @@ TRANSLATE "99999" SET BOOGIE 1 FSET QUUX(x) x*2 TRANSLATE "A" "B" -DEBUG +s +DEBUG +h