From: Tom Tromey <tromey@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: fix crash in expression evaluation
Date: Thu, 30 Oct 2008 21:48:00 -0000 [thread overview]
Message-ID: <m3mygliyrd.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m31vxxkfsr.fsf@fleche.redhat.com> (Tom Tromey's message of "Thu\, 30 Oct 2008 14\:07\:32 -0600")
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> I'll send it through the tester.
It passed.
Here is the new patch.
Tom
2008-10-02 Tom Tromey <tromey@redhat.com>
* value.c (coerce_array): Use check_typedef.
diff --git a/gdb/testsuite/gdb.base/pointers.c b/gdb/testsuite/gdb.base/pointers.c
index 85bfdc9..4ee5e78 100644
--- a/gdb/testsuite/gdb.base/pointers.c
+++ b/gdb/testsuite/gdb.base/pointers.c
@@ -71,6 +71,15 @@ float ** ptr_to_ptr_to_float;
int y;
+
+typedef long k[5];
+
+typedef struct {
+ k array_variable;
+} S;
+
+S instance;
+
/* Do nothing function used for forcing some of the above variables to
be referenced by the program source. If the variables are not
referenced, some linkers will remove the symbol from the symbol
diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp
index 5532140..d7d17e7 100644
--- a/gdb/testsuite/gdb.base/pointers.exp
+++ b/gdb/testsuite/gdb.base/pointers.exp
@@ -596,3 +596,7 @@ gdb_expect {
timeout { fail "(timeout) ptype ppppppC" }
}
+# Regression test for a crash.
+
+gdb_test "p instance.array_variable + 0" \
+ " = \\(long int \\*\\) 0x\[0-9a-f\]*"
diff --git a/gdb/value.c b/gdb/value.c
index 1fa376d..695aa33 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1728,12 +1728,21 @@ coerce_ref (struct value *arg)
struct value *
coerce_array (struct value *arg)
{
+ struct type *type;
+
arg = coerce_ref (arg);
- if (current_language->c_style_arrays
- && TYPE_CODE (value_type (arg)) == TYPE_CODE_ARRAY)
- arg = value_coerce_array (arg);
- if (TYPE_CODE (value_type (arg)) == TYPE_CODE_FUNC)
- arg = value_coerce_function (arg);
+ type = check_typedef (value_type (arg));
+
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_ARRAY:
+ if (current_language->c_style_arrays)
+ arg = value_coerce_array (arg);
+ break;
+ case TYPE_CODE_FUNC:
+ arg = value_coerce_function (arg);
+ break;
+ }
return arg;
}
\f
next prev parent reply other threads:[~2008-10-30 21:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-02 17:27 Tom Tromey
2008-10-30 4:04 ` Joel Brobecker
2008-10-30 21:50 ` Tom Tromey
2008-10-30 21:48 ` Tom Tromey [this message]
2008-10-30 21:42 ` Joel Brobecker
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=m3mygliyrd.fsf@fleche.redhat.com \
--to=tromey@redhat.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