From owner-freebsd-arch@FreeBSD.ORG Wed Dec 22 18:20:06 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 68B3216A4CE; Wed, 22 Dec 2004 18:20:06 +0000 (GMT) Received: from smtp2.server.rpi.edu (smtp2.server.rpi.edu [128.113.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id E328A43D1D; Wed, 22 Dec 2004 18:20:05 +0000 (GMT) (envelope-from drosih@rpi.edu) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp2.server.rpi.edu (8.13.0/8.13.0) with ESMTP id iBMIK4qo015914; Wed, 22 Dec 2004 13:20:04 -0500 Mime-Version: 1.0 Message-Id: In-Reply-To: <34cb7c8404122205002bd7de18@mail.gmail.com> References: <20041222010143.GS53357@wantadilla.lemis.com> <20041222090855.GO79646@cirb503493.alcatel.com.au> <20041222103844.GI801@straylight.m.ringlet.net> <34cb7c8404122205002bd7de18@mail.gmail.com> Date: Wed, 22 Dec 2004 13:20:03 -0500 To: Peter Edwards , "Greg 'groggy' Lehey" , FreeBSD Architecture Mailing List From: Garance A Drosihn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: default X-RPI-SA-Score: undef - spam-scanning disabled X-Scanned-By: CanIt (www . canit . ca) Subject: Re: Header files with enums instead of defines? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Dec 2004 18:20:06 -0000 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