summaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 422821ab1e6..05585c997af 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1349,7 +1349,7 @@ value_array (int lowbound, int highbound, struct value **elemvec)
}
struct value *
-value_typed_string (char *ptr, int len, struct type *char_type)
+value_cstring (char *ptr, int len, struct type *char_type)
{
struct value *val;
int lowbound = current_language->string_lower_bound;
@@ -1376,34 +1376,21 @@ value_typed_string (char *ptr, int len, struct type *char_type)
string may contain embedded null bytes. */
struct value *
-value_string (char *ptr, int len)
+value_string (char *ptr, int len, struct type *char_type)
{
struct value *val;
int lowbound = current_language->string_lower_bound;
+ int highbound = len / TYPE_LENGTH (char_type);
struct type *rangetype = create_range_type ((struct type *) NULL,
builtin_type_int32,
lowbound,
- len + lowbound - 1);
+ highbound + lowbound - 1);
struct type *stringtype
- = create_string_type ((struct type *) NULL, rangetype);
- CORE_ADDR addr;
-
- if (current_language->c_style_arrays == 0)
- {
- val = allocate_value (stringtype);
- memcpy (value_contents_raw (val), ptr, len);
- return val;
- }
+ = create_string_type ((struct type *) NULL, char_type, rangetype);
-
- /* Allocate space to store the string in the inferior, and then copy
- LEN bytes from PTR in gdb to that address in the inferior. */
-
- addr = allocate_space_in_inferior (len);
- write_memory (addr, (gdb_byte *) ptr, len);
-
- val = value_at_lazy (stringtype, addr);
- return (val);
+ val = allocate_value (stringtype);
+ memcpy (value_contents_raw (val), ptr, len);
+ return val;
}
struct value *