binutils-gdb/gdb/testsuite/gdb.base/max-value-size.c

27 lines
838 B
C
Raw Normal View History

gdb: New set/show max-value-size command. 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 of memory 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. gdb/ChangeLog: * value.c (max_value_size): New variable. (MIN_VALUE_FOR_MAX_VALUE_SIZE): New define. (show_max_value_size): New function. (check_type_length_before_alloc): New function. (allocate_value_contents): Call check_type_length_before_alloc. (set_value_enclosing_type): Likewise. (_initialize_values): Add set/show handler for max-value-size. * NEWS: Mention new set/show command. gdb/doc/ChangeLog: * gdb.texinfo (Value Sizes): New section. (Data): Add the 'Value Sizes' node to the menu. gdb/testsuite/ChangeLog: * gdb.base/max-value-size.c: New file. * gdb.base/max-value-size.exp: New file. * gdb.base/huge.exp: Disable max-value-size for this test.
2015-12-11 18:37:49 +01:00
/* This testcase is part of GDB, the GNU debugger.
Copyright (C) 2016-2017 Free Software Foundation, Inc.
gdb: New set/show max-value-size command. 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 of memory 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. gdb/ChangeLog: * value.c (max_value_size): New variable. (MIN_VALUE_FOR_MAX_VALUE_SIZE): New define. (show_max_value_size): New function. (check_type_length_before_alloc): New function. (allocate_value_contents): Call check_type_length_before_alloc. (set_value_enclosing_type): Likewise. (_initialize_values): Add set/show handler for max-value-size. * NEWS: Mention new set/show command. gdb/doc/ChangeLog: * gdb.texinfo (Value Sizes): New section. (Data): Add the 'Value Sizes' node to the menu. gdb/testsuite/ChangeLog: * gdb.base/max-value-size.c: New file. * gdb.base/max-value-size.exp: New file. * gdb.base/huge.exp: Disable max-value-size for this test.
2015-12-11 18:37:49 +01:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
char one;
char ten[10];
char one_hundred[100];
int
main (void)
{
return 0;
}