Skip to content
Snippets Groups Projects
make_debug 2.46 KiB
Newer Older
  • Learn to ignore specific revisions
  • Alexandre Julliard's avatar
    Alexandre Julliard committed
    #!/bin/sh
    #
    # This script scans the whole source code for symbols of the form dprintf_xxx,
    # generates the necessary macro definitions and puts them into the files
    # include/stddebug.h and include/debug.h . This script must be started with 
    # cwd = rootdir of the Wine-distribution.
    #
    # Michael Patra  <micky@marie.physik.tu-berlin.de>
    #
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    DEBUG_H=include/debug.h
    STDDEBUG_H=include/stddebug.h
    
    mv $DEBUG_H $DEBUG_H.old
    mv $STDDEBUG_H $STDDEBUG_H.old
    
    # Build the list of debug identifiers
    grep -h dprintf_ */*.c | sed 's/.*dprintf_\([A-Za-z0-9_]*\).*/\1/g' | \
    	sort | uniq > temp.$$
    
    # Build debug.h
    
    sed '/^\/\* Do not remove this line or change anything below this line \*\//q'\
          <$DEBUG_H.old >$DEBUG_H
    cat <<++EOF++ >> $DEBUG_H
    
    #ifdef DEBUG_NONE_EXT
    ++EOF++
    
    cat temp.$$ | tr a-z A-Z |
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    {
    while read x
    do
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	echo "#undef DEBUG_$x" >> $DEBUG_H
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    done
    }
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    
    cat <<++EOF++ >>$DEBUG_H
    #endif
    
    #ifdef DEBUG_ALL_EXT
    ++EOF++
    
    cat temp.$$ | tr a-z A-Z |
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    {
    while read x
    do
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	echo "#define DEBUG_$x" >> $DEBUG_H
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    done
    }
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    
    cat <<++EOF++ >>$DEBUG_H
    #endif
    
    #ifdef DEBUG_RUNTIME
    #ifdef DEBUG_DEFINE_VARIABLES
    short debug_msg_enabled[]={
    ++EOF++
    
    cat temp.$$ | tr a-z A-Z |
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    {
    while read x
    do
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	cat <<++EOF++ >>$DEBUG_H
    #ifdef DEBUG_$x
        1,
    #else
        0,
    #endif
    ++EOF++
    
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    done
    }
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    
    cat <<++EOF++ >>$DEBUG_H
        0
    };
    #else
    extern short debug_msg_enabled[];
    #endif
    #endif
    
    ++EOF++
    
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    i=0
    cat temp.$$ |
    {
    while read x 
    do
    	y=`echo $x | tr a-z A-Z`
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	cat <<++EOF++ >>$DEBUG_H
    #ifdef DEBUG_RUNTIME
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #define dprintf_$x if(!debug_msg_enabled[$i]) ; else fprintf
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #define debugging_$x debug_msg_enabled[$i]
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #else
    #ifdef DEBUG_$y
    #define dprintf_$x fprintf
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #define debugging_$x 1
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #else
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #define dprintf_$x while(0) fprintf
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #define debugging_$x 0
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    #endif
    #endif
    
    ++EOF++
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	let i=$i+1
    done
    }
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    
    cat <<++EOF++ >>$DEBUG_H
    
    #ifdef DEBUG_RUNTIME
    #ifdef DEBUG_DEFINE_VARIABLES
    static char *debug_msg_name[] = {
    ++EOF++
    
    cat temp.$$ | 
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    {
    while read x
    do
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	echo "    \"$x\"," >> $DEBUG_H
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    done
    }
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    
    cat <<++EOF++ >>$DEBUG_H
        ""
    };
    #endif
    #endif
    ++EOF++
    
    # Build stddebug.h
    
    sed '/^\/\* Do not remove this line or change anything below this line \*\//q'\
          <$STDDEBUG_H.old >$STDDEBUG_H
    
    cat <<++EOF++ >>$STDDEBUG_H
    
    #ifdef DEBUG_NONE
    ++EOF++
    
    cat temp.$$ | tr a-z A-Z |
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    {
    while read x
    do
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	echo "#undef DEBUG_$x" >> $STDDEBUG_H
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    done
    }
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    
    cat <<++EOF++ >>$STDDEBUG_H
    #endif
    
    #ifdef DEBUG_ALL
    ++EOF++
    
    cat temp.$$ | tr a-z A-Z |
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    {
    while read x
    do
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    	echo "#define DEBUG_$x" >> $STDDEBUG_H
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    done
    
    Alexandre Julliard's avatar
    Alexandre Julliard committed
    }
    echo "#endif" >> $STDDEBUG_H
    
    rm temp.$$ $DEBUG_H.old $STDDEBUG_H.old