From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sourceware.org
Subject: [commit] Fix a C++ segfault
Date: Thu, 20 Jul 2006 22:54:00 -0000 [thread overview]
Message-ID: <20060720225443.GA31345@nevyn.them.org> (raw)
Something Michael Chastain pointed out to me a long time ago.
This prevents GDB from crashing, in the fairly obvious way.
It still doesn't pass the test:
+# TODO: GDB doesn't know to convert the string to a const char *, and
+# instead tries to use the string as a structure initializer.
But this is well into the range of where you need a real C++ compiler wired
up. In Ottawa I talked to Mark Mitchell about the general problem; he said
that something like 20,000 lines of g++ is devoted to selecting the correct
conversions and overloaded functions. I have absolutely zero interest, full
stop, in duplicating that code. I don't intend any major improvements in
this area, unless someone is motivated enough to let us share the code for
it with g++.
Checked in.
--
Daniel Jacobowitz
CodeSourcery
2006-07-20 Daniel Jacobowitz <dan@codesourcery.com>
* eval.c (evaluate_struct_tuple): Skip static fields.
2006-07-20 Daniel Jacobowitz <dan@codesourcery.com>
* gdb.cp/bs15503.exp: Update comment for no longer crashing
test.
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.61
diff -u -p -r1.61 eval.c
--- eval.c 18 Feb 2006 20:47:54 -0000 1.61
+++ eval.c 20 Jul 2006 22:36:01 -0000
@@ -283,6 +283,10 @@ evaluate_struct_tuple (struct value *str
if (variantno < 0)
{
fieldno++;
+ /* Skip static fields. */
+ while (fieldno < TYPE_NFIELDS (struct_type)
+ && TYPE_FIELD_STATIC_KIND (struct_type, fieldno))
+ fieldno++;
subfieldno = fieldno;
if (fieldno >= TYPE_NFIELDS (struct_type))
error (_("too many initializers"));
Index: testsuite/gdb.cp/bs15503.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/bs15503.exp,v
retrieving revision 1.5
diff -u -p -r1.5 bs15503.exp
--- testsuite/gdb.cp/bs15503.exp 27 Apr 2005 16:35:15 -0000 1.5
+++ testsuite/gdb.cp/bs15503.exp 20 Jul 2006 22:36:02 -0000
@@ -83,11 +83,11 @@ gdb_test "print (const char *) s" \
# gdb_test "print s > "AAA" "\\$\[0-9\]+ = true"
# gdb_test "print s < "ZZZ" "\\$\[0-9\]+ = true"
-# TODO crash gdb! This is going to be a great test!
-# -- chastain 2004-01-07
+# TODO: GDB doesn't know to convert the string to a const char *, and
+# instead tries to use the string as a structure initializer.
#
# gdb_test "print s == \"I am a short stringand now a longer string\"" \
-# "\\$\[0-9\]+ = "true"
+# "\\$\[0-9\]+ = true"
gdb_test "print (const char *) s.substr(0,4)" "\\$\[0-9\]+ = $hex \"I am\""
gdb_test "print (const char *) (s=s.substr(0,4))" \
next reply other threads:[~2006-07-20 22:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-20 22:54 Daniel Jacobowitz [this message]
2006-07-21 0:28 ` Joel Brobecker
2006-07-21 0:40 ` Daniel Jacobowitz
2006-07-21 0:43 ` 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=20060720225443.GA31345@nevyn.them.org \
--to=drow@false.org \
--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