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] Allow printing of 64-bit array sizes in C


On Mon, 24 Sep 2012 16:51:51 +0530, Siddhesh wrote:
> 	* gdb.base/longest-types.patch.c: New test case.
> 	* gdb.base/longest-types.patch.c: New test case.

Sorry, I just noticed the stupid substitution mistake I made while
renaming the test case files.  Attached is the patch with the corrected
name, i.e. without the `.patch`.

Regards,
Siddhesh

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.patch.c: New test case.
	* gdb.base/longest-types.patch.c: New test case.

--- gdb/c-typeprint.c	21 Sep 2012 17:37:47 -0000	1.80
+++ gdb/c-typeprint.c	24 Sep 2012 10:59:44 -0000
@@ -621,8 +621,8 @@
 	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,
--- /dev/null	2012-09-19 15:55:50.322002065 +0530
+++ gdb/testsuite/gdb.base/longest-types.c	2012-09-24 16:22:15.332462082 +0530
@@ -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 <http://www.gnu.org/licenses/>.  */
+
+struct foo
+{
+  char buf[0xffff000000];
+  char buf2[2];
+} *f;
+
+int
+main (void)
+{
+  return 0;
+}
--- /dev/null	2012-09-19 15:55:50.322002065 +0530
+++ gdb/testsuite/gdb.base/longest-types.exp	2012-09-24 16:22:50.599462893 +0530
@@ -0,0 +1,27 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+set testfile "longest-types"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+    return -1
+}
+
+# 64-bit array size should not overflow
+gdb_test "print &f->buf" {= \(char \(\*\)\[1099494850560\]\) 0x0}

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