Hi,

    I have an RT-Linux (2.2.14-rtl2.2) program that is doing quite a few
    rtl_printf()s (for tracing), that (after a moment) panic'd the
    kernel (consistently).  Disabling a subset of these print statements
    seemed to make the problem go away.  Is this a known problem, or
    should I start learning how to debug the kernel crashes?  (Yeah, I
    know, I should probably learn that anyway...)



    If anybody is interested, below is the debug macro I cooked up that
    I use from my code:

    #ifdef DEBUG
    extern int DebugLevel;      /* define this in your RT module */

    #define dprintf(level, fmt, args...)    do {\
        if (level < DebugLevel) { \
            rtl_printf("<"#level">" "!" fmt, ## args); \
        } } while(0)
    #else 
    #define dprintf(level, fmt, args...)    do {/*nothing*/} while(0)
    #endif      /* DEBUG */

    Explanations for the curious:

    1. The if statement lets me keep from spending CPU on the rtl_printf()
    call without actually compiling out the code.  For more detailed
    debugging, you may want to use DebugLevel as a bitmask.

    2. The rtl_printf() call uses the same params as the kernels
    printk() routine, so I stuff the debug level into the string "<n>"
    so klogd can do the right thing.

    3. The "!" is used just so I can distinguish RTL code from other
    kernel printk() calls.

    4. In the #else case, I put a bogus statement (that the compiler
    should optimize out) as leaving a blank semicolon has in the past
    bitten me. 

    5. Note the use of (GCC specific!) varargs in a macro - beware
    trying this on none-gcc platforms.


Regards,
Eric

-- 
Given a choice between grief and nothing, I'd choose grief.
                -- William Faulkner

Eric Peterson WB6PYK (805)370-3046 mailto:[EMAIL PROTECTED]
    http://www.troikanetworks.com

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to