From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63061 invoked by alias); 4 Jul 2015 17:11:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 63048 invoked by uid 89); 4 Jul 2015 17:11:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 04 Jul 2015 17:11:54 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 42321B813C for ; Sat, 4 Jul 2015 17:11:53 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t64HBnae014009 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 4 Jul 2015 13:11:51 -0400 Date: Sat, 04 Jul 2015 17:11:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Phil Muldoon , Alexandre Oliva Subject: [patchv3] compile: Fix crash on cv-qualified self-reference Message-ID: <20150704171148.GA28708@host1.jankratochvil.net> References: <20150418172843.GA17777@host1.jankratochvil.net> <20150516132555.GB17266@host1.jankratochvil.net> <86lhf0p1hf.fsf@gmail.com> <20150701132406.GA13975@host1.jankratochvil.net> <20150702123401.GA1275@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J2SCkAp4GZ/dPZZf" Content-Disposition: inline In-Reply-To: <20150702123401.GA1275@host1.jankratochvil.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00105.txt.bz2 --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 869 On Thu, 02 Jul 2015 14:34:01 +0200, Jan Kratochvil wrote: > On Wed, 01 Jul 2015 15:24:06 +0200, Jan Kratochvil wrote: > > Just it causes a regression with latest GCC now as I have asked > > Alexandre Oliva off-list how it really should be fixed. > > I have removed requirement of this fix for the branching as there is currently > no valid fix at hand and after all the 'compile' feature probably should not > be a release blocker. So the bug was not in GDB but in the GCC part interfacing with GDB. Alexandre Oliva has fixed it the right way: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=commitdiff;h=072dfdba0ea62abb65514cb3a90cdf3868efe286 git://gcc.gnu.org/git/gcc.git aoliva/libcp1 Attaching this GDB testsuite update + info to user s/he should upgrade GCC. After Alex upstreams the fix I can update the message to contain the specific GCC release. Jan --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename=1 Content-length: 5068 gdb/ChangeLog 2015-07-04 Jan Kratochvil PR compile/18484 * compile/compile-c-types.c (insert_type): Change gdb_assert to error. gdb/testsuite/ChangeLog 2015-07-04 Jan Kratochvil PR compile/18484 * gdb.compile/compile.c (struct struct_type): Add volatile to selffield's type. * gdb.compile/compile.exp (compile code struct_object.selffield = &struct_object): Skip futher struct_object tests if this one xfails. diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 22f5a9d..1ad3dd9 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -78,7 +78,8 @@ insert_type (struct compile_c_instance *context, struct type *type, add = *slot; /* The type might have already been inserted in order to handle recursive types. */ - gdb_assert (add == NULL || add->gcc_type == gcc_type); + if (add != NULL && add->gcc_type != gcc_type) + error (_("Unexpected type id from GCC, check you use recent enough GCC.")); if (add == NULL) { diff --git a/gdb/testsuite/gdb.compile/compile.c b/gdb/testsuite/gdb.compile/compile.c index 3d5f20a..41ff087 100644 --- a/gdb/testsuite/gdb.compile/compile.c +++ b/gdb/testsuite/gdb.compile/compile.c @@ -42,7 +42,7 @@ struct struct_type { float floatfield; double doublefield; const union union_type *ptrfield; - struct struct_type *selffield; + volatile struct struct_type *selffield; int arrayfield[5]; _Complex double complexfield; _Bool boolfield; diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp index dd46a5f..a416e9e 100644 --- a/gdb/testsuite/gdb.compile/compile.exp +++ b/gdb/testsuite/gdb.compile/compile.exp @@ -189,51 +189,61 @@ gdb_test "p localvar" " = 1" # Test setting fields and also many different types. # +set skip_struct_object 0 set test "compile code struct_object.selffield = &struct_object" gdb_test_multiple $test $test { -re "^$test\r\n$gdb_prompt $" { pass "$test" } - -re "gdb command line:1:25: warning: assignment discards 'volatile' qualifier from pointer target type \\\[-Wdiscarded-qualifiers\\\]\r\n$gdb_prompt $" { + -re " error: Unexpected type id from GCC, check you use recent enough GCC\\.\r\n.*\r\n$gdb_prompt $" { xfail "$test (PR compile/18202)" + + # All following tests will break with the same error message. + set skip_struct_object 1 } } -gdb_test "print struct_object.selffield == &struct_object" " = 1" - -gdb_test_no_output "compile code struct_object.charfield = 1" -gdb_test "print struct_object.charfield" " = 1 '\\\\001'" -gdb_test_no_output "compile code struct_object.ucharfield = 1" -gdb_test "print struct_object.ucharfield" " = 1 '\\\\001'" - -foreach {field value} { - shortfield -5 - ushortfield 5 - intfield -7 - uintfield 7 - bitfield 2 - longfield -9 - ulongfield 9 - enumfield ONE - floatfield 1 - doublefield 2 -} { - gdb_test_no_output "compile code struct_object.$field = $value" - gdb_test "print struct_object.$field" " = $value" -} -gdb_test_no_output "compile code struct_object.arrayfield\[2\] = 7" -gdb_test "print struct_object.arrayfield" \ - " = \\{0, 0, 7, 0, 0\\}" +if {$skip_struct_object} { + untested "all struct_object tests" +} else { + gdb_test "print struct_object.selffield == &struct_object" " = 1" + + gdb_test_no_output "compile code struct_object.charfield = 1" + gdb_test "print struct_object.charfield" " = 1 '\\\\001'" + gdb_test_no_output "compile code struct_object.ucharfield = 1" + gdb_test "print struct_object.ucharfield" " = 1 '\\\\001'" + + foreach {field value} { + shortfield -5 + ushortfield 5 + intfield -7 + uintfield 7 + bitfield 2 + longfield -9 + ulongfield 9 + enumfield ONE + floatfield 1 + doublefield 2 + } { + gdb_test_no_output "compile code struct_object.$field = $value" + gdb_test "print struct_object.$field" " = $value" + } -gdb_test_no_output "compile code struct_object.complexfield = 7 + 5i" -gdb_test "print struct_object.complexfield" " = 7 \\+ 5 \\* I" + gdb_test_no_output "compile code struct_object.arrayfield\[2\] = 7" + gdb_test "print struct_object.arrayfield" \ + " = \\{0, 0, 7, 0, 0\\}" -gdb_test_no_output "compile code struct_object.boolfield = 1" -gdb_test "print struct_object.boolfield" " = true" + gdb_test_no_output "compile code struct_object.complexfield = 7 + 5i" + gdb_test "print struct_object.complexfield" " = 7 \\+ 5 \\* I" -gdb_test_no_output "compile code struct_object.vectorfield\[2\] = 7" -gdb_test "print struct_object.vectorfield" \ - " = \\{0, 0, 7, 0\\}" + gdb_test_no_output "compile code struct_object.boolfield = 1" + gdb_test "print struct_object.boolfield" " = true" + + gdb_test_no_output "compile code struct_object.vectorfield\[2\] = 7" + gdb_test "print struct_object.vectorfield" \ + " = \\{0, 0, 7, 0\\}" + +} gdb_test_no_output "compile code union_object.typedeffield = 7" gdb_test "print union_object.typedeffield" " = 7" --J2SCkAp4GZ/dPZZf--