From 318102b961ee0819c326894f988b187c11b24285 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 25 Sep 2012 12:20:42 +0000 Subject: [PATCH] gdb/ChangeLog: * c-typeprint.c (c_type_print_varspec_suffix): Remove cast and use plongest to print the array size. testsuite/ChangeLog: * gdb.base/longest-types.c: New test case. * gdb.base/longest-types.exp: New test case. --- gdb/ChangeLog | 5 +++++ gdb/c-typeprint.c | 4 ++-- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/longest-types.c | 28 ++++++++++++++++++++++++ gdb/testsuite/gdb.base/longest-types.exp | 25 +++++++++++++++++++++ 5 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.base/longest-types.c create mode 100644 gdb/testsuite/gdb.base/longest-types.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0a1ccdff41d..a6a75b5bbaa 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2012-09-25 Siddhesh Poyarekar + + * c-typeprint.c (c_type_print_varspec_suffix): Remove cast and + use plongest to print the array size. + 2012-09-24 Siddhesh Poyarekar * m2-typeprint.c (m2_enum): Expand LASTVAL to LONGEST. diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 9ce6f632b71..8b5bc2170ac 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -621,8 +621,8 @@ c_type_print_varspec_suffix (struct type *type, fprintf_filtered (stream, (is_vector ? "__attribute__ ((vector_size(" : "[")); if (get_array_bounds (type, &low_bound, &high_bound)) - fprintf_filtered (stream, "%d", - (int) (high_bound - low_bound + 1)); + fprintf_filtered (stream, "%s", + plongest (high_bound - low_bound + 1)); fprintf_filtered (stream, (is_vector ? ")))" : "]")); c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index da01f8d32cf..5e2bc5fc364 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-09-25 Siddhesh Poyarekar + + * gdb.base/longest-types.c: New test case. + * gdb.base/longest-types.exp: New test case. + 2012-09-25 Yao Qi * gdb.mi/mi2-cli.exp: Check breakpoint notification. diff --git a/gdb/testsuite/gdb.base/longest-types.c b/gdb/testsuite/gdb.base/longest-types.c new file mode 100644 index 00000000000..1394c08bdc5 --- /dev/null +++ b/gdb/testsuite/gdb.base/longest-types.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2012 Free Software Foundation, Inc. + + 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 . */ + +struct foo +{ + char buf[0xffff000000]; + char buf2[2]; +} *f; + +int +main (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/longest-types.exp b/gdb/testsuite/gdb.base/longest-types.exp new file mode 100644 index 00000000000..334307a1e02 --- /dev/null +++ b/gdb/testsuite/gdb.base/longest-types.exp @@ -0,0 +1,25 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2012 Free Software Foundation, Inc. + +# 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 . + +standard_testfile + +if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile {debug quiet}] } { + return -1 +} + +# 64-bit array size should not overflow +gdb_test "print &f->buf" {= \(char \(\*\)\[1099494850560\]\) 0x0} -- 2.30.2