* gdbtypes.c (create_string_type): Receive character type as argument.
[deliverable/binutils-gdb.git] / gdb / valops.c
index 422821ab1e63f72a9433ff44634f130738c10782..05585c997af25c5048d045181a3699064beca34f 100644 (file)
@@ -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 *
This page took 0.023469 seconds and 4 git commands to generate.