From 9f74cfbd847663f80c362cf06bda7e749f0f694b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dejan=20Jovanovi=C4=87?= Date: Wed, 9 May 2012 03:31:50 +0000 Subject: [PATCH] Fixing the debug tags generation and related methods in configuration.cpp that disallowed me to debug my bugs by reporting that the debug tag doesn't exists, where in fact it was in the code. 1) The grep and sed for tags wasn't picking up on .isOn("tag") 2) The isDebugTag a) didn't take a parameter b) was using binary search using strcmp which is non-portable and didn't work for tags including special characters Morgan should vet this, since there is some crazy sed stuff going on --- src/util/Makefile.am | 4 ++-- src/util/configuration.cpp | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 4945f6339..87fa2c890 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -128,9 +128,9 @@ endif # expression (no |, no \<, ...). Debug_tags.tmp Trace_tags.tmp: $(AM_V_GEN)\ - grep '\<$(@:_tags.tmp=) *( *\".*\" *)' \ + grep '\<$(@:_tags.tmp=)\(\.isOn\)\? *( *\".*\" *)' \ `find @srcdir@/../ -name "*.cpp" -or -name "*.h" -or -name "*.cc" -or -name "*.g"` | \ - sed 's/^$(@:_tags.tmp=) *( *\"\([^"]*\)\".*/\1/;s/.*[^a-zA-Z0-9_]$(@:_tags.tmp=) *( *\"\([^"]*\)\".*/\1/' | sort | uniq >"$@" + sed 's/^$(@:_tags.tmp=)\(.isOn\)\? *( *\"\([^"]*\)\".*/\2/;s/.*[^a-zA-Z0-9_]$(@:_tags.tmp=)\(\.isOn\)\? *( *\"\([^"]*\)\".*/\2/' | sort | uniq >"$@" if CVC4_CLN_IMP libutil_la_SOURCES += \ diff --git a/src/util/configuration.cpp b/src/util/configuration.cpp index abda24c26..66b0a2f90 100644 --- a/src/util/configuration.cpp +++ b/src/util/configuration.cpp @@ -153,15 +153,17 @@ int strcmpptr(const char **s1, const char **s2){ return strcmp(*s1,*s2); } -bool Configuration::isDebugTag(char const *){ +bool Configuration::isDebugTag(char const *tag){ #if CVC4_DEBUG unsigned ntags = getNumDebugTags(); char const* const* tags = getDebugTags(); - return (bsearch(&optarg, tags, ntags, sizeof(char *), - (int(*)(const void*,const void*))strcmpptr) != NULL); -#else /* CVC4_DEBUG */ + for (unsigned i = 0; i < ntags; ++ i) { + if (strcmp(tag, tags[i]) == 0) { + return true; + } + } +#endif * CVC4_DEBUG */ return false; -#endif /* CVC4_DEBUG */ } unsigned Configuration::getNumTraceTags() { @@ -182,15 +184,17 @@ char const* const* Configuration::getTraceTags() { #endif /* CVC4_TRACING */ } -bool Configuration::isTraceTag(char const *){ +bool Configuration::isTraceTag(char const * tag){ #if CVC4_TRACING unsigned ntags = getNumTraceTags(); char const* const* tags = getTraceTags(); - return (bsearch(&optarg, tags, ntags, sizeof(char *), - (int(*)(const void*,const void*))strcmpptr) != NULL); -#else /* CVC4_TRACING */ - return false; + for (unsigned i = 0; i < ntags; ++ i) { + if (strcmp(tag, tags[i]) == 0) { + return true; + } + } #endif /* CVC4_TRACING */ + return false; } bool Configuration::isSubversionBuild() { -- 2.30.2