Re: Header files with enums instead of defines?
From: Garance A Drosihn (drosih_at_rpi.edu)
Date: 12/22/04
- Previous message: Matthew D. Fuller: "Re: Header files with enums instead of defines?"
- In reply to: Peter Edwards: "Re: Header files with enums instead of defines?"
- Next in thread: M. Warner Losh: "Re: Header files with enums instead of defines?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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"
- Previous message: Matthew D. Fuller: "Re: Header files with enums instead of defines?"
- In reply to: Peter Edwards: "Re: Header files with enums instead of defines?"
- Next in thread: M. Warner Losh: "Re: Header files with enums instead of defines?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|