Rename gdb exception types
[deliverable/binutils-gdb.git] / gdb / guile / scm-value.c
1 /* Scheme interface to values.
2
3 Copyright (C) 2008-2019 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* See README file in this directory for implementation notes, coding
21 conventions, et.al. */
22
23 #include "defs.h"
24 #include "arch-utils.h"
25 #include "charset.h"
26 #include "cp-abi.h"
27 #include "target-float.h"
28 #include "infcall.h"
29 #include "symtab.h" /* Needed by language.h. */
30 #include "language.h"
31 #include "valprint.h"
32 #include "value.h"
33 #include "guile-internal.h"
34
35 /* The <gdb:value> smob. */
36
37 typedef struct _value_smob
38 {
39 /* This always appears first. */
40 gdb_smob base;
41
42 /* Doubly linked list of values in values_in_scheme.
43 IWBN to use a chained_gdb_smob instead, which is doable, it just requires
44 a bit more casting than normal. */
45 struct _value_smob *next;
46 struct _value_smob *prev;
47
48 struct value *value;
49
50 /* These are cached here to avoid making multiple copies of them.
51 Plus computing the dynamic_type can be a bit expensive.
52 We use #f to indicate that the value doesn't exist (e.g. value doesn't
53 have an address), so we need another value to indicate that we haven't
54 computed the value yet. For this we use SCM_UNDEFINED. */
55 SCM address;
56 SCM type;
57 SCM dynamic_type;
58 } value_smob;
59
60 static const char value_smob_name[] = "gdb:value";
61
62 /* The tag Guile knows the value smob by. */
63 static scm_t_bits value_smob_tag;
64
65 /* List of all values which are currently exposed to Scheme. It is
66 maintained so that when an objfile is discarded, preserve_values
67 can copy the values' types if needed. */
68 static value_smob *values_in_scheme;
69
70 /* Keywords used by Scheme procedures in this file. */
71 static SCM type_keyword;
72 static SCM encoding_keyword;
73 static SCM errors_keyword;
74 static SCM length_keyword;
75
76 /* Possible #:errors values. */
77 static SCM error_symbol;
78 static SCM escape_symbol;
79 static SCM substitute_symbol;
80 \f
81 /* Administrivia for value smobs. */
82
83 /* Iterate over all the <gdb:value> objects, calling preserve_one_value on
84 each.
85 This is the extension_language_ops.preserve_values "method". */
86
87 void
88 gdbscm_preserve_values (const struct extension_language_defn *extlang,
89 struct objfile *objfile, htab_t copied_types)
90 {
91 value_smob *iter;
92
93 for (iter = values_in_scheme; iter; iter = iter->next)
94 preserve_one_value (iter->value, objfile, copied_types);
95 }
96
97 /* Helper to add a value_smob to the global list. */
98
99 static void
100 vlscm_remember_scheme_value (value_smob *v_smob)
101 {
102 v_smob->next = values_in_scheme;
103 if (v_smob->next)
104 v_smob->next->prev = v_smob;
105 v_smob->prev = NULL;
106 values_in_scheme = v_smob;
107 }
108
109 /* Helper to remove a value_smob from the global list. */
110
111 static void
112 vlscm_forget_value_smob (value_smob *v_smob)
113 {
114 /* Remove SELF from the global list. */
115 if (v_smob->prev)
116 v_smob->prev->next = v_smob->next;
117 else
118 {
119 gdb_assert (values_in_scheme == v_smob);
120 values_in_scheme = v_smob->next;
121 }
122 if (v_smob->next)
123 v_smob->next->prev = v_smob->prev;
124 }
125
126 /* The smob "free" function for <gdb:value>. */
127
128 static size_t
129 vlscm_free_value_smob (SCM self)
130 {
131 value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self);
132
133 vlscm_forget_value_smob (v_smob);
134 value_decref (v_smob->value);
135
136 return 0;
137 }
138
139 /* The smob "print" function for <gdb:value>. */
140
141 static int
142 vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate)
143 {
144 value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self);
145 struct value_print_options opts;
146
147 if (pstate->writingp)
148 gdbscm_printf (port, "#<%s ", value_smob_name);
149
150 get_user_print_options (&opts);
151 opts.deref_ref = 0;
152
153 /* pstate->writingp = zero if invoked by display/~A, and nonzero if
154 invoked by write/~S. What to do here may need to evolve.
155 IWBN if we could pass an argument to format that would we could use
156 instead of writingp. */
157 opts.raw = !!pstate->writingp;
158
159 try
160 {
161 string_file stb;
162
163 common_val_print (v_smob->value, &stb, 0, &opts, current_language);
164 scm_puts (stb.c_str (), port);
165 }
166 catch (const gdb_exception &except)
167 {
168 GDBSCM_HANDLE_GDB_EXCEPTION (except);
169 }
170
171 if (pstate->writingp)
172 scm_puts (">", port);
173
174 scm_remember_upto_here_1 (self);
175
176 /* Non-zero means success. */
177 return 1;
178 }
179
180 /* The smob "equalp" function for <gdb:value>. */
181
182 static SCM
183 vlscm_equal_p_value_smob (SCM v1, SCM v2)
184 {
185 const value_smob *v1_smob = (value_smob *) SCM_SMOB_DATA (v1);
186 const value_smob *v2_smob = (value_smob *) SCM_SMOB_DATA (v2);
187 int result = 0;
188
189 try
190 {
191 result = value_equal (v1_smob->value, v2_smob->value);
192 }
193 catch (const gdb_exception &except)
194 {
195 GDBSCM_HANDLE_GDB_EXCEPTION (except);
196 }
197
198 return scm_from_bool (result);
199 }
200
201 /* Low level routine to create a <gdb:value> object. */
202
203 static SCM
204 vlscm_make_value_smob (void)
205 {
206 value_smob *v_smob = (value_smob *)
207 scm_gc_malloc (sizeof (value_smob), value_smob_name);
208 SCM v_scm;
209
210 /* These must be filled in by the caller. */
211 v_smob->value = NULL;
212 v_smob->prev = NULL;
213 v_smob->next = NULL;
214
215 /* These are lazily computed. */
216 v_smob->address = SCM_UNDEFINED;
217 v_smob->type = SCM_UNDEFINED;
218 v_smob->dynamic_type = SCM_UNDEFINED;
219
220 v_scm = scm_new_smob (value_smob_tag, (scm_t_bits) v_smob);
221 gdbscm_init_gsmob (&v_smob->base);
222
223 return v_scm;
224 }
225
226 /* Return non-zero if SCM is a <gdb:value> object. */
227
228 int
229 vlscm_is_value (SCM scm)
230 {
231 return SCM_SMOB_PREDICATE (value_smob_tag, scm);
232 }
233
234 /* (value? object) -> boolean */
235
236 static SCM
237 gdbscm_value_p (SCM scm)
238 {
239 return scm_from_bool (vlscm_is_value (scm));
240 }
241
242 /* Create a new <gdb:value> object that encapsulates VALUE.
243 The value is released from the all_values chain so its lifetime is not
244 bound to the execution of a command. */
245
246 SCM
247 vlscm_scm_from_value (struct value *value)
248 {
249 /* N.B. It's important to not cause any side-effects until we know the
250 conversion worked. */
251 SCM v_scm = vlscm_make_value_smob ();
252 value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (v_scm);
253
254 v_smob->value = release_value (value).release ();
255 vlscm_remember_scheme_value (v_smob);
256
257 return v_scm;
258 }
259
260 /* Returns the <gdb:value> object in SELF.
261 Throws an exception if SELF is not a <gdb:value> object. */
262
263 static SCM
264 vlscm_get_value_arg_unsafe (SCM self, int arg_pos, const char *func_name)
265 {
266 SCM_ASSERT_TYPE (vlscm_is_value (self), self, arg_pos, func_name,
267 value_smob_name);
268
269 return self;
270 }
271
272 /* Returns a pointer to the value smob of SELF.
273 Throws an exception if SELF is not a <gdb:value> object. */
274
275 static value_smob *
276 vlscm_get_value_smob_arg_unsafe (SCM self, int arg_pos, const char *func_name)
277 {
278 SCM v_scm = vlscm_get_value_arg_unsafe (self, arg_pos, func_name);
279 value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (v_scm);
280
281 return v_smob;
282 }
283
284 /* Return the value field of V_SCM, an object of type <gdb:value>.
285 This exists so that we don't have to export the struct's contents. */
286
287 struct value *
288 vlscm_scm_to_value (SCM v_scm)
289 {
290 value_smob *v_smob;
291
292 gdb_assert (vlscm_is_value (v_scm));
293 v_smob = (value_smob *) SCM_SMOB_DATA (v_scm);
294 return v_smob->value;
295 }
296 \f
297 /* Value methods. */
298
299 /* (make-value x [#:type type]) -> <gdb:value> */
300
301 static SCM
302 gdbscm_make_value (SCM x, SCM rest)
303 {
304 const SCM keywords[] = { type_keyword, SCM_BOOL_F };
305
306 int type_arg_pos = -1;
307 SCM type_scm = SCM_UNDEFINED;
308 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG2, keywords, "#O", rest,
309 &type_arg_pos, &type_scm);
310
311 struct type *type = NULL;
312 if (type_arg_pos > 0)
313 {
314 type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (type_scm,
315 type_arg_pos,
316 FUNC_NAME);
317 type = tyscm_type_smob_type (t_smob);
318 }
319
320 return gdbscm_wrap ([=]
321 {
322 scoped_value_mark free_values;
323
324 SCM except_scm;
325 struct value *value
326 = vlscm_convert_typed_value_from_scheme (FUNC_NAME, SCM_ARG1, x,
327 type_arg_pos, type_scm, type,
328 &except_scm,
329 get_current_arch (),
330 current_language);
331 if (value == NULL)
332 return except_scm;
333
334 return vlscm_scm_from_value (value);
335 });
336 }
337
338 /* (make-lazy-value <gdb:type> address) -> <gdb:value> */
339
340 static SCM
341 gdbscm_make_lazy_value (SCM type_scm, SCM address_scm)
342 {
343 type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (type_scm,
344 SCM_ARG1, FUNC_NAME);
345 struct type *type = tyscm_type_smob_type (t_smob);
346
347 ULONGEST address;
348 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG2, NULL, "U",
349 address_scm, &address);
350
351 return gdbscm_wrap ([=]
352 {
353 scoped_value_mark free_values;
354
355 struct value *value = value_from_contents_and_address (type, NULL,
356 address);
357 return vlscm_scm_from_value (value);
358 });
359 }
360
361 /* (value-optimized-out? <gdb:value>) -> boolean */
362
363 static SCM
364 gdbscm_value_optimized_out_p (SCM self)
365 {
366 value_smob *v_smob
367 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
368
369 return gdbscm_wrap ([=]
370 {
371 return scm_from_bool (value_optimized_out (v_smob->value));
372 });
373 }
374
375 /* (value-address <gdb:value>) -> integer
376 Returns #f if the value doesn't have one. */
377
378 static SCM
379 gdbscm_value_address (SCM self)
380 {
381 value_smob *v_smob
382 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
383 struct value *value = v_smob->value;
384
385 return gdbscm_wrap ([=]
386 {
387 if (SCM_UNBNDP (v_smob->address))
388 {
389 scoped_value_mark free_values;
390
391 SCM address = SCM_BOOL_F;
392
393 try
394 {
395 address = vlscm_scm_from_value (value_addr (value));
396 }
397 catch (const gdb_exception &except)
398 {
399 }
400
401 if (gdbscm_is_exception (address))
402 return address;
403
404 v_smob->address = address;
405 }
406
407 return v_smob->address;
408 });
409 }
410
411 /* (value-dereference <gdb:value>) -> <gdb:value>
412 Given a value of a pointer type, apply the C unary * operator to it. */
413
414 static SCM
415 gdbscm_value_dereference (SCM self)
416 {
417 value_smob *v_smob
418 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
419
420 return gdbscm_wrap ([=]
421 {
422 scoped_value_mark free_values;
423
424 struct value *res_val = value_ind (v_smob->value);
425 return vlscm_scm_from_value (res_val);
426 });
427 }
428
429 /* (value-referenced-value <gdb:value>) -> <gdb:value>
430 Given a value of a reference type, return the value referenced.
431 The difference between this function and gdbscm_value_dereference is that
432 the latter applies * unary operator to a value, which need not always
433 result in the value referenced.
434 For example, for a value which is a reference to an 'int' pointer ('int *'),
435 gdbscm_value_dereference will result in a value of type 'int' while
436 gdbscm_value_referenced_value will result in a value of type 'int *'. */
437
438 static SCM
439 gdbscm_value_referenced_value (SCM self)
440 {
441 value_smob *v_smob
442 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
443 struct value *value = v_smob->value;
444
445 return gdbscm_wrap ([=]
446 {
447 scoped_value_mark free_values;
448
449 struct value *res_val;
450
451 switch (TYPE_CODE (check_typedef (value_type (value))))
452 {
453 case TYPE_CODE_PTR:
454 res_val = value_ind (value);
455 break;
456 case TYPE_CODE_REF:
457 res_val = coerce_ref (value);
458 break;
459 default:
460 error (_("Trying to get the referenced value from a value which is"
461 " neither a pointer nor a reference"));
462 }
463
464 return vlscm_scm_from_value (res_val);
465 });
466 }
467
468 /* (value-type <gdb:value>) -> <gdb:type> */
469
470 static SCM
471 gdbscm_value_type (SCM self)
472 {
473 value_smob *v_smob
474 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
475 struct value *value = v_smob->value;
476
477 if (SCM_UNBNDP (v_smob->type))
478 v_smob->type = tyscm_scm_from_type (value_type (value));
479
480 return v_smob->type;
481 }
482
483 /* (value-dynamic-type <gdb:value>) -> <gdb:type> */
484
485 static SCM
486 gdbscm_value_dynamic_type (SCM self)
487 {
488 value_smob *v_smob
489 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
490 struct value *value = v_smob->value;
491 struct type *type = NULL;
492
493 if (! SCM_UNBNDP (v_smob->dynamic_type))
494 return v_smob->dynamic_type;
495
496 try
497 {
498 scoped_value_mark free_values;
499
500 type = value_type (value);
501 type = check_typedef (type);
502
503 if (((TYPE_CODE (type) == TYPE_CODE_PTR)
504 || (TYPE_CODE (type) == TYPE_CODE_REF))
505 && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT))
506 {
507 struct value *target;
508 int was_pointer = TYPE_CODE (type) == TYPE_CODE_PTR;
509
510 if (was_pointer)
511 target = value_ind (value);
512 else
513 target = coerce_ref (value);
514 type = value_rtti_type (target, NULL, NULL, NULL);
515
516 if (type)
517 {
518 if (was_pointer)
519 type = lookup_pointer_type (type);
520 else
521 type = lookup_lvalue_reference_type (type);
522 }
523 }
524 else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
525 type = value_rtti_type (value, NULL, NULL, NULL);
526 else
527 {
528 /* Re-use object's static type. */
529 type = NULL;
530 }
531 }
532 catch (const gdb_exception &except)
533 {
534 GDBSCM_HANDLE_GDB_EXCEPTION (except);
535 }
536
537 if (type == NULL)
538 v_smob->dynamic_type = gdbscm_value_type (self);
539 else
540 v_smob->dynamic_type = tyscm_scm_from_type (type);
541
542 return v_smob->dynamic_type;
543 }
544
545 /* A helper function that implements the various cast operators. */
546
547 static SCM
548 vlscm_do_cast (SCM self, SCM type_scm, enum exp_opcode op,
549 const char *func_name)
550 {
551 value_smob *v_smob
552 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
553 struct value *value = v_smob->value;
554 type_smob *t_smob
555 = tyscm_get_type_smob_arg_unsafe (type_scm, SCM_ARG2, FUNC_NAME);
556 struct type *type = tyscm_type_smob_type (t_smob);
557
558 return gdbscm_wrap ([=]
559 {
560 scoped_value_mark free_values;
561
562 struct value *res_val;
563 if (op == UNOP_DYNAMIC_CAST)
564 res_val = value_dynamic_cast (type, value);
565 else if (op == UNOP_REINTERPRET_CAST)
566 res_val = value_reinterpret_cast (type, value);
567 else
568 {
569 gdb_assert (op == UNOP_CAST);
570 res_val = value_cast (type, value);
571 }
572
573 return vlscm_scm_from_value (res_val);
574 });
575 }
576
577 /* (value-cast <gdb:value> <gdb:type>) -> <gdb:value> */
578
579 static SCM
580 gdbscm_value_cast (SCM self, SCM new_type)
581 {
582 return vlscm_do_cast (self, new_type, UNOP_CAST, FUNC_NAME);
583 }
584
585 /* (value-dynamic-cast <gdb:value> <gdb:type>) -> <gdb:value> */
586
587 static SCM
588 gdbscm_value_dynamic_cast (SCM self, SCM new_type)
589 {
590 return vlscm_do_cast (self, new_type, UNOP_DYNAMIC_CAST, FUNC_NAME);
591 }
592
593 /* (value-reinterpret-cast <gdb:value> <gdb:type>) -> <gdb:value> */
594
595 static SCM
596 gdbscm_value_reinterpret_cast (SCM self, SCM new_type)
597 {
598 return vlscm_do_cast (self, new_type, UNOP_REINTERPRET_CAST, FUNC_NAME);
599 }
600
601 /* (value-field <gdb:value> string) -> <gdb:value>
602 Given string name of an element inside structure, return its <gdb:value>
603 object. */
604
605 static SCM
606 gdbscm_value_field (SCM self, SCM field_scm)
607 {
608 value_smob *v_smob
609 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
610
611 SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2, FUNC_NAME,
612 _("string"));
613
614 return gdbscm_wrap ([=]
615 {
616 scoped_value_mark free_values;
617
618 gdb::unique_xmalloc_ptr<char> field = gdbscm_scm_to_c_string (field_scm);
619
620 struct value *tmp = v_smob->value;
621
622 struct value *res_val = value_struct_elt (&tmp, NULL, field.get (), NULL,
623 "struct/class/union");
624
625 return vlscm_scm_from_value (res_val);
626 });
627 }
628
629 /* (value-subscript <gdb:value> integer|<gdb:value>) -> <gdb:value>
630 Return the specified value in an array. */
631
632 static SCM
633 gdbscm_value_subscript (SCM self, SCM index_scm)
634 {
635 value_smob *v_smob
636 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
637 struct value *value = v_smob->value;
638 struct type *type = value_type (value);
639
640 SCM_ASSERT (type != NULL, self, SCM_ARG2, FUNC_NAME);
641
642 return gdbscm_wrap ([=]
643 {
644 scoped_value_mark free_values;
645
646 SCM except_scm;
647 struct value *index
648 = vlscm_convert_value_from_scheme (FUNC_NAME, SCM_ARG2, index_scm,
649 &except_scm,
650 get_type_arch (type),
651 current_language);
652 if (index == NULL)
653 return except_scm;
654
655 /* Assume we are attempting an array access, and let the value code
656 throw an exception if the index has an invalid type.
657 Check the value's type is something that can be accessed via
658 a subscript. */
659 struct value *tmp = coerce_ref (value);
660 struct type *tmp_type = check_typedef (value_type (tmp));
661 if (TYPE_CODE (tmp_type) != TYPE_CODE_ARRAY
662 && TYPE_CODE (tmp_type) != TYPE_CODE_PTR)
663 error (_("Cannot subscript requested type"));
664
665 struct value *res_val = value_subscript (tmp, value_as_long (index));
666 return vlscm_scm_from_value (res_val);
667 });
668 }
669
670 /* (value-call <gdb:value> arg-list) -> <gdb:value>
671 Perform an inferior function call on the value. */
672
673 static SCM
674 gdbscm_value_call (SCM self, SCM args)
675 {
676 value_smob *v_smob
677 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
678 struct value *function = v_smob->value;
679 struct type *ftype = NULL;
680 long args_count;
681 struct value **vargs = NULL;
682
683 try
684 {
685 ftype = check_typedef (value_type (function));
686 }
687 catch (const gdb_exception &except)
688 {
689 GDBSCM_HANDLE_GDB_EXCEPTION (except);
690 }
691
692 SCM_ASSERT_TYPE (TYPE_CODE (ftype) == TYPE_CODE_FUNC, self,
693 SCM_ARG1, FUNC_NAME,
694 _("function (value of TYPE_CODE_FUNC)"));
695
696 SCM_ASSERT_TYPE (gdbscm_is_true (scm_list_p (args)), args,
697 SCM_ARG2, FUNC_NAME, _("list"));
698
699 args_count = scm_ilength (args);
700 if (args_count > 0)
701 {
702 struct gdbarch *gdbarch = get_current_arch ();
703 const struct language_defn *language = current_language;
704 SCM except_scm;
705 long i;
706
707 vargs = XALLOCAVEC (struct value *, args_count);
708 for (i = 0; i < args_count; i++)
709 {
710 SCM arg = scm_car (args);
711
712 vargs[i] = vlscm_convert_value_from_scheme (FUNC_NAME,
713 GDBSCM_ARG_NONE, arg,
714 &except_scm,
715 gdbarch, language);
716 if (vargs[i] == NULL)
717 gdbscm_throw (except_scm);
718
719 args = scm_cdr (args);
720 }
721 gdb_assert (gdbscm_is_true (scm_null_p (args)));
722 }
723
724 return gdbscm_wrap ([=]
725 {
726 scoped_value_mark free_values;
727
728 auto av = gdb::make_array_view (vargs, args_count);
729 value *return_value = call_function_by_hand (function, NULL, av);
730 return vlscm_scm_from_value (return_value);
731 });
732 }
733
734 /* (value->bytevector <gdb:value>) -> bytevector */
735
736 static SCM
737 gdbscm_value_to_bytevector (SCM self)
738 {
739 value_smob *v_smob
740 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
741 struct value *value = v_smob->value;
742 struct type *type;
743 size_t length = 0;
744 const gdb_byte *contents = NULL;
745 SCM bv;
746
747 type = value_type (value);
748
749 try
750 {
751 type = check_typedef (type);
752 length = TYPE_LENGTH (type);
753 contents = value_contents (value);
754 }
755 catch (const gdb_exception &except)
756 {
757 GDBSCM_HANDLE_GDB_EXCEPTION (except);
758 }
759
760 bv = scm_c_make_bytevector (length);
761 memcpy (SCM_BYTEVECTOR_CONTENTS (bv), contents, length);
762
763 return bv;
764 }
765
766 /* Helper function to determine if a type is "int-like". */
767
768 static int
769 is_intlike (struct type *type, int ptr_ok)
770 {
771 return (TYPE_CODE (type) == TYPE_CODE_INT
772 || TYPE_CODE (type) == TYPE_CODE_ENUM
773 || TYPE_CODE (type) == TYPE_CODE_BOOL
774 || TYPE_CODE (type) == TYPE_CODE_CHAR
775 || (ptr_ok && TYPE_CODE (type) == TYPE_CODE_PTR));
776 }
777
778 /* (value->bool <gdb:value>) -> boolean
779 Throws an error if the value is not integer-like. */
780
781 static SCM
782 gdbscm_value_to_bool (SCM self)
783 {
784 value_smob *v_smob
785 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
786 struct value *value = v_smob->value;
787 struct type *type;
788 LONGEST l = 0;
789
790 type = value_type (value);
791
792 try
793 {
794 type = check_typedef (type);
795 }
796 catch (const gdb_exception &except)
797 {
798 GDBSCM_HANDLE_GDB_EXCEPTION (except);
799 }
800
801 SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME,
802 _("integer-like gdb value"));
803
804 try
805 {
806 if (TYPE_CODE (type) == TYPE_CODE_PTR)
807 l = value_as_address (value);
808 else
809 l = value_as_long (value);
810 }
811 catch (const gdb_exception &except)
812 {
813 GDBSCM_HANDLE_GDB_EXCEPTION (except);
814 }
815
816 return scm_from_bool (l != 0);
817 }
818
819 /* (value->integer <gdb:value>) -> integer
820 Throws an error if the value is not integer-like. */
821
822 static SCM
823 gdbscm_value_to_integer (SCM self)
824 {
825 value_smob *v_smob
826 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
827 struct value *value = v_smob->value;
828 struct type *type;
829 LONGEST l = 0;
830
831 type = value_type (value);
832
833 try
834 {
835 type = check_typedef (type);
836 }
837 catch (const gdb_exception &except)
838 {
839 GDBSCM_HANDLE_GDB_EXCEPTION (except);
840 }
841
842 SCM_ASSERT_TYPE (is_intlike (type, 1), self, SCM_ARG1, FUNC_NAME,
843 _("integer-like gdb value"));
844
845 try
846 {
847 if (TYPE_CODE (type) == TYPE_CODE_PTR)
848 l = value_as_address (value);
849 else
850 l = value_as_long (value);
851 }
852 catch (const gdb_exception &except)
853 {
854 GDBSCM_HANDLE_GDB_EXCEPTION (except);
855 }
856
857 if (TYPE_UNSIGNED (type))
858 return gdbscm_scm_from_ulongest (l);
859 else
860 return gdbscm_scm_from_longest (l);
861 }
862
863 /* (value->real <gdb:value>) -> real
864 Throws an error if the value is not a number. */
865
866 static SCM
867 gdbscm_value_to_real (SCM self)
868 {
869 value_smob *v_smob
870 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
871 struct value *value = v_smob->value;
872 struct type *type;
873 double d = 0;
874 struct value *check = nullptr;
875
876 type = value_type (value);
877
878 try
879 {
880 type = check_typedef (type);
881 }
882 catch (const gdb_exception &except)
883 {
884 GDBSCM_HANDLE_GDB_EXCEPTION (except);
885 }
886
887 SCM_ASSERT_TYPE (is_intlike (type, 0) || TYPE_CODE (type) == TYPE_CODE_FLT,
888 self, SCM_ARG1, FUNC_NAME, _("number"));
889
890 try
891 {
892 if (is_floating_value (value))
893 {
894 d = target_float_to_host_double (value_contents (value), type);
895 check = value_from_host_double (type, d);
896 }
897 else if (TYPE_UNSIGNED (type))
898 {
899 d = (ULONGEST) value_as_long (value);
900 check = value_from_ulongest (type, (ULONGEST) d);
901 }
902 else
903 {
904 d = value_as_long (value);
905 check = value_from_longest (type, (LONGEST) d);
906 }
907 }
908 catch (const gdb_exception &except)
909 {
910 GDBSCM_HANDLE_GDB_EXCEPTION (except);
911 }
912
913 /* TODO: Is there a better way to check if the value fits? */
914 if (!value_equal (value, check))
915 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
916 _("number can't be converted to a double"));
917
918 return scm_from_double (d);
919 }
920
921 /* (value->string <gdb:value>
922 [#:encoding encoding]
923 [#:errors #f | 'error | 'substitute]
924 [#:length length])
925 -> string
926 Return Unicode string with value's contents, which must be a string.
927
928 If ENCODING is not given, the string is assumed to be encoded in
929 the target's charset.
930
931 ERRORS is one of #f, 'error or 'substitute.
932 An error setting of #f means use the default, which is Guile's
933 %default-port-conversion-strategy when using Guile >= 2.0.6, or 'error if
934 using an earlier version of Guile. Earlier versions do not properly
935 support obtaining the default port conversion strategy.
936 If the default is not one of 'error or 'substitute, 'substitute is used.
937 An error setting of "error" causes an exception to be thrown if there's
938 a decoding error. An error setting of "substitute" causes invalid
939 characters to be replaced with "?".
940
941 If LENGTH is provided, only fetch string to the length provided.
942 LENGTH must be a Scheme integer, it can't be a <gdb:value> integer. */
943
944 static SCM
945 gdbscm_value_to_string (SCM self, SCM rest)
946 {
947 value_smob *v_smob
948 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
949 struct value *value = v_smob->value;
950 const SCM keywords[] = {
951 encoding_keyword, errors_keyword, length_keyword, SCM_BOOL_F
952 };
953 int encoding_arg_pos = -1, errors_arg_pos = -1, length_arg_pos = -1;
954 char *encoding = NULL;
955 SCM errors = SCM_BOOL_F;
956 /* Avoid an uninitialized warning from gcc. */
957 gdb_byte *buffer_contents = nullptr;
958 int length = -1;
959 const char *la_encoding = NULL;
960 struct type *char_type = NULL;
961 SCM result;
962
963 /* The sequencing here, as everywhere else, is important.
964 We can't have existing cleanups when a Scheme exception is thrown. */
965
966 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG2, keywords, "#sOi", rest,
967 &encoding_arg_pos, &encoding,
968 &errors_arg_pos, &errors,
969 &length_arg_pos, &length);
970
971 if (errors_arg_pos > 0
972 && errors != SCM_BOOL_F
973 && !scm_is_eq (errors, error_symbol)
974 && !scm_is_eq (errors, substitute_symbol))
975 {
976 SCM excp
977 = gdbscm_make_out_of_range_error (FUNC_NAME, errors_arg_pos, errors,
978 _("invalid error kind"));
979
980 xfree (encoding);
981 gdbscm_throw (excp);
982 }
983 if (errors == SCM_BOOL_F)
984 {
985 /* N.B. scm_port_conversion_strategy in Guile versions prior to 2.0.6
986 will throw a Scheme error when passed #f. */
987 if (gdbscm_guile_version_is_at_least (2, 0, 6))
988 errors = scm_port_conversion_strategy (SCM_BOOL_F);
989 else
990 errors = error_symbol;
991 }
992 /* We don't assume anything about the result of scm_port_conversion_strategy.
993 From this point on, if errors is not 'errors, use 'substitute. */
994
995 try
996 {
997 gdb::unique_xmalloc_ptr<gdb_byte> buffer;
998 LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding);
999 buffer_contents = buffer.release ();
1000 }
1001 catch (const gdb_exception &except)
1002 {
1003 xfree (encoding);
1004 GDBSCM_HANDLE_GDB_EXCEPTION (except);
1005 }
1006
1007 /* If errors is "error", scm_from_stringn may throw a Scheme exception.
1008 Make sure we don't leak. This is done via scm_dynwind_begin, et.al. */
1009
1010 scm_dynwind_begin ((scm_t_dynwind_flags) 0);
1011
1012 gdbscm_dynwind_xfree (encoding);
1013 gdbscm_dynwind_xfree (buffer_contents);
1014
1015 result = scm_from_stringn ((const char *) buffer_contents,
1016 length * TYPE_LENGTH (char_type),
1017 (encoding != NULL && *encoding != '\0'
1018 ? encoding
1019 : la_encoding),
1020 scm_is_eq (errors, error_symbol)
1021 ? SCM_FAILED_CONVERSION_ERROR
1022 : SCM_FAILED_CONVERSION_QUESTION_MARK);
1023
1024 scm_dynwind_end ();
1025
1026 return result;
1027 }
1028
1029 /* (value->lazy-string <gdb:value> [#:encoding encoding] [#:length length])
1030 -> <gdb:lazy-string>
1031 Return a Scheme object representing a lazy_string_object type.
1032 A lazy string is a pointer to a string with an optional encoding and length.
1033 If ENCODING is not given, the target's charset is used.
1034 If LENGTH is provided then the length parameter is set to LENGTH.
1035 Otherwise if the value is an array of known length then the array's length
1036 is used. Otherwise the length will be set to -1 (meaning first null of
1037 appropriate with).
1038 LENGTH must be a Scheme integer, it can't be a <gdb:value> integer. */
1039
1040 static SCM
1041 gdbscm_value_to_lazy_string (SCM self, SCM rest)
1042 {
1043 value_smob *v_smob
1044 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1045 struct value *value = v_smob->value;
1046 const SCM keywords[] = { encoding_keyword, length_keyword, SCM_BOOL_F };
1047 int encoding_arg_pos = -1, length_arg_pos = -1;
1048 char *encoding = NULL;
1049 int length = -1;
1050 SCM result = SCM_BOOL_F; /* -Wall */
1051 struct gdb_exception except = exception_none;
1052
1053 /* The sequencing here, as everywhere else, is important.
1054 We can't have existing cleanups when a Scheme exception is thrown. */
1055
1056 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG2, keywords, "#si", rest,
1057 &encoding_arg_pos, &encoding,
1058 &length_arg_pos, &length);
1059
1060 if (length < -1)
1061 {
1062 gdbscm_out_of_range_error (FUNC_NAME, length_arg_pos,
1063 scm_from_int (length),
1064 _("invalid length"));
1065 }
1066
1067 try
1068 {
1069 scoped_value_mark free_values;
1070
1071 struct type *type, *realtype;
1072 CORE_ADDR addr;
1073
1074 type = value_type (value);
1075 realtype = check_typedef (type);
1076
1077 switch (TYPE_CODE (realtype))
1078 {
1079 case TYPE_CODE_ARRAY:
1080 {
1081 LONGEST array_length = -1;
1082 LONGEST low_bound, high_bound;
1083
1084 /* PR 20786: There's no way to specify an array of length zero.
1085 Record a length of [0,-1] which is how Ada does it. Anything
1086 we do is broken, but this one possible solution. */
1087 if (get_array_bounds (realtype, &low_bound, &high_bound))
1088 array_length = high_bound - low_bound + 1;
1089 if (length == -1)
1090 length = array_length;
1091 else if (array_length == -1)
1092 {
1093 type = lookup_array_range_type (TYPE_TARGET_TYPE (realtype),
1094 0, length - 1);
1095 }
1096 else if (length != array_length)
1097 {
1098 /* We need to create a new array type with the
1099 specified length. */
1100 if (length > array_length)
1101 error (_("length is larger than array size"));
1102 type = lookup_array_range_type (TYPE_TARGET_TYPE (type),
1103 low_bound,
1104 low_bound + length - 1);
1105 }
1106 addr = value_address (value);
1107 break;
1108 }
1109 case TYPE_CODE_PTR:
1110 /* If a length is specified we defer creating an array of the
1111 specified width until we need to. */
1112 addr = value_as_address (value);
1113 break;
1114 default:
1115 /* Should flag an error here. PR 20769. */
1116 addr = value_address (value);
1117 break;
1118 }
1119
1120 result = lsscm_make_lazy_string (addr, length, encoding, type);
1121 }
1122 catch (const gdb_exception &ex)
1123 {
1124 except = ex;
1125 }
1126
1127 xfree (encoding);
1128 GDBSCM_HANDLE_GDB_EXCEPTION (except);
1129
1130 if (gdbscm_is_exception (result))
1131 gdbscm_throw (result);
1132
1133 return result;
1134 }
1135
1136 /* (value-lazy? <gdb:value>) -> boolean */
1137
1138 static SCM
1139 gdbscm_value_lazy_p (SCM self)
1140 {
1141 value_smob *v_smob
1142 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1143 struct value *value = v_smob->value;
1144
1145 return scm_from_bool (value_lazy (value));
1146 }
1147
1148 /* (value-fetch-lazy! <gdb:value>) -> unspecified */
1149
1150 static SCM
1151 gdbscm_value_fetch_lazy_x (SCM self)
1152 {
1153 value_smob *v_smob
1154 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1155 struct value *value = v_smob->value;
1156
1157 return gdbscm_wrap ([=]
1158 {
1159 if (value_lazy (value))
1160 value_fetch_lazy (value);
1161 return SCM_UNSPECIFIED;
1162 });
1163 }
1164
1165 /* (value-print <gdb:value>) -> string */
1166
1167 static SCM
1168 gdbscm_value_print (SCM self)
1169 {
1170 value_smob *v_smob
1171 = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1172 struct value *value = v_smob->value;
1173 struct value_print_options opts;
1174
1175 get_user_print_options (&opts);
1176 opts.deref_ref = 0;
1177
1178 string_file stb;
1179
1180 try
1181 {
1182 common_val_print (value, &stb, 0, &opts, current_language);
1183 }
1184 catch (const gdb_exception &except)
1185 {
1186 GDBSCM_HANDLE_GDB_EXCEPTION (except);
1187 }
1188
1189 /* Use SCM_FAILED_CONVERSION_QUESTION_MARK to ensure this doesn't
1190 throw an error if the encoding fails.
1191 IWBN to use scm_take_locale_string here, but we'd have to temporarily
1192 override the default port conversion handler because contrary to
1193 documentation it doesn't necessarily free the input string. */
1194 return scm_from_stringn (stb.c_str (), stb.size (), host_charset (),
1195 SCM_FAILED_CONVERSION_QUESTION_MARK);
1196 }
1197 \f
1198 /* (parse-and-eval string) -> <gdb:value>
1199 Parse a string and evaluate the string as an expression. */
1200
1201 static SCM
1202 gdbscm_parse_and_eval (SCM expr_scm)
1203 {
1204 char *expr_str;
1205 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "s",
1206 expr_scm, &expr_str);
1207
1208 return gdbscm_wrap ([=]
1209 {
1210 scoped_value_mark free_values;
1211 return vlscm_scm_from_value (parse_and_eval (expr_str));
1212 });
1213 }
1214
1215 /* (history-ref integer) -> <gdb:value>
1216 Return the specified value from GDB's value history. */
1217
1218 static SCM
1219 gdbscm_history_ref (SCM index)
1220 {
1221 int i;
1222 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "i", index, &i);
1223
1224 return gdbscm_wrap ([=]
1225 {
1226 return vlscm_scm_from_value (access_value_history (i));
1227 });
1228 }
1229
1230 /* (history-append! <gdb:value>) -> index
1231 Append VALUE to GDB's value history. Return its index in the history. */
1232
1233 static SCM
1234 gdbscm_history_append_x (SCM value)
1235 {
1236 value_smob *v_smob
1237 = vlscm_get_value_smob_arg_unsafe (value, SCM_ARG1, FUNC_NAME);
1238 return gdbscm_wrap ([=]
1239 {
1240 return scm_from_int (record_latest_value (v_smob->value));
1241 });
1242 }
1243 \f
1244 /* Initialize the Scheme value code. */
1245
1246 static const scheme_function value_functions[] =
1247 {
1248 { "value?", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_p),
1249 "\
1250 Return #t if the object is a <gdb:value> object." },
1251
1252 { "make-value", 1, 0, 1, as_a_scm_t_subr (gdbscm_make_value),
1253 "\
1254 Create a <gdb:value> representing object.\n\
1255 Typically this is used to convert numbers and strings to\n\
1256 <gdb:value> objects.\n\
1257 \n\
1258 Arguments: object [#:type <gdb:type>]" },
1259
1260 { "value-optimized-out?", 1, 0, 0,
1261 as_a_scm_t_subr (gdbscm_value_optimized_out_p),
1262 "\
1263 Return #t if the value has been optimizd out." },
1264
1265 { "value-address", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_address),
1266 "\
1267 Return the address of the value." },
1268
1269 { "value-type", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_type),
1270 "\
1271 Return the type of the value." },
1272
1273 { "value-dynamic-type", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_dynamic_type),
1274 "\
1275 Return the dynamic type of the value." },
1276
1277 { "value-cast", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_cast),
1278 "\
1279 Cast the value to the supplied type.\n\
1280 \n\
1281 Arguments: <gdb:value> <gdb:type>" },
1282
1283 { "value-dynamic-cast", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_dynamic_cast),
1284 "\
1285 Cast the value to the supplied type, as if by the C++\n\
1286 dynamic_cast operator.\n\
1287 \n\
1288 Arguments: <gdb:value> <gdb:type>" },
1289
1290 { "value-reinterpret-cast", 2, 0, 0,
1291 as_a_scm_t_subr (gdbscm_value_reinterpret_cast),
1292 "\
1293 Cast the value to the supplied type, as if by the C++\n\
1294 reinterpret_cast operator.\n\
1295 \n\
1296 Arguments: <gdb:value> <gdb:type>" },
1297
1298 { "value-dereference", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_dereference),
1299 "\
1300 Return the result of applying the C unary * operator to the value." },
1301
1302 { "value-referenced-value", 1, 0, 0,
1303 as_a_scm_t_subr (gdbscm_value_referenced_value),
1304 "\
1305 Given a value of a reference type, return the value referenced.\n\
1306 The difference between this function and value-dereference is that\n\
1307 the latter applies * unary operator to a value, which need not always\n\
1308 result in the value referenced.\n\
1309 For example, for a value which is a reference to an 'int' pointer ('int *'),\n\
1310 value-dereference will result in a value of type 'int' while\n\
1311 value-referenced-value will result in a value of type 'int *'." },
1312
1313 { "value-field", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_field),
1314 "\
1315 Return the specified field of the value.\n\
1316 \n\
1317 Arguments: <gdb:value> string" },
1318
1319 { "value-subscript", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_subscript),
1320 "\
1321 Return the value of the array at the specified index.\n\
1322 \n\
1323 Arguments: <gdb:value> integer" },
1324
1325 { "value-call", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_call),
1326 "\
1327 Perform an inferior function call taking the value as a pointer to the\n\
1328 function to call.\n\
1329 Each element of the argument list must be a <gdb:value> object or an object\n\
1330 that can be converted to one.\n\
1331 The result is the value returned by the function.\n\
1332 \n\
1333 Arguments: <gdb:value> arg-list" },
1334
1335 { "value->bool", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_to_bool),
1336 "\
1337 Return the Scheme boolean representing the GDB value.\n\
1338 The value must be \"integer like\". Pointers are ok." },
1339
1340 { "value->integer", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_to_integer),
1341 "\
1342 Return the Scheme integer representing the GDB value.\n\
1343 The value must be \"integer like\". Pointers are ok." },
1344
1345 { "value->real", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_to_real),
1346 "\
1347 Return the Scheme real number representing the GDB value.\n\
1348 The value must be a number." },
1349
1350 { "value->bytevector", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_to_bytevector),
1351 "\
1352 Return a Scheme bytevector with the raw contents of the GDB value.\n\
1353 No transformation, endian or otherwise, is performed." },
1354
1355 { "value->string", 1, 0, 1, as_a_scm_t_subr (gdbscm_value_to_string),
1356 "\
1357 Return the Unicode string of the value's contents.\n\
1358 If ENCODING is not given, the string is assumed to be encoded in\n\
1359 the target's charset.\n\
1360 An error setting \"error\" causes an exception to be thrown if there's\n\
1361 a decoding error. An error setting of \"substitute\" causes invalid\n\
1362 characters to be replaced with \"?\". The default is \"error\".\n\
1363 If LENGTH is provided, only fetch string to the length provided.\n\
1364 \n\
1365 Arguments: <gdb:value>\n\
1366 [#:encoding encoding] [#:errors \"error\"|\"substitute\"]\n\
1367 [#:length length]" },
1368
1369 { "value->lazy-string", 1, 0, 1,
1370 as_a_scm_t_subr (gdbscm_value_to_lazy_string),
1371 "\
1372 Return a Scheme object representing a lazily fetched Unicode string\n\
1373 of the value's contents.\n\
1374 If ENCODING is not given, the string is assumed to be encoded in\n\
1375 the target's charset.\n\
1376 If LENGTH is provided, only fetch string to the length provided.\n\
1377 \n\
1378 Arguments: <gdb:value> [#:encoding encoding] [#:length length]" },
1379
1380 { "value-lazy?", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_lazy_p),
1381 "\
1382 Return #t if the value is lazy (not fetched yet from the inferior).\n\
1383 A lazy value is fetched when needed, or when the value-fetch-lazy! function\n\
1384 is called." },
1385
1386 { "make-lazy-value", 2, 0, 0, as_a_scm_t_subr (gdbscm_make_lazy_value),
1387 "\
1388 Create a <gdb:value> that will be lazily fetched from the target.\n\
1389 \n\
1390 Arguments: <gdb:type> address" },
1391
1392 { "value-fetch-lazy!", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_fetch_lazy_x),
1393 "\
1394 Fetch the value from the inferior, if it was lazy.\n\
1395 The result is \"unspecified\"." },
1396
1397 { "value-print", 1, 0, 0, as_a_scm_t_subr (gdbscm_value_print),
1398 "\
1399 Return the string representation (print form) of the value." },
1400
1401 { "parse-and-eval", 1, 0, 0, as_a_scm_t_subr (gdbscm_parse_and_eval),
1402 "\
1403 Evaluates string in gdb and returns the result as a <gdb:value> object." },
1404
1405 { "history-ref", 1, 0, 0, as_a_scm_t_subr (gdbscm_history_ref),
1406 "\
1407 Return the specified value from GDB's value history." },
1408
1409 { "history-append!", 1, 0, 0, as_a_scm_t_subr (gdbscm_history_append_x),
1410 "\
1411 Append the specified value onto GDB's value history." },
1412
1413 END_FUNCTIONS
1414 };
1415
1416 void
1417 gdbscm_initialize_values (void)
1418 {
1419 value_smob_tag = gdbscm_make_smob_type (value_smob_name,
1420 sizeof (value_smob));
1421 scm_set_smob_free (value_smob_tag, vlscm_free_value_smob);
1422 scm_set_smob_print (value_smob_tag, vlscm_print_value_smob);
1423 scm_set_smob_equalp (value_smob_tag, vlscm_equal_p_value_smob);
1424
1425 gdbscm_define_functions (value_functions, 1);
1426
1427 type_keyword = scm_from_latin1_keyword ("type");
1428 encoding_keyword = scm_from_latin1_keyword ("encoding");
1429 errors_keyword = scm_from_latin1_keyword ("errors");
1430 length_keyword = scm_from_latin1_keyword ("length");
1431
1432 error_symbol = scm_from_latin1_symbol ("error");
1433 escape_symbol = scm_from_latin1_symbol ("escape");
1434 substitute_symbol = scm_from_latin1_symbol ("substitute");
1435 }
This page took 0.086 seconds and 4 git commands to generate.