This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC 1/8] Change wrap buffering to use a std::string
- From: Simon Marchi <simark at simark dot ca>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Sat, 6 Oct 2018 11:19:18 -0400
- Subject: Re: [RFC 1/8] Change wrap buffering to use a std::string
- References: <20180906211303.11029-1-tom@tromey.com> <20180906211303.11029-2-tom@tromey.com>
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