Re: Header files with enums instead of defines?

From: Garance A Drosihn (drosih_at_rpi.edu)
Date: 12/22/04

  • Next message: M. Warner Losh: "Re: no more <sys/vnode.h> in device drivers."
    Date: Wed, 22 Dec 2004 13:20:03 -0500
    To: Peter Edwards <peadar.edwards@gmail.com>, "Greg 'groggy' Lehey" <grog@freebsd.org>, FreeBSD Architecture Mailing List <arch@freebsd.org>
    
    

    At 1:00 PM +0000 12/22/04, Peter Edwards wrote:
    >As an alternative to Peter Jeremy's suggestion of using a GDB
    >macro, you could, of course, define a type as:
    >
    >typedef enum {
    > err_EPERM = EPERM,
    > err_ENOENT = ENOENT,
    > /* .... */
    >} errno_t
    >
    >Then within gdb:
    >
    >Breakpoint 1, main (argc=1, argv=0xbfbfe55c) at e.c:21
    >21 int rc = write(-1, "X", 1);
    >(gdb) n
    >22 pause();
    >(gdb) p (errno_t)errno
    >$1 = err_EBADF
    >(gdb)

    Ooo, that's a nice trick.

    >(Note if you actually try this, you need to define at least one
    >object of the errno_t type in your program to generate the type
    >in the executable output.)

    This note made me think of another possible trick:

    (gdb) printf "== '%s'\n", strerror(errno)
    == 'No such file or directory'

    I recommend the extra baggage in the print statement. Initially I
    happened to test this by trying:

    (gdb) printf "%s\n", strerror(4)
    Interrupted system call

    And I kept thinking that *gdb* was telling me the 'printf' call was
    getting interrupted. For a few minutes, I thought I had stumbled
    across some serious bug!

    I expect this only works if your program references strerror(),
    but I haven't tried it in other situations.

    -- 
    Garance Alistair Drosehn            =   gad@gilead.netel.rpi.edu
    Senior Systems Programmer           or  gad@freebsd.org
    Rensselaer Polytechnic Institute    or  drosih@rpi.edu
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
    

  • Next message: M. Warner Losh: "Re: no more <sys/vnode.h> in device drivers."

    Relevant Pages

    • Re: [9fans] OS X threads + dynamic linking
      ... on the given stack. ... A gdb session running the program ... It's dying in the dynamic linker trying to resolve printf. ... char stack; ...
      (comp.os.plan9)
    • Re: phtread_create while pthread_cond_timedwait in gdb
      ... When I run this program without gdb I get the following (as ... THREAD 2: printf ... THREAD 0: Timer expired ... static void *func1; ...
      (comp.os.linux.development.apps)
    • Re: std::ostringstream, urgent
      ... > make its destructor explode? ... Are you sure it dies *before* the second printf? ... so if the program dies any buffered data may fail ... If you're using GDB: ...
      (comp.lang.cpp)
    • Re: NASM 0.98.39 vs. NASM 2.03.01 disassembly
      ... Indeed so, but, with only a trivial effort, gdb can also be made more ... asm friendly, even for programs which do not have debug info. ... The a64 definitions follow the same pattern, but require four printf ...
      (alt.lang.asm)
    • phtread_create while pthread_cond_timedwait in gdb
      ... I experience a strange behavior while using gdb to test my software. ... Thread B does a simple printf. ... static void *func1; ... printf("Could not read realtime timer \n"); ...
      (comp.os.linux.development.apps)