From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4061 invoked by alias); 15 Jun 2009 13:25:42 -0000 Received: (qmail 4014 invoked by uid 22791); 15 Jun 2009 13:25:41 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Jun 2009 13:25:34 +0000 Received: (qmail 31856 invoked from network); 15 Jun 2009 13:25:32 -0000 Received: from unknown (HELO wind.localnet) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 15 Jun 2009 13:25:32 -0000 From: Vladimir Prus To: Daniel Jacobowitz Subject: Re: Robustifying pretty-printers Date: Mon, 15 Jun 2009 13:25:00 -0000 User-Agent: KMail/1.11.90 (Linux/2.6.24-24-generic; KDE/4.2.90; i686; svn-979530; 2009-06-10) Cc: Phil Muldoon , gdb@sources.redhat.com References: <200906131411.34204.vladimir@codesourcery.com> <200906151638.57869.vladimir@codesourcery.com> <20090615125509.GA20779@caradoc.them.org> In-Reply-To: <20090615125509.GA20779@caradoc.them.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200906151725.31749.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: 2009-06/txt/msg00143.txt.bz2 On Monday 15 June 2009 Daniel Jacobowitz wrote: > On Mon, Jun 15, 2009 at 04:38:57PM +0400, Vladimir Prus wrote: > > On Monday 15 June 2009 Phil Muldoon wrote: > > > + return self.val['_M_dataplus']['_M_p'].string (encoding, length = len) > > > > Great, this is exactly what I was looking for. > > Is it? This uses the length from the (possibly uninitialized) > std::string as a maximum. I think we want something higher level, > similar to today's "set print elements", to apply. That's a separate matter, which I raise in the topic starter. Yes, we want some safety net. As it stands, any IDE that automatically displays local variables is totally broken if pretty-printing is enabled. But at the same time, even if we assume that the variable is already initialized, we need to terminate the string at the length, as opposed to assuming it has some null terminator. The higher level safety net might cut the string at 100 characters, preventing a hang. But it would be nicer to cut it at actual string length, so avoid showing garbage. - Volodya