From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gdb-patches@sourceware.org, brobecker@adacore.com
Subject: [rfc] Ada simplification: ada_coerce_to_simple_array_type
Date: Thu, 14 May 2009 11:36:00 -0000 [thread overview]
Message-ID: <200905141135.n4EBZsqG001678@d12av02.megacenter.de.ibm.com> (raw)
Hello,
in my ongoing attempts to eliminate current_gdbarch from GDB, I've run into
a couple of places in Ada-specific code that makes things difficult. This
(and the following three) patches rework a couple of Ada details in order
to make life simpler for my subsequent changes ...
This patch addresses ada_coerce_to_simple_array_type, which creates a
dummy value only to pass it to ada_type_of_array which in the end only
inspects its type. Not only is that a bit wasteful; it makes a future
change to create values relative to a gdbarch difficult (because there
is no good choice of architecture to use for that dummy value).
This patch inlines the part of ada_type_of_array that is used in the
case of a "bounds == 0" parameter -- in this piece of code, only
the type of the passed-in value is inspected.
There should be no change in behaviour with this patch.
Joel, would this be OK?
Thanks,
Ulrich
ChangeLog:
* ada-lang.c (ada_coerce_to_simple_array_type): Reimplement to
avoid creating a dummy value.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -1689,13 +1689,13 @@ ada_coerce_to_simple_array (struct value
struct type *
ada_coerce_to_simple_array_type (struct type *type)
{
- struct value *mark = value_mark ();
- struct value *dummy = value_from_longest (builtin_type_int32, 0);
- struct type *result;
- deprecated_set_value_type (dummy, type);
- result = ada_type_of_array (dummy, 0);
- value_free_to_mark (mark);
- return result;
+ if (ada_is_packed_array_type (type))
+ return decode_packed_array_type (type);
+
+ if (ada_is_array_descriptor_type (type))
+ return ada_check_typedef (TYPE_TARGET_TYPE (desc_data_type (type)));
+
+ return type;
}
/* Non-zero iff TYPE represents a standard GNAT packed-array type. */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
next reply other threads:[~2009-05-14 11:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-14 11:36 Ulrich Weigand [this message]
2009-05-15 14:07 ` Joel Brobecker
2009-05-18 13:51 ` Ulrich Weigand
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=200905141135.n4EBZsqG001678@d12av02.megacenter.de.ibm.com \
--to=uweigand@de.ibm.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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