]>
Commit | Line | Data |
---|---|---|
37ba3390 | 1 | /* Output sdb-format symbol table information from GNU compiler. |
21abd7a6 | 2 | Copyright (C) 1988, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. |
37ba3390 RS |
3 | |
4 | This file is part of GNU CC. | |
5 | ||
6 | GNU CC is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GNU CC is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU CC; see the file COPYING. If not, write to | |
e9fa0c7c RK |
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. */ | |
37ba3390 RS |
20 | |
21 | /* mike@tredysvr.Tredydev.Unisys.COM says: | |
22 | I modified the struct.c example and have a nm of a .o resulting from the | |
23 | AT&T C compiler. From the example below I would conclude the following: | |
24 | ||
25 | 1. All .defs from structures are emitted as scanned. The example below | |
26 | clearly shows the symbol table entries for BoxRec2 are after the first | |
27 | function. | |
28 | ||
29 | 2. All functions and their locals (including statics) are emitted as scanned. | |
30 | ||
31 | 3. All nested unnamed union and structure .defs must be emitted before | |
32 | the structure in which they are nested. The AT&T assembler is a | |
33 | one pass beast as far as symbolics are concerned. | |
34 | ||
35 | 4. All structure .defs are emitted before the typedefs that refer to them. | |
36 | ||
37 | 5. All top level static and external variable definitions are moved to the | |
6dc42e49 | 38 | end of file with all top level statics occurring first before externs. |
37ba3390 RS |
39 | |
40 | 6. All undefined references are at the end of the file. | |
41 | */ | |
42 | ||
43 | #include "config.h" | |
44 | ||
45 | #ifdef SDB_DEBUGGING_INFO | |
46 | ||
47 | #include "tree.h" | |
48 | #include "rtl.h" | |
49 | #include <stdio.h> | |
50 | #include "regs.h" | |
51 | #include "flags.h" | |
52 | #include "insn-config.h" | |
53 | #include "reload.h" | |
54 | ||
64c6526a JW |
55 | /* Mips systems use the SDB functions to dump out symbols, but do not |
56 | supply usable syms.h include files. Which syms.h file to use is a | |
57 | target parameter so don't use the native one if we're cross compiling. */ | |
58 | ||
59 | #if defined(USG) && !defined(MIPS) && !defined (hpux) && !defined(_WIN32) && !defined(__linux__) && !defined(CROSS_COMPILE) | |
37ba3390 RS |
60 | #include <syms.h> |
61 | /* Use T_INT if we don't have T_VOID. */ | |
62 | #ifndef T_VOID | |
63 | #define T_VOID T_INT | |
64 | #endif | |
64c6526a | 65 | #else |
37ba3390 | 66 | #include "gsyms.h" |
64c6526a | 67 | #endif |
37ba3390 RS |
68 | |
69 | /* #include <storclass.h> used to be this instead of syms.h. */ | |
70 | ||
71 | /* 1 if PARM is passed to this function in memory. */ | |
72 | ||
73 | #define PARM_PASSED_IN_MEMORY(PARM) \ | |
74 | (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM) | |
75 | ||
76 | /* A C expression for the integer offset value of an automatic variable | |
77 | (C_AUTO) having address X (an RTX). */ | |
78 | #ifndef DEBUGGER_AUTO_OFFSET | |
79 | #define DEBUGGER_AUTO_OFFSET(X) \ | |
80 | (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) | |
81 | #endif | |
82 | ||
83 | /* A C expression for the integer offset value of an argument (C_ARG) | |
84 | having address X (an RTX). The nominal offset is OFFSET. */ | |
85 | #ifndef DEBUGGER_ARG_OFFSET | |
86 | #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET) | |
87 | #endif | |
88 | ||
89 | /* Line number of beginning of current function, minus one. | |
90 | Negative means not in a function or not using sdb. */ | |
91 | ||
92 | int sdb_begin_function_line = -1; | |
93 | ||
94 | /* Counter to generate unique "names" for nameless struct members. */ | |
95 | ||
96 | static int unnamed_struct_number = 0; | |
97 | ||
98 | extern FILE *asm_out_file; | |
99 | ||
100 | extern tree current_function_decl; | |
101 | ||
102 | void sdbout_init (); | |
103 | void sdbout_symbol (); | |
104 | void sdbout_types(); | |
105 | ||
21abd7a6 RK |
106 | static char *gen_fake_label PROTO((void)); |
107 | static int plain_type PROTO((tree)); | |
108 | static int template_name_p PROTO((tree)); | |
109 | static void sdbout_record_type_name PROTO((tree)); | |
110 | static int plain_type_1 PROTO((tree, int)); | |
111 | static void sdbout_block PROTO((tree)); | |
112 | static void sdbout_syms PROTO((tree)); | |
113 | static void sdbout_queue_anonymous_type PROTO((tree)); | |
114 | static void sdbout_dequeue_anonymous_types PROTO((void)); | |
115 | static void sdbout_type PROTO((tree)); | |
116 | static void sbdout_field_types PROTO((tree)); | |
117 | static void sdbout_one_type PROTO((tree)); | |
118 | static void sdbout_parms PROTO((tree)); | |
119 | static void sdbout_reg_parms PROTO((tree)); | |
37ba3390 RS |
120 | \f |
121 | /* Define the default sizes for various types. */ | |
122 | ||
123 | #ifndef CHAR_TYPE_SIZE | |
124 | #define CHAR_TYPE_SIZE BITS_PER_UNIT | |
125 | #endif | |
126 | ||
127 | #ifndef SHORT_TYPE_SIZE | |
128 | #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2)) | |
129 | #endif | |
130 | ||
131 | #ifndef INT_TYPE_SIZE | |
132 | #define INT_TYPE_SIZE BITS_PER_WORD | |
133 | #endif | |
134 | ||
135 | #ifndef LONG_TYPE_SIZE | |
136 | #define LONG_TYPE_SIZE BITS_PER_WORD | |
137 | #endif | |
138 | ||
139 | #ifndef LONG_LONG_TYPE_SIZE | |
140 | #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2) | |
141 | #endif | |
142 | ||
143 | #ifndef FLOAT_TYPE_SIZE | |
144 | #define FLOAT_TYPE_SIZE BITS_PER_WORD | |
145 | #endif | |
146 | ||
147 | #ifndef DOUBLE_TYPE_SIZE | |
148 | #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) | |
149 | #endif | |
150 | ||
151 | #ifndef LONG_DOUBLE_TYPE_SIZE | |
152 | #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) | |
153 | #endif | |
154 | \f | |
155 | /* Random macros describing parts of SDB data. */ | |
156 | ||
157 | /* Put something here if lines get too long */ | |
158 | #define CONTIN | |
159 | ||
160 | /* Default value of delimiter is ";". */ | |
161 | #ifndef SDB_DELIM | |
162 | #define SDB_DELIM ";" | |
163 | #endif | |
164 | ||
165 | /* Maximum number of dimensions the assembler will allow. */ | |
166 | #ifndef SDB_MAX_DIM | |
167 | #define SDB_MAX_DIM 4 | |
168 | #endif | |
169 | ||
170 | #ifndef PUT_SDB_SCL | |
171 | #define PUT_SDB_SCL(a) fprintf(asm_out_file, "\t.scl\t%d%s", (a), SDB_DELIM) | |
172 | #endif | |
173 | ||
174 | #ifndef PUT_SDB_INT_VAL | |
175 | #define PUT_SDB_INT_VAL(a) fprintf (asm_out_file, "\t.val\t%d%s", (a), SDB_DELIM) | |
176 | #endif | |
177 | ||
178 | #ifndef PUT_SDB_VAL | |
179 | #define PUT_SDB_VAL(a) \ | |
180 | ( fputs ("\t.val\t", asm_out_file), \ | |
181 | output_addr_const (asm_out_file, (a)), \ | |
182 | fprintf (asm_out_file, SDB_DELIM)) | |
183 | #endif | |
184 | ||
185 | #ifndef PUT_SDB_DEF | |
186 | #define PUT_SDB_DEF(a) \ | |
187 | do { fprintf (asm_out_file, "\t.def\t"); \ | |
188 | ASM_OUTPUT_LABELREF (asm_out_file, a); \ | |
189 | fprintf (asm_out_file, SDB_DELIM); } while (0) | |
190 | #endif | |
191 | ||
192 | #ifndef PUT_SDB_PLAIN_DEF | |
193 | #define PUT_SDB_PLAIN_DEF(a) fprintf(asm_out_file,"\t.def\t.%s%s",a, SDB_DELIM) | |
194 | #endif | |
195 | ||
196 | #ifndef PUT_SDB_ENDEF | |
197 | #define PUT_SDB_ENDEF fputs("\t.endef\n", asm_out_file) | |
198 | #endif | |
199 | ||
200 | #ifndef PUT_SDB_TYPE | |
201 | #define PUT_SDB_TYPE(a) fprintf(asm_out_file, "\t.type\t0%o%s", a, SDB_DELIM) | |
202 | #endif | |
203 | ||
204 | #ifndef PUT_SDB_SIZE | |
205 | #define PUT_SDB_SIZE(a) fprintf(asm_out_file, "\t.size\t%d%s", a, SDB_DELIM) | |
206 | #endif | |
207 | ||
208 | #ifndef PUT_SDB_START_DIM | |
209 | #define PUT_SDB_START_DIM fprintf(asm_out_file, "\t.dim\t") | |
210 | #endif | |
211 | ||
212 | #ifndef PUT_SDB_NEXT_DIM | |
213 | #define PUT_SDB_NEXT_DIM(a) fprintf(asm_out_file, "%d,", a) | |
214 | #endif | |
215 | ||
216 | #ifndef PUT_SDB_LAST_DIM | |
217 | #define PUT_SDB_LAST_DIM(a) fprintf(asm_out_file, "%d%s", a, SDB_DELIM) | |
218 | #endif | |
219 | ||
220 | #ifndef PUT_SDB_TAG | |
221 | #define PUT_SDB_TAG(a) \ | |
222 | do { fprintf (asm_out_file, "\t.tag\t"); \ | |
223 | ASM_OUTPUT_LABELREF (asm_out_file, a); \ | |
224 | fprintf (asm_out_file, SDB_DELIM); } while (0) | |
225 | #endif | |
226 | ||
227 | #ifndef PUT_SDB_BLOCK_START | |
228 | #define PUT_SDB_BLOCK_START(LINE) \ | |
229 | fprintf (asm_out_file, \ | |
230 | "\t.def\t.bb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \ | |
231 | SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM) | |
232 | #endif | |
233 | ||
234 | #ifndef PUT_SDB_BLOCK_END | |
235 | #define PUT_SDB_BLOCK_END(LINE) \ | |
236 | fprintf (asm_out_file, \ | |
237 | "\t.def\t.eb%s\t.val\t.%s\t.scl\t100%s\t.line\t%d%s\t.endef\n", \ | |
238 | SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM) | |
239 | #endif | |
240 | ||
241 | #ifndef PUT_SDB_FUNCTION_START | |
242 | #define PUT_SDB_FUNCTION_START(LINE) \ | |
243 | fprintf (asm_out_file, \ | |
244 | "\t.def\t.bf%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \ | |
245 | SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM) | |
246 | #endif | |
247 | ||
248 | #ifndef PUT_SDB_FUNCTION_END | |
249 | #define PUT_SDB_FUNCTION_END(LINE) \ | |
250 | fprintf (asm_out_file, \ | |
251 | "\t.def\t.ef%s\t.val\t.%s\t.scl\t101%s\t.line\t%d%s\t.endef\n", \ | |
252 | SDB_DELIM, SDB_DELIM, SDB_DELIM, (LINE), SDB_DELIM) | |
253 | #endif | |
254 | ||
255 | #ifndef PUT_SDB_EPILOGUE_END | |
256 | #define PUT_SDB_EPILOGUE_END(NAME) \ | |
257 | do { fprintf (asm_out_file, "\t.def\t"); \ | |
258 | ASM_OUTPUT_LABELREF (asm_out_file, NAME); \ | |
259 | fprintf (asm_out_file, \ | |
260 | "%s\t.val\t.%s\t.scl\t-1%s\t.endef\n", \ | |
261 | SDB_DELIM, SDB_DELIM, SDB_DELIM); } while (0) | |
262 | #endif | |
263 | ||
264 | #ifndef SDB_GENERATE_FAKE | |
265 | #define SDB_GENERATE_FAKE(BUFFER, NUMBER) \ | |
266 | sprintf ((BUFFER), ".%dfake", (NUMBER)); | |
267 | #endif | |
268 | ||
269 | /* Return the sdb tag identifier string for TYPE | |
270 | if TYPE has already been defined; otherwise return a null pointer. */ | |
271 | ||
6fb2e346 | 272 | #define KNOWN_TYPE_TAG(type) TYPE_SYMTAB_POINTER (type) |
37ba3390 RS |
273 | |
274 | /* Set the sdb tag identifier string for TYPE to NAME. */ | |
275 | ||
276 | #define SET_KNOWN_TYPE_TAG(TYPE, NAME) \ | |
6fb2e346 | 277 | TYPE_SYMTAB_POINTER (TYPE) = (NAME) |
37ba3390 RS |
278 | |
279 | /* Return the name (a string) of the struct, union or enum tag | |
280 | described by the TREE_LIST node LINK. This is 0 for an anonymous one. */ | |
281 | ||
282 | #define TAG_NAME(link) \ | |
283 | (((link) && TREE_PURPOSE ((link)) \ | |
284 | && IDENTIFIER_POINTER (TREE_PURPOSE ((link)))) \ | |
285 | ? IDENTIFIER_POINTER (TREE_PURPOSE ((link))) : (char *) 0) | |
286 | ||
287 | /* Ensure we don't output a negative line number. */ | |
288 | #define MAKE_LINE_SAFE(line) \ | |
289 | if (line <= sdb_begin_function_line) line = sdb_begin_function_line + 1 | |
290 | \f | |
291 | /* Set up for SDB output at the start of compilation. */ | |
292 | ||
293 | void | |
294 | sdbout_init (asm_file, input_file_name, syms) | |
295 | FILE *asm_file; | |
296 | char *input_file_name; | |
297 | tree syms; | |
298 | { | |
18205693 RS |
299 | #ifdef RMS_QUICK_HACK_1 |
300 | tree t; | |
301 | for (t = syms; t; t = TREE_CHAIN (t)) | |
302 | if (DECL_NAME (t) && IDENTIFIER_POINTER (DECL_NAME (t)) != 0 | |
303 | && !strcmp (IDENTIFIER_POINTER (DECL_NAME (t)), "__vtbl_ptr_type")) | |
304 | sdbout_symbol (t, 0); | |
305 | #endif | |
37ba3390 RS |
306 | } |
307 | ||
308 | #if 0 | |
309 | ||
310 | /* return the tag identifier for type | |
311 | */ | |
312 | ||
313 | char * | |
314 | tag_of_ru_type (type,link) | |
315 | tree type,link; | |
316 | { | |
317 | if (TYPE_SYMTAB_ADDRESS (type)) | |
6fb2e346 | 318 | return TYPE_SYMTAB_ADDRESS (type); |
37ba3390 RS |
319 | if (link && TREE_PURPOSE (link) |
320 | && IDENTIFIER_POINTER (TREE_PURPOSE (link))) | |
6fb2e346 | 321 | TYPE_SYMTAB_ADDRESS (type) = IDENTIFIER_POINTER (TREE_PURPOSE (link)); |
37ba3390 RS |
322 | else |
323 | return (char *) TYPE_SYMTAB_ADDRESS (type); | |
324 | } | |
325 | #endif | |
326 | ||
327 | /* Return a unique string to name an anonymous type. */ | |
328 | ||
329 | static char * | |
330 | gen_fake_label () | |
331 | { | |
332 | char label[10]; | |
333 | char *labelstr; | |
334 | SDB_GENERATE_FAKE (label, unnamed_struct_number); | |
335 | unnamed_struct_number++; | |
336 | labelstr = (char *) permalloc (strlen (label) + 1); | |
337 | strcpy (labelstr, label); | |
338 | return labelstr; | |
339 | } | |
340 | \f | |
341 | /* Return the number which describes TYPE for SDB. | |
342 | For pointers, etc., this function is recursive. | |
343 | Each record, union or enumeral type must already have had a | |
344 | tag number output. */ | |
345 | ||
346 | /* The number is given by d6d5d4d3d2d1bbbb | |
347 | where bbbb is 4 bit basic type, and di indicate one of notype,ptr,fn,array. | |
348 | Thus, char *foo () has bbbb=T_CHAR | |
349 | d1=D_FCN | |
350 | d2=D_PTR | |
351 | N_BTMASK= 017 1111 basic type field. | |
352 | N_TSHIFT= 2 derived type shift | |
353 | N_BTSHFT= 4 Basic type shift */ | |
354 | ||
355 | /* Produce the number that describes a pointer, function or array type. | |
356 | PREV is the number describing the target, value or element type. | |
357 | DT_type describes how to transform that type. */ | |
aa7a5913 RS |
358 | #define PUSH_DERIVED_LEVEL(DT_type,PREV) \ |
359 | ((((PREV) & ~(int)N_BTMASK) << (int)N_TSHIFT) \ | |
360 | | ((int)DT_type << (int)N_BTSHFT) \ | |
361 | | ((PREV) & (int)N_BTMASK)) | |
37ba3390 RS |
362 | |
363 | /* Number of elements used in sdb_dims. */ | |
364 | static int sdb_n_dims = 0; | |
365 | ||
366 | /* Table of array dimensions of current type. */ | |
367 | static int sdb_dims[SDB_MAX_DIM]; | |
368 | ||
369 | /* Size of outermost array currently being processed. */ | |
370 | static int sdb_type_size = -1; | |
371 | ||
372 | static int | |
373 | plain_type (type) | |
374 | tree type; | |
375 | { | |
1a625283 | 376 | int val = plain_type_1 (type, 0); |
37ba3390 RS |
377 | |
378 | /* If we have already saved up some array dimensions, print them now. */ | |
379 | if (sdb_n_dims > 0) | |
380 | { | |
381 | int i; | |
382 | PUT_SDB_START_DIM; | |
383 | for (i = sdb_n_dims - 1; i > 0; i--) | |
384 | PUT_SDB_NEXT_DIM (sdb_dims[i]); | |
385 | PUT_SDB_LAST_DIM (sdb_dims[0]); | |
386 | sdb_n_dims = 0; | |
387 | ||
388 | sdb_type_size = int_size_in_bytes (type); | |
389 | /* Don't kill sdb if type is not laid out or has variable size. */ | |
390 | if (sdb_type_size < 0) | |
391 | sdb_type_size = 0; | |
392 | } | |
393 | /* If we have computed the size of an array containing this type, | |
394 | print it now. */ | |
395 | if (sdb_type_size >= 0) | |
396 | { | |
397 | PUT_SDB_SIZE (sdb_type_size); | |
398 | sdb_type_size = -1; | |
399 | } | |
400 | return val; | |
401 | } | |
402 | ||
4be2397b RS |
403 | static int |
404 | template_name_p (name) | |
405 | tree name; | |
406 | { | |
407 | register char *ptr = IDENTIFIER_POINTER (name); | |
408 | while (*ptr && *ptr != '<') | |
409 | ptr++; | |
410 | ||
411 | return *ptr != '\0'; | |
412 | } | |
413 | ||
37ba3390 RS |
414 | static void |
415 | sdbout_record_type_name (type) | |
416 | tree type; | |
417 | { | |
418 | char *name = 0; | |
419 | int no_name; | |
420 | ||
421 | if (KNOWN_TYPE_TAG (type)) | |
422 | return; | |
423 | ||
424 | if (TYPE_NAME (type) != 0) | |
425 | { | |
426 | tree t = 0; | |
427 | /* Find the IDENTIFIER_NODE for the type name. */ | |
428 | if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) | |
95b2ff8b | 429 | t = TYPE_NAME (type); |
12357e42 | 430 | else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL) |
37ba3390 RS |
431 | { |
432 | t = DECL_NAME (TYPE_NAME (type)); | |
4be2397b RS |
433 | /* The DECL_NAME for templates includes "<>", which breaks |
434 | most assemblers. Use its assembler name instead, which | |
435 | has been mangled into being safe. */ | |
436 | if (t && template_name_p (t)) | |
437 | t = DECL_ASSEMBLER_NAME (TYPE_NAME (type)); | |
37ba3390 | 438 | } |
37ba3390 RS |
439 | |
440 | /* Now get the name as a string, or invent one. */ | |
4be2397b | 441 | if (t != NULL_TREE) |
37ba3390 RS |
442 | name = IDENTIFIER_POINTER (t); |
443 | } | |
444 | ||
445 | no_name = (name == 0 || *name == 0); | |
446 | if (no_name) | |
447 | name = gen_fake_label (); | |
448 | ||
449 | SET_KNOWN_TYPE_TAG (type, name); | |
450 | #ifdef SDB_ALLOW_FORWARD_REFERENCES | |
451 | if (no_name) | |
452 | sdbout_queue_anonymous_type (type); | |
453 | #endif | |
454 | } | |
455 | ||
1a625283 JW |
456 | /* Return the .type value for type TYPE. |
457 | ||
458 | LEVEL indicates how many levels deep we have recursed into the type. | |
459 | The SDB debug format can only represent 6 derived levels of types. | |
460 | After that, we must output inaccurate debug info. We deliberately | |
461 | stop before the 7th level, so that ADA recursive types will not give an | |
462 | infinite loop. */ | |
463 | ||
37ba3390 | 464 | static int |
1a625283 | 465 | plain_type_1 (type, level) |
37ba3390 | 466 | tree type; |
1a625283 | 467 | int level; |
37ba3390 RS |
468 | { |
469 | if (type == 0) | |
470 | type = void_type_node; | |
1a625283 | 471 | else if (type == error_mark_node) |
37ba3390 | 472 | type = integer_type_node; |
1a625283 JW |
473 | else |
474 | type = TYPE_MAIN_VARIANT (type); | |
37ba3390 RS |
475 | |
476 | switch (TREE_CODE (type)) | |
477 | { | |
478 | case VOID_TYPE: | |
479 | return T_VOID; | |
480 | case INTEGER_TYPE: | |
481 | { | |
482 | int size = int_size_in_bytes (type) * BITS_PER_UNIT; | |
aed0ae9b JW |
483 | |
484 | /* Carefully distinguish all the standard types of C, | |
485 | without messing up if the language is not C. | |
486 | Note that we check only for the names that contain spaces; | |
487 | other names might occur by coincidence in other languages. */ | |
488 | if (TYPE_NAME (type) != 0 | |
489 | && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
490 | && DECL_NAME (TYPE_NAME (type)) != 0 | |
491 | && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) | |
492 | { | |
493 | char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); | |
494 | ||
495 | if (!strcmp (name, "unsigned char")) | |
496 | return T_UCHAR; | |
497 | if (!strcmp (name, "signed char")) | |
498 | return T_CHAR; | |
499 | if (!strcmp (name, "unsigned int")) | |
500 | return T_UINT; | |
501 | if (!strcmp (name, "short int")) | |
502 | return T_SHORT; | |
503 | if (!strcmp (name, "short unsigned int")) | |
504 | return T_USHORT; | |
505 | if (!strcmp (name, "long int")) | |
506 | return T_LONG; | |
507 | if (!strcmp (name, "long unsigned int")) | |
508 | return T_ULONG; | |
509 | } | |
510 | ||
37ba3390 RS |
511 | if (size == CHAR_TYPE_SIZE) |
512 | return (TREE_UNSIGNED (type) ? T_UCHAR : T_CHAR); | |
513 | if (size == SHORT_TYPE_SIZE) | |
514 | return (TREE_UNSIGNED (type) ? T_USHORT : T_SHORT); | |
515 | if (size == INT_TYPE_SIZE) | |
516 | return (TREE_UNSIGNED (type) ? T_UINT : T_INT); | |
580b8ee2 RS |
517 | if (size == LONG_TYPE_SIZE) |
518 | return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG); | |
7726fc45 RK |
519 | if (size == LONG_LONG_TYPE_SIZE) /* better than nothing */ |
520 | return (TREE_UNSIGNED (type) ? T_ULONG : T_LONG); | |
37ba3390 RS |
521 | return 0; |
522 | } | |
523 | ||
524 | case REAL_TYPE: | |
525 | { | |
64c6526a JW |
526 | int precision = TYPE_PRECISION (type); |
527 | if (precision == FLOAT_TYPE_SIZE) | |
37ba3390 | 528 | return T_FLOAT; |
64c6526a | 529 | if (precision == DOUBLE_TYPE_SIZE) |
37ba3390 | 530 | return T_DOUBLE; |
64c6526a JW |
531 | #ifdef EXTENDED_SDB_BASIC_TYPES |
532 | if (precision == LONG_DOUBLE_TYPE_SIZE) | |
533 | return T_LNGDBL; | |
534 | #endif | |
37ba3390 RS |
535 | return 0; |
536 | } | |
537 | ||
538 | case ARRAY_TYPE: | |
539 | { | |
540 | int m; | |
1a625283 JW |
541 | if (level >= 6) |
542 | return T_VOID; | |
543 | else | |
544 | m = plain_type_1 (TREE_TYPE (type), level+1); | |
37ba3390 RS |
545 | if (sdb_n_dims < SDB_MAX_DIM) |
546 | sdb_dims[sdb_n_dims++] | |
547 | = (TYPE_DOMAIN (type) | |
973d79ed RK |
548 | ? (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) |
549 | - TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1) | |
37ba3390 RS |
550 | : 0); |
551 | return PUSH_DERIVED_LEVEL (DT_ARY, m); | |
552 | } | |
553 | ||
554 | case RECORD_TYPE: | |
555 | case UNION_TYPE: | |
c1b98a95 | 556 | case QUAL_UNION_TYPE: |
37ba3390 RS |
557 | case ENUMERAL_TYPE: |
558 | { | |
559 | char *tag; | |
560 | #ifdef SDB_ALLOW_FORWARD_REFERENCES | |
561 | sdbout_record_type_name (type); | |
562 | #endif | |
563 | #ifndef SDB_ALLOW_UNKNOWN_REFERENCES | |
564 | if ((TREE_ASM_WRITTEN (type) && KNOWN_TYPE_TAG (type) != 0) | |
565 | #ifdef SDB_ALLOW_FORWARD_REFERENCES | |
566 | || TYPE_MODE (type) != VOIDmode | |
567 | #endif | |
568 | ) | |
569 | #endif | |
570 | { | |
571 | /* Output the referenced structure tag name | |
572 | only if the .def has already been finished. | |
573 | At least on 386, the Unix assembler | |
574 | cannot handle forward references to tags. */ | |
0f41302f MS |
575 | /* But the 88100, it requires them, sigh... */ |
576 | /* And the MIPS requires unknown refs as well... */ | |
37ba3390 RS |
577 | tag = KNOWN_TYPE_TAG (type); |
578 | PUT_SDB_TAG (tag); | |
579 | /* These 3 lines used to follow the close brace. | |
580 | However, a size of 0 without a tag implies a tag of 0, | |
581 | so if we don't know a tag, we can't mention the size. */ | |
582 | sdb_type_size = int_size_in_bytes (type); | |
583 | if (sdb_type_size < 0) | |
584 | sdb_type_size = 0; | |
585 | } | |
586 | return ((TREE_CODE (type) == RECORD_TYPE) ? T_STRUCT | |
587 | : (TREE_CODE (type) == UNION_TYPE) ? T_UNION | |
c1b98a95 | 588 | : (TREE_CODE (type) == QUAL_UNION_TYPE) ? T_UNION |
37ba3390 RS |
589 | : T_ENUM); |
590 | } | |
591 | case POINTER_TYPE: | |
592 | case REFERENCE_TYPE: | |
593 | { | |
1a625283 JW |
594 | int m; |
595 | if (level >= 6) | |
596 | return T_VOID; | |
597 | else | |
598 | m = plain_type_1 (TREE_TYPE (type), level+1); | |
37ba3390 RS |
599 | return PUSH_DERIVED_LEVEL (DT_PTR, m); |
600 | } | |
601 | case FUNCTION_TYPE: | |
602 | case METHOD_TYPE: | |
603 | { | |
1a625283 JW |
604 | int m; |
605 | if (level >= 6) | |
606 | return T_VOID; | |
607 | else | |
608 | m = plain_type_1 (TREE_TYPE (type), level+1); | |
37ba3390 RS |
609 | return PUSH_DERIVED_LEVEL (DT_FCN, m); |
610 | } | |
611 | default: | |
612 | return 0; | |
613 | } | |
614 | } | |
615 | \f | |
616 | /* Output the symbols defined in block number DO_BLOCK. | |
617 | Set NEXT_BLOCK_NUMBER to 0 before calling. | |
618 | ||
619 | This function works by walking the tree structure of blocks, | |
620 | counting blocks until it finds the desired block. */ | |
621 | ||
622 | static int do_block = 0; | |
623 | ||
624 | static int next_block_number; | |
625 | ||
626 | static void | |
627 | sdbout_block (block) | |
628 | register tree block; | |
629 | { | |
630 | while (block) | |
631 | { | |
632 | /* Ignore blocks never expanded or otherwise marked as real. */ | |
633 | if (TREE_USED (block)) | |
634 | { | |
635 | /* When we reach the specified block, output its symbols. */ | |
636 | if (next_block_number == do_block) | |
637 | { | |
638 | sdbout_syms (BLOCK_VARS (block)); | |
639 | } | |
640 | ||
641 | /* If we are past the specified block, stop the scan. */ | |
642 | if (next_block_number > do_block) | |
643 | return; | |
644 | ||
645 | next_block_number++; | |
646 | ||
647 | /* Scan the blocks within this block. */ | |
648 | sdbout_block (BLOCK_SUBBLOCKS (block)); | |
649 | } | |
650 | ||
651 | block = BLOCK_CHAIN (block); | |
652 | } | |
653 | } | |
654 | \f | |
655 | /* Call sdbout_symbol on each decl in the chain SYMS. */ | |
656 | ||
657 | static void | |
658 | sdbout_syms (syms) | |
659 | tree syms; | |
660 | { | |
661 | while (syms) | |
662 | { | |
5b7f1820 RS |
663 | if (TREE_CODE (syms) != LABEL_DECL) |
664 | sdbout_symbol (syms, 1); | |
37ba3390 RS |
665 | syms = TREE_CHAIN (syms); |
666 | } | |
667 | } | |
668 | ||
669 | /* Output SDB information for a symbol described by DECL. | |
670 | LOCAL is nonzero if the symbol is not file-scope. */ | |
671 | ||
672 | void | |
673 | sdbout_symbol (decl, local) | |
674 | tree decl; | |
675 | int local; | |
676 | { | |
37ba3390 RS |
677 | tree type = TREE_TYPE (decl); |
678 | tree context = NULL_TREE; | |
679 | rtx value; | |
680 | int regno = -1; | |
681 | char *name; | |
682 | ||
16d90796 RS |
683 | sdbout_one_type (type); |
684 | ||
685 | #if 0 /* This loses when functions are marked to be ignored, | |
686 | which happens in the C++ front end. */ | |
5e32e83b RS |
687 | if (DECL_IGNORED_P (decl)) |
688 | return; | |
16d90796 | 689 | #endif |
37ba3390 RS |
690 | |
691 | switch (TREE_CODE (decl)) | |
692 | { | |
693 | case CONST_DECL: | |
694 | /* Enum values are defined by defining the enum type. */ | |
695 | return; | |
696 | ||
697 | case FUNCTION_DECL: | |
698 | /* Don't mention a nested function under its parent. */ | |
699 | context = decl_function_context (decl); | |
700 | if (context == current_function_decl) | |
701 | return; | |
b01a1fdb JW |
702 | /* Check DECL_INITIAL to distinguish declarations from definitions. |
703 | Don't output debug info here for declarations; they will have | |
704 | a DECL_INITIAL value of 0. */ | |
705 | if (! DECL_INITIAL (decl)) | |
37ba3390 RS |
706 | return; |
707 | if (GET_CODE (DECL_RTL (decl)) != MEM | |
708 | || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) | |
709 | return; | |
710 | PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); | |
711 | PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0)); | |
712 | PUT_SDB_SCL (TREE_PUBLIC (decl) ? C_EXT : C_STAT); | |
713 | break; | |
714 | ||
715 | case TYPE_DECL: | |
716 | /* Done with tagged types. */ | |
717 | if (DECL_NAME (decl) == 0) | |
718 | return; | |
16d90796 RS |
719 | if (DECL_IGNORED_P (decl)) |
720 | return; | |
37ba3390 RS |
721 | |
722 | /* Output typedef name. */ | |
4be2397b RS |
723 | if (template_name_p (DECL_NAME (decl))) |
724 | PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); | |
725 | else | |
726 | PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_NAME (decl))); | |
37ba3390 RS |
727 | PUT_SDB_SCL (C_TPDEF); |
728 | break; | |
729 | ||
730 | case PARM_DECL: | |
731 | /* Parm decls go in their own separate chains | |
732 | and are output by sdbout_reg_parms and sdbout_parms. */ | |
733 | abort (); | |
734 | ||
735 | case VAR_DECL: | |
736 | /* Don't mention a variable that is external. | |
737 | Let the file that defines it describe it. */ | |
216d5cdd | 738 | if (DECL_EXTERNAL (decl)) |
37ba3390 RS |
739 | return; |
740 | ||
16d90796 RS |
741 | /* Ignore __FUNCTION__, etc. */ |
742 | if (DECL_IGNORED_P (decl)) | |
743 | return; | |
744 | ||
37ba3390 RS |
745 | /* If there was an error in the declaration, don't dump core |
746 | if there is no RTL associated with the variable doesn't | |
747 | exist. */ | |
748 | if (DECL_RTL (decl) == 0) | |
749 | return; | |
750 | ||
8c334b8d | 751 | DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX); |
bf1e8c4d RS |
752 | #ifdef LEAF_REG_REMAP |
753 | if (leaf_function) | |
754 | leaf_renumber_regs_insn (DECL_RTL (decl)); | |
755 | #endif | |
756 | value = DECL_RTL (decl); | |
37ba3390 RS |
757 | |
758 | /* Don't mention a variable at all | |
759 | if it was completely optimized into nothingness. | |
760 | ||
761 | If DECL was from an inline function, then its rtl | |
762 | is not identically the rtl that was used in this | |
763 | particular compilation. */ | |
764 | if (GET_CODE (value) == REG) | |
765 | { | |
766 | regno = REGNO (DECL_RTL (decl)); | |
767 | if (regno >= FIRST_PSEUDO_REGISTER) | |
37ba3390 RS |
768 | return; |
769 | } | |
bf1e8c4d | 770 | else if (GET_CODE (value) == SUBREG) |
37ba3390 RS |
771 | { |
772 | int offset = 0; | |
773 | while (GET_CODE (value) == SUBREG) | |
774 | { | |
775 | offset += SUBREG_WORD (value); | |
776 | value = SUBREG_REG (value); | |
777 | } | |
778 | if (GET_CODE (value) == REG) | |
779 | { | |
780 | regno = REGNO (value); | |
781 | if (regno >= FIRST_PSEUDO_REGISTER) | |
bf1e8c4d RS |
782 | return; |
783 | regno += offset; | |
37ba3390 | 784 | } |
bf1e8c4d RS |
785 | alter_subreg (DECL_RTL (decl)); |
786 | value = DECL_RTL (decl); | |
37ba3390 | 787 | } |
39eae9f4 RS |
788 | /* Don't output anything if an auto variable |
789 | gets RTL that is static. | |
790 | GAS version 2.2 can't handle such output. */ | |
791 | else if (GET_CODE (value) == MEM && CONSTANT_P (XEXP (value, 0)) | |
792 | && ! TREE_STATIC (decl)) | |
793 | return; | |
37ba3390 RS |
794 | |
795 | /* Emit any structure, union, or enum type that has not been output. | |
796 | This occurs for tag-less structs (et al) used to declare variables | |
797 | within functions. */ | |
798 | if (TREE_CODE (type) == ENUMERAL_TYPE | |
799 | || TREE_CODE (type) == RECORD_TYPE | |
c1b98a95 RK |
800 | || TREE_CODE (type) == UNION_TYPE |
801 | || TREE_CODE (type) == QUAL_UNION_TYPE) | |
37ba3390 RS |
802 | { |
803 | if (TYPE_SIZE (type) != 0 /* not a forward reference */ | |
804 | && KNOWN_TYPE_TAG (type) == 0) /* not yet declared */ | |
805 | sdbout_one_type (type); | |
806 | } | |
807 | ||
808 | /* Defer SDB information for top-level initialized variables! */ | |
809 | if (! local | |
810 | && GET_CODE (value) == MEM | |
811 | && DECL_INITIAL (decl)) | |
812 | return; | |
813 | ||
ed5f8355 RS |
814 | /* C++ in 2.3 makes nameless symbols. That will be fixed later. |
815 | For now, avoid crashing. */ | |
816 | if (DECL_NAME (decl) == NULL_TREE) | |
817 | return; | |
818 | ||
37ba3390 | 819 | /* Record the name for, starting a symtab entry. */ |
95b2ff8b | 820 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); |
37ba3390 RS |
821 | |
822 | if (GET_CODE (value) == MEM | |
823 | && GET_CODE (XEXP (value, 0)) == SYMBOL_REF) | |
824 | { | |
825 | PUT_SDB_DEF (name); | |
826 | if (TREE_PUBLIC (decl)) | |
827 | { | |
828 | PUT_SDB_VAL (XEXP (value, 0)); | |
829 | PUT_SDB_SCL (C_EXT); | |
830 | } | |
831 | else | |
832 | { | |
833 | PUT_SDB_VAL (XEXP (value, 0)); | |
834 | PUT_SDB_SCL (C_STAT); | |
835 | } | |
836 | } | |
837 | else if (regno >= 0) | |
838 | { | |
839 | PUT_SDB_DEF (name); | |
840 | PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (regno)); | |
841 | PUT_SDB_SCL (C_REG); | |
842 | } | |
843 | else if (GET_CODE (value) == MEM | |
844 | && (GET_CODE (XEXP (value, 0)) == MEM | |
845 | || (GET_CODE (XEXP (value, 0)) == REG | |
d8a0edf4 | 846 | && REGNO (XEXP (value, 0)) != HARD_FRAME_POINTER_REGNUM |
5b7f1820 | 847 | && REGNO (XEXP (value, 0)) != STACK_POINTER_REGNUM))) |
37ba3390 RS |
848 | /* If the value is indirect by memory or by a register |
849 | that isn't the frame pointer | |
850 | then it means the object is variable-sized and address through | |
851 | that register or stack slot. COFF has no way to represent this | |
852 | so all we can do is output the variable as a pointer. */ | |
853 | { | |
854 | PUT_SDB_DEF (name); | |
855 | if (GET_CODE (XEXP (value, 0)) == REG) | |
856 | { | |
857 | PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (XEXP (value, 0)))); | |
858 | PUT_SDB_SCL (C_REG); | |
859 | } | |
860 | else | |
861 | { | |
862 | /* DECL_RTL looks like (MEM (MEM (PLUS (REG...) | |
863 | (CONST_INT...)))). | |
864 | We want the value of that CONST_INT. */ | |
865 | /* Encore compiler hates a newline in a macro arg, it seems. */ | |
866 | PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET | |
867 | (XEXP (XEXP (value, 0), 0))); | |
868 | PUT_SDB_SCL (C_AUTO); | |
869 | } | |
870 | ||
871 | type = build_pointer_type (TREE_TYPE (decl)); | |
872 | } | |
873 | else if (GET_CODE (value) == MEM | |
6d55e0ab JW |
874 | && ((GET_CODE (XEXP (value, 0)) == PLUS |
875 | && GET_CODE (XEXP (XEXP (value, 0), 0)) == REG | |
876 | && GET_CODE (XEXP (XEXP (value, 0), 1)) == CONST_INT) | |
877 | /* This is for variables which are at offset zero from | |
878 | the frame pointer. This happens on the Alpha. | |
879 | Non-frame pointer registers are excluded above. */ | |
880 | || (GET_CODE (XEXP (value, 0)) == REG))) | |
37ba3390 | 881 | { |
6d55e0ab JW |
882 | /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))) |
883 | or (MEM (REG...)). We want the value of that CONST_INT | |
884 | or zero. */ | |
37ba3390 RS |
885 | PUT_SDB_DEF (name); |
886 | PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET (XEXP (value, 0))); | |
887 | PUT_SDB_SCL (C_AUTO); | |
888 | } | |
5b7f1820 RS |
889 | else if (GET_CODE (value) == MEM && GET_CODE (XEXP (value, 0)) == CONST) |
890 | { | |
891 | /* Handle an obscure case which can arise when optimizing and | |
892 | when there are few available registers. (This is *always* | |
893 | the case for i386/i486 targets). The DECL_RTL looks like | |
894 | (MEM (CONST ...)) even though this variable is a local `auto' | |
895 | or a local `register' variable. In effect, what has happened | |
896 | is that the reload pass has seen that all assignments and | |
897 | references for one such a local variable can be replaced by | |
898 | equivalent assignments and references to some static storage | |
899 | variable, thereby avoiding the need for a register. In such | |
900 | cases we're forced to lie to debuggers and tell them that | |
901 | this variable was itself `static'. */ | |
902 | PUT_SDB_DEF (name); | |
903 | PUT_SDB_VAL (XEXP (XEXP (value, 0), 0)); | |
904 | PUT_SDB_SCL (C_STAT); | |
905 | } | |
37ba3390 RS |
906 | else |
907 | { | |
908 | /* It is something we don't know how to represent for SDB. */ | |
909 | return; | |
910 | } | |
911 | break; | |
912 | } | |
913 | PUT_SDB_TYPE (plain_type (type)); | |
914 | PUT_SDB_ENDEF; | |
915 | } | |
916 | \f | |
917 | /* Output SDB information for a top-level initialized variable | |
918 | that has been delayed. */ | |
919 | ||
920 | void | |
921 | sdbout_toplevel_data (decl) | |
922 | tree decl; | |
923 | { | |
924 | tree type = TREE_TYPE (decl); | |
925 | ||
5e32e83b RS |
926 | if (DECL_IGNORED_P (decl)) |
927 | return; | |
928 | ||
37ba3390 RS |
929 | if (! (TREE_CODE (decl) == VAR_DECL |
930 | && GET_CODE (DECL_RTL (decl)) == MEM | |
931 | && DECL_INITIAL (decl))) | |
932 | abort (); | |
933 | ||
934 | PUT_SDB_DEF (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); | |
935 | PUT_SDB_VAL (XEXP (DECL_RTL (decl), 0)); | |
936 | if (TREE_PUBLIC (decl)) | |
937 | { | |
938 | PUT_SDB_SCL (C_EXT); | |
939 | } | |
940 | else | |
941 | { | |
942 | PUT_SDB_SCL (C_STAT); | |
943 | } | |
944 | PUT_SDB_TYPE (plain_type (type)); | |
945 | PUT_SDB_ENDEF; | |
946 | } | |
947 | \f | |
948 | #ifdef SDB_ALLOW_FORWARD_REFERENCES | |
949 | ||
0f41302f | 950 | /* Machinery to record and output anonymous types. */ |
37ba3390 RS |
951 | |
952 | static tree anonymous_types; | |
953 | ||
954 | static void | |
955 | sdbout_queue_anonymous_type (type) | |
956 | tree type; | |
957 | { | |
958 | anonymous_types = saveable_tree_cons (NULL_TREE, type, anonymous_types); | |
959 | } | |
960 | ||
961 | static void | |
962 | sdbout_dequeue_anonymous_types () | |
963 | { | |
964 | register tree types, link; | |
965 | ||
966 | while (anonymous_types) | |
967 | { | |
968 | types = nreverse (anonymous_types); | |
969 | anonymous_types = NULL_TREE; | |
970 | ||
971 | for (link = types; link; link = TREE_CHAIN (link)) | |
972 | { | |
973 | register tree type = TREE_VALUE (link); | |
974 | ||
c325abbd | 975 | if (type && ! TREE_ASM_WRITTEN (type)) |
37ba3390 RS |
976 | sdbout_one_type (type); |
977 | } | |
978 | } | |
979 | } | |
980 | ||
981 | #endif | |
982 | \f | |
983 | /* Given a chain of ..._TYPE nodes, all of which have names, | |
984 | output definitions of those names, as typedefs. */ | |
985 | ||
986 | void | |
987 | sdbout_types (types) | |
988 | register tree types; | |
989 | { | |
990 | register tree link; | |
991 | ||
992 | for (link = types; link; link = TREE_CHAIN (link)) | |
993 | sdbout_one_type (link); | |
994 | ||
995 | #ifdef SDB_ALLOW_FORWARD_REFERENCES | |
996 | sdbout_dequeue_anonymous_types (); | |
997 | #endif | |
998 | } | |
999 | ||
1000 | static void | |
1001 | sdbout_type (type) | |
1002 | tree type; | |
1003 | { | |
37ba3390 RS |
1004 | if (type == error_mark_node) |
1005 | type = integer_type_node; | |
1006 | PUT_SDB_TYPE (plain_type (type)); | |
1007 | } | |
1008 | ||
1009 | /* Output types of the fields of type TYPE, if they are structs. | |
1010 | ||
1011 | Formerly did not chase through pointer types, since that could be circular. | |
1012 | They must come before TYPE, since forward refs are not allowed. | |
1013 | Now james@bigtex.cactus.org says to try them. */ | |
1014 | ||
1015 | static void | |
1016 | sdbout_field_types (type) | |
1017 | tree type; | |
1018 | { | |
1019 | tree tail; | |
1020 | for (tail = TYPE_FIELDS (type); tail; tail = TREE_CHAIN (tail)) | |
1021 | if (TREE_CODE (TREE_TYPE (tail)) == POINTER_TYPE) | |
1022 | sdbout_one_type (TREE_TYPE (TREE_TYPE (tail))); | |
1023 | else | |
1024 | sdbout_one_type (TREE_TYPE (tail)); | |
1025 | } | |
1026 | ||
1027 | /* Use this to put out the top level defined record and union types | |
1028 | for later reference. If this is a struct with a name, then put that | |
1029 | name out. Other unnamed structs will have .xxfake labels generated so | |
1030 | that they may be referred to later. | |
1031 | The label will be stored in the KNOWN_TYPE_TAG slot of a type. | |
1032 | It may NOT be called recursively. */ | |
1033 | ||
1034 | static void | |
1035 | sdbout_one_type (type) | |
1036 | tree type; | |
1037 | { | |
509b12e0 JW |
1038 | if (current_function_decl != NULL_TREE |
1039 | && DECL_SECTION_NAME (current_function_decl) != NULL_TREE) | |
1040 | ; /* Don't change section amid function. */ | |
1041 | else | |
1042 | text_section (); | |
37ba3390 RS |
1043 | |
1044 | switch (TREE_CODE (type)) | |
1045 | { | |
1046 | case RECORD_TYPE: | |
1047 | case UNION_TYPE: | |
c1b98a95 | 1048 | case QUAL_UNION_TYPE: |
37ba3390 RS |
1049 | case ENUMERAL_TYPE: |
1050 | type = TYPE_MAIN_VARIANT (type); | |
1051 | /* Don't output a type twice. */ | |
1052 | if (TREE_ASM_WRITTEN (type)) | |
1053 | /* James said test TREE_ASM_BEING_WRITTEN here. */ | |
1054 | return; | |
1055 | ||
1056 | /* Output nothing if type is not yet defined. */ | |
1057 | if (TYPE_SIZE (type) == 0) | |
1058 | return; | |
1059 | ||
1060 | TREE_ASM_WRITTEN (type) = 1; | |
1061 | #if 1 | |
1062 | /* This is reputed to cause trouble with the following case, | |
638e2294 | 1063 | but perhaps checking TYPE_SIZE above will fix it. */ |
37ba3390 RS |
1064 | |
1065 | /* Here is a test case: | |
1066 | ||
1067 | struct foo { | |
1068 | struct badstr *bbb; | |
1069 | } forwardref; | |
1070 | ||
1071 | typedef struct intermediate { | |
1072 | int aaaa; | |
1073 | } intermediate_ref; | |
1074 | ||
1075 | typedef struct badstr { | |
1076 | int ccccc; | |
1077 | } badtype; */ | |
1078 | ||
1079 | #if 0 | |
1080 | TREE_ASM_BEING_WRITTEN (type) = 1; | |
1081 | #endif | |
1082 | /* This change, which ought to make better output, | |
1083 | used to make the COFF assembler unhappy. | |
1084 | Changes involving KNOWN_TYPE_TAG may fix the problem. */ | |
1085 | /* Before really doing anything, output types we want to refer to. */ | |
1086 | /* Note that in version 1 the following two lines | |
1087 | are not used if forward references are in use. */ | |
1088 | if (TREE_CODE (type) != ENUMERAL_TYPE) | |
1089 | sdbout_field_types (type); | |
1090 | #if 0 | |
1091 | TREE_ASM_WRITTEN (type) = 1; | |
1092 | #endif | |
1093 | #endif | |
1094 | ||
1095 | /* Output a structure type. */ | |
1096 | { | |
1097 | int size = int_size_in_bytes (type); | |
1098 | int member_scl; | |
1099 | tree tem; | |
5b7f1820 | 1100 | int i, n_baseclasses = 0; |
37ba3390 RS |
1101 | |
1102 | /* Record the type tag, but not in its permanent place just yet. */ | |
1103 | sdbout_record_type_name (type); | |
1104 | ||
1105 | PUT_SDB_DEF (KNOWN_TYPE_TAG (type)); | |
1106 | ||
1107 | switch (TREE_CODE (type)) | |
1108 | { | |
1109 | case UNION_TYPE: | |
c1b98a95 | 1110 | case QUAL_UNION_TYPE: |
37ba3390 RS |
1111 | PUT_SDB_SCL (C_UNTAG); |
1112 | PUT_SDB_TYPE (T_UNION); | |
1113 | member_scl = C_MOU; | |
1114 | break; | |
1115 | ||
1116 | case RECORD_TYPE: | |
1117 | PUT_SDB_SCL (C_STRTAG); | |
1118 | PUT_SDB_TYPE (T_STRUCT); | |
1119 | member_scl = C_MOS; | |
1120 | break; | |
1121 | ||
1122 | case ENUMERAL_TYPE: | |
1123 | PUT_SDB_SCL (C_ENTAG); | |
1124 | PUT_SDB_TYPE (T_ENUM); | |
1125 | member_scl = C_MOE; | |
1126 | break; | |
1127 | } | |
1128 | ||
1129 | PUT_SDB_SIZE (size); | |
1130 | PUT_SDB_ENDEF; | |
1131 | ||
5b7f1820 RS |
1132 | /* Print out the base class information with fields |
1133 | named after the types they hold. */ | |
1134 | if (TYPE_BINFO (type) | |
1135 | && TYPE_BINFO_BASETYPES (type)) | |
1136 | n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type)); | |
1137 | for (i = 0; i < n_baseclasses; i++) | |
1138 | { | |
1139 | tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i); | |
1140 | tree child_type = BINFO_TYPE (child); | |
1141 | tree child_type_name; | |
1142 | if (TYPE_NAME (child_type) == 0) | |
1143 | continue; | |
1144 | if (TREE_CODE (TYPE_NAME (child_type)) == IDENTIFIER_NODE) | |
1145 | child_type_name = TYPE_NAME (child_type); | |
1146 | else if (TREE_CODE (TYPE_NAME (child_type)) == TYPE_DECL) | |
ee3e2d3d JW |
1147 | { |
1148 | child_type_name = DECL_NAME (TYPE_NAME (child_type)); | |
1149 | if (child_type_name && template_name_p (child_type_name)) | |
1150 | child_type_name | |
1151 | = DECL_ASSEMBLER_NAME (TYPE_NAME (child_type)); | |
1152 | } | |
5b7f1820 RS |
1153 | else |
1154 | continue; | |
1155 | ||
1156 | CONTIN; | |
1157 | PUT_SDB_DEF (IDENTIFIER_POINTER (child_type_name)); | |
1158 | PUT_SDB_INT_VAL (TREE_INT_CST_LOW (BINFO_OFFSET (child))); | |
1159 | PUT_SDB_SCL (member_scl); | |
1160 | sdbout_type (BINFO_TYPE (child)); | |
1161 | PUT_SDB_ENDEF; | |
1162 | } | |
1163 | ||
37ba3390 RS |
1164 | /* output the individual fields */ |
1165 | ||
1166 | if (TREE_CODE (type) == ENUMERAL_TYPE) | |
1167 | for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) | |
1168 | { | |
1169 | PUT_SDB_DEF (IDENTIFIER_POINTER (TREE_PURPOSE (tem))); | |
1170 | PUT_SDB_INT_VAL (TREE_INT_CST_LOW (TREE_VALUE (tem))); | |
1171 | PUT_SDB_SCL (C_MOE); | |
1172 | PUT_SDB_TYPE (T_MOE); | |
1173 | PUT_SDB_ENDEF; | |
1174 | } | |
1175 | ||
1176 | else /* record or union type */ | |
1177 | for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) | |
1178 | /* Output the name, type, position (in bits), size (in bits) | |
1179 | of each field. */ | |
1180 | ||
1181 | /* Omit here the nameless fields that are used to skip bits. | |
1182 | Also omit fields with variable size or position. | |
1183 | Also omit non FIELD_DECL nodes that GNU C++ may put here. */ | |
1184 | if (TREE_CODE (tem) == FIELD_DECL | |
1185 | && DECL_NAME (tem) != 0 | |
1186 | && TREE_CODE (DECL_SIZE (tem)) == INTEGER_CST | |
1187 | && TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST) | |
1188 | { | |
0eb111c2 JW |
1189 | char *name; |
1190 | ||
37ba3390 | 1191 | CONTIN; |
95b2ff8b | 1192 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)); |
0eb111c2 | 1193 | PUT_SDB_DEF (name); |
37ba3390 RS |
1194 | if (DECL_BIT_FIELD_TYPE (tem)) |
1195 | { | |
1196 | PUT_SDB_INT_VAL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem))); | |
1197 | PUT_SDB_SCL (C_FIELD); | |
1198 | sdbout_type (DECL_BIT_FIELD_TYPE (tem)); | |
1199 | PUT_SDB_SIZE (TREE_INT_CST_LOW (DECL_SIZE (tem))); | |
1200 | } | |
1201 | else | |
1202 | { | |
1203 | PUT_SDB_INT_VAL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)) | |
1204 | / BITS_PER_UNIT); | |
1205 | PUT_SDB_SCL (member_scl); | |
1206 | sdbout_type (TREE_TYPE (tem)); | |
1207 | } | |
1208 | PUT_SDB_ENDEF; | |
1209 | } | |
1210 | /* output end of a structure,union, or enumeral definition */ | |
1211 | ||
1212 | PUT_SDB_PLAIN_DEF ("eos"); | |
1213 | PUT_SDB_INT_VAL (size); | |
1214 | PUT_SDB_SCL (C_EOS); | |
1215 | PUT_SDB_TAG (KNOWN_TYPE_TAG (type)); | |
1216 | PUT_SDB_SIZE (size); | |
1217 | PUT_SDB_ENDEF; | |
1218 | break; | |
1219 | } | |
1220 | } | |
1221 | } | |
1222 | \f | |
1223 | /* The following two functions output definitions of function parameters. | |
1224 | Each parameter gets a definition locating it in the parameter list. | |
1225 | Each parameter that is a register variable gets a second definition | |
1226 | locating it in the register. | |
1227 | ||
1228 | Printing or argument lists in gdb uses the definitions that | |
1229 | locate in the parameter list. But reference to the variable in | |
1230 | expressions uses preferentially the definition as a register. */ | |
1231 | ||
1232 | /* Output definitions, referring to storage in the parmlist, | |
1233 | of all the parms in PARMS, which is a chain of PARM_DECL nodes. */ | |
1234 | ||
1235 | static void | |
1236 | sdbout_parms (parms) | |
1237 | tree parms; | |
1238 | { | |
1239 | for (; parms; parms = TREE_CHAIN (parms)) | |
1240 | if (DECL_NAME (parms)) | |
1241 | { | |
1242 | int current_sym_value = 0; | |
1243 | char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); | |
1244 | ||
1245 | if (name == 0 || *name == 0) | |
1246 | name = gen_fake_label (); | |
1247 | ||
1248 | /* Perform any necessary register eliminations on the parameter's rtl, | |
1249 | so that the debugging output will be accurate. */ | |
1250 | DECL_INCOMING_RTL (parms) = | |
37366632 RK |
1251 | eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX); |
1252 | DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX); | |
37ba3390 RS |
1253 | |
1254 | if (PARM_PASSED_IN_MEMORY (parms)) | |
1255 | { | |
1256 | rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0); | |
1257 | tree type; | |
1258 | ||
1259 | /* ??? Here we assume that the parm address is indexed | |
1260 | off the frame pointer or arg pointer. | |
1261 | If that is not true, we produce meaningless results, | |
1262 | but do not crash. */ | |
1263 | if (GET_CODE (addr) == PLUS | |
1264 | && GET_CODE (XEXP (addr, 1)) == CONST_INT) | |
1265 | current_sym_value = INTVAL (XEXP (addr, 1)); | |
1266 | else | |
1267 | current_sym_value = 0; | |
1268 | ||
1269 | if (GET_CODE (DECL_RTL (parms)) == REG | |
1270 | && REGNO (DECL_RTL (parms)) >= 0 | |
1271 | && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) | |
1272 | type = DECL_ARG_TYPE (parms); | |
1273 | else | |
1274 | { | |
1275 | int original_sym_value = current_sym_value; | |
1276 | ||
1277 | /* This is the case where the parm is passed as an int or | |
1278 | double and it is converted to a char, short or float | |
1279 | and stored back in the parmlist. In this case, describe | |
1280 | the parm with the variable's declared type, and adjust | |
1281 | the address if the least significant bytes (which we are | |
1282 | using) are not the first ones. */ | |
f76b9db2 ILT |
1283 | if (BYTES_BIG_ENDIAN |
1284 | && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) | |
37ba3390 RS |
1285 | current_sym_value += |
1286 | (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) | |
1287 | - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); | |
f76b9db2 | 1288 | |
37ba3390 RS |
1289 | if (GET_CODE (DECL_RTL (parms)) == MEM |
1290 | && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS | |
1291 | && (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) | |
1292 | == CONST_INT) | |
1293 | && (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) | |
1294 | == current_sym_value)) | |
1295 | type = TREE_TYPE (parms); | |
1296 | else | |
1297 | { | |
1298 | current_sym_value = original_sym_value; | |
1299 | type = DECL_ARG_TYPE (parms); | |
1300 | } | |
1301 | } | |
1302 | ||
1303 | PUT_SDB_DEF (name); | |
1304 | PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value, addr)); | |
1305 | PUT_SDB_SCL (C_ARG); | |
1306 | PUT_SDB_TYPE (plain_type (type)); | |
1307 | PUT_SDB_ENDEF; | |
1308 | } | |
1309 | else if (GET_CODE (DECL_RTL (parms)) == REG) | |
1310 | { | |
1311 | rtx best_rtl; | |
1312 | /* Parm passed in registers and lives in registers or nowhere. */ | |
1313 | ||
1314 | /* If parm lives in a register, use that register; | |
1315 | pretend the parm was passed there. It would be more consistent | |
1316 | to describe the register where the parm was passed, | |
1317 | but in practice that register usually holds something else. */ | |
1318 | if (REGNO (DECL_RTL (parms)) >= 0 | |
1319 | && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) | |
1320 | best_rtl = DECL_RTL (parms); | |
1321 | /* If the parm lives nowhere, | |
1322 | use the register where it was passed. */ | |
1323 | else | |
1324 | best_rtl = DECL_INCOMING_RTL (parms); | |
1325 | ||
1326 | PUT_SDB_DEF (name); | |
1327 | PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (best_rtl))); | |
1328 | PUT_SDB_SCL (C_REGPARM); | |
21abd7a6 | 1329 | PUT_SDB_TYPE (plain_type (TREE_TYPE (parms))); |
37ba3390 RS |
1330 | PUT_SDB_ENDEF; |
1331 | } | |
1332 | else if (GET_CODE (DECL_RTL (parms)) == MEM | |
1333 | && XEXP (DECL_RTL (parms), 0) != const0_rtx) | |
1334 | { | |
1335 | /* Parm was passed in registers but lives on the stack. */ | |
1336 | ||
1337 | /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))), | |
1338 | in which case we want the value of that CONST_INT, | |
1339 | or (MEM (REG ...)) or (MEM (MEM ...)), | |
1340 | in which case we use a value of zero. */ | |
1341 | if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG | |
1342 | || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM) | |
1343 | current_sym_value = 0; | |
1344 | else | |
1345 | current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)); | |
1346 | ||
1347 | /* Again, this assumes the offset is based on the arg pointer. */ | |
1348 | PUT_SDB_DEF (name); | |
1349 | PUT_SDB_INT_VAL (DEBUGGER_ARG_OFFSET (current_sym_value, | |
1350 | XEXP (DECL_RTL (parms), 0))); | |
1351 | PUT_SDB_SCL (C_ARG); | |
21abd7a6 | 1352 | PUT_SDB_TYPE (plain_type (TREE_TYPE (parms))); |
37ba3390 RS |
1353 | PUT_SDB_ENDEF; |
1354 | } | |
1355 | } | |
1356 | } | |
1357 | ||
1358 | /* Output definitions for the places where parms live during the function, | |
1359 | when different from where they were passed, when the parms were passed | |
1360 | in memory. | |
1361 | ||
1362 | It is not useful to do this for parms passed in registers | |
1363 | that live during the function in different registers, because it is | |
1364 | impossible to look in the passed register for the passed value, | |
1365 | so we use the within-the-function register to begin with. | |
1366 | ||
1367 | PARMS is a chain of PARM_DECL nodes. */ | |
1368 | ||
1369 | static void | |
1370 | sdbout_reg_parms (parms) | |
1371 | tree parms; | |
1372 | { | |
1373 | for (; parms; parms = TREE_CHAIN (parms)) | |
1374 | if (DECL_NAME (parms)) | |
1375 | { | |
1376 | char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); | |
1377 | ||
1378 | /* Report parms that live in registers during the function | |
1379 | but were passed in memory. */ | |
1380 | if (GET_CODE (DECL_RTL (parms)) == REG | |
1381 | && REGNO (DECL_RTL (parms)) >= 0 | |
1382 | && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER | |
1383 | && PARM_PASSED_IN_MEMORY (parms)) | |
1384 | { | |
1385 | if (name == 0 || *name == 0) | |
1386 | name = gen_fake_label (); | |
1387 | PUT_SDB_DEF (name); | |
1388 | PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms)))); | |
1389 | PUT_SDB_SCL (C_REG); | |
21abd7a6 | 1390 | PUT_SDB_TYPE (plain_type (TREE_TYPE (parms))); |
37ba3390 RS |
1391 | PUT_SDB_ENDEF; |
1392 | } | |
1393 | /* Report parms that live in memory but not where they were passed. */ | |
1394 | else if (GET_CODE (DECL_RTL (parms)) == MEM | |
1395 | && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS | |
1396 | && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT | |
1397 | && PARM_PASSED_IN_MEMORY (parms) | |
1398 | && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms))) | |
1399 | { | |
1400 | #if 0 /* ??? It is not clear yet what should replace this. */ | |
1401 | int offset = DECL_OFFSET (parms) / BITS_PER_UNIT; | |
1402 | /* A parm declared char is really passed as an int, | |
1403 | so it occupies the least significant bytes. | |
1404 | On a big-endian machine those are not the low-numbered ones. */ | |
f76b9db2 ILT |
1405 | if (BYTES_BIG_ENDIAN |
1406 | && offset != -1 | |
1407 | && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) | |
37ba3390 RS |
1408 | offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) |
1409 | - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); | |
37ba3390 RS |
1410 | if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...} |
1411 | #endif | |
1412 | { | |
1413 | if (name == 0 || *name == 0) | |
1414 | name = gen_fake_label (); | |
1415 | PUT_SDB_DEF (name); | |
1416 | PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET | |
1417 | (XEXP (DECL_RTL (parms), 0))); | |
1418 | PUT_SDB_SCL (C_AUTO); | |
1419 | PUT_SDB_TYPE (plain_type (TREE_TYPE (parms))); | |
1420 | PUT_SDB_ENDEF; | |
1421 | } | |
1422 | } | |
1423 | } | |
1424 | } | |
1425 | \f | |
1426 | /* Describe the beginning of an internal block within a function. | |
1427 | Also output descriptions of variables defined in this block. | |
1428 | ||
1429 | N is the number of the block, by order of beginning, counting from 1, | |
1430 | and not counting the outermost (function top-level) block. | |
1431 | The blocks match the BLOCKs in DECL_INITIAL (current_function_decl), | |
1432 | if the count starts at 0 for the outermost one. */ | |
1433 | ||
1434 | void | |
1435 | sdbout_begin_block (file, line, n) | |
1436 | FILE *file; | |
1437 | int line; | |
1438 | int n; | |
1439 | { | |
1440 | tree decl = current_function_decl; | |
1441 | MAKE_LINE_SAFE (line); | |
9f27ca8b JW |
1442 | |
1443 | /* The SCO compiler does not emit a separate block for the function level | |
1444 | scope, so we avoid it here also. However, mips ECOFF compilers do emit | |
1445 | a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */ | |
1446 | #ifndef MIPS_DEBUGGING_INFO | |
1447 | if (n != 1) | |
1448 | #endif | |
1449 | PUT_SDB_BLOCK_START (line - sdb_begin_function_line); | |
1450 | ||
37ba3390 RS |
1451 | if (n == 1) |
1452 | { | |
1453 | /* Include the outermost BLOCK's variables in block 1. */ | |
1454 | next_block_number = 0; | |
1455 | do_block = 0; | |
1456 | sdbout_block (DECL_INITIAL (decl)); | |
1457 | } | |
1458 | /* If -g1, suppress all the internal symbols of functions | |
1459 | except for arguments. */ | |
1460 | if (debug_info_level != DINFO_LEVEL_TERSE) | |
1461 | { | |
1462 | next_block_number = 0; | |
1463 | do_block = n; | |
1464 | sdbout_block (DECL_INITIAL (decl)); | |
1465 | } | |
1466 | ||
1467 | #ifdef SDB_ALLOW_FORWARD_REFERENCES | |
1468 | sdbout_dequeue_anonymous_types (); | |
1469 | #endif | |
1470 | } | |
1471 | ||
1472 | /* Describe the end line-number of an internal block within a function. */ | |
1473 | ||
1474 | void | |
9f27ca8b | 1475 | sdbout_end_block (file, line, n) |
37ba3390 RS |
1476 | FILE *file; |
1477 | int line; | |
9f27ca8b | 1478 | int n; |
37ba3390 RS |
1479 | { |
1480 | MAKE_LINE_SAFE (line); | |
9f27ca8b JW |
1481 | |
1482 | /* The SCO compiler does not emit a separate block for the function level | |
1483 | scope, so we avoid it here also. However, mips ECOFF compilers do emit | |
1484 | a separate block, so we retain it when MIPS_DEBUGGING_INFO is defined. */ | |
1485 | #ifndef MIPS_DEBUGGING_INFO | |
1486 | if (n != 1) | |
1487 | #endif | |
37ba3390 RS |
1488 | PUT_SDB_BLOCK_END (line - sdb_begin_function_line); |
1489 | } | |
1490 | ||
1491 | /* Output sdb info for the current function name. | |
1492 | Called from assemble_start_function. */ | |
1493 | ||
1494 | void | |
1495 | sdbout_mark_begin_function () | |
1496 | { | |
1497 | sdbout_symbol (current_function_decl, 0); | |
1498 | } | |
1499 | ||
1500 | /* Called at beginning of function body (after prologue). | |
1501 | Record the function's starting line number, so we can output | |
1502 | relative line numbers for the other lines. | |
1503 | Describe beginning of outermost block. | |
1504 | Also describe the parameter list. */ | |
1505 | ||
1506 | void | |
1507 | sdbout_begin_function (line) | |
1508 | int line; | |
1509 | { | |
1510 | sdb_begin_function_line = line - 1; | |
1511 | PUT_SDB_FUNCTION_START (line); | |
1512 | sdbout_parms (DECL_ARGUMENTS (current_function_decl)); | |
1513 | sdbout_reg_parms (DECL_ARGUMENTS (current_function_decl)); | |
1514 | } | |
1515 | ||
1516 | /* Called at end of function (before epilogue). | |
1517 | Describe end of outermost block. */ | |
1518 | ||
1519 | void | |
1520 | sdbout_end_function (line) | |
1521 | int line; | |
1522 | { | |
1523 | #ifdef SDB_ALLOW_FORWARD_REFERENCES | |
1524 | sdbout_dequeue_anonymous_types (); | |
1525 | #endif | |
1526 | ||
1527 | MAKE_LINE_SAFE (line); | |
1528 | PUT_SDB_FUNCTION_END (line - sdb_begin_function_line); | |
1529 | ||
1530 | /* Indicate we are between functions, for line-number output. */ | |
1531 | sdb_begin_function_line = -1; | |
1532 | } | |
1533 | ||
1534 | /* Output sdb info for the absolute end of a function. | |
1535 | Called after the epilogue is output. */ | |
1536 | ||
1537 | void | |
1538 | sdbout_end_epilogue () | |
1539 | { | |
1540 | char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)); | |
1541 | PUT_SDB_EPILOGUE_END (name); | |
1542 | } | |
1543 | ||
1544 | /* Output sdb info for the given label. Called only if LABEL_NAME (insn) | |
1545 | is present. */ | |
1546 | ||
1547 | void | |
1548 | sdbout_label (insn) | |
1549 | register rtx insn; | |
1550 | { | |
1551 | PUT_SDB_DEF (LABEL_NAME (insn)); | |
1552 | PUT_SDB_VAL (insn); | |
1553 | PUT_SDB_SCL (C_LABEL); | |
1554 | PUT_SDB_TYPE (T_NULL); | |
1555 | PUT_SDB_ENDEF; | |
1556 | } | |
1557 | ||
1558 | #endif /* SDB_DEBUGGING_INFO */ |