From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21728 invoked by alias); 24 Dec 2007 06:41:17 -0000 Received: (qmail 21718 invoked by uid 22791); 24 Dec 2007 06:41:16 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 24 Dec 2007 06:41:12 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B463E2A962B for ; Mon, 24 Dec 2007 01:41:10 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gybdiIp1hLD2 for ; Mon, 24 Dec 2007 01:41:10 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 0B2C02A962A for ; Mon, 24 Dec 2007 01:41:09 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id A281836A4A3; Mon, 24 Dec 2007 10:41:01 +0400 (RET) Date: Mon, 24 Dec 2007 08:00:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] Cleaner handling of character entities ? Message-ID: <20071224064101.GW6154@adacore.com> References: <20060505182351.GK1109@adacore.com> <20060505182852.GL31029@nevyn.them.org> <20060505190625.GA1042@adacore.com> <20060505194846.GO31029@nevyn.them.org> <20060515171603.GE385@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="HuXIgs6JvY9hJs5C" Content-Disposition: inline In-Reply-To: <20060515171603.GE385@nevyn.them.org> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00406.txt.bz2 --HuXIgs6JvY9hJs5C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1058 This is an old patch that, for some reason, I forgot to commit: > So, Joel, I think that a patch along the lines of that changelog entry > above is probably the way to go, So I took the opportunity to add some comments, and do a minor reformatting... 2007-12-24 Joel Brobecker * dwarf2read.c (read_base_type): Set code to TYPE_CODE_CHAR for char and unsigned char types of Ada compilation units. * ada-lang.c (ada_is_character_type): Always return true if the type code is TYPE_CODE_CHAR. Tested on x86-linux with DWARF and stabs. Checked in. You also said: > you may want to audit uses of TYPE_CODE_INT and TYPE_CODE_CHAR in > backends or else calling Ada procedures which take chars may not work > well. > [Sounds like a new testcase, doesn't it?] That's a good idea. I will write one ASAP. Incidentally, that reminded me of a recent change that Daniel made regarding handling of (unsigned?) characters. Perhaps one day we won't have to set TYPE_CODE_CHAR only for Ada and M2... -- Joel --HuXIgs6JvY9hJs5C Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="char-ada.diff" Content-length: 2200 Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.243 diff -u -p -r1.243 dwarf2read.c --- dwarf2read.c 22 Dec 2007 20:58:30 -0000 1.243 +++ dwarf2read.c 24 Dec 2007 04:35:03 -0000 @@ -5007,11 +5007,11 @@ read_base_type (struct die_info *die, st type_flags |= TYPE_FLAG_UNSIGNED; break; case DW_ATE_signed_char: - if (cu->language == language_m2) + if (cu->language == language_ada && cu->language == language_m2) code = TYPE_CODE_CHAR; break; case DW_ATE_unsigned_char: - if (cu->language == language_m2) + if (cu->language == language_ada && cu->language == language_m2) code = TYPE_CODE_CHAR; type_flags |= TYPE_FLAG_UNSIGNED; break; Index: ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.110 diff -u -p -r1.110 ada-lang.c --- ada-lang.c 21 Dec 2007 11:50:11 -0000 1.110 +++ ada-lang.c 24 Dec 2007 04:35:28 -0000 @@ -7286,15 +7286,22 @@ value_val_atr (struct type *type, struct int ada_is_character_type (struct type *type) { - const char *name = ada_type_name (type); - return - name != NULL - && (TYPE_CODE (type) == TYPE_CODE_CHAR - || TYPE_CODE (type) == TYPE_CODE_INT - || TYPE_CODE (type) == TYPE_CODE_RANGE) - && (strcmp (name, "character") == 0 - || strcmp (name, "wide_character") == 0 - || strcmp (name, "unsigned char") == 0); + const char *name; + + /* If the type code says it's a character, then assume it really is, + and don't check any further. */ + if (TYPE_CODE (type) == TYPE_CODE_CHAR) + return 1; + + /* Otherwise, assume it's a character type iff it is a discrete type + with a known character type name. */ + name = ada_type_name (type); + return (name != NULL + && (TYPE_CODE (type) == TYPE_CODE_INT + || TYPE_CODE (type) == TYPE_CODE_RANGE) + && (strcmp (name, "character") == 0 + || strcmp (name, "wide_character") == 0 + || strcmp (name, "unsigned char") == 0)); } /* True if TYPE appears to be an Ada string type. */ --HuXIgs6JvY9hJs5C--