From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFC/RFA] Cleaner handling of character entities ?
Date: Mon, 24 Dec 2007 08:00:00 -0000 [thread overview]
Message-ID: <20071224064101.GW6154@adacore.com> (raw)
In-Reply-To: <20060515171603.GE385@nevyn.them.org>
[-- Attachment #1: Type: text/plain, Size: 1058 bytes --]
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 <brobecker@adacore.com>
* 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
[-- Attachment #2: char-ada.diff --]
[-- Type: text/plain, Size: 2200 bytes --]
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. */
prev parent reply other threads:[~2007-12-24 6:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-05 18:24 Joel Brobecker
2006-05-05 18:29 ` Daniel Jacobowitz
2006-05-05 19:06 ` Joel Brobecker
2006-05-05 19:40 ` Jim Blandy
2006-05-05 19:48 ` Daniel Jacobowitz
2006-05-05 20:54 ` Joel Brobecker
2006-05-05 21:47 ` Jim Blandy
2006-05-15 19:06 ` Daniel Jacobowitz
2007-12-24 8:00 ` Joel Brobecker [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071224064101.GW6154@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox