This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC 1/8] Change wrap buffering to use a std::string


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]