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


On Mon, 24 Sep 2012 18:45:34 +0100, Pedro wrote:
> This will fail to compile on 32-bit targets (size too large), and
> the complaint will be verbose on the test run's terminal.  You can
> make the failure quiet by passing "quiet" to prepare_for_testing.
> 
> Other than that, looks good to me.
> 

Thanks, committed with your suggested changes.

Regards,
Siddhesh

http://sourceware.org/ml/gdb-cvs/2012-09/msg00138.html


===================================================================
RCS file: /cvs/src/src/gdb/c-typeprint.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- src/gdb/c-typeprint.c	2012/09/21 17:37:47	1.80
+++ src/gdb/c-typeprint.c	2012/09/25 12:20:39	1.81
@@ -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,
/cvs/src/src/gdb/testsuite/gdb.base/longest-types.c,v  -->  standard output
revision 1.1
--- src/gdb/testsuite/gdb.base/longest-types.c
+++ -	2012-09-25 12:22:16.332782000 +0000
@@ -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;
+}
/cvs/src/src/gdb/testsuite/gdb.base/longest-types.exp,v  -->  standard output
revision 1.1
--- src/gdb/testsuite/gdb.base/longest-types.exp
+++ -	2012-09-25 12:22:16.970778000 +0000
@@ -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 <http://www.gnu.org/licenses/>.
+
+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}


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