Changeset 2370

Show
Ignore:
Timestamp:
05/24/07 23:21:08 (2 years ago)
Author:
mtaylor
Message:

I found two major impediments to using athdebug and 80211debug:

1. When no device exists, using 80211debug or athdebug without arguments will cause an error to be displayed, rather than usage information.

2. Flags are entered and displayed in either hexadecimal (which is efficient but non-friendly) or symbolic names. However, symbolic names are never displayed and are only available if you have man pages installed (not common on access points).

The attached patch corrects both situations. For #1 we add usage message if this occurs. For #2 we add a tabular mapping of symbolic names to hexadecimal values in the usage information and after each invocation we display the same table with an indicator of which flags are enabled.

These changes greatly improve the usability of the debug flags.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tools/80211debug.c

    r1849 r2370  
    209209#endif 
    210210        debuglen = sizeof(debug); 
    211         if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0) 
    212                 err(1, "sysctl-get(%s)", oid); 
     211        if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0) { 
     212                if (argc <= 1)  
     213                        usage(); /* no user input, device not found - show usage instead of error message */ 
     214                else  
     215                        err(1, "sysctl-get(%s)", oid); /* user specified arguments indicating a command, show error message */ 
     216        } 
    213217        ndebug = debug; 
    214218        for (; argc > 1; argc--, argv++) { 
     
    259263                } 
    260264        printf("%s\n", *sep != '<' ? ">" : ""); 
     265        printf("Details:\n"); 
     266        for (i = 0; i < N(flags); i++) 
     267                printf("%12s %s 0x%08x - %s\n", flags[i].name, debug & flags[i].bit ? "+" : " ", flags[i].bit, flags[i].desc); 
    261268        return 0; 
    262269} 
  • trunk/tools/athdebug.c

    r1849 r2370  
    213213#endif 
    214214        debuglen = sizeof(debug); 
    215         if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0) 
    216                 err(1, "sysctl-get(%s)", oid); 
     215        if (sysctlbyname(oid, &debug, &debuglen, NULL, 0) < 0) { 
     216                if (argc <= 1) 
     217                        usage(); /* no user input, device not found - show usage instead of error message */ 
     218                else  
     219                        err(1, "sysctl-get(%s)", oid); /* user specified arguments indicating a command, show error message */ 
     220        } 
    217221        ndebug = debug; 
    218222        for (; argc > 1; argc--, argv++) { 
     
    263267                } 
    264268        printf("%s\n", *sep != '<' ? ">" : ""); 
     269        printf("Details:\n"); 
     270        for (i = 0; i < N(flags); i++) 
     271                printf("%12s %s 0x%08x - %s\n", flags[i].name, debug & flags[i].bit ? "+" : " ", flags[i].bit, flags[i].desc); 
    265272        return 0; 
    266273}