Changeset 4009 for zzuf/trunk


Ignore:
Timestamp:
Nov 23, 2009, 1:26:53 AM (11 years ago)
Author:
Sam Hocevar
Message:

Add a second level of debugging for slightly less useful information.

Location:
zzuf/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/doc/libzzuf.3

    r4006 r4009  
    1 .TH libzzuf 3 "2008-06-10" "libzzuf"
     1.TH libzzuf 3 "2009-11-22" "libzzuf"
    22.SH NAME
    33libzzuf \- helper library for the zzuf multiple purpose fuzzer
     
    2121.TP
    2222\fBZZUF_DEBUG\fR
     23This environment variable is set to the debugging level. 0 means no debugging
     24information is sent to \fBzzuf\fR. 1 logs important information as well as
     25all diverted functions. 2 logs fuzzing status and all optional file stream
     26information.
     27.TP
     28\fBZZUF_DEBUGFD\fR
    2329This environment variable is set to a file descriptor where \fBlibzzuf\fR will
    2430send debugging information. This is used to send data to the main \fBzzuf\fR
  • zzuf/trunk/doc/zzuf.1

    r4006 r4009  
    1 .TH zzuf 1 "2006-12-22" "zzuf"
     1.TH zzuf 1 "2009-11-22" "zzuf"
    22.SH NAME
    33zzuf \- multiple purpose fuzzer
     
    9393.TP
    9494\fB\-d\fR, \fB\-\-debug\fR
    95 Activate the display of debug messages.
     95Activate the display of debug messages. Can be specified multiple times for
     96increased verbosity.
    9697.TP
    9798\fB\-D\fR, \fB\-\-delay\fR=\fIdelay\fR
  • zzuf/trunk/src/debug.c

    r2336 r4009  
    11/*
    22 *  zzuf - general purpose fuzzer
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    3737#include "libzzuf.h"
    3838
    39 extern int _zz_debugfd;
     39static void mydebug(char const *format, va_list args);
    4040
    4141/**
     
    5757    } while(0)
    5858
     59void _zz_debug(char const *format, ...)
     60{
     61    va_list args;
     62    va_start(args, format);
     63    if (_zz_debuglevel >= 1)
     64        mydebug(format, args);
     65    va_end(args);
     66}
     67
     68void _zz_debug2(char const *format, ...)
     69{
     70    va_list args;
     71    va_start(args, format);
     72    if (_zz_debuglevel >= 2)
     73        mydebug(format, args);
     74    va_end(args);
     75}
     76
    5977/**
    6078 * Format a string, printf-like, and write the resulting data to zzuf's
     
    6886 *  - fprintf(stderr, "\n");
    6987 */
    70 void _zz_debug(char const *format, ...)
     88static void mydebug(char const *format, va_list args)
    7189{
    7290    static char const *hex2char = "0123456789abcdef";
    7391    char const *f;
    74     va_list args;
    7592    int saved_errno;
    7693
     
    7996
    8097    saved_errno = errno;
    81     va_start(args, format);
    8298
    8399    write(_zz_debugfd, "** zzuf debug ** ", 17);
     
    187203    }
    188204    write(_zz_debugfd, "\n", 1);
    189     va_end(args);
    190205    errno = saved_errno;
    191206}
  • zzuf/trunk/src/debug.h

    r2577 r4009  
    11/*
    22 *  zzuf - general purpose fuzzer
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    1818
    1919extern void _zz_debug(const char *format, ...) ATTRIBUTE_PRINTF(1,2);
     20extern void _zz_debug2(const char *format, ...) ATTRIBUTE_PRINTF(1,2);
    2021
    2122#ifdef LIBZZUF
    2223#   define debug _zz_debug
     24#   define debug2 _zz_debug2
    2325#else
    24 #   define debug(...)
     26#   define debug(...) do {} while(0)
     27#   define debug2(...) do {} while(0)
    2528#endif
    2629
  • zzuf/trunk/src/fd.c

    r3635 r4009  
    224224        return;
    225225
    226 #if 0
    227226    if(autoinc)
    228         debug("using seed %li", (long int)seed);
    229 #endif
     227        debug2("using seed %li", (long int)seed);
    230228
    231229    /* If filedescriptor is outside our bounds */
     
    378376        return;
    379377
     378    debug2("setfuzzed(%i, %i)", fd, count);
     379
    380380    files[fds[fd]].already_pos = files[fds[fd]].pos;
    381381    files[fds[fd]].already_fuzzed = count;
  • zzuf/trunk/src/fuzz.c

    r2575 r4009  
    11/*
    22 *  zzuf - general purpose fuzzer
    3  *  Copyright (c) 2006-2007 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    9292    int todo;
    9393
    94     debug("fuzz(%i, @%lli, %lli)", fd, (long long int)pos, (long long int)len);
     94    debug2("fuzz(%i, @%lli, %lli)", fd, (long long int)pos, (long long int)len);
    9595
    9696    aligned_buf = buf - pos;
  • zzuf/trunk/src/libzzuf.c

    r3635 r4009  
    6565 * Is libzzuf fully initialised?
    6666 */
    67 int   _zz_ready    = 0;
     67int _zz_ready = 0;
     68
     69/**
     70 * The debugging level that libzzuf should use. 0 means no debugging,
     71 * 1 means minimal debugging, 2 means verbose debugging. Its value is set
     72 * by the ZZUF_DEBUG environment variable.
     73 */
     74int _zz_debuglevel = 0;
    6875
    6976/**
    7077 * The file descriptor used by libzzuf for communication with the main
    71  * zzuf program in debug mode. Its value is set by the ZZUF_DEBUG
     78 * zzuf program in debug mode. Its value is set by the ZZUF_DEBUGFD
    7279 * environment variable.
    7380 */
    74 int   _zz_debugfd = -1;
     81int _zz_debugfd = -1;
    7582
    7683/**
     
    8087 * instance. Its value is set by the ZZUF_SIGNAL environment variable.
    8188 */
    82 int   _zz_signal  = 0;
     89int _zz_signal = 0;
    8390
    8491/**
     
    8895 * variable.
    8996 */
    90 int   _zz_memory  = 0;
     97int _zz_memory = 0;
    9198
    9299/**
     
    95102 * variable.
    96103 */
    97 int   _zz_network = 0;
     104int _zz_network = 0;
    98105
    99106/**
     
    111118
    112119    tmp = getenv("ZZUF_DEBUG");
     120    if(tmp)
     121        _zz_debuglevel = atoi(tmp);
     122
     123    tmp = getenv("ZZUF_DEBUGFD");
    113124    if(tmp)
    114125        _zz_debugfd = atoi(tmp);
  • zzuf/trunk/src/libzzuf.h

    r2521 r4009  
    11/*
    22 *  zzuf - general purpose fuzzer
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    5151extern int _zz_ready;
    5252extern int _zz_disabled;
     53extern int _zz_debuglevel;
    5354extern int _zz_debugfd;
    5455extern int _zz_signal;
  • zzuf/trunk/src/zzuf.c

    r3637 r4009  
    158158    int cmdline = 0;
    159159#endif
    160     int network = 0;
     160    int debug = 0, network = 0;
    161161    int i;
    162162
     
    260260            break;
    261261        case 'd': /* --debug */
    262             setenv("ZZUF_DEBUG", DEBUG_FILENO_STR, 1);
     262            debug++;
    263263            break;
    264264        case 'D': /* --delay */
     
    467467        setenv("ZZUF_EXCLUDE", exclude, 1);
    468468#endif
     469
     470    setenv("ZZUF_DEBUG", debug ? debug > 1 ? "2" : "1" : "0", 1);
     471    setenv("ZZUF_DEBUGFD", DEBUG_FILENO_STR, 1);
    469472
    470473    if(opts->fuzzing)
Note: See TracChangeset for help on using the changeset viewer.