1
/* debug.c -- Handle generic debugging information.
2
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3
Written by Ian Lance Taylor <ian@cygnus.com>.
5
This file is part of GNU Binutils.
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 2 of the License, or
10
(at your option) any later version.
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.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22
/* This file implements a generic debugging format. We may eventually
23
have readers which convert different formats into this generic
24
format, and writers which write it out. The initial impetus for
25
this was writing a convertor from stabs to HP IEEE-695 debugging
33
#include <libiberty.h>
36
/* Global information we keep for debugging. A pointer to this
37
structure is the debugging handle passed to all the routines. */
41
/* A linked list of compilation units. */
42
struct debug_unit *units;
43
/* The current compilation unit. */
44
struct debug_unit *current_unit;
45
/* The current source file. */
46
struct debug_file *current_file;
47
/* The current function. */
48
struct debug_function *current_function;
49
/* The current block. */
50
struct debug_block *current_block;
51
/* The current line number information for the current unit. */
52
struct debug_lineno *current_lineno;
53
/* Mark. This is used by debug_write. */
55
/* A struct/class ID used by debug_write. */
56
unsigned int class_id;
57
/* The base for class_id for this call to debug_write. */
59
/* The current line number in debug_write. */
60
struct debug_lineno *current_write_lineno;
61
unsigned int current_write_lineno_index;
62
/* A list of classes which have assigned ID's during debug_write.
63
This is linked through the next_id field of debug_class_type. */
64
struct debug_class_id *id_list;
65
/* A list used to avoid recursion during debug_type_samep. */
66
struct debug_type_compare_list *compare_list;
69
/* Information we keep for a single compilation unit. */
73
/* The next compilation unit. */
74
struct debug_unit *next;
75
/* A list of files included in this compilation unit. The first
76
file is always the main one, and that is where the main file name
78
struct debug_file *files;
79
/* Line number information for this compilation unit. This is not
80
stored by function, because assembler code may have line number
81
information without function information. */
82
struct debug_lineno *linenos;
85
/* Information kept for a single source file. */
89
/* The next source file in this compilation unit. */
90
struct debug_file *next;
91
/* The name of the source file. */
93
/* Global functions, variables, types, etc. */
94
struct debug_namespace *globals;
102
enum debug_type_kind kind;
103
/* Size of type (0 if not known). */
105
/* Type which is a pointer to this type. */
107
/* Tagged union with additional information about the type. */
110
/* DEBUG_KIND_INDIRECT. */
111
struct debug_indirect_type *kindirect;
112
/* DEBUG_KIND_INT. */
113
/* Whether the integer is unsigned. */
115
/* DEBUG_KIND_STRUCT, DEBUG_KIND_UNION, DEBUG_KIND_CLASS,
116
DEBUG_KIND_UNION_CLASS. */
117
struct debug_class_type *kclass;
118
/* DEBUG_KIND_ENUM. */
119
struct debug_enum_type *kenum;
120
/* DEBUG_KIND_POINTER. */
121
struct debug_type *kpointer;
122
/* DEBUG_KIND_FUNCTION. */
123
struct debug_function_type *kfunction;
124
/* DEBUG_KIND_REFERENCE. */
125
struct debug_type *kreference;
126
/* DEBUG_KIND_RANGE. */
127
struct debug_range_type *krange;
128
/* DEBUG_KIND_ARRAY. */
129
struct debug_array_type *karray;
130
/* DEBUG_KIND_SET. */
131
struct debug_set_type *kset;
132
/* DEBUG_KIND_OFFSET. */
133
struct debug_offset_type *koffset;
134
/* DEBUG_KIND_METHOD. */
135
struct debug_method_type *kmethod;
136
/* DEBUG_KIND_CONST. */
137
struct debug_type *kconst;
138
/* DEBUG_KIND_VOLATILE. */
139
struct debug_type *kvolatile;
140
/* DEBUG_KIND_NAMED, DEBUG_KIND_TAGGED. */
141
struct debug_named_type *knamed;
145
/* Information kept for an indirect type. */
147
struct debug_indirect_type
149
/* Slot where the final type will appear. */
155
/* Information kept for a struct, union, or class. */
157
struct debug_class_type
159
/* NULL terminated array of fields. */
161
/* A mark field which indicates whether the struct has already been
164
/* This is used to uniquely identify unnamed structs when printing. */
166
/* The remaining fields are only used for DEBUG_KIND_CLASS and
167
DEBUG_KIND_UNION_CLASS. */
168
/* NULL terminated array of base classes. */
169
debug_baseclass *baseclasses;
170
/* NULL terminated array of methods. */
171
debug_method *methods;
172
/* The type of the class providing the virtual function table for
173
this class. This may point to the type itself. */
177
/* Information kept for an enum. */
179
struct debug_enum_type
181
/* NULL terminated array of names. */
183
/* Array of corresponding values. */
184
bfd_signed_vma *values;
187
/* Information kept for a function. FIXME: We should be able to
188
record the parameter types. */
190
struct debug_function_type
193
debug_type return_type;
194
/* NULL terminated array of argument types. */
195
debug_type *arg_types;
196
/* Whether the function takes a variable number of arguments. */
200
/* Information kept for a range. */
202
struct debug_range_type
204
/* Range base type. */
207
bfd_signed_vma lower;
209
bfd_signed_vma upper;
212
/* Information kept for an array. */
214
struct debug_array_type
217
debug_type element_type;
219
debug_type range_type;
221
bfd_signed_vma lower;
223
bfd_signed_vma upper;
224
/* Whether this array is really a string. */
228
/* Information kept for a set. */
230
struct debug_set_type
234
/* Whether this set is really a bitstring. */
238
/* Information kept for an offset type (a based pointer). */
240
struct debug_offset_type
242
/* The type the pointer is an offset from. */
243
debug_type base_type;
244
/* The type the pointer points to. */
245
debug_type target_type;
248
/* Information kept for a method type. */
250
struct debug_method_type
252
/* The return type. */
253
debug_type return_type;
254
/* The object type which this method is for. */
255
debug_type domain_type;
256
/* A NULL terminated array of argument types. */
257
debug_type *arg_types;
258
/* Whether the method takes a variable number of arguments. */
262
/* Information kept for a named type. */
264
struct debug_named_type
267
struct debug_name *name;
272
/* A field in a struct or union. */
276
/* Name of the field. */
278
/* Type of the field. */
279
struct debug_type *type;
280
/* Visibility of the field. */
281
enum debug_visibility visibility;
282
/* Whether this is a static member. */
283
boolean static_member;
286
/* If static_member is false. */
289
/* Bit position of the field in the struct. */
291
/* Size of the field in bits. */
292
unsigned int bitsize;
294
/* If static_member is true. */
297
const char *physname;
302
/* A base class for an object. */
304
struct debug_baseclass
306
/* Type of the base class. */
307
struct debug_type *type;
308
/* Bit position of the base class in the object. */
310
/* Whether the base class is virtual. */
312
/* Visibility of the base class. */
313
enum debug_visibility visibility;
316
/* A method of an object. */
320
/* The name of the method. */
322
/* A NULL terminated array of different types of variants. */
323
struct debug_method_variant **variants;
326
/* The variants of a method function of an object. These indicate
327
which method to run. */
329
struct debug_method_variant
331
/* The physical name of the function. */
332
const char *physname;
333
/* The type of the function. */
334
struct debug_type *type;
335
/* The visibility of the function. */
336
enum debug_visibility visibility;
337
/* Whether the function is const. */
339
/* Whether the function is volatile. */
341
/* The offset to the function in the virtual function table. */
343
/* If voffset is VOFFSET_STATIC_METHOD, this is a static method. */
344
#define VOFFSET_STATIC_METHOD ((bfd_vma) -1)
345
/* Context of a virtual method function. */
346
struct debug_type *context;
349
/* A variable. This is the information we keep for a variable object.
350
This has no name; a name is associated with a variable in a
351
debug_name structure. */
353
struct debug_variable
355
/* Kind of variable. */
356
enum debug_var_kind kind;
359
/* Value. The interpretation of the value depends upon kind. */
363
/* A function. This has no name; a name is associated with a function
364
in a debug_name structure. */
366
struct debug_function
369
debug_type return_type;
370
/* Parameter information. */
371
struct debug_parameter *parameters;
372
/* Block information. The first structure on the list is the main
373
block of the function, and describes function local variables. */
374
struct debug_block *blocks;
377
/* A function parameter. */
379
struct debug_parameter
381
/* Next parameter. */
382
struct debug_parameter *next;
388
enum debug_parm_kind kind;
389
/* Value (meaning depends upon kind). */
393
/* A typed constant. */
395
struct debug_typed_constant
399
/* Value. FIXME: We may eventually need to support non-integral
404
/* Information about a block within a function. */
408
/* Next block with the same parent. */
409
struct debug_block *next;
411
struct debug_block *parent;
412
/* List of child blocks. */
413
struct debug_block *children;
414
/* Start address of the block. */
416
/* End address of the block. */
418
/* Local variables. */
419
struct debug_namespace *locals;
422
/* Line number information we keep for a compilation unit. FIXME:
423
This structure is easy to create, but can be very space
428
/* More line number information for this block. */
429
struct debug_lineno *next;
431
struct debug_file *file;
432
/* Line numbers, terminated by a -1 or the end of the array. */
433
#define DEBUG_LINENO_COUNT 10
434
unsigned long linenos[DEBUG_LINENO_COUNT];
435
/* Addresses for the line numbers. */
436
bfd_vma addrs[DEBUG_LINENO_COUNT];
439
/* A namespace. This is a mapping from names to objects. FIXME: This
440
should be implemented as a hash table. */
442
struct debug_namespace
444
/* List of items in this namespace. */
445
struct debug_name *list;
446
/* Pointer to where the next item in this namespace should go. */
447
struct debug_name **tail;
450
/* Kinds of objects that appear in a namespace. */
452
enum debug_object_kind
456
/* A tagged type (really a different sort of namespace). */
459
DEBUG_OBJECT_VARIABLE,
461
DEBUG_OBJECT_FUNCTION,
462
/* An integer constant. */
463
DEBUG_OBJECT_INT_CONSTANT,
464
/* A floating point constant. */
465
DEBUG_OBJECT_FLOAT_CONSTANT,
466
/* A typed constant. */
467
DEBUG_OBJECT_TYPED_CONSTANT
470
/* Linkage of an object that appears in a namespace. */
472
enum debug_object_linkage
474
/* Local variable. */
475
DEBUG_LINKAGE_AUTOMATIC,
476
/* Static--either file static or function static, depending upon the
478
DEBUG_LINKAGE_STATIC,
480
DEBUG_LINKAGE_GLOBAL,
485
/* A name in a namespace. */
489
/* Next name in this namespace. */
490
struct debug_name *next;
493
/* Mark. This is used by debug_write. */
495
/* Kind of object. */
496
enum debug_object_kind kind;
497
/* Linkage of object. */
498
enum debug_object_linkage linkage;
499
/* Tagged union with additional information about the object. */
502
/* DEBUG_OBJECT_TYPE. */
503
struct debug_type *type;
504
/* DEBUG_OBJECT_TAG. */
505
struct debug_type *tag;
506
/* DEBUG_OBJECT_VARIABLE. */
507
struct debug_variable *variable;
508
/* DEBUG_OBJECT_FUNCTION. */
509
struct debug_function *function;
510
/* DEBUG_OBJECT_INT_CONSTANT. */
511
bfd_vma int_constant;
512
/* DEBUG_OBJECT_FLOAT_CONSTANT. */
513
double float_constant;
514
/* DEBUG_OBJECT_TYPED_CONSTANT. */
515
struct debug_typed_constant *typed_constant;
519
/* During debug_write, a linked list of these structures is used to
520
keep track of ID numbers that have been assigned to classes. */
522
struct debug_class_id
524
/* Next ID number. */
525
struct debug_class_id *next;
526
/* The type with the ID. */
527
struct debug_type *type;
528
/* The tag; NULL if no tag. */
532
/* During debug_type_samep, a linked list of these structures is kept
533
on the stack to avoid infinite recursion. */
535
struct debug_type_compare_list
537
/* Next type on list. */
538
struct debug_type_compare_list *next;
539
/* The types we are comparing. */
540
struct debug_type *t1;
541
struct debug_type *t2;
544
/* Local functions. */
546
static void debug_error PARAMS ((const char *));
547
static struct debug_name *debug_add_to_namespace
548
PARAMS ((struct debug_handle *, struct debug_namespace **, const char *,
549
enum debug_object_kind, enum debug_object_linkage));
550
static struct debug_name *debug_add_to_current_namespace
551
PARAMS ((struct debug_handle *, const char *, enum debug_object_kind,
552
enum debug_object_linkage));
553
static struct debug_type *debug_make_type
554
PARAMS ((struct debug_handle *, enum debug_type_kind, unsigned int));
555
static struct debug_type *debug_get_real_type PARAMS ((PTR, debug_type));
556
static boolean debug_write_name
557
PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
558
struct debug_name *));
559
static boolean debug_write_type
560
PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
561
struct debug_type *, struct debug_name *));
562
static boolean debug_write_class_type
563
PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
564
struct debug_type *, const char *));
565
static boolean debug_write_function
566
PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
567
const char *, enum debug_object_linkage, struct debug_function *));
568
static boolean debug_write_block
569
PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
570
struct debug_block *));
571
static boolean debug_write_linenos
572
PARAMS ((struct debug_handle *, const struct debug_write_fns *, PTR,
574
static boolean debug_set_class_id
575
PARAMS ((struct debug_handle *, const char *, struct debug_type *));
576
static boolean debug_type_samep
577
PARAMS ((struct debug_handle *, struct debug_type *, struct debug_type *));
578
static boolean debug_class_type_samep
579
PARAMS ((struct debug_handle *, struct debug_type *, struct debug_type *));
581
/* Issue an error message. */
584
debug_error (message)
587
fprintf (stderr, "%s\n", message);
590
/* Add an object to a namespace. */
592
static struct debug_name *
593
debug_add_to_namespace (info, nsp, name, kind, linkage)
594
struct debug_handle *info;
595
struct debug_namespace **nsp;
597
enum debug_object_kind kind;
598
enum debug_object_linkage linkage;
600
struct debug_name *n;
601
struct debug_namespace *ns;
603
n = (struct debug_name *) xmalloc (sizeof *n);
604
memset (n, 0, sizeof *n);
608
n->linkage = linkage;
613
ns = (struct debug_namespace *) xmalloc (sizeof *ns);
614
memset (ns, 0, sizeof *ns);
616
ns->tail = &ns->list;
627
/* Add an object to the current namespace. */
629
static struct debug_name *
630
debug_add_to_current_namespace (info, name, kind, linkage)
631
struct debug_handle *info;
633
enum debug_object_kind kind;
634
enum debug_object_linkage linkage;
636
struct debug_namespace **nsp;
638
if (info->current_unit == NULL
639
|| info->current_file == NULL)
641
debug_error ("debug_add_to_current_namespace: no current file");
645
if (info->current_block != NULL)
646
nsp = &info->current_block->locals;
648
nsp = &info->current_file->globals;
650
return debug_add_to_namespace (info, nsp, name, kind, linkage);
653
/* Return a handle for debugging information. */
658
struct debug_handle *ret;
660
ret = (struct debug_handle *) xmalloc (sizeof *ret);
661
memset (ret, 0, sizeof *ret);
665
/* Set the source filename. This implicitly starts a new compilation
669
debug_set_filename (handle, name)
673
struct debug_handle *info = (struct debug_handle *) handle;
674
struct debug_file *nfile;
675
struct debug_unit *nunit;
680
nfile = (struct debug_file *) xmalloc (sizeof *nfile);
681
memset (nfile, 0, sizeof *nfile);
683
nfile->filename = name;
685
nunit = (struct debug_unit *) xmalloc (sizeof *nunit);
686
memset (nunit, 0, sizeof *nunit);
688
nunit->files = nfile;
689
info->current_file = nfile;
691
if (info->current_unit != NULL)
692
info->current_unit->next = nunit;
695
assert (info->units == NULL);
699
info->current_unit = nunit;
701
info->current_function = NULL;
702
info->current_block = NULL;
703
info->current_lineno = NULL;
708
/* Change source files to the given file name. This is used for
709
include files in a single compilation unit. */
712
debug_start_source (handle, name)
716
struct debug_handle *info = (struct debug_handle *) handle;
717
struct debug_file *f, **pf;
722
if (info->current_unit == NULL)
724
debug_error ("debug_start_source: no debug_set_filename call");
728
for (f = info->current_unit->files; f != NULL; f = f->next)
730
if (f->filename[0] == name[0]
731
&& f->filename[1] == name[1]
732
&& strcmp (f->filename, name) == 0)
734
info->current_file = f;
739
f = (struct debug_file *) xmalloc (sizeof *f);
740
memset (f, 0, sizeof *f);
744
for (pf = &info->current_file->next;
750
info->current_file = f;
755
/* Record a function definition. This implicitly starts a function
756
block. The debug_type argument is the type of the return value.
757
The boolean indicates whether the function is globally visible.
758
The bfd_vma is the address of the start of the function. Currently
759
the parameter types are specified by calls to
760
debug_record_parameter. FIXME: There is no way to specify nested
764
debug_record_function (handle, name, return_type, global, addr)
767
debug_type return_type;
771
struct debug_handle *info = (struct debug_handle *) handle;
772
struct debug_function *f;
773
struct debug_block *b;
774
struct debug_name *n;
778
if (return_type == NULL)
781
if (info->current_unit == NULL)
783
debug_error ("debug_record_function: no debug_set_filename call");
787
f = (struct debug_function *) xmalloc (sizeof *f);
788
memset (f, 0, sizeof *f);
790
f->return_type = return_type;
792
b = (struct debug_block *) xmalloc (sizeof *b);
793
memset (b, 0, sizeof *b);
796
b->end = (bfd_vma) -1;
800
info->current_function = f;
801
info->current_block = b;
803
/* FIXME: If we could handle nested functions, this would be the
804
place: we would want to use a different namespace. */
805
n = debug_add_to_namespace (info,
806
&info->current_file->globals,
808
DEBUG_OBJECT_FUNCTION,
810
? DEBUG_LINKAGE_GLOBAL
811
: DEBUG_LINKAGE_STATIC));
820
/* Record a parameter for the current function. */
823
debug_record_parameter (handle, name, type, kind, val)
827
enum debug_parm_kind kind;
830
struct debug_handle *info = (struct debug_handle *) handle;
831
struct debug_parameter *p, **pp;
833
if (name == NULL || type == NULL)
836
if (info->current_unit == NULL
837
|| info->current_function == NULL)
839
debug_error ("debug_record_parameter: no current function");
843
p = (struct debug_parameter *) xmalloc (sizeof *p);
844
memset (p, 0, sizeof *p);
851
for (pp = &info->current_function->parameters;
860
/* End a function. FIXME: This should handle function nesting. */
863
debug_end_function (handle, addr)
867
struct debug_handle *info = (struct debug_handle *) handle;
869
if (info->current_unit == NULL
870
|| info->current_block == NULL
871
|| info->current_function == NULL)
873
debug_error ("debug_end_function: no current function");
877
if (info->current_block->parent != NULL)
879
debug_error ("debug_end_function: some blocks were not closed");
883
info->current_block->end = addr;
885
info->current_function = NULL;
886
info->current_block = NULL;
891
/* Start a block in a function. All local information will be
892
recorded in this block, until the matching call to debug_end_block.
893
debug_start_block and debug_end_block may be nested. The bfd_vma
894
argument is the address at which this block starts. */
897
debug_start_block (handle, addr)
901
struct debug_handle *info = (struct debug_handle *) handle;
902
struct debug_block *b, **pb;
904
/* We must always have a current block: debug_record_function sets
906
if (info->current_unit == NULL
907
|| info->current_block == NULL)
909
debug_error ("debug_start_block: no current block");
913
b = (struct debug_block *) xmalloc (sizeof *b);
914
memset (b, 0, sizeof *b);
916
b->parent = info->current_block;
918
b->end = (bfd_vma) -1;
920
/* This new block is a child of the current block. */
921
for (pb = &info->current_block->children;
927
info->current_block = b;
932
/* Finish a block in a function. This matches the call to
933
debug_start_block. The argument is the address at which this block
937
debug_end_block (handle, addr)
941
struct debug_handle *info = (struct debug_handle *) handle;
942
struct debug_block *parent;
944
if (info->current_unit == NULL
945
|| info->current_block == NULL)
947
debug_error ("debug_end_block: no current block");
951
parent = info->current_block->parent;
954
debug_error ("debug_end_block: attempt to close top level block");
958
info->current_block->end = addr;
960
info->current_block = parent;
965
/* Associate a line number in the current source file and function
966
with a given address. */
969
debug_record_line (handle, lineno, addr)
971
unsigned long lineno;
974
struct debug_handle *info = (struct debug_handle *) handle;
975
struct debug_lineno *l;
978
if (info->current_unit == NULL)
980
debug_error ("debug_record_line: no current unit");
984
l = info->current_lineno;
985
if (l != NULL && l->file == info->current_file)
987
for (i = 0; i < DEBUG_LINENO_COUNT; i++)
989
if (l->linenos[i] == (unsigned long) -1)
991
l->linenos[i] = lineno;
998
/* If we get here, then either 1) there is no current_lineno
999
structure, which means this is the first line number in this
1000
compilation unit, 2) the current_lineno structure is for a
1001
different file, or 3) the current_lineno structure is full.
1002
Regardless, we want to allocate a new debug_lineno structure, put
1003
it in the right place, and make it the new current_lineno
1006
l = (struct debug_lineno *) xmalloc (sizeof *l);
1007
memset (l, 0, sizeof *l);
1009
l->file = info->current_file;
1010
l->linenos[0] = lineno;
1012
for (i = 1; i < DEBUG_LINENO_COUNT; i++)
1013
l->linenos[i] = (unsigned long) -1;
1015
if (info->current_lineno != NULL)
1016
info->current_lineno->next = l;
1018
info->current_unit->linenos = l;
1020
info->current_lineno = l;
1025
/* Start a named common block. This is a block of variables that may
1029
debug_start_common_block (handle, name)
1034
debug_error ("debug_start_common_block: not implemented");
1038
/* End a named common block. */
1041
debug_end_common_block (handle, name)
1046
debug_error ("debug_end_common_block: not implemented");
1050
/* Record a named integer constant. */
1053
debug_record_int_const (handle, name, val)
1058
struct debug_handle *info = (struct debug_handle *) handle;
1059
struct debug_name *n;
1064
n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_INT_CONSTANT,
1065
DEBUG_LINKAGE_NONE);
1069
n->u.int_constant = val;
1074
/* Record a named floating point constant. */
1077
debug_record_float_const (handle, name, val)
1082
struct debug_handle *info = (struct debug_handle *) handle;
1083
struct debug_name *n;
1088
n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_FLOAT_CONSTANT,
1089
DEBUG_LINKAGE_NONE);
1093
n->u.float_constant = val;
1098
/* Record a typed constant with an integral value. */
1101
debug_record_typed_const (handle, name, type, val)
1107
struct debug_handle *info = (struct debug_handle *) handle;
1108
struct debug_name *n;
1109
struct debug_typed_constant *tc;
1111
if (name == NULL || type == NULL)
1114
n = debug_add_to_current_namespace (info, name, DEBUG_OBJECT_TYPED_CONSTANT,
1115
DEBUG_LINKAGE_NONE);
1119
tc = (struct debug_typed_constant *) xmalloc (sizeof *tc);
1120
memset (tc, 0, sizeof *tc);
1125
n->u.typed_constant = tc;
1130
/* Record a label. */
1133
debug_record_label (handle, name, type, addr)
1140
debug_error ("debug_record_label not implemented");
1144
/* Record a variable. */
1147
debug_record_variable (handle, name, type, kind, val)
1151
enum debug_var_kind kind;
1154
struct debug_handle *info = (struct debug_handle *) handle;
1155
struct debug_namespace **nsp;
1156
enum debug_object_linkage linkage;
1157
struct debug_name *n;
1158
struct debug_variable *v;
1160
if (name == NULL || type == NULL)
1163
if (info->current_unit == NULL
1164
|| info->current_file == NULL)
1166
debug_error ("debug_record_variable: no current file");
1170
if (kind == DEBUG_GLOBAL || kind == DEBUG_STATIC)
1172
nsp = &info->current_file->globals;
1173
if (kind == DEBUG_GLOBAL)
1174
linkage = DEBUG_LINKAGE_GLOBAL;
1176
linkage = DEBUG_LINKAGE_STATIC;
1180
if (info->current_block == NULL)
1182
debug_error ("debug_record_variable: no current block");
1185
nsp = &info->current_block->locals;
1186
linkage = DEBUG_LINKAGE_AUTOMATIC;
1189
n = debug_add_to_namespace (info, nsp, name, DEBUG_OBJECT_VARIABLE, linkage);
1193
v = (struct debug_variable *) xmalloc (sizeof *v);
1194
memset (v, 0, sizeof *v);
1205
/* Make a type with a given kind and size. */
1208
static struct debug_type *
1209
debug_make_type (info, kind, size)
1210
struct debug_handle *info;
1211
enum debug_type_kind kind;
1214
struct debug_type *t;
1216
t = (struct debug_type *) xmalloc (sizeof *t);
1217
memset (t, 0, sizeof *t);
1225
/* Make an indirect type which may be used as a placeholder for a type
1226
which is referenced before it is defined. */
1229
debug_make_indirect_type (handle, slot, tag)
1234
struct debug_handle *info = (struct debug_handle *) handle;
1235
struct debug_type *t;
1236
struct debug_indirect_type *i;
1238
t = debug_make_type (info, DEBUG_KIND_INDIRECT, 0);
1240
return DEBUG_TYPE_NULL;
1242
i = (struct debug_indirect_type *) xmalloc (sizeof *i);
1243
memset (i, 0, sizeof *i);
1253
/* Make a void type. There is only one of these. */
1256
debug_make_void_type (handle)
1259
struct debug_handle *info = (struct debug_handle *) handle;
1261
return debug_make_type (info, DEBUG_KIND_VOID, 0);
1264
/* Make an integer type of a given size. The boolean argument is true
1265
if the integer is unsigned. */
1268
debug_make_int_type (handle, size, unsignedp)
1273
struct debug_handle *info = (struct debug_handle *) handle;
1274
struct debug_type *t;
1276
t = debug_make_type (info, DEBUG_KIND_INT, size);
1278
return DEBUG_TYPE_NULL;
1280
t->u.kint = unsignedp;
1285
/* Make a floating point type of a given size. FIXME: On some
1286
platforms, like an Alpha, you probably need to be able to specify
1290
debug_make_float_type (handle, size)
1294
struct debug_handle *info = (struct debug_handle *) handle;
1296
return debug_make_type (info, DEBUG_KIND_FLOAT, size);
1299
/* Make a boolean type of a given size. */
1302
debug_make_bool_type (handle, size)
1306
struct debug_handle *info = (struct debug_handle *) handle;
1308
return debug_make_type (info, DEBUG_KIND_BOOL, size);
1311
/* Make a complex type of a given size. */
1314
debug_make_complex_type (handle, size)
1318
struct debug_handle *info = (struct debug_handle *) handle;
1320
return debug_make_type (info, DEBUG_KIND_COMPLEX, size);
1323
/* Make a structure type. The second argument is true for a struct,
1324
false for a union. The third argument is the size of the struct.
1325
The fourth argument is a NULL terminated array of fields. */
1328
debug_make_struct_type (handle, structp, size, fields)
1332
debug_field *fields;
1334
struct debug_handle *info = (struct debug_handle *) handle;
1335
struct debug_type *t;
1336
struct debug_class_type *c;
1338
t = debug_make_type (info,
1339
structp ? DEBUG_KIND_STRUCT : DEBUG_KIND_UNION,
1342
return DEBUG_TYPE_NULL;
1344
c = (struct debug_class_type *) xmalloc (sizeof *c);
1345
memset (c, 0, sizeof *c);
1354
/* Make an object type. The first three arguments after the handle
1355
are the same as for debug_make_struct_type. The next arguments are
1356
a NULL terminated array of base classes, a NULL terminated array of
1357
methods, the type of the object holding the virtual function table
1358
if it is not this object, and a boolean which is true if this
1359
object has its own virtual function table. */
1362
debug_make_object_type (handle, structp, size, fields, baseclasses,
1363
methods, vptrbase, ownvptr)
1367
debug_field *fields;
1368
debug_baseclass *baseclasses;
1369
debug_method *methods;
1370
debug_type vptrbase;
1373
struct debug_handle *info = (struct debug_handle *) handle;
1374
struct debug_type *t;
1375
struct debug_class_type *c;
1377
t = debug_make_type (info,
1378
structp ? DEBUG_KIND_CLASS : DEBUG_KIND_UNION_CLASS,
1381
return DEBUG_TYPE_NULL;
1383
c = (struct debug_class_type *) xmalloc (sizeof *c);
1384
memset (c, 0, sizeof *c);
1387
c->baseclasses = baseclasses;
1388
c->methods = methods;
1392
c->vptrbase = vptrbase;
1399
/* Make an enumeration type. The arguments are a null terminated
1400
array of strings, and an array of corresponding values. */
1403
debug_make_enum_type (handle, names, values)
1406
bfd_signed_vma *values;
1408
struct debug_handle *info = (struct debug_handle *) handle;
1409
struct debug_type *t;
1410
struct debug_enum_type *e;
1412
t = debug_make_type (info, DEBUG_KIND_ENUM, 0);
1414
return DEBUG_TYPE_NULL;
1416
e = (struct debug_enum_type *) xmalloc (sizeof *e);
1417
memset (e, 0, sizeof *e);
1427
/* Make a pointer to a given type. */
1430
debug_make_pointer_type (handle, type)
1434
struct debug_handle *info = (struct debug_handle *) handle;
1435
struct debug_type *t;
1438
return DEBUG_TYPE_NULL;
1440
if (type->pointer != DEBUG_TYPE_NULL)
1441
return type->pointer;
1443
t = debug_make_type (info, DEBUG_KIND_POINTER, 0);
1445
return DEBUG_TYPE_NULL;
1447
t->u.kpointer = type;
1454
/* Make a function returning a given type. FIXME: We should be able
1455
to record the parameter types. */
1458
debug_make_function_type (handle, type, arg_types, varargs)
1461
debug_type *arg_types;
1464
struct debug_handle *info = (struct debug_handle *) handle;
1465
struct debug_type *t;
1466
struct debug_function_type *f;
1469
return DEBUG_TYPE_NULL;
1471
t = debug_make_type (info, DEBUG_KIND_FUNCTION, 0);
1473
return DEBUG_TYPE_NULL;
1475
f = (struct debug_function_type *) xmalloc (sizeof *f);
1476
memset (f, 0, sizeof *f);
1478
f->return_type = type;
1479
f->arg_types = arg_types;
1480
f->varargs = varargs;
1487
/* Make a reference to a given type. */
1490
debug_make_reference_type (handle, type)
1494
struct debug_handle *info = (struct debug_handle *) handle;
1495
struct debug_type *t;
1498
return DEBUG_TYPE_NULL;
1500
t = debug_make_type (info, DEBUG_KIND_REFERENCE, 0);
1502
return DEBUG_TYPE_NULL;
1504
t->u.kreference = type;
1509
/* Make a range of a given type from a lower to an upper bound. */
1512
debug_make_range_type (handle, type, lower, upper)
1515
bfd_signed_vma lower;
1516
bfd_signed_vma upper;
1518
struct debug_handle *info = (struct debug_handle *) handle;
1519
struct debug_type *t;
1520
struct debug_range_type *r;
1523
return DEBUG_TYPE_NULL;
1525
t = debug_make_type (info, DEBUG_KIND_RANGE, 0);
1527
return DEBUG_TYPE_NULL;
1529
r = (struct debug_range_type *) xmalloc (sizeof *r);
1530
memset (r, 0, sizeof *r);
1541
/* Make an array type. The second argument is the type of an element
1542
of the array. The third argument is the type of a range of the
1543
array. The fourth and fifth argument are the lower and upper
1544
bounds, respectively. The sixth argument is true if this array is
1545
actually a string, as in C. */
1548
debug_make_array_type (handle, element_type, range_type, lower, upper,
1551
debug_type element_type;
1552
debug_type range_type;
1553
bfd_signed_vma lower;
1554
bfd_signed_vma upper;
1557
struct debug_handle *info = (struct debug_handle *) handle;
1558
struct debug_type *t;
1559
struct debug_array_type *a;
1561
if (element_type == NULL || range_type == NULL)
1562
return DEBUG_TYPE_NULL;
1564
t = debug_make_type (info, DEBUG_KIND_ARRAY, 0);
1566
return DEBUG_TYPE_NULL;
1568
a = (struct debug_array_type *) xmalloc (sizeof *a);
1569
memset (a, 0, sizeof *a);
1571
a->element_type = element_type;
1572
a->range_type = range_type;
1575
a->stringp = stringp;
1582
/* Make a set of a given type. For example, a Pascal set type. The
1583
boolean argument is true if this set is actually a bitstring, as in
1587
debug_make_set_type (handle, type, bitstringp)
1592
struct debug_handle *info = (struct debug_handle *) handle;
1593
struct debug_type *t;
1594
struct debug_set_type *s;
1597
return DEBUG_TYPE_NULL;
1599
t = debug_make_type (info, DEBUG_KIND_SET, 0);
1601
return DEBUG_TYPE_NULL;
1603
s = (struct debug_set_type *) xmalloc (sizeof *s);
1604
memset (s, 0, sizeof *s);
1607
s->bitstringp = bitstringp;
1614
/* Make a type for a pointer which is relative to an object. The
1615
second argument is the type of the object to which the pointer is
1616
relative. The third argument is the type that the pointer points
1620
debug_make_offset_type (handle, base_type, target_type)
1622
debug_type base_type;
1623
debug_type target_type;
1625
struct debug_handle *info = (struct debug_handle *) handle;
1626
struct debug_type *t;
1627
struct debug_offset_type *o;
1629
if (base_type == NULL || target_type == NULL)
1630
return DEBUG_TYPE_NULL;
1632
t = debug_make_type (info, DEBUG_KIND_OFFSET, 0);
1634
return DEBUG_TYPE_NULL;
1636
o = (struct debug_offset_type *) xmalloc (sizeof *o);
1637
memset (o, 0, sizeof *o);
1639
o->base_type = base_type;
1640
o->target_type = target_type;
1647
/* Make a type for a method function. The second argument is the
1648
return type, the third argument is the domain, and the fourth
1649
argument is a NULL terminated array of argument types. */
1652
debug_make_method_type (handle, return_type, domain_type, arg_types, varargs)
1654
debug_type return_type;
1655
debug_type domain_type;
1656
debug_type *arg_types;
1659
struct debug_handle *info = (struct debug_handle *) handle;
1660
struct debug_type *t;
1661
struct debug_method_type *m;
1663
if (return_type == NULL)
1664
return DEBUG_TYPE_NULL;
1666
t = debug_make_type (info, DEBUG_KIND_METHOD, 0);
1668
return DEBUG_TYPE_NULL;
1670
m = (struct debug_method_type *) xmalloc (sizeof *m);
1671
memset (m, 0, sizeof *m);
1673
m->return_type = return_type;
1674
m->domain_type = domain_type;
1675
m->arg_types = arg_types;
1676
m->varargs = varargs;
1683
/* Make a const qualified version of a given type. */
1686
debug_make_const_type (handle, type)
1690
struct debug_handle *info = (struct debug_handle *) handle;
1691
struct debug_type *t;
1694
return DEBUG_TYPE_NULL;
1696
t = debug_make_type (info, DEBUG_KIND_CONST, 0);
1698
return DEBUG_TYPE_NULL;
1705
/* Make a volatile qualified version of a given type. */
1708
debug_make_volatile_type (handle, type)
1712
struct debug_handle *info = (struct debug_handle *) handle;
1713
struct debug_type *t;
1716
return DEBUG_TYPE_NULL;
1718
t = debug_make_type (info, DEBUG_KIND_VOLATILE, 0);
1720
return DEBUG_TYPE_NULL;
1722
t->u.kvolatile = type;
1727
/* Make an undefined tagged type. For example, a struct which has
1728
been mentioned, but not defined. */
1731
debug_make_undefined_tagged_type (handle, name, kind)
1734
enum debug_type_kind kind;
1736
struct debug_handle *info = (struct debug_handle *) handle;
1737
struct debug_type *t;
1740
return DEBUG_TYPE_NULL;
1744
case DEBUG_KIND_STRUCT:
1745
case DEBUG_KIND_UNION:
1746
case DEBUG_KIND_CLASS:
1747
case DEBUG_KIND_UNION_CLASS:
1748
case DEBUG_KIND_ENUM:
1752
debug_error ("debug_make_undefined_type: unsupported kind");
1753
return DEBUG_TYPE_NULL;
1756
t = debug_make_type (info, kind, 0);
1758
return DEBUG_TYPE_NULL;
1760
return debug_tag_type (handle, name, t);
1763
/* Make a base class for an object. The second argument is the base
1764
class type. The third argument is the bit position of this base
1765
class in the object (always 0 unless doing multiple inheritance).
1766
The fourth argument is whether this is a virtual class. The fifth
1767
argument is the visibility of the base class. */
1771
debug_make_baseclass (handle, type, bitpos, virtual, visibility)
1776
enum debug_visibility visibility;
1778
struct debug_baseclass *b;
1780
b = (struct debug_baseclass *) xmalloc (sizeof *b);
1781
memset (b, 0, sizeof *b);
1785
b->virtual = virtual;
1786
b->visibility = visibility;
1791
/* Make a field for a struct. The second argument is the name. The
1792
third argument is the type of the field. The fourth argument is
1793
the bit position of the field. The fifth argument is the size of
1794
the field (it may be zero). The sixth argument is the visibility
1799
debug_make_field (handle, name, type, bitpos, bitsize, visibility)
1805
enum debug_visibility visibility;
1807
struct debug_field *f;
1809
f = (struct debug_field *) xmalloc (sizeof *f);
1810
memset (f, 0, sizeof *f);
1814
f->static_member = false;
1815
f->u.f.bitpos = bitpos;
1816
f->u.f.bitsize = bitsize;
1817
f->visibility = visibility;
1822
/* Make a static member of an object. The second argument is the
1823
name. The third argument is the type of the member. The fourth
1824
argument is the physical name of the member (i.e., the name as a
1825
global variable). The fifth argument is the visibility of the
1830
debug_make_static_member (handle, name, type, physname, visibility)
1834
const char *physname;
1835
enum debug_visibility visibility;
1837
struct debug_field *f;
1839
f = (struct debug_field *) xmalloc (sizeof *f);
1840
memset (f, 0, sizeof *f);
1844
f->static_member = true;
1845
f->u.s.physname = physname;
1846
f->visibility = visibility;
1851
/* Make a method. The second argument is the name, and the third
1852
argument is a NULL terminated array of method variants. */
1856
debug_make_method (handle, name, variants)
1859
debug_method_variant *variants;
1861
struct debug_method *m;
1863
m = (struct debug_method *) xmalloc (sizeof *m);
1864
memset (m, 0, sizeof *m);
1867
m->variants = variants;
1872
/* Make a method argument. The second argument is the real name of
1873
the function. The third argument is the type of the function. The
1874
fourth argument is the visibility. The fifth argument is whether
1875
this is a const function. The sixth argument is whether this is a
1876
volatile function. The seventh argument is the offset in the
1877
virtual function table, if any. The eighth argument is the virtual
1878
function context. FIXME: Are the const and volatile arguments
1879
necessary? Could we just use debug_make_const_type? */
1882
debug_method_variant
1883
debug_make_method_variant (handle, physname, type, visibility, constp,
1884
volatilep, voffset, context)
1886
const char *physname;
1888
enum debug_visibility visibility;
1894
struct debug_method_variant *m;
1896
m = (struct debug_method_variant *) xmalloc (sizeof *m);
1897
memset (m, 0, sizeof *m);
1899
m->physname = physname;
1901
m->visibility = visibility;
1903
m->volatilep = volatilep;
1904
m->voffset = voffset;
1905
m->context = context;
1910
/* Make a static method argument. The arguments are the same as for
1911
debug_make_method_variant, except that the last two are omitted
1912
since a static method can not also be virtual. */
1914
debug_method_variant
1915
debug_make_static_method_variant (handle, physname, type, visibility,
1918
const char *physname;
1920
enum debug_visibility visibility;
1924
struct debug_method_variant *m;
1926
m = (struct debug_method_variant *) xmalloc (sizeof *m);
1927
memset (m, 0, sizeof *m);
1929
m->physname = physname;
1931
m->visibility = visibility;
1933
m->volatilep = volatilep;
1934
m->voffset = VOFFSET_STATIC_METHOD;
1942
debug_name_type (handle, name, type)
1947
struct debug_handle *info = (struct debug_handle *) handle;
1948
struct debug_type *t;
1949
struct debug_named_type *n;
1950
struct debug_name *nm;
1952
if (name == NULL || type == NULL)
1953
return DEBUG_TYPE_NULL;
1955
if (info->current_unit == NULL
1956
|| info->current_file == NULL)
1958
debug_error ("debug_name_type: no current file");
1959
return DEBUG_TYPE_NULL;
1963
t = debug_make_type (info, DEBUG_KIND_NAMED, 0);
1965
return DEBUG_TYPE_NULL;
1967
n = (struct debug_named_type *) xmalloc (sizeof *n);
1968
memset (n, 0, sizeof *n);
1974
/* We always add the name to the global namespace. This is probably
1975
wrong in some cases, but it seems to be right for stabs. FIXME. */
1977
nm = debug_add_to_namespace (info, &info->current_file->globals, name,
1978
DEBUG_OBJECT_TYPE, DEBUG_LINKAGE_NONE);
1980
return DEBUG_TYPE_NULL;
1992
debug_tag_type (handle, name, type)
1997
struct debug_handle *info = (struct debug_handle *) handle;
1998
struct debug_type *t;
1999
struct debug_named_type *n;
2000
struct debug_name *nm;
2002
if (name == NULL || type == NULL)
2003
return DEBUG_TYPE_NULL;
2005
if (info->current_file == NULL)
2007
debug_error ("debug_tag_type: no current file");
2008
return DEBUG_TYPE_NULL;
2011
if (type->kind == DEBUG_KIND_TAGGED)
2013
if (strcmp (type->u.knamed->name->name, name) == 0)
2015
debug_error ("debug_tag_type: extra tag attempted");
2016
return DEBUG_TYPE_NULL;
2019
t = debug_make_type (info, DEBUG_KIND_TAGGED, 0);
2021
return DEBUG_TYPE_NULL;
2023
n = (struct debug_named_type *) xmalloc (sizeof *n);
2024
memset (n, 0, sizeof *n);
2030
/* We keep a global namespace of tags for each compilation unit. I
2031
don't know if that is the right thing to do. */
2033
nm = debug_add_to_namespace (info, &info->current_file->globals, name,
2034
DEBUG_OBJECT_TAG, DEBUG_LINKAGE_NONE);
2036
return DEBUG_TYPE_NULL;
2045
/* Record the size of a given type. */
2049
debug_record_type_size (handle, type, size)
2055
if (type->size != 0 && type->size != size)
2056
fprintf (stderr, "Warning: changing type size from %d to %d\n",
2065
/* Find a named type. */
2068
debug_find_named_type (handle, name)
2072
struct debug_handle *info = (struct debug_handle *) handle;
2073
struct debug_block *b;
2074
struct debug_file *f;
2076
/* We only search the current compilation unit. I don't know if
2077
this is right or not. */
2079
if (info->current_unit == NULL)
2081
debug_error ("debug_find_named_type: no current compilation unit");
2082
return DEBUG_TYPE_NULL;
2085
for (b = info->current_block; b != NULL; b = b->parent)
2087
if (b->locals != NULL)
2089
struct debug_name *n;
2091
for (n = b->locals->list; n != NULL; n = n->next)
2093
if (n->kind == DEBUG_OBJECT_TYPE
2094
&& n->name[0] == name[0]
2095
&& strcmp (n->name, name) == 0)
2101
for (f = info->current_unit->files; f != NULL; f = f->next)
2103
if (f->globals != NULL)
2105
struct debug_name *n;
2107
for (n = f->globals->list; n != NULL; n = n->next)
2109
if (n->kind == DEBUG_OBJECT_TYPE
2110
&& n->name[0] == name[0]
2111
&& strcmp (n->name, name) == 0)
2117
return DEBUG_TYPE_NULL;
2120
/* Find a tagged type. */
2123
debug_find_tagged_type (handle, name, kind)
2126
enum debug_type_kind kind;
2128
struct debug_handle *info = (struct debug_handle *) handle;
2129
struct debug_unit *u;
2131
/* We search the globals of all the compilation units. I don't know
2132
if this is correct or not. It would be easy to change. */
2134
for (u = info->units; u != NULL; u = u->next)
2136
struct debug_file *f;
2138
for (f = u->files; f != NULL; f = f->next)
2140
struct debug_name *n;
2142
if (f->globals != NULL)
2144
for (n = f->globals->list; n != NULL; n = n->next)
2146
if (n->kind == DEBUG_OBJECT_TAG
2147
&& (kind == DEBUG_KIND_ILLEGAL
2148
|| n->u.tag->kind == kind)
2149
&& n->name[0] == name[0]
2150
&& strcmp (n->name, name) == 0)
2157
return DEBUG_TYPE_NULL;
2160
/* Get a base type. */
2162
static struct debug_type *
2163
debug_get_real_type (handle, type)
2171
case DEBUG_KIND_INDIRECT:
2172
if (*type->u.kindirect->slot != NULL)
2173
return debug_get_real_type (handle, *type->u.kindirect->slot);
2175
case DEBUG_KIND_NAMED:
2176
case DEBUG_KIND_TAGGED:
2177
return debug_get_real_type (handle, type->u.knamed->type);
2182
/* Get the kind of a type. */
2184
enum debug_type_kind
2185
debug_get_type_kind (handle, type)
2190
return DEBUG_KIND_ILLEGAL;
2191
type = debug_get_real_type (handle, type);
2195
/* Get the name of a type. */
2198
debug_get_type_name (handle, type)
2202
if (type->kind == DEBUG_KIND_INDIRECT)
2204
if (*type->u.kindirect->slot != NULL)
2205
return debug_get_type_name (handle, *type->u.kindirect->slot);
2206
return type->u.kindirect->tag;
2208
if (type->kind == DEBUG_KIND_NAMED
2209
|| type->kind == DEBUG_KIND_TAGGED)
2210
return type->u.knamed->name->name;
2214
/* Get the size of a type. */
2217
debug_get_type_size (handle, type)
2224
/* We don't call debug_get_real_type, because somebody might have
2225
called debug_record_type_size on a named or indirect type. */
2227
if (type->size != 0)
2234
case DEBUG_KIND_INDIRECT:
2235
if (*type->u.kindirect->slot != NULL)
2236
return debug_get_type_size (handle, *type->u.kindirect->slot);
2238
case DEBUG_KIND_NAMED:
2239
case DEBUG_KIND_TAGGED:
2240
return debug_get_type_size (handle, type->u.knamed->type);
2245
/* Get the return type of a function or method type. */
2248
debug_get_return_type (handle, type)
2253
return DEBUG_TYPE_NULL;
2254
type = debug_get_real_type (handle, type);
2258
return DEBUG_TYPE_NULL;
2259
case DEBUG_KIND_FUNCTION:
2260
return type->u.kfunction->return_type;
2261
case DEBUG_KIND_METHOD:
2262
return type->u.kmethod->return_type;
2267
/* Get the parameter types of a function or method type (except that
2268
we don't currently store the parameter types of a function). */
2271
debug_get_parameter_types (handle, type, pvarargs)
2278
type = debug_get_real_type (handle, type);
2283
case DEBUG_KIND_FUNCTION:
2284
*pvarargs = type->u.kfunction->varargs;
2285
return type->u.kfunction->arg_types;
2286
case DEBUG_KIND_METHOD:
2287
*pvarargs = type->u.kmethod->varargs;
2288
return type->u.kmethod->arg_types;
2293
/* Get the target type of a type. */
2296
debug_get_target_type (handle, type)
2302
type = debug_get_real_type (handle, type);
2307
case DEBUG_KIND_POINTER:
2308
return type->u.kpointer;
2309
case DEBUG_KIND_REFERENCE:
2310
return type->u.kreference;
2311
case DEBUG_KIND_CONST:
2312
return type->u.kconst;
2313
case DEBUG_KIND_VOLATILE:
2314
return type->u.kvolatile;
2319
/* Get the NULL terminated array of fields for a struct, union, or
2323
debug_get_fields (handle, type)
2329
type = debug_get_real_type (handle, type);
2334
case DEBUG_KIND_STRUCT:
2335
case DEBUG_KIND_UNION:
2336
case DEBUG_KIND_CLASS:
2337
case DEBUG_KIND_UNION_CLASS:
2338
return type->u.kclass->fields;
2343
/* Get the type of a field. */
2347
debug_get_field_type (handle, field)
2356
/* Get the name of a field. */
2360
debug_get_field_name (handle, field)
2369
/* Get the bit position of a field. */
2373
debug_get_field_bitpos (handle, field)
2377
if (field == NULL || field->static_member)
2378
return (bfd_vma) -1;
2379
return field->u.f.bitpos;
2382
/* Get the bit size of a field. */
2386
debug_get_field_bitsize (handle, field)
2390
if (field == NULL || field->static_member)
2391
return (bfd_vma) -1;
2392
return field->u.f.bitsize;
2395
/* Get the visibility of a field. */
2398
enum debug_visibility
2399
debug_get_field_visibility (handle, field)
2404
return DEBUG_VISIBILITY_IGNORE;
2405
return field->visibility;
2408
/* Get the physical name of a field. */
2411
debug_get_field_physname (handle, field)
2415
if (field == NULL || ! field->static_member)
2417
return field->u.s.physname;
2420
/* Write out the debugging information. This is given a handle to
2421
debugging information, and a set of function pointers to call. */
2424
debug_write (handle, fns, fhandle)
2426
const struct debug_write_fns *fns;
2429
struct debug_handle *info = (struct debug_handle *) handle;
2430
struct debug_unit *u;
2432
/* We use a mark to tell whether we have already written out a
2433
particular name. We use an integer, so that we don't have to
2434
clear the mark fields if we happen to write out the same
2435
information more than once. */
2438
/* The base_id field holds an ID value which will never be used, so
2439
that we can tell whether we have assigned an ID during this call
2441
info->base_id = info->class_id;
2443
/* We keep a linked list of classes for which was have assigned ID's
2444
during this call to debug_write. */
2445
info->id_list = NULL;
2447
for (u = info->units; u != NULL; u = u->next)
2449
struct debug_file *f;
2452
info->current_write_lineno = u->linenos;
2453
info->current_write_lineno_index = 0;
2455
if (! (*fns->start_compilation_unit) (fhandle, u->files->filename))
2459
for (f = u->files; f != NULL; f = f->next)
2461
struct debug_name *n;
2467
if (! (*fns->start_source) (fhandle, f->filename))
2471
if (f->globals != NULL)
2473
for (n = f->globals->list; n != NULL; n = n->next)
2475
if (! debug_write_name (info, fns, fhandle, n))
2481
/* Output any line number information which hasn't already been
2483
if (! debug_write_linenos (info, fns, fhandle, (bfd_vma) -1))
2490
/* Write out an element in a namespace. */
2493
debug_write_name (info, fns, fhandle, n)
2494
struct debug_handle *info;
2495
const struct debug_write_fns *fns;
2497
struct debug_name *n;
2501
case DEBUG_OBJECT_TYPE:
2502
if (! debug_write_type (info, fns, fhandle, n->u.type, n)
2503
|| ! (*fns->typdef) (fhandle, n->name))
2506
case DEBUG_OBJECT_TAG:
2507
if (! debug_write_type (info, fns, fhandle, n->u.tag, n))
2509
return (*fns->tag) (fhandle, n->name);
2510
case DEBUG_OBJECT_VARIABLE:
2511
if (! debug_write_type (info, fns, fhandle, n->u.variable->type,
2512
(struct debug_name *) NULL))
2514
return (*fns->variable) (fhandle, n->name, n->u.variable->kind,
2515
n->u.variable->val);
2516
case DEBUG_OBJECT_FUNCTION:
2517
return debug_write_function (info, fns, fhandle, n->name,
2518
n->linkage, n->u.function);
2519
case DEBUG_OBJECT_INT_CONSTANT:
2520
return (*fns->int_constant) (fhandle, n->name, n->u.int_constant);
2521
case DEBUG_OBJECT_FLOAT_CONSTANT:
2522
return (*fns->float_constant) (fhandle, n->name, n->u.float_constant);
2523
case DEBUG_OBJECT_TYPED_CONSTANT:
2524
if (! debug_write_type (info, fns, fhandle, n->u.typed_constant->type,
2525
(struct debug_name *) NULL))
2527
return (*fns->typed_constant) (fhandle, n->name,
2528
n->u.typed_constant->val);
2536
/* Write out a type. If the type is DEBUG_KIND_NAMED or
2537
DEBUG_KIND_TAGGED, then the name argument is the name for which we
2538
are about to call typedef or tag. If the type is anything else,
2539
then the name argument is a tag from a DEBUG_KIND_TAGGED type which
2540
points to this one. */
2543
debug_write_type (info, fns, fhandle, type, name)
2544
struct debug_handle *info;
2545
const struct debug_write_fns *fns;
2547
struct debug_type *type;
2548
struct debug_name *name;
2554
/* If we have a name for this type, just output it. We only output
2555
typedef names after they have been defined. We output type tags
2556
whenever we are not actually defining them. */
2557
if ((type->kind == DEBUG_KIND_NAMED
2558
|| type->kind == DEBUG_KIND_TAGGED)
2559
&& (type->u.knamed->name->mark == info->mark
2560
|| (type->kind == DEBUG_KIND_TAGGED
2561
&& type->u.knamed->name != name)))
2563
if (type->kind == DEBUG_KIND_NAMED)
2564
return (*fns->typedef_type) (fhandle, type->u.knamed->name->name);
2567
struct debug_type *real;
2570
real = debug_get_real_type ((PTR) info, type);
2572
if ((real->kind == DEBUG_KIND_STRUCT
2573
|| real->kind == DEBUG_KIND_UNION
2574
|| real->kind == DEBUG_KIND_CLASS
2575
|| real->kind == DEBUG_KIND_UNION_CLASS)
2576
&& real->u.kclass != NULL)
2578
if (real->u.kclass->id <= info->base_id)
2580
if (! debug_set_class_id (info,
2581
type->u.knamed->name->name,
2585
id = real->u.kclass->id;
2588
return (*fns->tag_type) (fhandle, type->u.knamed->name->name, id,
2593
/* Mark the name after we have already looked for a known name, so
2594
that we don't just define a type in terms of itself. We need to
2595
mark the name here so that a struct containing a pointer to
2596
itself will work. */
2598
name->mark = info->mark;
2602
&& type->kind != DEBUG_KIND_NAMED
2603
&& type->kind != DEBUG_KIND_TAGGED)
2605
assert (name->kind == DEBUG_OBJECT_TAG);
2611
case DEBUG_KIND_ILLEGAL:
2612
debug_error ("debug_write_type: illegal type encountered");
2614
case DEBUG_KIND_INDIRECT:
2615
if (*type->u.kindirect->slot == DEBUG_TYPE_NULL)
2616
return (*fns->empty_type) (fhandle);
2617
return debug_write_type (info, fns, fhandle, *type->u.kindirect->slot,
2619
case DEBUG_KIND_VOID:
2620
return (*fns->void_type) (fhandle);
2621
case DEBUG_KIND_INT:
2622
return (*fns->int_type) (fhandle, type->size, type->u.kint);
2623
case DEBUG_KIND_FLOAT:
2624
return (*fns->float_type) (fhandle, type->size);
2625
case DEBUG_KIND_COMPLEX:
2626
return (*fns->complex_type) (fhandle, type->size);
2627
case DEBUG_KIND_BOOL:
2628
return (*fns->bool_type) (fhandle, type->size);
2629
case DEBUG_KIND_STRUCT:
2630
case DEBUG_KIND_UNION:
2631
if (type->u.kclass != NULL)
2633
if (type->u.kclass->id <= info->base_id)
2635
if (! debug_set_class_id (info, tag, type))
2639
if (info->mark == type->u.kclass->mark)
2641
/* We are currently outputting this struct, or we have
2642
already output it. I don't know if this can happen,
2643
but it can happen for a class. */
2644
assert (type->u.kclass->id > info->base_id);
2645
return (*fns->tag_type) (fhandle, tag, type->u.kclass->id,
2648
type->u.kclass->mark = info->mark;
2651
if (! (*fns->start_struct_type) (fhandle, tag,
2652
(type->u.kclass != NULL
2653
? type->u.kclass->id
2655
type->kind == DEBUG_KIND_STRUCT,
2658
if (type->u.kclass != NULL
2659
&& type->u.kclass->fields != NULL)
2661
for (i = 0; type->u.kclass->fields[i] != NULL; i++)
2663
struct debug_field *f;
2665
f = type->u.kclass->fields[i];
2666
if (! debug_write_type (info, fns, fhandle, f->type,
2667
(struct debug_name *) NULL)
2668
|| ! (*fns->struct_field) (fhandle, f->name, f->u.f.bitpos,
2669
f->u.f.bitsize, f->visibility))
2673
return (*fns->end_struct_type) (fhandle);
2674
case DEBUG_KIND_CLASS:
2675
case DEBUG_KIND_UNION_CLASS:
2676
return debug_write_class_type (info, fns, fhandle, type, tag);
2677
case DEBUG_KIND_ENUM:
2678
if (type->u.kenum == NULL)
2679
return (*fns->enum_type) (fhandle, tag, (const char **) NULL,
2680
(bfd_signed_vma *) NULL);
2681
return (*fns->enum_type) (fhandle, tag, type->u.kenum->names,
2682
type->u.kenum->values);
2683
case DEBUG_KIND_POINTER:
2684
if (! debug_write_type (info, fns, fhandle, type->u.kpointer,
2685
(struct debug_name *) NULL))
2687
return (*fns->pointer_type) (fhandle);
2688
case DEBUG_KIND_FUNCTION:
2689
if (! debug_write_type (info, fns, fhandle,
2690
type->u.kfunction->return_type,
2691
(struct debug_name *) NULL))
2693
if (type->u.kfunction->arg_types == NULL)
2697
for (is = 0; type->u.kfunction->arg_types[is] != NULL; is++)
2698
if (! debug_write_type (info, fns, fhandle,
2699
type->u.kfunction->arg_types[is],
2700
(struct debug_name *) NULL))
2703
return (*fns->function_type) (fhandle, is,
2704
type->u.kfunction->varargs);
2705
case DEBUG_KIND_REFERENCE:
2706
if (! debug_write_type (info, fns, fhandle, type->u.kreference,
2707
(struct debug_name *) NULL))
2709
return (*fns->reference_type) (fhandle);
2710
case DEBUG_KIND_RANGE:
2711
if (! debug_write_type (info, fns, fhandle, type->u.krange->type,
2712
(struct debug_name *) NULL))
2714
return (*fns->range_type) (fhandle, type->u.krange->lower,
2715
type->u.krange->upper);
2716
case DEBUG_KIND_ARRAY:
2717
if (! debug_write_type (info, fns, fhandle, type->u.karray->element_type,
2718
(struct debug_name *) NULL)
2719
|| ! debug_write_type (info, fns, fhandle,
2720
type->u.karray->range_type,
2721
(struct debug_name *) NULL))
2723
return (*fns->array_type) (fhandle, type->u.karray->lower,
2724
type->u.karray->upper,
2725
type->u.karray->stringp);
2726
case DEBUG_KIND_SET:
2727
if (! debug_write_type (info, fns, fhandle, type->u.kset->type,
2728
(struct debug_name *) NULL))
2730
return (*fns->set_type) (fhandle, type->u.kset->bitstringp);
2731
case DEBUG_KIND_OFFSET:
2732
if (! debug_write_type (info, fns, fhandle, type->u.koffset->base_type,
2733
(struct debug_name *) NULL)
2734
|| ! debug_write_type (info, fns, fhandle,
2735
type->u.koffset->target_type,
2736
(struct debug_name *) NULL))
2738
return (*fns->offset_type) (fhandle);
2739
case DEBUG_KIND_METHOD:
2740
if (! debug_write_type (info, fns, fhandle,
2741
type->u.kmethod->return_type,
2742
(struct debug_name *) NULL))
2744
if (type->u.kmethod->arg_types == NULL)
2748
for (is = 0; type->u.kmethod->arg_types[is] != NULL; is++)
2749
if (! debug_write_type (info, fns, fhandle,
2750
type->u.kmethod->arg_types[is],
2751
(struct debug_name *) NULL))
2754
if (type->u.kmethod->domain_type != NULL)
2756
if (! debug_write_type (info, fns, fhandle,
2757
type->u.kmethod->domain_type,
2758
(struct debug_name *) NULL))
2761
return (*fns->method_type) (fhandle,
2762
type->u.kmethod->domain_type != NULL,
2764
type->u.kmethod->varargs);
2765
case DEBUG_KIND_CONST:
2766
if (! debug_write_type (info, fns, fhandle, type->u.kconst,
2767
(struct debug_name *) NULL))
2769
return (*fns->const_type) (fhandle);
2770
case DEBUG_KIND_VOLATILE:
2771
if (! debug_write_type (info, fns, fhandle, type->u.kvolatile,
2772
(struct debug_name *) NULL))
2774
return (*fns->volatile_type) (fhandle);
2775
case DEBUG_KIND_NAMED:
2776
return debug_write_type (info, fns, fhandle, type->u.knamed->type,
2777
(struct debug_name *) NULL);
2778
case DEBUG_KIND_TAGGED:
2779
return debug_write_type (info, fns, fhandle, type->u.knamed->type,
2780
type->u.knamed->name);
2787
/* Write out a class type. */
2790
debug_write_class_type (info, fns, fhandle, type, tag)
2791
struct debug_handle *info;
2792
const struct debug_write_fns *fns;
2794
struct debug_type *type;
2799
struct debug_type *vptrbase;
2801
if (type->u.kclass == NULL)
2808
if (type->u.kclass->id <= info->base_id)
2810
if (! debug_set_class_id (info, tag, type))
2814
if (info->mark == type->u.kclass->mark)
2816
/* We are currently outputting this class, or we have
2817
already output it. This can happen when there are
2818
methods for an anonymous class. */
2819
assert (type->u.kclass->id > info->base_id);
2820
return (*fns->tag_type) (fhandle, tag, type->u.kclass->id,
2823
type->u.kclass->mark = info->mark;
2824
id = type->u.kclass->id;
2826
vptrbase = type->u.kclass->vptrbase;
2827
if (vptrbase != NULL && vptrbase != type)
2829
if (! debug_write_type (info, fns, fhandle, vptrbase,
2830
(struct debug_name *) NULL))
2835
if (! (*fns->start_class_type) (fhandle, tag, id,
2836
type->kind == DEBUG_KIND_CLASS,
2842
if (type->u.kclass != NULL)
2844
if (type->u.kclass->fields != NULL)
2846
for (i = 0; type->u.kclass->fields[i] != NULL; i++)
2848
struct debug_field *f;
2850
f = type->u.kclass->fields[i];
2851
if (! debug_write_type (info, fns, fhandle, f->type,
2852
(struct debug_name *) NULL))
2854
if (f->static_member)
2856
if (! (*fns->class_static_member) (fhandle, f->name,
2863
if (! (*fns->struct_field) (fhandle, f->name, f->u.f.bitpos,
2864
f->u.f.bitsize, f->visibility))
2870
if (type->u.kclass->baseclasses != NULL)
2872
for (i = 0; type->u.kclass->baseclasses[i] != NULL; i++)
2874
struct debug_baseclass *b;
2876
b = type->u.kclass->baseclasses[i];
2877
if (! debug_write_type (info, fns, fhandle, b->type,
2878
(struct debug_name *) NULL))
2880
if (! (*fns->class_baseclass) (fhandle, b->bitpos, b->virtual,
2886
if (type->u.kclass->methods != NULL)
2888
for (i = 0; type->u.kclass->methods[i] != NULL; i++)
2890
struct debug_method *m;
2893
m = type->u.kclass->methods[i];
2894
if (! (*fns->class_start_method) (fhandle, m->name))
2896
for (j = 0; m->variants[j] != NULL; j++)
2898
struct debug_method_variant *v;
2901
if (v->context != NULL)
2903
if (! debug_write_type (info, fns, fhandle, v->context,
2904
(struct debug_name *) NULL))
2907
if (! debug_write_type (info, fns, fhandle, v->type,
2908
(struct debug_name *) NULL))
2910
if (v->voffset != VOFFSET_STATIC_METHOD)
2912
if (! (*fns->class_method_variant) (fhandle, v->physname,
2917
v->context != NULL))
2922
if (! (*fns->class_static_method_variant) (fhandle,
2930
if (! (*fns->class_end_method) (fhandle))
2936
return (*fns->end_class_type) (fhandle);
2939
/* Write out information for a function. */
2942
debug_write_function (info, fns, fhandle, name, linkage, function)
2943
struct debug_handle *info;
2944
const struct debug_write_fns *fns;
2947
enum debug_object_linkage linkage;
2948
struct debug_function *function;
2950
struct debug_parameter *p;
2951
struct debug_block *b;
2953
if (! debug_write_linenos (info, fns, fhandle, function->blocks->start))
2956
if (! debug_write_type (info, fns, fhandle, function->return_type,
2957
(struct debug_name *) NULL))
2960
if (! (*fns->start_function) (fhandle, name,
2961
linkage == DEBUG_LINKAGE_GLOBAL))
2964
for (p = function->parameters; p != NULL; p = p->next)
2966
if (! debug_write_type (info, fns, fhandle, p->type,
2967
(struct debug_name *) NULL)
2968
|| ! (*fns->function_parameter) (fhandle, p->name, p->kind, p->val))
2972
for (b = function->blocks; b != NULL; b = b->next)
2974
if (! debug_write_block (info, fns, fhandle, b))
2978
return (*fns->end_function) (fhandle);
2981
/* Write out information for a block. */
2984
debug_write_block (info, fns, fhandle, block)
2985
struct debug_handle *info;
2986
const struct debug_write_fns *fns;
2988
struct debug_block *block;
2990
struct debug_name *n;
2991
struct debug_block *b;
2993
if (! debug_write_linenos (info, fns, fhandle, block->start))
2996
/* I can't see any point to writing out a block with no local
2997
variables, so we don't bother, except for the top level block. */
2998
if (block->locals != NULL || block->parent == NULL)
3000
if (! (*fns->start_block) (fhandle, block->start))
3004
if (block->locals != NULL)
3006
for (n = block->locals->list; n != NULL; n = n->next)
3008
if (! debug_write_name (info, fns, fhandle, n))
3013
for (b = block->children; b != NULL; b = b->next)
3015
if (! debug_write_block (info, fns, fhandle, b))
3019
if (! debug_write_linenos (info, fns, fhandle, block->end))
3022
if (block->locals != NULL || block->parent == NULL)
3024
if (! (*fns->end_block) (fhandle, block->end))
3031
/* Write out line number information up to ADDRESS. */
3034
debug_write_linenos (info, fns, fhandle, address)
3035
struct debug_handle *info;
3036
const struct debug_write_fns *fns;
3040
while (info->current_write_lineno != NULL)
3042
struct debug_lineno *l;
3044
l = info->current_write_lineno;
3046
while (info->current_write_lineno_index < DEBUG_LINENO_COUNT)
3048
if (l->linenos[info->current_write_lineno_index]
3049
== (unsigned long) -1)
3052
if (l->addrs[info->current_write_lineno_index] >= address)
3055
if (! (*fns->lineno) (fhandle, l->file->filename,
3056
l->linenos[info->current_write_lineno_index],
3057
l->addrs[info->current_write_lineno_index]))
3060
++info->current_write_lineno_index;
3063
info->current_write_lineno = l->next;
3064
info->current_write_lineno_index = 0;
3070
/* Get the ID number for a class. If during the same call to
3071
debug_write we find a struct with the same definition with the same
3072
name, we use the same ID. This type of things happens because the
3073
same struct will be defined by multiple compilation units. */
3076
debug_set_class_id (info, tag, type)
3077
struct debug_handle *info;
3079
struct debug_type *type;
3081
struct debug_class_type *c;
3082
struct debug_class_id *l;
3084
assert (type->kind == DEBUG_KIND_STRUCT
3085
|| type->kind == DEBUG_KIND_UNION
3086
|| type->kind == DEBUG_KIND_CLASS
3087
|| type->kind == DEBUG_KIND_UNION_CLASS);
3091
if (c->id > info->base_id)
3094
for (l = info->id_list; l != NULL; l = l->next)
3096
if (l->type->kind != type->kind)
3107
|| l->tag[0] != tag[0]
3108
|| strcmp (l->tag, tag) != 0)
3112
if (debug_type_samep (info, l->type, type))
3114
c->id = l->type->u.kclass->id;
3119
/* There are no identical types. Use a new ID, and add it to the
3122
c->id = info->class_id;
3124
l = (struct debug_class_id *) xmalloc (sizeof *l);
3125
memset (l, 0, sizeof *l);
3130
l->next = info->id_list;
3136
/* See if two types are the same. At this point, we don't care about
3137
tags and the like. */
3140
debug_type_samep (info, t1, t2)
3141
struct debug_handle *info;
3142
struct debug_type *t1;
3143
struct debug_type *t2;
3145
struct debug_type_compare_list *l;
3146
struct debug_type_compare_list top;
3154
while (t1->kind == DEBUG_KIND_INDIRECT)
3156
t1 = *t1->u.kindirect->slot;
3160
while (t2->kind == DEBUG_KIND_INDIRECT)
3162
t2 = *t2->u.kindirect->slot;
3170
/* As a special case, permit a typedef to match a tag, since C++
3171
debugging output will sometimes add a typedef where C debugging
3173
if (t1->kind == DEBUG_KIND_NAMED
3174
&& t2->kind == DEBUG_KIND_TAGGED)
3175
return debug_type_samep (info, t1->u.knamed->type, t2);
3176
else if (t1->kind == DEBUG_KIND_TAGGED
3177
&& t2->kind == DEBUG_KIND_NAMED)
3178
return debug_type_samep (info, t1, t2->u.knamed->type);
3180
if (t1->kind != t2->kind
3181
|| t1->size != t2->size)
3184
/* Get rid of the trivial cases first. */
3189
case DEBUG_KIND_VOID:
3190
case DEBUG_KIND_FLOAT:
3191
case DEBUG_KIND_COMPLEX:
3192
case DEBUG_KIND_BOOL:
3194
case DEBUG_KIND_INT:
3195
return t1->u.kint == t2->u.kint;
3198
/* We have to avoid an infinite recursion. We do this by keeping a
3199
list of types which we are comparing. We just keep the list on
3200
the stack. If we encounter a pair of types we are currently
3201
comparing, we just assume that they are equal. */
3202
for (l = info->compare_list; l != NULL; l = l->next)
3204
if (l->t1 == t1 && l->t2 == t2)
3210
top.next = info->compare_list;
3211
info->compare_list = ⊤
3220
case DEBUG_KIND_STRUCT:
3221
case DEBUG_KIND_UNION:
3222
case DEBUG_KIND_CLASS:
3223
case DEBUG_KIND_UNION_CLASS:
3224
if (t1->u.kclass == NULL)
3225
ret = t2->u.kclass == NULL;
3226
else if (t2->u.kclass == NULL)
3228
else if (t1->u.kclass->id > info->base_id
3229
&& t1->u.kclass->id == t2->u.kclass->id)
3232
ret = debug_class_type_samep (info, t1, t2);
3235
case DEBUG_KIND_ENUM:
3236
if (t1->u.kenum == NULL)
3237
ret = t2->u.kenum == NULL;
3238
else if (t2->u.kenum == NULL)
3242
const char **pn1, **pn2;
3243
bfd_signed_vma *pv1, *pv2;
3245
pn1 = t1->u.kenum->names;
3246
pn2 = t2->u.kenum->names;
3247
pv1 = t1->u.kenum->values;
3248
pv2 = t2->u.kenum->values;
3249
while (*pn1 != NULL && *pn2 != NULL)
3253
|| strcmp (*pn1, *pn2) != 0)
3260
ret = *pn1 == NULL && *pn2 == NULL;
3264
case DEBUG_KIND_POINTER:
3265
ret = debug_type_samep (info, t1->u.kpointer, t2->u.kpointer);
3268
case DEBUG_KIND_FUNCTION:
3269
if (t1->u.kfunction->varargs != t2->u.kfunction->varargs
3270
|| ! debug_type_samep (info, t1->u.kfunction->return_type,
3271
t2->u.kfunction->return_type)
3272
|| ((t1->u.kfunction->arg_types == NULL)
3273
!= (t2->u.kfunction->arg_types == NULL)))
3275
else if (t1->u.kfunction->arg_types == NULL)
3279
struct debug_type **a1, **a2;
3281
a1 = t1->u.kfunction->arg_types;
3282
a2 = t2->u.kfunction->arg_types;
3283
while (*a1 != NULL && *a2 != NULL)
3284
if (! debug_type_samep (info, *a1, *a2))
3286
ret = *a1 == NULL && *a2 == NULL;
3290
case DEBUG_KIND_REFERENCE:
3291
ret = debug_type_samep (info, t1->u.kreference, t2->u.kreference);
3294
case DEBUG_KIND_RANGE:
3295
ret = (t1->u.krange->lower == t2->u.krange->lower
3296
&& t1->u.krange->upper == t2->u.krange->upper
3297
&& debug_type_samep (info, t1->u.krange->type,
3298
t2->u.krange->type));
3300
case DEBUG_KIND_ARRAY:
3301
ret = (t1->u.karray->lower == t2->u.karray->lower
3302
&& t1->u.karray->upper == t2->u.karray->upper
3303
&& t1->u.karray->stringp == t2->u.karray->stringp
3304
&& debug_type_samep (info, t1->u.karray->element_type,
3305
t2->u.karray->element_type));
3308
case DEBUG_KIND_SET:
3309
ret = (t1->u.kset->bitstringp == t2->u.kset->bitstringp
3310
&& debug_type_samep (info, t1->u.kset->type, t2->u.kset->type));
3313
case DEBUG_KIND_OFFSET:
3314
ret = (debug_type_samep (info, t1->u.koffset->base_type,
3315
t2->u.koffset->base_type)
3316
&& debug_type_samep (info, t1->u.koffset->target_type,
3317
t2->u.koffset->target_type));
3320
case DEBUG_KIND_METHOD:
3321
if (t1->u.kmethod->varargs != t2->u.kmethod->varargs
3322
|| ! debug_type_samep (info, t1->u.kmethod->return_type,
3323
t2->u.kmethod->return_type)
3324
|| ! debug_type_samep (info, t1->u.kmethod->domain_type,
3325
t2->u.kmethod->domain_type)
3326
|| ((t1->u.kmethod->arg_types == NULL)
3327
!= (t2->u.kmethod->arg_types == NULL)))
3329
else if (t1->u.kmethod->arg_types == NULL)
3333
struct debug_type **a1, **a2;
3335
a1 = t1->u.kmethod->arg_types;
3336
a2 = t2->u.kmethod->arg_types;
3337
while (*a1 != NULL && *a2 != NULL)
3338
if (! debug_type_samep (info, *a1, *a2))
3340
ret = *a1 == NULL && *a2 == NULL;
3344
case DEBUG_KIND_CONST:
3345
ret = debug_type_samep (info, t1->u.kconst, t2->u.kconst);
3348
case DEBUG_KIND_VOLATILE:
3349
ret = debug_type_samep (info, t1->u.kvolatile, t2->u.kvolatile);
3352
case DEBUG_KIND_NAMED:
3353
case DEBUG_KIND_TAGGED:
3354
ret = (strcmp (t1->u.knamed->name->name, t2->u.knamed->name->name) == 0
3355
&& debug_type_samep (info, t1->u.knamed->type,
3356
t2->u.knamed->type));
3360
info->compare_list = top.next;
3365
/* See if two classes are the same. This is a subroutine of
3366
debug_type_samep. */
3369
debug_class_type_samep (info, t1, t2)
3370
struct debug_handle *info;
3371
struct debug_type *t1;
3372
struct debug_type *t2;
3374
struct debug_class_type *c1, *c2;
3379
if ((c1->fields == NULL) != (c2->fields == NULL)
3380
|| (c1->baseclasses == NULL) != (c2->baseclasses == NULL)
3381
|| (c1->methods == NULL) != (c2->methods == NULL)
3382
|| (c1->vptrbase == NULL) != (c2->vptrbase == NULL))
3385
if (c1->fields != NULL)
3387
struct debug_field **pf1, **pf2;
3389
for (pf1 = c1->fields, pf2 = c2->fields;
3390
*pf1 != NULL && *pf2 != NULL;
3393
struct debug_field *f1, *f2;
3397
if (f1->name[0] != f2->name[0]
3398
|| f1->visibility != f2->visibility
3399
|| f1->static_member != f2->static_member)
3401
if (f1->static_member)
3403
if (strcmp (f1->u.s.physname, f2->u.s.physname) != 0)
3408
if (f1->u.f.bitpos != f2->u.f.bitpos
3409
|| f1->u.f.bitsize != f2->u.f.bitsize)
3412
/* We do the checks which require function calls last. We
3413
don't require that the types of fields have the same
3414
names, since that sometimes fails in the presence of
3415
typedefs and we really don't care. */
3416
if (strcmp (f1->name, f2->name) != 0
3417
|| ! debug_type_samep (info,
3418
debug_get_real_type ((PTR) info,
3420
debug_get_real_type ((PTR) info,
3424
if (*pf1 != NULL || *pf2 != NULL)
3428
if (c1->vptrbase != NULL)
3430
if (! debug_type_samep (info, c1->vptrbase, c2->vptrbase))
3434
if (c1->baseclasses != NULL)
3436
struct debug_baseclass **pb1, **pb2;
3438
for (pb1 = c1->baseclasses, pb2 = c2->baseclasses;
3439
*pb1 != NULL && *pb2 != NULL;
3442
struct debug_baseclass *b1, *b2;
3446
if (b1->bitpos != b2->bitpos
3447
|| b1->virtual != b2->virtual
3448
|| b1->visibility != b2->visibility
3449
|| ! debug_type_samep (info, b1->type, b2->type))
3452
if (*pb1 != NULL || *pb2 != NULL)
3456
if (c1->methods != NULL)
3458
struct debug_method **pm1, **pm2;
3460
for (pm1 = c1->methods, pm2 = c2->methods;
3461
*pm1 != NULL && *pm2 != NULL;
3464
struct debug_method *m1, *m2;
3468
if (m1->name[0] != m2->name[0]
3469
|| strcmp (m1->name, m2->name) != 0
3470
|| (m1->variants == NULL) != (m2->variants == NULL))
3472
if (m1->variants == NULL)
3474
struct debug_method_variant **pv1, **pv2;
3476
for (pv1 = m1->variants, pv2 = m2->variants;
3477
*pv1 != NULL && *pv2 != NULL;
3480
struct debug_method_variant *v1, *v2;
3484
if (v1->physname[0] != v2->physname[0]
3485
|| v1->visibility != v2->visibility
3486
|| v1->constp != v2->constp
3487
|| v1->volatilep != v2->volatilep
3488
|| v1->voffset != v2->voffset
3489
|| (v1->context == NULL) != (v2->context == NULL)
3490
|| strcmp (v1->physname, v2->physname) != 0
3491
|| ! debug_type_samep (info, v1->type, v2->type))
3493
if (v1->context != NULL)
3495
if (! debug_type_samep (info, v1->context,
3500
if (*pv1 != NULL || *pv2 != NULL)
3504
if (*pm1 != NULL || *pm2 != NULL)