From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7067 invoked by alias); 24 Sep 2012 11:22:54 -0000 Received: (qmail 7057 invoked by uid 22791); 24 Sep 2012 11:22:52 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Sep 2012 11:22:34 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8OBMYwv016394 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 24 Sep 2012 07:22:34 -0400 Received: from spoyarek (spoyarek.pnq.redhat.com [10.65.192.188]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8OBMVIc009730 for ; Mon, 24 Sep 2012 07:22:32 -0400 Date: Mon, 24 Sep 2012 11:22:00 -0000 From: Siddhesh Poyarekar To: gdb-patches@sourceware.org Subject: [PATCH] Allow printing of 64-bit array sizes in C Message-ID: <20120924165151.1ad3c613@spoyarek> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/6v8phnnu/suSn+zjVXIeYs0" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-09/txt/msg00494.txt.bz2 --MP_/6v8phnnu/suSn+zjVXIeYs0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 946 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. --MP_/6v8phnnu/suSn+zjVXIeYs0 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=array-size.patch Content-length: 2784 --- 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 . */ + +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 . + +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} --MP_/6v8phnnu/suSn+zjVXIeYs0--