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