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: [PATCH 1/3] gdb: New set/show max-value-size command.


> Date: Tue, 5 Jan 2016 14:12:41 +0000
> From: Andrew Burgess <andrew.burgess@embecosm.com>
> Cc: gdb-patches@sourceware.org
> 
> For languages with dynamic types, an incorrect program, or uninitialised
> variables within a program, could result in an incorrect, overly large
> type being associated with a value.  Currently, attempting to print such
> a variable will result in gdb trying to allocate an overly large buffer.
> 
> If this large memory allocation fails then the result can be gdb either
> terminating, or (due to memory contention) becoming unresponsive for the
> user.
> 
> A new user visible variable in gdb helps guard against such problems,
> two new commands are available:
> 
>    set max-value-size
>    show max-value-size
> 
> The 'max-value-size' is the maximum size in bytes that gdb will allocate
> for the contents of a value.  Any attempt to allocate a value with a
> size greater than this will result in an error.  The initial default for
> this limit is set at 64k, this is based on a similar limit that exists
> within the ada specific code.
> 
> It is possible for the user to set max-value-size to unlimited, in which
> case the old behaviour is restored.

Thanks.

> gdb/doc/ChangeLog:
> 
> 	* gdb.texinfo (Value Sizes): New section, also add the new section
> 	to the menu.

The addition to the menu is probably in a different node, so it needs
a separate entry in the ChangeLog.

> +set max-value-size
> +show max-value-size
> +  Control the maximum size, in bytes, that GDB will allocate for value
> +  contents.  Prevent incorrect programs from causing GDB to allocate
> +  overly large buffers.  Default is unlimited.

"Controls" and "Prevents".  Also "maximum size of memory" (we allocate
memory, not size).

> +@table @code
> +@kindex set max-value-size
> +@itemx set max-value-size @var{bytes}
> +@itemx set max-value-size unlimited
> +Set the maximum size, in bytes, that @value{GDBN} will allocate for

Same here:

  Set the maximum size of memory, in bytes, that @value{GDBN} will ...

Also, the "in bytes" part is redundant, since the parameter is called
"bytes", which is self-explanatory.

> +the contents of a value to @var{bytes}.  Any value whose contents
> +require more than this number of bytes can't be displayed by
> +@value{GDBN}, and trying to display the value will result in an error.

I would remove the "can't be displayed by @value{GDBN}" part.  It can
be interpreted to mean some limitation inherent in GDB, which is not
what you want to convey.  The rest of the sentence says it all: trying
to display a value that requires more memory than that will result in
an error.

> +Setting this variable does not effect values that have already been
> +allocated within gdb, only future allocations.
                    ^^^
@value{GDBN}

> +There's a minimum size that @code{max-value-size} can be set too in
                                                                ^^^
"to"

OK with those fixed.

Thanks.


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