1 /* stabs.c -- Parse stabs debugging information
2 Copyright (C) 1995, 1996, 1997, 1998 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 contains code which parses stabs debugging information.
23 The organization of this code is based on the gdb stabs reading
24 code. The job it does is somewhat different, because it is not
25 trying to identify the correct address for anything. */
32 #include "libiberty.h"
37 /* Meaningless definition needs by aout64.h. FIXME. */
38 #define BYTES_IN_WORD 4
40 #include "aout/aout64.h"
41 #include "aout/stab_gnu.h"
44 #define DIR_SEPARATOR '/'
47 /* The number of predefined XCOFF types. */
49 #define XCOFF_TYPE_COUNT 34
51 /* This structure is used as a handle so that the stab parsing doesn't
52 need to use any static variables. */
58 /* True if this is stabs in sections. */
60 /* The symbol table. */
62 /* The number of symbols. */
64 /* The accumulated file name string. */
66 /* The value of the last N_SO symbol. */
68 /* The value of the start of the file, so that we can handle file
69 relative N_LBRAC and N_RBRAC symbols. */
70 bfd_vma file_start_offset;
71 /* The offset of the start of the function, so that we can handle
72 function relative N_LBRAC and N_RBRAC symbols. */
73 bfd_vma function_start_offset;
74 /* The version number of gcc which compiled the current compilation
75 unit, 0 if not compiled by gcc. */
77 /* Whether an N_OPT symbol was seen that was not generated by gcc,
78 so that we can detect the SunPRO compiler. */
80 /* The main file name. */
82 /* A stack of unfinished N_BINCL files. */
83 struct bincl_file *bincl_stack;
84 /* A list of finished N_BINCL files. */
85 struct bincl_file *bincl_list;
86 /* Whether we are inside a function or not. */
87 boolean within_function;
88 /* The address of the end of the function, used if we have seen an
89 N_FUN symbol while in a function. This is -1 if we have not seen
90 an N_FUN (the normal case). */
92 /* The depth of block nesting. */
94 /* List of pending variable definitions. */
95 struct stab_pending_var *pending;
96 /* Number of files for which we have types. */
98 /* Lists of types per file. */
99 struct stab_types **file_types;
100 /* Predefined XCOFF types. */
101 debug_type xcoff_types[XCOFF_TYPE_COUNT];
102 /* Undefined tags. */
103 struct stab_tag *tags;
104 /* Set by parse_stab_type if it sees a structure defined as a cross
105 reference to itself. Reset by parse_stab_type otherwise. */
106 boolean self_crossref;
109 /* A list of these structures is used to hold pending variable
110 definitions seen before the N_LBRAC of a block. */
112 struct stab_pending_var
114 /* Next pending variable definition. */
115 struct stab_pending_var *next;
121 enum debug_var_kind kind;
126 /* A list of these structures is used to hold the types for a single
131 /* Next set of slots for this file. */
132 struct stab_types *next;
133 /* Types indexed by type number. */
134 #define STAB_TYPES_SLOTS (16)
135 debug_type types[STAB_TYPES_SLOTS];
138 /* We keep a list of undefined tags that we encounter, so that we can
139 fill them in if the tag is later defined. */
143 /* Next undefined tag. */
144 struct stab_tag *next;
148 enum debug_type_kind kind;
149 /* Slot to hold real type when we discover it. If we don't, we fill
150 in an undefined tag type. */
152 /* Indirect type we have created to point at slot. */
156 static char *savestring PARAMS ((const char *, int));
157 static bfd_vma parse_number PARAMS ((const char **, boolean *));
158 static void bad_stab PARAMS ((const char *));
159 static void warn_stab PARAMS ((const char *, const char *));
160 static boolean parse_stab_string
161 PARAMS ((PTR, struct stab_handle *, int, int, bfd_vma, const char *));
162 static debug_type parse_stab_type
163 PARAMS ((PTR, struct stab_handle *, const char *, const char **,
165 static boolean parse_stab_type_number
166 PARAMS ((const char **, int *));
167 static debug_type parse_stab_range_type
168 PARAMS ((PTR, struct stab_handle *, const char *, const char **,
170 static debug_type parse_stab_sun_builtin_type PARAMS ((PTR, const char **));
171 static debug_type parse_stab_sun_floating_type
172 PARAMS ((PTR, const char **));
173 static debug_type parse_stab_enum_type PARAMS ((PTR, const char **));
174 static debug_type parse_stab_struct_type
175 PARAMS ((PTR, struct stab_handle *, const char *, const char **, boolean,
177 static boolean parse_stab_baseclasses
178 PARAMS ((PTR, struct stab_handle *, const char **, debug_baseclass **));
179 static boolean parse_stab_struct_fields
180 PARAMS ((PTR, struct stab_handle *, const char **, debug_field **,
182 static boolean parse_stab_cpp_abbrev
183 PARAMS ((PTR, struct stab_handle *, const char **, debug_field *));
184 static boolean parse_stab_one_struct_field
185 PARAMS ((PTR, struct stab_handle *, const char **, const char *,
186 debug_field *, boolean *));
187 static boolean parse_stab_members
188 PARAMS ((PTR, struct stab_handle *, const char *, const char **,
189 const int *, debug_method **));
190 static debug_type parse_stab_argtypes
191 PARAMS ((PTR, struct stab_handle *, debug_type, const char *, const char *,
192 debug_type, const char *, boolean, boolean, const char **));
193 static boolean parse_stab_tilde_field
194 PARAMS ((PTR, struct stab_handle *, const char **, const int *,
195 debug_type *, boolean *));
196 static debug_type parse_stab_array_type
197 PARAMS ((PTR, struct stab_handle *, const char **, boolean));
198 static void push_bincl PARAMS ((struct stab_handle *, const char *, bfd_vma));
199 static const char *pop_bincl PARAMS ((struct stab_handle *));
200 static boolean find_excl
201 PARAMS ((struct stab_handle *, const char *, bfd_vma));
202 static boolean stab_record_variable
203 PARAMS ((PTR, struct stab_handle *, const char *, debug_type,
204 enum debug_var_kind, bfd_vma));
205 static boolean stab_emit_pending_vars PARAMS ((PTR, struct stab_handle *));
206 static debug_type *stab_find_slot
207 PARAMS ((struct stab_handle *, const int *));
208 static debug_type stab_find_type
209 PARAMS ((PTR, struct stab_handle *, const int *));
210 static boolean stab_record_type
211 PARAMS ((PTR, struct stab_handle *, const int *, debug_type));
212 static debug_type stab_xcoff_builtin_type
213 PARAMS ((PTR, struct stab_handle *, int));
214 static debug_type stab_find_tagged_type
215 PARAMS ((PTR, struct stab_handle *, const char *, int,
216 enum debug_type_kind));
217 static debug_type *stab_demangle_argtypes
218 PARAMS ((PTR, struct stab_handle *, const char *, boolean *));
220 /* Save a string in memory. */
223 savestring (start, len)
229 ret = (char *) xmalloc (len + 1);
230 memcpy (ret, start, len);
235 /* Read a number from a string. */
238 parse_number (pp, poverflow)
245 if (poverflow != NULL)
251 ul = strtoul (*pp, (char **) pp, 0);
252 if (ul + 1 != 0 || errno == 0)
254 /* If bfd_vma is larger than unsigned long, and the number is
255 meant to be negative, we have to make sure that we sign
258 return (bfd_vma) (bfd_signed_vma) (long) ul;
262 /* Note that even though strtoul overflowed, it should have set *pp
263 to the end of the number, which is where we want it. */
265 if (sizeof (bfd_vma) > sizeof (unsigned long))
270 bfd_vma over, lastdig;
274 /* Our own version of strtoul, for a bfd_vma. */
290 if (p[1] == 'x' || p[1] == 'X')
302 over = ((bfd_vma) (bfd_signed_vma) -1) / (bfd_vma) base;
303 lastdig = ((bfd_vma) (bfd_signed_vma) -1) % (bfd_vma) base;
312 if (isdigit ((unsigned char) d))
314 else if (isupper ((unsigned char) d))
316 else if (islower ((unsigned char) d))
324 if (v > over || (v == over && (bfd_vma) d > lastdig))
339 /* If we get here, the number is too large to represent in a
342 if (poverflow != NULL)
345 warn_stab (orig, _("numeric overflow"));
350 /* Give an error for a bad stab string. */
356 fprintf (stderr, _("Bad stab: %s\n"), p);
359 /* Warn about something in a stab string. */
366 fprintf (stderr, _("Warning: %s: %s\n"), err, p);
369 /* Create a handle to parse stabs symbols with. */
373 start_stab (dhandle, abfd, sections, syms, symcount)
380 struct stab_handle *ret;
382 ret = (struct stab_handle *) xmalloc (sizeof *ret);
383 memset (ret, 0, sizeof *ret);
385 ret->sections = sections;
387 ret->symcount = symcount;
389 ret->file_types = (struct stab_types **) xmalloc (sizeof *ret->file_types);
390 ret->file_types[0] = NULL;
391 ret->function_end = (bfd_vma) -1;
395 /* When we have processed all the stabs information, we need to go
396 through and fill in all the undefined tags. */
399 finish_stab (dhandle, handle)
403 struct stab_handle *info = (struct stab_handle *) handle;
406 if (info->within_function)
408 if (! stab_emit_pending_vars (dhandle, info)
409 || ! debug_end_function (dhandle, info->function_end))
411 info->within_function = false;
412 info->function_end = (bfd_vma) -1;
415 for (st = info->tags; st != NULL; st = st->next)
417 enum debug_type_kind kind;
420 if (kind == DEBUG_KIND_ILLEGAL)
421 kind = DEBUG_KIND_STRUCT;
422 st->slot = debug_make_undefined_tagged_type (dhandle, st->name, kind);
423 if (st->slot == DEBUG_TYPE_NULL)
430 /* Handle a single stabs symbol. */
433 parse_stab (dhandle, handle, type, desc, value, string)
441 struct stab_handle *info = (struct stab_handle *) handle;
443 /* gcc will emit two N_SO strings per compilation unit, one for the
444 directory name and one for the file name. We just collect N_SO
445 strings as we see them, and start the new compilation unit when
446 we see a non N_SO symbol. */
447 if (info->so_string != NULL
448 && (type != N_SO || *string == '\0' || value != info->so_value))
450 if (! debug_set_filename (dhandle, info->so_string))
452 info->main_filename = info->so_string;
454 info->gcc_compiled = 0;
455 info->n_opt_found = false;
457 /* Generally, for stabs in the symbol table, the N_LBRAC and
458 N_RBRAC symbols are relative to the N_SO symbol value. */
459 if (! info->sections)
460 info->file_start_offset = info->so_value;
462 /* We need to reset the mapping from type numbers to types. We
463 can't free the old mapping, because of the use of
464 debug_make_indirect_type. */
466 info->file_types = ((struct stab_types **)
467 xmalloc (sizeof *info->file_types));
468 info->file_types[0] = NULL;
470 info->so_string = NULL;
472 /* Now process whatever type we just got. */
482 /* Ignore extra outermost context from SunPRO cc and acc. */
483 if (info->n_opt_found && desc == 1)
486 if (! info->within_function)
488 fprintf (stderr, _("N_LBRAC not within function\n"));
492 /* Start an inner lexical block. */
493 if (! debug_start_block (dhandle,
495 + info->file_start_offset
496 + info->function_start_offset)))
499 /* Emit any pending variable definitions. */
500 if (! stab_emit_pending_vars (dhandle, info))
507 /* Ignore extra outermost context from SunPRO cc and acc. */
508 if (info->n_opt_found && desc == 1)
511 /* We shouldn't have any pending variable definitions here, but,
512 if we do, we probably need to emit them before closing the
514 if (! stab_emit_pending_vars (dhandle, info))
517 /* End an inner lexical block. */
518 if (! debug_end_block (dhandle,
520 + info->file_start_offset
521 + info->function_start_offset)))
525 if (info->block_depth < 0)
527 fprintf (stderr, _("Too many N_RBRACs\n"));
533 /* This always ends a function. */
534 if (info->within_function)
540 && info->function_end != (bfd_vma) -1
541 && info->function_end < endval)
542 endval = info->function_end;
543 if (! stab_emit_pending_vars (dhandle, info)
544 || ! debug_end_function (dhandle, endval))
546 info->within_function = false;
547 info->function_end = (bfd_vma) -1;
550 /* An empty string is emitted by gcc at the end of a compilation
555 /* Just accumulate strings until we see a non N_SO symbol. If
556 the string starts with a directory separator or some other
557 form of absolute path specification, we discard the previously
558 accumulated strings. */
559 if (info->so_string == NULL)
560 info->so_string = xstrdup (string);
567 if ( (string[0] == '/')
568 || (string[0] == DIR_SEPARATOR)
569 || ( (DIR_SEPARATOR == '\\')
570 && (string[1] == ':')
571 && ( (string[2] == DIR_SEPARATOR)
572 || (string[2] == '/'))))
573 info->so_string = xstrdup (string);
575 info->so_string = concat (info->so_string, string,
576 (const char *) NULL);
580 info->so_value = value;
585 /* Start an include file. */
586 if (! debug_start_source (dhandle, string))
591 /* Start an include file which may be replaced. */
592 push_bincl (info, string, value);
593 if (! debug_start_source (dhandle, string))
598 /* End an N_BINCL include. */
599 if (! debug_start_source (dhandle, pop_bincl (info)))
604 /* This is a duplicate of a header file named by N_BINCL which
605 was eliminated by the linker. */
606 if (! find_excl (info, string, value))
611 if (! debug_record_line (dhandle, desc,
612 value + info->function_start_offset))
617 if (! debug_start_common_block (dhandle, string))
622 if (! debug_end_common_block (dhandle, string))
629 if (info->within_function)
631 /* This always marks the end of a function; we don't
632 need to worry about info->function_end. */
634 value += info->function_start_offset;
635 if (! stab_emit_pending_vars (dhandle, info)
636 || ! debug_end_function (dhandle, value))
638 info->within_function = false;
639 info->function_end = (bfd_vma) -1;
644 /* A const static symbol in the .text section will have an N_FUN
645 entry. We need to use these to mark the end of the function,
646 in case we are looking at gcc output before it was changed to
647 always emit an empty N_FUN. We can't call debug_end_function
648 here, because it might be a local static symbol. */
649 if (info->within_function
650 && (info->function_end == (bfd_vma) -1
651 || value < info->function_end))
652 info->function_end = value;
655 /* FIXME: gdb checks the string for N_STSYM, N_LCSYM or N_ROSYM
656 symbols, and if it does not start with :S, gdb relocates the
657 value to the start of the section. gcc always seems to use
658 :S, so we don't worry about this. */
664 colon = strchr (string, ':');
666 && (colon[1] == 'f' || colon[1] == 'F'))
668 if (info->within_function)
673 if (info->function_end != (bfd_vma) -1
674 && info->function_end < endval)
675 endval = info->function_end;
676 if (! stab_emit_pending_vars (dhandle, info)
677 || ! debug_end_function (dhandle, endval))
679 info->function_end = (bfd_vma) -1;
681 /* For stabs in sections, line numbers and block addresses
682 are offsets from the start of the function. */
684 info->function_start_offset = value;
685 info->within_function = true;
688 if (! parse_stab_string (dhandle, info, type, desc, value, string))
694 if (string != NULL && strcmp (string, "gcc2_compiled.") == 0)
695 info->gcc_compiled = 2;
696 else if (string != NULL && strcmp (string, "gcc_compiled.") == 0)
697 info->gcc_compiled = 1;
699 info->n_opt_found = true;
711 /* Parse the stabs string. */
714 parse_stab_string (dhandle, info, stabtype, desc, value, string)
716 struct stab_handle *info;
727 boolean self_crossref;
731 p = strchr (string, ':');
746 /* GCC 2.x puts the line number in desc. SunOS apparently puts in
747 the number of bytes occupied by a type or object, which we
749 if (info->gcc_compiled >= 2)
754 /* FIXME: Sometimes the special C++ names start with '.'. */
756 if (string[0] == '$')
764 /* Was: name = "vptr"; */
770 /* This was an anonymous type that was never fixed up. */
773 /* SunPRO (3.0 at least) static variable encoding. */
776 warn_stab (string, _("unknown C++ encoded name"));
783 if (p == string || (string[0] == ' ' && p == string + 1))
786 name = savestring (string, p - string);
790 if (isdigit ((unsigned char) *p) || *p == '(' || *p == '-')
798 /* c is a special case, not followed by a type-number.
799 SYMBOL:c=iVALUE for an integer constant symbol.
800 SYMBOL:c=rVALUE for a floating constant symbol.
801 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
802 e.g. "b:c=e6,0" for "const b = blob1"
803 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
813 /* Floating point constant. */
814 if (! debug_record_float_const (dhandle, name, atof (p)))
818 /* Integer constant. */
819 /* Defining integer constants this way is kind of silly,
820 since 'e' constants allows the compiler to give not only
821 the value, but the type as well. C has at least int,
822 long, unsigned int, and long long as constant types;
823 other languages probably should have at least unsigned as
824 well as signed constants. */
825 if (! debug_record_int_const (dhandle, name, atoi (p)))
829 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
830 can be represented as integral.
831 e.g. "b:c=e6,0" for "const b = blob1"
832 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
833 dtype = parse_stab_type (dhandle, info, (const char *) NULL,
834 &p, (debug_type **) NULL);
835 if (dtype == DEBUG_TYPE_NULL)
842 if (! debug_record_typed_const (dhandle, name, dtype, atoi (p)))
853 /* The name of a caught exception. */
854 dtype = parse_stab_type (dhandle, info, (const char *) NULL,
855 &p, (debug_type **) NULL);
856 if (dtype == DEBUG_TYPE_NULL)
858 if (! debug_record_label (dhandle, name, dtype, value))
864 /* A function definition. */
865 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
866 (debug_type **) NULL);
867 if (dtype == DEBUG_TYPE_NULL)
869 if (! debug_record_function (dhandle, name, dtype, type == 'F', value))
872 /* Sun acc puts declared types of arguments here. We don't care
873 about their actual types (FIXME -- we should remember the whole
874 function prototype), but the list may define some new types
875 that we have to remember, so we must scan it now. */
879 if (parse_stab_type (dhandle, info, (const char *) NULL, &p,
880 (debug_type **) NULL)
893 /* A global symbol. The value must be extracted from the
895 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
896 (debug_type **) NULL);
897 if (dtype == DEBUG_TYPE_NULL)
899 leading = bfd_get_symbol_leading_char (info->abfd);
900 for (c = info->symcount, ps = info->syms; c > 0; --c, ++ps)
904 n = bfd_asymbol_name (*ps);
905 if (leading != '\0' && *n == leading)
907 if (*n == *name && strcmp (n, name) == 0)
911 value = bfd_asymbol_value (*ps);
912 if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_GLOBAL,
918 /* This case is faked by a conditional above, when there is no
919 code letter in the dbx data. Dbx data never actually
923 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
924 (debug_type **) NULL);
925 if (dtype == DEBUG_TYPE_NULL)
927 if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_LOCAL,
933 /* A function parameter. */
935 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
936 (debug_type **) NULL);
939 /* pF is a two-letter code that means a function parameter in
940 Fortran. The type-number specifies the type of the return
941 value. Translate it into a pointer-to-function type. */
943 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
944 (debug_type **) NULL);
945 if (dtype != DEBUG_TYPE_NULL)
949 ftype = debug_make_function_type (dhandle, dtype,
950 (debug_type *) NULL, false);
951 dtype = debug_make_pointer_type (dhandle, ftype);
954 if (dtype == DEBUG_TYPE_NULL)
956 if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_STACK,
960 /* FIXME: At this point gdb considers rearranging the parameter
961 address on a big endian machine if it is smaller than an int.
962 We have no way to do that, since we don't really know much
968 if (stabtype == N_FUN)
970 /* Prototype of a function referenced by this file. */
974 if (parse_stab_type (dhandle, info, (const char *) NULL, &p,
975 (debug_type **) NULL)
983 /* Parameter which is in a register. */
984 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
985 (debug_type **) NULL);
986 if (dtype == DEBUG_TYPE_NULL)
988 if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_REG,
994 /* Register variable (either global or local). */
995 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
996 (debug_type **) NULL);
997 if (dtype == DEBUG_TYPE_NULL)
999 if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_REGISTER,
1003 /* FIXME: At this point gdb checks to combine pairs of 'p' and
1004 'r' stabs into a single 'P' stab. */
1009 /* Static symbol at top level of file */
1010 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
1011 (debug_type **) NULL);
1012 if (dtype == DEBUG_TYPE_NULL)
1014 if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_STATIC,
1021 dtype = parse_stab_type (dhandle, info, name, &p, &slot);
1022 if (dtype == DEBUG_TYPE_NULL)
1026 /* A nameless type. Nothing to do. */
1030 dtype = debug_name_type (dhandle, name, dtype);
1031 if (dtype == DEBUG_TYPE_NULL)
1040 /* Struct, union, or enum tag. For GNU C++, this can be be followed
1041 by 't' which means we are typedef'ing it as well. */
1045 /* FIXME: gdb sets synonym to true if the current language
1054 dtype = parse_stab_type (dhandle, info, name, &p, &slot);
1055 if (dtype == DEBUG_TYPE_NULL)
1060 /* INFO->SELF_CROSSREF is set by parse_stab_type if this type is
1061 a cross reference to itself. These are generated by some
1063 self_crossref = info->self_crossref;
1065 dtype = debug_tag_type (dhandle, name, dtype);
1066 if (dtype == DEBUG_TYPE_NULL)
1071 /* See if we have a cross reference to this tag which we can now
1072 fill in. Avoid filling in a cross reference to ourselves,
1073 because that would lead to circular debugging information. */
1074 if (! self_crossref)
1076 register struct stab_tag **pst;
1078 for (pst = &info->tags; *pst != NULL; pst = &(*pst)->next)
1080 if ((*pst)->name[0] == name[0]
1081 && strcmp ((*pst)->name, name) == 0)
1083 (*pst)->slot = dtype;
1084 *pst = (*pst)->next;
1092 dtype = debug_name_type (dhandle, name, dtype);
1093 if (dtype == DEBUG_TYPE_NULL)
1103 /* Static symbol of local scope */
1104 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
1105 (debug_type **) NULL);
1106 if (dtype == DEBUG_TYPE_NULL)
1108 /* FIXME: gdb checks os9k_stabs here. */
1109 if (! stab_record_variable (dhandle, info, name, dtype,
1110 DEBUG_LOCAL_STATIC, value))
1115 /* Reference parameter. */
1116 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
1117 (debug_type **) NULL);
1118 if (dtype == DEBUG_TYPE_NULL)
1120 if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_REFERENCE,
1126 /* Reference parameter which is in a register. */
1127 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
1128 (debug_type **) NULL);
1129 if (dtype == DEBUG_TYPE_NULL)
1131 if (! debug_record_parameter (dhandle, name, dtype, DEBUG_PARM_REF_REG,
1137 /* This is used by Sun FORTRAN for "function result value".
1138 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
1139 that Pascal uses it too, but when I tried it Pascal used
1140 "x:3" (local symbol) instead. */
1141 dtype = parse_stab_type (dhandle, info, (const char *) NULL, &p,
1142 (debug_type **) NULL);
1143 if (dtype == DEBUG_TYPE_NULL)
1145 if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_LOCAL,
1155 /* FIXME: gdb converts structure values to structure pointers in a
1156 couple of cases, depending upon the target. */
1161 /* Parse a stabs type. The typename argument is non-NULL if this is a
1162 typedef or a tag definition. The pp argument points to the stab
1163 string, and is updated. The slotp argument points to a place to
1164 store the slot used if the type is being defined. */
1167 parse_stab_type (dhandle, info, typename, pp, slotp)
1169 struct stab_handle *info;
1170 const char *typename;
1189 info->self_crossref = false;
1191 /* Read type number if present. The type number may be omitted.
1192 for instance in a two-dimensional array declared with type
1193 "ar1;1;10;ar1;1;10;4". */
1194 if (! isdigit ((unsigned char) **pp) && **pp != '(' && **pp != '-')
1196 /* 'typenums=' not present, type is anonymous. Read and return
1197 the definition, but don't put it in the type vector. */
1198 typenums[0] = typenums[1] = -1;
1202 if (! parse_stab_type_number (pp, typenums))
1203 return DEBUG_TYPE_NULL;
1207 /* Type is not being defined here. Either it already
1208 exists, or this is a forward reference to it. */
1209 return stab_find_type (dhandle, info, typenums);
1212 /* Only set the slot if the type is being defined. This means
1213 that the mapping from type numbers to types will only record
1214 the name of the typedef which defines a type. If we don't do
1215 this, then something like
1218 will record that i is of type foo. Unfortunately, stabs
1219 information is ambiguous about variable types. For this code,
1223 the stabs information records both i and j as having the same
1224 type. This could be fixed by patching the compiler. */
1225 if (slotp != NULL && typenums[0] >= 0 && typenums[1] >= 0)
1226 *slotp = stab_find_slot (info, typenums);
1228 /* Type is being defined here. */
1234 const char *p = *pp + 1;
1237 if (isdigit ((unsigned char) *p) || *p == '(' || *p == '-')
1243 /* Type attributes. */
1246 for (; *p != ';'; ++p)
1251 return DEBUG_TYPE_NULL;
1259 size = atoi (attr + 1);
1269 /* Ignore unrecognized type attributes, so future
1270 compilers can invent new ones. */
1283 enum debug_type_kind code;
1284 const char *q1, *q2, *p;
1286 /* A cross reference to another type. */
1291 code = DEBUG_KIND_STRUCT;
1294 code = DEBUG_KIND_UNION;
1297 code = DEBUG_KIND_ENUM;
1300 /* Complain and keep going, so compilers can invent new
1301 cross-reference types. */
1302 warn_stab (orig, _("unrecognized cross reference type"));
1303 code = DEBUG_KIND_STRUCT;
1308 q1 = strchr (*pp, '<');
1309 p = strchr (*pp, ':');
1313 return DEBUG_TYPE_NULL;
1315 while (q1 != NULL && p > q1 && p[1] == ':')
1317 q2 = strchr (q1, '>');
1318 if (q2 == NULL || q2 < p)
1321 p = strchr (p, ':');
1325 return DEBUG_TYPE_NULL;
1329 /* Some versions of g++ can emit stabs like
1331 which define structures in terms of themselves. We need to
1332 tell the caller to avoid building a circular structure. */
1333 if (typename != NULL
1334 && strncmp (typename, *pp, p - *pp) == 0
1335 && typename[p - *pp] == '\0')
1336 info->self_crossref = true;
1338 dtype = stab_find_tagged_type (dhandle, info, *pp, p - *pp, code);
1360 /* This type is defined as another type. */
1365 /* Peek ahead at the number to detect void. */
1366 if (! parse_stab_type_number (pp, xtypenums))
1367 return DEBUG_TYPE_NULL;
1369 if (typenums[0] == xtypenums[0] && typenums[1] == xtypenums[1])
1371 /* This type is being defined as itself, which means that
1373 dtype = debug_make_void_type (dhandle);
1379 /* Go back to the number and have parse_stab_type get it.
1380 This means that we can deal with something like
1381 t(1,2)=(3,4)=... which the Lucid compiler uses. */
1382 dtype = parse_stab_type (dhandle, info, (const char *) NULL,
1383 pp, (debug_type **) NULL);
1384 if (dtype == DEBUG_TYPE_NULL)
1385 return DEBUG_TYPE_NULL;
1388 if (typenums[0] != -1)
1390 if (! stab_record_type (dhandle, info, typenums, dtype))
1391 return DEBUG_TYPE_NULL;
1398 dtype = debug_make_pointer_type (dhandle,
1399 parse_stab_type (dhandle, info,
1400 (const char *) NULL,
1402 (debug_type **) NULL));
1406 /* Reference to another type. */
1407 dtype = (debug_make_reference_type
1409 parse_stab_type (dhandle, info, (const char *) NULL, pp,
1410 (debug_type **) NULL)));
1414 /* Function returning another type. */
1415 /* FIXME: gdb checks os9k_stabs here. */
1416 dtype = (debug_make_function_type
1418 parse_stab_type (dhandle, info, (const char *) NULL, pp,
1419 (debug_type **) NULL),
1420 (debug_type *) NULL, false));
1424 /* Const qualifier on some type (Sun). */
1425 /* FIXME: gdb accepts 'c' here if os9k_stabs. */
1426 dtype = debug_make_const_type (dhandle,
1427 parse_stab_type (dhandle, info,
1428 (const char *) NULL,
1430 (debug_type **) NULL));
1434 /* Volatile qual on some type (Sun). */
1435 /* FIXME: gdb accepts 'i' here if os9k_stabs. */
1436 dtype = (debug_make_volatile_type
1438 parse_stab_type (dhandle, info, (const char *) NULL, pp,
1439 (debug_type **) NULL)));
1443 /* Offset (class & variable) type. This is used for a pointer
1444 relative to an object. */
1451 domain = parse_stab_type (dhandle, info, (const char *) NULL, pp,
1452 (debug_type **) NULL);
1453 if (domain == DEBUG_TYPE_NULL)
1454 return DEBUG_TYPE_NULL;
1459 return DEBUG_TYPE_NULL;
1463 memtype = parse_stab_type (dhandle, info, (const char *) NULL, pp,
1464 (debug_type **) NULL);
1465 if (memtype == DEBUG_TYPE_NULL)
1466 return DEBUG_TYPE_NULL;
1468 dtype = debug_make_offset_type (dhandle, domain, memtype);
1473 /* Method (class & fn) type. */
1476 debug_type return_type;
1479 return_type = parse_stab_type (dhandle, info, (const char *) NULL,
1480 pp, (debug_type **) NULL);
1481 if (return_type == DEBUG_TYPE_NULL)
1482 return DEBUG_TYPE_NULL;
1486 return DEBUG_TYPE_NULL;
1489 dtype = debug_make_method_type (dhandle, return_type,
1491 (debug_type *) NULL, false);
1496 debug_type return_type;
1502 domain = parse_stab_type (dhandle, info, (const char *) NULL,
1503 pp, (debug_type **) NULL);
1504 if (domain == DEBUG_TYPE_NULL)
1505 return DEBUG_TYPE_NULL;
1510 return DEBUG_TYPE_NULL;
1514 return_type = parse_stab_type (dhandle, info, (const char *) NULL,
1515 pp, (debug_type **) NULL);
1516 if (return_type == DEBUG_TYPE_NULL)
1517 return DEBUG_TYPE_NULL;
1520 args = (debug_type *) xmalloc (alloc * sizeof *args);
1527 return DEBUG_TYPE_NULL;
1534 args = ((debug_type *)
1535 xrealloc ((PTR) args, alloc * sizeof *args));
1538 args[n] = parse_stab_type (dhandle, info, (const char *) NULL,
1539 pp, (debug_type **) NULL);
1540 if (args[n] == DEBUG_TYPE_NULL)
1541 return DEBUG_TYPE_NULL;
1546 /* If the last type is not void, then this function takes a
1547 variable number of arguments. Otherwise, we must strip
1550 || debug_get_type_kind (dhandle, args[n - 1]) != DEBUG_KIND_VOID)
1558 args[n] = DEBUG_TYPE_NULL;
1560 dtype = debug_make_method_type (dhandle, return_type, domain, args,
1567 dtype = parse_stab_range_type (dhandle, info, typename, pp, typenums);
1571 /* FIXME: gdb checks os9k_stabs here. */
1572 /* Sun ACC builtin int type. */
1573 dtype = parse_stab_sun_builtin_type (dhandle, pp);
1577 /* Sun ACC builtin float type. */
1578 dtype = parse_stab_sun_floating_type (dhandle, pp);
1582 /* Enumeration type. */
1583 dtype = parse_stab_enum_type (dhandle, pp);
1588 /* Struct or union type. */
1589 dtype = parse_stab_struct_type (dhandle, info, typename, pp,
1590 descriptor == 's', typenums);
1598 return DEBUG_TYPE_NULL;
1602 dtype = parse_stab_array_type (dhandle, info, pp, stringp);
1606 dtype = debug_make_set_type (dhandle,
1607 parse_stab_type (dhandle, info,
1608 (const char *) NULL,
1610 (debug_type **) NULL),
1616 return DEBUG_TYPE_NULL;
1619 if (dtype == DEBUG_TYPE_NULL)
1620 return DEBUG_TYPE_NULL;
1622 if (typenums[0] != -1)
1624 if (! stab_record_type (dhandle, info, typenums, dtype))
1625 return DEBUG_TYPE_NULL;
1630 if (! debug_record_type_size (dhandle, dtype, (unsigned int) size))
1637 /* Read a number by which a type is referred to in dbx data, or
1638 perhaps read a pair (FILENUM, TYPENUM) in parentheses. Just a
1639 single number N is equivalent to (0,N). Return the two numbers by
1640 storing them in the vector TYPENUMS. */
1643 parse_stab_type_number (pp, typenums)
1654 typenums[1] = (int) parse_number (pp, (boolean *) NULL);
1659 typenums[0] = (int) parse_number (pp, (boolean *) NULL);
1666 typenums[1] = (int) parse_number (pp, (boolean *) NULL);
1678 /* Parse a range type. */
1681 parse_stab_range_type (dhandle, info, typename, pp, typenums)
1683 struct stab_handle *info;
1684 const char *typename;
1686 const int *typenums;
1690 boolean self_subrange;
1691 debug_type index_type;
1692 const char *s2, *s3;
1693 bfd_signed_vma n2, n3;
1698 index_type = DEBUG_TYPE_NULL;
1700 /* First comes a type we are a subrange of.
1701 In C it is usually 0, 1 or the type being defined. */
1702 if (! parse_stab_type_number (pp, rangenums))
1703 return DEBUG_TYPE_NULL;
1705 self_subrange = (rangenums[0] == typenums[0]
1706 && rangenums[1] == typenums[1]);
1711 index_type = parse_stab_type (dhandle, info, (const char *) NULL,
1712 pp, (debug_type **) NULL);
1713 if (index_type == DEBUG_TYPE_NULL)
1714 return DEBUG_TYPE_NULL;
1720 /* The remaining two operands are usually lower and upper bounds of
1721 the range. But in some special cases they mean something else. */
1723 n2 = parse_number (pp, &ov2);
1727 return DEBUG_TYPE_NULL;
1732 n3 = parse_number (pp, &ov3);
1736 return DEBUG_TYPE_NULL;
1742 /* gcc will emit range stabs for long long types. Handle this
1743 as a special case. FIXME: This needs to be more general. */
1744 #define LLLOW "01000000000000000000000;"
1745 #define LLHIGH "0777777777777777777777;"
1746 #define ULLHIGH "01777777777777777777777;"
1747 if (index_type == DEBUG_TYPE_NULL)
1749 if (strncmp (s2, LLLOW, sizeof LLLOW - 1) == 0
1750 && strncmp (s3, LLHIGH, sizeof LLHIGH - 1) == 0)
1751 return debug_make_int_type (dhandle, 8, false);
1754 && strncmp (s3, ULLHIGH, sizeof ULLHIGH - 1) == 0)
1755 return debug_make_int_type (dhandle, 8, true);
1758 warn_stab (orig, _("numeric overflow"));
1761 if (index_type == DEBUG_TYPE_NULL)
1763 /* A type defined as a subrange of itself, with both bounds 0,
1765 if (self_subrange && n2 == 0 && n3 == 0)
1766 return debug_make_void_type (dhandle);
1768 /* A type defined as a subrange of itself, with n2 positive and
1769 n3 zero, is a complex type, and n2 is the number of bytes. */
1770 if (self_subrange && n3 == 0 && n2 > 0)
1771 return debug_make_complex_type (dhandle, n2);
1773 /* If n3 is zero and n2 is positive, this is a floating point
1774 type, and n2 is the number of bytes. */
1775 if (n3 == 0 && n2 > 0)
1776 return debug_make_float_type (dhandle, n2);
1778 /* If the upper bound is -1, this is an unsigned int. */
1779 if (n2 == 0 && n3 == -1)
1781 /* When gcc is used with -gstabs, but not -gstabs+, it will emit
1782 long long int:t6=r1;0;-1;
1783 long long unsigned int:t7=r1;0;-1;
1784 We hack here to handle this reasonably. */
1785 if (typename != NULL)
1787 if (strcmp (typename, "long long int") == 0)
1788 return debug_make_int_type (dhandle, 8, false);
1789 else if (strcmp (typename, "long long unsigned int") == 0)
1790 return debug_make_int_type (dhandle, 8, true);
1792 /* FIXME: The size here really depends upon the target. */
1793 return debug_make_int_type (dhandle, 4, true);
1796 /* A range of 0 to 127 is char. */
1797 if (self_subrange && n2 == 0 && n3 == 127)
1798 return debug_make_int_type (dhandle, 1, false);
1800 /* FIXME: gdb checks for the language CHILL here. */
1805 return debug_make_int_type (dhandle, - n3, true);
1806 else if (n3 == 0xff)
1807 return debug_make_int_type (dhandle, 1, true);
1808 else if (n3 == 0xffff)
1809 return debug_make_int_type (dhandle, 2, true);
1810 /* -1 is used for the upper bound of (4 byte) "unsigned int"
1811 and "unsigned long", and we already checked for that, so
1812 don't need to test for it here. */
1816 && (self_subrange || n2 == -8))
1817 return debug_make_int_type (dhandle, - n2, true);
1818 else if (n2 == - n3 - 1)
1821 return debug_make_int_type (dhandle, 1, false);
1822 else if (n3 == 0x7fff)
1823 return debug_make_int_type (dhandle, 2, false);
1824 else if (n3 == 0x7fffffff)
1825 return debug_make_int_type (dhandle, 4, false);
1829 /* At this point I don't have the faintest idea how to deal with a
1830 self_subrange type; I'm going to assume that this is used as an
1831 idiom, and that all of them are special cases. So . . . */
1835 return DEBUG_TYPE_NULL;
1838 index_type = stab_find_type (dhandle, info, rangenums);
1839 if (index_type == DEBUG_TYPE_NULL)
1841 /* Does this actually ever happen? Is that why we are worrying
1842 about dealing with it rather than just calling error_type? */
1843 warn_stab (orig, _("missing index type"));
1844 index_type = debug_make_int_type (dhandle, 4, false);
1847 return debug_make_range_type (dhandle, index_type, n2, n3);
1850 /* Sun's ACC uses a somewhat saner method for specifying the builtin
1851 typedefs in every file (for int, long, etc):
1853 type = b <signed> <width>; <offset>; <nbits>
1854 signed = u or s. Possible c in addition to u or s (for char?).
1855 offset = offset from high order bit to start bit of type.
1856 width is # bytes in object of this type, nbits is # bits in type.
1858 The width/offset stuff appears to be for small objects stored in
1859 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
1863 parse_stab_sun_builtin_type (dhandle, pp)
1883 return DEBUG_TYPE_NULL;
1887 /* For some odd reason, all forms of char put a c here. This is strange
1888 because no other type has this honor. We can safely ignore this because
1889 we actually determine 'char'acterness by the number of bits specified in
1894 /* The first number appears to be the number of bytes occupied
1895 by this type, except that unsigned short is 4 instead of 2.
1896 Since this information is redundant with the third number,
1897 we will ignore it. */
1898 (void) parse_number (pp, (boolean *) NULL);
1902 return DEBUG_TYPE_NULL;
1906 /* The second number is always 0, so ignore it too. */
1907 (void) parse_number (pp, (boolean *) NULL);
1911 return DEBUG_TYPE_NULL;
1915 /* The third number is the number of bits for this type. */
1916 bits = parse_number (pp, (boolean *) NULL);
1918 /* The type *should* end with a semicolon. If it are embedded
1919 in a larger type the semicolon may be the only way to know where
1920 the type ends. If this type is at the end of the stabstring we
1921 can deal with the omitted semicolon (but we don't have to like
1922 it). Don't bother to complain(), Sun's compiler omits the semicolon
1928 return debug_make_void_type (dhandle);
1930 return debug_make_int_type (dhandle, bits / 8, unsignedp);
1933 /* Parse a builtin floating type generated by the Sun compiler. */
1936 parse_stab_sun_floating_type (dhandle, pp)
1946 /* The first number has more details about the type, for example
1948 details = parse_number (pp, (boolean *) NULL);
1952 return DEBUG_TYPE_NULL;
1955 /* The second number is the number of bytes occupied by this type */
1956 bytes = parse_number (pp, (boolean *) NULL);
1960 return DEBUG_TYPE_NULL;
1963 if (details == NF_COMPLEX
1964 || details == NF_COMPLEX16
1965 || details == NF_COMPLEX32)
1966 return debug_make_complex_type (dhandle, bytes);
1968 return debug_make_float_type (dhandle, bytes);
1971 /* Handle an enum type. */
1974 parse_stab_enum_type (dhandle, pp)
1980 bfd_signed_vma *values;
1986 /* FIXME: gdb checks os9k_stabs here. */
1988 /* The aix4 compiler emits an extra field before the enum members;
1989 my guess is it's a type of some sort. Just ignore it. */
1997 /* Read the value-names and their values.
1998 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
1999 A semicolon or comma instead of a NAME means the end. */
2001 names = (const char **) xmalloc (alloc * sizeof *names);
2002 values = (bfd_signed_vma *) xmalloc (alloc * sizeof *values);
2004 while (**pp != '\0' && **pp != ';' && **pp != ',')
2014 name = savestring (*pp, p - *pp);
2017 val = (bfd_signed_vma) parse_number (pp, (boolean *) NULL);
2021 return DEBUG_TYPE_NULL;
2028 names = ((const char **)
2029 xrealloc ((PTR) names, alloc * sizeof *names));
2030 values = ((bfd_signed_vma *)
2031 xrealloc ((PTR) values, alloc * sizeof *values));
2045 return debug_make_enum_type (dhandle, names, values);
2048 /* Read the description of a structure (or union type) and return an object
2049 describing the type.
2051 PP points to a character pointer that points to the next unconsumed token
2052 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
2053 *PP will point to "4a:1,0,32;;". */
2056 parse_stab_struct_type (dhandle, info, tagname, pp, structp, typenums)
2058 struct stab_handle *info;
2059 const char *tagname;
2062 const int *typenums;
2066 debug_baseclass *baseclasses;
2067 debug_field *fields;
2069 debug_method *methods;
2070 debug_type vptrbase;
2076 size = parse_number (pp, (boolean *) NULL);
2078 /* Get the other information. */
2079 if (! parse_stab_baseclasses (dhandle, info, pp, &baseclasses)
2080 || ! parse_stab_struct_fields (dhandle, info, pp, &fields, &statics)
2081 || ! parse_stab_members (dhandle, info, tagname, pp, typenums, &methods)
2082 || ! parse_stab_tilde_field (dhandle, info, pp, typenums, &vptrbase,
2084 return DEBUG_TYPE_NULL;
2087 && baseclasses == NULL
2089 && vptrbase == DEBUG_TYPE_NULL
2091 return debug_make_struct_type (dhandle, structp, size, fields);
2093 return debug_make_object_type (dhandle, structp, size, fields, baseclasses,
2094 methods, vptrbase, ownvptr);
2097 /* The stabs for C++ derived classes contain baseclass information which
2098 is marked by a '!' character after the total size. This function is
2099 called when we encounter the baseclass marker, and slurps up all the
2100 baseclass information.
2102 Immediately following the '!' marker is the number of base classes that
2103 the class is derived from, followed by information for each base class.
2104 For each base class, there are two visibility specifiers, a bit offset
2105 to the base class information within the derived class, a reference to
2106 the type for the base class, and a terminating semicolon.
2108 A typical example, with two base classes, would be "!2,020,19;0264,21;".
2110 Baseclass information marker __________________|| | | | | | |
2111 Number of baseclasses __________________________| | | | | | |
2112 Visibility specifiers (2) ________________________| | | | | |
2113 Offset in bits from start of class _________________| | | | |
2114 Type number for base class ___________________________| | | |
2115 Visibility specifiers (2) _______________________________| | |
2116 Offset in bits from start of class ________________________| |
2117 Type number of base class ____________________________________|
2119 Return true for success, false for failure. */
2122 parse_stab_baseclasses (dhandle, info, pp, retp)
2124 struct stab_handle *info;
2126 debug_baseclass **retp;
2130 debug_baseclass *classes;
2138 /* No base classes. */
2143 c = (unsigned int) parse_number (pp, (boolean *) NULL);
2152 classes = (debug_baseclass *) xmalloc ((c + 1) * sizeof (**retp));
2154 for (i = 0; i < c; i++)
2157 enum debug_visibility visibility;
2170 warn_stab (orig, _("unknown virtual character for baseclass"));
2179 visibility = DEBUG_VISIBILITY_PRIVATE;
2182 visibility = DEBUG_VISIBILITY_PROTECTED;
2185 visibility = DEBUG_VISIBILITY_PUBLIC;
2188 warn_stab (orig, _("unknown visibility character for baseclass"));
2189 visibility = DEBUG_VISIBILITY_PUBLIC;
2194 /* The remaining value is the bit offset of the portion of the
2195 object corresponding to this baseclass. Always zero in the
2196 absence of multiple inheritance. */
2197 bitpos = parse_number (pp, (boolean *) NULL);
2205 type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
2206 (debug_type **) NULL);
2207 if (type == DEBUG_TYPE_NULL)
2210 classes[i] = debug_make_baseclass (dhandle, type, bitpos, virtual,
2212 if (classes[i] == DEBUG_BASECLASS_NULL)
2220 classes[i] = DEBUG_BASECLASS_NULL;
2227 /* Read struct or class data fields. They have the form:
2229 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
2231 At the end, we see a semicolon instead of a field.
2233 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
2236 The optional VISIBILITY is one of:
2238 '/0' (VISIBILITY_PRIVATE)
2239 '/1' (VISIBILITY_PROTECTED)
2240 '/2' (VISIBILITY_PUBLIC)
2241 '/9' (VISIBILITY_IGNORE)
2243 or nothing, for C style fields with public visibility.
2245 Returns 1 for success, 0 for failure. */
2248 parse_stab_struct_fields (dhandle, info, pp, retp, staticsp)
2250 struct stab_handle *info;
2257 debug_field *fields;
2268 fields = (debug_field *) xmalloc (alloc * sizeof *fields);
2271 /* FIXME: gdb checks os9k_stabs here. */
2275 /* Add 1 to c to leave room for NULL pointer at end. */
2279 fields = ((debug_field *)
2280 xrealloc ((PTR) fields, alloc * sizeof *fields));
2283 /* If it starts with CPLUS_MARKER it is a special abbreviation,
2284 unless the CPLUS_MARKER is followed by an underscore, in
2285 which case it is just the name of an anonymous type, which we
2286 should handle like any other type name. We accept either '$'
2287 or '.', because a field name can never contain one of these
2288 characters except as a CPLUS_MARKER. */
2290 if ((*p == '$' || *p == '.') && p[1] != '_')
2293 if (! parse_stab_cpp_abbrev (dhandle, info, pp, fields + c))
2299 /* Look for the ':' that separates the field name from the field
2300 values. Data members are delimited by a single ':', while member
2301 functions are delimited by a pair of ':'s. When we hit the member
2302 functions (if any), terminate scan loop and return. */
2304 p = strchr (p, ':');
2314 if (! parse_stab_one_struct_field (dhandle, info, pp, p, fields + c,
2321 fields[c] = DEBUG_FIELD_NULL;
2328 /* Special GNU C++ name. */
2331 parse_stab_cpp_abbrev (dhandle, info, pp, retp)
2333 struct stab_handle *info;
2341 const char *typename;
2345 *retp = DEBUG_FIELD_NULL;
2359 /* At this point, *pp points to something like "22:23=*22...", where
2360 the type number before the ':' is the "context" and everything
2361 after is a regular type definition. Lookup the type, find it's
2362 name, and construct the field name. */
2364 context = parse_stab_type (dhandle, info, (const char *) NULL, pp,
2365 (debug_type **) NULL);
2366 if (context == DEBUG_TYPE_NULL)
2372 /* $vf -- a virtual function table pointer. */
2376 /* $vb -- a virtual bsomethingorother */
2377 typename = debug_get_type_name (dhandle, context);
2378 if (typename == NULL)
2380 warn_stab (orig, _("unnamed $vb type"));
2383 name = concat ("_vb$", typename, (const char *) NULL);
2386 warn_stab (orig, _("unrecognized C++ abbreviation"));
2387 name = "INVALID_CPLUSPLUS_ABBREV";
2398 type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
2399 (debug_type **) NULL);
2407 bitpos = parse_number (pp, (boolean *) NULL);
2415 *retp = debug_make_field (dhandle, name, type, bitpos, 0,
2416 DEBUG_VISIBILITY_PRIVATE);
2417 if (*retp == DEBUG_FIELD_NULL)
2423 /* Parse a single field in a struct or union. */
2426 parse_stab_one_struct_field (dhandle, info, pp, p, retp, staticsp)
2428 struct stab_handle *info;
2436 enum debug_visibility visibility;
2443 /* FIXME: gdb checks ARM_DEMANGLING here. */
2445 name = savestring (*pp, p - *pp);
2450 visibility = DEBUG_VISIBILITY_PUBLIC;
2457 visibility = DEBUG_VISIBILITY_PRIVATE;
2460 visibility = DEBUG_VISIBILITY_PROTECTED;
2463 visibility = DEBUG_VISIBILITY_PUBLIC;
2466 warn_stab (orig, _("unknown visibility character for field"));
2467 visibility = DEBUG_VISIBILITY_PUBLIC;
2473 type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
2474 (debug_type **) NULL);
2475 if (type == DEBUG_TYPE_NULL)
2482 /* This is a static class member. */
2484 p = strchr (*pp, ';');
2491 varname = savestring (*pp, p - *pp);
2495 *retp = debug_make_static_member (dhandle, name, type, varname,
2509 bitpos = parse_number (pp, (boolean *) NULL);
2517 bitsize = parse_number (pp, (boolean *) NULL);
2525 if (bitpos == 0 && bitsize == 0)
2527 /* This can happen in two cases: (1) at least for gcc 2.4.5 or
2528 so, it is a field which has been optimized out. The correct
2529 stab for this case is to use VISIBILITY_IGNORE, but that is a
2530 recent invention. (2) It is a 0-size array. For example
2531 union { int num; char str[0]; } foo. Printing "<no value>"
2532 for str in "p foo" is OK, since foo.str (and thus foo.str[3])
2533 will continue to work, and a 0-size array as a whole doesn't
2534 have any contents to print.
2536 I suspect this probably could also happen with gcc -gstabs
2537 (not -gstabs+) for static fields, and perhaps other C++
2538 extensions. Hopefully few people use -gstabs with gdb, since
2539 it is intended for dbx compatibility. */
2540 visibility = DEBUG_VISIBILITY_IGNORE;
2543 /* FIXME: gdb does some stuff here to mark fields as unpacked. */
2545 *retp = debug_make_field (dhandle, name, type, bitpos, bitsize, visibility);
2550 /* Read member function stabs info for C++ classes. The form of each member
2553 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
2555 An example with two member functions is:
2557 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
2559 For the case of overloaded operators, the format is op$::*.funcs, where
2560 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
2561 name (such as `+=') and `.' marks the end of the operator name. */
2564 parse_stab_members (dhandle, info, tagname, pp, typenums, retp)
2566 struct stab_handle *info;
2567 const char *tagname;
2569 const int *typenums;
2570 debug_method **retp;
2573 debug_method *methods;
2589 debug_method_variant *variants;
2591 unsigned int allocvars;
2592 debug_type look_ahead_type;
2594 p = strchr (*pp, ':');
2595 if (p == NULL || p[1] != ':')
2598 /* FIXME: Some systems use something other than '$' here. */
2599 if ((*pp)[0] != 'o' || (*pp)[1] != 'p' || (*pp)[2] != '$')
2601 name = savestring (*pp, p - *pp);
2606 /* This is a completely wierd case. In order to stuff in the
2607 names that might contain colons (the usual name delimiter),
2608 Mike Tiemann defined a different name format which is
2609 signalled if the identifier is "op$". In that case, the
2610 format is "op$::XXXX." where XXXX is the name. This is
2611 used for names like "+" or "=". YUUUUUUUK! FIXME! */
2613 for (p = *pp; *p != '.' && *p != '\0'; p++)
2620 name = savestring (*pp, p - *pp);
2625 variants = ((debug_method_variant *)
2626 xmalloc (allocvars * sizeof *variants));
2629 look_ahead_type = DEBUG_TYPE_NULL;
2636 enum debug_visibility visibility;
2637 boolean constp, volatilep, staticp;
2640 const char *physname;
2643 if (look_ahead_type != DEBUG_TYPE_NULL)
2645 /* g++ version 1 kludge */
2646 type = look_ahead_type;
2647 look_ahead_type = DEBUG_TYPE_NULL;
2651 type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
2652 (debug_type **) NULL);
2653 if (type == DEBUG_TYPE_NULL)
2663 p = strchr (*pp, ';');
2671 if (debug_get_type_kind (dhandle, type) == DEBUG_KIND_METHOD
2672 && debug_get_parameter_types (dhandle, type, &varargs) == NULL)
2675 argtypes = savestring (*pp, p - *pp);
2681 visibility = DEBUG_VISIBILITY_PRIVATE;
2684 visibility = DEBUG_VISIBILITY_PROTECTED;
2687 visibility = DEBUG_VISIBILITY_PUBLIC;
2697 /* Normal function. */
2701 /* const member function. */
2706 /* volatile member function. */
2711 /* const volatile member function. */
2719 /* File compiled with g++ version 1; no information. */
2722 warn_stab (orig, _("const/volatile indicator missing"));
2730 /* virtual member function, followed by index. The sign
2731 bit is supposedly set to distinguish
2732 pointers-to-methods from virtual function indicies. */
2734 voffset = parse_number (pp, (boolean *) NULL);
2741 voffset &= 0x7fffffff;
2743 if (**pp == ';' || *pp == '\0')
2745 /* Must be g++ version 1. */
2746 context = DEBUG_TYPE_NULL;
2750 /* Figure out from whence this virtual function
2751 came. It may belong to virtual function table of
2752 one of its baseclasses. */
2753 look_ahead_type = parse_stab_type (dhandle, info,
2754 (const char *) NULL,
2756 (debug_type **) NULL);
2759 /* g++ version 1 overloaded methods. */
2760 context = DEBUG_TYPE_NULL;
2764 context = look_ahead_type;
2765 look_ahead_type = DEBUG_TYPE_NULL;
2777 /* static member function. */
2781 context = DEBUG_TYPE_NULL;
2782 if (strncmp (argtypes, name, strlen (name)) != 0)
2787 warn_stab (orig, "member function type missing");
2789 context = DEBUG_TYPE_NULL;
2795 context = DEBUG_TYPE_NULL;
2799 /* If the type is not a stub, then the argtypes string is
2800 the physical name of the function. Otherwise the
2801 argtypes string is the mangled form of the argument
2802 types, and the full type and the physical name must be
2803 extracted from them. */
2805 physname = argtypes;
2808 debug_type class_type, return_type;
2810 class_type = stab_find_type (dhandle, info, typenums);
2811 if (class_type == DEBUG_TYPE_NULL)
2813 return_type = debug_get_return_type (dhandle, type);
2814 if (return_type == DEBUG_TYPE_NULL)
2819 type = parse_stab_argtypes (dhandle, info, class_type, name,
2820 tagname, return_type, argtypes,
2821 constp, volatilep, &physname);
2822 if (type == DEBUG_TYPE_NULL)
2826 if (cvars + 1 >= allocvars)
2829 variants = ((debug_method_variant *)
2830 xrealloc ((PTR) variants,
2831 allocvars * sizeof *variants));
2835 variants[cvars] = debug_make_method_variant (dhandle, physname,
2840 variants[cvars] = debug_make_static_method_variant (dhandle,
2846 if (variants[cvars] == DEBUG_METHOD_VARIANT_NULL)
2851 while (**pp != ';' && **pp != '\0');
2853 variants[cvars] = DEBUG_METHOD_VARIANT_NULL;
2861 methods = ((debug_method *)
2862 xrealloc ((PTR) methods, alloc * sizeof *methods));
2865 methods[c] = debug_make_method (dhandle, name, variants);
2870 if (methods != NULL)
2871 methods[c] = DEBUG_METHOD_NULL;
2878 /* Parse a string representing argument types for a method. Stabs
2879 tries to save space by packing argument types into a mangled
2880 string. This string should give us enough information to extract
2881 both argument types and the physical name of the function, given
2885 parse_stab_argtypes (dhandle, info, class_type, fieldname, tagname,
2886 return_type, argtypes, constp, volatilep, pphysname)
2888 struct stab_handle *info;
2889 debug_type class_type;
2890 const char *fieldname;
2891 const char *tagname;
2892 debug_type return_type;
2893 const char *argtypes;
2896 const char **pphysname;
2898 boolean is_full_physname_constructor;
2899 boolean is_constructor;
2900 boolean is_destructor;
2904 /* Constructors are sometimes handled specially. */
2905 is_full_physname_constructor = ((argtypes[0] == '_'
2906 && argtypes[1] == '_'
2907 && (isdigit ((unsigned char) argtypes[2])
2908 || argtypes[2] == 'Q'
2909 || argtypes[2] == 't'))
2910 || strncmp (argtypes, "__ct", 4) == 0);
2912 is_constructor = (is_full_physname_constructor
2914 && strcmp (fieldname, tagname) == 0));
2915 is_destructor = ((argtypes[0] == '_'
2916 && (argtypes[1] == '$' || argtypes[1] == '.')
2917 && argtypes[2] == '_')
2918 || strncmp (argtypes, "__dt", 4) == 0);
2920 if (is_destructor || is_full_physname_constructor)
2921 *pphysname = argtypes;
2925 const char *const_prefix;
2926 const char *volatile_prefix;
2928 unsigned int mangled_name_len;
2931 len = tagname == NULL ? 0 : strlen (tagname);
2932 const_prefix = constp ? "C" : "";
2933 volatile_prefix = volatilep ? "V" : "";
2936 sprintf (buf, "__%s%s", const_prefix, volatile_prefix);
2937 else if (tagname != NULL && strchr (tagname, '<') != NULL)
2939 /* Template methods are fully mangled. */
2940 sprintf (buf, "__%s%s", const_prefix, volatile_prefix);
2945 sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len);
2947 mangled_name_len = ((is_constructor ? 0 : strlen (fieldname))
2953 if (fieldname[0] == 'o'
2954 && fieldname[1] == 'p'
2955 && (fieldname[2] == '$' || fieldname[2] == '.'))
2959 opname = cplus_mangle_opname (fieldname + 3, 0);
2962 fprintf (stderr, _("No mangling for \"%s\"\n"), fieldname);
2963 return DEBUG_TYPE_NULL;
2965 mangled_name_len += strlen (opname);
2966 physname = (char *) xmalloc (mangled_name_len);
2967 strncpy (physname, fieldname, 3);
2968 strcpy (physname + 3, opname);
2972 physname = (char *) xmalloc (mangled_name_len);
2976 strcpy (physname, fieldname);
2979 strcat (physname, buf);
2980 if (tagname != NULL)
2981 strcat (physname, tagname);
2982 strcat (physname, argtypes);
2984 *pphysname = physname;
2987 if (*argtypes == '\0' || is_destructor)
2989 args = (debug_type *) xmalloc (sizeof *args);
2991 return debug_make_method_type (dhandle, return_type, class_type, args,
2995 args = stab_demangle_argtypes (dhandle, info, *pphysname, &varargs);
2997 return DEBUG_TYPE_NULL;
2999 return debug_make_method_type (dhandle, return_type, class_type, args,
3003 /* The tail end of stabs for C++ classes that contain a virtual function
3004 pointer contains a tilde, a %, and a type number.
3005 The type number refers to the base class (possibly this class itself) which
3006 contains the vtable pointer for the current class.
3008 This function is called when we have parsed all the method declarations,
3009 so we can look for the vptr base class info. */
3012 parse_stab_tilde_field (dhandle, info, pp, typenums, retvptrbase, retownvptr)
3014 struct stab_handle *info;
3016 const int *typenums;
3017 debug_type *retvptrbase;
3018 boolean *retownvptr;
3024 *retvptrbase = DEBUG_TYPE_NULL;
3025 *retownvptr = false;
3029 /* If we are positioned at a ';', then skip it. */
3038 if (**pp == '=' || **pp == '+' || **pp == '-')
3040 /* Obsolete flags that used to indicate the presence of
3041 constructors and/or destructors. */
3052 /* The next number is the type number of the base class (possibly
3053 our own class) which supplies the vtable for this class. */
3054 if (! parse_stab_type_number (pp, vtypenums))
3057 if (vtypenums[0] == typenums[0]
3058 && vtypenums[1] == typenums[1])
3067 vtype = parse_stab_type (dhandle, info, (const char *) NULL, pp,
3068 (debug_type **) NULL);
3069 for (p = *pp; *p != ';' && *p != '\0'; p++)
3077 *retvptrbase = vtype;
3085 /* Read a definition of an array type. */
3088 parse_stab_array_type (dhandle, info, pp, stringp)
3090 struct stab_handle *info;
3097 debug_type index_type;
3099 bfd_signed_vma lower, upper;
3100 debug_type element_type;
3102 /* Format of an array type:
3103 "ar<index type>;lower;upper;<array_contents_type>".
3104 OS9000: "arlower,upper;<array_contents_type>".
3106 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
3107 for these, produce a type like float[][]. */
3111 /* FIXME: gdb checks os9k_stabs here. */
3113 /* If the index type is type 0, we take it as int. */
3115 if (! parse_stab_type_number (&p, typenums))
3117 if (typenums[0] == 0 && typenums[1] == 0 && **pp != '=')
3119 index_type = debug_find_named_type (dhandle, "int");
3120 if (index_type == DEBUG_TYPE_NULL)
3122 index_type = debug_make_int_type (dhandle, 4, false);
3123 if (index_type == DEBUG_TYPE_NULL)
3130 index_type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
3131 (debug_type **) NULL);
3137 return DEBUG_TYPE_NULL;
3143 if (! isdigit ((unsigned char) **pp) && **pp != '-')
3149 lower = (bfd_signed_vma) parse_number (pp, (boolean *) NULL);
3157 if (! isdigit ((unsigned char) **pp) && **pp != '-')
3163 upper = (bfd_signed_vma) parse_number (pp, (boolean *) NULL);
3171 element_type = parse_stab_type (dhandle, info, (const char *) NULL, pp,
3172 (debug_type **) NULL);
3173 if (element_type == DEBUG_TYPE_NULL)
3182 return debug_make_array_type (dhandle, element_type, index_type, lower,
3186 /* This struct holds information about files we have seen using
3191 /* The next N_BINCL file. */
3192 struct bincl_file *next;
3193 /* The next N_BINCL on the stack. */
3194 struct bincl_file *next_stack;
3195 /* The file name. */
3197 /* The hash value. */
3199 /* The file index. */
3201 /* The list of types defined in this file. */
3202 struct stab_types *file_types;
3205 /* Start a new N_BINCL file, pushing it onto the stack. */
3208 push_bincl (info, name, hash)
3209 struct stab_handle *info;
3213 struct bincl_file *n;
3215 n = (struct bincl_file *) xmalloc (sizeof *n);
3216 n->next = info->bincl_list;
3217 n->next_stack = info->bincl_stack;
3220 n->file = info->files;
3221 n->file_types = NULL;
3222 info->bincl_list = n;
3223 info->bincl_stack = n;
3226 info->file_types = ((struct stab_types **)
3227 xrealloc ((PTR) info->file_types,
3229 * sizeof *info->file_types)));
3230 info->file_types[n->file] = NULL;
3233 /* Finish an N_BINCL file, at an N_EINCL, popping the name off the
3238 struct stab_handle *info;
3240 struct bincl_file *o;
3242 o = info->bincl_stack;
3244 return info->main_filename;
3245 info->bincl_stack = o->next_stack;
3247 o->file_types = info->file_types[o->file];
3249 if (info->bincl_stack == NULL)
3250 return info->main_filename;
3251 return info->bincl_stack->name;
3254 /* Handle an N_EXCL: get the types from the corresponding N_BINCL. */
3257 find_excl (info, name, hash)
3258 struct stab_handle *info;
3262 struct bincl_file *l;
3265 info->file_types = ((struct stab_types **)
3266 xrealloc ((PTR) info->file_types,
3268 * sizeof *info->file_types)));
3270 for (l = info->bincl_list; l != NULL; l = l->next)
3271 if (l->hash == hash && strcmp (l->name, name) == 0)
3275 warn_stab (name, _("Undefined N_EXCL"));
3276 info->file_types[info->files - 1] = NULL;
3280 info->file_types[info->files - 1] = l->file_types;
3285 /* Handle a variable definition. gcc emits variable definitions for a
3286 block before the N_LBRAC, so we must hold onto them until we see
3287 it. The SunPRO compiler emits variable definitions after the
3288 N_LBRAC, so we can call debug_record_variable immediately. */
3291 stab_record_variable (dhandle, info, name, type, kind, val)
3293 struct stab_handle *info;
3296 enum debug_var_kind kind;
3299 struct stab_pending_var *v;
3301 if ((kind == DEBUG_GLOBAL || kind == DEBUG_STATIC)
3302 || ! info->within_function
3303 || (info->gcc_compiled == 0 && info->n_opt_found))
3304 return debug_record_variable (dhandle, name, type, kind, val);
3306 v = (struct stab_pending_var *) xmalloc (sizeof *v);
3307 memset (v, 0, sizeof *v);
3309 v->next = info->pending;
3319 /* Emit pending variable definitions. This is called after we see the
3320 N_LBRAC that starts the block. */
3323 stab_emit_pending_vars (dhandle, info)
3325 struct stab_handle *info;
3327 struct stab_pending_var *v;
3332 struct stab_pending_var *next;
3334 if (! debug_record_variable (dhandle, v->name, v->type, v->kind, v->val))
3342 info->pending = NULL;
3347 /* Find the slot for a type in the database. */
3350 stab_find_slot (info, typenums)
3351 struct stab_handle *info;
3352 const int *typenums;
3356 struct stab_types **ps;
3358 filenum = typenums[0];
3359 index = typenums[1];
3361 if (filenum < 0 || (unsigned int) filenum >= info->files)
3363 fprintf (stderr, _("Type file number %d out of range\n"), filenum);
3368 fprintf (stderr, _("Type index number %d out of range\n"), index);
3372 ps = info->file_types + filenum;
3374 while (index >= STAB_TYPES_SLOTS)
3378 *ps = (struct stab_types *) xmalloc (sizeof **ps);
3379 memset (*ps, 0, sizeof **ps);
3382 index -= STAB_TYPES_SLOTS;
3386 *ps = (struct stab_types *) xmalloc (sizeof **ps);
3387 memset (*ps, 0, sizeof **ps);
3390 return (*ps)->types + index;
3393 /* Find a type given a type number. If the type has not been
3394 allocated yet, create an indirect type. */
3397 stab_find_type (dhandle, info, typenums)
3399 struct stab_handle *info;
3400 const int *typenums;
3404 if (typenums[0] == 0 && typenums[1] < 0)
3406 /* A negative type number indicates an XCOFF builtin type. */
3407 return stab_xcoff_builtin_type (dhandle, info, typenums[1]);
3410 slot = stab_find_slot (info, typenums);
3412 return DEBUG_TYPE_NULL;
3414 if (*slot == DEBUG_TYPE_NULL)
3415 return debug_make_indirect_type (dhandle, slot, (const char *) NULL);
3420 /* Record that a given type number refers to a given type. */
3423 stab_record_type (dhandle, info, typenums, type)
3425 struct stab_handle *info;
3426 const int *typenums;
3431 slot = stab_find_slot (info, typenums);
3435 /* gdb appears to ignore type redefinitions, so we do as well. */
3442 /* Return an XCOFF builtin type. */
3445 stab_xcoff_builtin_type (dhandle, info, typenum)
3447 struct stab_handle *info;
3453 if (typenum >= 0 || typenum < -XCOFF_TYPE_COUNT)
3455 fprintf (stderr, _("Unrecognized XCOFF type %d\n"), typenum);
3456 return DEBUG_TYPE_NULL;
3458 if (info->xcoff_types[-typenum] != NULL)
3459 return info->xcoff_types[-typenum];
3464 /* The size of this and all the other types are fixed, defined
3465 by the debugging format. */
3467 rettype = debug_make_int_type (dhandle, 4, false);
3471 rettype = debug_make_int_type (dhandle, 1, false);
3475 rettype = debug_make_int_type (dhandle, 2, false);
3479 rettype = debug_make_int_type (dhandle, 4, false);
3482 name = "unsigned char";
3483 rettype = debug_make_int_type (dhandle, 1, true);
3486 name = "signed char";
3487 rettype = debug_make_int_type (dhandle, 1, false);
3490 name = "unsigned short";
3491 rettype = debug_make_int_type (dhandle, 2, true);
3494 name = "unsigned int";
3495 rettype = debug_make_int_type (dhandle, 4, true);
3499 rettype = debug_make_int_type (dhandle, 4, true);
3501 name = "unsigned long";
3502 rettype = debug_make_int_type (dhandle, 4, true);
3506 rettype = debug_make_void_type (dhandle);
3509 /* IEEE single precision (32 bit). */
3511 rettype = debug_make_float_type (dhandle, 4);
3514 /* IEEE double precision (64 bit). */
3516 rettype = debug_make_float_type (dhandle, 8);
3519 /* This is an IEEE double on the RS/6000, and different machines
3520 with different sizes for "long double" should use different
3521 negative type numbers. See stabs.texinfo. */
3522 name = "long double";
3523 rettype = debug_make_float_type (dhandle, 8);
3527 rettype = debug_make_int_type (dhandle, 4, false);
3531 rettype = debug_make_bool_type (dhandle, 4);
3534 name = "short real";
3535 rettype = debug_make_float_type (dhandle, 4);
3539 rettype = debug_make_float_type (dhandle, 8);
3549 rettype = debug_make_int_type (dhandle, 1, true);
3553 rettype = debug_make_bool_type (dhandle, 1);
3557 rettype = debug_make_bool_type (dhandle, 2);
3561 rettype = debug_make_bool_type (dhandle, 4);
3565 rettype = debug_make_bool_type (dhandle, 4);
3568 /* Complex type consisting of two IEEE single precision values. */
3570 rettype = debug_make_complex_type (dhandle, 8);
3573 /* Complex type consisting of two IEEE double precision values. */
3574 name = "double complex";
3575 rettype = debug_make_complex_type (dhandle, 16);
3579 rettype = debug_make_int_type (dhandle, 1, false);
3583 rettype = debug_make_int_type (dhandle, 2, false);
3587 rettype = debug_make_int_type (dhandle, 4, false);
3592 rettype = debug_make_int_type (dhandle, 2, false);
3596 rettype = debug_make_int_type (dhandle, 8, false);
3599 name = "unsigned long long";
3600 rettype = debug_make_int_type (dhandle, 8, true);
3604 rettype = debug_make_bool_type (dhandle, 8);
3608 rettype = debug_make_int_type (dhandle, 8, false);
3614 rettype = debug_name_type (dhandle, name, rettype);
3616 info->xcoff_types[-typenum] = rettype;
3621 /* Find or create a tagged type. */
3624 stab_find_tagged_type (dhandle, info, p, len, kind)
3626 struct stab_handle *info;
3629 enum debug_type_kind kind;
3633 struct stab_tag *st;
3635 name = savestring (p, len);
3637 /* We pass DEBUG_KIND_ILLEGAL because we want all tags in the same
3638 namespace. This is right for C, and I don't know how to handle
3639 other languages. FIXME. */
3640 dtype = debug_find_tagged_type (dhandle, name, DEBUG_KIND_ILLEGAL);
3641 if (dtype != DEBUG_TYPE_NULL)
3647 /* We need to allocate an entry on the undefined tag list. */
3648 for (st = info->tags; st != NULL; st = st->next)
3650 if (st->name[0] == name[0]
3651 && strcmp (st->name, name) == 0)
3653 if (st->kind == DEBUG_KIND_ILLEGAL)
3661 st = (struct stab_tag *) xmalloc (sizeof *st);
3662 memset (st, 0, sizeof *st);
3664 st->next = info->tags;
3667 st->slot = DEBUG_TYPE_NULL;
3668 st->type = debug_make_indirect_type (dhandle, &st->slot, name);
3675 /* In order to get the correct argument types for a stubbed method, we
3676 need to extract the argument types from a C++ mangled string.
3677 Since the argument types can refer back to the return type, this
3678 means that we must demangle the entire physical name. In gdb this
3679 is done by calling cplus_demangle and running the results back
3680 through the C++ expression parser. Since we have no expression
3681 parser, we must duplicate much of the work of cplus_demangle here.
3683 We assume that GNU style demangling is used, since this is only
3684 done for method stubs, and only g++ should output that form of
3685 debugging information. */
3687 /* This structure is used to hold a pointer to type information which
3688 demangling a string. */
3690 struct stab_demangle_typestring
3692 /* The start of the type. This is not null terminated. */
3693 const char *typestring;
3694 /* The length of the type. */
3698 /* This structure is used to hold information while demangling a
3701 struct stab_demangle_info
3703 /* The debugging information handle. */
3705 /* The stab information handle. */
3706 struct stab_handle *info;
3707 /* The array of arguments we are building. */
3709 /* Whether the method takes a variable number of arguments. */
3711 /* The array of types we have remembered. */
3712 struct stab_demangle_typestring *typestrings;
3713 /* The number of typestrings. */
3714 unsigned int typestring_count;
3715 /* The number of typestring slots we have allocated. */
3716 unsigned int typestring_alloc;
3719 static void stab_bad_demangle PARAMS ((const char *));
3720 static unsigned int stab_demangle_count PARAMS ((const char **));
3721 static boolean stab_demangle_get_count
3722 PARAMS ((const char **, unsigned int *));
3723 static boolean stab_demangle_prefix
3724 PARAMS ((struct stab_demangle_info *, const char **));
3725 static boolean stab_demangle_function_name
3726 PARAMS ((struct stab_demangle_info *, const char **, const char *));
3727 static boolean stab_demangle_signature
3728 PARAMS ((struct stab_demangle_info *, const char **));
3729 static boolean stab_demangle_qualified
3730 PARAMS ((struct stab_demangle_info *, const char **, debug_type *));
3731 static boolean stab_demangle_template
3732 PARAMS ((struct stab_demangle_info *, const char **));
3733 static boolean stab_demangle_class
3734 PARAMS ((struct stab_demangle_info *, const char **, const char **));
3735 static boolean stab_demangle_args
3736 PARAMS ((struct stab_demangle_info *, const char **, debug_type **,
3738 static boolean stab_demangle_arg
3739 PARAMS ((struct stab_demangle_info *, const char **, debug_type **,
3740 unsigned int *, unsigned int *));
3741 static boolean stab_demangle_type
3742 PARAMS ((struct stab_demangle_info *, const char **, debug_type *));
3743 static boolean stab_demangle_fund_type
3744 PARAMS ((struct stab_demangle_info *, const char **, debug_type *));
3745 static boolean stab_demangle_remember_type
3746 PARAMS ((struct stab_demangle_info *, const char *, int));
3748 /* Warn about a bad demangling. */
3751 stab_bad_demangle (s)
3754 fprintf (stderr, _("bad mangled name `%s'\n"), s);
3757 /* Get a count from a stab string. */
3760 stab_demangle_count (pp)
3766 while (isdigit ((unsigned char) **pp))
3769 count += **pp - '0';
3775 /* Require a count in a string. The count may be multiple digits, in
3776 which case it must end in an underscore. */
3779 stab_demangle_get_count (pp, pi)
3783 if (! isdigit ((unsigned char) **pp))
3788 if (isdigit ((unsigned char) **pp))
3801 while (isdigit ((unsigned char) *p));
3812 /* This function demangles a physical name, returning a NULL
3813 terminated array of argument types. */
3816 stab_demangle_argtypes (dhandle, info, physname, pvarargs)
3818 struct stab_handle *info;
3819 const char *physname;
3822 struct stab_demangle_info minfo;
3824 minfo.dhandle = dhandle;
3827 minfo.varargs = false;
3828 minfo.typestring_alloc = 10;
3829 minfo.typestrings = ((struct stab_demangle_typestring *)
3830 xmalloc (minfo.typestring_alloc
3831 * sizeof *minfo.typestrings));
3832 minfo.typestring_count = 0;
3834 /* cplus_demangle checks for special GNU mangled forms, but we can't
3835 see any of them in mangled method argument types. */
3837 if (! stab_demangle_prefix (&minfo, &physname))
3840 if (*physname != '\0')
3842 if (! stab_demangle_signature (&minfo, &physname))
3846 free (minfo.typestrings);
3847 minfo.typestrings = NULL;
3849 if (minfo.args == NULL)
3850 fprintf (stderr, _("no argument types in mangled string\n"));
3852 *pvarargs = minfo.varargs;
3856 if (minfo.typestrings != NULL)
3857 free (minfo.typestrings);
3861 /* Demangle the prefix of the mangled name. */
3864 stab_demangle_prefix (minfo, pp)
3865 struct stab_demangle_info *minfo;
3871 /* cplus_demangle checks for global constructors and destructors,
3872 but we can't see them in mangled argument types. */
3874 /* Look for `__'. */
3878 scan = strchr (scan, '_');
3880 while (scan != NULL && *++scan != '_');
3884 stab_bad_demangle (*pp);
3890 /* We found `__'; move ahead to the last contiguous `__' pair. */
3891 i = strspn (scan, "_");
3896 && (isdigit ((unsigned char) scan[2])
3900 /* This is a GNU style constructor name. */
3904 else if (scan == *pp
3905 && ! isdigit ((unsigned char) scan[2])
3908 /* Look for the `__' that separates the prefix from the
3910 while (*scan == '_')
3912 scan = strstr (scan, "__");
3913 if (scan == NULL || scan[2] == '\0')
3915 stab_bad_demangle (*pp);
3919 return stab_demangle_function_name (minfo, pp, scan);
3921 else if (scan[2] != '\0')
3923 /* The name doesn't start with `__', but it does contain `__'. */
3924 return stab_demangle_function_name (minfo, pp, scan);
3928 stab_bad_demangle (*pp);
3934 /* Demangle a function name prefix. The scan argument points to the
3935 double underscore which separates the function name from the
3939 stab_demangle_function_name (minfo, pp, scan)
3940 struct stab_demangle_info *minfo;
3946 /* The string from *pp to scan is the name of the function. We
3947 don't care about the name, since we just looking for argument
3948 types. However, for conversion operators, the name may include a
3949 type which we must remember in order to handle backreferences. */
3955 && strncmp (name, "type", 4) == 0
3956 && (name[4] == '$' || name[4] == '.'))
3960 /* This is a type conversion operator. */
3962 if (! stab_demangle_type (minfo, &tem, (debug_type *) NULL))
3965 else if (name[0] == '_'
3972 /* This is a type conversion operator. */
3974 if (! stab_demangle_type (minfo, &tem, (debug_type *) NULL))
3981 /* Demangle the signature. This is where the argument types are
3985 stab_demangle_signature (minfo, pp)
3986 struct stab_demangle_info *minfo;
3990 boolean expect_func, func_done;
3995 expect_func = false;
3999 while (**pp != '\0')
4005 if (! stab_demangle_qualified (minfo, pp, (debug_type *) NULL)
4006 || ! stab_demangle_remember_type (minfo, hold, *pp - hold))
4013 /* Static member function. FIXME: Can this happen? */
4020 /* Const member function. */
4026 case '0': case '1': case '2': case '3': case '4':
4027 case '5': case '6': case '7': case '8': case '9':
4030 if (! stab_demangle_class (minfo, pp, (const char **) NULL)
4031 || ! stab_demangle_remember_type (minfo, hold, *pp - hold))
4038 /* Function. I don't know if this actually happens with g++
4043 if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs))
4051 if (! stab_demangle_template (minfo, pp)
4052 || ! stab_demangle_remember_type (minfo, hold, *pp - hold))
4059 /* At the outermost level, we cannot have a return type
4060 specified, so if we run into another '_' at this point we
4061 are dealing with a mangled name that is either bogus, or
4062 has been mangled by some algorithm we don't know how to
4063 deal with. So just reject the entire demangling. */
4064 stab_bad_demangle (orig);
4068 /* Assume we have stumbled onto the first outermost function
4069 argument token, and start processing args. */
4071 if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs))
4079 if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs))
4086 /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and
4087 bar__3fooi is 'foo::bar(int)'. We get here when we find the
4088 first case, and need to ensure that the '(void)' gets added
4089 to the current declp. */
4090 if (! stab_demangle_args (minfo, pp, &minfo->args, &minfo->varargs))
4097 /* Demangle a qualified name, such as "Q25Outer5Inner" which is the
4098 mangled form of "Outer::Inner". */
4101 stab_demangle_qualified (minfo, pp, ptype)
4102 struct stab_demangle_info *minfo;
4108 unsigned int qualifiers;
4116 /* GNU mangled name with more than 9 classes. The count is
4117 preceded by an underscore (to distinguish it from the <= 9
4118 case) and followed by an underscore. */
4120 if (! isdigit ((unsigned char) *p) || *p == '0')
4122 stab_bad_demangle (orig);
4125 qualifiers = atoi (p);
4126 while (isdigit ((unsigned char) *p))
4130 stab_bad_demangle (orig);
4136 case '1': case '2': case '3': case '4': case '5':
4137 case '6': case '7': case '8': case '9':
4138 qualifiers = (*pp)[1] - '0';
4139 /* Skip an optional underscore after the count. */
4140 if ((*pp)[2] == '_')
4147 stab_bad_demangle (orig);
4151 context = DEBUG_TYPE_NULL;
4153 /* Pick off the names. */
4154 while (qualifiers-- > 0)
4160 /* FIXME: I don't know how to handle the ptype != NULL case
4162 if (! stab_demangle_template (minfo, pp))
4169 len = stab_demangle_count (pp);
4170 if (strlen (*pp) < len)
4172 stab_bad_demangle (orig);
4178 const debug_field *fields;
4181 if (context != DEBUG_TYPE_NULL)
4182 fields = debug_get_fields (minfo->dhandle, context);
4184 context = DEBUG_TYPE_NULL;
4190 /* Try to find the type by looking through the
4191 fields of context until we find a field with the
4192 same type. This ought to work for a class
4193 defined within a class, but it won't work for,
4194 e.g., an enum defined within a class. stabs does
4195 not give us enough information to figure out the
4198 name = savestring (*pp, len);
4200 for (; *fields != DEBUG_FIELD_NULL; fields++)
4205 ft = debug_get_field_type (minfo->dhandle, *fields);
4208 dn = debug_get_type_name (minfo->dhandle, ft);
4209 if (dn != NULL && strcmp (dn, name) == 0)
4219 if (context == DEBUG_TYPE_NULL)
4221 /* We have to fall back on finding the type by name.
4222 If there are more types to come, then this must
4223 be a class. Otherwise, it could be anything. */
4225 if (qualifiers == 0)
4229 name = savestring (*pp, len);
4230 context = debug_find_named_type (minfo->dhandle,
4235 if (context == DEBUG_TYPE_NULL)
4237 context = stab_find_tagged_type (minfo->dhandle,
4241 ? DEBUG_KIND_ILLEGAL
4242 : DEBUG_KIND_CLASS));
4243 if (context == DEBUG_TYPE_NULL)
4259 /* Demangle a template. */
4262 stab_demangle_template (minfo, pp)
4263 struct stab_demangle_info *minfo;
4273 /* Skip the template name. */
4274 r = stab_demangle_count (pp);
4275 if (r == 0 || strlen (*pp) < r)
4277 stab_bad_demangle (orig);
4282 /* Get the size of the parameter list. */
4283 if (stab_demangle_get_count (pp, &r) == 0)
4285 stab_bad_demangle (orig);
4289 for (i = 0; i < r; i++)
4293 /* This is a type parameter. */
4295 if (! stab_demangle_type (minfo, pp, (debug_type *) NULL))
4301 boolean pointerp, realp, integralp, charp, boolp;
4312 /* This is a value parameter. */
4314 if (! stab_demangle_type (minfo, pp, (debug_type *) NULL))
4317 while (*old_p != '\0' && ! done)
4327 case 'C': /* Const. */
4328 case 'S': /* Signed. */
4329 case 'U': /* Unsigned. */
4330 case 'V': /* Volatile. */
4331 case 'F': /* Function. */
4332 case 'M': /* Member function. */
4336 case 'Q': /* Qualified name. */
4340 case 'T': /* Remembered type. */
4342 case 'v': /* Void. */
4344 case 'x': /* Long long. */
4345 case 'l': /* Long. */
4346 case 'i': /* Int. */
4347 case 's': /* Short. */
4348 case 'w': /* Wchar_t. */
4352 case 'b': /* Bool. */
4356 case 'c': /* Char. */
4360 case 'r': /* Long double. */
4361 case 'd': /* Double. */
4362 case 'f': /* Float. */
4367 /* Assume it's a user defined integral type. */
4378 while (isdigit ((unsigned char) **pp))
4387 val = stab_demangle_count (pp);
4390 stab_bad_demangle (orig);
4398 val = stab_demangle_count (pp);
4399 if (val != 0 && val != 1)
4401 stab_bad_demangle (orig);
4409 while (isdigit ((unsigned char) **pp))
4414 while (isdigit ((unsigned char) **pp))
4420 while (isdigit ((unsigned char) **pp))
4428 if (! stab_demangle_get_count (pp, &len))
4430 stab_bad_demangle (orig);
4441 /* Demangle a class name. */
4444 stab_demangle_class (minfo, pp, pstart)
4445 struct stab_demangle_info *minfo;
4447 const char **pstart;
4454 n = stab_demangle_count (pp);
4455 if (strlen (*pp) < n)
4457 stab_bad_demangle (orig);
4469 /* Demangle function arguments. If the pargs argument is not NULL, it
4470 is set to a NULL terminated array holding the arguments. */
4473 stab_demangle_args (minfo, pp, pargs, pvarargs)
4474 struct stab_demangle_info *minfo;
4480 unsigned int alloc, count;
4487 *pargs = (debug_type *) xmalloc (alloc * sizeof **pargs);
4492 while (**pp != '_' && **pp != '\0' && **pp != 'e')
4494 if (**pp == 'N' || **pp == 'T')
4502 if (temptype == 'T')
4506 if (! stab_demangle_get_count (pp, &r))
4508 stab_bad_demangle (orig);
4513 if (! stab_demangle_get_count (pp, &t))
4515 stab_bad_demangle (orig);
4519 if (t >= minfo->typestring_count)
4521 stab_bad_demangle (orig);
4528 tem = minfo->typestrings[t].typestring;
4529 if (! stab_demangle_arg (minfo, &tem, pargs, &count, &alloc))
4535 if (! stab_demangle_arg (minfo, pp, pargs, &count, &alloc))
4541 (*pargs)[count] = DEBUG_TYPE_NULL;
4553 /* Demangle a single argument. */
4556 stab_demangle_arg (minfo, pp, pargs, pcount, palloc)
4557 struct stab_demangle_info *minfo;
4560 unsigned int *pcount;
4561 unsigned int *palloc;
4567 if (! stab_demangle_type (minfo, pp,
4568 pargs == NULL ? (debug_type *) NULL : &type)
4569 || ! stab_demangle_remember_type (minfo, start, *pp - start))
4574 if (type == DEBUG_TYPE_NULL)
4577 if (*pcount + 1 >= *palloc)
4580 *pargs = ((debug_type *)
4581 xrealloc (*pargs, *palloc * sizeof **pargs));
4583 (*pargs)[*pcount] = type;
4590 /* Demangle a type. If the ptype argument is not NULL, *ptype is set
4591 to the newly allocated type. */
4594 stab_demangle_type (minfo, pp, ptype)
4595 struct stab_demangle_info *minfo;
4607 /* A pointer type. */
4609 if (! stab_demangle_type (minfo, pp, ptype))
4612 *ptype = debug_make_pointer_type (minfo->dhandle, *ptype);
4616 /* A reference type. */
4618 if (! stab_demangle_type (minfo, pp, ptype))
4621 *ptype = debug_make_reference_type (minfo->dhandle, *ptype);
4631 while (**pp != '\0' && **pp != '_')
4633 if (! isdigit ((unsigned char) **pp))
4635 stab_bad_demangle (orig);
4644 stab_bad_demangle (orig);
4649 if (! stab_demangle_type (minfo, pp, ptype))
4653 debug_type int_type;
4655 int_type = debug_find_named_type (minfo->dhandle, "int");
4656 if (int_type == NULL)
4657 int_type = debug_make_int_type (minfo->dhandle, 4, false);
4658 *ptype = debug_make_array_type (minfo->dhandle, *ptype, int_type,
4665 /* A back reference to a remembered type. */
4671 if (! stab_demangle_get_count (pp, &i))
4673 stab_bad_demangle (orig);
4676 if (i >= minfo->typestring_count)
4678 stab_bad_demangle (orig);
4681 p = minfo->typestrings[i].typestring;
4682 if (! stab_demangle_type (minfo, &p, ptype))
4694 if (! stab_demangle_args (minfo, pp,
4696 ? (debug_type **) NULL
4704 /* cplus_demangle will accept a function without a return
4705 type, but I don't know when that will happen, or what
4706 to do if it does. */
4707 stab_bad_demangle (orig);
4711 if (! stab_demangle_type (minfo, pp, ptype))
4714 *ptype = debug_make_function_type (minfo->dhandle, *ptype, args,
4723 boolean memberp, constp, volatilep;
4729 memberp = **pp == 'M';
4736 if (! isdigit ((unsigned char) **pp))
4738 stab_bad_demangle (orig);
4741 n = stab_demangle_count (pp);
4742 if (strlen (*pp) < n)
4744 stab_bad_demangle (orig);
4757 else if (**pp == 'V')
4764 stab_bad_demangle (orig);
4768 if (! stab_demangle_args (minfo, pp,
4770 ? (debug_type **) NULL
4780 stab_bad_demangle (orig);
4785 if (! stab_demangle_type (minfo, pp, ptype))
4790 debug_type class_type;
4792 class_type = stab_find_tagged_type (minfo->dhandle, minfo->info,
4795 if (class_type == DEBUG_TYPE_NULL)
4799 *ptype = debug_make_offset_type (minfo->dhandle, class_type,
4803 /* FIXME: We have no way to record constp or
4805 *ptype = debug_make_method_type (minfo->dhandle, *ptype,
4806 class_type, args, varargs);
4814 if (! stab_demangle_type (minfo, pp, ptype))
4820 if (! stab_demangle_type (minfo, pp, ptype))
4823 *ptype = debug_make_const_type (minfo->dhandle, *ptype);
4831 if (! stab_demangle_qualified (minfo, pp, ptype))
4837 if (! stab_demangle_fund_type (minfo, pp, ptype))
4845 /* Demangle a fundamental type. If the ptype argument is not NULL,
4846 *ptype is set to the newly allocated type. */
4849 stab_demangle_fund_type (minfo, pp, ptype)
4850 struct stab_demangle_info *minfo;
4855 boolean constp, volatilep, unsignedp, signedp;
4900 /* cplus_demangle permits this, but I don't know what it means. */
4901 stab_bad_demangle (orig);
4904 case 'v': /* void */
4907 *ptype = debug_find_named_type (minfo->dhandle, "void");
4908 if (*ptype == DEBUG_TYPE_NULL)
4909 *ptype = debug_make_void_type (minfo->dhandle);
4914 case 'x': /* long long */
4917 *ptype = debug_find_named_type (minfo->dhandle,
4919 ? "long long unsigned int"
4920 : "long long int"));
4921 if (*ptype == DEBUG_TYPE_NULL)
4922 *ptype = debug_make_int_type (minfo->dhandle, 8, unsignedp);
4927 case 'l': /* long */
4930 *ptype = debug_find_named_type (minfo->dhandle,
4932 ? "long unsigned int"
4934 if (*ptype == DEBUG_TYPE_NULL)
4935 *ptype = debug_make_int_type (minfo->dhandle, 4, unsignedp);
4943 *ptype = debug_find_named_type (minfo->dhandle,
4947 if (*ptype == DEBUG_TYPE_NULL)
4948 *ptype = debug_make_int_type (minfo->dhandle, 4, unsignedp);
4953 case 's': /* short */
4956 *ptype = debug_find_named_type (minfo->dhandle,
4958 ? "short unsigned int"
4960 if (*ptype == DEBUG_TYPE_NULL)
4961 *ptype = debug_make_int_type (minfo->dhandle, 2, unsignedp);
4966 case 'b': /* bool */
4969 *ptype = debug_find_named_type (minfo->dhandle, "bool");
4970 if (*ptype == DEBUG_TYPE_NULL)
4971 *ptype = debug_make_bool_type (minfo->dhandle, 4);
4976 case 'c': /* char */
4979 *ptype = debug_find_named_type (minfo->dhandle,
4985 if (*ptype == DEBUG_TYPE_NULL)
4986 *ptype = debug_make_int_type (minfo->dhandle, 1, unsignedp);
4991 case 'w': /* wchar_t */
4994 *ptype = debug_find_named_type (minfo->dhandle, "__wchar_t");
4995 if (*ptype == DEBUG_TYPE_NULL)
4996 *ptype = debug_make_int_type (minfo->dhandle, 2, true);
5001 case 'r': /* long double */
5004 *ptype = debug_find_named_type (minfo->dhandle, "long double");
5005 if (*ptype == DEBUG_TYPE_NULL)
5006 *ptype = debug_make_float_type (minfo->dhandle, 8);
5011 case 'd': /* double */
5014 *ptype = debug_find_named_type (minfo->dhandle, "double");
5015 if (*ptype == DEBUG_TYPE_NULL)
5016 *ptype = debug_make_float_type (minfo->dhandle, 8);
5021 case 'f': /* float */
5024 *ptype = debug_find_named_type (minfo->dhandle, "float");
5025 if (*ptype == DEBUG_TYPE_NULL)
5026 *ptype = debug_make_float_type (minfo->dhandle, 4);
5033 if (! isdigit ((unsigned char) **pp))
5035 stab_bad_demangle (orig);
5039 case '0': case '1': case '2': case '3': case '4':
5040 case '5': case '6': case '7': case '8': case '9':
5044 if (! stab_demangle_class (minfo, pp, &hold))
5050 name = savestring (hold, *pp - hold);
5051 *ptype = debug_find_named_type (minfo->dhandle, name);
5052 if (*ptype == DEBUG_TYPE_NULL)
5054 /* FIXME: It is probably incorrect to assume that
5055 undefined types are tagged types. */
5056 *ptype = stab_find_tagged_type (minfo->dhandle, minfo->info,
5058 DEBUG_KIND_ILLEGAL);
5066 if (! stab_demangle_template (minfo, pp))
5072 /* FIXME: I really don't know how a template should be
5073 represented in the current type system. Perhaps the
5074 template should be demangled into a string, and the type
5075 should be represented as a named type. However, I don't
5076 know what the base type of the named type should be. */
5077 t = debug_make_void_type (minfo->dhandle);
5078 t = debug_make_pointer_type (minfo->dhandle, t);
5079 t = debug_name_type (minfo->dhandle, "TEMPLATE", t);
5085 stab_bad_demangle (orig);
5092 *ptype = debug_make_const_type (minfo->dhandle, *ptype);
5094 *ptype = debug_make_volatile_type (minfo->dhandle, *ptype);
5100 /* Remember a type string in a demangled string. */
5103 stab_demangle_remember_type (minfo, p, len)
5104 struct stab_demangle_info *minfo;
5108 if (minfo->typestring_count >= minfo->typestring_alloc)
5110 minfo->typestring_alloc += 10;
5111 minfo->typestrings = ((struct stab_demangle_typestring *)
5112 xrealloc (minfo->typestrings,
5113 (minfo->typestring_alloc
5114 * sizeof *minfo->typestrings)));
5117 minfo->typestrings[minfo->typestring_count].typestring = p;
5118 minfo->typestrings[minfo->typestring_count].len = (unsigned int) len;
5119 ++minfo->typestring_count;