From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51699 invoked by alias); 6 Oct 2018 15:19:23 -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 51685 invoked by uid 89); 6 Oct 2018 15:19:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=20180906, H*f:sk:2018090, independently X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 06 Oct 2018 15:19:21 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 6BD811E4C2; Sat, 6 Oct 2018 11:19:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=simark.ca; s=mail; t=1538839159; bh=Qv0Ab8/1UQB6DwSKbHa2Mbqg5KTqUmAdOEXH73wbVxU=; h=Subject:To:References:From:Date:In-Reply-To:From; b=P5pl+FP/OPfeetk9/fx/1z4iMirkoDcWjUL/w7OqngGe1SocLAb6sqMtLWYg+KZ/v P+9BdjPsc2mVGPCmnMicHtVyBBI1gEMkWJ90LQjHDxvXtHTm4u9FwaAXxCdh16ZTuA 6w98ZNoKvmi6S0KgsYXJ2ix+pp+0cMEYp3ZYZ0YY= Subject: Re: [RFC 1/8] Change wrap buffering to use a std::string To: Tom Tromey , gdb-patches@sourceware.org References: <20180906211303.11029-1-tom@tromey.com> <20180906211303.11029-2-tom@tromey.com> From: Simon Marchi Message-ID: <9ac8cf66-040e-b11a-841b-4d378b256f8a@simark.ca> Date: Sat, 06 Oct 2018 15:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180906211303.11029-2-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-10/txt/msg00144.txt.bz2 On 2018-09-06 5:12 p.m., Tom Tromey wrote: > Currently wrap buffering is implemented by allocating a string that is > the same width as the window, and then writing characters into it. > However, if gdb emits terminal escapes, then these could possibly > overflow the buffer. > > To prevent this, change the wrap buffer to be a std::string and update > the various uses. This looks like a good change to me, independently of this series. I think you should push it right away. > diff --git a/gdb/utils.c b/gdb/utils.c > index 7a8c80c64ed..1982fa20e64 100644 > --- a/gdb/utils.c > +++ b/gdb/utils.c > @@ -1268,13 +1268,11 @@ static bool pagination_disabled_for_command; > the end of the line, we spit out a newline, the indent, and then > the buffered output. */ > > -/* Malloc'd buffer with chars_per_line+2 bytes. Contains characters which > - are waiting to be output (they have already been counted in chars_printed). > - When wrap_buffer[0] is null, the buffer is empty. */ > -static char *wrap_buffer; > +static bool filter_initalized = false; Typo, "initalized". > @@ -1546,17 +1537,13 @@ void > wrap_here (const char *indent) > { > /* This should have been allocated, but be paranoid anyway. */ > - if (!wrap_buffer) > + if (!filter_initalized) > internal_error (__FILE__, __LINE__, > _("failed internal consistency check")); This should be gdb_assert (filter_initialized), IMO. Simon