lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] debugging issues


From: Robert
Subject: Re: [lwip-users] debugging issues
Date: Thu, 3 Jul 2003 08:08:18 -0400 (EDT)

On Thu, 3 Jul 2003, Zschocke, Florian wrote:
> It's me again, this time picking at the lwIP debugging system. :) While it
> is already pretty advanced with its different levels and options, I think it
> still has some deficiencies that I'd like to attack.

If I get a vote in this, I vote *not* to add more features to the debug 
system, it's already too complicated.  I would vote for removing features 
actually.  Here is one possible scheme:  (disclaimer, the code below is 
intended to show my suggestion conceptually but has not actually 
been tested.)

----------------------

LWIP_DEBUG indicates debugging is wanted or not.  This allows all
debugging to be turned on or off at once, and if off, removes all
debugging code (and overhead) from the source.  This would be a compile
time option.  For example:

     #define LWIP_DEBUG             /* turn on debugging */

LWIP_ASSERT  indicates that assertion tests are wanted.  Another compile 
time option. For example:

     #define LWIP_ASSERT             /* turn on assertions */


The debugging messages themselves would look like this:


LWIP_DEBUGF( ip, 8, ("ip_forward: not bouncing packets back on 
incoming interface.\n"));

  -or for a more complicated example-

LWIP_DEBUGF( ip, ((len < 20)) ? 8 : 0), ("ip_forward: not bouncing packets 
back on incoming interface.\n"));


where "ip" indicate which member of the control structure controls this
message, and "8" indicates the group to which this message belongs.  IE
each debugging variable could define 8 message groups.  All the messages
belonging to a group would be turned on or off by using a
LWIP_DEBUG_CONTROL struct, the members of which could be adjusted both at
compile time or run time.  Any given messsage can be assigned to 1 or more
of the 8 groups by turning on the bits in the first parm of LWIP_DEBUGF().
The struct would look like this:


struct LWIP_DEBUG_CONTROL {
    unsigned char ip;
    unsigned char tcp_in;
    ....
    } lwip_debug_ctrl;

to see just "group 1" "ip" messages, set   lwip_debug_ctrl.ip = 1;
to see all "ip" messages, set   lwip_debug_ctrl.ip = 255;


The macro for LWIP_DEBUGF would look like this:

#define LWIP_DEBUGF(section,debug,x)                        \
     do {                                                   \
         if((debug) & lwip_debug_ctrl.section) {            \
             LWIP_PLATFORM_DIAG(x);                         \
             }                                              \
         } while(0)

-- 
Best Regards,
Robert 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]