1 /* ieee.c -- Read and write IEEE-695 debugging information.
2 Copyright (C) 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 reads and writes IEEE-695 debugging information. */
30 #include "libiberty.h"
34 /* This structure holds an entry on the block stack. */
38 /* The kind of block. */
40 /* The source file name, for a BB5 block. */
42 /* The index of the function type, for a BB4 or BB6 block. */
46 /* This structure is the block stack. */
48 #define BLOCKSTACK_SIZE (16)
50 struct ieee_blockstack
52 /* The stack pointer. */
53 struct ieee_block
*bsp
;
55 struct ieee_block stack
[BLOCKSTACK_SIZE
];
58 /* This structure holds information for a variable. */
68 /* Slot if we make an indirect type. */
70 /* Kind of variable (DEBUG_VAR_ILLEGAL if not a variable). */
71 enum debug_var_kind variable
;
74 /* This structure holds all the variables. */
78 /* Number of slots allocated. */
81 struct ieee_var
*vars
;
84 /* This structure holds information for a type. We need this because
85 we don't want to represent bitfields as real types. */
91 /* Slot if this is type is referenced before it is defined. */
93 /* Slots for arguments if we make indirect types for them. */
94 debug_type
*arg_slots
;
95 /* If this is a bitfield, this is the size in bits. If this is not
96 a bitfield, this is zero. */
97 unsigned long bitsize
;
100 /* This structure holds all the type information. */
104 /* Number of slots allocated. */
107 struct ieee_type
*types
;
109 #define BUILTIN_TYPE_COUNT (60)
110 debug_type builtins
[BUILTIN_TYPE_COUNT
];
113 /* This structure holds a linked last of structs with their tag names,
114 so that we can convert them to C++ classes if necessary. */
119 struct ieee_tag
*next
;
122 /* The type of the tag. */
124 /* The tagged type is an indirect type pointing at this slot. */
126 /* This is an array of slots used when a field type is converted
127 into a indirect type, in case it needs to be later converted into
132 /* This structure holds the information we pass around to the parsing
137 /* The debugging handle. */
141 /* The start of the bytes to be parsed. */
142 const bfd_byte
*bytes
;
143 /* The end of the bytes to be parsed. */
144 const bfd_byte
*pend
;
145 /* The block stack. */
146 struct ieee_blockstack blockstack
;
148 struct ieee_vars vars
;
150 struct ieee_types types
;
151 /* The list of tagged structs. */
152 struct ieee_tag
*tags
;
155 /* Basic builtin types, not including the pointers. */
161 builtin_signed_char
= 2,
162 builtin_unsigned_char
= 3,
163 builtin_signed_short_int
= 4,
164 builtin_unsigned_short_int
= 5,
165 builtin_signed_long
= 6,
166 builtin_unsigned_long
= 7,
167 builtin_signed_long_long
= 8,
168 builtin_unsigned_long_long
= 9,
171 builtin_long_double
= 12,
172 builtin_long_long_double
= 13,
173 builtin_quoted_string
= 14,
174 builtin_instruction_address
= 15,
176 builtin_unsigned
= 17,
177 builtin_unsigned_int
= 18,
181 builtin_unsigned_short
= 22,
182 builtin_short_int
= 23,
183 builtin_signed_short
= 24,
184 builtin_bcd_float
= 25
187 /* These are the values found in the derivation flags of a 'b'
188 component record of a 'T' type extension record in a C++ pmisc
189 record. These are bitmasks. */
191 /* Set for a private base class, clear for a public base class.
192 Protected base classes are not supported. */
193 #define BASEFLAGS_PRIVATE (0x1)
194 /* Set for a virtual base class. */
195 #define BASEFLAGS_VIRTUAL (0x2)
196 /* Set for a friend class, clear for a base class. */
197 #define BASEFLAGS_FRIEND (0x10)
199 /* These are the values found in the specs flags of a 'd', 'm', or 'v'
200 component record of a 'T' type extension record in a C++ pmisc
201 record. The same flags are used for a 'M' record in a C++ pmisc
204 /* The lower two bits hold visibility information. */
205 #define CXXFLAGS_VISIBILITY (0x3)
206 /* This value in the lower two bits indicates a public member. */
207 #define CXXFLAGS_VISIBILITY_PUBLIC (0x0)
208 /* This value in the lower two bits indicates a private member. */
209 #define CXXFLAGS_VISIBILITY_PRIVATE (0x1)
210 /* This value in the lower two bits indicates a protected member. */
211 #define CXXFLAGS_VISIBILITY_PROTECTED (0x2)
212 /* Set for a static member. */
213 #define CXXFLAGS_STATIC (0x4)
214 /* Set for a virtual override. */
215 #define CXXFLAGS_OVERRIDE (0x8)
216 /* Set for a friend function. */
217 #define CXXFLAGS_FRIEND (0x10)
218 /* Set for a const function. */
219 #define CXXFLAGS_CONST (0x20)
220 /* Set for a volatile function. */
221 #define CXXFLAGS_VOLATILE (0x40)
222 /* Set for an overloaded function. */
223 #define CXXFLAGS_OVERLOADED (0x80)
224 /* Set for an operator function. */
225 #define CXXFLAGS_OPERATOR (0x100)
226 /* Set for a constructor or destructor. */
227 #define CXXFLAGS_CTORDTOR (0x400)
228 /* Set for a constructor. */
229 #define CXXFLAGS_CTOR (0x200)
230 /* Set for an inline function. */
231 #define CXXFLAGS_INLINE (0x800)
233 /* Local functions. */
235 static void ieee_error
236 PARAMS ((struct ieee_info
*, const bfd_byte
*, const char *));
237 static void ieee_eof
PARAMS ((struct ieee_info
*));
238 static char *savestring
PARAMS ((const char *, unsigned long));
239 static boolean ieee_read_number
240 PARAMS ((struct ieee_info
*, const bfd_byte
**, bfd_vma
*));
241 static boolean ieee_read_optional_number
242 PARAMS ((struct ieee_info
*, const bfd_byte
**, bfd_vma
*, boolean
*));
243 static boolean ieee_read_id
244 PARAMS ((struct ieee_info
*, const bfd_byte
**, const char **,
246 static boolean ieee_read_optional_id
247 PARAMS ((struct ieee_info
*, const bfd_byte
**, const char **,
248 unsigned long *, boolean
*));
249 static boolean ieee_read_expression
250 PARAMS ((struct ieee_info
*, const bfd_byte
**, bfd_vma
*));
251 static debug_type ieee_builtin_type
252 PARAMS ((struct ieee_info
*, const bfd_byte
*, unsigned int));
253 static boolean ieee_alloc_type
254 PARAMS ((struct ieee_info
*, unsigned int, boolean
));
255 static boolean ieee_read_type_index
256 PARAMS ((struct ieee_info
*, const bfd_byte
**, debug_type
*));
257 static int ieee_regno_to_genreg
PARAMS ((bfd
*, int));
258 static int ieee_genreg_to_regno
PARAMS ((bfd
*, int));
259 static boolean parse_ieee_bb
PARAMS ((struct ieee_info
*, const bfd_byte
**));
260 static boolean parse_ieee_be
PARAMS ((struct ieee_info
*, const bfd_byte
**));
261 static boolean parse_ieee_nn
PARAMS ((struct ieee_info
*, const bfd_byte
**));
262 static boolean parse_ieee_ty
PARAMS ((struct ieee_info
*, const bfd_byte
**));
263 static boolean parse_ieee_atn
PARAMS ((struct ieee_info
*, const bfd_byte
**));
264 static boolean ieee_read_cxx_misc
265 PARAMS ((struct ieee_info
*, const bfd_byte
**, unsigned long));
266 static boolean ieee_read_cxx_class
267 PARAMS ((struct ieee_info
*, const bfd_byte
**, unsigned long));
268 static boolean ieee_read_cxx_defaults
269 PARAMS ((struct ieee_info
*, const bfd_byte
**, unsigned long));
270 static boolean ieee_read_reference
271 PARAMS ((struct ieee_info
*, const bfd_byte
**));
272 static boolean ieee_require_asn
273 PARAMS ((struct ieee_info
*, const bfd_byte
**, bfd_vma
*));
274 static boolean ieee_require_atn65
275 PARAMS ((struct ieee_info
*, const bfd_byte
**, const char **,
278 /* Report an error in the IEEE debugging information. */
281 ieee_error (info
, p
, s
)
282 struct ieee_info
*info
;
287 fprintf (stderr
, "%s: 0x%lx: %s (0x%x)\n", bfd_get_filename (info
->abfd
),
288 (unsigned long) (p
- info
->bytes
), s
, *p
);
290 fprintf (stderr
, "%s: %s\n", bfd_get_filename (info
->abfd
), s
);
293 /* Report an unexpected EOF in the IEEE debugging information. */
297 struct ieee_info
*info
;
299 ieee_error (info
, (const bfd_byte
*) NULL
,
300 "unexpected end of debugging information");
303 /* Save a string in memory. */
306 savestring (start
, len
)
312 ret
= (char *) xmalloc (len
+ 1);
313 memcpy (ret
, start
, len
);
318 /* Read a number which must be present in an IEEE file. */
321 ieee_read_number (info
, pp
, pv
)
322 struct ieee_info
*info
;
326 return ieee_read_optional_number (info
, pp
, pv
, (boolean
*) NULL
);
329 /* Read a number in an IEEE file. If ppresent is not NULL, the number
330 need not be there. */
333 ieee_read_optional_number (info
, pp
, pv
, ppresent
)
334 struct ieee_info
*info
;
339 ieee_record_enum_type b
;
341 if (*pp
>= info
->pend
)
343 if (ppresent
!= NULL
)
352 b
= (ieee_record_enum_type
) **pp
;
355 if (b
<= ieee_number_end_enum
)
358 if (ppresent
!= NULL
)
363 if (b
>= ieee_number_repeat_start_enum
&& b
<= ieee_number_repeat_end_enum
)
367 i
= (int) b
- (int) ieee_number_repeat_start_enum
;
368 if (*pp
+ i
- 1 >= info
->pend
)
382 if (ppresent
!= NULL
)
388 if (ppresent
!= NULL
)
395 ieee_error (info
, *pp
- 1, "invalid number");
399 /* Read a required string from an IEEE file. */
402 ieee_read_id (info
, pp
, pname
, pnamlen
)
403 struct ieee_info
*info
;
406 unsigned long *pnamlen
;
408 return ieee_read_optional_id (info
, pp
, pname
, pnamlen
, (boolean
*) NULL
);
411 /* Read a string from an IEEE file. If ppresent is not NULL, the
412 string is optional. */
415 ieee_read_optional_id (info
, pp
, pname
, pnamlen
, ppresent
)
416 struct ieee_info
*info
;
419 unsigned long *pnamlen
;
425 if (*pp
>= info
->pend
)
436 else if ((ieee_record_enum_type
) b
== ieee_extension_length_1_enum
)
441 else if ((ieee_record_enum_type
) b
== ieee_extension_length_2_enum
)
443 len
= (**pp
<< 8) + (*pp
)[1];
448 if (ppresent
!= NULL
)
454 ieee_error (info
, *pp
- 1, "invalid string length");
458 if ((unsigned long) (info
->pend
- *pp
) < len
)
464 *pname
= (const char *) *pp
;
468 if (ppresent
!= NULL
)
474 /* Read an expression from an IEEE file. Since this code is only used
475 to parse debugging information, I haven't bothered to write a full
476 blown IEEE expression parser. I've only thrown in the things I've
477 seen in debugging information. This can be easily extended if
481 ieee_read_expression (info
, pp
, pv
)
482 struct ieee_info
*info
;
486 const bfd_byte
*expr_start
;
487 #define EXPR_STACK_SIZE (10)
488 bfd_vma expr_stack
[EXPR_STACK_SIZE
];
497 const bfd_byte
*start
;
500 ieee_record_enum_type c
;
504 if (! ieee_read_optional_number (info
, pp
, &val
, &present
))
509 if (esp
- expr_stack
>= EXPR_STACK_SIZE
)
511 ieee_error (info
, start
, "expression stack overflow");
518 c
= (ieee_record_enum_type
) **pp
;
520 if (c
>= ieee_module_beginning_enum
)
531 ieee_error (info
, start
, "unsupported IEEE expression operator");
534 case ieee_variable_R_enum
:
539 if (! ieee_read_number (info
, pp
, &indx
))
541 for (s
= info
->abfd
->sections
; s
!= NULL
; s
= s
->next
)
542 if ((bfd_vma
) s
->target_index
== indx
)
546 ieee_error (info
, start
, "unknown section");
550 if (esp
- expr_stack
>= EXPR_STACK_SIZE
)
552 ieee_error (info
, start
, "expression stack overflow");
556 *esp
++ = bfd_get_section_vma (info
->abfd
, s
);
560 case ieee_function_plus_enum
:
561 case ieee_function_minus_enum
:
565 if (esp
- expr_stack
< 2)
567 ieee_error (info
, start
, "expression stack underflow");
579 if (esp
- 1 != expr_stack
)
581 ieee_error (info
, expr_start
, "expression stack mismatch");
590 /* Return an IEEE builtin type. */
593 ieee_builtin_type (info
, p
, indx
)
594 struct ieee_info
*info
;
602 if (indx
< BUILTIN_TYPE_COUNT
603 && info
->types
.builtins
[indx
] != DEBUG_TYPE_NULL
)
604 return info
->types
.builtins
[indx
];
606 dhandle
= info
->dhandle
;
608 if (indx
>= 32 && indx
< 64)
610 type
= debug_make_pointer_type (dhandle
,
611 ieee_builtin_type (info
, p
, indx
- 32));
612 assert (indx
< BUILTIN_TYPE_COUNT
);
613 info
->types
.builtins
[indx
] = type
;
617 switch ((enum builtin_types
) indx
)
620 ieee_error (info
, p
, "unknown builtin type");
623 case builtin_unknown
:
624 type
= debug_make_void_type (dhandle
);
629 type
= debug_make_void_type (dhandle
);
633 case builtin_signed_char
:
634 type
= debug_make_int_type (dhandle
, 1, false);
635 name
= "signed char";
638 case builtin_unsigned_char
:
639 type
= debug_make_int_type (dhandle
, 1, true);
640 name
= "unsigned char";
643 case builtin_signed_short_int
:
644 type
= debug_make_int_type (dhandle
, 2, false);
645 name
= "signed short int";
648 case builtin_unsigned_short_int
:
649 type
= debug_make_int_type (dhandle
, 2, true);
650 name
= "unsigned short int";
653 case builtin_signed_long
:
654 type
= debug_make_int_type (dhandle
, 4, false);
655 name
= "signed long";
658 case builtin_unsigned_long
:
659 type
= debug_make_int_type (dhandle
, 4, true);
660 name
= "unsigned long";
663 case builtin_signed_long_long
:
664 type
= debug_make_int_type (dhandle
, 8, false);
665 name
= "signed long long";
668 case builtin_unsigned_long_long
:
669 type
= debug_make_int_type (dhandle
, 8, true);
670 name
= "unsigned long long";
674 type
= debug_make_float_type (dhandle
, 4);
679 type
= debug_make_float_type (dhandle
, 8);
683 case builtin_long_double
:
684 /* FIXME: The size for this type should depend upon the
686 type
= debug_make_float_type (dhandle
, 12);
687 name
= "long double";
690 case builtin_long_long_double
:
691 type
= debug_make_float_type (dhandle
, 16);
692 name
= "long long double";
695 case builtin_quoted_string
:
696 type
= debug_make_array_type (dhandle
,
697 ieee_builtin_type (info
, p
,
700 ieee_builtin_type (info
, p
,
704 name
= "QUOTED STRING";
707 case builtin_instruction_address
:
708 /* FIXME: This should be a code address. */
709 type
= debug_make_int_type (dhandle
, 4, true);
710 name
= "instruction address";
714 /* FIXME: The size for this type should depend upon the
716 type
= debug_make_int_type (dhandle
, 4, false);
720 case builtin_unsigned
:
721 /* FIXME: The size for this type should depend upon the
723 type
= debug_make_int_type (dhandle
, 4, true);
727 case builtin_unsigned_int
:
728 /* FIXME: The size for this type should depend upon the
730 type
= debug_make_int_type (dhandle
, 4, true);
731 name
= "unsigned int";
735 type
= debug_make_int_type (dhandle
, 1, false);
740 type
= debug_make_int_type (dhandle
, 4, false);
745 type
= debug_make_int_type (dhandle
, 2, false);
749 case builtin_unsigned_short
:
750 type
= debug_make_int_type (dhandle
, 2, true);
751 name
= "unsigned short";
754 case builtin_short_int
:
755 type
= debug_make_int_type (dhandle
, 2, false);
759 case builtin_signed_short
:
760 type
= debug_make_int_type (dhandle
, 2, false);
761 name
= "signed short";
764 case builtin_bcd_float
:
765 ieee_error (info
, p
, "BCD float type not supported");
770 type
= debug_name_type (dhandle
, name
, type
);
772 assert (indx
< BUILTIN_TYPE_COUNT
);
774 info
->types
.builtins
[indx
] = type
;
779 /* Allocate more space in the type table. If ref is true, this is a
780 reference to the type; if it is not already defined, we should set
781 up an indirect type. */
784 ieee_alloc_type (info
, indx
, ref
)
785 struct ieee_info
*info
;
790 register struct ieee_type
*t
;
791 struct ieee_type
*tend
;
793 if (indx
>= info
->types
.alloc
)
795 nalloc
= info
->types
.alloc
;
798 while (indx
>= nalloc
)
801 info
->types
.types
= ((struct ieee_type
*)
802 xrealloc (info
->types
.types
,
803 nalloc
* sizeof *info
->types
.types
));
805 memset (info
->types
.types
+ info
->types
.alloc
, 0,
806 (nalloc
- info
->types
.alloc
) * sizeof *info
->types
.types
);
808 tend
= info
->types
.types
+ nalloc
;
809 for (t
= info
->types
.types
+ info
->types
.alloc
; t
< tend
; t
++)
810 t
->type
= DEBUG_TYPE_NULL
;
812 info
->types
.alloc
= nalloc
;
817 t
= info
->types
.types
+ indx
;
820 t
->pslot
= (debug_type
*) xmalloc (sizeof *t
->pslot
);
821 *t
->pslot
= DEBUG_TYPE_NULL
;
822 t
->type
= debug_make_indirect_type (info
->dhandle
, t
->pslot
,
823 (const char *) NULL
);
832 /* Read a type index and return the corresponding type. */
835 ieee_read_type_index (info
, pp
, ptype
)
836 struct ieee_info
*info
;
840 const bfd_byte
*start
;
845 if (! ieee_read_number (info
, pp
, &indx
))
850 *ptype
= ieee_builtin_type (info
, start
, indx
);
857 if (! ieee_alloc_type (info
, indx
, true))
860 *ptype
= info
->types
.types
[indx
].type
;
865 /* Parse IEEE debugging information for a file. This is passed the
866 bytes which compose the Debug Information Part of an IEEE file. */
869 parse_ieee (dhandle
, abfd
, bytes
, len
)
872 const bfd_byte
*bytes
;
875 struct ieee_info info
;
877 const bfd_byte
*p
, *pend
;
879 info
.dhandle
= dhandle
;
882 info
.pend
= bytes
+ len
;
883 info
.blockstack
.bsp
= info
.blockstack
.stack
;
885 info
.vars
.vars
= NULL
;
886 info
.types
.alloc
= 0;
887 info
.types
.types
= NULL
;
889 for (i
= 0; i
< BUILTIN_TYPE_COUNT
; i
++)
890 info
.types
.builtins
[i
] = DEBUG_TYPE_NULL
;
896 const bfd_byte
*record_start
;
897 ieee_record_enum_type c
;
901 c
= (ieee_record_enum_type
) *p
++;
903 if (c
== ieee_at_record_enum
)
904 c
= (ieee_record_enum_type
) (((unsigned int) c
<< 8) | *p
++);
906 if (c
<= ieee_number_repeat_end_enum
)
908 ieee_error (&info
, record_start
, "unexpected number");
915 ieee_error (&info
, record_start
, "unexpected record type");
918 case ieee_bb_record_enum
:
919 if (! parse_ieee_bb (&info
, &p
))
923 case ieee_be_record_enum
:
924 if (! parse_ieee_be (&info
, &p
))
929 if (! parse_ieee_nn (&info
, &p
))
933 case ieee_ty_record_enum
:
934 if (! parse_ieee_ty (&info
, &p
))
938 case ieee_atn_record_enum
:
939 if (! parse_ieee_atn (&info
, &p
))
945 if (info
.blockstack
.bsp
!= info
.blockstack
.stack
)
947 ieee_error (&info
, (const bfd_byte
*) NULL
,
948 "blocks left on stack at end");
955 /* Handle an IEEE BB record. */
958 parse_ieee_bb (info
, pp
)
959 struct ieee_info
*info
;
962 const bfd_byte
*block_start
;
966 unsigned long namlen
;
975 if (! ieee_read_number (info
, pp
, &size
)
976 || ! ieee_read_id (info
, pp
, &name
, &namlen
))
979 fnindx
= (unsigned int) -1;
984 /* BB1: Type definitions local to a module. */
985 namcopy
= savestring (name
, namlen
);
988 if (! debug_set_filename (info
->dhandle
, namcopy
))
993 /* BB2: Global type definitions. The name is supposed to be
994 empty, but we don't check. */
995 if (! debug_set_filename (info
->dhandle
, "*global*"))
1000 /* BB3: High level module block begin. We don't have to do
1001 anything here. The name is supposed to be the same as for
1002 the BB1, but we don't check. */
1006 /* BB4: Global function. */
1008 bfd_vma stackspace
, typindx
, offset
;
1009 debug_type return_type
;
1011 if (! ieee_read_number (info
, pp
, &stackspace
)
1012 || ! ieee_read_number (info
, pp
, &typindx
)
1013 || ! ieee_read_expression (info
, pp
, &offset
))
1016 /* We have no way to record the stack space. FIXME. */
1020 return_type
= ieee_builtin_type (info
, block_start
, typindx
);
1021 if (return_type
== DEBUG_TYPE_NULL
)
1027 if (! ieee_alloc_type (info
, typindx
, true))
1030 return_type
= info
->types
.types
[typindx
].type
;
1031 if (debug_get_type_kind (info
->dhandle
, return_type
)
1032 == DEBUG_KIND_FUNCTION
)
1033 return_type
= debug_get_return_type (info
->dhandle
,
1037 namcopy
= savestring (name
, namlen
);
1038 if (namcopy
== NULL
)
1040 if (! debug_record_function (info
->dhandle
, namcopy
, return_type
,
1047 /* BB5: File name for source line numbers. */
1051 /* We ignore the date and time. FIXME. */
1052 for (i
= 0; i
< 6; i
++)
1057 if (! ieee_read_optional_number (info
, pp
, &ignore
, &present
))
1063 namcopy
= savestring (name
, namlen
);
1064 if (namcopy
== NULL
)
1066 if (! debug_start_source (info
->dhandle
, namcopy
))
1072 /* BB6: Local function or block. */
1074 bfd_vma stackspace
, typindx
, offset
;
1076 if (! ieee_read_number (info
, pp
, &stackspace
)
1077 || ! ieee_read_number (info
, pp
, &typindx
)
1078 || ! ieee_read_expression (info
, pp
, &offset
))
1081 /* We have no way to record the stack space. FIXME. */
1085 if (! debug_start_block (info
->dhandle
, offset
))
1087 /* Change b to indicate that this is a block
1088 rather than a function. */
1093 debug_type return_type
;
1097 return_type
= ieee_builtin_type (info
, block_start
, typindx
);
1098 if (return_type
== NULL
)
1104 if (! ieee_alloc_type (info
, typindx
, true))
1107 return_type
= info
->types
.types
[typindx
].type
;
1108 if (debug_get_type_kind (info
->dhandle
, return_type
)
1109 == DEBUG_KIND_FUNCTION
)
1110 return_type
= debug_get_return_type (info
->dhandle
,
1114 namcopy
= savestring (name
, namlen
);
1115 if (namcopy
== NULL
)
1117 if (! debug_record_function (info
->dhandle
, namcopy
, return_type
,
1125 /* BB10: Assembler module scope. We completely ignore all this
1126 information. FIXME. */
1128 const char *inam
, *vstr
;
1129 unsigned long inamlen
, vstrlen
;
1134 if (! ieee_read_id (info
, pp
, &inam
, &inamlen
)
1135 || ! ieee_read_number (info
, pp
, &tool_type
)
1136 || ! ieee_read_optional_id (info
, pp
, &vstr
, &vstrlen
, &present
))
1138 for (i
= 0; i
< 6; i
++)
1142 if (! ieee_read_optional_number (info
, pp
, &ignore
, &present
))
1151 /* BB11: Module section. We completely ignore all this
1152 information. FIXME. */
1154 bfd_vma sectype
, secindx
, offset
, map
;
1157 if (! ieee_read_number (info
, pp
, §ype
)
1158 || ! ieee_read_number (info
, pp
, &secindx
)
1159 || ! ieee_read_expression (info
, pp
, &offset
)
1160 || ! ieee_read_optional_number (info
, pp
, &map
, &present
))
1166 ieee_error (info
, block_start
, "unknown BB type");
1171 /* Push this block on the block stack. */
1173 if (info
->blockstack
.bsp
>= info
->blockstack
.stack
+ BLOCKSTACK_SIZE
)
1175 ieee_error (info
, (const bfd_byte
*) NULL
, "stack overflow");
1179 info
->blockstack
.bsp
->kind
= b
;
1181 info
->blockstack
.bsp
->filename
= namcopy
;
1182 info
->blockstack
.bsp
->fnindx
= fnindx
;
1183 ++info
->blockstack
.bsp
;
1188 /* Handle an IEEE BE record. */
1191 parse_ieee_be (info
, pp
)
1192 struct ieee_info
*info
;
1193 const bfd_byte
**pp
;
1197 if (info
->blockstack
.bsp
<= info
->blockstack
.stack
)
1199 ieee_error (info
, *pp
, "stack underflow");
1202 --info
->blockstack
.bsp
;
1204 switch (info
->blockstack
.bsp
->kind
)
1208 if (! ieee_read_expression (info
, pp
, &offset
))
1210 if (! debug_end_function (info
->dhandle
, offset
))
1215 /* This is BE6 when BB6 started a block rather than a local
1217 if (! ieee_read_expression (info
, pp
, &offset
))
1219 if (! debug_end_block (info
->dhandle
, offset
))
1224 /* When we end a BB5, we look up the stack for the last BB5, if
1225 there is one, so that we can call debug_start_source. */
1226 if (info
->blockstack
.bsp
> info
->blockstack
.stack
)
1228 struct ieee_block
*bl
;
1230 bl
= info
->blockstack
.bsp
;
1236 if (! debug_start_source (info
->dhandle
, bl
->filename
))
1241 while (bl
!= info
->blockstack
.stack
);
1246 if (! ieee_read_expression (info
, pp
, &offset
))
1248 /* We just ignore the module size. FIXME. */
1252 /* Other block types do not have any trailing information. */
1259 /* Parse an NN record. */
1262 parse_ieee_nn (info
, pp
)
1263 struct ieee_info
*info
;
1264 const bfd_byte
**pp
;
1266 const bfd_byte
*nn_start
;
1269 unsigned long namlen
;
1273 if (! ieee_read_number (info
, pp
, &varindx
)
1274 || ! ieee_read_id (info
, pp
, &name
, &namlen
))
1279 ieee_error (info
, nn_start
, "illegal variable index");
1284 if (varindx
>= info
->vars
.alloc
)
1288 alloc
= info
->vars
.alloc
;
1291 while (varindx
>= alloc
)
1293 info
->vars
.vars
= ((struct ieee_var
*)
1294 xrealloc (info
->vars
.vars
,
1295 alloc
* sizeof *info
->vars
.vars
));
1296 memset (info
->vars
.vars
+ info
->vars
.alloc
, 0,
1297 (alloc
- info
->vars
.alloc
) * sizeof *info
->vars
.vars
);
1298 info
->vars
.alloc
= alloc
;
1301 info
->vars
.vars
[varindx
].name
= name
;
1302 info
->vars
.vars
[varindx
].namlen
= namlen
;
1307 /* Parse a TY record. */
1310 parse_ieee_ty (info
, pp
)
1311 struct ieee_info
*info
;
1312 const bfd_byte
**pp
;
1314 const bfd_byte
*ty_start
, *ty_var_start
, *ty_code_start
;
1315 bfd_vma typeindx
, varindx
, tc
;
1317 boolean tag
, typdef
;
1318 debug_type
*arg_slots
;
1319 unsigned long type_bitsize
;
1324 if (! ieee_read_number (info
, pp
, &typeindx
))
1329 ieee_error (info
, ty_start
, "illegal type index");
1334 if (! ieee_alloc_type (info
, typeindx
, false))
1339 ieee_error (info
, *pp
, "unknown TY code");
1346 if (! ieee_read_number (info
, pp
, &varindx
))
1351 ieee_error (info
, ty_var_start
, "illegal variable index");
1356 if (varindx
>= info
->vars
.alloc
|| info
->vars
.vars
[varindx
].name
== NULL
)
1358 ieee_error (info
, ty_var_start
, "undefined variable in TY");
1362 ty_code_start
= *pp
;
1364 if (! ieee_read_number (info
, pp
, &tc
))
1367 dhandle
= info
->dhandle
;
1376 ieee_error (info
, ty_code_start
, "unknown TY code");
1380 /* Unknown type, with size. We treat it as int. FIXME. */
1384 if (! ieee_read_number (info
, pp
, &size
))
1386 type
= debug_make_int_type (dhandle
, size
, false);
1390 case 'A': /* Array. */
1391 case 'a': /* FORTRAN array in column/row order. FIXME: Not
1392 distinguished from normal array. */
1394 debug_type ele_type
;
1395 bfd_vma lower
, upper
;
1397 if (! ieee_read_type_index (info
, pp
, &ele_type
)
1398 || ! ieee_read_number (info
, pp
, &lower
)
1399 || ! ieee_read_number (info
, pp
, &upper
))
1401 type
= debug_make_array_type (dhandle
, ele_type
,
1402 ieee_builtin_type (info
, ty_code_start
,
1405 (bfd_signed_vma
) lower
,
1406 (bfd_signed_vma
) upper
,
1412 /* Simple enumeration. */
1418 bfd_signed_vma
*vals
;
1421 if (! ieee_read_number (info
, pp
, &size
))
1423 /* FIXME: we ignore the enumeration size. */
1426 names
= (const char **) xmalloc (alloc
* sizeof *names
);
1427 memset (names
, 0, alloc
* sizeof *names
);
1432 unsigned long namlen
;
1435 if (! ieee_read_optional_id (info
, pp
, &name
, &namlen
, &present
))
1443 names
= ((const char **)
1444 xrealloc (names
, alloc
* sizeof *names
));
1447 names
[c
] = savestring (name
, namlen
);
1448 if (names
[c
] == NULL
)
1455 vals
= (bfd_signed_vma
*) xmalloc (c
* sizeof *vals
);
1456 for (i
= 0; i
< c
; i
++)
1459 type
= debug_make_enum_type (dhandle
, names
, vals
);
1465 /* Struct with bit fields. */
1469 debug_field
*fields
;
1472 if (! ieee_read_number (info
, pp
, &size
))
1476 fields
= (debug_field
*) xmalloc (alloc
* sizeof *fields
);
1481 unsigned long namlen
;
1484 bfd_vma bitpos
, bitsize
;
1486 if (! ieee_read_optional_id (info
, pp
, &name
, &namlen
, &present
))
1490 if (! ieee_read_type_index (info
, pp
, &ftype
)
1491 || ! ieee_read_number (info
, pp
, &bitpos
)
1492 || ! ieee_read_number (info
, pp
, &bitsize
))
1498 fields
= ((debug_field
*)
1499 xrealloc (fields
, alloc
* sizeof *fields
));
1502 fields
[c
] = debug_make_field (dhandle
, savestring (name
, namlen
),
1503 ftype
, bitpos
, bitsize
,
1504 DEBUG_VISIBILITY_PUBLIC
);
1505 if (fields
[c
] == NULL
)
1512 type
= debug_make_struct_type (dhandle
, true, size
, fields
);
1522 bfd_signed_vma
*vals
;
1526 names
= (const char **) xmalloc (alloc
* sizeof *names
);
1527 vals
= (bfd_signed_vma
*) xmalloc (alloc
* sizeof *names
);
1532 unsigned long namlen
;
1536 if (! ieee_read_optional_id (info
, pp
, &name
, &namlen
, &present
))
1540 if (! ieee_read_number (info
, pp
, &val
))
1543 /* If the length of the name is zero, then the value is
1544 actually the size of the enum. We ignore this
1545 information. FIXME. */
1552 names
= ((const char **)
1553 xrealloc (names
, alloc
* sizeof *names
));
1554 vals
= ((bfd_signed_vma
*)
1555 xrealloc (vals
, alloc
* sizeof *vals
));
1558 names
[c
] = savestring (name
, namlen
);
1559 if (names
[c
] == NULL
)
1561 vals
[c
] = (bfd_signed_vma
) val
;
1567 type
= debug_make_enum_type (dhandle
, names
, vals
);
1572 case 'O': /* Small pointer. We don't distinguish small and large
1574 case 'P': /* Large pointer. */
1578 if (! ieee_read_type_index (info
, pp
, &t
))
1580 type
= debug_make_pointer_type (dhandle
, t
);
1587 bfd_vma low
, high
, signedp
, size
;
1589 if (! ieee_read_number (info
, pp
, &low
)
1590 || ! ieee_read_number (info
, pp
, &high
)
1591 || ! ieee_read_number (info
, pp
, &signedp
)
1592 || ! ieee_read_number (info
, pp
, &size
))
1595 type
= debug_make_range_type (dhandle
,
1596 debug_make_int_type (dhandle
, size
,
1598 (bfd_signed_vma
) low
,
1599 (bfd_signed_vma
) high
);
1603 case 'S': /* Struct. */
1604 case 'U': /* Union. */
1608 debug_field
*fields
;
1611 if (! ieee_read_number (info
, pp
, &size
))
1615 fields
= (debug_field
*) xmalloc (alloc
* sizeof *fields
);
1620 unsigned long namlen
;
1627 if (! ieee_read_optional_id (info
, pp
, &name
, &namlen
, &present
))
1631 if (! ieee_read_number (info
, pp
, &tindx
)
1632 || ! ieee_read_number (info
, pp
, &offset
))
1637 ftype
= ieee_builtin_type (info
, ty_code_start
, tindx
);
1643 struct ieee_type
*t
;
1646 if (! ieee_alloc_type (info
, tindx
, true))
1648 t
= info
->types
.types
+ tindx
;
1650 bitsize
= t
->bitsize
;
1658 fields
= ((debug_field
*)
1659 xrealloc (fields
, alloc
* sizeof *fields
));
1662 fields
[c
] = debug_make_field (dhandle
, savestring (name
, namlen
),
1663 ftype
, offset
, bitsize
,
1664 DEBUG_VISIBILITY_PUBLIC
);
1665 if (fields
[c
] == NULL
)
1672 type
= debug_make_struct_type (dhandle
, tc
== 'S', size
, fields
);
1679 if (! ieee_read_type_index (info
, pp
, &type
))
1685 /* Procedure. FIXME: This is an extern declaration, which we
1686 have no way of representing. */
1692 struct ieee_var
*pv
;
1694 /* FIXME: We ignore the attribute and the argument names. */
1696 if (! ieee_read_number (info
, pp
, &attr
)
1697 || ! ieee_read_type_index (info
, pp
, &rtype
)
1698 || ! ieee_read_number (info
, pp
, &nargs
))
1703 unsigned long namlen
;
1705 if (! ieee_read_optional_id (info
, pp
, &name
, &namlen
, &present
))
1710 pv
= info
->vars
.vars
+ varindx
;
1712 && debug_get_type_kind (dhandle
, rtype
) == DEBUG_KIND_POINTER
)
1714 /* Set up the return type as an indirect type pointing to
1715 the variable slot, so that we can change it to a
1716 reference later if appropriate. */
1717 pv
->pslot
= (debug_type
*) xmalloc (sizeof *pv
->pslot
);
1719 rtype
= debug_make_indirect_type (dhandle
, pv
->pslot
,
1720 (const char *) NULL
);
1723 type
= debug_make_function_type (dhandle
, rtype
, (debug_type
*) NULL
,
1729 /* Array with 0 lower bound. */
1734 if (! ieee_read_type_index (info
, pp
, &etype
)
1735 || ! ieee_read_number (info
, pp
, &high
))
1738 type
= debug_make_array_type (dhandle
, etype
,
1739 ieee_builtin_type (info
, ty_code_start
,
1742 0, (bfd_signed_vma
) high
, false);
1746 case 'c': /* Complex. */
1747 case 'd': /* Double complex. */
1750 unsigned long namlen
;
1752 /* FIXME: I don't know what the name means. */
1754 if (! ieee_read_id (info
, pp
, &name
, &namlen
))
1757 type
= debug_make_complex_type (dhandle
, tc
== 'c' ? 4 : 8);
1762 /* Pascal file name. FIXME. */
1763 ieee_error (info
, ty_code_start
, "Pascal file name not supported");
1767 /* Bitfield type. */
1769 bfd_vma signedp
, bitsize
;
1771 if (! ieee_read_number (info
, pp
, &signedp
)
1772 || ! ieee_read_number (info
, pp
, &bitsize
)
1773 || ! ieee_read_type_index (info
, pp
, &type
))
1776 /* FIXME: This is just a guess. */
1778 type
= debug_make_int_type (dhandle
, 4, true);
1779 type_bitsize
= bitsize
;
1789 if (! ieee_read_number (info
, pp
, &kind
)
1790 || ! ieee_read_type_index (info
, pp
, &t
))
1796 ieee_error (info
, ty_start
, "unsupported qualifer");
1800 type
= debug_make_const_type (dhandle
, t
);
1804 type
= debug_make_volatile_type (dhandle
, t
);
1816 if (! ieee_read_number (info
, pp
, &size
)
1817 || ! ieee_read_type_index (info
, pp
, &etype
))
1820 /* FIXME: We ignore the size. */
1822 type
= debug_make_set_type (dhandle
, etype
, false);
1827 /* Procedure with compiler dependencies. FIXME: This is an
1828 extern declaration, which we have no way of representing. */
1830 struct ieee_var
*pv
;
1831 bfd_vma attr
, frame_type
, push_mask
, nargs
, level
, father
;
1833 debug_type
*arg_types
;
1837 /* FIXME: We ignore almost all this information. */
1839 pv
= info
->vars
.vars
+ varindx
;
1841 if (! ieee_read_number (info
, pp
, &attr
)
1842 || ! ieee_read_number (info
, pp
, &frame_type
)
1843 || ! ieee_read_number (info
, pp
, &push_mask
)
1844 || ! ieee_read_type_index (info
, pp
, &rtype
)
1845 || ! ieee_read_number (info
, pp
, &nargs
))
1847 if (nargs
== (bfd_vma
) -1)
1856 arg_types
= ((debug_type
*)
1857 xmalloc ((nargs
+ 1) * sizeof *arg_types
));
1858 for (i
= 0; i
< nargs
; i
++)
1859 if (! ieee_read_type_index (info
, pp
, arg_types
+ i
))
1862 /* If the last type is pointer to void, this is really a
1863 varargs function. */
1869 last
= arg_types
[nargs
- 1];
1870 if (debug_get_type_kind (dhandle
, last
) == DEBUG_KIND_POINTER
1871 && (debug_get_type_kind (dhandle
,
1872 debug_get_target_type (dhandle
,
1874 == DEBUG_KIND_VOID
))
1881 /* If there are any pointer arguments, turn them into
1882 indirect types in case we later need to convert them to
1884 for (i
= 0; i
< nargs
; i
++)
1886 if (debug_get_type_kind (dhandle
, arg_types
[i
])
1887 == DEBUG_KIND_POINTER
)
1889 if (arg_slots
== NULL
)
1891 arg_slots
= ((debug_type
*)
1892 xmalloc (nargs
* sizeof *arg_slots
));
1893 memset (arg_slots
, 0, nargs
* sizeof *arg_slots
);
1895 arg_slots
[i
] = arg_types
[i
];
1897 debug_make_indirect_type (dhandle
,
1899 (const char *) NULL
);
1903 arg_types
[nargs
] = DEBUG_TYPE_NULL
;
1905 if (! ieee_read_number (info
, pp
, &level
)
1906 || ! ieee_read_optional_number (info
, pp
, &father
, &present
))
1910 && debug_get_type_kind (dhandle
, rtype
) == DEBUG_KIND_POINTER
)
1912 /* Set up the return type as an indirect type pointing to
1913 the variable slot, so that we can change it to a
1914 reference later if appropriate. */
1915 pv
->pslot
= (debug_type
*) xmalloc (sizeof *pv
->pslot
);
1917 rtype
= debug_make_indirect_type (dhandle
, pv
->pslot
,
1918 (const char *) NULL
);
1921 type
= debug_make_function_type (dhandle
, rtype
, arg_types
, varargs
);
1926 /* Record the type in the table. If the corresponding NN record has
1927 a name, name it. FIXME: Is this always correct? */
1929 if (type
== DEBUG_TYPE_NULL
)
1932 info
->vars
.vars
[varindx
].type
= type
;
1935 && info
->vars
.vars
[varindx
].namlen
> 0)
1939 name
= savestring (info
->vars
.vars
[varindx
].name
,
1940 info
->vars
.vars
[varindx
].namlen
);
1942 type
= debug_name_type (dhandle
, name
, type
);
1943 else if (tc
== 'E' || tc
== 'N')
1944 type
= debug_tag_type (dhandle
, name
, type
);
1947 struct ieee_tag
*it
;
1949 /* We must allocate all struct tags as indirect types, so
1950 that if we later see a definition of the tag as a C++
1951 record we can update the indirect slot and automatically
1952 change all the existing references. */
1953 it
= (struct ieee_tag
*) xmalloc (sizeof *it
);
1954 memset (it
, 0, sizeof *it
);
1955 it
->next
= info
->tags
;
1960 type
= debug_make_indirect_type (dhandle
, &it
->slot
, name
);
1961 type
= debug_tag_type (dhandle
, name
, type
);
1969 info
->types
.types
[typeindx
].type
= type
;
1970 info
->types
.types
[typeindx
].arg_slots
= arg_slots
;
1971 info
->types
.types
[typeindx
].bitsize
= type_bitsize
;
1973 /* We may have already allocated type as an indirect type pointing
1974 to slot. It does no harm to replace the indirect type with the
1975 real type. Filling in slot as well handles the indirect types
1976 which are already hanging around. */
1977 if (info
->types
.types
[typeindx
].pslot
!= NULL
)
1978 *info
->types
.types
[typeindx
].pslot
= type
;
1983 /* Parse an ATN record. */
1986 parse_ieee_atn (info
, pp
)
1987 struct ieee_info
*info
;
1988 const bfd_byte
**pp
;
1990 const bfd_byte
*atn_start
, *atn_code_start
;
1992 struct ieee_var
*pvar
;
1996 bfd_vma v
, v2
, v3
, v4
, v5
;
1998 unsigned long namlen
;
2005 if (! ieee_read_number (info
, pp
, &varindx
)
2006 || ! ieee_read_type_index (info
, pp
, &type
))
2009 atn_code_start
= *pp
;
2011 if (! ieee_read_number (info
, pp
, &atn_code
))
2020 else if (varindx
< 32)
2022 ieee_error (info
, atn_start
, "illegal variable index");
2028 if (varindx
>= info
->vars
.alloc
2029 || info
->vars
.vars
[varindx
].name
== NULL
)
2031 ieee_error (info
, atn_start
, "undefined variable in ATN");
2035 pvar
= info
->vars
.vars
+ varindx
;
2040 namlen
= pvar
->namlen
;
2043 dhandle
= info
->dhandle
;
2045 /* If we are going to call debug_record_variable with a pointer
2046 type, change the type to an indirect type so that we can later
2047 change it to a reference type if we encounter a C++ pmisc 'R'
2050 && type
!= DEBUG_TYPE_NULL
2051 && debug_get_type_kind (dhandle
, type
) == DEBUG_KIND_POINTER
)
2060 pvar
->pslot
= (debug_type
*) xmalloc (sizeof *pvar
->pslot
);
2061 *pvar
->pslot
= type
;
2062 type
= debug_make_indirect_type (dhandle
, pvar
->pslot
,
2063 (const char *) NULL
);
2072 ieee_error (info
, atn_code_start
, "unknown ATN type");
2076 /* Automatic variable. */
2077 if (! ieee_read_number (info
, pp
, &v
))
2079 namcopy
= savestring (name
, namlen
);
2081 type
= debug_make_void_type (dhandle
);
2083 pvar
->variable
= DEBUG_LOCAL
;
2084 return debug_record_variable (dhandle
, namcopy
, type
, DEBUG_LOCAL
, v
);
2087 /* Register variable. */
2088 if (! ieee_read_number (info
, pp
, &v
))
2090 namcopy
= savestring (name
, namlen
);
2092 type
= debug_make_void_type (dhandle
);
2094 pvar
->variable
= DEBUG_REGISTER
;
2095 return debug_record_variable (dhandle
, namcopy
, type
, DEBUG_REGISTER
,
2096 ieee_regno_to_genreg (info
->abfd
, v
));
2099 /* Static variable. */
2100 if (! ieee_require_asn (info
, pp
, &v
))
2102 namcopy
= savestring (name
, namlen
);
2104 type
= debug_make_void_type (dhandle
);
2105 if (info
->blockstack
.bsp
<= info
->blockstack
.stack
)
2108 blocktype
= info
->blockstack
.bsp
[-1].kind
;
2111 if (blocktype
== 4 || blocktype
== 6)
2112 pvar
->variable
= DEBUG_LOCAL_STATIC
;
2114 pvar
->variable
= DEBUG_STATIC
;
2116 return debug_record_variable (dhandle
, namcopy
, type
,
2117 (blocktype
== 4 || blocktype
== 6
2118 ? DEBUG_LOCAL_STATIC
2123 /* External function. We don't currently record these. FIXME. */
2127 /* External variable. We don't currently record these. FIXME. */
2131 if (! ieee_read_number (info
, pp
, &v
)
2132 || ! ieee_read_number (info
, pp
, &v2
)
2133 || ! ieee_read_optional_number (info
, pp
, &v3
, &present
))
2137 if (! ieee_read_optional_number (info
, pp
, &v4
, &present
))
2141 /* We just ignore the two optional fields in v3 and v4, since
2142 they are not defined. */
2144 if (! ieee_require_asn (info
, pp
, &v3
))
2147 /* We have no way to record the column number. FIXME. */
2149 return debug_record_line (dhandle
, v
, v3
);
2152 /* Global variable. */
2153 if (! ieee_require_asn (info
, pp
, &v
))
2155 namcopy
= savestring (name
, namlen
);
2157 type
= debug_make_void_type (dhandle
);
2159 pvar
->variable
= DEBUG_GLOBAL
;
2160 return debug_record_variable (dhandle
, namcopy
, type
, DEBUG_GLOBAL
, v
);
2163 /* Variable lifetime information. */
2164 if (! ieee_read_number (info
, pp
, &v
))
2167 /* We have no way to record this information. FIXME. */
2171 /* Locked register. */
2172 if (! ieee_read_number (info
, pp
, &v
)
2173 || ! ieee_read_number (info
, pp
, &v2
))
2176 /* I think this means a variable that is both in a register and
2177 a frame slot. We ignore the frame slot. FIXME. */
2179 namcopy
= savestring (name
, namlen
);
2181 type
= debug_make_void_type (dhandle
);
2183 pvar
->variable
= DEBUG_REGISTER
;
2184 return debug_record_variable (dhandle
, namcopy
, type
, DEBUG_REGISTER
, v
);
2187 /* Reserved for FORTRAN common. */
2188 ieee_error (info
, atn_code_start
, "unsupported ATN11");
2190 /* Return true to keep going. */
2194 /* Based variable. */
2198 if (! ieee_read_number (info
, pp
, &v
)
2199 || ! ieee_read_number (info
, pp
, &v2
)
2200 || ! ieee_read_optional_number (info
, pp
, &v3
, &present
))
2204 if (! ieee_read_optional_number (info
, pp
, &v4
, &present
))
2208 if (! ieee_read_optional_number (info
, pp
, &v5
, &present
))
2213 /* We have no way to record this information. FIXME. */
2215 ieee_error (info
, atn_code_start
, "unsupported ATN12");
2217 /* Return true to keep going. */
2221 /* Constant. The description of this that I have is ambiguous,
2222 so I'm not going to try to implement it. */
2223 if (! ieee_read_number (info
, pp
, &v
)
2224 || ! ieee_read_optional_number (info
, pp
, &v2
, &present
))
2228 if (! ieee_read_optional_number (info
, pp
, &v2
, &present
))
2232 if (! ieee_read_optional_id (info
, pp
, &name
, &namlen
, &present
))
2237 if ((ieee_record_enum_type
) **pp
== ieee_e2_first_byte_enum
)
2239 if (! ieee_require_asn (info
, pp
, &v3
))
2246 /* Static variable from assembler. */
2248 if (! ieee_read_number (info
, pp
, &v
)
2249 || ! ieee_read_optional_number (info
, pp
, &v2
, &present
)
2250 || ! ieee_require_asn (info
, pp
, &v3
))
2252 namcopy
= savestring (name
, namlen
);
2253 /* We don't really handle this correctly. FIXME. */
2254 return debug_record_variable (dhandle
, namcopy
,
2255 debug_make_void_type (dhandle
),
2256 v2
!= 0 ? DEBUG_GLOBAL
: DEBUG_STATIC
,
2260 /* Procedure miscellaneous information. */
2262 /* Variable miscellaneous information. */
2264 /* Module miscellaneous information. */
2265 if (! ieee_read_number (info
, pp
, &v
)
2266 || ! ieee_read_number (info
, pp
, &v2
)
2267 || ! ieee_read_optional_id (info
, pp
, &name
, &namlen
, &present
))
2270 if (atn_code
== 62 && v
== 80)
2274 ieee_error (info
, atn_code_start
,
2275 "unexpected string in C++ misc");
2278 return ieee_read_cxx_misc (info
, pp
, v2
);
2281 /* We just ignore all of this stuff. FIXME. */
2283 for (; v2
> 0; --v2
)
2285 switch ((ieee_record_enum_type
) **pp
)
2288 ieee_error (info
, *pp
, "bad misc record");
2291 case ieee_at_record_enum
:
2292 if (! ieee_require_atn65 (info
, pp
, &name
, &namlen
))
2296 case ieee_e2_first_byte_enum
:
2297 if (! ieee_require_asn (info
, pp
, &v3
))
2309 /* Handle C++ debugging miscellaneous records. This is called for
2310 procedure miscellaneous records of type 80. */
2313 ieee_read_cxx_misc (info
, pp
, count
)
2314 struct ieee_info
*info
;
2315 const bfd_byte
**pp
;
2316 unsigned long count
;
2318 const bfd_byte
*start
;
2323 /* Get the category of C++ misc record. */
2324 if (! ieee_require_asn (info
, pp
, &category
))
2331 ieee_error (info
, start
, "unrecognized C++ misc record");
2335 if (! ieee_read_cxx_class (info
, pp
, count
))
2343 unsigned long namlen
;
2345 /* The IEEE spec indicates that the 'M' record only has a
2346 flags field. The MRI compiler also emits the name of the
2349 if (! ieee_require_asn (info
, pp
, &flags
))
2351 if (*pp
< info
->pend
2352 && (ieee_record_enum_type
) **pp
== ieee_at_record_enum
)
2354 if (! ieee_require_atn65 (info
, pp
, &name
, &namlen
))
2358 /* This is emitted for method functions, but I don't think we
2359 care very much. It might help if it told us useful
2360 information like the class with which this function is
2361 associated, but it doesn't, so it isn't helpful. */
2366 if (! ieee_read_cxx_defaults (info
, pp
, count
))
2372 const char *name
, *mangled
, *class;
2373 unsigned long namlen
, mangledlen
, classlen
;
2376 /* Pointer to member. */
2378 if (! ieee_require_atn65 (info
, pp
, &name
, &namlen
)
2379 || ! ieee_require_atn65 (info
, pp
, &mangled
, &mangledlen
)
2380 || ! ieee_require_atn65 (info
, pp
, &class, &classlen
)
2381 || ! ieee_require_asn (info
, pp
, &control
))
2384 /* FIXME: We should now track down name and change its type. */
2389 if (! ieee_read_reference (info
, pp
))
2397 /* Read a C++ class definition. This is a pmisc type 80 record of
2401 ieee_read_cxx_class (info
, pp
, count
)
2402 struct ieee_info
*info
;
2403 const bfd_byte
**pp
;
2404 unsigned long count
;
2406 const bfd_byte
*start
;
2409 unsigned long taglen
;
2410 struct ieee_tag
*it
;
2412 debug_field
*fields
;
2413 unsigned int field_count
, field_alloc
;
2414 debug_baseclass
*baseclasses
;
2415 unsigned int baseclasses_count
, baseclasses_alloc
;
2416 const debug_field
*structfields
;
2420 unsigned long namlen
;
2421 debug_method_variant
*variants
;
2425 unsigned int methods_count
, methods_alloc
;
2426 debug_type vptrbase
;
2428 debug_method
*dmethods
;
2432 if (! ieee_require_asn (info
, pp
, &class))
2436 if (! ieee_require_atn65 (info
, pp
, &tag
, &taglen
))
2440 /* Find the C struct with this name. */
2441 for (it
= info
->tags
; it
!= NULL
; it
= it
->next
)
2442 if (it
->name
[0] == tag
[0]
2443 && strncmp (it
->name
, tag
, taglen
) == 0
2444 && strlen (it
->name
) == taglen
)
2448 ieee_error (info
, start
, "undefined C++ object");
2452 dhandle
= info
->dhandle
;
2458 baseclasses_count
= 0;
2459 baseclasses_alloc
= 0;
2463 vptrbase
= DEBUG_TYPE_NULL
;
2466 structfields
= debug_get_fields (dhandle
, it
->type
);
2471 const bfd_byte
*spec_start
;
2475 if (! ieee_require_asn (info
, pp
, &id
))
2482 ieee_error (info
, spec_start
, "unrecognized C++ object spec");
2487 bfd_vma flags
, cinline
;
2488 const char *basename
, *fieldname
;
2489 unsigned long baselen
, fieldlen
;
2491 debug_type basetype
;
2494 enum debug_visibility visibility
;
2495 debug_baseclass baseclass
;
2497 /* This represents a base or friend class. */
2499 if (! ieee_require_asn (info
, pp
, &flags
)
2500 || ! ieee_require_atn65 (info
, pp
, &basename
, &baselen
)
2501 || ! ieee_require_asn (info
, pp
, &cinline
)
2502 || ! ieee_require_atn65 (info
, pp
, &fieldname
, &fieldlen
))
2506 /* We have no way of recording friend information, so we
2508 if ((flags
& BASEFLAGS_FRIEND
) != 0)
2511 /* I assume that either all of the members of the
2512 baseclass are included in the object, starting at the
2513 beginning of the object, or that none of them are
2516 if ((fieldlen
== 0) == (cinline
== 0))
2518 ieee_error (info
, start
, "unsupported C++ object type");
2522 basecopy
= savestring (basename
, baselen
);
2523 basetype
= debug_find_tagged_type (dhandle
, basecopy
,
2524 DEBUG_KIND_ILLEGAL
);
2526 if (basetype
== DEBUG_TYPE_NULL
)
2528 ieee_error (info
, start
, "C++ base class not defined");
2536 const debug_field
*pf
;
2538 if (structfields
== NULL
)
2540 ieee_error (info
, start
, "C++ object has no fields");
2544 for (pf
= structfields
; *pf
!= DEBUG_FIELD_NULL
; pf
++)
2548 fname
= debug_get_field_name (dhandle
, *pf
);
2551 if (fname
[0] == fieldname
[0]
2552 && strncmp (fname
, fieldname
, fieldlen
) == 0
2553 && strlen (fname
) == fieldlen
)
2556 if (*pf
== DEBUG_FIELD_NULL
)
2558 ieee_error (info
, start
,
2559 "C++ base class not found in container");
2563 bitpos
= debug_get_field_bitpos (dhandle
, *pf
);
2566 if ((flags
& BASEFLAGS_VIRTUAL
) != 0)
2570 if ((flags
& BASEFLAGS_PRIVATE
) != 0)
2571 visibility
= DEBUG_VISIBILITY_PRIVATE
;
2573 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2575 baseclass
= debug_make_baseclass (dhandle
, basetype
, bitpos
,
2576 virtualp
, visibility
);
2577 if (baseclass
== DEBUG_BASECLASS_NULL
)
2580 if (baseclasses_count
+ 1 >= baseclasses_alloc
)
2582 baseclasses_alloc
+= 10;
2583 baseclasses
= ((debug_baseclass
*)
2584 xrealloc (baseclasses
,
2586 * sizeof *baseclasses
)));
2589 baseclasses
[baseclasses_count
] = baseclass
;
2590 ++baseclasses_count
;
2591 baseclasses
[baseclasses_count
] = DEBUG_BASECLASS_NULL
;
2598 const char *fieldname
, *mangledname
;
2599 unsigned long fieldlen
, mangledlen
;
2603 const debug_field
*pf
;
2604 enum debug_visibility visibility
;
2607 /* This represents a data member. */
2609 if (! ieee_require_asn (info
, pp
, &flags
)
2610 || ! ieee_require_atn65 (info
, pp
, &fieldname
, &fieldlen
)
2611 || ! ieee_require_atn65 (info
, pp
, &mangledname
, &mangledlen
))
2615 fieldcopy
= savestring (fieldname
, fieldlen
);
2617 staticp
= (flags
& CXXFLAGS_STATIC
) != 0 ? true : false;
2621 /* We can only figure out the type here if mangledname
2622 happens to have already been defined, but that is
2623 not necessarily the case. In fact, it may never be
2624 defined. For now, we don't even try. FIXME. */
2626 ftype
= ieee_builtin_type (info
, start
,
2627 (unsigned int) builtin_void
);
2633 if (structfields
== NULL
)
2635 ieee_error (info
, start
, "C++ object has no fields");
2639 for (pf
= structfields
, findx
= 0;
2640 *pf
!= DEBUG_FIELD_NULL
;
2645 fname
= debug_get_field_name (dhandle
, *pf
);
2648 if (fname
[0] == mangledname
[0]
2649 && strncmp (fname
, mangledname
, mangledlen
) == 0
2650 && strlen (fname
) == mangledlen
)
2653 if (*pf
== DEBUG_FIELD_NULL
)
2655 ieee_error (info
, start
,
2656 "C++ data member not found in container");
2660 ftype
= debug_get_field_type (dhandle
, *pf
);
2662 if (debug_get_type_kind (dhandle
, ftype
) == DEBUG_KIND_POINTER
)
2664 /* We might need to convert this field into a
2665 reference type later on, so make it an indirect
2667 if (it
->fslots
== NULL
)
2670 const debug_field
*pfcnt
;
2673 for (pfcnt
= structfields
;
2674 *pfcnt
!= DEBUG_FIELD_NULL
;
2677 it
->fslots
= ((debug_type
*)
2678 xmalloc (fcnt
* sizeof *it
->fslots
));
2679 memset (it
->fslots
, 0,
2680 fcnt
* sizeof *it
->fslots
);
2683 if (ftype
== DEBUG_TYPE_NULL
)
2685 it
->fslots
[findx
] = ftype
;
2686 ftype
= debug_make_indirect_type (dhandle
,
2688 (const char *) NULL
);
2691 if (ftype
== DEBUG_TYPE_NULL
)
2694 switch (flags
& CXXFLAGS_VISIBILITY
)
2697 ieee_error (info
, start
, "unknown C++ visibility");
2700 case CXXFLAGS_VISIBILITY_PUBLIC
:
2701 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2704 case CXXFLAGS_VISIBILITY_PRIVATE
:
2705 visibility
= DEBUG_VISIBILITY_PRIVATE
;
2708 case CXXFLAGS_VISIBILITY_PROTECTED
:
2709 visibility
= DEBUG_VISIBILITY_PROTECTED
;
2713 if ((flags
& CXXFLAGS_STATIC
) != 0)
2717 mangledcopy
= savestring (mangledname
, mangledlen
);
2719 field
= debug_make_static_member (dhandle
, fieldcopy
,
2725 bfd_vma bitpos
, bitsize
;
2727 bitpos
= debug_get_field_bitpos (dhandle
, *pf
);
2728 bitsize
= debug_get_field_bitsize (dhandle
, *pf
);
2729 if (bitpos
== (bfd_vma
) -1 || bitsize
== (bfd_vma
) -1)
2731 ieee_error (info
, start
, "bad C++ field bit pos or size");
2734 field
= debug_make_field (dhandle
, fieldcopy
, ftype
, bitpos
,
2735 bitsize
, visibility
);
2738 if (field
== DEBUG_FIELD_NULL
)
2741 if (field_count
+ 1 >= field_alloc
)
2744 fields
= ((debug_field
*)
2745 xrealloc (fields
, field_alloc
* sizeof *fields
));
2748 fields
[field_count
] = field
;
2750 fields
[field_count
] = DEBUG_FIELD_NULL
;
2757 bfd_vma flags
, virtindex
, control
;
2758 const char *name
, *mangled
;
2759 unsigned long namlen
, mangledlen
;
2760 struct ieee_var
*pv
, *pvend
;
2762 enum debug_visibility visibility
;
2763 boolean constp
, volatilep
;
2765 debug_method_variant mv
;
2766 struct ieee_method
*meth
;
2769 if (! ieee_require_asn (info
, pp
, &flags
)
2770 || ! ieee_require_atn65 (info
, pp
, &name
, &namlen
)
2771 || ! ieee_require_atn65 (info
, pp
, &mangled
, &mangledlen
))
2776 if (! ieee_require_asn (info
, pp
, &virtindex
))
2780 if (! ieee_require_asn (info
, pp
, &control
))
2784 /* We just ignore the control information. */
2786 /* We have no way to represent friend information, so we
2788 if ((flags
& CXXFLAGS_FRIEND
) != 0)
2791 /* We should already have seen a type for the function. */
2792 pv
= info
->vars
.vars
;
2793 pvend
= pv
+ info
->vars
.alloc
;
2794 for (; pv
< pvend
; pv
++)
2795 if (pv
->namlen
== mangledlen
2796 && strncmp (pv
->name
, mangled
, mangledlen
) == 0)
2801 /* We won't have type information for this function if
2802 it is not included in this file. We don't try to
2803 handle this case. FIXME. */
2804 type
= (debug_make_function_type
2806 ieee_builtin_type (info
, start
,
2807 (unsigned int) builtin_void
),
2808 (debug_type
*) NULL
,
2813 debug_type return_type
;
2814 const debug_type
*arg_types
;
2817 if (debug_get_type_kind (dhandle
, pv
->type
)
2818 != DEBUG_KIND_FUNCTION
)
2820 ieee_error (info
, start
,
2821 "bad type for C++ method function");
2825 return_type
= debug_get_return_type (dhandle
, pv
->type
);
2826 arg_types
= debug_get_parameter_types (dhandle
, pv
->type
,
2828 if (return_type
== DEBUG_TYPE_NULL
|| arg_types
== NULL
)
2830 ieee_error (info
, start
,
2831 "no type information for C++ method function");
2835 type
= debug_make_method_type (dhandle
, return_type
, it
->type
,
2836 (debug_type
*) arg_types
,
2839 if (type
== DEBUG_TYPE_NULL
)
2842 switch (flags
& CXXFLAGS_VISIBILITY
)
2845 ieee_error (info
, start
, "unknown C++ visibility");
2848 case CXXFLAGS_VISIBILITY_PUBLIC
:
2849 visibility
= DEBUG_VISIBILITY_PUBLIC
;
2852 case CXXFLAGS_VISIBILITY_PRIVATE
:
2853 visibility
= DEBUG_VISIBILITY_PRIVATE
;
2856 case CXXFLAGS_VISIBILITY_PROTECTED
:
2857 visibility
= DEBUG_VISIBILITY_PROTECTED
;
2861 constp
= (flags
& CXXFLAGS_CONST
) != 0 ? true : false;
2862 volatilep
= (flags
& CXXFLAGS_VOLATILE
) != 0 ? true : false;
2864 mangledcopy
= savestring (mangled
, mangledlen
);
2866 if ((flags
& CXXFLAGS_STATIC
) != 0)
2870 ieee_error (info
, start
, "C++ static virtual method");
2873 mv
= debug_make_static_method_variant (dhandle
, mangledcopy
,
2880 debug_type vcontext
;
2885 vcontext
= DEBUG_TYPE_NULL
;
2889 /* FIXME: This should depend upon the pointer
2891 voffset
= virtindex
* 4;
2892 /* FIXME: How can we calculate this correctly? */
2893 vcontext
= it
->type
;
2895 mv
= debug_make_method_variant (dhandle
, mangledcopy
, type
,
2900 if (mv
== DEBUG_METHOD_VARIANT_NULL
)
2903 for (meth
= methods
, im
= 0; im
< methods_count
; meth
++, im
++)
2904 if (meth
->namlen
== namlen
2905 && strncmp (meth
->name
, name
, namlen
) == 0)
2907 if (im
>= methods_count
)
2909 if (methods_count
>= methods_alloc
)
2911 methods_alloc
+= 10;
2912 methods
= ((struct ieee_method
*)
2914 methods_alloc
* sizeof *methods
));
2916 methods
[methods_count
].name
= name
;
2917 methods
[methods_count
].namlen
= namlen
;
2918 methods
[methods_count
].variants
= NULL
;
2919 methods
[methods_count
].count
= 0;
2920 methods
[methods_count
].alloc
= 0;
2921 meth
= methods
+ methods_count
;
2925 if (meth
->count
+ 1 >= meth
->alloc
)
2928 meth
->variants
= ((debug_method_variant
*)
2929 xrealloc (meth
->variants
,
2931 * sizeof *meth
->variants
)));
2934 meth
->variants
[meth
->count
] = mv
;
2936 meth
->variants
[meth
->count
] = DEBUG_METHOD_VARIANT_NULL
;
2944 /* We have no way to store this information, so we just
2946 if (! ieee_require_asn (info
, pp
, &spec
))
2949 if ((spec
& 4) != 0)
2951 const char *filename
;
2952 unsigned long filenamlen
;
2955 if (! ieee_require_atn65 (info
, pp
, &filename
, &filenamlen
)
2956 || ! ieee_require_asn (info
, pp
, &lineno
))
2960 else if ((spec
& 8) != 0)
2962 const char *mangled
;
2963 unsigned long mangledlen
;
2965 if (! ieee_require_atn65 (info
, pp
, &mangled
, &mangledlen
))
2971 ieee_error (info
, start
,
2972 "unrecognized C++ object overhead spec");
2980 const char *vname
, *basename
;
2981 unsigned long vnamelen
, baselen
;
2982 bfd_vma vsize
, control
;
2984 /* A virtual table pointer. */
2986 if (! ieee_require_atn65 (info
, pp
, &vname
, &vnamelen
)
2987 || ! ieee_require_asn (info
, pp
, &vsize
)
2988 || ! ieee_require_atn65 (info
, pp
, &basename
, &baselen
)
2989 || ! ieee_require_asn (info
, pp
, &control
))
2993 /* We just ignore the control number. We don't care what
2994 the virtual table name is. We have no way to store the
2995 virtual table size, and I don't think we care anyhow. */
2997 /* FIXME: We can't handle multiple virtual table pointers. */
3005 basecopy
= savestring (basename
, baselen
);
3006 vptrbase
= debug_find_tagged_type (dhandle
, basecopy
,
3007 DEBUG_KIND_ILLEGAL
);
3009 if (vptrbase
== DEBUG_TYPE_NULL
)
3011 ieee_error (info
, start
, "undefined C++ vtable");
3020 /* Now that we have seen all the method variants, we can call
3021 debug_make_method for each one. */
3023 if (methods_count
== 0)
3029 dmethods
= ((debug_method
*)
3030 xmalloc ((methods_count
+ 1) * sizeof *dmethods
));
3031 for (i
= 0; i
< methods_count
; i
++)
3035 namcopy
= savestring (methods
[i
].name
, methods
[i
].namlen
);
3036 dmethods
[i
] = debug_make_method (dhandle
, namcopy
,
3037 methods
[i
].variants
);
3038 if (dmethods
[i
] == DEBUG_METHOD_NULL
)
3041 dmethods
[i
] = DEBUG_METHOD_NULL
;
3045 /* The struct type was created as an indirect type pointing at
3046 it->slot. We update it->slot to automatically update all
3047 references to this struct. */
3048 it
->slot
= debug_make_object_type (dhandle
,
3050 debug_get_type_size (dhandle
,
3052 fields
, baseclasses
, dmethods
,
3054 if (it
->slot
== DEBUG_TYPE_NULL
)
3060 /* Read C++ default argument value and reference type information. */
3063 ieee_read_cxx_defaults (info
, pp
, count
)
3064 struct ieee_info
*info
;
3065 const bfd_byte
**pp
;
3066 unsigned long count
;
3068 const bfd_byte
*start
;
3070 unsigned long fnlen
;
3075 /* Giving the function name before the argument count is an addendum
3076 to the spec. The function name is demangled, though, so this
3077 record must always refer to the current function. */
3079 if (info
->blockstack
.bsp
<= info
->blockstack
.stack
3080 || info
->blockstack
.bsp
[-1].fnindx
== (unsigned int) -1)
3082 ieee_error (info
, start
, "C++ default values not in a function");
3086 if (! ieee_require_atn65 (info
, pp
, &fnname
, &fnlen
)
3087 || ! ieee_require_asn (info
, pp
, &defcount
))
3091 while (defcount
-- > 0)
3095 unsigned long strvallen
;
3097 if (! ieee_require_asn (info
, pp
, &type
))
3109 if (! ieee_require_asn (info
, pp
, &val
))
3116 if (! ieee_require_atn65 (info
, pp
, &strval
, &strvallen
))
3122 ieee_error (info
, start
, "unrecognized C++ default type");
3126 /* We have no way to record the default argument values, so we
3127 just ignore them. FIXME. */
3130 /* Any remaining arguments are indices of parameters that are really
3135 debug_type
*arg_slots
;
3137 dhandle
= info
->dhandle
;
3138 arg_slots
= info
->types
.types
[info
->blockstack
.bsp
[-1].fnindx
].arg_slots
;
3144 if (! ieee_require_asn (info
, pp
, &indx
))
3146 /* The index is 1 based. */
3148 if (arg_slots
== NULL
3149 || arg_slots
[indx
] == DEBUG_TYPE_NULL
3150 || (debug_get_type_kind (dhandle
, arg_slots
[indx
])
3151 != DEBUG_KIND_POINTER
))
3153 ieee_error (info
, start
, "reference parameter is not a pointer");
3157 target
= debug_get_target_type (dhandle
, arg_slots
[indx
]);
3158 arg_slots
[indx
] = debug_make_reference_type (dhandle
, target
);
3159 if (arg_slots
[indx
] == DEBUG_TYPE_NULL
)
3167 /* Read a C++ reference definition. */
3170 ieee_read_reference (info
, pp
)
3171 struct ieee_info
*info
;
3172 const bfd_byte
**pp
;
3174 const bfd_byte
*start
;
3176 const char *class, *name
;
3177 unsigned long classlen
, namlen
;
3183 if (! ieee_require_asn (info
, pp
, &flags
))
3186 /* Giving the class name before the member name is in an addendum to
3190 if (! ieee_require_atn65 (info
, pp
, &class, &classlen
))
3194 if (! ieee_require_atn65 (info
, pp
, &name
, &namlen
))
3201 struct ieee_var
*pv
= NULL
;
3203 /* We search from the last variable indices to the first in
3204 hopes of finding local variables correctly. FIXME: This
3205 probably won't work in all cases. On the other hand, I don't
3207 for (i
= (int) info
->vars
.alloc
- 1; i
>= 0; i
--)
3211 pv
= info
->vars
.vars
+ i
;
3213 if (pv
->pslot
== NULL
3214 || pv
->namlen
!= namlen
3215 || strncmp (pv
->name
, name
, namlen
) != 0)
3222 ieee_error (info
, start
,
3223 "unrecognized C++ reference type");
3227 /* Global variable or function. */
3228 if (pv
->variable
== DEBUG_GLOBAL
)
3230 else if (pv
->type
!= DEBUG_TYPE_NULL
3231 && (debug_get_type_kind (info
->dhandle
, pv
->type
)
3232 == DEBUG_KIND_FUNCTION
))
3237 /* Global static variable or function. */
3238 if (pv
->variable
== DEBUG_STATIC
)
3240 else if (pv
->type
!= DEBUG_TYPE_NULL
3241 && (debug_get_type_kind (info
->dhandle
, pv
->type
)
3242 == DEBUG_KIND_FUNCTION
))
3247 /* Local variable. */
3248 if (pv
->variable
== DEBUG_LOCAL_STATIC
3249 || pv
->variable
== DEBUG_LOCAL
3250 || pv
->variable
== DEBUG_REGISTER
)
3264 struct ieee_tag
*it
;
3266 for (it
= info
->tags
; it
!= NULL
; it
= it
->next
)
3268 if (it
->name
[0] == class[0]
3269 && strncmp (it
->name
, class, classlen
) == 0
3270 && strlen (it
->name
) == classlen
)
3272 if (it
->fslots
!= NULL
)
3274 const debug_field
*pf
;
3277 pf
= debug_get_fields (info
->dhandle
, it
->type
);
3280 ieee_error (info
, start
,
3281 "C++ reference in class with no fields");
3285 for (findx
= 0; *pf
!= DEBUG_FIELD_NULL
; pf
++, findx
++)
3289 fname
= debug_get_field_name (info
->dhandle
, *pf
);
3292 if (strncmp (fname
, name
, namlen
) == 0
3293 && strlen (fname
) == namlen
)
3295 pslot
= it
->fslots
+ findx
;
3308 ieee_error (info
, start
, "C++ reference not found");
3312 /* We allocated the type of the object as an indirect type pointing
3313 to *pslot, which we can now update to be a reference type. */
3314 if (debug_get_type_kind (info
->dhandle
, *pslot
) != DEBUG_KIND_POINTER
)
3316 ieee_error (info
, start
, "C++ reference is not pointer");
3320 target
= debug_get_target_type (info
->dhandle
, *pslot
);
3321 *pslot
= debug_make_reference_type (info
->dhandle
, target
);
3322 if (*pslot
== DEBUG_TYPE_NULL
)
3328 /* Require an ASN record. */
3331 ieee_require_asn (info
, pp
, pv
)
3332 struct ieee_info
*info
;
3333 const bfd_byte
**pp
;
3336 const bfd_byte
*start
;
3337 ieee_record_enum_type c
;
3342 c
= (ieee_record_enum_type
) **pp
;
3343 if (c
!= ieee_e2_first_byte_enum
)
3345 ieee_error (info
, start
, "missing required ASN");
3350 c
= (ieee_record_enum_type
) (((unsigned int) c
<< 8) | **pp
);
3351 if (c
!= ieee_asn_record_enum
)
3353 ieee_error (info
, start
, "missing required ASN");
3358 /* Just ignore the variable index. */
3359 if (! ieee_read_number (info
, pp
, &varindx
))
3362 return ieee_read_expression (info
, pp
, pv
);
3365 /* Require an ATN65 record. */
3368 ieee_require_atn65 (info
, pp
, pname
, pnamlen
)
3369 struct ieee_info
*info
;
3370 const bfd_byte
**pp
;
3372 unsigned long *pnamlen
;
3374 const bfd_byte
*start
;
3375 ieee_record_enum_type c
;
3376 bfd_vma name_indx
, type_indx
, atn_code
;
3380 c
= (ieee_record_enum_type
) **pp
;
3381 if (c
!= ieee_at_record_enum
)
3383 ieee_error (info
, start
, "missing required ATN65");
3388 c
= (ieee_record_enum_type
) (((unsigned int) c
<< 8) | **pp
);
3389 if (c
!= ieee_atn_record_enum
)
3391 ieee_error (info
, start
, "missing required ATN65");
3396 if (! ieee_read_number (info
, pp
, &name_indx
)
3397 || ! ieee_read_number (info
, pp
, &type_indx
)
3398 || ! ieee_read_number (info
, pp
, &atn_code
))
3401 /* Just ignore name_indx. */
3403 if (type_indx
!= 0 || atn_code
!= 65)
3405 ieee_error (info
, start
, "bad ATN65 record");
3409 return ieee_read_id (info
, pp
, pname
, pnamlen
);
3412 /* Convert a register number in IEEE debugging information into a
3413 generic register number. */
3416 ieee_regno_to_genreg (abfd
, r
)
3423 /* Convert a generic register number to an IEEE specific one. */
3426 ieee_genreg_to_regno (abfd
, r
)
3433 /* These routines build IEEE debugging information out of the generic
3434 debugging information. */
3436 /* We build the IEEE debugging information byte by byte. Rather than
3437 waste time copying data around, we use a linked list of buffers to
3440 #define IEEE_BUFSIZE (490)
3445 struct ieee_buf
*next
;
3446 /* Number of data bytes in this buffer. */
3449 bfd_byte buf
[IEEE_BUFSIZE
];
3452 /* In order to generate the BB11 blocks required by the HP emulator,
3453 we keep track of ranges of addresses which correspond to a given
3454 compilation unit. */
3459 struct ieee_range
*next
;
3466 /* This structure holds information for a class on the type stack. */
3468 struct ieee_type_class
3470 /* The name of the class. */
3472 /* The name index in the debugging information. */
3474 /* The pmisc records for the class. */
3475 struct ieee_buf
*pmiscbuf
;
3476 /* The number of pmisc records. */
3477 unsigned int pmisccount
;
3478 /* The name of the class holding the virtual table, if not this
3481 /* Whether this class holds its own virtual table. */
3483 /* The largest virtual table offset seen so far. */
3485 /* The current method. */
3489 /* This is how we store types for the writing routines. Most types
3490 are simply represented by a type index. */
3492 struct ieee_write_type
3496 /* The size of the type, if known. */
3498 /* If this is a struct, this is where the struct definition is
3500 struct ieee_buf
*strdef
;
3501 /* If this is a class, this is where the class information is built. */
3502 struct ieee_type_class
*classdef
;
3503 /* Whether the type is unsigned. */
3504 unsigned int unsignedp
: 1;
3505 /* Whether this is a reference type. */
3506 unsigned int referencep
: 1;
3509 /* This is the type stack used by the debug writing routines. FIXME:
3510 We could generate more efficient output if we remembered when we
3511 have output a particular type before. */
3513 struct ieee_type_stack
3515 /* Next entry on stack. */
3516 struct ieee_type_stack
*next
;
3517 /* Type information. */
3518 struct ieee_write_type type
;
3521 /* This is a list of associations between names and types. This could
3522 be more efficiently implemented as a hash table. */
3524 struct ieee_name_type
3526 /* Next name/type assocation. */
3527 struct ieee_name_type
*next
;
3531 struct ieee_write_type type
;
3532 /* If this is a tag which has not yet been defined, this is the
3533 kind. If the tag has been defined, this is DEBUG_KIND_ILLEGAL. */
3534 enum debug_type_kind kind
;
3537 /* This is a list of pending function parameter information. We don't
3538 output them until we see the first block. */
3540 struct ieee_pending_parm
3542 /* Next pending parameter. */
3543 struct ieee_pending_parm
*next
;
3549 enum debug_parm_kind kind
;
3554 /* This is the handle passed down by debug_write. */
3558 /* BFD we are writing to. */
3560 /* Current data buffer. */
3561 struct ieee_buf
*current
;
3562 /* Filename of current compilation unit. */
3563 const char *filename
;
3564 /* Module name of current compilation unit. */
3565 const char *modname
;
3566 /* List of finished data buffers. */
3567 struct ieee_buf
*data
;
3568 /* List of buffers for typedefs in the current compilation unit. */
3569 struct ieee_buf
*types
;
3570 /* List of buffers for variables and functions in the current
3571 compilation unit. */
3572 struct ieee_buf
*vars
;
3573 /* List of buffers for C++ class definitions in the current
3574 compilation unit. */
3575 struct ieee_buf
*cxx
;
3576 /* List of buffers for line numbers in the current compilation unit. */
3577 struct ieee_buf
*linenos
;
3578 /* Ranges for the current compilation unit. */
3579 struct ieee_range
*ranges
;
3580 /* Nested pending ranges. */
3581 struct ieee_range
*pending_ranges
;
3583 struct ieee_type_stack
*type_stack
;
3584 /* Next unallocated type index. */
3585 unsigned int type_indx
;
3586 /* Next unallocated name index. */
3587 unsigned int name_indx
;
3589 struct ieee_name_type
*typedefs
;
3591 struct ieee_name_type
*tags
;
3592 /* The depth of block nesting. This is 0 outside a function, and 1
3593 just after start_function is called. */
3594 unsigned int block_depth
;
3595 /* Pending function parameters. */
3596 struct ieee_pending_parm
*pending_parms
;
3597 /* Current line number filename. */
3598 const char *lineno_filename
;
3599 /* Line number name index. */
3600 unsigned int lineno_name_indx
;
3601 /* Highest address seen at end of procedure. */
3605 static boolean ieee_change_buffer
3606 PARAMS ((struct ieee_handle
*, struct ieee_buf
**));
3607 static boolean ieee_push_type
3608 PARAMS ((struct ieee_handle
*, unsigned int, unsigned int, boolean
));
3609 static unsigned int ieee_pop_type
PARAMS ((struct ieee_handle
*));
3610 static boolean ieee_add_range
3611 PARAMS ((struct ieee_handle
*, bfd_vma
, bfd_vma
));
3612 static boolean ieee_start_range
PARAMS ((struct ieee_handle
*, bfd_vma
));
3613 static boolean ieee_end_range
PARAMS ((struct ieee_handle
*, bfd_vma
));
3614 static boolean ieee_real_write_byte
PARAMS ((struct ieee_handle
*, int));
3615 static boolean ieee_write_2bytes
PARAMS ((struct ieee_handle
*, int));
3616 static boolean ieee_write_number
PARAMS ((struct ieee_handle
*, bfd_vma
));
3617 static boolean ieee_write_id
PARAMS ((struct ieee_handle
*, const char *));
3618 static boolean ieee_write_asn
3619 PARAMS ((struct ieee_handle
*, unsigned int, bfd_vma
));
3620 static boolean ieee_write_atn65
3621 PARAMS ((struct ieee_handle
*, unsigned int, const char *));
3622 static boolean ieee_define_type
3623 PARAMS ((struct ieee_handle
*, unsigned int, boolean
));
3624 static boolean ieee_define_named_type
3625 PARAMS ((struct ieee_handle
*, const char *, boolean
, unsigned int,
3626 unsigned int, boolean
, struct ieee_buf
**));
3627 static boolean ieee_finish_compilation_unit
PARAMS ((struct ieee_handle
*));
3628 static boolean ieee_output_pending_parms
PARAMS ((struct ieee_handle
*));
3629 static unsigned int ieee_vis_to_flags
PARAMS ((enum debug_visibility
));
3630 static boolean ieee_class_method_var
3631 PARAMS ((struct ieee_handle
*, const char *, enum debug_visibility
, boolean
,
3632 boolean
, boolean
, bfd_vma
, boolean
));
3634 static boolean ieee_start_compilation_unit
PARAMS ((PTR
, const char *));
3635 static boolean ieee_start_source
PARAMS ((PTR
, const char *));
3636 static boolean ieee_empty_type
PARAMS ((PTR
));
3637 static boolean ieee_void_type
PARAMS ((PTR
));
3638 static boolean ieee_int_type
PARAMS ((PTR
, unsigned int, boolean
));
3639 static boolean ieee_float_type
PARAMS ((PTR
, unsigned int));
3640 static boolean ieee_complex_type
PARAMS ((PTR
, unsigned int));
3641 static boolean ieee_bool_type
PARAMS ((PTR
, unsigned int));
3642 static boolean ieee_enum_type
3643 PARAMS ((PTR
, const char *, const char **, bfd_signed_vma
*));
3644 static boolean ieee_pointer_type
PARAMS ((PTR
));
3645 static boolean ieee_function_type
PARAMS ((PTR
, int, boolean
));
3646 static boolean ieee_reference_type
PARAMS ((PTR
));
3647 static boolean ieee_range_type
PARAMS ((PTR
, bfd_signed_vma
, bfd_signed_vma
));
3648 static boolean ieee_array_type
3649 PARAMS ((PTR
, bfd_signed_vma
, bfd_signed_vma
, boolean
));
3650 static boolean ieee_set_type
PARAMS ((PTR
, boolean
));
3651 static boolean ieee_offset_type
PARAMS ((PTR
));
3652 static boolean ieee_method_type
PARAMS ((PTR
, boolean
, int, boolean
));
3653 static boolean ieee_const_type
PARAMS ((PTR
));
3654 static boolean ieee_volatile_type
PARAMS ((PTR
));
3655 static boolean ieee_start_struct_type
3656 PARAMS ((PTR
, const char *, unsigned int, boolean
, unsigned int));
3657 static boolean ieee_struct_field
3658 PARAMS ((PTR
, const char *, bfd_vma
, bfd_vma
, enum debug_visibility
));
3659 static boolean ieee_end_struct_type
PARAMS ((PTR
));
3660 static boolean ieee_start_class_type
3661 PARAMS ((PTR
, const char *, unsigned int, boolean
, unsigned int, boolean
,
3663 static boolean ieee_class_static_member
3664 PARAMS ((PTR
, const char *, const char *, enum debug_visibility
));
3665 static boolean ieee_class_baseclass
3666 PARAMS ((PTR
, bfd_vma
, boolean
, enum debug_visibility
));
3667 static boolean ieee_class_start_method
PARAMS ((PTR
, const char *));
3668 static boolean ieee_class_method_variant
3669 PARAMS ((PTR
, const char *, enum debug_visibility
, boolean
, boolean
,
3671 static boolean ieee_class_static_method_variant
3672 PARAMS ((PTR
, const char *, enum debug_visibility
, boolean
, boolean
));
3673 static boolean ieee_class_end_method
PARAMS ((PTR
));
3674 static boolean ieee_end_class_type
PARAMS ((PTR
));
3675 static boolean ieee_typedef_type
PARAMS ((PTR
, const char *));
3676 static boolean ieee_tag_type
3677 PARAMS ((PTR
, const char *, unsigned int, enum debug_type_kind
));
3678 static boolean ieee_typdef
PARAMS ((PTR
, const char *));
3679 static boolean ieee_tag
PARAMS ((PTR
, const char *));
3680 static boolean ieee_int_constant
PARAMS ((PTR
, const char *, bfd_vma
));
3681 static boolean ieee_float_constant
PARAMS ((PTR
, const char *, double));
3682 static boolean ieee_typed_constant
PARAMS ((PTR
, const char *, bfd_vma
));
3683 static boolean ieee_variable
3684 PARAMS ((PTR
, const char *, enum debug_var_kind
, bfd_vma
));
3685 static boolean ieee_start_function
PARAMS ((PTR
, const char *, boolean
));
3686 static boolean ieee_function_parameter
3687 PARAMS ((PTR
, const char *, enum debug_parm_kind
, bfd_vma
));
3688 static boolean ieee_start_block
PARAMS ((PTR
, bfd_vma
));
3689 static boolean ieee_end_block
PARAMS ((PTR
, bfd_vma
));
3690 static boolean ieee_end_function
PARAMS ((PTR
));
3691 static boolean ieee_lineno
3692 PARAMS ((PTR
, const char *, unsigned long, bfd_vma
));
3694 static const struct debug_write_fns ieee_fns
=
3696 ieee_start_compilation_unit
,
3707 ieee_reference_type
,
3715 ieee_start_struct_type
,
3717 ieee_end_struct_type
,
3718 ieee_start_class_type
,
3719 ieee_class_static_member
,
3720 ieee_class_baseclass
,
3721 ieee_class_start_method
,
3722 ieee_class_method_variant
,
3723 ieee_class_static_method_variant
,
3724 ieee_class_end_method
,
3725 ieee_end_class_type
,
3731 ieee_float_constant
,
3732 ieee_typed_constant
,
3734 ieee_start_function
,
3735 ieee_function_parameter
,
3742 /* Change the current buffer to a specified buffer chain. */
3745 ieee_change_buffer (info
, ppbuf
)
3746 struct ieee_handle
*info
;
3747 struct ieee_buf
**ppbuf
;
3749 struct ieee_buf
*buf
;
3753 for (buf
= *ppbuf
; buf
->next
!= NULL
; buf
= buf
->next
)
3758 buf
= (struct ieee_buf
*) xmalloc (sizeof *buf
);
3764 info
->current
= buf
;
3768 /* Push a type index onto the type stack. */
3771 ieee_push_type (info
, indx
, size
, unsignedp
)
3772 struct ieee_handle
*info
;
3777 struct ieee_type_stack
*ts
;
3779 ts
= (struct ieee_type_stack
*) xmalloc (sizeof *ts
);
3780 memset (ts
, 0, sizeof *ts
);
3782 ts
->type
.indx
= indx
;
3783 ts
->type
.size
= size
;
3784 ts
->type
.unsignedp
= unsignedp
;
3786 ts
->next
= info
->type_stack
;
3787 info
->type_stack
= ts
;
3792 /* Pop a type index off the type stack. */
3795 ieee_pop_type (info
)
3796 struct ieee_handle
*info
;
3798 struct ieee_type_stack
*ts
;
3801 ts
= info
->type_stack
;
3802 assert (ts
!= NULL
);
3803 ret
= ts
->type
.indx
;
3804 info
->type_stack
= ts
->next
;
3809 /* Add a range of bytes included in the current compilation unit. */
3812 ieee_add_range (info
, low
, high
)
3813 struct ieee_handle
*info
;
3817 struct ieee_range
*r
, **pr
;
3819 if (low
== (bfd_vma
) -1 || high
== (bfd_vma
) -1)
3822 for (r
= info
->ranges
; r
!= NULL
; r
= r
->next
)
3824 if (high
>= r
->low
&& low
<= r
->high
)
3826 /* The new range overlaps r. */
3832 while (*pr
!= NULL
&& (*pr
)->low
<= r
->high
)
3834 struct ieee_range
*n
;
3836 if ((*pr
)->high
> r
->high
)
3837 r
->high
= (*pr
)->high
;
3846 r
= (struct ieee_range
*) xmalloc (sizeof *r
);
3847 memset (r
, 0, sizeof *r
);
3852 /* Store the ranges sorted by address. */
3853 for (pr
= &info
->ranges
; *pr
!= NULL
; pr
= &(*pr
)->next
)
3854 if ((*pr
)->next
!= NULL
&& (*pr
)->next
->low
> high
)
3862 /* Start a new range for which we only have the low address. */
3865 ieee_start_range (info
, low
)
3866 struct ieee_handle
*info
;
3869 struct ieee_range
*r
;
3871 r
= (struct ieee_range
*) xmalloc (sizeof *r
);
3872 memset (r
, 0, sizeof *r
);
3874 r
->next
= info
->pending_ranges
;
3875 info
->pending_ranges
= r
;
3879 /* Finish a range started by ieee_start_range. */
3882 ieee_end_range (info
, high
)
3883 struct ieee_handle
*info
;
3886 struct ieee_range
*r
;
3889 assert (info
->pending_ranges
!= NULL
);
3890 r
= info
->pending_ranges
;
3892 info
->pending_ranges
= r
->next
;
3894 return ieee_add_range (info
, low
, high
);
3897 /* Write a byte into the buffer. We use a macro for speed and a
3898 function for the complex cases. */
3900 #define ieee_write_byte(info, b) \
3901 ((info)->current->c < IEEE_BUFSIZE \
3902 ? ((info)->current->buf[(info)->current->c++] = (b), true) \
3903 : ieee_real_write_byte ((info), (b)))
3906 ieee_real_write_byte (info
, b
)
3907 struct ieee_handle
*info
;
3910 if (info
->current
->c
>= IEEE_BUFSIZE
)
3914 n
= (struct ieee_buf
*) xmalloc (sizeof *n
);
3917 info
->current
->next
= n
;
3921 info
->current
->buf
[info
->current
->c
] = b
;
3927 /* Write out two bytes. */
3930 ieee_write_2bytes (info
, i
)
3931 struct ieee_handle
*info
;
3934 return (ieee_write_byte (info
, i
>> 8)
3935 && ieee_write_byte (info
, i
& 0xff));
3938 /* Write out an integer. */
3941 ieee_write_number (info
, v
)
3942 struct ieee_handle
*info
;
3950 if (v
<= (bfd_vma
) ieee_number_end_enum
)
3951 return ieee_write_byte (info
, (int) v
);
3962 if (c
> (unsigned int) (ieee_number_repeat_end_enum
3963 - ieee_number_repeat_start_enum
))
3965 fprintf (stderr
, "IEEE numeric overflow: 0x");
3966 fprintf_vma (stderr
, v
);
3967 fprintf (stderr
, "\n");
3971 if (! ieee_write_byte (info
, (int) ieee_number_repeat_start_enum
+ c
))
3973 for (; c
> 0; --c
, ++p
)
3975 if (! ieee_write_byte (info
, *p
))
3982 /* Write out a string. */
3985 ieee_write_id (info
, s
)
3986 struct ieee_handle
*info
;
3994 if (! ieee_write_byte (info
, len
))
3997 else if (len
<= 0xff)
3999 if (! ieee_write_byte (info
, (int) ieee_extension_length_1_enum
)
4000 || ! ieee_write_byte (info
, len
))
4003 else if (len
<= 0xffff)
4005 if (! ieee_write_byte (info
, (int) ieee_extension_length_2_enum
)
4006 || ! ieee_write_2bytes (info
, len
))
4011 fprintf (stderr
, "IEEE string length overflow: %u\n", len
);
4015 for (; *s
!= '\0'; s
++)
4016 if (! ieee_write_byte (info
, *s
))
4022 /* Write out an ASN record. */
4025 ieee_write_asn (info
, indx
, val
)
4026 struct ieee_handle
*info
;
4030 return (ieee_write_2bytes (info
, (int) ieee_asn_record_enum
)
4031 && ieee_write_number (info
, indx
)
4032 && ieee_write_number (info
, val
));
4035 /* Write out an ATN65 record. */
4038 ieee_write_atn65 (info
, indx
, s
)
4039 struct ieee_handle
*info
;
4043 return (ieee_write_2bytes (info
, (int) ieee_atn_record_enum
)
4044 && ieee_write_number (info
, indx
)
4045 && ieee_write_number (info
, 0)
4046 && ieee_write_number (info
, 65)
4047 && ieee_write_id (info
, s
));
4050 /* Start defining a type. */
4053 ieee_define_type (info
, size
, unsignedp
)
4054 struct ieee_handle
*info
;
4058 return ieee_define_named_type (info
, (const char *) NULL
, false, 0, size
,
4059 unsignedp
, (struct ieee_buf
**) NULL
);
4062 /* Start defining a named type. */
4065 ieee_define_named_type (info
, name
, tagp
, id
, size
, unsignedp
, ppbuf
)
4066 struct ieee_handle
*info
;
4072 struct ieee_buf
**ppbuf
;
4074 unsigned int type_indx
;
4075 unsigned int name_indx
;
4077 if (! tagp
|| id
== (unsigned int) -1)
4079 type_indx
= info
->type_indx
;
4084 struct ieee_name_type
*nt
;
4088 /* We need to create a tag for internal use even if we don't
4089 want one for external use. This will let us refer to an
4090 anonymous struct. */
4095 sprintf (ab
, "__anon%u", id
);
4099 /* The name is a tag. If we have already defined the tag, we
4100 must use the existing type index. */
4101 for (nt
= info
->tags
; nt
!= NULL
; nt
= nt
->next
)
4102 if (nt
->name
[0] == tag
[0]
4103 && strcmp (nt
->name
, tag
) == 0)
4108 nt
= (struct ieee_name_type
*) xmalloc (sizeof *nt
);
4109 memset (nt
, 0, sizeof *nt
);
4111 nt
->next
= info
->tags
;
4113 nt
->type
.indx
= info
->type_indx
;
4117 nt
->type
.size
= size
;
4118 nt
->type
.unsignedp
= unsignedp
;
4119 nt
->kind
= DEBUG_KIND_ILLEGAL
;
4121 type_indx
= nt
->type
.indx
;
4124 name_indx
= info
->name_indx
;
4130 /* If we were given a buffer, use it; otherwise, use the general
4131 type information, and make sure that the type block is started. */
4134 if (! ieee_change_buffer (info
, ppbuf
))
4137 else if (info
->types
!= NULL
)
4139 if (! ieee_change_buffer (info
, &info
->types
))
4144 if (! ieee_change_buffer (info
, &info
->types
)
4145 || ! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
4146 || ! ieee_write_byte (info
, 1)
4147 || ! ieee_write_number (info
, 0)
4148 || ! ieee_write_id (info
, info
->modname
))
4152 /* Push the new type on the type stack, write out an NN record, and
4153 write out the start of a TY record. The caller will then finish
4155 return (ieee_push_type (info
, type_indx
, size
, unsignedp
)
4156 && ieee_write_byte (info
, (int) ieee_nn_record
)
4157 && ieee_write_number (info
, name_indx
)
4158 && ieee_write_id (info
, name
)
4159 && ieee_write_byte (info
, (int) ieee_ty_record_enum
)
4160 && ieee_write_number (info
, type_indx
)
4161 && ieee_write_byte (info
, 0xce)
4162 && ieee_write_number (info
, name_indx
));
4165 /* The general routine to write out IEEE debugging information. */
4168 write_ieee_debugging_info (abfd
, dhandle
)
4172 struct ieee_handle info
;
4173 struct ieee_buf
*tags
;
4174 struct ieee_name_type
*nt
;
4179 memset (&info
, 0, sizeof info
);
4181 info
.type_indx
= 256;
4182 info
.name_indx
= 32;
4184 if (! debug_write (dhandle
, &ieee_fns
, (PTR
) &info
))
4187 if (info
.filename
!= NULL
)
4189 if (! ieee_finish_compilation_unit (&info
))
4193 /* Put any undefined tags in the global typedef information. */
4195 for (nt
= info
.tags
; nt
!= NULL
; nt
= nt
->next
)
4197 unsigned int name_indx
;
4200 if (nt
->kind
== DEBUG_KIND_ILLEGAL
)
4204 if (! ieee_change_buffer (&info
, &tags
)
4205 || ! ieee_write_byte (&info
, (int) ieee_bb_record_enum
)
4206 || ! ieee_write_byte (&info
, 2)
4207 || ! ieee_write_number (&info
, 0)
4208 || ! ieee_write_id (&info
, ""))
4211 name_indx
= info
.name_indx
;
4213 if (! ieee_write_byte (&info
, (int) ieee_nn_record
)
4214 || ! ieee_write_number (&info
, name_indx
)
4215 || ! ieee_write_id (&info
, nt
->name
)
4216 || ! ieee_write_byte (&info
, (int) ieee_ty_record_enum
)
4217 || ! ieee_write_number (&info
, nt
->type
.indx
)
4218 || ! ieee_write_byte (&info
, 0xce)
4219 || ! ieee_write_number (&info
, name_indx
))
4226 case DEBUG_KIND_STRUCT
:
4227 case DEBUG_KIND_CLASS
:
4230 case DEBUG_KIND_UNION
:
4231 case DEBUG_KIND_UNION_CLASS
:
4234 case DEBUG_KIND_ENUM
:
4238 if (! ieee_write_number (&info
, code
)
4239 || ! ieee_write_number (&info
, 0))
4244 struct ieee_buf
**pb
;
4246 if (! ieee_write_byte (&info
, (int) ieee_be_record_enum
))
4249 for (pb
= &tags
; *pb
!= NULL
; pb
= &(*pb
)->next
)
4255 /* Now all the data is in info.data. Write it out to the BFD. We
4256 normally would need to worry about whether all the other sections
4257 are set up yet, but the IEEE backend will handle this particular
4258 case correctly regardless. */
4259 if (info
.data
== NULL
)
4261 /* There is no debugging information. */
4265 s
= bfd_make_section (abfd
, ".debug");
4267 err
= "bfd_make_section";
4270 if (! bfd_set_section_flags (abfd
, s
, SEC_DEBUGGING
| SEC_HAS_CONTENTS
))
4271 err
= "bfd_set_section_flags";
4278 for (b
= info
.data
; b
!= NULL
; b
= b
->next
)
4280 if (! bfd_set_section_size (abfd
, s
, size
))
4281 err
= "bfd_set_section_size";
4288 for (b
= info
.data
; b
!= NULL
; b
= b
->next
)
4290 if (! bfd_set_section_contents (abfd
, s
, b
->buf
, offset
, b
->c
))
4292 err
= "bfd_set_section_contents";
4301 fprintf (stderr
, "%s: %s: %s\n", bfd_get_filename (abfd
), err
,
4302 bfd_errmsg (bfd_get_error ()));
4309 /* Start writing out information for a compilation unit. */
4312 ieee_start_compilation_unit (p
, filename
)
4314 const char *filename
;
4316 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4317 const char *modname
;
4320 if (info
->filename
!= NULL
)
4322 if (! ieee_finish_compilation_unit (info
))
4326 info
->filename
= filename
;
4327 modname
= strrchr (filename
, '/');
4328 if (modname
!= NULL
)
4332 modname
= strrchr (filename
, '\\');
4333 if (modname
!= NULL
)
4338 c
= xstrdup (modname
);
4339 s
= strrchr (c
, '.');
4347 info
->linenos
= NULL
;
4348 info
->ranges
= NULL
;
4353 /* Finish up a compilation unit. */
4356 ieee_finish_compilation_unit (info
)
4357 struct ieee_handle
*info
;
4359 struct ieee_buf
**pp
;
4360 struct ieee_range
*r
;
4362 if (info
->types
!= NULL
)
4364 if (! ieee_change_buffer (info
, &info
->types
)
4365 || ! ieee_write_byte (info
, (int) ieee_be_record_enum
))
4369 if (info
->cxx
!= NULL
)
4371 /* Append any C++ information to the global function and
4372 variable information. */
4373 if (info
->vars
!= NULL
)
4375 if (! ieee_change_buffer (info
, &info
->vars
))
4380 if (! ieee_change_buffer (info
, &info
->vars
)
4381 || ! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
4382 || ! ieee_write_byte (info
, 3)
4383 || ! ieee_write_number (info
, 0)
4384 || ! ieee_write_id (info
, info
->modname
))
4388 /* We put the pmisc records in a dummy procedure, just as the
4389 MRI compiler does. */
4390 if (! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
4391 || ! ieee_write_byte (info
, 6)
4392 || ! ieee_write_number (info
, 0)
4393 || ! ieee_write_id (info
, "__XRYCPP")
4394 || ! ieee_write_number (info
, 0)
4395 || ! ieee_write_number (info
, 0)
4396 || ! ieee_write_number (info
, info
->highaddr
))
4399 for (pp
= &info
->vars
; *pp
!= NULL
; pp
= &(*pp
)->next
)
4403 if (! ieee_change_buffer (info
, &info
->vars
)
4404 || ! ieee_write_byte (info
, (int) ieee_be_record_enum
)
4405 || ! ieee_write_number (info
, info
->highaddr
))
4409 if (info
->vars
!= NULL
)
4411 if (! ieee_change_buffer (info
, &info
->vars
)
4412 || ! ieee_write_byte (info
, (int) ieee_be_record_enum
))
4416 if (info
->linenos
!= NULL
)
4418 if (! ieee_change_buffer (info
, &info
->linenos
)
4419 || ! ieee_write_byte (info
, (int) ieee_be_record_enum
))
4423 for (pp
= &info
->data
; *pp
!= NULL
; pp
= &(*pp
)->next
)
4426 for (; *pp
!= NULL
; pp
= &(*pp
)->next
)
4429 for (; *pp
!= NULL
; pp
= &(*pp
)->next
)
4431 *pp
= info
->linenos
;
4433 /* Build BB10/BB11 blocks based on the ranges we recorded. */
4434 if (! ieee_change_buffer (info
, &info
->data
))
4437 if (! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
4438 || ! ieee_write_byte (info
, 10)
4439 || ! ieee_write_number (info
, 0)
4440 || ! ieee_write_id (info
, info
->modname
)
4441 || ! ieee_write_id (info
, "")
4442 || ! ieee_write_number (info
, 0)
4443 || ! ieee_write_id (info
, "GNU objcopy"))
4446 for (r
= info
->ranges
; r
!= NULL
; r
= r
->next
)
4455 /* Find the section corresponding to this range. */
4456 for (s
= info
->abfd
->sections
; s
!= NULL
; s
= s
->next
)
4458 if (bfd_get_section_vma (info
->abfd
, s
) <= low
4459 && high
<= (bfd_get_section_vma (info
->abfd
, s
)
4460 + bfd_section_size (info
->abfd
, s
)))
4466 /* Just ignore this range. */
4470 /* Coalesce ranges if it seems reasonable. */
4471 while (r
->next
!= NULL
4472 && high
+ 64 >= r
->next
->low
4474 <= (bfd_get_section_vma (info
->abfd
, s
)
4475 + bfd_section_size (info
->abfd
, s
))))
4478 high
= r
->next
->high
;
4481 if ((s
->flags
& SEC_CODE
) != 0)
4483 else if ((s
->flags
& SEC_READONLY
) != 0)
4488 if (! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
4489 || ! ieee_write_byte (info
, 11)
4490 || ! ieee_write_number (info
, 0)
4491 || ! ieee_write_id (info
, "")
4492 || ! ieee_write_number (info
, kind
)
4493 || ! ieee_write_number (info
, s
->index
)
4494 || ! ieee_write_number (info
, low
)
4495 || ! ieee_write_byte (info
, (int) ieee_be_record_enum
)
4496 || ! ieee_write_number (info
, high
- low
))
4500 if (! ieee_write_byte (info
, (int) ieee_be_record_enum
))
4506 /* Start recording information from a particular source file. This is
4507 used to record which file defined which types, variables, etc. It
4508 is not used for line numbers, since the lineno entry point passes
4509 down the file name anyhow. IEEE debugging information doesn't seem
4510 to store this information anywhere. */
4514 ieee_start_source (p
, filename
)
4516 const char *filename
;
4521 /* Make an empty type. */
4527 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4529 return ieee_push_type (info
, 0, 0, false);
4532 /* Make a void type. */
4538 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4540 return ieee_push_type (info
, 1, 0, false);
4543 /* Make an integer type. */
4546 ieee_int_type (p
, size
, unsignedp
)
4551 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4557 indx
= (int) builtin_signed_char
;
4560 indx
= (int) builtin_signed_short_int
;
4563 indx
= (int) builtin_signed_long
;
4566 indx
= (int) builtin_signed_long_long
;
4569 fprintf (stderr
, "IEEE unsupported integer type size %u\n", size
);
4576 return ieee_push_type (info
, indx
, size
, unsignedp
);
4579 /* Make a floating point type. */
4582 ieee_float_type (p
, size
)
4586 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4592 indx
= (int) builtin_float
;
4595 indx
= (int) builtin_double
;
4598 /* FIXME: This size really depends upon the processor. */
4599 indx
= (int) builtin_long_double
;
4602 indx
= (int) builtin_long_long_double
;
4605 fprintf (stderr
, "IEEE unsupported float type size %u\n", size
);
4609 return ieee_push_type (info
, indx
, size
, false);
4612 /* Make a complex type. */
4615 ieee_complex_type (p
, size
)
4619 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4631 fprintf (stderr
, "IEEE unsupported complex type size %u\n", size
);
4635 /* FIXME: I don't know what the string is for. */
4636 return (ieee_define_type (info
, size
, false)
4637 && ieee_write_number (info
, code
)
4638 && ieee_write_id (info
, ""));
4641 /* Make a boolean type. IEEE doesn't support these, so we just make
4642 an integer type instead. */
4645 ieee_bool_type (p
, size
)
4649 return ieee_int_type (p
, size
, true);
4652 /* Make an enumeration. */
4655 ieee_enum_type (p
, tag
, names
, vals
)
4659 bfd_signed_vma
*vals
;
4661 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4665 /* If this is a simple enumeration, in which the values start at 0
4666 and always increment by 1, we can use type E. Otherwise we must
4672 for (i
= 0; names
[i
] != NULL
; i
++)
4682 if (! ieee_define_named_type (info
, tag
, true, (unsigned int) -1, 0,
4683 true, (struct ieee_buf
**) NULL
)
4684 || ! ieee_write_number (info
, simple
? 'E' : 'N'))
4688 /* FIXME: This is supposed to be the enumeration size, but we
4689 don't store that. */
4690 if (! ieee_write_number (info
, 4))
4695 for (i
= 0; names
[i
] != NULL
; i
++)
4697 if (! ieee_write_id (info
, names
[i
]))
4701 if (! ieee_write_number (info
, vals
[i
]))
4710 /* Make a pointer type. */
4713 ieee_pointer_type (p
)
4716 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4719 indx
= ieee_pop_type (info
);
4721 /* A pointer to a simple builtin type can be obtained by adding 32. */
4723 return ieee_push_type (info
, indx
+ 32, 0, true);
4725 return (ieee_define_type (info
, 0, true)
4726 && ieee_write_number (info
, 'P')
4727 && ieee_write_number (info
, indx
));
4730 /* Make a function type. */
4733 ieee_function_type (p
, argcount
, varargs
)
4738 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4739 unsigned int *args
= NULL
;
4741 unsigned int retindx
;
4745 args
= (unsigned int *) xmalloc (argcount
* sizeof *args
);
4746 for (i
= argcount
- 1; i
>= 0; i
--)
4747 args
[i
] = ieee_pop_type (info
);
4749 else if (argcount
< 0)
4752 retindx
= ieee_pop_type (info
);
4754 /* An attribute of 0x41 means that the frame and push mask are
4756 if (! ieee_define_type (info
, 0, true)
4757 || ! ieee_write_number (info
, 'x')
4758 || ! ieee_write_number (info
, 0x41)
4759 || ! ieee_write_number (info
, 0)
4760 || ! ieee_write_number (info
, 0)
4761 || ! ieee_write_number (info
, retindx
)
4762 || ! ieee_write_number (info
, (bfd_vma
) argcount
+ (varargs
? 1 : 0)))
4766 for (i
= 0; i
< argcount
; i
++)
4767 if (! ieee_write_number (info
, args
[i
]))
4773 /* A varargs function is represented by writing out the last
4774 argument as type void *, although this makes little sense. */
4775 if (! ieee_write_number (info
, (bfd_vma
) builtin_void
+ 32))
4779 return ieee_write_number (info
, 0);
4782 /* Make a reference type. */
4785 ieee_reference_type (p
)
4788 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4790 /* IEEE appears to record a normal pointer type, and then use a
4791 pmisc record to indicate that it is really a reference. */
4793 if (! ieee_pointer_type (p
))
4795 info
->type_stack
->type
.referencep
= true;
4799 /* Make a range type. */
4802 ieee_range_type (p
, low
, high
)
4805 bfd_signed_vma high
;
4807 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4811 size
= info
->type_stack
->type
.size
;
4812 unsignedp
= info
->type_stack
->type
.unsignedp
;
4813 (void) ieee_pop_type (info
);
4814 return (ieee_define_type (info
, size
, unsignedp
)
4815 && ieee_write_number (info
, 'R')
4816 && ieee_write_number (info
, (bfd_vma
) low
)
4817 && ieee_write_number (info
, (bfd_vma
) high
)
4818 && ieee_write_number (info
, unsignedp
? 0 : 1)
4819 && ieee_write_number (info
, size
));
4822 /* Make an array type. */
4826 ieee_array_type (p
, low
, high
, stringp
)
4829 bfd_signed_vma high
;
4832 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4833 unsigned int eleindx
;
4835 /* IEEE does not store the range, so we just ignore it. */
4836 (void) ieee_pop_type (info
);
4837 eleindx
= ieee_pop_type (info
);
4839 if (! ieee_define_type (info
, 0, false)
4840 || ! ieee_write_number (info
, low
== 0 ? 'Z' : 'C')
4841 || ! ieee_write_number (info
, eleindx
))
4845 if (! ieee_write_number (info
, low
))
4849 return ieee_write_number (info
, high
);
4852 /* Make a set type. */
4855 ieee_set_type (p
, bitstringp
)
4859 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4860 unsigned int eleindx
;
4862 eleindx
= ieee_pop_type (info
);
4864 /* FIXME: We don't know the size, so we just use 4. */
4866 return (ieee_define_type (info
, 0, true)
4867 && ieee_write_number (info
, 's')
4868 && ieee_write_number (info
, 4)
4869 && ieee_write_number (info
, eleindx
));
4872 /* Make an offset type. */
4875 ieee_offset_type (p
)
4878 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4879 unsigned int targetindx
, baseindx
;
4881 targetindx
= ieee_pop_type (info
);
4882 baseindx
= ieee_pop_type (info
);
4884 /* FIXME: The MRI C++ compiler does not appear to generate any
4885 useful type information about an offset type. It just records a
4886 pointer to member as an integer. The MRI/HP IEEE spec does
4887 describe a pmisc record which can be used for a pointer to
4888 member. Unfortunately, it does not describe the target type,
4889 which seems pretty important. I'm going to punt this for now. */
4891 return ieee_int_type (p
, 4, true);
4894 /* Make a method type. */
4897 ieee_method_type (p
, domain
, argcount
, varargs
)
4903 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4905 /* FIXME: The MRI/HP IEEE spec defines a pmisc record to use for a
4906 method, but the definition is incomplete. We just output an 'x'
4910 (void) ieee_pop_type (info
);
4912 return ieee_function_type (p
, argcount
, varargs
);
4915 /* Make a const qualified type. */
4921 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4926 size
= info
->type_stack
->type
.size
;
4927 unsignedp
= info
->type_stack
->type
.unsignedp
;
4928 indx
= ieee_pop_type (info
);
4929 return (ieee_define_type (info
, size
, unsignedp
)
4930 && ieee_write_number (info
, 'n')
4931 && ieee_write_number (info
, 1)
4932 && ieee_write_number (info
, indx
));
4935 /* Make a volatile qualified type. */
4938 ieee_volatile_type (p
)
4941 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4946 size
= info
->type_stack
->type
.size
;
4947 unsignedp
= info
->type_stack
->type
.unsignedp
;
4948 indx
= ieee_pop_type (info
);
4949 return (ieee_define_type (info
, size
, unsignedp
)
4950 && ieee_write_number (info
, 'n')
4951 && ieee_write_number (info
, 2)
4952 && ieee_write_number (info
, indx
));
4955 /* Convert an enum debug_visibility into a CXXFLAGS value. */
4958 ieee_vis_to_flags (visibility
)
4959 enum debug_visibility visibility
;
4965 case DEBUG_VISIBILITY_PUBLIC
:
4966 return CXXFLAGS_VISIBILITY_PUBLIC
;
4967 case DEBUG_VISIBILITY_PRIVATE
:
4968 return CXXFLAGS_VISIBILITY_PRIVATE
;
4969 case DEBUG_VISIBILITY_PROTECTED
:
4970 return CXXFLAGS_VISIBILITY_PROTECTED
;
4975 /* Start defining a struct type. We build it in the strdef field on
4976 the stack, to avoid confusing type definitions required by the
4977 fields with the struct type itself. */
4980 ieee_start_struct_type (p
, tag
, id
, structp
, size
)
4987 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
4988 struct ieee_buf
*strdef
;
4991 if (! ieee_define_named_type (info
, tag
, true, id
, size
, true, &strdef
)
4992 || ! ieee_write_number (info
, structp
? 'S' : 'U')
4993 || ! ieee_write_number (info
, size
))
4996 info
->type_stack
->type
.strdef
= strdef
;
5001 /* Add a field to a struct. */
5004 ieee_struct_field (p
, name
, bitpos
, bitsize
, visibility
)
5009 enum debug_visibility visibility
;
5011 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5017 size
= info
->type_stack
->type
.size
;
5018 unsignedp
= info
->type_stack
->type
.unsignedp
;
5019 indx
= ieee_pop_type (info
);
5021 assert (info
->type_stack
!= NULL
&& info
->type_stack
->type
.strdef
!= NULL
);
5023 if (info
->type_stack
->type
.classdef
!= NULL
)
5028 /* This is a class. We must add a description of this field to
5029 the class records we are building. */
5031 flags
= ieee_vis_to_flags (visibility
);
5032 nindx
= info
->type_stack
->type
.classdef
->indx
;
5033 if (! ieee_change_buffer (info
,
5034 &info
->type_stack
->type
.classdef
->pmiscbuf
)
5035 || ! ieee_write_asn (info
, nindx
, 'd')
5036 || ! ieee_write_asn (info
, nindx
, flags
)
5037 || ! ieee_write_atn65 (info
, nindx
, name
)
5038 || ! ieee_write_atn65 (info
, nindx
, name
))
5040 info
->type_stack
->type
.classdef
->pmisccount
+= 4;
5043 /* If the bitsize doesn't match the expected size, we need to output
5045 if (size
== 0 || bitsize
== size
* 8)
5046 offset
= bitpos
/ 8;
5049 if (! ieee_define_type (info
, 0, unsignedp
)
5050 || ! ieee_write_number (info
, 'g')
5051 || ! ieee_write_number (info
, unsignedp
? 0 : 1)
5052 || ! ieee_write_number (info
, indx
))
5054 indx
= ieee_pop_type (info
);
5058 /* Switch to the struct we are building in order to output this
5059 field definition. */
5060 return (ieee_change_buffer (info
, &info
->type_stack
->type
.strdef
)
5061 && ieee_write_id (info
, name
)
5062 && ieee_write_number (info
, indx
)
5063 && ieee_write_number (info
, offset
));
5066 /* Finish up a struct type. */
5069 ieee_end_struct_type (p
)
5072 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5073 struct ieee_buf
**pb
;
5075 assert (info
->type_stack
!= NULL
&& info
->type_stack
->type
.strdef
!= NULL
);
5077 /* Make sure we have started the types block. */
5078 if (info
->types
== NULL
)
5080 if (! ieee_change_buffer (info
, &info
->types
)
5081 || ! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
5082 || ! ieee_write_byte (info
, 1)
5083 || ! ieee_write_number (info
, 0)
5084 || ! ieee_write_id (info
, info
->modname
))
5088 /* Append the struct definition to the types. */
5089 for (pb
= &info
->types
; *pb
!= NULL
; pb
= &(*pb
)->next
)
5091 *pb
= info
->type_stack
->type
.strdef
;
5092 info
->type_stack
->type
.strdef
= NULL
;
5094 /* Leave the struct on the type stack. */
5099 /* Start a class type. */
5102 ieee_start_class_type (p
, tag
, id
, structp
, size
, vptr
, ownvptr
)
5111 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5113 struct ieee_buf
*pmiscbuf
;
5115 struct ieee_type_class
*classdef
;
5116 struct ieee_name_type
*nt
;
5118 /* A C++ class is output as a C++ struct along with a set of pmisc
5119 records describing the class. */
5121 /* We need to have a name so that we can associate the struct and
5127 t
= (char *) xmalloc (20);
5128 sprintf (t
, "__anon%u", id
);
5132 /* We can't write out the virtual table information until we have
5133 finished the class, because we don't know the virtual table size.
5134 We get the size from the largest voffset we see. */
5136 if (vptr
&& ! ownvptr
)
5138 assert (info
->type_stack
->type
.classdef
!= NULL
);
5139 vclass
= info
->type_stack
->type
.classdef
->name
;
5140 (void) ieee_pop_type (info
);
5143 if (! ieee_start_struct_type (p
, tag
, id
, structp
, size
))
5146 indx
= info
->name_indx
;
5149 /* We write out pmisc records into the classdef field. We will
5150 write out the pmisc start after we know the number of records we
5153 if (! ieee_change_buffer (info
, &pmiscbuf
)
5154 || ! ieee_write_asn (info
, indx
, 'T')
5155 || ! ieee_write_asn (info
, indx
, structp
? 'o' : 'u')
5156 || ! ieee_write_atn65 (info
, indx
, tag
))
5159 classdef
= (struct ieee_type_class
*) xmalloc (sizeof *classdef
);
5160 memset (classdef
, 0, sizeof *classdef
);
5162 classdef
->name
= tag
;
5163 classdef
->indx
= indx
;
5164 classdef
->pmiscbuf
= pmiscbuf
;
5165 classdef
->pmisccount
= 3;
5166 classdef
->vclass
= vclass
;
5167 classdef
->ownvptr
= ownvptr
;
5169 info
->type_stack
->type
.classdef
= classdef
;
5171 /* We need to fill in the classdef in the tag as well, so that it
5172 will be set when ieee_tag_type is called. */
5173 for (nt
= info
->tags
; nt
!= NULL
; nt
= nt
->next
)
5174 if (nt
->name
[0] == tag
[0]
5175 && strcmp (nt
->name
, tag
) == 0)
5177 assert (nt
!= NULL
);
5178 nt
->type
.classdef
= classdef
;
5183 /* Add a static member to a class. */
5186 ieee_class_static_member (p
, name
, physname
, visibility
)
5189 const char *physname
;
5190 enum debug_visibility visibility
;
5192 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5196 /* We don't care about the type. Hopefully there will be a call
5197 ieee_variable declaring the physical name and the type, since
5198 that is where an IEEE consumer must get the type. */
5199 (void) ieee_pop_type (info
);
5201 assert (info
->type_stack
!= NULL
5202 && info
->type_stack
->type
.classdef
!= NULL
);
5204 flags
= ieee_vis_to_flags (visibility
);
5205 flags
|= CXXFLAGS_STATIC
;
5207 nindx
= info
->type_stack
->type
.classdef
->indx
;
5209 if (! ieee_change_buffer (info
, &info
->type_stack
->type
.classdef
->pmiscbuf
)
5210 || ! ieee_write_asn (info
, nindx
, 'd')
5211 || ! ieee_write_asn (info
, nindx
, flags
)
5212 || ! ieee_write_atn65 (info
, nindx
, name
)
5213 || ! ieee_write_atn65 (info
, nindx
, physname
))
5215 info
->type_stack
->type
.classdef
->pmisccount
+= 4;
5220 /* Add a base class to a class. */
5223 ieee_class_baseclass (p
, bitpos
, virtual, visibility
)
5227 enum debug_visibility visibility
;
5229 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5236 assert (info
->type_stack
!= NULL
5237 && info
->type_stack
->type
.classdef
!= NULL
5238 && info
->type_stack
->next
!= NULL
5239 && info
->type_stack
->next
->type
.classdef
!= NULL
5240 && info
->type_stack
->next
->type
.strdef
!= NULL
);
5242 bname
= info
->type_stack
->type
.classdef
->name
;
5243 bindx
= ieee_pop_type (info
);
5245 /* We are currently defining both a struct and a class. We must
5246 write out a field definition in the struct which holds the base
5247 class. The stabs debugging reader will create a field named
5248 _vb$CLASS for a virtual base class, so we just use that. FIXME:
5249 we should not depend upon a detail of stabs debugging. */
5252 fname
= (char *) xmalloc (strlen (bname
) + sizeof "_vb$");
5253 sprintf (fname
, "_vb$%s", bname
);
5254 flags
= BASEFLAGS_VIRTUAL
;
5258 fname
= (char *) xmalloc (strlen (bname
) + sizeof "_b$");
5259 sprintf (fname
, "_b$%s", bname
);
5261 if (! ieee_change_buffer (info
, &info
->type_stack
->type
.strdef
)
5262 || ! ieee_write_id (info
, fname
)
5263 || ! ieee_write_number (info
, bindx
)
5264 || ! ieee_write_number (info
, bitpos
/ 8))
5269 if (visibility
== DEBUG_VISIBILITY_PRIVATE
)
5270 flags
|= BASEFLAGS_PRIVATE
;
5272 nindx
= info
->type_stack
->type
.classdef
->indx
;
5274 if (! ieee_change_buffer (info
, &info
->type_stack
->type
.classdef
->pmiscbuf
)
5275 || ! ieee_write_asn (info
, nindx
, 'b')
5276 || ! ieee_write_asn (info
, nindx
, flags
)
5277 || ! ieee_write_atn65 (info
, nindx
, bname
)
5278 || ! ieee_write_asn (info
, nindx
, 0)
5279 || ! ieee_write_atn65 (info
, nindx
, fname
))
5281 info
->type_stack
->type
.classdef
->pmisccount
+= 5;
5288 /* Start building a method for a class. */
5291 ieee_class_start_method (p
, name
)
5295 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5297 assert (info
->type_stack
!= NULL
5298 && info
->type_stack
->type
.classdef
!= NULL
5299 && info
->type_stack
->type
.classdef
->method
== NULL
);
5301 info
->type_stack
->type
.classdef
->method
= name
;
5306 /* Define a new method variant, either static or not. */
5309 ieee_class_method_var (info
, physname
, visibility
, staticp
, constp
,
5310 volatilep
, voffset
, context
)
5311 struct ieee_handle
*info
;
5312 const char *physname
;
5313 enum debug_visibility visibility
;
5324 /* We don't need the type of the method. An IEEE consumer which
5325 wants the type must track down the function by the physical name
5326 and get the type from that. */
5327 (void) ieee_pop_type (info
);
5329 /* We don't use the context. FIXME: We probably ought to use it to
5330 adjust the voffset somehow, but I don't really know how. */
5332 (void) ieee_pop_type (info
);
5334 assert (info
->type_stack
!= NULL
5335 && info
->type_stack
->type
.classdef
!= NULL
5336 && info
->type_stack
->type
.classdef
->method
!= NULL
);
5338 flags
= ieee_vis_to_flags (visibility
);
5340 /* FIXME: We never set CXXFLAGS_OVERRIDE, CXXFLAGS_OPERATOR,
5341 CXXFLAGS_CTORDTOR, CXXFLAGS_CTOR, or CXXFLAGS_INLINE. */
5344 flags
|= CXXFLAGS_STATIC
;
5346 flags
|= CXXFLAGS_CONST
;
5348 flags
|= CXXFLAGS_VOLATILE
;
5350 nindx
= info
->type_stack
->type
.classdef
->indx
;
5352 virtual = context
|| voffset
> 0;
5354 if (! ieee_change_buffer (info
,
5355 &info
->type_stack
->type
.classdef
->pmiscbuf
)
5356 || ! ieee_write_asn (info
, nindx
, virtual ? 'v' : 'm')
5357 || ! ieee_write_asn (info
, nindx
, flags
)
5358 || ! ieee_write_atn65 (info
, nindx
,
5359 info
->type_stack
->type
.classdef
->method
)
5360 || ! ieee_write_atn65 (info
, nindx
, physname
))
5365 if (voffset
> info
->type_stack
->type
.classdef
->voffset
)
5366 info
->type_stack
->type
.classdef
->voffset
= voffset
;
5367 /* FIXME: The size of a vtable entry depends upon the
5369 if (! ieee_write_asn (info
, nindx
, (voffset
/ 4) + 1))
5371 ++info
->type_stack
->type
.classdef
->pmisccount
;
5374 if (! ieee_write_asn (info
, nindx
, 0))
5377 info
->type_stack
->type
.classdef
->pmisccount
+= 5;
5382 /* Define a new method variant. */
5385 ieee_class_method_variant (p
, physname
, visibility
, constp
, volatilep
,
5388 const char *physname
;
5389 enum debug_visibility visibility
;
5395 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5397 return ieee_class_method_var (info
, physname
, visibility
, false, constp
,
5398 volatilep
, voffset
, context
);
5401 /* Define a new static method variant. */
5404 ieee_class_static_method_variant (p
, physname
, visibility
, constp
, volatilep
)
5406 const char *physname
;
5407 enum debug_visibility visibility
;
5411 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5413 return ieee_class_method_var (info
, physname
, visibility
, true, constp
,
5414 volatilep
, 0, false);
5417 /* Finish up a method. */
5420 ieee_class_end_method (p
)
5423 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5425 assert (info
->type_stack
!= NULL
5426 && info
->type_stack
->type
.classdef
!= NULL
5427 && info
->type_stack
->type
.classdef
->method
!= NULL
);
5429 info
->type_stack
->type
.classdef
->method
= NULL
;
5434 /* Finish up a class. */
5437 ieee_end_class_type (p
)
5440 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5442 struct ieee_buf
**pb
;
5444 assert (info
->type_stack
!= NULL
5445 && info
->type_stack
->type
.classdef
!= NULL
);
5447 nindx
= info
->type_stack
->type
.classdef
->indx
;
5449 /* If we have a virtual table, we can write out the information now. */
5450 if (info
->type_stack
->type
.classdef
->vclass
!= NULL
5451 || info
->type_stack
->type
.classdef
->ownvptr
)
5455 /* FIXME: This calculation is architecture dependent. */
5456 vsize
= (info
->type_stack
->type
.classdef
->voffset
+ 4) / 4;
5458 if (! ieee_change_buffer (info
,
5459 &info
->type_stack
->type
.classdef
->pmiscbuf
)
5460 || ! ieee_write_asn (info
, nindx
, 'z')
5461 || ! ieee_write_atn65 (info
, nindx
, "")
5462 || ! ieee_write_asn (info
, nindx
, vsize
))
5464 if (info
->type_stack
->type
.classdef
->ownvptr
)
5466 if (! ieee_write_atn65 (info
, nindx
, ""))
5471 if (! ieee_write_atn65 (info
, nindx
,
5472 info
->type_stack
->type
.classdef
->vclass
))
5475 if (! ieee_write_asn (info
, nindx
, 0))
5477 info
->type_stack
->type
.classdef
->pmisccount
+= 5;
5480 /* Now that we know the number of pmisc records, we can write out
5481 the atn62 which starts the pmisc records, and append them to the
5484 if (! ieee_change_buffer (info
, &info
->cxx
)
5485 || ! ieee_write_byte (info
, (int) ieee_nn_record
)
5486 || ! ieee_write_number (info
, nindx
)
5487 || ! ieee_write_id (info
, "")
5488 || ! ieee_write_2bytes (info
, (int) ieee_atn_record_enum
)
5489 || ! ieee_write_number (info
, nindx
)
5490 || ! ieee_write_number (info
, 0)
5491 || ! ieee_write_number (info
, 62)
5492 || ! ieee_write_number (info
, 80)
5493 || ! ieee_write_number (info
,
5494 info
->type_stack
->type
.classdef
->pmisccount
))
5497 for (pb
= &info
->cxx
; *pb
!= NULL
; pb
= &(*pb
)->next
)
5499 *pb
= info
->type_stack
->type
.classdef
->pmiscbuf
;
5501 return ieee_end_struct_type (p
);
5504 /* Push a previously seen typedef onto the type stack. */
5507 ieee_typedef_type (p
, name
)
5511 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5512 register struct ieee_name_type
*nt
;
5514 for (nt
= info
->typedefs
; nt
!= NULL
; nt
= nt
->next
)
5516 if (nt
->name
[0] == name
[0]
5517 && strcmp (nt
->name
, name
) == 0)
5519 if (! ieee_push_type (info
, nt
->type
.indx
, nt
->type
.size
,
5520 nt
->type
.unsignedp
))
5522 /* Copy over any other type information we may have. */
5523 info
->type_stack
->type
= nt
->type
;
5531 /* Push a tagged type onto the type stack. */
5534 ieee_tag_type (p
, name
, id
, kind
)
5538 enum debug_type_kind kind
;
5540 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5541 register struct ieee_name_type
*nt
;
5546 sprintf (ab
, "__anon%u", id
);
5550 for (nt
= info
->tags
; nt
!= NULL
; nt
= nt
->next
)
5552 if (nt
->name
[0] == name
[0]
5553 && strcmp (nt
->name
, name
) == 0)
5555 if (! ieee_push_type (info
, nt
->type
.indx
, nt
->type
.size
,
5556 nt
->type
.unsignedp
))
5558 /* Copy over any other type information we may have. */
5559 info
->type_stack
->type
= nt
->type
;
5564 nt
= (struct ieee_name_type
*) xmalloc (sizeof *nt
);
5565 memset (nt
, 0, sizeof *nt
);
5568 nt
->type
.indx
= info
->type_indx
;
5572 nt
->next
= info
->tags
;
5575 return ieee_push_type (info
, nt
->type
.indx
, 0, false);
5578 /* Output a typedef. */
5581 ieee_typdef (p
, name
)
5585 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5586 struct ieee_name_type
*nt
;
5591 nt
= (struct ieee_name_type
*) xmalloc (sizeof *nt
);
5592 memset (nt
, 0, sizeof *nt
);
5594 nt
->type
= info
->type_stack
->type
;
5595 nt
->kind
= DEBUG_KIND_ILLEGAL
;
5597 nt
->next
= info
->typedefs
;
5598 info
->typedefs
= nt
;
5600 size
= info
->type_stack
->type
.size
;
5601 unsignedp
= info
->type_stack
->type
.unsignedp
;
5602 indx
= ieee_pop_type (info
);
5604 /* If this is a simple builtin type using a builtin name, we don't
5605 want to output the typedef itself. We also want to change the
5606 type index to correspond to the name being used. We recognize
5607 names used in stabs debugging output even if they don't exactly
5608 correspond to the names used for the IEEE builtin types. */
5609 if (indx
<= (unsigned int) builtin_bcd_float
)
5614 switch ((enum builtin_types
) indx
)
5620 if (strcmp (name
, "void") == 0)
5624 case builtin_signed_char
:
5626 if (strcmp (name
, "signed char") == 0)
5628 indx
= (unsigned int) builtin_signed_char
;
5631 else if (strcmp (name
, "char") == 0)
5633 indx
= (unsigned int) builtin_char
;
5638 case builtin_unsigned_char
:
5639 if (strcmp (name
, "unsigned char") == 0)
5643 case builtin_signed_short_int
:
5645 case builtin_short_int
:
5646 case builtin_signed_short
:
5647 if (strcmp (name
, "signed short int") == 0)
5649 indx
= (unsigned int) builtin_signed_short_int
;
5652 else if (strcmp (name
, "short") == 0)
5654 indx
= (unsigned int) builtin_short
;
5657 else if (strcmp (name
, "short int") == 0)
5659 indx
= (unsigned int) builtin_short_int
;
5662 else if (strcmp (name
, "signed short") == 0)
5664 indx
= (unsigned int) builtin_signed_short
;
5669 case builtin_unsigned_short_int
:
5670 case builtin_unsigned_short
:
5671 if (strcmp (name
, "unsigned short int") == 0
5672 || strcmp (name
, "short unsigned int") == 0)
5674 indx
= builtin_unsigned_short_int
;
5677 else if (strcmp (name
, "unsigned short") == 0)
5679 indx
= builtin_unsigned_short
;
5684 case builtin_signed_long
:
5685 case builtin_int
: /* FIXME: Size depends upon architecture. */
5687 if (strcmp (name
, "signed long") == 0)
5689 indx
= builtin_signed_long
;
5692 else if (strcmp (name
, "int") == 0)
5697 else if (strcmp (name
, "long") == 0
5698 || strcmp (name
, "long int") == 0)
5700 indx
= builtin_long
;
5705 case builtin_unsigned_long
:
5706 case builtin_unsigned
: /* FIXME: Size depends upon architecture. */
5707 case builtin_unsigned_int
: /* FIXME: Like builtin_unsigned. */
5708 if (strcmp (name
, "unsigned long") == 0
5709 || strcmp (name
, "long unsigned int") == 0)
5711 indx
= builtin_unsigned_long
;
5714 else if (strcmp (name
, "unsigned") == 0)
5716 indx
= builtin_unsigned
;
5719 else if (strcmp (name
, "unsigned int") == 0)
5721 indx
= builtin_unsigned_int
;
5726 case builtin_signed_long_long
:
5727 if (strcmp (name
, "signed long long") == 0
5728 || strcmp (name
, "long long int") == 0)
5732 case builtin_unsigned_long_long
:
5733 if (strcmp (name
, "unsigned long long") == 0
5734 || strcmp (name
, "long long unsigned int") == 0)
5739 if (strcmp (name
, "float") == 0)
5743 case builtin_double
:
5744 if (strcmp (name
, "double") == 0)
5748 case builtin_long_double
:
5749 if (strcmp (name
, "long double") == 0)
5753 case builtin_long_long_double
:
5754 if (strcmp (name
, "long long double") == 0)
5761 nt
->type
.indx
= indx
;
5766 if (! ieee_define_named_type (info
, name
, false, 0, size
, unsignedp
,
5767 (struct ieee_buf
**) NULL
)
5768 || ! ieee_write_number (info
, 'T')
5769 || ! ieee_write_number (info
, indx
))
5772 /* Remove the type we just added to the type stack. */
5773 (void) ieee_pop_type (info
);
5778 /* Output a tag for a type. We don't have to do anything here. */
5785 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5787 (void) ieee_pop_type (info
);
5791 /* Output an integer constant. */
5794 ieee_int_constant (p
, name
, val
)
5803 /* Output a floating point constant. */
5806 ieee_float_constant (p
, name
, val
)
5815 /* Output a typed constant. */
5818 ieee_typed_constant (p
, name
, val
)
5823 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5826 (void) ieee_pop_type (info
);
5830 /* Output a variable. */
5833 ieee_variable (p
, name
, kind
, val
)
5836 enum debug_var_kind kind
;
5839 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5840 unsigned int name_indx
;
5842 unsigned int type_indx
;
5845 /* Make sure the variable section is started. */
5846 if (info
->vars
!= NULL
)
5848 if (! ieee_change_buffer (info
, &info
->vars
))
5853 if (! ieee_change_buffer (info
, &info
->vars
)
5854 || ! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
5855 || ! ieee_write_byte (info
, 3)
5856 || ! ieee_write_number (info
, 0)
5857 || ! ieee_write_id (info
, info
->modname
))
5861 name_indx
= info
->name_indx
;
5864 size
= info
->type_stack
->type
.size
;
5865 type_indx
= ieee_pop_type (info
);
5867 /* Write out an NN and an ATN record for this variable. */
5868 if (! ieee_write_byte (info
, (int) ieee_nn_record
)
5869 || ! ieee_write_number (info
, name_indx
)
5870 || ! ieee_write_id (info
, name
)
5871 || ! ieee_write_2bytes (info
, (int) ieee_atn_record_enum
)
5872 || ! ieee_write_number (info
, name_indx
)
5873 || ! ieee_write_number (info
, type_indx
))
5881 if (! ieee_write_number (info
, 8)
5882 || ! ieee_add_range (info
, val
, val
+ size
))
5887 case DEBUG_LOCAL_STATIC
:
5888 if (! ieee_write_number (info
, 3)
5889 || ! ieee_add_range (info
, val
, val
+ size
))
5894 if (! ieee_write_number (info
, 1)
5895 || ! ieee_write_number (info
, val
))
5899 case DEBUG_REGISTER
:
5900 if (! ieee_write_number (info
, 2)
5901 || ! ieee_write_number (info
,
5902 ieee_genreg_to_regno (info
->abfd
, val
)))
5910 if (! ieee_write_asn (info
, name_indx
, val
))
5917 /* Start outputting information for a function. */
5920 ieee_start_function (p
, name
, global
)
5925 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5928 /* Make sure the variable section is started. */
5929 if (info
->vars
!= NULL
)
5931 if (! ieee_change_buffer (info
, &info
->vars
))
5936 if (! ieee_change_buffer (info
, &info
->vars
)
5937 || ! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
5938 || ! ieee_write_byte (info
, 3)
5939 || ! ieee_write_number (info
, 0)
5940 || ! ieee_write_id (info
, info
->modname
))
5944 indx
= ieee_pop_type (info
);
5946 /* The address is written out as the first block. */
5948 ++info
->block_depth
;
5950 return (ieee_write_byte (info
, (int) ieee_bb_record_enum
)
5951 && ieee_write_byte (info
, global
? 4 : 6)
5952 && ieee_write_number (info
, 0)
5953 && ieee_write_id (info
, name
)
5954 && ieee_write_number (info
, 0)
5955 && ieee_write_number (info
, indx
));
5958 /* Add a function parameter. This will normally be called before the
5959 first block, so we postpone them until we see the block. */
5962 ieee_function_parameter (p
, name
, kind
, val
)
5965 enum debug_parm_kind kind
;
5968 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
5969 struct ieee_pending_parm
*m
, **pm
;
5971 assert (info
->block_depth
== 1);
5973 m
= (struct ieee_pending_parm
*) xmalloc (sizeof *m
);
5974 memset (m
, 0, sizeof *m
);
5978 m
->type
= ieee_pop_type (info
);
5982 for (pm
= &info
->pending_parms
; *pm
!= NULL
; pm
= &(*pm
)->next
)
5989 /* Output pending function parameters. */
5992 ieee_output_pending_parms (info
)
5993 struct ieee_handle
*info
;
5995 struct ieee_pending_parm
*m
;
5997 m
= info
->pending_parms
;
6000 struct ieee_pending_parm
*next
;
6001 enum debug_var_kind vkind
;
6008 case DEBUG_PARM_STACK
:
6009 case DEBUG_PARM_REFERENCE
:
6010 vkind
= DEBUG_LOCAL
;
6012 case DEBUG_PARM_REG
:
6013 case DEBUG_PARM_REF_REG
:
6014 vkind
= DEBUG_REGISTER
;
6018 if (! ieee_push_type (info
, m
->type
, 0, false)
6019 || ! ieee_variable ((PTR
) info
, m
->name
, vkind
, m
->val
))
6022 /* FIXME: We should output a pmisc note here for reference
6029 info
->pending_parms
= NULL
;
6034 /* Start a block. If this is the first block, we output the address
6035 to finish the BB4 or BB6, and then output the function parameters. */
6038 ieee_start_block (p
, addr
)
6042 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
6044 if (! ieee_change_buffer (info
, &info
->vars
))
6047 if (info
->block_depth
== 1)
6049 if (! ieee_write_number (info
, addr
)
6050 || ! ieee_output_pending_parms (info
))
6055 if (! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
6056 || ! ieee_write_byte (info
, 6)
6057 || ! ieee_write_number (info
, 0)
6058 || ! ieee_write_id (info
, "")
6059 || ! ieee_write_number (info
, 0)
6060 || ! ieee_write_number (info
, 0)
6061 || ! ieee_write_number (info
, addr
))
6065 if (! ieee_start_range (info
, addr
))
6068 ++info
->block_depth
;
6076 ieee_end_block (p
, addr
)
6080 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
6082 if (! ieee_change_buffer (info
, &info
->vars
)
6083 || ! ieee_write_byte (info
, (int) ieee_be_record_enum
)
6084 || ! ieee_write_number (info
, addr
))
6087 if (! ieee_end_range (info
, addr
))
6090 --info
->block_depth
;
6092 if (addr
> info
->highaddr
)
6093 info
->highaddr
= addr
;
6098 /* End a function. */
6101 ieee_end_function (p
)
6104 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
6106 assert (info
->block_depth
== 1);
6108 --info
->block_depth
;
6113 /* Record line number information. */
6116 ieee_lineno (p
, filename
, lineno
, addr
)
6118 const char *filename
;
6119 unsigned long lineno
;
6122 struct ieee_handle
*info
= (struct ieee_handle
*) p
;
6124 assert (info
->filename
!= NULL
);
6126 /* Make sure we have a line number block. */
6127 if (info
->linenos
!= NULL
)
6129 if (! ieee_change_buffer (info
, &info
->linenos
))
6134 info
->lineno_name_indx
= info
->name_indx
;
6136 if (! ieee_change_buffer (info
, &info
->linenos
)
6137 || ! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
6138 || ! ieee_write_byte (info
, 5)
6139 || ! ieee_write_number (info
, 0)
6140 || ! ieee_write_id (info
, info
->filename
)
6141 || ! ieee_write_byte (info
, (int) ieee_nn_record
)
6142 || ! ieee_write_number (info
, info
->lineno_name_indx
)
6143 || ! ieee_write_id (info
, ""))
6145 info
->lineno_filename
= info
->filename
;
6148 if (strcmp (filename
, info
->lineno_filename
) != 0)
6150 if (strcmp (info
->filename
, info
->lineno_filename
) != 0)
6152 /* We were not in the main file. Close the block for the
6154 if (! ieee_write_byte (info
, (int) ieee_be_record_enum
))
6157 if (strcmp (info
->filename
, filename
) != 0)
6159 /* We are not changing to the main file. Open a block for
6160 the new included file. */
6161 if (! ieee_write_byte (info
, (int) ieee_bb_record_enum
)
6162 || ! ieee_write_byte (info
, 5)
6163 || ! ieee_write_number (info
, 0)
6164 || ! ieee_write_id (info
, filename
))
6167 info
->lineno_filename
= filename
;
6170 return (ieee_write_2bytes (info
, (int) ieee_atn_record_enum
)
6171 && ieee_write_number (info
, info
->lineno_name_indx
)
6172 && ieee_write_number (info
, 0)
6173 && ieee_write_number (info
, 7)
6174 && ieee_write_number (info
, lineno
)
6175 && ieee_write_number (info
, 0)
6176 && ieee_write_asn (info
, info
->lineno_name_indx
, addr
));