Expose YR_DEBUG_VERBOSITY in configure script. (#1542)

Add a --with-debug-verbose option to the configure script which takes a number
greater than 0 as an argument. This gives us the flexibility to make verbosity
of this useful debugging information greater than it's current maximum (2)
without needing to modify the configure script.

Currently the maximum is 2, which gets you a lot of useful runtime debugging
information. A value of 1 is only used in tests. It may be worth it to consider
reworking this system so the numbers describe how much information you want.
For example, 1 could just be function entry and exit, 2 could add arguments to
it. I'll leave changing that up to a future diff if it is desired.

While here, fix a warning in the scanner from using an incorrect format string:

scan.c:644:7: warning: format specifies type 'long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
      match_offset,
      ^~~~~~~~~~~~~
./include/yara/globals.h:100:29: note: expanded from macro 'YR_DEBUG_FPRINTF'
    fprintf(STREAM, FORMAT, __VA_ARGS__);                      \
                    ~~~~~~  ^~~~~~~~~~~
1 warning generated.
This commit is contained in:
Wesley Shields
2021-08-23 09:50:05 +02:00
committed by GitHub
parent 4d6ecf83c0
commit 37bee583c2
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -1,4 +1,4 @@
AC_INIT([yara], [4.1.0], [[email protected]])
AC_INIT([yara], [4.1.1], [[email protected]])
AM_SILENT_RULES([yes])
AC_CONFIG_SRCDIR([cli/yara.c])
@@ -121,6 +121,14 @@ AC_ARG_ENABLE([profiling],
CFLAGS="$CFLAGS -DYR_PROFILING_ENABLED"
fi])
AC_ARG_WITH([debug-verbose],
[AS_HELP_STRING([--with-debug-verbose=[[NUM]]], [Turn on runtime debugging information])],
[if test $withval -gt 0; then
AC_DEFINE_UNQUOTED([YR_DEBUG_VERBOSITY], [$withval])
else
AC_MSG_ERROR([debug verbosity must be greater than 0])
fi])
AC_ARG_ENABLE([cuckoo],
[AS_HELP_STRING([--enable-cuckoo], [enable cuckoo module])],
[if test x$enableval = xyes; then
+1 -1
View File
@@ -635,7 +635,7 @@ static int _yr_scan_match_callback(
2,
stderr,
"+ %s(match_data=%p match_length=%d) { //"
" match_offset=%" PRId64 " args->data=%p args->string.length=%u"
" match_offset=%zu args->data=%p args->string.length=%u"
" args->data_base=0x%" PRIx64 " args->data_size=%zu"
" args->forward_matches=%'u\n",
__FUNCTION__,