* [PATCH] Allow printing of 64-bit array sizes in C
@ 2012-09-24 11:22 Siddhesh Poyarekar
2012-09-24 11:48 ` Siddhesh Poyarekar
0 siblings, 1 reply; 5+ messages in thread
From: Siddhesh Poyarekar @ 2012-09-24 11:22 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 946 bytes --]
Hi,
The bitpos expansion patch[1] also included a fix to allow printing of
64-bit array sizes in C. I have now separated out this portion of the
patch since it is a separate problem and can be fixed independently of
the struct/offset expansion.
I have also included a test case with this. I have put the array whose
size I intend to test inside a struct so that I can use this same test
case for the bitpos test and renamed the test case accordingly. The
test passes with this patch (and not without it). I have also verified
on F-16 x86_64 that I do not see any regressions resulting from the
fix. OK to commit?
Regards,
Siddhesh
[1] http://sourceware.org/ml/gdb-patches/2012-08/msg00144.html
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.
[-- Attachment #2: array-size.patch --]
[-- Type: text/x-patch, Size: 2784 bytes --]
--- 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.patch.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.patch.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.patch"
+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}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Allow printing of 64-bit array sizes in C
2012-09-24 11:22 [PATCH] Allow printing of 64-bit array sizes in C Siddhesh Poyarekar
@ 2012-09-24 11:48 ` Siddhesh Poyarekar
2012-09-24 12:18 ` [PATCH] Take 2: " Siddhesh Poyarekar
0 siblings, 1 reply; 5+ messages in thread
From: Siddhesh Poyarekar @ 2012-09-24 11:48 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
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.
[-- Attachment #2: array-size.patch --]
[-- Type: text/x-patch, Size: 2766 bytes --]
--- 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}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Take 2: Allow printing of 64-bit array sizes in C
2012-09-24 11:48 ` Siddhesh Poyarekar
@ 2012-09-24 12:18 ` Siddhesh Poyarekar
2012-09-24 17:45 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Siddhesh Poyarekar @ 2012-09-24 12:18 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]
(Starting afresh because I have made too many mistakes in the earlier
thread. Sorry about the noise)
Hi,
The bitpos expansion patch[1] also included a fix to allow printing of
64-bit array sizes in C. I have now separated out this portion of the
patch since it is a separate problem and can be fixed independently of
the struct/offset expansion.
I have also included a test case with this. I have put the array whose
size I intend to test inside a struct so that I can use this same test
case for the bitpos test and renamed the test case accordingly. The
test passes with this patch (and not without it). I have also verified
on F-16 x86_64 that I do not see any regressions resulting from the
fix. OK to commit?
Regards,
Siddhesh
[1] http://sourceware.org/ml/gdb-patches/2012-08/msg00144.html
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.
[-- Attachment #2: array-size.patch --]
[-- Type: text/x-patch, Size: 2766 bytes --]
--- 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}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Take 2: Allow printing of 64-bit array sizes in C
2012-09-24 12:18 ` [PATCH] Take 2: " Siddhesh Poyarekar
@ 2012-09-24 17:45 ` Pedro Alves
2012-09-25 12:23 ` Siddhesh Poyarekar
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2012-09-24 17:45 UTC (permalink / raw)
To: Siddhesh Poyarekar; +Cc: gdb-patches
On 09/24/2012 01:17 PM, Siddhesh Poyarekar wrote:
> +set testfile "longest-types"
> +set srcfile ${testfile}.c
> +set binfile ${objdir}/${subdir}/${testfile}
These three lines can now be replaced with a single
standard_testfile
+
> +if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
...
+struct foo
> +{
> + char buf[0xffff000000];
> + char buf2[2];
> +} *f;
> +
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.
--
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Take 2: Allow printing of 64-bit array sizes in C
2012-09-24 17:45 ` Pedro Alves
@ 2012-09-25 12:23 ` Siddhesh Poyarekar
0 siblings, 0 replies; 5+ messages in thread
From: Siddhesh Poyarekar @ 2012-09-25 12:23 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
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}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-09-25 12:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-24 11:22 [PATCH] Allow printing of 64-bit array sizes in C Siddhesh Poyarekar
2012-09-24 11:48 ` Siddhesh Poyarekar
2012-09-24 12:18 ` [PATCH] Take 2: " Siddhesh Poyarekar
2012-09-24 17:45 ` Pedro Alves
2012-09-25 12:23 ` Siddhesh Poyarekar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox