* [PATCH] Expand LEN parameter of value_*string functions
@ 2012-09-25 15:54 Siddhesh Poyarekar
2012-09-26 17:37 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Siddhesh Poyarekar @ 2012-09-25 15:54 UTC (permalink / raw)
To: gdb-patches
[-- 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,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Expand LEN parameter of value_*string functions
2012-09-25 15:54 [PATCH] Expand LEN parameter of value_*string functions Siddhesh Poyarekar
@ 2012-09-26 17:37 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2012-09-26 17:37 UTC (permalink / raw)
To: Siddhesh Poyarekar; +Cc: gdb-patches
>>>>> "Siddhesh" == Siddhesh Poyarekar <siddhesh@redhat.com> writes:
Siddhesh> The value_string and value_cstring functions take string
Siddhesh> lengths as parameters and that ought to be at least ssize_t.
Siddhesh> * gdbtypes.c (lookup_array_range_type): Expand parameters
Siddhesh> LOW_BOUND and HIGH_BOUND to LONGEST.
Siddhesh> (lookup_string_range_type): Likewise.
Siddhesh> * gdbtypes.h (lookup_array_range_type): Likewise.
Siddhesh> (lookup_string_range_type): Likewise.
Siddhesh> * valops.c (value_cstring): Expand parameter LEN to ssize_t.
Siddhesh> Expand HIGHBOUND to ssize_t.
Siddhesh> (value_string): Likewise.
Siddhesh> * value.h (value_cstring): Expand parameter LEN to ssize_t.
Siddhesh> (value_string): Likewise.
Ok. Thanks.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-26 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-25 15:54 [PATCH] Expand LEN parameter of value_*string functions Siddhesh Poyarekar
2012-09-26 17:37 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox