From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29812 invoked by alias); 11 May 2011 14:38:59 -0000 Received: (qmail 29606 invoked by uid 22791); 11 May 2011 14:38:57 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 May 2011 14:38:39 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4BEcWgV017507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 11 May 2011 10:38:32 -0400 Received: from host1.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4BEcTwA023561 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 May 2011 10:38:31 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p4BEcT51029221; Wed, 11 May 2011 16:38:29 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p4BEcSvv029217; Wed, 11 May 2011 16:38:28 +0200 Date: Wed, 11 May 2011 14:38:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: RFC: fix `gdb -write' case Message-ID: <20110511143828.GA28962@host1.jankratochvil.net> References: <4DC75B31.2020501@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-05/txt/msg00284.txt.bz2 >>>>> "Yao" == Yao Qi writes: Tom> https://bugzilla.redhat.com/show_bug.cgi?id=696148 Yao> FYI, I can't access this bug. I am told "You are not authorized to Yao> access bug #696148." In that Bug I made a comment # evaluate_subexp_c->OP_STRING ignores expect_type, GDB then tries to convert # the non-matching type using malloc. which I advocate below. On Mon, 09 May 2011 16:53:38 +0200, Tom Tromey wrote: > Yao> Any difference on these two type variables (expect_type vs. stringtype)? > > Yes. You can wind up with a different "char" type following the logic > in c-lang.c. In this case some higher level will try to cast the string > to the correct type, which will try to force it to memory, leading to > the bad result. > > The checks in the patch are intended to ensure that the expected type > isn't "too weird" -- that we don't do something nonsensical. The approach you took is not in the style of current GDB: #include short a_short[2]; long a_long[2]; char a_char[3]; wchar_t a_wchar[3]; int main (void) { return 0; } # With gcc only - without libstdc++ linked - GDB complains despite the code # compiled and runs fine; but that is a different Bug. # (gdb) p U"x" # No type named char32_t. g++ -g (gdb) start (gdb) set a_short={1L,2LL} (gdb) p a_short $1 = {1, 2} (gdb) ptype a_short type = short [2] (gdb) set a_long={1L,2LL} (gdb) p a_long $2 = {1, 2} (gdb) ptype a_long type = long [2] (gdb) set a_char=U"x" expected type of string constant has wrong character width (gdb) set a_wchar="x" expected type of string constant has wrong character width (gdb) I believe if GDB adjusts the short/long types shouldn't it adjust also char/whar_t types? That is now the user must know the type of string in advance which wasn't the case for arrays before. But it is not a real regression as GDB had not supported Unicode strings. This is why I made the comment above. Thanks, Jan