From: Siddhesh Poyarekar <siddhesh@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Expand LEN parameter of value_*string functions
Date: Tue, 25 Sep 2012 15:54:00 -0000 [thread overview]
Message-ID: <20120925203940.591674f1@spoyarek> (raw)
[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]
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.
[-- Attachment #2: bounds.patch --]
[-- Type: text/x-patch, Size: 3623 bytes --]
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,
next reply other threads:[~2012-09-25 15:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-25 15:54 Siddhesh Poyarekar [this message]
2012-09-26 17:37 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120925203940.591674f1@spoyarek \
--to=siddhesh@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox