From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8259 invoked by alias); 12 Dec 2002 11:06:09 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 8116 invoked from network); 12 Dec 2002 11:06:02 -0000 Received: from unknown (HELO fw-cam.cambridge.arm.com) (193.131.176.3) by sources.redhat.com with SMTP; 12 Dec 2002 11:06:02 -0000 Received: by fw-cam.cambridge.arm.com; id LAA01983; Thu, 12 Dec 2002 11:05:53 GMT Received: from unknown(172.16.1.2) by fw-cam.cambridge.arm.com via smap (V5.5) id xma001241; Thu, 12 Dec 02 11:05:04 GMT Received: from pc960.cambridge.arm.com (pc960.cambridge.arm.com [10.1.205.4]) by cam-admin0.cambridge.arm.com (8.9.3/8.9.3) with ESMTP id LAA19670; Thu, 12 Dec 2002 11:05:02 GMT Received: from pc960.cambridge.arm.com (rearnsha@localhost) by pc960.cambridge.arm.com (8.11.6/8.9.3) with ESMTP id gBCB52308429; Thu, 12 Dec 2002 11:05:02 GMT Message-Id: <200212121105.gBCB52308429@pc960.cambridge.arm.com> X-Authentication-Warning: pc960.cambridge.arm.com: rearnsha owned process doing -bs To: Klee Dienes cc: gdb-patches@sources.redhat.com, Richard.Earnshaw@arm.com Reply-To: Richard.Earnshaw@arm.com Organization: ARM Ltd. X-Telephone: +44 1223 400569 (direct+voicemail), +44 1223 400400 (switchbd) X-Fax: +44 1223 400410 X-Address: ARM Ltd., 110 Fulbourn Road, Cherry Hinton, Cambridge CB1 9NJ. Subject: Re: [RFA] New function type_code_name. In-reply-to: Your message of "Wed, 11 Dec 2002 19:21:55 EST." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 12 Dec 2002 09:12:00 -0000 From: Richard Earnshaw X-SW-Source: 2002-12/txt/msg00403.txt.bz2 klee@apple.com said: > This patch moves the type-printing code from recursive_dump_type() > into the new function type_code_name(). It's handy when one wants to > use the type code of a type in debugging or warning/error messages. > * gdbtypes.h (type_code_name): Add prototype. > * gdbtypes.c (type_code_name): New function. Returns a > constant string containing the ASCII name of the type code. > (recursive_dump_type): Use type_code_name. Hmm, I think this could be much cleaner if we considered moving towards GCC's model of having a gdbtype.def file which defined the type the strings together. We could then build up an array of strings that is kept in sync with the enum definition. Something like gdbtype.def: DEF_TYPE (TYPE_CODE_INT, "TYPE_CODE_INT", anything else needed by all types) DEF_TYPE (TYPE_CODE_TYPEDEF, "TYPE_CODE_TYPEDEF", ...) etc then to use it, do #define DEF_TYPE(X,Y,Z) X, enum type_code { #include "gdbtype.def" TYPE_CODE_NUM_TYPES }; #undef DEF_TYPE #define DEF_TYPE(X,Y,Z) Y, const char char *const type_code_names[] = { #include "gdbtype.def" }; You can then look up the type name simply with if (type_code_number < TYPE_CODE_NUM_TYPES) type_name = type_code_names[type_code_number]; else type_name = "INVALID TYPE"; and adding a new type (should we need to) is trivial. R.