GDB (xrefs)
Loading...
Searching...
No Matches
scm-type.c
Go to the documentation of this file.
1/* Scheme interface to types.
2
3 Copyright (C) 2008-2023 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 "top.h"
25#include "arch-utils.h"
26#include "value.h"
27#include "gdbtypes.h"
28#include "objfiles.h"
29#include "language.h"
30#include "bcache.h"
31#include "dwarf2/loc.h"
32#include "typeprint.h"
33#include "guile-internal.h"
34
35/* The <gdb:type> smob.
36 The type is chained with all types associated with its objfile, if any.
37 This lets us copy the underlying struct type when the objfile is
38 deleted. */
39
41{
42 /* This always appears first.
43 eqable_gdb_smob is used so that types are eq?-able.
44 Also, a type object can be associated with an objfile. eqable_gdb_smob
45 lets us track the lifetime of all types associated with an objfile.
46 When an objfile is deleted we need to invalidate the type object. */
48
49 /* The GDB type structure this smob is wrapping. */
50 struct type *type;
51};
52
53/* A field smob. */
54
56{
57 /* This always appears first. */
59
60 /* Backlink to the containing <gdb:type> object. */
62
63 /* The field number in TYPE_SCM. */
65};
66
67static const char type_smob_name[] = "gdb:type";
68static const char field_smob_name[] = "gdb:field";
69
70static const char not_composite_error[] =
71 N_("type is not a structure, union, or enum type");
72
73/* The tag Guile knows the type smob by. */
74static scm_t_bits type_smob_tag;
75
76/* The tag Guile knows the field smob by. */
77static scm_t_bits field_smob_tag;
78
79/* The "next" procedure for field iterators. */
81
82/* Keywords used in argument passing. */
83static SCM block_keyword;
84
85static int tyscm_copy_type_recursive (void **slot, void *info);
86
87/* Called when an objfile is about to be deleted.
88 Make a copy of all types associated with OBJFILE. */
89
91{
92 void operator() (htab_t htab)
93 {
95 return;
96
97 gdb_assert (htab != nullptr);
98 htab_up copied_types = create_copied_types_hash ();
99 htab_traverse_noresize (htab, tyscm_copy_type_recursive, copied_types.get ());
100 htab_delete (htab);
101 }
102};
103
104static const registry<objfile>::key<htab, tyscm_deleter>
106
107/* Hash table to uniquify global (non-objfile-owned) types. */
108static htab_t global_types_map;
109
110static struct type *tyscm_get_composite (struct type *type);
111
112/* Return the type field of T_SMOB.
113 This exists so that we don't have to export the struct's contents. */
114
115struct type *
117{
118 return t_smob->type;
119}
120
121/* Return the name of TYPE in expanded form. If there's an error
122 computing the name, throws the gdb exception with scm_throw. */
123
124static std::string
126{
127 SCM excp;
128 try
129 {
130 string_file stb;
131
132 current_language->print_type (type, "", &stb, -1, 0,
134 return stb.release ();
135 }
136 catch (const gdb_exception_forced_quit &except)
137 {
138 quit_force (NULL, 0);
139 }
140 catch (const gdb_exception &except)
141 {
142 excp = gdbscm_scm_from_gdb_exception (unpack (except));
143 }
144
145 gdbscm_throw (excp);
146}
147
148/* Administrivia for type smobs. */
149
150/* Helper function to hash a type_smob. */
151
152static hashval_t
153tyscm_hash_type_smob (const void *p)
154{
155 const type_smob *t_smob = (const type_smob *) p;
156
157 return htab_hash_pointer (t_smob->type);
158}
159
160/* Helper function to compute equality of type_smobs. */
161
162static int
163tyscm_eq_type_smob (const void *ap, const void *bp)
164{
165 const type_smob *a = (const type_smob *) ap;
166 const type_smob *b = (const type_smob *) bp;
167
168 return (a->type == b->type
169 && a->type != NULL);
170}
171
172/* Return the struct type pointer -> SCM mapping table.
173 If type is owned by an objfile, the mapping table is created if necessary.
174 Otherwise, type is not owned by an objfile, and we use
175 global_types_map. */
176
177static htab_t
179{
180 struct objfile *objfile = type->objfile_owner ();
181 htab_t htab;
182
183 if (objfile == NULL)
184 return global_types_map;
185
187 if (htab == NULL)
188 {
192 }
193
194 return htab;
195}
196
197/* The smob "free" function for <gdb:type>. */
198
199static size_t
201{
202 type_smob *t_smob = (type_smob *) SCM_SMOB_DATA (self);
203
204 if (t_smob->type != NULL)
205 {
206 htab_t htab = tyscm_type_map (t_smob->type);
207
209 }
210
211 /* Not necessary, done to catch bugs. */
212 t_smob->type = NULL;
213
214 return 0;
215}
216
217/* The smob "print" function for <gdb:type>. */
218
219static int
220tyscm_print_type_smob (SCM self, SCM port, scm_print_state *pstate)
221{
222 type_smob *t_smob = (type_smob *) SCM_SMOB_DATA (self);
223 std::string name = tyscm_type_name (t_smob->type);
224
225 /* pstate->writingp = zero if invoked by display/~A, and nonzero if
226 invoked by write/~S. What to do here may need to evolve.
227 IWBN if we could pass an argument to format that would we could use
228 instead of writingp. */
229 if (pstate->writingp)
230 gdbscm_printf (port, "#<%s ", type_smob_name);
231
232 scm_puts (name.c_str (), port);
233
234 if (pstate->writingp)
235 scm_puts (">", port);
236
237 scm_remember_upto_here_1 (self);
238
239 /* Non-zero means success. */
240 return 1;
241}
242
243/* The smob "equal?" function for <gdb:type>. */
244
245static SCM
246tyscm_equal_p_type_smob (SCM type1_scm, SCM type2_scm)
247{
248 type_smob *type1_smob, *type2_smob;
249 struct type *type1, *type2;
250 bool result = false;
251
252 SCM_ASSERT_TYPE (tyscm_is_type (type1_scm), type1_scm, SCM_ARG1, FUNC_NAME,
254 SCM_ASSERT_TYPE (tyscm_is_type (type2_scm), type2_scm, SCM_ARG2, FUNC_NAME,
256 type1_smob = (type_smob *) SCM_SMOB_DATA (type1_scm);
257 type2_smob = (type_smob *) SCM_SMOB_DATA (type2_scm);
258 type1 = type1_smob->type;
259 type2 = type2_smob->type;
260
262 try
263 {
264 result = types_deeply_equal (type1, type2);
265 }
266 catch (const gdb_exception &except)
267 {
268 exc = unpack (except);
269 }
270
272 return scm_from_bool (result);
273}
274
275/* Low level routine to create a <gdb:type> object. */
276
277static SCM
279{
280 type_smob *t_smob = (type_smob *)
281 scm_gc_malloc (sizeof (type_smob), type_smob_name);
282 SCM t_scm;
283
284 /* This must be filled in by the caller. */
285 t_smob->type = NULL;
286
287 t_scm = scm_new_smob (type_smob_tag, (scm_t_bits) t_smob);
288 gdbscm_init_eqable_gsmob (&t_smob->base, t_scm);
289
290 return t_scm;
291}
292
293/* Return non-zero if SCM is a <gdb:type> object. */
294
295int
297{
298 return SCM_SMOB_PREDICATE (type_smob_tag, self);
299}
300
301/* (type? object) -> boolean */
302
303static SCM
305{
306 return scm_from_bool (tyscm_is_type (self));
307}
308
309/* Return the existing object that encapsulates TYPE, or create a new
310 <gdb:type> object. */
311
312SCM
314{
315 htab_t htab;
316 eqable_gdb_smob **slot;
317 type_smob *t_smob, t_smob_for_lookup;
318 SCM t_scm;
319
320 /* If we've already created a gsmob for this type, return it.
321 This makes types eq?-able. */
322 htab = tyscm_type_map (type);
323 t_smob_for_lookup.type = type;
324 slot = gdbscm_find_eqable_gsmob_ptr_slot (htab, &t_smob_for_lookup.base);
325 if (*slot != NULL)
326 return (*slot)->containing_scm;
327
328 t_scm = tyscm_make_type_smob ();
329 t_smob = (type_smob *) SCM_SMOB_DATA (t_scm);
330 t_smob->type = type;
332
333 return t_scm;
334}
335
336/* Returns the <gdb:type> object in SELF.
337 Throws an exception if SELF is not a <gdb:type> object. */
338
339static SCM
340tyscm_get_type_arg_unsafe (SCM self, int arg_pos, const char *func_name)
341{
342 SCM_ASSERT_TYPE (tyscm_is_type (self), self, arg_pos, func_name,
344
345 return self;
346}
347
348/* Returns a pointer to the type smob of SELF.
349 Throws an exception if SELF is not a <gdb:type> object. */
350
351type_smob *
352tyscm_get_type_smob_arg_unsafe (SCM self, int arg_pos, const char *func_name)
353{
354 SCM t_scm = tyscm_get_type_arg_unsafe (self, arg_pos, func_name);
355 type_smob *t_smob = (type_smob *) SCM_SMOB_DATA (t_scm);
356
357 return t_smob;
358}
359
360/* Return the type field of T_SCM, an object of type <gdb:type>.
361 This exists so that we don't have to export the struct's contents. */
362
363struct type *
365{
366 type_smob *t_smob;
367
368 gdb_assert (tyscm_is_type (t_scm));
369 t_smob = (type_smob *) SCM_SMOB_DATA (t_scm);
370 return t_smob->type;
371}
372
373/* Helper function to make a deep copy of the type. */
374
375static int
376tyscm_copy_type_recursive (void **slot, void *info)
377{
378 type_smob *t_smob = (type_smob *) *slot;
379 htab_t copied_types = (htab_t) info;
380 htab_t htab;
381 eqable_gdb_smob **new_slot;
382 type_smob t_smob_for_lookup;
383
384 htab_empty (copied_types);
385 t_smob->type = copy_type_recursive (t_smob->type, copied_types);
386
387 /* The eq?-hashtab that the type lived in is going away.
388 Add the type to its new eq?-hashtab: Otherwise if/when the type is later
389 garbage collected we'll assert-fail if the type isn't in the hashtab.
390 PR 16612.
391
392 Types now live in "arch space", and things like "char" that came from
393 the objfile *could* be considered eq? with the arch "char" type.
394 However, they weren't before the objfile got deleted, so making them
395 eq? now is debatable. */
396 htab = tyscm_type_map (t_smob->type);
397 t_smob_for_lookup.type = t_smob->type;
398 new_slot = gdbscm_find_eqable_gsmob_ptr_slot (htab, &t_smob_for_lookup.base);
399 gdb_assert (*new_slot == NULL);
400 gdbscm_fill_eqable_gsmob_ptr_slot (new_slot, &t_smob->base);
401
402 return 1;
403}
404
405
406/* Administrivia for field smobs. */
407
408/* The smob "print" function for <gdb:field>. */
409
410static int
411tyscm_print_field_smob (SCM self, SCM port, scm_print_state *pstate)
412{
413 field_smob *f_smob = (field_smob *) SCM_SMOB_DATA (self);
414
415 gdbscm_printf (port, "#<%s ", field_smob_name);
416 scm_write (f_smob->type_scm, port);
417 gdbscm_printf (port, " %d", f_smob->field_num);
418 scm_puts (">", port);
419
420 scm_remember_upto_here_1 (self);
421
422 /* Non-zero means success. */
423 return 1;
424}
425
426/* Low level routine to create a <gdb:field> object for field FIELD_NUM
427 of type TYPE_SCM. */
428
429static SCM
430tyscm_make_field_smob (SCM type_scm, int field_num)
431{
432 field_smob *f_smob = (field_smob *)
433 scm_gc_malloc (sizeof (field_smob), field_smob_name);
434 SCM result;
435
436 f_smob->type_scm = type_scm;
437 f_smob->field_num = field_num;
438 result = scm_new_smob (field_smob_tag, (scm_t_bits) f_smob);
439 gdbscm_init_gsmob (&f_smob->base);
440
441 return result;
442}
443
444/* Return non-zero if SCM is a <gdb:field> object. */
445
446static int
448{
449 return SCM_SMOB_PREDICATE (field_smob_tag, self);
450}
451
452/* (field? object) -> boolean */
453
454static SCM
456{
457 return scm_from_bool (tyscm_is_field (self));
458}
459
460/* Create a new <gdb:field> object that encapsulates field FIELD_NUM
461 in type TYPE_SCM. */
462
463SCM
464tyscm_scm_from_field (SCM type_scm, int field_num)
465{
466 return tyscm_make_field_smob (type_scm, field_num);
467}
468
469/* Returns the <gdb:field> object in SELF.
470 Throws an exception if SELF is not a <gdb:field> object. */
471
472static SCM
473tyscm_get_field_arg_unsafe (SCM self, int arg_pos, const char *func_name)
474{
475 SCM_ASSERT_TYPE (tyscm_is_field (self), self, arg_pos, func_name,
477
478 return self;
479}
480
481/* Returns a pointer to the field smob of SELF.
482 Throws an exception if SELF is not a <gdb:field> object. */
483
484static field_smob *
485tyscm_get_field_smob_arg_unsafe (SCM self, int arg_pos, const char *func_name)
486{
487 SCM f_scm = tyscm_get_field_arg_unsafe (self, arg_pos, func_name);
488 field_smob *f_smob = (field_smob *) SCM_SMOB_DATA (f_scm);
489
490 return f_smob;
491}
492
493/* Returns a pointer to the type struct in F_SMOB
494 (the type the field is in). */
495
496static struct type *
498{
499 type_smob *t_smob;
500
501 gdb_assert (tyscm_is_type (f_smob->type_scm));
502 t_smob = (type_smob *) SCM_SMOB_DATA (f_smob->type_scm);
503
504 return t_smob->type;
505}
506
507/* Returns a pointer to the field struct of F_SMOB. */
508
509static struct field *
511{
512 struct type *type = tyscm_field_smob_containing_type (f_smob);
513
514 /* This should be non-NULL by construction. */
515 gdb_assert (type->fields () != NULL);
516
517 return &type->field (f_smob->field_num);
518}
519
520/* Type smob accessors. */
521
522/* (type-code <gdb:type>) -> integer
523 Return the code for this type. */
524
525static SCM
527{
528 type_smob *t_smob
529 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
530 struct type *type = t_smob->type;
531
532 return scm_from_int (type->code ());
533}
534
535/* (type-fields <gdb:type>) -> list
536 Return a list of all fields. Each element is a <gdb:field> object.
537 This also supports arrays, we return a field list of one element,
538 the range type. */
539
540static SCM
542{
543 type_smob *t_smob
544 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
545 struct type *type = t_smob->type;
546 struct type *containing_type;
547 SCM containing_type_scm, result;
548 int i;
549
550 containing_type = tyscm_get_composite (type);
551 if (containing_type == NULL)
552 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
554
555 /* If SELF is a typedef or reference, we want the underlying type,
556 which is what tyscm_get_composite returns. */
557 if (containing_type == type)
558 containing_type_scm = self;
559 else
560 containing_type_scm = tyscm_scm_from_type (containing_type);
561
562 result = SCM_EOL;
563 for (i = 0; i < containing_type->num_fields (); ++i)
564 result = scm_cons (tyscm_make_field_smob (containing_type_scm, i), result);
565
566 return scm_reverse_x (result, SCM_EOL);
567}
568
569/* (type-tag <gdb:type>) -> string
570 Return the type's tag, or #f. */
571
572static SCM
574{
575 type_smob *t_smob
576 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
577 struct type *type = t_smob->type;
578 const char *tagname = nullptr;
579
580 if (type->code () == TYPE_CODE_STRUCT
581 || type->code () == TYPE_CODE_UNION
582 || type->code () == TYPE_CODE_ENUM)
583 tagname = type->name ();
584
585 if (tagname == nullptr)
586 return SCM_BOOL_F;
587 return gdbscm_scm_from_c_string (tagname);
588}
589
590/* (type-name <gdb:type>) -> string
591 Return the type's name, or #f. */
592
593static SCM
595{
596 type_smob *t_smob
597 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
598 struct type *type = t_smob->type;
599
600 if (!type->name ())
601 return SCM_BOOL_F;
603}
604
605/* (type-print-name <gdb:type>) -> string
606 Return the print name of type.
607 TODO: template support elided for now. */
608
609static SCM
611{
612 type_smob *t_smob
613 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
614 struct type *type = t_smob->type;
615 std::string thetype = tyscm_type_name (type);
616 SCM result = gdbscm_scm_from_c_string (thetype.c_str ());
617
618 return result;
619}
620
621/* (type-sizeof <gdb:type>) -> integer
622 Return the size of the type represented by SELF, in bytes. */
623
624static SCM
626{
627 type_smob *t_smob
628 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
629 struct type *type = t_smob->type;
630
631 try
632 {
634 }
635 catch (const gdb_exception &except)
636 {
637 }
638
639 /* Ignore exceptions. */
640
641 return scm_from_long (type->length ());
642}
643
644/* (type-strip-typedefs <gdb:type>) -> <gdb:type>
645 Return the type, stripped of typedefs. */
646
647static SCM
649{
650 type_smob *t_smob
651 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
652 struct type *type = t_smob->type;
653
655 try
656 {
658 }
659 catch (const gdb_exception &except)
660 {
661 exc = unpack (except);
662 }
663
665 return tyscm_scm_from_type (type);
666}
667
668/* Strip typedefs and pointers/reference from a type. Then check that
669 it is a struct, union, or enum type. If not, return NULL. */
670
671static struct type *
673{
674
675 for (;;)
676 {
678 try
679 {
681 }
682 catch (const gdb_exception &except)
683 {
684 exc = unpack (except);
685 }
686
688 if (type->code () != TYPE_CODE_PTR
689 && type->code () != TYPE_CODE_REF)
690 break;
691 type = type->target_type ();
692 }
693
694 /* If this is not a struct, union, or enum type, raise TypeError
695 exception. */
696 if (type->code () != TYPE_CODE_STRUCT
697 && type->code () != TYPE_CODE_UNION
698 && type->code () != TYPE_CODE_ENUM)
699 return NULL;
700
701 return type;
702}
703
704/* Helper for tyscm_array and tyscm_vector. */
705
706static SCM
707tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector,
708 const char *func_name)
709{
710 type_smob *t_smob
711 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, func_name);
712 struct type *type = t_smob->type;
713 long n1, n2 = 0;
714 struct type *array = NULL;
715
716 gdbscm_parse_function_args (func_name, SCM_ARG2, NULL, "l|l",
717 n1_scm, &n1, n2_scm, &n2);
718
719 if (SCM_UNBNDP (n2_scm))
720 {
721 n2 = n1;
722 n1 = 0;
723 }
724
725 if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1. */
726 {
727 gdbscm_out_of_range_error (func_name, SCM_ARG3,
728 scm_cons (scm_from_long (n1),
729 scm_from_long (n2)),
730 _("Array length must not be negative"));
731 }
732
734 try
735 {
736 array = lookup_array_range_type (type, n1, n2);
737 if (is_vector)
738 make_vector_type (array);
739 }
740 catch (const gdb_exception &except)
741 {
742 exc = unpack (except);
743 }
744
746 return tyscm_scm_from_type (array);
747}
748
749/* (type-array <gdb:type> [low-bound] high-bound) -> <gdb:type>
750 The array has indices [low-bound,high-bound].
751 If low-bound is not provided zero is used.
752 Return an array type.
753
754 IWBN if the one argument version specified a size, not the high bound.
755 It's too easy to pass one argument thinking it is the size of the array.
756 The current semantics are for compatibility with the Python version.
757 Later we can add #:size. */
758
759static SCM
760gdbscm_type_array (SCM self, SCM n1, SCM n2)
761{
762 return tyscm_array_1 (self, n1, n2, 0, FUNC_NAME);
763}
764
765/* (type-vector <gdb:type> [low-bound] high-bound) -> <gdb:type>
766 The array has indices [low-bound,high-bound].
767 If low-bound is not provided zero is used.
768 Return a vector type.
769
770 IWBN if the one argument version specified a size, not the high bound.
771 It's too easy to pass one argument thinking it is the size of the array.
772 The current semantics are for compatibility with the Python version.
773 Later we can add #:size. */
774
775static SCM
776gdbscm_type_vector (SCM self, SCM n1, SCM n2)
777{
778 return tyscm_array_1 (self, n1, n2, 1, FUNC_NAME);
779}
780
781/* (type-pointer <gdb:type>) -> <gdb:type>
782 Return a <gdb:type> object which represents a pointer to SELF. */
783
784static SCM
786{
787 type_smob *t_smob
788 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
789 struct type *type = t_smob->type;
790
792 try
793 {
795 }
796 catch (const gdb_exception &except)
797 {
798 exc = unpack (except);
799 }
800
802 return tyscm_scm_from_type (type);
803}
804
805/* (type-range <gdb:type>) -> (low high)
806 Return the range of a type represented by SELF. The return type is
807 a list. The first element is the low bound, and the second element
808 is the high bound. */
809
810static SCM
812{
813 type_smob *t_smob
814 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
815 struct type *type = t_smob->type;
816 SCM low_scm, high_scm;
817 /* Initialize these to appease GCC warnings. */
818 LONGEST low = 0, high = 0;
819
820 SCM_ASSERT_TYPE (type->code () == TYPE_CODE_ARRAY
821 || type->code () == TYPE_CODE_STRING
822 || type->code () == TYPE_CODE_RANGE,
823 self, SCM_ARG1, FUNC_NAME, _("ranged type"));
824
825 switch (type->code ())
826 {
827 case TYPE_CODE_ARRAY:
828 case TYPE_CODE_STRING:
829 case TYPE_CODE_RANGE:
830 if (type->bounds ()->low.is_constant ())
831 low = type->bounds ()->low.const_val ();
832 else
833 low = 0;
834
835 if (type->bounds ()->high.is_constant ())
836 high = type->bounds ()->high.const_val ();
837 else
838 high = 0;
839 break;
840 }
841
842 low_scm = gdbscm_scm_from_longest (low);
843 high_scm = gdbscm_scm_from_longest (high);
844
845 return scm_list_2 (low_scm, high_scm);
846}
847
848/* (type-reference <gdb:type>) -> <gdb:type>
849 Return a <gdb:type> object which represents a reference to SELF. */
850
851static SCM
853{
854 type_smob *t_smob
855 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
856 struct type *type = t_smob->type;
857
859 try
860 {
862 }
863 catch (const gdb_exception &except)
864 {
865 exc = unpack (except);
866 }
867
869 return tyscm_scm_from_type (type);
870}
871
872/* (type-target <gdb:type>) -> <gdb:type>
873 Return a <gdb:type> object which represents the target type of SELF. */
874
875static SCM
877{
878 type_smob *t_smob
879 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
880 struct type *type = t_smob->type;
881
882 SCM_ASSERT (type->target_type (), self, SCM_ARG1, FUNC_NAME);
883
885}
886
887/* (type-const <gdb:type>) -> <gdb:type>
888 Return a const-qualified type variant. */
889
890static SCM
892{
893 type_smob *t_smob
894 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
895 struct type *type = t_smob->type;
896
898 try
899 {
900 type = make_cv_type (1, 0, type, NULL);
901 }
902 catch (const gdb_exception &except)
903 {
904 exc = unpack (except);
905 }
906
908 return tyscm_scm_from_type (type);
909}
910
911/* (type-volatile <gdb:type>) -> <gdb:type>
912 Return a volatile-qualified type variant. */
913
914static SCM
916{
917 type_smob *t_smob
918 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
919 struct type *type = t_smob->type;
920
922 try
923 {
924 type = make_cv_type (0, 1, type, NULL);
925 }
926 catch (const gdb_exception &except)
927 {
928 exc = unpack (except);
929 }
930
932 return tyscm_scm_from_type (type);
933}
934
935/* (type-unqualified <gdb:type>) -> <gdb:type>
936 Return an unqualified type variant. */
937
938static SCM
940{
941 type_smob *t_smob
942 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
943 struct type *type = t_smob->type;
944
946 try
947 {
948 type = make_cv_type (0, 0, type, NULL);
949 }
950 catch (const gdb_exception &except)
951 {
952 exc = unpack (except);
953 }
954
956 return tyscm_scm_from_type (type);
957}
958
959/* Field related accessors of types. */
960
961/* (type-num-fields <gdb:type>) -> integer
962 Return number of fields. */
963
964static SCM
966{
967 type_smob *t_smob
968 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
969 struct type *type = t_smob->type;
970
972 if (type == NULL)
973 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
975
976 return scm_from_long (type->num_fields ());
977}
978
979/* (type-field <gdb:type> string) -> <gdb:field>
980 Return the <gdb:field> object for the field named by the argument. */
981
982static SCM
983gdbscm_type_field (SCM self, SCM field_scm)
984{
985 type_smob *t_smob
986 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
987 struct type *type = t_smob->type;
988
989 SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2, FUNC_NAME,
990 _("string"));
991
992 /* We want just fields of this type, not of base types, so instead of
993 using lookup_struct_elt_type, portions of that function are
994 copied here. */
995
997 if (type == NULL)
998 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
1000
1001 {
1002 gdb::unique_xmalloc_ptr<char> field = gdbscm_scm_to_c_string (field_scm);
1003
1004 for (int i = 0; i < type->num_fields (); i++)
1005 {
1006 const char *t_field_name = type->field (i).name ();
1007
1008 if (t_field_name && (strcmp_iw (t_field_name, field.get ()) == 0))
1009 {
1010 field.reset (nullptr);
1011 return tyscm_make_field_smob (self, i);
1012 }
1013 }
1014 }
1015
1016 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, field_scm,
1017 _("Unknown field"));
1018}
1019
1020/* (type-has-field? <gdb:type> string) -> boolean
1021 Return boolean indicating if type SELF has FIELD_SCM (a string). */
1022
1023static SCM
1024gdbscm_type_has_field_p (SCM self, SCM field_scm)
1025{
1026 type_smob *t_smob
1027 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1028 struct type *type = t_smob->type;
1029
1030 SCM_ASSERT_TYPE (scm_is_string (field_scm), field_scm, SCM_ARG2, FUNC_NAME,
1031 _("string"));
1032
1033 /* We want just fields of this type, not of base types, so instead of
1034 using lookup_struct_elt_type, portions of that function are
1035 copied here. */
1036
1038 if (type == NULL)
1039 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
1041
1042 {
1043 gdb::unique_xmalloc_ptr<char> field
1044 = gdbscm_scm_to_c_string (field_scm);
1045
1046 for (int i = 0; i < type->num_fields (); i++)
1047 {
1048 const char *t_field_name = type->field (i).name ();
1049
1050 if (t_field_name && (strcmp_iw (t_field_name, field.get ()) == 0))
1051 return SCM_BOOL_T;
1052 }
1053 }
1054
1055 return SCM_BOOL_F;
1056}
1057
1058/* (make-field-iterator <gdb:type>) -> <gdb:iterator>
1059 Make a field iterator object. */
1060
1061static SCM
1063{
1064 type_smob *t_smob
1065 = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1066 struct type *type = t_smob->type;
1067 struct type *containing_type;
1068 SCM containing_type_scm;
1069
1070 containing_type = tyscm_get_composite (type);
1071 if (containing_type == NULL)
1072 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
1074
1075 /* If SELF is a typedef or reference, we want the underlying type,
1076 which is what tyscm_get_composite returns. */
1077 if (containing_type == type)
1078 containing_type_scm = self;
1079 else
1080 containing_type_scm = tyscm_scm_from_type (containing_type);
1081
1082 return gdbscm_make_iterator (containing_type_scm, scm_from_int (0),
1084}
1085
1086/* (type-next-field! <gdb:iterator>) -> <gdb:field>
1087 Return the next field in the iteration through the list of fields of the
1088 type, or (end-of-iteration).
1089 SELF is a <gdb:iterator> object created by gdbscm_make_field_iterator.
1090 This is the next! <gdb:iterator> function, not exported to the user. */
1091
1092static SCM
1094{
1095 iterator_smob *i_smob;
1096 type_smob *t_smob;
1097 struct type *type;
1098 SCM it_scm, result, progress, object;
1099 int field;
1100
1101 it_scm = itscm_get_iterator_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1102 i_smob = (iterator_smob *) SCM_SMOB_DATA (it_scm);
1103 object = itscm_iterator_smob_object (i_smob);
1104 progress = itscm_iterator_smob_progress (i_smob);
1105
1106 SCM_ASSERT_TYPE (tyscm_is_type (object), object,
1107 SCM_ARG1, FUNC_NAME, type_smob_name);
1108 t_smob = (type_smob *) SCM_SMOB_DATA (object);
1109 type = t_smob->type;
1110
1111 SCM_ASSERT_TYPE (scm_is_signed_integer (progress,
1112 0, type->num_fields ()),
1113 progress, SCM_ARG1, FUNC_NAME, _("integer"));
1114 field = scm_to_int (progress);
1115
1116 if (field < type->num_fields ())
1117 {
1118 result = tyscm_make_field_smob (object, field);
1119 itscm_set_iterator_smob_progress_x (i_smob, scm_from_int (field + 1));
1120 return result;
1121 }
1122
1123 return gdbscm_end_of_iteration ();
1124}
1125
1126/* Field smob accessors. */
1127
1128/* (field-name <gdb:field>) -> string
1129 Return the name of this field or #f if there isn't one. */
1130
1131static SCM
1133{
1134 field_smob *f_smob
1135 = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1136 struct field *field = tyscm_field_smob_to_field (f_smob);
1137
1138 if (field->name () != nullptr)
1139 return gdbscm_scm_from_c_string (field->name ());
1140 return SCM_BOOL_F;
1141}
1142
1143/* (field-type <gdb:field>) -> <gdb:type>
1144 Return the <gdb:type> object of the field or #f if there isn't one. */
1145
1146static SCM
1148{
1149 field_smob *f_smob
1150 = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1151 struct field *field = tyscm_field_smob_to_field (f_smob);
1152
1153 /* A field can have a NULL type in some situations. */
1154 if (field->type ())
1155 return tyscm_scm_from_type (field->type ());
1156 return SCM_BOOL_F;
1157}
1158
1159/* (field-enumval <gdb:field>) -> integer
1160 For enum values, return its value as an integer. */
1161
1162static SCM
1164{
1165 field_smob *f_smob
1166 = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1167 struct field *field = tyscm_field_smob_to_field (f_smob);
1168 struct type *type = tyscm_field_smob_containing_type (f_smob);
1169
1170 SCM_ASSERT_TYPE (type->code () == TYPE_CODE_ENUM,
1171 self, SCM_ARG1, FUNC_NAME, _("enum type"));
1172
1173 return scm_from_long (field->loc_enumval ());
1174}
1175
1176/* (field-bitpos <gdb:field>) -> integer
1177 For bitfields, return its offset in bits. */
1178
1179static SCM
1181{
1182 field_smob *f_smob
1183 = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1184 struct field *field = tyscm_field_smob_to_field (f_smob);
1185 struct type *type = tyscm_field_smob_containing_type (f_smob);
1186
1187 SCM_ASSERT_TYPE (type->code () != TYPE_CODE_ENUM,
1188 self, SCM_ARG1, FUNC_NAME, _("non-enum type"));
1189
1190 return scm_from_long (field->loc_bitpos ());
1191}
1192
1193/* (field-bitsize <gdb:field>) -> integer
1194 Return the size of the field in bits. */
1195
1196static SCM
1198{
1199 field_smob *f_smob
1200 = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1201 struct field *field = tyscm_field_smob_to_field (f_smob);
1202
1203 return scm_from_long (field->loc_bitpos ());
1204}
1205
1206/* (field-artificial? <gdb:field>) -> boolean
1207 Return #t if field is artificial. */
1208
1209static SCM
1211{
1212 field_smob *f_smob
1213 = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1214 struct field *field = tyscm_field_smob_to_field (f_smob);
1215
1216 return scm_from_bool (field->is_artificial ());
1217}
1218
1219/* (field-baseclass? <gdb:field>) -> boolean
1220 Return #t if field is a baseclass. */
1221
1222static SCM
1224{
1225 field_smob *f_smob
1226 = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1227 struct type *type = tyscm_field_smob_containing_type (f_smob);
1228
1229 if (type->code () == TYPE_CODE_STRUCT)
1230 return scm_from_bool (f_smob->field_num < TYPE_N_BASECLASSES (type));
1231 return SCM_BOOL_F;
1232}
1233
1234/* Return the type named TYPE_NAME in BLOCK.
1235 Returns NULL if not found.
1236 This routine does not throw an error. */
1237
1238static struct type *
1239tyscm_lookup_typename (const char *type_name, const struct block *block)
1240{
1241 struct type *type = NULL;
1242
1243 try
1244 {
1245 if (startswith (type_name, "struct "))
1246 type = lookup_struct (type_name + 7, NULL);
1247 else if (startswith (type_name, "union "))
1248 type = lookup_union (type_name + 6, NULL);
1249 else if (startswith (type_name, "enum "))
1250 type = lookup_enum (type_name + 5, NULL);
1251 else
1253 type_name, block, 0);
1254 }
1255 catch (const gdb_exception &except)
1256 {
1257 return NULL;
1258 }
1259
1260 return type;
1261}
1262
1263/* (lookup-type name [#:block <gdb:block>]) -> <gdb:type>
1264 TODO: legacy template support left out until needed. */
1265
1266static SCM
1267gdbscm_lookup_type (SCM name_scm, SCM rest)
1268{
1269 SCM keywords[] = { block_keyword, SCM_BOOL_F };
1270 char *name;
1271 SCM block_scm = SCM_BOOL_F;
1272 int block_arg_pos = -1;
1273 const struct block *block = NULL;
1274 struct type *type;
1275
1276 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#O",
1277 name_scm, &name,
1278 rest, &block_arg_pos, &block_scm);
1279
1280 if (block_arg_pos != -1)
1281 {
1282 SCM exception;
1283
1284 block = bkscm_scm_to_block (block_scm, block_arg_pos, FUNC_NAME,
1285 &exception);
1286 if (block == NULL)
1287 {
1288 xfree (name);
1289 gdbscm_throw (exception);
1290 }
1291 }
1293 xfree (name);
1294
1295 if (type != NULL)
1296 return tyscm_scm_from_type (type);
1297 return SCM_BOOL_F;
1298}
1299
1300/* Initialize the Scheme type code. */
1301
1302
1304{
1305 /* This is kept for backward compatibility. */
1306 { "TYPE_CODE_BITSTRING", -1 },
1307
1308#define OP(SYM) { #SYM, SYM },
1309#include "type-codes.def"
1310#undef OP
1311
1313};
1314
1316{
1317 { "type?", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_p),
1318 "\
1319Return #t if the object is a <gdb:type> object." },
1320
1321 { "lookup-type", 1, 0, 1, as_a_scm_t_subr (gdbscm_lookup_type),
1322 "\
1323Return the <gdb:type> object representing string or #f if not found.\n\
1324If block is given then the type is looked for in that block.\n\
1325\n\
1326 Arguments: string [#:block <gdb:block>]" },
1327
1328 { "type-code", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_code),
1329 "\
1330Return the code of the type" },
1331
1332 { "type-tag", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_tag),
1333 "\
1334Return the tag name of the type, or #f if there isn't one." },
1335
1336 { "type-name", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_name),
1337 "\
1338Return the name of the type as a string, or #f if there isn't one." },
1339
1340 { "type-print-name", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_print_name),
1341 "\
1342Return the print name of the type as a string." },
1343
1344 { "type-sizeof", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_sizeof),
1345 "\
1346Return the size of the type, in bytes." },
1347
1348 { "type-strip-typedefs", 1, 0, 0,
1350 "\
1351Return a type formed by stripping the type of all typedefs." },
1352
1353 { "type-array", 2, 1, 0, as_a_scm_t_subr (gdbscm_type_array),
1354 "\
1355Return a type representing an array of objects of the type.\n\
1356\n\
1357 Arguments: <gdb:type> [low-bound] high-bound\n\
1358 If low-bound is not provided zero is used.\n\
1359 N.B. If only the high-bound parameter is specified, it is not\n\
1360 the array size.\n\
1361 Valid bounds for array indices are [low-bound,high-bound]." },
1362
1363 { "type-vector", 2, 1, 0, as_a_scm_t_subr (gdbscm_type_vector),
1364 "\
1365Return a type representing a vector of objects of the type.\n\
1366Vectors differ from arrays in that if the current language has C-style\n\
1367arrays, vectors don't decay to a pointer to the first element.\n\
1368They are first class values.\n\
1369\n\
1370 Arguments: <gdb:type> [low-bound] high-bound\n\
1371 If low-bound is not provided zero is used.\n\
1372 N.B. If only the high-bound parameter is specified, it is not\n\
1373 the array size.\n\
1374 Valid bounds for array indices are [low-bound,high-bound]." },
1375
1376 { "type-pointer", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_pointer),
1377 "\
1378Return a type of pointer to the type." },
1379
1380 { "type-range", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_range),
1381 "\
1382Return (low high) representing the range for the type." },
1383
1384 { "type-reference", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_reference),
1385 "\
1386Return a type of reference to the type." },
1387
1388 { "type-target", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_target),
1389 "\
1390Return the target type of the type." },
1391
1392 { "type-const", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_const),
1393 "\
1394Return a const variant of the type." },
1395
1396 { "type-volatile", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_volatile),
1397 "\
1398Return a volatile variant of the type." },
1399
1400 { "type-unqualified", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_unqualified),
1401 "\
1402Return a variant of the type without const or volatile attributes." },
1403
1404 { "type-num-fields", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_num_fields),
1405 "\
1406Return the number of fields of the type." },
1407
1408 { "type-fields", 1, 0, 0, as_a_scm_t_subr (gdbscm_type_fields),
1409 "\
1410Return the list of <gdb:field> objects of fields of the type." },
1411
1412 { "make-field-iterator", 1, 0, 0,
1414 "\
1415Return a <gdb:iterator> object for iterating over the fields of the type." },
1416
1417 { "type-field", 2, 0, 0, as_a_scm_t_subr (gdbscm_type_field),
1418 "\
1419Return the field named by string of the type.\n\
1420\n\
1421 Arguments: <gdb:type> string" },
1422
1423 { "type-has-field?", 2, 0, 0, as_a_scm_t_subr (gdbscm_type_has_field_p),
1424 "\
1425Return #t if the type has field named string.\n\
1426\n\
1427 Arguments: <gdb:type> string" },
1428
1429 { "field?", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_p),
1430 "\
1431Return #t if the object is a <gdb:field> object." },
1432
1433 { "field-name", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_name),
1434 "\
1435Return the name of the field." },
1436
1437 { "field-type", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_type),
1438 "\
1439Return the type of the field." },
1440
1441 { "field-enumval", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_enumval),
1442 "\
1443Return the enum value represented by the field." },
1444
1445 { "field-bitpos", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_bitpos),
1446 "\
1447Return the offset in bits of the field in its containing type." },
1448
1449 { "field-bitsize", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_bitsize),
1450 "\
1451Return the size of the field in bits." },
1452
1453 { "field-artificial?", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_artificial_p),
1454 "\
1455Return #t if the field is artificial." },
1456
1457 { "field-baseclass?", 1, 0, 0, as_a_scm_t_subr (gdbscm_field_baseclass_p),
1458 "\
1459Return #t if the field is a baseclass." },
1460
1462};
1463
1464void
1466{
1468 scm_set_smob_free (type_smob_tag, tyscm_free_type_smob);
1469 scm_set_smob_print (type_smob_tag, tyscm_print_type_smob);
1470 scm_set_smob_equalp (type_smob_tag, tyscm_equal_p_type_smob);
1471
1473 sizeof (field_smob));
1474 scm_set_smob_print (field_smob_tag, tyscm_print_field_smob);
1475
1478
1479 /* This function is "private". */
1481 = scm_c_define_gsubr ("%type-next-field!", 1, 0, 0,
1483 scm_set_procedure_property_x (tyscm_next_field_x_proc,
1486Internal function to assist the type fields iterator."));
1487
1488 block_keyword = scm_from_latin1_keyword ("block");
1489
1492}
const char *const name
static struct parser_state * pstate
Definition ada-exp.c:101
void xfree(void *)
constexpr int n1
Definition 2.cc:29
constexpr int n2
Definition 2.cc:30
void set(unsigned key, void *datum)
Definition registry.h:204
void * get(unsigned key)
Definition registry.h:211
std::string release()
Definition ui-file.h:204
struct type * copy_type_recursive(struct type *type, htab_t copied_types)
Definition gdbtypes.c:5502
struct type * lookup_pointer_type(struct type *type)
Definition gdbtypes.c:430
struct type * lookup_enum(const char *name, const struct block *block)
Definition gdbtypes.c:1743
struct type * lookup_lvalue_reference_type(struct type *type)
Definition gdbtypes.c:518
struct type * lookup_typename(const struct language_defn *language, const char *name, const struct block *block, int noerr)
Definition gdbtypes.c:1651
htab_up create_copied_types_hash()
Definition gdbtypes.c:5464
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
Definition gdbtypes.c:1397
struct type * make_cv_type(int cnst, int voltl, struct type *type, struct type **typeptr)
Definition gdbtypes.c:740
bool types_deeply_equal(struct type *type1, struct type *type2)
Definition gdbtypes.c:4342
struct type * lookup_struct(const char *name, const struct block *block)
Definition gdbtypes.c:1697
struct type * lookup_union(const char *name, const struct block *block)
Definition gdbtypes.c:1719
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:2966
void make_vector_type(struct type *array_type)
Definition gdbtypes.c:1468
#define TYPE_N_BASECLASSES(thistype)
Definition gdbtypes.h:1947
void itscm_set_iterator_smob_progress_x(iterator_smob *i_smob, SCM progress)
void gdbscm_init_eqable_gsmob(eqable_gdb_smob *base, SCM containing_scm)
Definition scm-gsmob.c:162
SCM itscm_iterator_smob_object(iterator_smob *i_smob)
SCM itscm_iterator_smob_progress(iterator_smob *i_smob)
#define END_FUNCTIONS
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
Definition scm-utils.c:528
#define END_INTEGER_CONSTANTS
SCM gdbscm_documentation_symbol
gdbscm_gdb_exception unpack(const gdb_exception &exc)
htab_t gdbscm_create_eqable_gsmob_ptr_map(htab_hash hash_fn, htab_eq eq_fn)
Definition scm-gsmob.c:213
void gdbscm_init_gsmob(gdb_smob *base)
Definition scm-gsmob.c:140
SCM gdbscm_scm_from_gdb_exception(const gdbscm_gdb_exception &exception)
SCM gdbscm_scm_from_longest(LONGEST l)
Definition scm-utils.c:546
SCM gdbscm_make_iterator(SCM object, SCM progress, SCM next)
void gdbscm_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
void gdbscm_clear_eqable_gsmob_ptr_slot(htab_t htab, eqable_gdb_smob *base)
Definition scm-gsmob.c:251
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
gdb::unique_xmalloc_ptr< char > gdbscm_scm_to_c_string(SCM string)
Definition scm-string.c:55
void gdbscm_define_integer_constants(const scheme_integer_constant *, int is_public)
Definition scm-utils.c:63
const struct block * bkscm_scm_to_block(SCM block_scm, int arg_pos, const char *func_name, SCM *excp)
Definition scm-block.c:345
static SCM scm_new_smob(scm_t_bits tc, scm_t_bits data)
void gdbscm_define_functions(const scheme_function *, int is_public)
Definition scm-utils.c:44
eqable_gdb_smob ** gdbscm_find_eqable_gsmob_ptr_slot(htab_t htab, eqable_gdb_smob *base)
Definition scm-gsmob.c:226
#define GDBSCM_HANDLE_GDB_EXCEPTION(exception)
void gdbscm_fill_eqable_gsmob_ptr_slot(eqable_gdb_smob **slot, eqable_gdb_smob *base)
Definition scm-gsmob.c:237
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
Definition scm-gsmob.c:103
void gdbscm_throw(SCM exception) ATTRIBUTE_NORETURN
SCM itscm_get_iterator_arg_unsafe(SCM self, int arg_pos, const char *func_name)
int gdb_scheme_initialized
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
SCM gdbscm_end_of_iteration(void)
#define FUNC_NAME
SCM gdbscm_scm_from_c_string(const char *string)
Definition scm-string.c:45
const struct language_defn * current_language
Definition language.c:82
enum var_types type
Definition scm-param.c:142
static SCM tyscm_next_field_x_proc
Definition scm-type.c:80
static SCM gdbscm_field_artificial_p(SCM self)
Definition scm-type.c:1210
static SCM gdbscm_type_num_fields(SCM self)
Definition scm-type.c:965
static int tyscm_print_type_smob(SCM self, SCM port, scm_print_state *pstate)
Definition scm-type.c:220
void gdbscm_initialize_types(void)
Definition scm-type.c:1465
static SCM gdbscm_type_p(SCM self)
Definition scm-type.c:304
static SCM tyscm_array_1(SCM self, SCM n1_scm, SCM n2_scm, int is_vector, const char *func_name)
Definition scm-type.c:707
SCM tyscm_scm_from_field(SCM type_scm, int field_num)
Definition scm-type.c:464
static struct field * tyscm_field_smob_to_field(field_smob *f_smob)
Definition scm-type.c:510
struct type * tyscm_type_smob_type(type_smob *t_smob)
Definition scm-type.c:116
static SCM gdbscm_type_code(SCM self)
Definition scm-type.c:526
static SCM gdbscm_type_name(SCM self)
Definition scm-type.c:594
static SCM gdbscm_field_name(SCM self)
Definition scm-type.c:1132
static size_t tyscm_free_type_smob(SCM self)
Definition scm-type.c:200
static const char not_composite_error[]
Definition scm-type.c:70
static SCM gdbscm_make_field_iterator(SCM self)
Definition scm-type.c:1062
static SCM gdbscm_type_volatile(SCM self)
Definition scm-type.c:915
static SCM gdbscm_field_type(SCM self)
Definition scm-type.c:1147
static scm_t_bits field_smob_tag
Definition scm-type.c:77
static SCM gdbscm_type_reference(SCM self)
Definition scm-type.c:852
static const char type_smob_name[]
Definition scm-type.c:67
static SCM gdbscm_field_bitsize(SCM self)
Definition scm-type.c:1197
static SCM gdbscm_type_print_name(SCM self)
Definition scm-type.c:610
static struct type * tyscm_field_smob_containing_type(field_smob *f_smob)
Definition scm-type.c:497
static const scheme_function type_functions[]
Definition scm-type.c:1315
static SCM gdbscm_type_unqualified(SCM self)
Definition scm-type.c:939
static SCM gdbscm_type_target(SCM self)
Definition scm-type.c:876
static htab_t tyscm_type_map(struct type *type)
Definition scm-type.c:178
static SCM gdbscm_type_next_field_x(SCM self)
Definition scm-type.c:1093
static scm_t_bits type_smob_tag
Definition scm-type.c:74
int tyscm_is_type(SCM self)
Definition scm-type.c:296
SCM tyscm_scm_from_type(struct type *type)
Definition scm-type.c:313
static int tyscm_is_field(SCM self)
Definition scm-type.c:447
static SCM tyscm_get_type_arg_unsafe(SCM self, int arg_pos, const char *func_name)
Definition scm-type.c:340
static SCM tyscm_equal_p_type_smob(SCM type1_scm, SCM type2_scm)
Definition scm-type.c:246
static SCM gdbscm_type_fields(SCM self)
Definition scm-type.c:541
static const scheme_integer_constant type_integer_constants[]
Definition scm-type.c:1303
static SCM gdbscm_type_range(SCM self)
Definition scm-type.c:811
static struct type * tyscm_get_composite(struct type *type)
Definition scm-type.c:672
static int tyscm_copy_type_recursive(void **slot, void *info)
Definition scm-type.c:376
static SCM block_keyword
Definition scm-type.c:83
static std::string tyscm_type_name(struct type *type)
Definition scm-type.c:125
static SCM gdbscm_field_bitpos(SCM self)
Definition scm-type.c:1180
static const registry< objfile >::key< htab, tyscm_deleter > tyscm_objfile_data_key
Definition scm-type.c:105
static hashval_t tyscm_hash_type_smob(const void *p)
Definition scm-type.c:153
static SCM gdbscm_field_p(SCM self)
Definition scm-type.c:455
static int tyscm_print_field_smob(SCM self, SCM port, scm_print_state *pstate)
Definition scm-type.c:411
struct type * tyscm_scm_to_type(SCM t_scm)
Definition scm-type.c:364
static SCM gdbscm_type_strip_typedefs(SCM self)
Definition scm-type.c:648
static SCM gdbscm_field_enumval(SCM self)
Definition scm-type.c:1163
static struct type * tyscm_lookup_typename(const char *type_name, const struct block *block)
Definition scm-type.c:1239
static SCM gdbscm_type_has_field_p(SCM self, SCM field_scm)
Definition scm-type.c:1024
static SCM gdbscm_type_array(SCM self, SCM n1, SCM n2)
Definition scm-type.c:760
type_smob * tyscm_get_type_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
Definition scm-type.c:352
static SCM tyscm_make_type_smob(void)
Definition scm-type.c:278
static SCM tyscm_make_field_smob(SCM type_scm, int field_num)
Definition scm-type.c:430
static SCM gdbscm_type_vector(SCM self, SCM n1, SCM n2)
Definition scm-type.c:776
static SCM gdbscm_field_baseclass_p(SCM self)
Definition scm-type.c:1223
static htab_t global_types_map
Definition scm-type.c:108
static SCM gdbscm_lookup_type(SCM name_scm, SCM rest)
Definition scm-type.c:1267
static int tyscm_eq_type_smob(const void *ap, const void *bp)
Definition scm-type.c:163
static field_smob * tyscm_get_field_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
Definition scm-type.c:485
static SCM gdbscm_type_pointer(SCM self)
Definition scm-type.c:785
static SCM gdbscm_type_sizeof(SCM self)
Definition scm-type.c:625
static SCM gdbscm_type_field(SCM self, SCM field_scm)
Definition scm-type.c:983
static const char field_smob_name[]
Definition scm-type.c:68
static SCM gdbscm_type_tag(SCM self)
Definition scm-type.c:573
static SCM tyscm_get_field_arg_unsafe(SCM self, int arg_pos, const char *func_name)
Definition scm-type.c:473
static SCM gdbscm_type_const(SCM self)
Definition scm-type.c:891
Definition block.h:109
LONGEST const_val() const
Definition gdbtypes.h:330
bool is_constant() const
Definition gdbtypes.h:345
gdb_smob base
Definition scm-type.c:58
SCM type_scm
Definition scm-type.c:61
int field_num
Definition scm-type.c:64
LONGEST loc_bitpos() const
Definition gdbtypes.h:611
bool is_artificial() const
Definition gdbtypes.h:567
LONGEST loc_enumval() const
Definition gdbtypes.h:623
const char * name() const
Definition gdbtypes.h:557
struct type * type() const
Definition gdbtypes.h:547
virtual void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const =0
struct dynamic_prop high
Definition gdbtypes.h:721
struct dynamic_prop low
Definition gdbtypes.h:717
struct type * type
Definition scm-type.c:50
eqable_gdb_smob base
Definition scm-type.c:47
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
struct field & field(int idx) const
Definition gdbtypes.h:1012
bool is_vector() const
Definition gdbtypes.h:1186
struct objfile * objfile_owner() const
Definition gdbtypes.h:1379
unsigned int num_fields() const
Definition gdbtypes.h:994
struct field * fields() const
Definition gdbtypes.h:1006
range_bounds * bounds() const
Definition gdbtypes.h:1065
const char * name() const
Definition gdbtypes.h:968
void operator()(htab_t htab)
Definition scm-type.c:92
void quit_force(int *exit_arg, int from_tty)
Definition top.c:1732
const struct type_print_options type_print_raw_options
Definition typeprint.c:41
int strcmp_iw(const char *string1, const char *string2)
Definition utils.c:3033