aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-value.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2013-12-10 16:20:08 -0800
committerDoug Evans <dje@google.com>2013-12-10 16:20:08 -0800
commit0987cf351276271164c94b3bc8ca54482573bda4 (patch)
tree6f5e90b28a6fcbdadcfd1a29c56c3ac5b8fde3df /gdb/testsuite/gdb.python/py-value.c
parent34dc884e1711a3d00c6815bf32aa5823390ff1f6 (diff)
downloadgdb-0987cf351276271164c94b3bc8ca54482573bda4.zip
gdb-0987cf351276271164c94b3bc8ca54482573bda4.tar.gz
gdb-0987cf351276271164c94b3bc8ca54482573bda4.tar.bz2
PR 16286
* c-lang.c (c_get_string): Ignore the declared size of the object if a specific length is requested. testsuite/ * gdb.python/py-value.c: #include stdlib.h, string.h. (str): New struct. (main): New local xstr. * gdb.python/py-value.exp (test_value_in_inferior): Add test to fetch a value as a string with a length beyond the declared length of the array.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-value.c')
-rw-r--r--gdb/testsuite/gdb.python/py-value.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-value.c b/gdb/testsuite/gdb.python/py-value.c
index 0c94e64..4f8c27b 100644
--- a/gdb/testsuite/gdb.python/py-value.c
+++ b/gdb/testsuite/gdb.python/py-value.c
@@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
struct s
{
@@ -39,6 +41,13 @@ typedef struct s *PTR;
enum e evalue = TWO;
+struct str
+{
+ int length;
+ /* Variable length. */
+ char text[1];
+};
+
#ifdef __cplusplus
struct Base {
@@ -86,6 +95,8 @@ main (int argc, char *argv[])
int i = 2;
int *ptr_i = &i;
const char *sn = 0;
+ struct str *xstr;
+
s.a = 3;
s.b = 5;
u.a = 7;
@@ -96,6 +107,12 @@ main (int argc, char *argv[])
ptr_ref(ptr_i);
#endif
+#define STR_LENGTH 100
+ xstr = (struct str *) malloc (sizeof (*xstr) + STR_LENGTH);
+ xstr->length = STR_LENGTH;
+ memset (xstr->text, 'x', STR_LENGTH);
+#undef STR_LENGTH
+
save_argv = argv; /* break to inspect struct and union */
return 0;
}