From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23408 invoked by alias); 25 Sep 2012 15:54:59 -0000 Received: (qmail 23393 invoked by uid 22791); 25 Sep 2012 15:54:58 -0000 X-SWARE-Spam-Status: No, hits=-7.4 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; Tue, 25 Sep 2012 15:54:34 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8PFsW0M003754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Sep 2012 11:54:34 -0400 Received: from spoyarek (spoyarek.pnq.redhat.com [10.65.192.188]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8PFALmp000954 for ; Tue, 25 Sep 2012 11:10:22 -0400 Date: Tue, 25 Sep 2012 15:54:00 -0000 From: Siddhesh Poyarekar To: gdb-patches@sourceware.org Subject: [PATCH] Expand LEN parameter of value_*string functions Message-ID: <20120925203940.591674f1@spoyarek> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/FhWWdy_xfcp.1bzactVvEMG" 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/msg00556.txt.bz2 --MP_/FhWWdy_xfcp.1bzactVvEMG Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1125 Hi, The value_string and value_cstring functions take string lengths as parameters and that ought to be at least ssize_t. Attached patch makes this change and also adjusts the parameters of functions it calls, i.e. lookup_array_range_type and lookup_string_range_type. The bounds parameters of these functions are expanded to LONGEST instead of just ssize_t to match them with the type of low and high in type.main_type.fields[i].flds_bnds.bounds. This fix is separated from the earlier bitpos patch[1]. I have verified that this does not cause any regressions on x86_64. OK to commit? Regards, Siddhesh [1] http://sourceware.org/ml/gdb-patches/2012-08/msg00144.html gdb/ChangeLog: * gdbtypes.c (lookup_array_range_type): Expand parameters LOW_BOUND and HIGH_BOUND to LONGEST. (lookup_string_range_type): Likewise. * gdbtypes.h (lookup_array_range_type): Likewise. (lookup_string_range_type): Likewise. * valops.c (value_cstring): Expand parameter LEN to ssize_t. Expand HIGHBOUND to ssize_t. (value_string): Likewise. * value.h (value_cstring): Expand parameter LEN to ssize_t. (value_string): Likewise. --MP_/FhWWdy_xfcp.1bzactVvEMG Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=bounds.patch Content-length: 3623 Index: gdb/gdbtypes.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtypes.c,v retrieving revision 1.242 diff -u -r1.242 gdbtypes.c --- gdb/gdbtypes.c 10 Sep 2012 17:12:51 -0000 1.242 +++ gdb/gdbtypes.c 25 Sep 2012 14:33:46 -0000 @@ -964,7 +964,7 @@ struct type * lookup_array_range_type (struct type *element_type, - int low_bound, int high_bound) + LONGEST low_bound, LONGEST high_bound) { struct gdbarch *gdbarch = get_type_arch (element_type); struct type *index_type = builtin_type (gdbarch)->builtin_int; @@ -1000,7 +1000,7 @@ struct type * lookup_string_range_type (struct type *string_char_type, - int low_bound, int high_bound) + LONGEST low_bound, LONGEST high_bound) { struct type *result_type; Index: gdb/gdbtypes.h =================================================================== RCS file: /cvs/src/src/gdb/gdbtypes.h,v retrieving revision 1.172 diff -u -r1.172 gdbtypes.h --- gdb/gdbtypes.h 10 Sep 2012 17:12:51 -0000 1.172 +++ gdb/gdbtypes.h 25 Sep 2012 14:33:47 -0000 @@ -1526,11 +1526,11 @@ extern struct type *create_array_type (struct type *, struct type *, struct type *); -extern struct type *lookup_array_range_type (struct type *, int, int); +extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST); extern struct type *create_string_type (struct type *, struct type *, struct type *); -extern struct type *lookup_string_range_type (struct type *, int, int); +extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST); extern struct type *create_set_type (struct type *, struct type *); Index: gdb/valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.303 diff -u -r1.303 valops.c --- gdb/valops.c 25 Sep 2012 12:48:53 -0000 1.303 +++ gdb/valops.c 25 Sep 2012 14:33:48 -0000 @@ -1838,11 +1838,11 @@ } struct value * -value_cstring (char *ptr, int len, struct type *char_type) +value_cstring (char *ptr, ssize_t len, struct type *char_type) { struct value *val; int lowbound = current_language->string_lower_bound; - int highbound = len / TYPE_LENGTH (char_type); + ssize_t highbound = len / TYPE_LENGTH (char_type); struct type *stringtype = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1); @@ -1861,11 +1861,11 @@ string may contain embedded null bytes. */ struct value * -value_string (char *ptr, int len, struct type *char_type) +value_string (char *ptr, ssize_t len, struct type *char_type) { struct value *val; int lowbound = current_language->string_lower_bound; - int highbound = len / TYPE_LENGTH (char_type); + ssize_t highbound = len / TYPE_LENGTH (char_type); struct type *stringtype = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1); Index: gdb/value.h =================================================================== RCS file: /cvs/src/src/gdb/value.h,v retrieving revision 1.209 diff -u -r1.209 value.h --- gdb/value.h 13 Aug 2012 00:54:04 -0000 1.209 +++ gdb/value.h 25 Sep 2012 14:33:48 -0000 @@ -587,9 +587,9 @@ extern void value_free_to_mark (struct value *mark); -extern struct value *value_cstring (char *ptr, int len, +extern struct value *value_cstring (char *ptr, ssize_t len, struct type *char_type); -extern struct value *value_string (char *ptr, int len, +extern struct value *value_string (char *ptr, ssize_t len, struct type *char_type); extern struct value *value_array (int lowbound, int highbound, --MP_/FhWWdy_xfcp.1bzactVvEMG--