From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27092 invoked by alias); 20 Jul 2006 22:54:49 -0000 Received: (qmail 27084 invoked by uid 22791); 20 Jul 2006 22:54:48 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Thu, 20 Jul 2006 22:54:45 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1G3hPn-0008AW-OU for gdb-patches@sourceware.org; Thu, 20 Jul 2006 18:54:43 -0400 Date: Thu, 20 Jul 2006 22:54:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: [commit] Fix a C++ segfault Message-ID: <20060720225443.GA31345@nevyn.them.org> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.11+cvs20060403 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00278.txt.bz2 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 * eval.c (evaluate_struct_tuple): Skip static fields. 2006-07-20 Daniel Jacobowitz * 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))" \