aboutsummaryrefslogtreecommitdiff
path: root/gdb/values.c
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>1999-06-14 18:08:47 +0000
committerJason Molenda <jmolenda@apple.com>1999-06-14 18:08:47 +0000
commit0f71a2f66f83f4c7ac139fa8d33ab882362fe861 (patch)
tree16074aaf8b9c3abda2ddf840b5b307c933298a75 /gdb/values.c
parent308b1ffdedc0380e17d84260b0069593eb4f9336 (diff)
downloadgdb-0f71a2f66f83f4c7ac139fa8d33ab882362fe861.zip
gdb-0f71a2f66f83f4c7ac139fa8d33ab882362fe861.tar.gz
gdb-0f71a2f66f83f4c7ac139fa8d33ab882362fe861.tar.bz2
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 68e0444..b3cc82f 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;