1 /* stabs.c -- Parse stabs 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 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"
43 /* The number of predefined XCOFF types. */
45 #define XCOFF_TYPE_COUNT 34
47 /* This structure is used as a handle so that the stab parsing doesn't
48 need to use any static variables. */
52 /* True if this is stabs in sections. */
54 /* The accumulated file name string. */
56 /* The value of the last N_SO symbol. */
58 /* The value of the start of the file, so that we can handle file
59 relative N_LBRAC and N_RBRAC symbols. */
60 bfd_vma file_start_offset
;
61 /* The offset of the start of the function, so that we can handle
62 function relative N_LBRAC and N_RBRAC symbols. */
63 bfd_vma function_start_offset
;
64 /* The version number of gcc which compiled the current compilation
65 unit, 0 if not compiled by gcc. */
67 /* Whether an N_OPT symbol was seen that was not generated by gcc,
68 so that we can detect the SunPRO compiler. */
70 /* The main file name. */
72 /* A stack of N_BINCL files. */
73 struct bincl_file
*bincl_stack
;
74 /* Whether we are inside a function or not. */
75 boolean within_function
;
76 /* The depth of block nesting. */
78 /* List of pending variable definitions. */
79 struct stab_pending_var
*pending
;
80 /* Number of files for which we have types. */
82 /* Lists of types per file. */
83 struct stab_types
**file_types
;
84 /* Predefined XCOFF types. */
85 debug_type xcoff_types
[XCOFF_TYPE_COUNT
];
87 struct stab_tag
*tags
;
90 /* A list of these structures is used to hold pending variable
91 definitions seen before the N_LBRAC of a block. */
93 struct stab_pending_var
95 /* Next pending variable definition. */
96 struct stab_pending_var
*next
;
102 enum debug_var_kind kind
;
107 /* A list of these structures is used to hold the types for a single
112 /* Next set of slots for this file. */
113 struct stab_types
*next
;
114 /* Types indexed by type number. */
115 #define STAB_TYPES_SLOTS (16)
116 debug_type types
[STAB_TYPES_SLOTS
];
119 /* We keep a list of undefined tags that we encounter, so that we can
120 fill them in if the tag is later defined. */
124 /* Next undefined tag. */
125 struct stab_tag
*next
;
129 enum debug_type_kind kind
;
130 /* Slot to hold real type when we discover it. If we don't, we fill
131 in an undefined tag type. */
133 /* Indirect type we have created to point at slot. */
137 static char *savestring
PARAMS ((const char *, int));
138 static bfd_vma parse_number
PARAMS ((const char **, boolean
*));
139 static void bad_stab
PARAMS ((const char *));
140 static void warn_stab
PARAMS ((const char *, const char *));
141 static boolean parse_stab_string
142 PARAMS ((PTR
, struct stab_handle
*, int, int, bfd_vma
, const char *));
143 static debug_type parse_stab_type
144 PARAMS ((PTR
, struct stab_handle
*, const char *, const char **,
146 static boolean parse_stab_type_number
147 PARAMS ((const char **, int *));
148 static debug_type parse_stab_range_type
149 PARAMS ((PTR
, struct stab_handle
*, const char *, const char **,
151 static debug_type parse_stab_sun_builtin_type
PARAMS ((PTR
, const char **));
152 static debug_type parse_stab_sun_floating_type
153 PARAMS ((PTR
, const char **));
154 static debug_type parse_stab_enum_type
PARAMS ((PTR
, const char **));
155 static debug_type parse_stab_struct_type
156 PARAMS ((PTR
, struct stab_handle
*, const char *, const char **, boolean
,
158 static boolean parse_stab_baseclasses
159 PARAMS ((PTR
, struct stab_handle
*, const char **, debug_baseclass
**));
160 static boolean parse_stab_struct_fields
161 PARAMS ((PTR
, struct stab_handle
*, const char **, debug_field
**,
163 static boolean parse_stab_cpp_abbrev
164 PARAMS ((PTR
, struct stab_handle
*, const char **, debug_field
*));
165 static boolean parse_stab_one_struct_field
166 PARAMS ((PTR
, struct stab_handle
*, const char **, const char *,
167 debug_field
*, boolean
*));
168 static boolean parse_stab_members
169 PARAMS ((PTR
, struct stab_handle
*, const char *, const char **,
170 const int *, debug_method
**));
171 static debug_type parse_stab_argtypes
172 PARAMS ((PTR
, struct stab_handle
*, debug_type
, const char *, const char *,
173 debug_type
, const char *, boolean
, boolean
, const char **));
174 static boolean parse_stab_tilde_field
175 PARAMS ((PTR
, struct stab_handle
*, const char **, const int *,
176 debug_type
*, boolean
*));
177 static debug_type parse_stab_array_type
178 PARAMS ((PTR
, struct stab_handle
*, const char **, boolean
));
179 static void push_bincl
PARAMS ((struct stab_handle
*, const char *));
180 static const char *pop_bincl
PARAMS ((struct stab_handle
*));
181 static boolean stab_record_variable
182 PARAMS ((PTR
, struct stab_handle
*, const char *, debug_type
,
183 enum debug_var_kind
, bfd_vma
));
184 static boolean stab_emit_pending_vars
PARAMS ((PTR
, struct stab_handle
*));
185 static debug_type
*stab_find_slot
186 PARAMS ((struct stab_handle
*, const int *));
187 static debug_type stab_find_type
188 PARAMS ((PTR
, struct stab_handle
*, const int *));
189 static boolean stab_record_type
190 PARAMS ((PTR
, struct stab_handle
*, const int *, debug_type
));
191 static debug_type stab_xcoff_builtin_type
192 PARAMS ((PTR
, struct stab_handle
*, int));
193 static debug_type stab_find_tagged_type
194 PARAMS ((PTR
, struct stab_handle
*, const char *, int,
195 enum debug_type_kind
));
196 static debug_type
*stab_demangle_argtypes
197 PARAMS ((PTR
, struct stab_handle
*, const char *, boolean
*));
199 /* Save a string in memory. */
202 savestring (start
, len
)
208 ret
= (char *) xmalloc (len
+ 1);
209 memcpy (ret
, start
, len
);
214 /* Read a number from a string. */
217 parse_number (pp
, poverflow
)
224 if (poverflow
!= NULL
)
230 ul
= strtoul (*pp
, (char **) pp
, 0);
231 if (ul
+ 1 != 0 || errno
== 0)
234 /* Note that even though strtoul overflowed, it should have set *pp
235 to the end of the number, which is where we want it. */
237 if (sizeof (bfd_vma
) > sizeof (unsigned long))
242 bfd_vma over
, lastdig
;
246 /* Our own version of strtoul, for a bfd_vma. */
262 if (p
[1] == 'x' || p
[1] == 'X')
274 over
= ((bfd_vma
) (bfd_signed_vma
) -1) / (bfd_vma
) base
;
275 lastdig
= ((bfd_vma
) (bfd_signed_vma
) -1) % (bfd_vma
) base
;
284 if (isdigit ((unsigned char) d
))
286 else if (isupper ((unsigned char) d
))
288 else if (islower ((unsigned char) d
))
296 if (v
> over
|| (v
== over
&& (bfd_vma
) d
> lastdig
))
311 /* If we get here, the number is too large to represent in a
314 if (poverflow
!= NULL
)
317 warn_stab (orig
, "numeric overflow");
322 /* Give an error for a bad stab string. */
328 fprintf (stderr
, "Bad stab: %s\n", p
);
331 /* Warn about something in a stab string. */
338 fprintf (stderr
, "Warning: %s: %s\n", err
, p
);
341 /* Create a handle to parse stabs symbols with. */
345 start_stab (dhandle
, sections
)
349 struct stab_handle
*ret
;
351 ret
= (struct stab_handle
*) xmalloc (sizeof *ret
);
352 memset (ret
, 0, sizeof *ret
);
353 ret
->sections
= sections
;
355 ret
->file_types
= (struct stab_types
**) xmalloc (sizeof *ret
->file_types
);
356 ret
->file_types
[0] = NULL
;
360 /* When we have processed all the stabs information, we need to go
361 through and fill in all the undefined tags. */
364 finish_stab (dhandle
, handle
)
368 struct stab_handle
*info
= (struct stab_handle
*) handle
;
371 if (info
->within_function
)
373 if (! stab_emit_pending_vars (dhandle
, info
)
374 || ! debug_end_function (dhandle
, (bfd_vma
) -1))
376 info
->within_function
= false;
379 for (st
= info
->tags
; st
!= NULL
; st
= st
->next
)
381 enum debug_type_kind kind
;
384 if (kind
== DEBUG_KIND_ILLEGAL
)
385 kind
= DEBUG_KIND_STRUCT
;
386 st
->slot
= debug_make_undefined_tagged_type (dhandle
, st
->name
, kind
);
387 if (st
->slot
== DEBUG_TYPE_NULL
)
394 /* Handle a single stabs symbol. */
397 parse_stab (dhandle
, handle
, type
, desc
, value
, string
)
405 struct stab_handle
*info
= (struct stab_handle
*) handle
;
407 /* gcc will emit two N_SO strings per compilation unit, one for the
408 directory name and one for the file name. We just collect N_SO
409 strings as we see them, and start the new compilation unit when
410 we see a non N_SO symbol. */
411 if (info
->so_string
!= NULL
412 && (type
!= N_SO
|| *string
== '\0' || value
!= info
->so_value
))
414 if (! debug_set_filename (dhandle
, info
->so_string
))
416 info
->main_filename
= info
->so_string
;
418 info
->gcc_compiled
= 0;
419 info
->n_opt_found
= false;
421 /* Generally, for stabs in the symbol table, the N_LBRAC and
422 N_RBRAC symbols are relative to the N_SO symbol value. */
423 if (! info
->sections
)
424 info
->file_start_offset
= info
->so_value
;
426 /* We need to reset the mapping from type numbers to types. We
427 can't free the old mapping, because of the use of
428 debug_make_indirect_type. */
430 info
->file_types
= ((struct stab_types
**)
431 xmalloc (sizeof *info
->file_types
));
432 info
->file_types
[0] = NULL
;
434 info
->so_string
= NULL
;
436 /* Now process whatever type we just got. */
446 /* Ignore extra outermost context from SunPRO cc and acc. */
447 if (info
->n_opt_found
&& desc
== 1)
450 if (! info
->within_function
)
452 fprintf (stderr
, "N_LBRAC not within function\n");
456 /* Start an inner lexical block. */
457 if (! debug_start_block (dhandle
,
459 + info
->file_start_offset
460 + info
->function_start_offset
)))
463 /* Emit any pending variable definitions. */
464 if (! stab_emit_pending_vars (dhandle
, info
))
471 /* Ignore extra outermost context from SunPRO cc and acc. */
472 if (info
->n_opt_found
&& desc
== 1)
475 /* We shouldn't have any pending variable definitions here, but,
476 if we do, we probably need to emit them before closing the
478 if (! stab_emit_pending_vars (dhandle
, info
))
481 /* End an inner lexical block. */
482 if (! debug_end_block (dhandle
,
484 + info
->file_start_offset
485 + info
->function_start_offset
)))
489 if (info
->block_depth
< 0)
491 fprintf (stderr
, "Too many N_RBRACs\n");
497 /* This always ends a function. */
498 if (info
->within_function
)
500 if (! stab_emit_pending_vars (dhandle
, info
)
501 || ! debug_end_function (dhandle
, value
))
503 info
->within_function
= false;
506 /* An empty string is emitted by gcc at the end of a compilation
511 /* Just accumulate strings until we see a non N_SO symbol. If
512 the string starts with '/', we discard the previously
513 accumulated strings. */
514 if (info
->so_string
== NULL
)
515 info
->so_string
= xstrdup (string
);
522 info
->so_string
= xstrdup (string
);
524 info
->so_string
= concat (info
->so_string
, string
,
525 (const char *) NULL
);
529 info
->so_value
= value
;
534 /* Start an include file. */
535 if (! debug_start_source (dhandle
, string
))
540 /* Start an include file which may be replaced. */
541 push_bincl (info
, string
);
542 if (! debug_start_source (dhandle
, string
))
547 /* End an N_BINCL include. */
548 if (! debug_start_source (dhandle
, pop_bincl (info
)))
553 /* This is a duplicate of a header file named by N_BINCL which
554 was eliminated by the linker. */
556 info
->file_types
= ((struct stab_types
**)
557 xrealloc ((PTR
) info
->file_types
,
559 * sizeof *info
->file_types
)));
560 info
->file_types
[info
->files
- 1] = NULL
;
564 if (! debug_record_line (dhandle
, desc
,
565 value
+ info
->function_start_offset
))
570 if (! debug_start_common_block (dhandle
, string
))
575 if (! debug_end_common_block (dhandle
, string
))
579 /* FIXME: gdb checks the string for N_STSYM, N_LCSYM or N_ROSYM
580 symbols, and if it does not start with :S, gdb relocates the
581 value to the start of the section. gcc always seems to use
582 :S, so we don't worry about this. */
587 colon
= strchr (string
, ':');
589 && (colon
[1] == 'f' || colon
[1] == 'F'))
591 if (info
->within_function
)
593 if (! stab_emit_pending_vars (dhandle
, info
)
594 || ! debug_end_function (dhandle
, value
))
597 /* For stabs in sections, line numbers and block addresses
598 are offsets from the start of the function. */
600 info
->function_start_offset
= value
;
601 info
->within_function
= true;
604 if (! parse_stab_string (dhandle
, info
, type
, desc
, value
, string
))
610 if (string
!= NULL
&& strcmp (string
, "gcc2_compiled.") == 0)
611 info
->gcc_compiled
= 2;
612 else if (string
!= NULL
&& strcmp (string
, "gcc_compiled.") == 0)
613 info
->gcc_compiled
= 1;
615 info
->n_opt_found
= true;
627 /* Parse the stabs string. */
630 parse_stab_string (dhandle
, info
, stabtype
, desc
, value
, string
)
632 struct stab_handle
*info
;
646 p
= strchr (string
, ':');
661 /* GCC 2.x puts the line number in desc. SunOS apparently puts in
662 the number of bytes occupied by a type or object, which we
664 if (info
->gcc_compiled
>= 2)
669 /* FIXME: Sometimes the special C++ names start with '.'. */
671 if (string
[0] == '$')
679 /* Was: name = "vptr"; */
685 /* This was an anonymous type that was never fixed up. */
688 /* SunPRO (3.0 at least) static variable encoding. */
691 warn_stab (string
, "unknown C++ encoded name");
698 if (p
== string
|| (string
[0] == ' ' && p
== string
+ 1))
701 name
= savestring (string
, p
- string
);
705 if (isdigit ((unsigned char) *p
) || *p
== '(' || *p
== '-')
713 /* c is a special case, not followed by a type-number.
714 SYMBOL:c=iVALUE for an integer constant symbol.
715 SYMBOL:c=rVALUE for a floating constant symbol.
716 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
717 e.g. "b:c=e6,0" for "const b = blob1"
718 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
728 /* Floating point constant. */
729 if (! debug_record_float_const (dhandle
, name
, atof (p
)))
733 /* Integer constant. */
734 /* Defining integer constants this way is kind of silly,
735 since 'e' constants allows the compiler to give not only
736 the value, but the type as well. C has at least int,
737 long, unsigned int, and long long as constant types;
738 other languages probably should have at least unsigned as
739 well as signed constants. */
740 if (! debug_record_int_const (dhandle
, name
, atoi (p
)))
744 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
745 can be represented as integral.
746 e.g. "b:c=e6,0" for "const b = blob1"
747 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
748 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
,
749 &p
, (debug_type
**) NULL
);
750 if (dtype
== DEBUG_TYPE_NULL
)
757 if (! debug_record_typed_const (dhandle
, name
, dtype
, atoi (p
)))
768 /* The name of a caught exception. */
769 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
,
770 &p
, (debug_type
**) NULL
);
771 if (dtype
== DEBUG_TYPE_NULL
)
773 if (! debug_record_label (dhandle
, name
, dtype
, value
))
779 /* A function definition. */
780 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
781 (debug_type
**) NULL
);
782 if (dtype
== DEBUG_TYPE_NULL
)
784 if (! debug_record_function (dhandle
, name
, dtype
, type
== 'F', value
))
787 /* Sun acc puts declared types of arguments here. We don't care
788 about their actual types (FIXME -- we should remember the whole
789 function prototype), but the list may define some new types
790 that we have to remember, so we must scan it now. */
794 if (parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
795 (debug_type
**) NULL
)
803 /* A global symbol. The value must be extracted from the symbol
805 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
806 (debug_type
**) NULL
);
807 if (dtype
== DEBUG_TYPE_NULL
)
809 if (! stab_record_variable (dhandle
, info
, name
, dtype
, DEBUG_GLOBAL
,
814 /* This case is faked by a conditional above, when there is no
815 code letter in the dbx data. Dbx data never actually
819 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
820 (debug_type
**) NULL
);
821 if (dtype
== DEBUG_TYPE_NULL
)
823 if (! stab_record_variable (dhandle
, info
, name
, dtype
, DEBUG_LOCAL
,
829 /* A function parameter. */
831 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
832 (debug_type
**) NULL
);
835 /* pF is a two-letter code that means a function parameter in
836 Fortran. The type-number specifies the type of the return
837 value. Translate it into a pointer-to-function type. */
839 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
840 (debug_type
**) NULL
);
841 if (dtype
!= DEBUG_TYPE_NULL
)
845 ftype
= debug_make_function_type (dhandle
, dtype
,
846 (debug_type
*) NULL
, false);
847 dtype
= debug_make_pointer_type (dhandle
, ftype
);
850 if (dtype
== DEBUG_TYPE_NULL
)
852 if (! debug_record_parameter (dhandle
, name
, dtype
, DEBUG_PARM_STACK
,
856 /* FIXME: At this point gdb considers rearranging the parameter
857 address on a big endian machine if it is smaller than an int.
858 We have no way to do that, since we don't really know much
864 if (stabtype
== N_FUN
)
866 /* Prototype of a function referenced by this file. */
870 if (parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
871 (debug_type
**) NULL
)
879 /* Parameter which is in a register. */
880 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
881 (debug_type
**) NULL
);
882 if (dtype
== DEBUG_TYPE_NULL
)
884 if (! debug_record_parameter (dhandle
, name
, dtype
, DEBUG_PARM_REG
,
890 /* Register variable (either global or local). */
891 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
892 (debug_type
**) NULL
);
893 if (dtype
== DEBUG_TYPE_NULL
)
895 if (! stab_record_variable (dhandle
, info
, name
, dtype
, DEBUG_REGISTER
,
899 /* FIXME: At this point gdb checks to combine pairs of 'p' and
900 'r' stabs into a single 'P' stab. */
905 /* Static symbol at top level of file */
906 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
907 (debug_type
**) NULL
);
908 if (dtype
== DEBUG_TYPE_NULL
)
910 if (! stab_record_variable (dhandle
, info
, name
, dtype
, DEBUG_STATIC
,
917 dtype
= parse_stab_type (dhandle
, info
, name
, &p
, &slot
);
918 if (dtype
== DEBUG_TYPE_NULL
)
922 /* A nameless type. Nothing to do. */
926 dtype
= debug_name_type (dhandle
, name
, dtype
);
927 if (dtype
== DEBUG_TYPE_NULL
)
936 /* Struct, union, or enum tag. For GNU C++, this can be be followed
937 by 't' which means we are typedef'ing it as well. */
941 /* FIXME: gdb sets synonym to true if the current language
950 dtype
= parse_stab_type (dhandle
, info
, name
, &p
, &slot
);
951 if (dtype
== DEBUG_TYPE_NULL
)
956 dtype
= debug_tag_type (dhandle
, name
, dtype
);
957 if (dtype
== DEBUG_TYPE_NULL
)
962 /* See if we have a cross reference to this tag which we can now
965 register struct stab_tag
**pst
;
967 for (pst
= &info
->tags
; *pst
!= NULL
; pst
= &(*pst
)->next
)
969 if ((*pst
)->name
[0] == name
[0]
970 && strcmp ((*pst
)->name
, name
) == 0)
972 (*pst
)->slot
= dtype
;
981 dtype
= debug_name_type (dhandle
, name
, dtype
);
982 if (dtype
== DEBUG_TYPE_NULL
)
992 /* Static symbol of local scope */
993 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
994 (debug_type
**) NULL
);
995 if (dtype
== DEBUG_TYPE_NULL
)
997 /* FIXME: gdb checks os9k_stabs here. */
998 if (! stab_record_variable (dhandle
, info
, name
, dtype
,
999 DEBUG_LOCAL_STATIC
, value
))
1004 /* Reference parameter. */
1005 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
1006 (debug_type
**) NULL
);
1007 if (dtype
== DEBUG_TYPE_NULL
)
1009 if (! debug_record_parameter (dhandle
, name
, dtype
, DEBUG_PARM_REFERENCE
,
1015 /* Reference parameter which is in a register. */
1016 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
1017 (debug_type
**) NULL
);
1018 if (dtype
== DEBUG_TYPE_NULL
)
1020 if (! debug_record_parameter (dhandle
, name
, dtype
, DEBUG_PARM_REF_REG
,
1026 /* This is used by Sun FORTRAN for "function result value".
1027 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
1028 that Pascal uses it too, but when I tried it Pascal used
1029 "x:3" (local symbol) instead. */
1030 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, &p
,
1031 (debug_type
**) NULL
);
1032 if (dtype
== DEBUG_TYPE_NULL
)
1034 if (! stab_record_variable (dhandle
, info
, name
, dtype
, DEBUG_LOCAL
,
1044 /* FIXME: gdb converts structure values to structure pointers in a
1045 couple of cases, depending upon the target. */
1050 /* Parse a stabs type. The typename argument is non-NULL if this is a
1051 typedef or a tag definition. The pp argument points to the stab
1052 string, and is updated. The slotp argument points to a place to
1053 store the slot used if the type is being defined. */
1056 parse_stab_type (dhandle
, info
, typename
, pp
, slotp
)
1058 struct stab_handle
*info
;
1059 const char *typename
;
1078 /* Read type number if present. The type number may be omitted.
1079 for instance in a two-dimensional array declared with type
1080 "ar1;1;10;ar1;1;10;4". */
1081 if (! isdigit ((unsigned char) **pp
) && **pp
!= '(' && **pp
!= '-')
1083 /* 'typenums=' not present, type is anonymous. Read and return
1084 the definition, but don't put it in the type vector. */
1085 typenums
[0] = typenums
[1] = -1;
1089 if (! parse_stab_type_number (pp
, typenums
))
1090 return DEBUG_TYPE_NULL
;
1094 /* Type is not being defined here. Either it already
1095 exists, or this is a forward reference to it. */
1096 return stab_find_type (dhandle
, info
, typenums
);
1099 /* Only set the slot if the type is being defined. This means
1100 that the mapping from type numbers to types will only record
1101 the name of the typedef which defines a type. If we don't do
1102 this, then something like
1105 will record that i is of type foo. Unfortunately, stabs
1106 information is ambiguous about variable types. For this code,
1110 the stabs information records both i and j as having the same
1111 type. This could be fixed by patching the compiler. */
1112 if (slotp
!= NULL
&& typenums
[0] >= 0 && typenums
[1] >= 0)
1113 *slotp
= stab_find_slot (info
, typenums
);
1115 /* Type is being defined here. */
1121 const char *p
= *pp
+ 1;
1124 if (isdigit ((unsigned char) *p
) || *p
== '(' || *p
== '-')
1130 /* Type attributes. */
1133 for (; *p
!= ';'; ++p
)
1138 return DEBUG_TYPE_NULL
;
1146 size
= atoi (attr
+ 1);
1156 /* Ignore unrecognized type attributes, so future
1157 compilers can invent new ones. */
1170 enum debug_type_kind code
;
1171 const char *q1
, *q2
, *p
;
1173 /* A cross reference to another type. */
1178 code
= DEBUG_KIND_STRUCT
;
1181 code
= DEBUG_KIND_UNION
;
1184 code
= DEBUG_KIND_ENUM
;
1187 /* Complain and keep going, so compilers can invent new
1188 cross-reference types. */
1189 warn_stab (orig
, "unrecognized cross reference type");
1190 code
= DEBUG_KIND_STRUCT
;
1195 q1
= strchr (*pp
, '<');
1196 p
= strchr (*pp
, ':');
1200 return DEBUG_TYPE_NULL
;
1202 while (q1
!= NULL
&& p
> q1
&& p
[1] == ':')
1204 q2
= strchr (q1
, '>');
1205 if (q2
== NULL
|| q2
< p
)
1208 p
= strchr (p
, ':');
1212 return DEBUG_TYPE_NULL
;
1216 dtype
= stab_find_tagged_type (dhandle
, info
, *pp
, p
- *pp
, code
);
1238 /* This type is defined as another type. */
1243 /* Peek ahead at the number to detect void. */
1244 if (! parse_stab_type_number (pp
, xtypenums
))
1245 return DEBUG_TYPE_NULL
;
1247 if (typenums
[0] == xtypenums
[0] && typenums
[1] == xtypenums
[1])
1249 /* This type is being defined as itself, which means that
1251 dtype
= debug_make_void_type (dhandle
);
1257 /* Go back to the number and have parse_stab_type get it.
1258 This means that we can deal with something like
1259 t(1,2)=(3,4)=... which the Lucid compiler uses. */
1260 dtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
,
1261 pp
, (debug_type
**) NULL
);
1262 if (dtype
== DEBUG_TYPE_NULL
)
1263 return DEBUG_TYPE_NULL
;
1266 if (typenums
[0] != -1)
1268 if (! stab_record_type (dhandle
, info
, typenums
, dtype
))
1269 return DEBUG_TYPE_NULL
;
1276 dtype
= debug_make_pointer_type (dhandle
,
1277 parse_stab_type (dhandle
, info
,
1278 (const char *) NULL
,
1280 (debug_type
**) NULL
));
1284 /* Reference to another type. */
1285 dtype
= (debug_make_reference_type
1287 parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
1288 (debug_type
**) NULL
)));
1292 /* Function returning another type. */
1293 /* FIXME: gdb checks os9k_stabs here. */
1294 dtype
= (debug_make_function_type
1296 parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
1297 (debug_type
**) NULL
),
1298 (debug_type
*) NULL
, false));
1302 /* Const qualifier on some type (Sun). */
1303 /* FIXME: gdb accepts 'c' here if os9k_stabs. */
1304 dtype
= debug_make_const_type (dhandle
,
1305 parse_stab_type (dhandle
, info
,
1306 (const char *) NULL
,
1308 (debug_type
**) NULL
));
1312 /* Volatile qual on some type (Sun). */
1313 /* FIXME: gdb accepts 'i' here if os9k_stabs. */
1314 dtype
= (debug_make_volatile_type
1316 parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
1317 (debug_type
**) NULL
)));
1321 /* Offset (class & variable) type. This is used for a pointer
1322 relative to an object. */
1329 domain
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
1330 (debug_type
**) NULL
);
1331 if (domain
== DEBUG_TYPE_NULL
)
1332 return DEBUG_TYPE_NULL
;
1337 return DEBUG_TYPE_NULL
;
1341 memtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
1342 (debug_type
**) NULL
);
1343 if (memtype
== DEBUG_TYPE_NULL
)
1344 return DEBUG_TYPE_NULL
;
1346 dtype
= debug_make_offset_type (dhandle
, domain
, memtype
);
1351 /* Method (class & fn) type. */
1354 debug_type return_type
;
1357 return_type
= parse_stab_type (dhandle
, info
, (const char *) NULL
,
1358 pp
, (debug_type
**) NULL
);
1359 if (return_type
== DEBUG_TYPE_NULL
)
1360 return DEBUG_TYPE_NULL
;
1364 return DEBUG_TYPE_NULL
;
1367 dtype
= debug_make_method_type (dhandle
, return_type
,
1369 (debug_type
*) NULL
, false);
1374 debug_type return_type
;
1380 domain
= parse_stab_type (dhandle
, info
, (const char *) NULL
,
1381 pp
, (debug_type
**) NULL
);
1382 if (domain
== DEBUG_TYPE_NULL
)
1383 return DEBUG_TYPE_NULL
;
1388 return DEBUG_TYPE_NULL
;
1392 return_type
= parse_stab_type (dhandle
, info
, (const char *) NULL
,
1393 pp
, (debug_type
**) NULL
);
1394 if (return_type
== DEBUG_TYPE_NULL
)
1395 return DEBUG_TYPE_NULL
;
1398 args
= (debug_type
*) xmalloc (alloc
* sizeof *args
);
1405 return DEBUG_TYPE_NULL
;
1412 args
= ((debug_type
*)
1413 xrealloc ((PTR
) args
, alloc
* sizeof *args
));
1416 args
[n
] = parse_stab_type (dhandle
, info
, (const char *) NULL
,
1417 pp
, (debug_type
**) NULL
);
1418 if (args
[n
] == DEBUG_TYPE_NULL
)
1419 return DEBUG_TYPE_NULL
;
1424 /* If the last type is not void, then this function takes a
1425 variable number of arguments. Otherwise, we must strip
1428 || debug_get_type_kind (dhandle
, args
[n
- 1]) != DEBUG_KIND_VOID
)
1436 args
[n
] = DEBUG_TYPE_NULL
;
1438 dtype
= debug_make_method_type (dhandle
, return_type
, domain
, args
,
1445 dtype
= parse_stab_range_type (dhandle
, info
, typename
, pp
, typenums
);
1449 /* FIXME: gdb checks os9k_stabs here. */
1450 /* Sun ACC builtin int type. */
1451 dtype
= parse_stab_sun_builtin_type (dhandle
, pp
);
1455 /* Sun ACC builtin float type. */
1456 dtype
= parse_stab_sun_floating_type (dhandle
, pp
);
1460 /* Enumeration type. */
1461 dtype
= parse_stab_enum_type (dhandle
, pp
);
1466 /* Struct or union type. */
1467 dtype
= parse_stab_struct_type (dhandle
, info
, typename
, pp
,
1468 descriptor
== 's', typenums
);
1476 return DEBUG_TYPE_NULL
;
1480 dtype
= parse_stab_array_type (dhandle
, info
, pp
, stringp
);
1484 dtype
= debug_make_set_type (dhandle
,
1485 parse_stab_type (dhandle
, info
,
1486 (const char *) NULL
,
1488 (debug_type
**) NULL
),
1494 return DEBUG_TYPE_NULL
;
1497 if (dtype
== DEBUG_TYPE_NULL
)
1498 return DEBUG_TYPE_NULL
;
1500 if (typenums
[0] != -1)
1502 if (! stab_record_type (dhandle
, info
, typenums
, dtype
))
1503 return DEBUG_TYPE_NULL
;
1508 if (! debug_record_type_size (dhandle
, dtype
, (unsigned int) size
))
1515 /* Read a number by which a type is referred to in dbx data, or
1516 perhaps read a pair (FILENUM, TYPENUM) in parentheses. Just a
1517 single number N is equivalent to (0,N). Return the two numbers by
1518 storing them in the vector TYPENUMS. */
1521 parse_stab_type_number (pp
, typenums
)
1532 typenums
[1] = (int) parse_number (pp
, (boolean
*) NULL
);
1537 typenums
[0] = (int) parse_number (pp
, (boolean
*) NULL
);
1544 typenums
[1] = (int) parse_number (pp
, (boolean
*) NULL
);
1556 /* Parse a range type. */
1559 parse_stab_range_type (dhandle
, info
, typename
, pp
, typenums
)
1561 struct stab_handle
*info
;
1562 const char *typename
;
1564 const int *typenums
;
1568 boolean self_subrange
;
1569 debug_type index_type
;
1570 const char *s2
, *s3
;
1571 bfd_signed_vma n2
, n3
;
1576 index_type
= DEBUG_TYPE_NULL
;
1578 /* First comes a type we are a subrange of.
1579 In C it is usually 0, 1 or the type being defined. */
1580 if (! parse_stab_type_number (pp
, rangenums
))
1581 return DEBUG_TYPE_NULL
;
1583 self_subrange
= (rangenums
[0] == typenums
[0]
1584 && rangenums
[1] == typenums
[1]);
1589 index_type
= parse_stab_type (dhandle
, info
, (const char *) NULL
,
1590 pp
, (debug_type
**) NULL
);
1591 if (index_type
== DEBUG_TYPE_NULL
)
1592 return DEBUG_TYPE_NULL
;
1598 /* The remaining two operands are usually lower and upper bounds of
1599 the range. But in some special cases they mean something else. */
1601 n2
= parse_number (pp
, &ov2
);
1605 return DEBUG_TYPE_NULL
;
1610 n3
= parse_number (pp
, &ov3
);
1614 return DEBUG_TYPE_NULL
;
1620 /* gcc will emit range stabs for long long types. Handle this
1621 as a special case. FIXME: This needs to be more general. */
1622 #define LLLOW "01000000000000000000000;"
1623 #define LLHIGH "0777777777777777777777;"
1624 #define ULLHIGH "01777777777777777777777;"
1625 if (index_type
== DEBUG_TYPE_NULL
)
1627 if (strncmp (s2
, LLLOW
, sizeof LLLOW
- 1) == 0
1628 && strncmp (s3
, LLHIGH
, sizeof LLHIGH
- 1) == 0)
1629 return debug_make_int_type (dhandle
, 8, false);
1632 && strncmp (s3
, ULLHIGH
, sizeof ULLHIGH
- 1) == 0)
1633 return debug_make_int_type (dhandle
, 8, true);
1636 warn_stab (orig
, "numeric overflow");
1639 if (index_type
== DEBUG_TYPE_NULL
)
1641 /* A type defined as a subrange of itself, with both bounds 0,
1643 if (self_subrange
&& n2
== 0 && n3
== 0)
1644 return debug_make_void_type (dhandle
);
1646 /* If n3 is zero and n2 is positive, this is a floating point
1647 type, and n2 is the number of bytes. */
1648 if (n3
== 0 && n2
> 0)
1649 return debug_make_float_type (dhandle
, n2
);
1651 /* If the upper bound is -1, this is an unsigned int. */
1652 if (n2
== 0 && n3
== -1)
1654 /* When gcc is used with -gstabs, but not -gstabs+, it will emit
1655 long long int:t6=r1;0;-1;
1656 long long unsigned int:t7=r1;0;-1;
1657 We hack here to handle this reasonably. */
1658 if (typename
!= NULL
)
1660 if (strcmp (typename
, "long long int") == 0)
1661 return debug_make_int_type (dhandle
, 8, false);
1662 else if (strcmp (typename
, "long long unsigned int") == 0)
1663 return debug_make_int_type (dhandle
, 8, true);
1665 /* FIXME: The size here really depends upon the target. */
1666 return debug_make_int_type (dhandle
, 4, true);
1669 /* A range of 0 to 127 is char. */
1670 if (self_subrange
&& n2
== 0 && n3
== 127)
1671 return debug_make_int_type (dhandle
, 1, false);
1673 /* FIXME: gdb checks for the language CHILL here. */
1678 return debug_make_int_type (dhandle
, - n3
, true);
1679 else if (n3
== 0xff)
1680 return debug_make_int_type (dhandle
, 1, true);
1681 else if (n3
== 0xffff)
1682 return debug_make_int_type (dhandle
, 2, true);
1683 /* -1 is used for the upper bound of (4 byte) "unsigned int"
1684 and "unsigned long", and we already checked for that, so
1685 don't need to test for it here. */
1689 && (self_subrange
|| n2
== -8))
1690 return debug_make_int_type (dhandle
, - n2
, true);
1691 else if (n2
== - n3
- 1)
1694 return debug_make_int_type (dhandle
, 1, false);
1695 else if (n3
== 0x7fff)
1696 return debug_make_int_type (dhandle
, 2, false);
1697 else if (n3
== 0x7fffffff)
1698 return debug_make_int_type (dhandle
, 4, false);
1702 /* At this point I don't have the faintest idea how to deal with a
1703 self_subrange type; I'm going to assume that this is used as an
1704 idiom, and that all of them are special cases. So . . . */
1708 return DEBUG_TYPE_NULL
;
1711 index_type
= stab_find_type (dhandle
, info
, rangenums
);
1712 if (index_type
== DEBUG_TYPE_NULL
)
1714 /* Does this actually ever happen? Is that why we are worrying
1715 about dealing with it rather than just calling error_type? */
1716 warn_stab (orig
, "missing index type");
1717 index_type
= debug_make_int_type (dhandle
, 4, false);
1720 return debug_make_range_type (dhandle
, index_type
, n2
, n3
);
1723 /* Sun's ACC uses a somewhat saner method for specifying the builtin
1724 typedefs in every file (for int, long, etc):
1726 type = b <signed> <width>; <offset>; <nbits>
1727 signed = u or s. Possible c in addition to u or s (for char?).
1728 offset = offset from high order bit to start bit of type.
1729 width is # bytes in object of this type, nbits is # bits in type.
1731 The width/offset stuff appears to be for small objects stored in
1732 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
1736 parse_stab_sun_builtin_type (dhandle
, pp
)
1756 return DEBUG_TYPE_NULL
;
1760 /* For some odd reason, all forms of char put a c here. This is strange
1761 because no other type has this honor. We can safely ignore this because
1762 we actually determine 'char'acterness by the number of bits specified in
1767 /* The first number appears to be the number of bytes occupied
1768 by this type, except that unsigned short is 4 instead of 2.
1769 Since this information is redundant with the third number,
1770 we will ignore it. */
1771 (void) parse_number (pp
, (boolean
*) NULL
);
1775 return DEBUG_TYPE_NULL
;
1779 /* The second number is always 0, so ignore it too. */
1780 (void) parse_number (pp
, (boolean
*) NULL
);
1784 return DEBUG_TYPE_NULL
;
1788 /* The third number is the number of bits for this type. */
1789 bits
= parse_number (pp
, (boolean
*) NULL
);
1791 /* The type *should* end with a semicolon. If it are embedded
1792 in a larger type the semicolon may be the only way to know where
1793 the type ends. If this type is at the end of the stabstring we
1794 can deal with the omitted semicolon (but we don't have to like
1795 it). Don't bother to complain(), Sun's compiler omits the semicolon
1801 return debug_make_void_type (dhandle
);
1803 return debug_make_int_type (dhandle
, bits
/ 8, unsignedp
);
1806 /* Parse a builtin floating type generated by the Sun compiler. */
1809 parse_stab_sun_floating_type (dhandle
, pp
)
1819 /* The first number has more details about the type, for example
1821 details
= parse_number (pp
, (boolean
*) NULL
);
1825 return DEBUG_TYPE_NULL
;
1828 /* The second number is the number of bytes occupied by this type */
1829 bytes
= parse_number (pp
, (boolean
*) NULL
);
1833 return DEBUG_TYPE_NULL
;
1836 if (details
== NF_COMPLEX
1837 || details
== NF_COMPLEX16
1838 || details
== NF_COMPLEX32
)
1839 return debug_make_complex_type (dhandle
, bytes
);
1841 return debug_make_float_type (dhandle
, bytes
);
1844 /* Handle an enum type. */
1847 parse_stab_enum_type (dhandle
, pp
)
1853 bfd_signed_vma
*values
;
1859 /* FIXME: gdb checks os9k_stabs here. */
1861 /* The aix4 compiler emits an extra field before the enum members;
1862 my guess is it's a type of some sort. Just ignore it. */
1870 /* Read the value-names and their values.
1871 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
1872 A semicolon or comma instead of a NAME means the end. */
1874 names
= (const char **) xmalloc (alloc
* sizeof *names
);
1875 values
= (bfd_signed_vma
*) xmalloc (alloc
* sizeof *values
);
1877 while (**pp
!= '\0' && **pp
!= ';' && **pp
!= ',')
1887 name
= savestring (*pp
, p
- *pp
);
1890 val
= (bfd_signed_vma
) parse_number (pp
, (boolean
*) NULL
);
1894 return DEBUG_TYPE_NULL
;
1901 names
= ((const char **)
1902 xrealloc ((PTR
) names
, alloc
* sizeof *names
));
1903 values
= ((bfd_signed_vma
*)
1904 xrealloc ((PTR
) values
, alloc
* sizeof *values
));
1918 return debug_make_enum_type (dhandle
, names
, values
);
1921 /* Read the description of a structure (or union type) and return an object
1922 describing the type.
1924 PP points to a character pointer that points to the next unconsumed token
1925 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
1926 *PP will point to "4a:1,0,32;;". */
1929 parse_stab_struct_type (dhandle
, info
, tagname
, pp
, structp
, typenums
)
1931 struct stab_handle
*info
;
1932 const char *tagname
;
1935 const int *typenums
;
1939 debug_baseclass
*baseclasses
;
1940 debug_field
*fields
;
1942 debug_method
*methods
;
1943 debug_type vptrbase
;
1949 size
= parse_number (pp
, (boolean
*) NULL
);
1951 /* Get the other information. */
1952 if (! parse_stab_baseclasses (dhandle
, info
, pp
, &baseclasses
)
1953 || ! parse_stab_struct_fields (dhandle
, info
, pp
, &fields
, &statics
)
1954 || ! parse_stab_members (dhandle
, info
, tagname
, pp
, typenums
, &methods
)
1955 || ! parse_stab_tilde_field (dhandle
, info
, pp
, typenums
, &vptrbase
,
1957 return DEBUG_TYPE_NULL
;
1960 && baseclasses
== NULL
1962 && vptrbase
== DEBUG_TYPE_NULL
1964 return debug_make_struct_type (dhandle
, structp
, size
, fields
);
1966 return debug_make_object_type (dhandle
, structp
, size
, fields
, baseclasses
,
1967 methods
, vptrbase
, ownvptr
);
1970 /* The stabs for C++ derived classes contain baseclass information which
1971 is marked by a '!' character after the total size. This function is
1972 called when we encounter the baseclass marker, and slurps up all the
1973 baseclass information.
1975 Immediately following the '!' marker is the number of base classes that
1976 the class is derived from, followed by information for each base class.
1977 For each base class, there are two visibility specifiers, a bit offset
1978 to the base class information within the derived class, a reference to
1979 the type for the base class, and a terminating semicolon.
1981 A typical example, with two base classes, would be "!2,020,19;0264,21;".
1983 Baseclass information marker __________________|| | | | | | |
1984 Number of baseclasses __________________________| | | | | | |
1985 Visibility specifiers (2) ________________________| | | | | |
1986 Offset in bits from start of class _________________| | | | |
1987 Type number for base class ___________________________| | | |
1988 Visibility specifiers (2) _______________________________| | |
1989 Offset in bits from start of class ________________________| |
1990 Type number of base class ____________________________________|
1992 Return true for success, false for failure. */
1995 parse_stab_baseclasses (dhandle
, info
, pp
, retp
)
1997 struct stab_handle
*info
;
1999 debug_baseclass
**retp
;
2003 debug_baseclass
*classes
;
2011 /* No base classes. */
2016 c
= (unsigned int) parse_number (pp
, (boolean
*) NULL
);
2025 classes
= (debug_baseclass
*) xmalloc ((c
+ 1) * sizeof (**retp
));
2027 for (i
= 0; i
< c
; i
++)
2030 enum debug_visibility visibility
;
2043 warn_stab (orig
, "unknown virtual character for baseclass");
2052 visibility
= DEBUG_VISIBILITY_PRIVATE
;
2055 visibility
= DEBUG_VISIBILITY_PROTECTED
;
2058 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2061 warn_stab (orig
, "unknown visibility character for baseclass");
2062 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2067 /* The remaining value is the bit offset of the portion of the
2068 object corresponding to this baseclass. Always zero in the
2069 absence of multiple inheritance. */
2070 bitpos
= parse_number (pp
, (boolean
*) NULL
);
2078 type
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
2079 (debug_type
**) NULL
);
2080 if (type
== DEBUG_TYPE_NULL
)
2083 classes
[i
] = debug_make_baseclass (dhandle
, type
, bitpos
, virtual,
2085 if (classes
[i
] == DEBUG_BASECLASS_NULL
)
2093 classes
[i
] = DEBUG_BASECLASS_NULL
;
2100 /* Read struct or class data fields. They have the form:
2102 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
2104 At the end, we see a semicolon instead of a field.
2106 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
2109 The optional VISIBILITY is one of:
2111 '/0' (VISIBILITY_PRIVATE)
2112 '/1' (VISIBILITY_PROTECTED)
2113 '/2' (VISIBILITY_PUBLIC)
2114 '/9' (VISIBILITY_IGNORE)
2116 or nothing, for C style fields with public visibility.
2118 Returns 1 for success, 0 for failure. */
2121 parse_stab_struct_fields (dhandle
, info
, pp
, retp
, staticsp
)
2123 struct stab_handle
*info
;
2130 debug_field
*fields
;
2141 fields
= (debug_field
*) xmalloc (alloc
* sizeof *fields
);
2144 /* FIXME: gdb checks os9k_stabs here. */
2148 /* Add 1 to c to leave room for NULL pointer at end. */
2152 fields
= ((debug_field
*)
2153 xrealloc ((PTR
) fields
, alloc
* sizeof *fields
));
2156 /* If it starts with CPLUS_MARKER it is a special abbreviation,
2157 unless the CPLUS_MARKER is followed by an underscore, in
2158 which case it is just the name of an anonymous type, which we
2159 should handle like any other type name. We accept either '$'
2160 or '.', because a field name can never contain one of these
2161 characters except as a CPLUS_MARKER. */
2163 if ((*p
== '$' || *p
== '.') && p
[1] != '_')
2166 if (! parse_stab_cpp_abbrev (dhandle
, info
, pp
, fields
+ c
))
2172 /* Look for the ':' that separates the field name from the field
2173 values. Data members are delimited by a single ':', while member
2174 functions are delimited by a pair of ':'s. When we hit the member
2175 functions (if any), terminate scan loop and return. */
2177 p
= strchr (p
, ':');
2187 if (! parse_stab_one_struct_field (dhandle
, info
, pp
, p
, fields
+ c
,
2194 fields
[c
] = DEBUG_FIELD_NULL
;
2201 /* Special GNU C++ name. */
2204 parse_stab_cpp_abbrev (dhandle
, info
, pp
, retp
)
2206 struct stab_handle
*info
;
2214 const char *typename
;
2218 *retp
= DEBUG_FIELD_NULL
;
2232 /* At this point, *pp points to something like "22:23=*22...", where
2233 the type number before the ':' is the "context" and everything
2234 after is a regular type definition. Lookup the type, find it's
2235 name, and construct the field name. */
2237 context
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
2238 (debug_type
**) NULL
);
2239 if (context
== DEBUG_TYPE_NULL
)
2245 /* $vf -- a virtual function table pointer. */
2249 /* $vb -- a virtual bsomethingorother */
2250 typename
= debug_get_type_name (dhandle
, context
);
2251 if (typename
== NULL
)
2253 warn_stab (orig
, "unnamed $vb type");
2256 name
= concat ("_vb$", typename
, (const char *) NULL
);
2259 warn_stab (orig
, "unrecognized C++ abbreviation");
2260 name
= "INVALID_CPLUSPLUS_ABBREV";
2271 type
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
2272 (debug_type
**) NULL
);
2280 bitpos
= parse_number (pp
, (boolean
*) NULL
);
2288 *retp
= debug_make_field (dhandle
, name
, type
, bitpos
, 0,
2289 DEBUG_VISIBILITY_PRIVATE
);
2290 if (*retp
== DEBUG_FIELD_NULL
)
2296 /* Parse a single field in a struct or union. */
2299 parse_stab_one_struct_field (dhandle
, info
, pp
, p
, retp
, staticsp
)
2301 struct stab_handle
*info
;
2309 enum debug_visibility visibility
;
2316 /* FIXME: gdb checks ARM_DEMANGLING here. */
2318 name
= savestring (*pp
, p
- *pp
);
2323 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2330 visibility
= DEBUG_VISIBILITY_PRIVATE
;
2333 visibility
= DEBUG_VISIBILITY_PROTECTED
;
2336 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2339 warn_stab (orig
, "unknown visibility character for field");
2340 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2346 type
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
2347 (debug_type
**) NULL
);
2348 if (type
== DEBUG_TYPE_NULL
)
2355 /* This is a static class member. */
2357 p
= strchr (*pp
, ';');
2364 varname
= savestring (*pp
, p
- *pp
);
2368 *retp
= debug_make_static_member (dhandle
, name
, type
, varname
,
2382 bitpos
= parse_number (pp
, (boolean
*) NULL
);
2390 bitsize
= parse_number (pp
, (boolean
*) NULL
);
2398 if (bitpos
== 0 && bitsize
== 0)
2400 /* This can happen in two cases: (1) at least for gcc 2.4.5 or
2401 so, it is a field which has been optimized out. The correct
2402 stab for this case is to use VISIBILITY_IGNORE, but that is a
2403 recent invention. (2) It is a 0-size array. For example
2404 union { int num; char str[0]; } foo. Printing "<no value>"
2405 for str in "p foo" is OK, since foo.str (and thus foo.str[3])
2406 will continue to work, and a 0-size array as a whole doesn't
2407 have any contents to print.
2409 I suspect this probably could also happen with gcc -gstabs
2410 (not -gstabs+) for static fields, and perhaps other C++
2411 extensions. Hopefully few people use -gstabs with gdb, since
2412 it is intended for dbx compatibility. */
2413 visibility
= DEBUG_VISIBILITY_IGNORE
;
2416 /* FIXME: gdb does some stuff here to mark fields as unpacked. */
2418 *retp
= debug_make_field (dhandle
, name
, type
, bitpos
, bitsize
, visibility
);
2423 /* Read member function stabs info for C++ classes. The form of each member
2426 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
2428 An example with two member functions is:
2430 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
2432 For the case of overloaded operators, the format is op$::*.funcs, where
2433 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
2434 name (such as `+=') and `.' marks the end of the operator name. */
2437 parse_stab_members (dhandle
, info
, tagname
, pp
, typenums
, retp
)
2439 struct stab_handle
*info
;
2440 const char *tagname
;
2442 const int *typenums
;
2443 debug_method
**retp
;
2446 debug_method
*methods
;
2462 debug_method_variant
*variants
;
2464 unsigned int allocvars
;
2465 debug_type look_ahead_type
;
2467 p
= strchr (*pp
, ':');
2468 if (p
== NULL
|| p
[1] != ':')
2471 /* FIXME: Some systems use something other than '$' here. */
2472 if ((*pp
)[0] != 'o' || (*pp
)[1] != 'p' || (*pp
)[2] != '$')
2474 name
= savestring (*pp
, p
- *pp
);
2479 /* This is a completely wierd case. In order to stuff in the
2480 names that might contain colons (the usual name delimiter),
2481 Mike Tiemann defined a different name format which is
2482 signalled if the identifier is "op$". In that case, the
2483 format is "op$::XXXX." where XXXX is the name. This is
2484 used for names like "+" or "=". YUUUUUUUK! FIXME! */
2486 for (p
= *pp
; *p
!= '.' && *p
!= '\0'; p
++)
2493 name
= savestring (*pp
, p
- *pp
);
2498 variants
= ((debug_method_variant
*)
2499 xmalloc (allocvars
* sizeof *variants
));
2502 look_ahead_type
= DEBUG_TYPE_NULL
;
2508 enum debug_visibility visibility
;
2509 boolean constp
, volatilep
, staticp
;
2512 const char *physname
;
2515 if (look_ahead_type
!= DEBUG_TYPE_NULL
)
2517 /* g++ version 1 kludge */
2518 type
= look_ahead_type
;
2519 look_ahead_type
= DEBUG_TYPE_NULL
;
2523 type
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
2524 (debug_type
**) NULL
);
2525 if (type
== DEBUG_TYPE_NULL
)
2535 p
= strchr (*pp
, ';');
2542 argtypes
= savestring (*pp
, p
- *pp
);
2548 visibility
= DEBUG_VISIBILITY_PRIVATE
;
2551 visibility
= DEBUG_VISIBILITY_PROTECTED
;
2554 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2564 /* Normal function. */
2568 /* const member function. */
2573 /* volatile member function. */
2578 /* const volatile member function. */
2586 /* File compiled with g++ version 1; no information. */
2589 warn_stab (orig
, "const/volatile indicator missing");
2597 /* virtual member function, followed by index. The sign
2598 bit is set to distinguish pointers-to-methods from
2599 virtual function indicies. Since the array is in
2600 words, the quantity must be shifted left by 1 on 16
2601 bit machine, and by 2 on 32 bit machine, forcing the
2602 sign bit out, and usable as a valid index into the
2603 array. Remove the sign bit here. */
2605 voffset
= parse_number (pp
, (boolean
*) NULL
);
2612 voffset
&= 0x7fffffff;
2615 if (**pp
== ';' || *pp
== '\0')
2617 /* Must be g++ version 1. */
2618 context
= DEBUG_TYPE_NULL
;
2622 /* Figure out from whence this virtual function
2623 came. It may belong to virtual function table of
2624 one of its baseclasses. */
2625 look_ahead_type
= parse_stab_type (dhandle
, info
,
2626 (const char *) NULL
,
2628 (debug_type
**) NULL
);
2631 /* g++ version 1 overloaded methods. */
2635 context
= look_ahead_type
;
2636 look_ahead_type
= DEBUG_TYPE_NULL
;
2648 /* static member function. */
2652 context
= DEBUG_TYPE_NULL
;
2656 warn_stab (orig
, "member function type missing");
2658 context
= DEBUG_TYPE_NULL
;
2664 context
= DEBUG_TYPE_NULL
;
2668 /* If this is a method type which is not a stub--that is,
2669 the argument types are fully specified--then the argtypes
2670 string is actually the physical name of the function.
2671 Otherwise, the argtypes string is the mangled from of the
2672 argument types, and the physical name of the function,
2673 and the argument types, must be deduced from it. */
2675 if (debug_get_type_kind (dhandle
, type
) == DEBUG_KIND_METHOD
2676 && debug_get_parameter_types (dhandle
, type
, &varargs
) != NULL
)
2677 physname
= argtypes
;
2680 debug_type class_type
, return_type
;
2682 class_type
= stab_find_type (dhandle
, info
, typenums
);
2683 if (class_type
== DEBUG_TYPE_NULL
)
2685 return_type
= debug_get_return_type (dhandle
, type
);
2686 if (return_type
== DEBUG_TYPE_NULL
)
2691 type
= parse_stab_argtypes (dhandle
, info
, class_type
, name
,
2692 tagname
, return_type
, argtypes
,
2693 constp
, volatilep
, &physname
);
2694 if (type
== DEBUG_TYPE_NULL
)
2698 if (cvars
+ 1 >= allocvars
)
2701 variants
= ((debug_method_variant
*)
2702 xrealloc ((PTR
) variants
,
2703 allocvars
* sizeof *variants
));
2707 variants
[cvars
] = debug_make_method_variant (dhandle
, physname
,
2712 variants
[cvars
] = debug_make_static_method_variant (dhandle
,
2718 if (variants
[cvars
] == DEBUG_METHOD_VARIANT_NULL
)
2723 while (**pp
!= ';' && **pp
!= '\0');
2725 variants
[cvars
] = DEBUG_METHOD_VARIANT_NULL
;
2733 methods
= ((debug_method
*)
2734 xrealloc ((PTR
) methods
, alloc
* sizeof *methods
));
2737 methods
[c
] = debug_make_method (dhandle
, name
, variants
);
2742 if (methods
!= NULL
)
2743 methods
[c
] = DEBUG_METHOD_NULL
;
2750 /* Parse a string representing argument types for a method. Stabs
2751 tries to save space by packing argument types into a mangled
2752 string. This string should give us enough information to extract
2753 both argument types and the physical name of the function, given
2757 parse_stab_argtypes (dhandle
, info
, class_type
, fieldname
, tagname
,
2758 return_type
, argtypes
, constp
, volatilep
, pphysname
)
2760 struct stab_handle
*info
;
2761 debug_type class_type
;
2762 const char *fieldname
;
2763 const char *tagname
;
2764 debug_type return_type
;
2765 const char *argtypes
;
2768 const char **pphysname
;
2770 boolean is_full_physname_constructor
;
2771 boolean is_constructor
;
2772 boolean is_destructor
;
2776 /* Constructors are sometimes handled specially. */
2777 is_full_physname_constructor
= ((argtypes
[0] == '_'
2778 && argtypes
[1] == '_'
2779 && (isdigit ((unsigned char) argtypes
[2])
2780 || argtypes
[2] == 'Q'
2781 || argtypes
[2] == 't'))
2782 || strncmp (argtypes
, "__ct", 4) == 0);
2784 is_constructor
= (is_full_physname_constructor
2786 && strcmp (fieldname
, tagname
) == 0));
2787 is_destructor
= ((argtypes
[0] == '_'
2788 && (argtypes
[1] == '$' || argtypes
[1] == '.')
2789 && argtypes
[2] == '_')
2790 || strncmp (argtypes
, "__dt", 4) == 0);
2792 if (is_destructor
|| is_full_physname_constructor
)
2793 *pphysname
= argtypes
;
2797 const char *const_prefix
;
2798 const char *volatile_prefix
;
2800 unsigned int mangled_name_len
;
2803 len
= tagname
== NULL
? 0 : strlen (tagname
);
2804 const_prefix
= constp
? "C" : "";
2805 volatile_prefix
= volatilep
? "V" : "";
2808 sprintf (buf
, "__%s%s", const_prefix
, volatile_prefix
);
2809 else if (tagname
!= NULL
&& strchr (tagname
, '<') != NULL
)
2811 /* Template methods are fully mangled. */
2812 sprintf (buf
, "__%s%s", const_prefix
, volatile_prefix
);
2817 sprintf (buf
, "__%s%s%d", const_prefix
, volatile_prefix
, len
);
2819 mangled_name_len
= ((is_constructor
? 0 : strlen (fieldname
))
2825 if (fieldname
[0] == 'o'
2826 && fieldname
[1] == 'p'
2827 && (fieldname
[2] == '$' || fieldname
[2] == '.'))
2831 opname
= cplus_mangle_opname (fieldname
+ 3, 0);
2834 fprintf (stderr
, "No mangling for \"%s\"\n", fieldname
);
2835 return DEBUG_TYPE_NULL
;
2837 mangled_name_len
+= strlen (opname
);
2838 physname
= (char *) xmalloc (mangled_name_len
);
2839 strncpy (physname
, fieldname
, 3);
2840 strcpy (physname
+ 3, opname
);
2844 physname
= (char *) xmalloc (mangled_name_len
);
2848 strcpy (physname
, fieldname
);
2851 strcat (physname
, buf
);
2852 if (tagname
!= NULL
)
2853 strcat (physname
, tagname
);
2854 strcat (physname
, argtypes
);
2856 *pphysname
= physname
;
2859 if (*argtypes
== '\0')
2861 args
= (debug_type
*) xmalloc (sizeof *args
);
2863 return debug_make_method_type (dhandle
, return_type
, class_type
, args
,
2867 args
= stab_demangle_argtypes (dhandle
, info
, *pphysname
, &varargs
);
2869 return DEBUG_TYPE_NULL
;
2871 return debug_make_method_type (dhandle
, return_type
, class_type
, args
,
2875 /* The tail end of stabs for C++ classes that contain a virtual function
2876 pointer contains a tilde, a %, and a type number.
2877 The type number refers to the base class (possibly this class itself) which
2878 contains the vtable pointer for the current class.
2880 This function is called when we have parsed all the method declarations,
2881 so we can look for the vptr base class info. */
2884 parse_stab_tilde_field (dhandle
, info
, pp
, typenums
, retvptrbase
, retownvptr
)
2886 struct stab_handle
*info
;
2888 const int *typenums
;
2889 debug_type
*retvptrbase
;
2890 boolean
*retownvptr
;
2896 *retvptrbase
= DEBUG_TYPE_NULL
;
2897 *retownvptr
= false;
2901 /* If we are positioned at a ';', then skip it. */
2910 if (**pp
== '=' || **pp
== '+' || **pp
== '-')
2912 /* Obsolete flags that used to indicate the presence of
2913 constructors and/or destructors. */
2924 /* The next number is the type number of the base class (possibly
2925 our own class) which supplies the vtable for this class. */
2926 if (! parse_stab_type_number (pp
, vtypenums
))
2929 if (vtypenums
[0] == typenums
[0]
2930 && vtypenums
[1] == typenums
[1])
2939 vtype
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
2940 (debug_type
**) NULL
);
2941 for (p
= *pp
; *p
!= ';' && *p
!= '\0'; p
++)
2949 *retvptrbase
= vtype
;
2957 /* Read a definition of an array type. */
2960 parse_stab_array_type (dhandle
, info
, pp
, stringp
)
2962 struct stab_handle
*info
;
2967 debug_type index_type
;
2969 bfd_signed_vma lower
, upper
;
2970 debug_type element_type
;
2972 /* Format of an array type:
2973 "ar<index type>;lower;upper;<array_contents_type>".
2974 OS9000: "arlower,upper;<array_contents_type>".
2976 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
2977 for these, produce a type like float[][]. */
2981 /* FIXME: gdb checks os9k_stabs here. */
2983 index_type
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
2984 (debug_type
**) NULL
);
2988 return DEBUG_TYPE_NULL
;
2994 if (! isdigit ((unsigned char) **pp
) && **pp
!= '-')
3000 lower
= (bfd_signed_vma
) parse_number (pp
, (boolean
*) NULL
);
3008 if (! isdigit ((unsigned char) **pp
) && **pp
!= '-')
3014 upper
= (bfd_signed_vma
) parse_number (pp
, (boolean
*) NULL
);
3022 element_type
= parse_stab_type (dhandle
, info
, (const char *) NULL
, pp
,
3023 (debug_type
**) NULL
);
3024 if (element_type
== DEBUG_TYPE_NULL
)
3033 return debug_make_array_type (dhandle
, element_type
, index_type
, lower
,
3037 /* Keep a stack of N_BINCL include files. */
3041 struct bincl_file
*next
;
3045 /* Start a new N_BINCL file, pushing it onto the stack. */
3048 push_bincl (info
, name
)
3049 struct stab_handle
*info
;
3052 struct bincl_file
*n
;
3054 n
= (struct bincl_file
*) xmalloc (sizeof *n
);
3055 n
->next
= info
->bincl_stack
;
3057 info
->bincl_stack
= n
;
3060 info
->file_types
= ((struct stab_types
**)
3061 xrealloc ((PTR
) info
->file_types
,
3063 * sizeof *info
->file_types
)));
3064 info
->file_types
[info
->files
- 1] = NULL
;
3067 /* Finish an N_BINCL file, at an N_EINCL, popping the name off the
3072 struct stab_handle
*info
;
3074 struct bincl_file
*o
;
3076 o
= info
->bincl_stack
;
3078 return info
->main_filename
;
3079 info
->bincl_stack
= o
->next
;
3081 if (info
->bincl_stack
== NULL
)
3082 return info
->main_filename
;
3083 return info
->bincl_stack
->name
;
3086 /* Handle a variable definition. gcc emits variable definitions for a
3087 block before the N_LBRAC, so we must hold onto them until we see
3088 it. The SunPRO compiler emits variable definitions after the
3089 N_LBRAC, so we can call debug_record_variable immediately. */
3092 stab_record_variable (dhandle
, info
, name
, type
, kind
, val
)
3094 struct stab_handle
*info
;
3097 enum debug_var_kind kind
;
3100 struct stab_pending_var
*v
;
3102 if ((kind
== DEBUG_GLOBAL
|| kind
== DEBUG_STATIC
)
3103 || ! info
->within_function
3104 || (info
->gcc_compiled
== 0 && info
->n_opt_found
))
3105 return debug_record_variable (dhandle
, name
, type
, kind
, val
);
3107 v
= (struct stab_pending_var
*) xmalloc (sizeof *v
);
3108 memset (v
, 0, sizeof *v
);
3110 v
->next
= info
->pending
;
3120 /* Emit pending variable definitions. This is called after we see the
3121 N_LBRAC that starts the block. */
3124 stab_emit_pending_vars (dhandle
, info
)
3126 struct stab_handle
*info
;
3128 struct stab_pending_var
*v
;
3133 struct stab_pending_var
*next
;
3135 if (! debug_record_variable (dhandle
, v
->name
, v
->type
, v
->kind
, v
->val
))
3143 info
->pending
= NULL
;
3148 /* Find the slot for a type in the database. */
3151 stab_find_slot (info
, typenums
)
3152 struct stab_handle
*info
;
3153 const int *typenums
;
3157 struct stab_types
**ps
;
3159 filenum
= typenums
[0];
3160 index
= typenums
[1];
3162 if (filenum
< 0 || (unsigned int) filenum
>= info
->files
)
3164 fprintf (stderr
, "Type file number %d out of range\n", filenum
);
3169 fprintf (stderr
, "Type index number %d out of range\n", index
);
3173 ps
= info
->file_types
+ filenum
;
3175 while (index
>= STAB_TYPES_SLOTS
)
3179 *ps
= (struct stab_types
*) xmalloc (sizeof **ps
);
3180 memset (*ps
, 0, sizeof **ps
);
3183 index
-= STAB_TYPES_SLOTS
;
3187 *ps
= (struct stab_types
*) xmalloc (sizeof **ps
);
3188 memset (*ps
, 0, sizeof **ps
);
3191 return (*ps
)->types
+ index
;
3194 /* Find a type given a type number. If the type has not been
3195 allocated yet, create an indirect type. */
3198 stab_find_type (dhandle
, info
, typenums
)
3200 struct stab_handle
*info
;
3201 const int *typenums
;
3205 if (typenums
[0] == 0 && typenums
[1] < 0)
3207 /* A negative type number indicates an XCOFF builtin type. */
3208 return stab_xcoff_builtin_type (dhandle
, info
, typenums
[1]);
3211 slot
= stab_find_slot (info
, typenums
);
3213 return DEBUG_TYPE_NULL
;
3215 if (*slot
== DEBUG_TYPE_NULL
)
3216 return debug_make_indirect_type (dhandle
, slot
, (const char *) NULL
);
3221 /* Record that a given type number refers to a given type. */
3224 stab_record_type (dhandle
, info
, typenums
, type
)
3226 struct stab_handle
*info
;
3227 const int *typenums
;
3232 slot
= stab_find_slot (info
, typenums
);
3236 /* gdb appears to ignore type redefinitions, so we do as well. */
3243 /* Return an XCOFF builtin type. */
3246 stab_xcoff_builtin_type (dhandle
, info
, typenum
)
3248 struct stab_handle
*info
;
3254 if (typenum
>= 0 || typenum
< -XCOFF_TYPE_COUNT
)
3256 fprintf (stderr
, "Unrecognized XCOFF type %d\n", typenum
);
3257 return DEBUG_TYPE_NULL
;
3259 if (info
->xcoff_types
[-typenum
] != NULL
)
3260 return info
->xcoff_types
[-typenum
];
3265 /* The size of this and all the other types are fixed, defined
3266 by the debugging format. */
3268 rettype
= debug_make_int_type (dhandle
, 4, false);
3272 rettype
= debug_make_int_type (dhandle
, 1, false);
3276 rettype
= debug_make_int_type (dhandle
, 2, false);
3280 rettype
= debug_make_int_type (dhandle
, 4, false);
3283 name
= "unsigned char";
3284 rettype
= debug_make_int_type (dhandle
, 1, true);
3287 name
= "signed char";
3288 rettype
= debug_make_int_type (dhandle
, 1, false);
3291 name
= "unsigned short";
3292 rettype
= debug_make_int_type (dhandle
, 2, true);
3295 name
= "unsigned int";
3296 rettype
= debug_make_int_type (dhandle
, 4, true);
3300 rettype
= debug_make_int_type (dhandle
, 4, true);
3302 name
= "unsigned long";
3303 rettype
= debug_make_int_type (dhandle
, 4, true);
3307 rettype
= debug_make_void_type (dhandle
);
3310 /* IEEE single precision (32 bit). */
3312 rettype
= debug_make_float_type (dhandle
, 4);
3315 /* IEEE double precision (64 bit). */
3317 rettype
= debug_make_float_type (dhandle
, 8);
3320 /* This is an IEEE double on the RS/6000, and different machines
3321 with different sizes for "long double" should use different
3322 negative type numbers. See stabs.texinfo. */
3323 name
= "long double";
3324 rettype
= debug_make_float_type (dhandle
, 8);
3328 rettype
= debug_make_int_type (dhandle
, 4, false);
3332 rettype
= debug_make_bool_type (dhandle
, 4);
3335 name
= "short real";
3336 rettype
= debug_make_float_type (dhandle
, 4);
3340 rettype
= debug_make_float_type (dhandle
, 8);
3350 rettype
= debug_make_int_type (dhandle
, 1, true);
3354 rettype
= debug_make_bool_type (dhandle
, 1);
3358 rettype
= debug_make_bool_type (dhandle
, 2);
3362 rettype
= debug_make_bool_type (dhandle
, 4);
3366 rettype
= debug_make_bool_type (dhandle
, 4);
3369 /* Complex type consisting of two IEEE single precision values. */
3371 rettype
= debug_make_complex_type (dhandle
, 8);
3374 /* Complex type consisting of two IEEE double precision values. */
3375 name
= "double complex";
3376 rettype
= debug_make_complex_type (dhandle
, 16);
3380 rettype
= debug_make_int_type (dhandle
, 1, false);
3384 rettype
= debug_make_int_type (dhandle
, 2, false);
3388 rettype
= debug_make_int_type (dhandle
, 4, false);
3393 rettype
= debug_make_int_type (dhandle
, 2, false);
3397 rettype
= debug_make_int_type (dhandle
, 8, false);
3400 name
= "unsigned long long";
3401 rettype
= debug_make_int_type (dhandle
, 8, true);
3405 rettype
= debug_make_bool_type (dhandle
, 8);
3409 rettype
= debug_make_int_type (dhandle
, 8, false);
3415 rettype
= debug_name_type (dhandle
, name
, rettype
);
3417 info
->xcoff_types
[-typenum
] = rettype
;
3422 /* Find or create a tagged type. */
3425 stab_find_tagged_type (dhandle
, info
, p
, len
, kind
)
3427 struct stab_handle
*info
;
3430 enum debug_type_kind kind
;
3434 struct stab_tag
*st
;
3436 name
= savestring (p
, len
);
3438 /* We pass DEBUG_KIND_ILLEGAL because we want all tags in the same
3439 namespace. This is right for C, and I don't know how to handle
3440 other languages. FIXME. */
3441 dtype
= debug_find_tagged_type (dhandle
, name
, DEBUG_KIND_ILLEGAL
);
3442 if (dtype
!= DEBUG_TYPE_NULL
)
3448 /* We need to allocate an entry on the undefined tag list. */
3449 for (st
= info
->tags
; st
!= NULL
; st
= st
->next
)
3451 if (st
->name
[0] == name
[0]
3452 && strcmp (st
->name
, name
) == 0)
3454 if (st
->kind
== DEBUG_KIND_ILLEGAL
)
3462 st
= (struct stab_tag
*) xmalloc (sizeof *st
);
3463 memset (st
, 0, sizeof *st
);
3465 st
->next
= info
->tags
;
3468 st
->slot
= DEBUG_TYPE_NULL
;
3469 st
->type
= debug_make_indirect_type (dhandle
, &st
->slot
, name
);
3476 /* In order to get the correct argument types for a stubbed method, we
3477 need to extract the argument types from a C++ mangled string.
3478 Since the argument types can refer back to the return type, this
3479 means that we must demangle the entire physical name. In gdb this
3480 is done by calling cplus_demangle and running the results back
3481 through the C++ expression parser. Since we have no expression
3482 parser, we must duplicate much of the work of cplus_demangle here.
3484 We assume that GNU style demangling is used, since this is only
3485 done for method stubs, and only g++ should output that form of
3486 debugging information. */
3488 /* This structure is used to hold a pointer to type information which
3489 demangling a string. */
3491 struct stab_demangle_typestring
3493 /* The start of the type. This is not null terminated. */
3494 const char *typestring
;
3495 /* The length of the type. */
3499 /* This structure is used to hold information while demangling a
3502 struct stab_demangle_info
3504 /* The debugging information handle. */
3506 /* The stab information handle. */
3507 struct stab_handle
*info
;
3508 /* The array of arguments we are building. */
3510 /* Whether the method takes a variable number of arguments. */
3512 /* The array of types we have remembered. */
3513 struct stab_demangle_typestring
*typestrings
;
3514 /* The number of typestrings. */
3515 unsigned int typestring_count
;
3516 /* The number of typestring slots we have allocated. */
3517 unsigned int typestring_alloc
;
3520 static void stab_bad_demangle
PARAMS ((const char *));
3521 static unsigned int stab_demangle_count
PARAMS ((const char **));
3522 static boolean stab_demangle_get_count
3523 PARAMS ((const char **, unsigned int *));
3524 static boolean stab_demangle_prefix
3525 PARAMS ((struct stab_demangle_info
*, const char **));
3526 static boolean stab_demangle_function_name
3527 PARAMS ((struct stab_demangle_info
*, const char **, const char *));
3528 static boolean stab_demangle_signature
3529 PARAMS ((struct stab_demangle_info
*, const char **));
3530 static boolean stab_demangle_qualified
3531 PARAMS ((struct stab_demangle_info
*, const char **, debug_type
*));
3532 static boolean stab_demangle_template
3533 PARAMS ((struct stab_demangle_info
*, const char **));
3534 static boolean stab_demangle_class
3535 PARAMS ((struct stab_demangle_info
*, const char **, const char **));
3536 static boolean stab_demangle_args
3537 PARAMS ((struct stab_demangle_info
*, const char **, debug_type
**,
3539 static boolean stab_demangle_arg
3540 PARAMS ((struct stab_demangle_info
*, const char **, debug_type
**,
3541 unsigned int *, unsigned int *));
3542 static boolean stab_demangle_type
3543 PARAMS ((struct stab_demangle_info
*, const char **, debug_type
*));
3544 static boolean stab_demangle_fund_type
3545 PARAMS ((struct stab_demangle_info
*, const char **, debug_type
*));
3546 static boolean stab_demangle_remember_type
3547 PARAMS ((struct stab_demangle_info
*, const char *, int));
3549 /* Warn about a bad demangling. */
3552 stab_bad_demangle (s
)
3555 fprintf (stderr
, "bad mangled name `%s'\n", s
);
3558 /* Get a count from a stab string. */
3561 stab_demangle_count (pp
)
3567 while (isdigit ((unsigned char) **pp
))
3570 count
+= **pp
- '0';
3576 /* Require a count in a string. The count may be multiple digits, in
3577 which case it must end in an underscore. */
3580 stab_demangle_get_count (pp
, pi
)
3584 if (! isdigit ((unsigned char) **pp
))
3589 if (isdigit ((unsigned char) **pp
))
3602 while (isdigit ((unsigned char) *p
));
3613 /* This function demangles a physical name, returning a NULL
3614 terminated array of argument types. */
3617 stab_demangle_argtypes (dhandle
, info
, physname
, pvarargs
)
3619 struct stab_handle
*info
;
3620 const char *physname
;
3623 struct stab_demangle_info minfo
;
3625 minfo
.dhandle
= dhandle
;
3628 minfo
.varargs
= false;
3629 minfo
.typestring_alloc
= 10;
3630 minfo
.typestrings
= ((struct stab_demangle_typestring
*)
3631 xmalloc (minfo
.typestring_alloc
3632 * sizeof *minfo
.typestrings
));
3633 minfo
.typestring_count
= 0;
3635 /* cplus_demangle checks for special GNU mangled forms, but we can't
3636 see any of them in mangled method argument types. */
3638 if (! stab_demangle_prefix (&minfo
, &physname
))
3641 if (*physname
!= '\0')
3643 if (! stab_demangle_signature (&minfo
, &physname
))
3647 free (minfo
.typestrings
);
3648 minfo
.typestrings
= NULL
;
3650 if (minfo
.args
== NULL
)
3651 fprintf (stderr
, "no argument types in mangled string\n");
3653 *pvarargs
= minfo
.varargs
;
3657 if (minfo
.typestrings
!= NULL
)
3658 free (minfo
.typestrings
);
3662 /* Demangle the prefix of the mangled name. */
3665 stab_demangle_prefix (minfo
, pp
)
3666 struct stab_demangle_info
*minfo
;
3672 /* cplus_demangle checks for global constructors and destructors,
3673 but we can't see them in mangled argument types. */
3675 /* Look for `__'. */
3679 scan
= strchr (scan
, '_');
3681 while (scan
!= NULL
&& *++scan
!= '_');
3685 stab_bad_demangle (*pp
);
3691 /* We found `__'; move ahead to the last contiguous `__' pair. */
3692 i
= strspn (scan
, "_");
3697 && (isdigit ((unsigned char) scan
[2])
3701 /* This is a GNU style constructor name. */
3705 else if (scan
== *pp
3706 && ! isdigit ((unsigned char) scan
[2])
3709 /* Look for the `__' that separates the prefix from the
3711 while (*scan
== '_')
3713 scan
= strstr (scan
, "__");
3714 if (scan
== NULL
|| scan
[2] == '\0')
3716 stab_bad_demangle (*pp
);
3720 return stab_demangle_function_name (minfo
, pp
, scan
);
3722 else if (scan
[2] != '\0')
3724 /* The name doesn't start with `__', but it does contain `__'. */
3725 return stab_demangle_function_name (minfo
, pp
, scan
);
3729 stab_bad_demangle (*pp
);
3735 /* Demangle a function name prefix. The scan argument points to the
3736 double underscore which separates the function name from the
3740 stab_demangle_function_name (minfo
, pp
, scan
)
3741 struct stab_demangle_info
*minfo
;
3747 /* The string from *pp to scan is the name of the function. We
3748 don't care about the name, since we just looking for argument
3749 types. However, for conversion operators, the name may include a
3750 type which we must remember in order to handle backreferences. */
3756 && strncmp (name
, "type", 4) == 0
3757 && (name
[4] == '$' || name
[4] == '.'))
3761 /* This is a type conversion operator. */
3763 if (! stab_demangle_type (minfo
, &tem
, (debug_type
*) NULL
))
3766 else if (name
[0] == '_'
3773 /* This is a type conversion operator. */
3775 if (! stab_demangle_type (minfo
, &tem
, (debug_type
*) NULL
))
3782 /* Demangle the signature. This is where the argument types are
3786 stab_demangle_signature (minfo
, pp
)
3787 struct stab_demangle_info
*minfo
;
3791 boolean expect_func
, func_done
;
3796 expect_func
= false;
3800 while (**pp
!= '\0')
3806 if (! stab_demangle_qualified (minfo
, pp
, (debug_type
*) NULL
)
3807 || ! stab_demangle_remember_type (minfo
, hold
, *pp
- hold
))
3814 /* Static member function. FIXME: Can this happen? */
3821 /* Const member function. */
3827 case '0': case '1': case '2': case '3': case '4':
3828 case '5': case '6': case '7': case '8': case '9':
3831 if (! stab_demangle_class (minfo
, pp
, (const char **) NULL
)
3832 || ! stab_demangle_remember_type (minfo
, hold
, *pp
- hold
))
3839 /* Function. I don't know if this actually happens with g++
3844 if (! stab_demangle_args (minfo
, pp
, &minfo
->args
, &minfo
->varargs
))
3852 if (! stab_demangle_template (minfo
, pp
)
3853 || ! stab_demangle_remember_type (minfo
, hold
, *pp
- hold
))
3860 /* At the outermost level, we cannot have a return type
3861 specified, so if we run into another '_' at this point we
3862 are dealing with a mangled name that is either bogus, or
3863 has been mangled by some algorithm we don't know how to
3864 deal with. So just reject the entire demangling. */
3865 stab_bad_demangle (orig
);
3869 /* Assume we have stumbled onto the first outermost function
3870 argument token, and start processing args. */
3872 if (! stab_demangle_args (minfo
, pp
, &minfo
->args
, &minfo
->varargs
))
3880 if (! stab_demangle_args (minfo
, pp
, &minfo
->args
, &minfo
->varargs
))
3887 /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and
3888 bar__3fooi is 'foo::bar(int)'. We get here when we find the
3889 first case, and need to ensure that the '(void)' gets added
3890 to the current declp. */
3891 if (! stab_demangle_args (minfo
, pp
, &minfo
->args
, &minfo
->varargs
))
3898 /* Demangle a qualified name, such as "Q25Outer5Inner" which is the
3899 mangled form of "Outer::Inner". */
3902 stab_demangle_qualified (minfo
, pp
, ptype
)
3903 struct stab_demangle_info
*minfo
;
3909 unsigned int qualifiers
;
3917 /* GNU mangled name with more than 9 classes. The count is
3918 preceded by an underscore (to distinguish it from the <= 9
3919 case) and followed by an underscore. */
3921 if (! isdigit ((unsigned char) *p
) || *p
== '0')
3923 stab_bad_demangle (orig
);
3926 qualifiers
= atoi (p
);
3927 while (isdigit ((unsigned char) *p
))
3931 stab_bad_demangle (orig
);
3937 case '1': case '2': case '3': case '4': case '5':
3938 case '6': case '7': case '8': case '9':
3939 qualifiers
= (*pp
)[1] - '0';
3940 /* Skip an optional underscore after the count. */
3941 if ((*pp
)[2] == '_')
3948 stab_bad_demangle (orig
);
3952 context
= DEBUG_TYPE_NULL
;
3954 /* Pick off the names. */
3955 while (qualifiers
-- > 0)
3961 /* FIXME: I don't know how to handle the ptype != NULL case
3963 if (! stab_demangle_template (minfo
, pp
))
3970 len
= stab_demangle_count (pp
);
3971 if (strlen (*pp
) < len
)
3973 stab_bad_demangle (orig
);
3979 const debug_field
*fields
;
3982 if (context
!= DEBUG_TYPE_NULL
)
3983 fields
= debug_get_fields (minfo
->dhandle
, context
);
3985 context
= DEBUG_TYPE_NULL
;
3991 /* Try to find the type by looking through the
3992 fields of context until we find a field with the
3993 same type. This ought to work for a class
3994 defined within a class, but it won't work for,
3995 e.g., an enum defined within a class. stabs does
3996 not give us enough information to figure out the
3999 name
= savestring (*pp
, len
);
4001 for (; *fields
!= DEBUG_FIELD_NULL
; fields
++)
4006 ft
= debug_get_field_type (minfo
->dhandle
, *fields
);
4009 dn
= debug_get_type_name (minfo
->dhandle
, ft
);
4010 if (dn
!= NULL
&& strcmp (dn
, name
) == 0)
4020 if (context
== DEBUG_TYPE_NULL
)
4022 /* We have to fall back on finding the type by name.
4023 If there are more types to come, then this must
4024 be a class. Otherwise, it could be anything. */
4026 if (qualifiers
== 0)
4030 name
= savestring (*pp
, len
);
4031 context
= debug_find_named_type (minfo
->dhandle
,
4036 if (context
== DEBUG_TYPE_NULL
)
4038 context
= stab_find_tagged_type (minfo
->dhandle
,
4042 ? DEBUG_KIND_ILLEGAL
4043 : DEBUG_KIND_CLASS
));
4044 if (context
== DEBUG_TYPE_NULL
)
4060 /* Demangle a template. */
4063 stab_demangle_template (minfo
, pp
)
4064 struct stab_demangle_info
*minfo
;
4074 /* Skip the template name. */
4075 r
= stab_demangle_count (pp
);
4076 if (r
== 0 || strlen (*pp
) < r
)
4078 stab_bad_demangle (orig
);
4083 /* Get the size of the parameter list. */
4084 if (stab_demangle_get_count (pp
, &r
) == 0)
4086 stab_bad_demangle (orig
);
4090 for (i
= 0; i
< r
; i
++)
4094 /* This is a type parameter. */
4096 if (! stab_demangle_type (minfo
, pp
, (debug_type
*) NULL
))
4102 boolean pointerp
, realp
, integralp
, charp
, boolp
;
4113 /* This is a value parameter. */
4115 if (! stab_demangle_type (minfo
, pp
, (debug_type
*) NULL
))
4118 while (*old_p
!= '\0' && ! done
)
4128 case 'C': /* Const. */
4129 case 'S': /* Signed. */
4130 case 'U': /* Unsigned. */
4131 case 'V': /* Volatile. */
4132 case 'F': /* Function. */
4133 case 'M': /* Member function. */
4137 case 'Q': /* Qualified name. */
4141 case 'T': /* Remembered type. */
4143 case 'v': /* Void. */
4145 case 'x': /* Long long. */
4146 case 'l': /* Long. */
4147 case 'i': /* Int. */
4148 case 's': /* Short. */
4149 case 'w': /* Wchar_t. */
4153 case 'b': /* Bool. */
4157 case 'c': /* Char. */
4161 case 'r': /* Long double. */
4162 case 'd': /* Double. */
4163 case 'f': /* Float. */
4168 /* Assume it's a uder defined integral type. */
4179 while (isdigit ((unsigned char) **pp
))
4188 val
= stab_demangle_count (pp
);
4191 stab_bad_demangle (orig
);
4199 val
= stab_demangle_count (pp
);
4200 if (val
!= 0 && val
!= 1)
4202 stab_bad_demangle (orig
);
4210 while (isdigit ((unsigned char) **pp
))
4215 while (isdigit ((unsigned char) **pp
))
4221 while (isdigit ((unsigned char) **pp
))
4229 if (! stab_demangle_get_count (pp
, &len
))
4231 stab_bad_demangle (orig
);
4242 /* Demangle a class name. */
4245 stab_demangle_class (minfo
, pp
, pstart
)
4246 struct stab_demangle_info
*minfo
;
4248 const char **pstart
;
4255 n
= stab_demangle_count (pp
);
4256 if (strlen (*pp
) < n
)
4258 stab_bad_demangle (orig
);
4270 /* Demangle function arguments. If the pargs argument is not NULL, it
4271 is set to a NULL terminated array holding the arguments. */
4274 stab_demangle_args (minfo
, pp
, pargs
, pvarargs
)
4275 struct stab_demangle_info
*minfo
;
4281 unsigned int alloc
, count
;
4288 *pargs
= (debug_type
*) xmalloc (alloc
* sizeof **pargs
);
4293 while (**pp
!= '_' && **pp
!= '\0' && **pp
!= 'e')
4295 if (**pp
== 'N' || **pp
== 'T')
4303 if (temptype
== 'T')
4307 if (! stab_demangle_get_count (pp
, &r
))
4309 stab_bad_demangle (orig
);
4314 if (! stab_demangle_get_count (pp
, &t
))
4316 stab_bad_demangle (orig
);
4320 if (t
>= minfo
->typestring_count
)
4322 stab_bad_demangle (orig
);
4329 tem
= minfo
->typestrings
[t
].typestring
;
4330 if (! stab_demangle_arg (minfo
, &tem
, pargs
, &count
, &alloc
))
4336 if (! stab_demangle_arg (minfo
, pp
, pargs
, &count
, &alloc
))
4342 (*pargs
)[count
] = DEBUG_TYPE_NULL
;
4354 /* Demangle a single argument. */
4357 stab_demangle_arg (minfo
, pp
, pargs
, pcount
, palloc
)
4358 struct stab_demangle_info
*minfo
;
4361 unsigned int *pcount
;
4362 unsigned int *palloc
;
4368 if (! stab_demangle_type (minfo
, pp
,
4369 pargs
== NULL
? (debug_type
*) NULL
: &type
)
4370 || ! stab_demangle_remember_type (minfo
, start
, *pp
- start
))
4375 if (type
== DEBUG_TYPE_NULL
)
4378 if (*pcount
+ 1 >= *palloc
)
4381 *pargs
= ((debug_type
*)
4382 xrealloc (*pargs
, *palloc
* sizeof **pargs
));
4384 (*pargs
)[*pcount
] = type
;
4391 /* Demangle a type. If the ptype argument is not NULL, *ptype is set
4392 to the newly allocated type. */
4395 stab_demangle_type (minfo
, pp
, ptype
)
4396 struct stab_demangle_info
*minfo
;
4408 /* A pointer type. */
4410 if (! stab_demangle_type (minfo
, pp
, ptype
))
4413 *ptype
= debug_make_pointer_type (minfo
->dhandle
, *ptype
);
4417 /* A reference type. */
4419 if (! stab_demangle_type (minfo
, pp
, ptype
))
4422 *ptype
= debug_make_reference_type (minfo
->dhandle
, *ptype
);
4432 while (**pp
!= '\0' && **pp
!= '_')
4434 if (! isdigit ((unsigned char) **pp
))
4436 stab_bad_demangle (orig
);
4445 stab_bad_demangle (orig
);
4450 if (! stab_demangle_type (minfo
, pp
, ptype
))
4454 debug_type int_type
;
4456 int_type
= debug_find_named_type (minfo
->dhandle
, "int");
4457 if (int_type
== NULL
)
4458 int_type
= debug_make_int_type (minfo
->dhandle
, 4, false);
4459 *ptype
= debug_make_array_type (minfo
->dhandle
, *ptype
, int_type
,
4466 /* A back reference to a remembered type. */
4472 if (! stab_demangle_get_count (pp
, &i
))
4474 stab_bad_demangle (orig
);
4477 if (i
>= minfo
->typestring_count
)
4479 stab_bad_demangle (orig
);
4482 p
= minfo
->typestrings
[i
].typestring
;
4483 if (! stab_demangle_type (minfo
, &p
, ptype
))
4495 if (! stab_demangle_args (minfo
, pp
,
4497 ? (debug_type
**) NULL
4505 /* cplus_demangle will accept a function without a return
4506 type, but I don't know when that will happen, or what
4507 to do if it does. */
4508 stab_bad_demangle (orig
);
4512 if (! stab_demangle_type (minfo
, pp
, ptype
))
4515 *ptype
= debug_make_function_type (minfo
->dhandle
, *ptype
, args
,
4524 boolean memberp
, constp
, volatilep
;
4530 memberp
= **pp
== 'M';
4537 if (! isdigit ((unsigned char) **pp
))
4539 stab_bad_demangle (orig
);
4542 n
= stab_demangle_count (pp
);
4543 if (strlen (*pp
) < n
)
4545 stab_bad_demangle (orig
);
4558 else if (**pp
== 'V')
4565 stab_bad_demangle (orig
);
4569 if (! stab_demangle_args (minfo
, pp
,
4571 ? (debug_type
**) NULL
4581 stab_bad_demangle (orig
);
4586 if (! stab_demangle_type (minfo
, pp
, ptype
))
4591 debug_type class_type
;
4593 class_type
= stab_find_tagged_type (minfo
->dhandle
, minfo
->info
,
4596 if (class_type
== DEBUG_TYPE_NULL
)
4600 *ptype
= debug_make_offset_type (minfo
->dhandle
, class_type
,
4604 /* FIXME: We have no way to record constp or
4606 *ptype
= debug_make_method_type (minfo
->dhandle
, *ptype
,
4607 class_type
, args
, varargs
);
4615 if (! stab_demangle_type (minfo
, pp
, ptype
))
4621 if (! stab_demangle_type (minfo
, pp
, ptype
))
4624 *ptype
= debug_make_const_type (minfo
->dhandle
, *ptype
);
4632 if (! stab_demangle_qualified (minfo
, pp
, ptype
))
4638 if (! stab_demangle_fund_type (minfo
, pp
, ptype
))
4646 /* Demangle a fundamental type. If the ptype argument is not NULL,
4647 *ptype is set to the newly allocated type. */
4650 stab_demangle_fund_type (minfo
, pp
, ptype
)
4651 struct stab_demangle_info
*minfo
;
4656 boolean constp
, volatilep
, unsignedp
, signedp
;
4701 /* cplus_demangle permits this, but I don't know what it means. */
4702 stab_bad_demangle (orig
);
4705 case 'v': /* void */
4708 *ptype
= debug_find_named_type (minfo
->dhandle
, "void");
4709 if (*ptype
== DEBUG_TYPE_NULL
)
4710 *ptype
= debug_make_void_type (minfo
->dhandle
);
4715 case 'x': /* long long */
4718 *ptype
= debug_find_named_type (minfo
->dhandle
,
4720 ? "long long unsigned int"
4721 : "long long int"));
4722 if (*ptype
== DEBUG_TYPE_NULL
)
4723 *ptype
= debug_make_int_type (minfo
->dhandle
, 8, unsignedp
);
4728 case 'l': /* long */
4731 *ptype
= debug_find_named_type (minfo
->dhandle
,
4733 ? "long unsigned int"
4735 if (*ptype
== DEBUG_TYPE_NULL
)
4736 *ptype
= debug_make_int_type (minfo
->dhandle
, 4, unsignedp
);
4744 *ptype
= debug_find_named_type (minfo
->dhandle
,
4748 if (*ptype
== DEBUG_TYPE_NULL
)
4749 *ptype
= debug_make_int_type (minfo
->dhandle
, 4, unsignedp
);
4754 case 's': /* short */
4757 *ptype
= debug_find_named_type (minfo
->dhandle
,
4759 ? "short unsigned int"
4761 if (*ptype
== DEBUG_TYPE_NULL
)
4762 *ptype
= debug_make_int_type (minfo
->dhandle
, 2, unsignedp
);
4767 case 'b': /* bool */
4770 *ptype
= debug_find_named_type (minfo
->dhandle
, "bool");
4771 if (*ptype
== DEBUG_TYPE_NULL
)
4772 *ptype
= debug_make_bool_type (minfo
->dhandle
, 4);
4777 case 'c': /* char */
4780 *ptype
= debug_find_named_type (minfo
->dhandle
,
4786 if (*ptype
== DEBUG_TYPE_NULL
)
4787 *ptype
= debug_make_int_type (minfo
->dhandle
, 1, unsignedp
);
4792 case 'w': /* wchar_t */
4795 *ptype
= debug_find_named_type (minfo
->dhandle
, "__wchar_t");
4796 if (*ptype
== DEBUG_TYPE_NULL
)
4797 *ptype
= debug_make_int_type (minfo
->dhandle
, 2, true);
4802 case 'r': /* long double */
4805 *ptype
= debug_find_named_type (minfo
->dhandle
, "long double");
4806 if (*ptype
== DEBUG_TYPE_NULL
)
4807 *ptype
= debug_make_float_type (minfo
->dhandle
, 8);
4812 case 'd': /* double */
4815 *ptype
= debug_find_named_type (minfo
->dhandle
, "double");
4816 if (*ptype
== DEBUG_TYPE_NULL
)
4817 *ptype
= debug_make_float_type (minfo
->dhandle
, 8);
4822 case 'f': /* float */
4825 *ptype
= debug_find_named_type (minfo
->dhandle
, "float");
4826 if (*ptype
== DEBUG_TYPE_NULL
)
4827 *ptype
= debug_make_float_type (minfo
->dhandle
, 4);
4834 if (! isdigit ((unsigned char) **pp
))
4836 stab_bad_demangle (orig
);
4840 case '0': case '1': case '2': case '3': case '4':
4841 case '5': case '6': case '7': case '8': case '9':
4845 if (! stab_demangle_class (minfo
, pp
, &hold
))
4851 name
= savestring (hold
, *pp
- hold
);
4852 *ptype
= debug_find_named_type (minfo
->dhandle
, name
);
4853 if (*ptype
== DEBUG_TYPE_NULL
)
4855 /* FIXME: It is probably incorrect to assume that
4856 undefined types are tagged types. */
4857 *ptype
= stab_find_tagged_type (minfo
->dhandle
, minfo
->info
,
4859 DEBUG_KIND_ILLEGAL
);
4867 if (! stab_demangle_template (minfo
, pp
))
4873 stab_bad_demangle (orig
);
4880 *ptype
= debug_make_const_type (minfo
->dhandle
, *ptype
);
4882 *ptype
= debug_make_volatile_type (minfo
->dhandle
, *ptype
);
4888 /* Remember a type string in a demangled string. */
4891 stab_demangle_remember_type (minfo
, p
, len
)
4892 struct stab_demangle_info
*minfo
;
4896 if (minfo
->typestring_count
>= minfo
->typestring_alloc
)
4898 minfo
->typestring_alloc
+= 10;
4899 minfo
->typestrings
= ((struct stab_demangle_typestring
*)
4900 xrealloc (minfo
->typestrings
,
4901 (minfo
->typestring_alloc
4902 * sizeof *minfo
->typestrings
)));
4905 minfo
->typestrings
[minfo
->typestring_count
].typestring
= p
;
4906 minfo
->typestrings
[minfo
->typestring_count
].len
= (unsigned int) len
;
4907 ++minfo
->typestring_count
;