From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24843 invoked by alias); 12 Jan 2007 11:22:03 -0000 Received: (qmail 24835 invoked by uid 22791); 12 Jan 2007 11:22:02 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO brahms.sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 12 Jan 2007 11:21:53 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.13.8/8.13.8) with ESMTP id l0CBIi00003902; Fri, 12 Jan 2007 12:18:44 +0100 (CET) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.13.8/8.13.8/Submit) id l0CBIh7p011299; Fri, 12 Jan 2007 12:18:44 +0100 (CET) Date: Fri, 12 Jan 2007 11:22:00 -0000 Message-Id: <200701121118.l0CBIh7p011299@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: vladimir@codesourcery.com CC: gdb@sources.redhat.com In-reply-to: <200701121351.29310.vladimir@codesourcery.com> (message from Vladimir Prus on Fri, 12 Jan 2007 13:51:29 +0300) Subject: Re: MI failures related to string printing References: <200701121351.29310.vladimir@codesourcery.com> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00206.txt.bz2 > From: Vladimir Prus > Date: Fri, 12 Jan 2007 13:51:29 +0300 > > > As I've reported before, I'm getting this failure: > > FAIL: gdb.mi/mi-var-child.exp: update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed > > After investigation, it appears related to recent -var-update changes. The failing test > does: > > mi_gdb_test "-var-update *" \ > "\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ > "update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed" > > It's the last check in mi-var-child.exp. The reply from gdb includes also: > > {name="psnp->char_ptr.*psnp->char_ptr.**psnp->char_ptr.***psnp->char_ptr",in_scope="true",type_changed="false"} > > and another similar thing. The problem is that test is written like this: > > char a0, *a1, **a2, ***a3; > > a0 = '0'; > a1 = &a0; > a2 = &a1; > a3 = &a2; > > There's a variable object correspoding to a1. When varobj_update tries to compare old > and new value of that varobj, it computes string value of a1. Unfortunately, a1 points to > a single character. There's no terminating zero character. So, the string value of a1 is > essentially random, and -var-update randomly marks varobj as changed. > > What do we do about it? At the very least, the test should be fixed. Is there anything smart > we can do here? I think the whole idea of doing string comparisons for C (or C++) "char *" pointers is flawed. There is no guarantee that a "char *" actually points to a null-terminated as the test shows. You should not treat "char *" any different from other pointers like "int *", at least not by default. You could implement a way for the user to specify that a "char *" is actually a pointer to a string instead of a single character. But otherwise I think the string comparison should only do for languages that have a genuine string type, such as Pascal. Mark