summaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorJason Molenda <jsm@bugshack.cygnus.com>1999-06-14 18:08:47 +0000
committerJason Molenda <jsm@bugshack.cygnus.com>1999-06-14 18:08:47 +0000
commit230bac55c0bfe6bf4aeaffc03b8995570c39d35c (patch)
tree5e5477c70dc79b6182aa43e88cb7840ce81cc41c /gdb/values.c
parent57db482b8ea3919ee06ac7a11b1c76320c5807ff (diff)
downloadgdb-230bac55c0bfe6bf4aeaffc03b8995570c39d35c.tar.gz
import gdb-1999-06-14 snapshot
Diffstat (limited to 'gdb/values.c')
-rw-r--r--gdb/values.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb/values.c b/gdb/values.c
index 68e04441d0b..b3cc82f447a 100644
--- a/gdb/values.c
+++ b/gdb/values.c
@@ -1454,6 +1454,32 @@ value_from_longest (type, num)
return val;
}
+/* Create a value for a string constant to be stored locally
+ (not in the inferior's memory space, but in GDB memory).
+ This is analogous to value_from_longest, which also does not
+ use inferior memory. String shall NOT contain embedded nulls. */
+
+value_ptr
+value_from_string (ptr)
+ char *ptr;
+{
+ value_ptr val;
+ int len = strlen (ptr);
+ int lowbound = current_language->string_lower_bound;
+ struct type *rangetype =
+ create_range_type ((struct type *) NULL,
+ builtin_type_int,
+ lowbound, len + lowbound - 1);
+ struct type *stringtype =
+ create_array_type ((struct type *) NULL,
+ *current_language->string_char_type,
+ rangetype);
+
+ val = allocate_value (stringtype);
+ memcpy (VALUE_CONTENTS_RAW (val), ptr, len);
+ return val;
+}
+
value_ptr
value_from_double (type, num)
struct type *type;