]>
Commit | Line | Data |
---|---|---|
00fe048c RS |
1 | /* Output dbx-format symbol table information from GNU compiler. |
2 | Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc. | |
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 | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | ||
20 | ||
21 | /* Output dbx-format symbol table data. | |
22 | This consists of many symbol table entries, each of them | |
23 | a .stabs assembler pseudo-op with four operands: | |
24 | a "name" which is really a description of one symbol and its type, | |
25 | a "code", which is a symbol defined in stab.h whose name starts with N_, | |
26 | an unused operand always 0, | |
27 | and a "value" which is an address or an offset. | |
28 | The name is enclosed in doublequote characters. | |
29 | ||
30 | Each function, variable, typedef, and structure tag | |
31 | has a symbol table entry to define it. | |
32 | The beginning and end of each level of name scoping within | |
33 | a function are also marked by special symbol table entries. | |
34 | ||
35 | The "name" consists of the symbol name, a colon, a kind-of-symbol letter, | |
36 | and a data type number. The data type number may be followed by | |
37 | "=" and a type definition; normally this will happen the first time | |
38 | the type number is mentioned. The type definition may refer to | |
39 | other types by number, and those type numbers may be followed | |
40 | by "=" and nested definitions. | |
41 | ||
42 | This can make the "name" quite long. | |
43 | When a name is more than 80 characters, we split the .stabs pseudo-op | |
44 | into two .stabs pseudo-ops, both sharing the same "code" and "value". | |
45 | The first one is marked as continued with a double-backslash at the | |
46 | end of its "name". | |
47 | ||
48 | The kind-of-symbol letter distinguished function names from global | |
49 | variables from file-scope variables from parameters from auto | |
50 | variables in memory from typedef names from register variables. | |
51 | See `dbxout_symbol'. | |
52 | ||
53 | The "code" is mostly redundant with the kind-of-symbol letter | |
54 | that goes in the "name", but not entirely: for symbols located | |
55 | in static storage, the "code" says which segment the address is in, | |
56 | which controls how it is relocated. | |
57 | ||
58 | The "value" for a symbol in static storage | |
59 | is the core address of the symbol (actually, the assembler | |
60 | label for the symbol). For a symbol located in a stack slot | |
61 | it is the stack offset; for one in a register, the register number. | |
62 | For a typedef symbol, it is zero. | |
63 | ||
64 | If DEBUG_SYMS_TEXT is defined, all debugging symbols must be | |
65 | output while in the text section. | |
66 | ||
67 | For more on data type definitions, see `dbxout_type'. */ | |
68 | ||
69 | /* Include these first, because they may define MIN and MAX. */ | |
70 | #include <stdio.h> | |
00fe048c RS |
71 | #include <errno.h> |
72 | ||
73 | #include "config.h" | |
74 | #include "tree.h" | |
75 | #include "rtl.h" | |
76 | #include "flags.h" | |
77 | #include "regs.h" | |
78 | #include "insn-config.h" | |
79 | #include "reload.h" | |
0eb0686e | 80 | #include "defaults.h" |
c3bbab6a | 81 | #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */ |
00fe048c RS |
82 | |
83 | #ifndef errno | |
84 | extern int errno; | |
85 | #endif | |
86 | ||
b372168c | 87 | #ifdef XCOFF_DEBUGGING_INFO |
95f2ba07 | 88 | #include "xcoffout.h" |
b372168c MM |
89 | #endif |
90 | ||
00fe048c RS |
91 | #ifndef ASM_STABS_OP |
92 | #define ASM_STABS_OP ".stabs" | |
93 | #endif | |
94 | ||
95 | #ifndef ASM_STABN_OP | |
96 | #define ASM_STABN_OP ".stabn" | |
97 | #endif | |
98 | ||
01e2750c RS |
99 | #ifndef DBX_TYPE_DECL_STABS_CODE |
100 | #define DBX_TYPE_DECL_STABS_CODE N_LSYM | |
b372168c MM |
101 | #endif |
102 | ||
103 | #ifndef DBX_STATIC_CONST_VAR_CODE | |
104 | #define DBX_STATIC_CONST_VAR_CODE N_FUN | |
105 | #endif | |
106 | ||
107 | #ifndef DBX_REGPARM_STABS_CODE | |
108 | #define DBX_REGPARM_STABS_CODE N_RSYM | |
109 | #endif | |
110 | ||
111 | #ifndef DBX_REGPARM_STABS_LETTER | |
112 | #define DBX_REGPARM_STABS_LETTER 'P' | |
113 | #endif | |
114 | ||
01e2750c RS |
115 | #ifndef DBX_MEMPARM_STABS_LETTER |
116 | #define DBX_MEMPARM_STABS_LETTER 'p' | |
117 | #endif | |
118 | ||
00fe048c RS |
119 | /* Nonzero means if the type has methods, only output debugging |
120 | information if methods are actually written to the asm file. */ | |
121 | ||
122 | static int flag_minimal_debug = 1; | |
123 | ||
124 | /* Nonzero if we have actually used any of the GDB extensions | |
125 | to the debugging format. The idea is that we use them for the | |
126 | first time only if there's a strong reason, but once we have done that, | |
127 | we use them whenever convenient. */ | |
128 | ||
129 | static int have_used_extensions = 0; | |
130 | ||
b372168c | 131 | char *getpwd (); |
00fe048c RS |
132 | |
133 | /* Typical USG systems don't have stab.h, and they also have | |
134 | no use for DBX-format debugging info. */ | |
135 | ||
b372168c | 136 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) |
00fe048c RS |
137 | |
138 | #ifdef DEBUG_SYMS_TEXT | |
139 | #define FORCE_TEXT text_section (); | |
140 | #else | |
141 | #define FORCE_TEXT | |
142 | #endif | |
143 | ||
95f2ba07 | 144 | #if defined (USG) || defined (NO_STAB_H) |
00fe048c RS |
145 | #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */ |
146 | #else | |
147 | #include <stab.h> /* On BSD, use the system's stab.h. */ | |
148 | ||
149 | /* This is a GNU extension we need to reference in this file. */ | |
150 | #ifndef N_CATCH | |
151 | #define N_CATCH 0x54 | |
152 | #endif | |
153 | #endif /* not USG */ | |
154 | ||
155 | #ifdef __GNU_STAB__ | |
156 | #define STAB_CODE_TYPE enum __stab_debug_code | |
157 | #else | |
158 | #define STAB_CODE_TYPE int | |
159 | #endif | |
160 | ||
161 | /* 1 if PARM is passed to this function in memory. */ | |
162 | ||
163 | #define PARM_PASSED_IN_MEMORY(PARM) \ | |
164 | (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM) | |
165 | ||
166 | /* A C expression for the integer offset value of an automatic variable | |
167 | (N_LSYM) having address X (an RTX). */ | |
168 | #ifndef DEBUGGER_AUTO_OFFSET | |
169 | #define DEBUGGER_AUTO_OFFSET(X) \ | |
170 | (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) | |
171 | #endif | |
172 | ||
173 | /* A C expression for the integer offset value of an argument (N_PSYM) | |
174 | having address X (an RTX). The nominal offset is OFFSET. */ | |
175 | #ifndef DEBUGGER_ARG_OFFSET | |
176 | #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET) | |
177 | #endif | |
178 | ||
179 | /* Stream for writing to assembler file. */ | |
180 | ||
181 | static FILE *asmfile; | |
182 | ||
183 | /* Last source file name mentioned in a NOTE insn. */ | |
184 | ||
185 | static char *lastfile; | |
186 | ||
187 | /* Current working directory. */ | |
188 | ||
189 | static char *cwd; | |
00fe048c RS |
190 | |
191 | enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED}; | |
192 | ||
193 | /* Vector recording the status of describing C data types. | |
194 | When we first notice a data type (a tree node), | |
195 | we assign it a number using next_type_number. | |
196 | That is its index in this vector. | |
197 | The vector element says whether we have yet output | |
198 | the definition of the type. TYPE_XREF says we have | |
199 | output it as a cross-reference only. */ | |
200 | ||
201 | enum typestatus *typevec; | |
202 | ||
203 | /* Number of elements of space allocated in `typevec'. */ | |
204 | ||
205 | static int typevec_len; | |
206 | ||
207 | /* In dbx output, each type gets a unique number. | |
208 | This is the number for the next type output. | |
209 | The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */ | |
210 | ||
211 | static int next_type_number; | |
212 | ||
213 | /* In dbx output, we must assign symbol-blocks id numbers | |
214 | in the order in which their beginnings are encountered. | |
215 | We output debugging info that refers to the beginning and | |
216 | end of the ranges of code in each block | |
217 | with assembler labels LBBn and LBEn, where n is the block number. | |
218 | The labels are generated in final, which assigns numbers to the | |
219 | blocks in the same way. */ | |
220 | ||
221 | static int next_block_number; | |
222 | ||
223 | /* These variables are for dbxout_symbol to communicate to | |
224 | dbxout_finish_symbol. | |
225 | current_sym_code is the symbol-type-code, a symbol N_... define in stab.h. | |
226 | current_sym_value and current_sym_addr are two ways to address the | |
227 | value to store in the symtab entry. | |
228 | current_sym_addr if nonzero represents the value as an rtx. | |
229 | If that is zero, current_sym_value is used. This is used | |
230 | when the value is an offset (such as for auto variables, | |
231 | register variables and parms). */ | |
232 | ||
233 | static STAB_CODE_TYPE current_sym_code; | |
234 | static int current_sym_value; | |
235 | static rtx current_sym_addr; | |
236 | ||
237 | /* Number of chars of symbol-description generated so far for the | |
238 | current symbol. Used by CHARS and CONTIN. */ | |
239 | ||
240 | static int current_sym_nchars; | |
241 | ||
242 | /* Report having output N chars of the current symbol-description. */ | |
243 | ||
244 | #define CHARS(N) (current_sym_nchars += (N)) | |
245 | ||
246 | /* Break the current symbol-description, generating a continuation, | |
247 | if it has become long. */ | |
248 | ||
249 | #ifndef DBX_CONTIN_LENGTH | |
250 | #define DBX_CONTIN_LENGTH 80 | |
251 | #endif | |
252 | ||
253 | #if DBX_CONTIN_LENGTH > 0 | |
254 | #define CONTIN \ | |
255 | do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0) | |
256 | #else | |
257 | #define CONTIN | |
258 | #endif | |
259 | ||
260 | void dbxout_types (); | |
261 | void dbxout_args (); | |
262 | void dbxout_symbol (); | |
263 | static void dbxout_type_name (); | |
264 | static void dbxout_type (); | |
265 | static void dbxout_typedefs (); | |
47700802 RS |
266 | static void dbxout_symbol_name (); |
267 | static void dbxout_symbol_location (); | |
00fe048c RS |
268 | static void dbxout_prepare_symbol (); |
269 | static void dbxout_finish_symbol (); | |
270 | static void dbxout_continue (); | |
271 | static void print_int_cst_octal (); | |
272 | static void print_octal (); | |
273 | \f | |
274 | #if 0 /* Not clear we will actually need this. */ | |
275 | ||
276 | /* Return the absolutized filename for the given relative | |
277 | filename. Note that if that filename is already absolute, it may | |
278 | still be returned in a modified form because this routine also | |
279 | eliminates redundant slashes and single dots and eliminates double | |
280 | dots to get a shortest possible filename from the given input | |
281 | filename. The absolutization of relative filenames is made by | |
282 | assuming that the given filename is to be taken as relative to | |
283 | the first argument (cwd) or to the current directory if cwd is | |
284 | NULL. */ | |
285 | ||
286 | static char * | |
287 | abspath (rel_filename) | |
288 | char *rel_filename; | |
289 | { | |
290 | /* Setup the current working directory as needed. */ | |
291 | char *abs_buffer | |
292 | = (char *) alloca (strlen (cwd) + strlen (rel_filename) + 1); | |
293 | char *endp = abs_buffer; | |
294 | char *outp, *inp; | |
295 | char *value; | |
296 | ||
b372168c | 297 | /* Copy the filename (possibly preceded by the current working |
00fe048c RS |
298 | directory name) into the absolutization buffer. */ |
299 | ||
300 | { | |
301 | char *src_p; | |
302 | ||
303 | if (rel_filename[0] != '/') | |
304 | { | |
305 | src_p = cwd; | |
306 | while (*endp++ = *src_p++) | |
307 | continue; | |
308 | *(endp-1) = '/'; /* overwrite null */ | |
309 | } | |
310 | src_p = rel_filename; | |
311 | while (*endp++ = *src_p++) | |
312 | continue; | |
313 | if (endp[-1] == '/') | |
314 | *endp = '\0'; | |
00fe048c RS |
315 | |
316 | /* Now make a copy of abs_buffer into abs_buffer, shortening the | |
317 | filename (by taking out slashes and dots) as we go. */ | |
318 | ||
319 | outp = inp = abs_buffer; | |
320 | *outp++ = *inp++; /* copy first slash */ | |
321 | for (;;) | |
322 | { | |
323 | if (!inp[0]) | |
324 | break; | |
325 | else if (inp[0] == '/' && outp[-1] == '/') | |
326 | { | |
327 | inp++; | |
328 | continue; | |
329 | } | |
330 | else if (inp[0] == '.' && outp[-1] == '/') | |
331 | { | |
332 | if (!inp[1]) | |
333 | break; | |
334 | else if (inp[1] == '/') | |
335 | { | |
336 | inp += 2; | |
337 | continue; | |
338 | } | |
339 | else if ((inp[1] == '.') && (inp[2] == 0 || inp[2] == '/')) | |
340 | { | |
341 | inp += (inp[2] == '/') ? 3 : 2; | |
342 | outp -= 2; | |
343 | while (outp >= abs_buffer && *outp != '/') | |
344 | outp--; | |
345 | if (outp < abs_buffer) | |
346 | { | |
347 | /* Catch cases like /.. where we try to backup to a | |
348 | point above the absolute root of the logical file | |
349 | system. */ | |
350 | ||
351 | fprintf (stderr, "%s: invalid file name: %s\n", | |
352 | pname, rel_filename); | |
353 | exit (1); | |
354 | } | |
355 | *++outp = '\0'; | |
356 | continue; | |
357 | } | |
358 | } | |
359 | *outp++ = *inp++; | |
360 | } | |
361 | ||
362 | /* On exit, make sure that there is a trailing null, and make sure that | |
363 | the last character of the returned string is *not* a slash. */ | |
364 | ||
365 | *outp = '\0'; | |
366 | if (outp[-1] == '/') | |
367 | *--outp = '\0'; | |
368 | ||
369 | /* Make a copy (in the heap) of the stuff left in the absolutization | |
370 | buffer and return a pointer to the copy. */ | |
371 | ||
372 | value = (char *) oballoc (strlen (abs_buffer) + 1); | |
373 | strcpy (value, abs_buffer); | |
374 | return value; | |
375 | } | |
376 | #endif /* 0 */ | |
377 | \f | |
378 | /* At the beginning of compilation, start writing the symbol table. | |
379 | Initialize `typevec' and output the standard data types of C. */ | |
380 | ||
381 | void | |
382 | dbxout_init (asm_file, input_file_name, syms) | |
383 | FILE *asm_file; | |
384 | char *input_file_name; | |
385 | tree syms; | |
386 | { | |
387 | char ltext_label_name[100]; | |
388 | ||
389 | asmfile = asm_file; | |
390 | ||
391 | typevec_len = 100; | |
392 | typevec = (enum typestatus *) xmalloc (typevec_len * sizeof typevec[0]); | |
393 | bzero (typevec, typevec_len * sizeof typevec[0]); | |
394 | ||
395 | /* Convert Ltext into the appropriate format for local labels in case | |
396 | the system doesn't insert underscores in front of user generated | |
397 | labels. */ | |
398 | ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0); | |
399 | ||
400 | /* Put the current working directory in an N_SO symbol. */ | |
b372168c MM |
401 | #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this, |
402 | but GDB always does. */ | |
196cedd0 | 403 | if (use_gnu_debug_info_extensions) |
b372168c MM |
404 | #endif |
405 | { | |
406 | if (cwd || (cwd = getpwd ())) | |
407 | { | |
00fe048c | 408 | #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY |
b372168c | 409 | DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd); |
00fe048c | 410 | #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */ |
b372168c MM |
411 | fprintf (asmfile, "%s \"%s/\",%d,0,0,%s\n", ASM_STABS_OP, |
412 | cwd, N_SO, <ext_label_name[1]); | |
00fe048c | 413 | #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */ |
b372168c MM |
414 | } |
415 | } | |
00fe048c RS |
416 | |
417 | #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME | |
418 | /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That | |
419 | would give us an N_SOL, and we want an N_SO. */ | |
420 | DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name); | |
421 | #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */ | |
422 | /* We include outputting `Ltext:' here, | |
423 | because that gives you a way to override it. */ | |
424 | /* Used to put `Ltext:' before the reference, but that loses on sun 4. */ | |
425 | fprintf (asmfile, "%s \"%s\",%d,0,0,%s\n", ASM_STABS_OP, input_file_name, | |
426 | N_SO, <ext_label_name[1]); | |
427 | text_section (); | |
428 | ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0); | |
429 | #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */ | |
430 | ||
01571284 RS |
431 | /* Possibly output something to inform GDB that this compilation was by |
432 | GCC. It's easier for GDB to parse it when after the N_SO's. This | |
433 | is used in Solaris 2. */ | |
434 | #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE | |
435 | ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile); | |
436 | #endif | |
437 | ||
00fe048c RS |
438 | lastfile = input_file_name; |
439 | ||
440 | next_type_number = 1; | |
441 | next_block_number = 2; | |
442 | ||
443 | /* Make sure that types `int' and `char' have numbers 1 and 2. | |
444 | Definitions of other integer types will refer to those numbers. | |
445 | (Actually it should no longer matter what their numbers are. | |
446 | Also, if any types with tags have been defined, dbxout_symbol | |
447 | will output them first, so the numbers won't be 1 and 2. That | |
448 | happens in C++. So it's a good thing it should no longer matter). */ | |
449 | ||
450 | #ifdef DBX_OUTPUT_STANDARD_TYPES | |
451 | DBX_OUTPUT_STANDARD_TYPES (syms); | |
452 | #else | |
453 | dbxout_symbol (TYPE_NAME (integer_type_node), 0); | |
454 | dbxout_symbol (TYPE_NAME (char_type_node), 0); | |
455 | #endif | |
456 | ||
457 | /* Get all permanent types that have typedef names, | |
458 | and output them all, except for those already output. */ | |
459 | ||
460 | dbxout_typedefs (syms); | |
461 | } | |
462 | ||
463 | /* Output any typedef names for types described by TYPE_DECLs in SYMS, | |
464 | in the reverse order from that which is found in SYMS. */ | |
465 | ||
466 | static void | |
467 | dbxout_typedefs (syms) | |
468 | tree syms; | |
469 | { | |
470 | if (syms) | |
471 | { | |
472 | dbxout_typedefs (TREE_CHAIN (syms)); | |
473 | if (TREE_CODE (syms) == TYPE_DECL) | |
474 | { | |
475 | tree type = TREE_TYPE (syms); | |
476 | if (TYPE_NAME (type) | |
477 | && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
478 | && ! TREE_ASM_WRITTEN (TYPE_NAME (type))) | |
479 | dbxout_symbol (TYPE_NAME (type), 0); | |
480 | } | |
481 | } | |
482 | } | |
483 | ||
484 | /* Output debugging info to FILE to switch to sourcefile FILENAME. */ | |
485 | ||
486 | void | |
487 | dbxout_source_file (file, filename) | |
488 | FILE *file; | |
489 | char *filename; | |
490 | { | |
491 | char ltext_label_name[100]; | |
492 | ||
493 | if (filename && (lastfile == 0 || strcmp (filename, lastfile))) | |
494 | { | |
495 | #ifdef DBX_OUTPUT_SOURCE_FILENAME | |
496 | DBX_OUTPUT_SOURCE_FILENAME (file, filename); | |
497 | #else | |
498 | ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0); | |
499 | fprintf (file, "%s \"%s\",%d,0,0,%s\n", ASM_STABS_OP, | |
500 | filename, N_SOL, <ext_label_name[1]); | |
501 | #endif | |
502 | lastfile = filename; | |
503 | } | |
504 | } | |
505 | ||
674c724c RS |
506 | /* Output a line number symbol entry into output stream FILE, |
507 | for source file FILENAME and line number LINENO. */ | |
508 | ||
509 | void | |
510 | dbxout_source_line (file, filename, lineno) | |
511 | FILE *file; | |
512 | char *filename; | |
513 | int lineno; | |
514 | { | |
515 | dbxout_source_file (file, filename); | |
516 | ||
517 | #ifdef ASM_OUTPUT_SOURCE_LINE | |
518 | ASM_OUTPUT_SOURCE_LINE (file, lineno); | |
519 | #else | |
520 | fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno); | |
521 | #endif | |
522 | } | |
523 | ||
00fe048c RS |
524 | /* At the end of compilation, finish writing the symbol table. |
525 | Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is | |
526 | to do nothing. */ | |
527 | ||
528 | void | |
529 | dbxout_finish (file, filename) | |
530 | FILE *file; | |
531 | char *filename; | |
532 | { | |
533 | #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END | |
534 | DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename); | |
535 | #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */ | |
536 | } | |
537 | ||
538 | /* Continue a symbol-description that gets too big. | |
539 | End one symbol table entry with a double-backslash | |
540 | and start a new one, eventually producing something like | |
541 | .stabs "start......\\",code,0,value | |
542 | .stabs "...rest",code,0,value */ | |
543 | ||
544 | static void | |
545 | dbxout_continue () | |
546 | { | |
547 | #ifdef DBX_CONTIN_CHAR | |
548 | fprintf (asmfile, "%c", DBX_CONTIN_CHAR); | |
549 | #else | |
550 | fprintf (asmfile, "\\\\"); | |
551 | #endif | |
0d92cbff | 552 | dbxout_finish_symbol (NULL_TREE); |
00fe048c RS |
553 | fprintf (asmfile, "%s \"", ASM_STABS_OP); |
554 | current_sym_nchars = 0; | |
555 | } | |
556 | \f | |
6dc42e49 | 557 | /* Subroutine of `dbxout_type'. Output the type fields of TYPE. |
00fe048c RS |
558 | This must be a separate function because anonymous unions require |
559 | recursive calls. */ | |
560 | ||
561 | static void | |
562 | dbxout_type_fields (type) | |
563 | tree type; | |
564 | { | |
565 | tree tem; | |
15a5b8a2 RS |
566 | /* Output the name, type, position (in bits), size (in bits) of each |
567 | field. */ | |
00fe048c RS |
568 | for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) |
569 | { | |
15a5b8a2 | 570 | /* For nameless subunions and subrecords, treat their fields as ours. */ |
00fe048c | 571 | if (DECL_NAME (tem) == NULL_TREE |
15a5b8a2 | 572 | && (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE |
c1b98a95 | 573 | || TREE_CODE (TREE_TYPE (tem)) == QUAL_UNION_TYPE |
15a5b8a2 | 574 | || TREE_CODE (TREE_TYPE (tem)) == RECORD_TYPE)) |
00fe048c RS |
575 | dbxout_type_fields (TREE_TYPE (tem)); |
576 | /* Omit here local type decls until we know how to support them. */ | |
577 | else if (TREE_CODE (tem) == TYPE_DECL) | |
578 | continue; | |
579 | /* Omit here the nameless fields that are used to skip bits. */ | |
580 | else if (DECL_NAME (tem) != 0 && TREE_CODE (tem) != CONST_DECL) | |
581 | { | |
582 | /* Continue the line if necessary, | |
583 | but not before the first field. */ | |
584 | if (tem != TYPE_FIELDS (type)) | |
585 | CONTIN; | |
586 | ||
196cedd0 | 587 | if (use_gnu_debug_info_extensions |
00fe048c RS |
588 | && flag_minimal_debug |
589 | && TREE_CODE (tem) == FIELD_DECL | |
590 | && DECL_VIRTUAL_P (tem) | |
591 | && DECL_ASSEMBLER_NAME (tem)) | |
592 | { | |
593 | have_used_extensions = 1; | |
594 | CHARS (3 + IDENTIFIER_LENGTH (DECL_NAME (TYPE_NAME (DECL_FCONTEXT (tem))))); | |
595 | fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile); | |
3a7587e4 | 596 | dbxout_type (DECL_FCONTEXT (tem), 0, 0); |
00fe048c | 597 | fprintf (asmfile, ":"); |
3a7587e4 | 598 | dbxout_type (TREE_TYPE (tem), 0, 0); |
00fe048c RS |
599 | fprintf (asmfile, ",%d;", |
600 | TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem))); | |
601 | continue; | |
602 | } | |
603 | ||
604 | fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem))); | |
605 | CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem))); | |
606 | ||
196cedd0 | 607 | if (use_gnu_debug_info_extensions |
00fe048c RS |
608 | && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem) |
609 | || TREE_CODE (tem) != FIELD_DECL)) | |
610 | { | |
611 | have_used_extensions = 1; | |
612 | putc ('/', asmfile); | |
613 | putc ((TREE_PRIVATE (tem) ? '0' | |
614 | : TREE_PROTECTED (tem) ? '1' : '2'), | |
615 | asmfile); | |
616 | CHARS (2); | |
617 | } | |
618 | ||
619 | dbxout_type ((TREE_CODE (tem) == FIELD_DECL | |
620 | && DECL_BIT_FIELD_TYPE (tem)) | |
621 | ? DECL_BIT_FIELD_TYPE (tem) | |
3a7587e4 | 622 | : TREE_TYPE (tem), 0, 0); |
00fe048c RS |
623 | |
624 | if (TREE_CODE (tem) == VAR_DECL) | |
625 | { | |
196cedd0 | 626 | if (TREE_STATIC (tem) && use_gnu_debug_info_extensions) |
00fe048c RS |
627 | { |
628 | char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)); | |
629 | have_used_extensions = 1; | |
00fe048c RS |
630 | fprintf (asmfile, ":%s;", name); |
631 | CHARS (strlen (name)); | |
632 | } | |
633 | else | |
634 | { | |
635 | /* If TEM is non-static, GDB won't understand it. */ | |
636 | fprintf (asmfile, ",0,0;"); | |
637 | } | |
638 | } | |
639 | else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST) | |
640 | { | |
641 | fprintf (asmfile, ",%d,%d;", | |
642 | TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)), | |
643 | TREE_INT_CST_LOW (DECL_SIZE (tem))); | |
644 | } | |
645 | else | |
646 | /* This has yet to be implemented. */ | |
647 | abort (); | |
648 | CHARS (23); | |
649 | } | |
650 | } | |
651 | } | |
652 | \f | |
6dc42e49 | 653 | /* Subroutine of `dbxout_type_methods'. Output debug info about the |
00fe048c RS |
654 | method described DECL. DEBUG_NAME is an encoding of the method's |
655 | type signature. ??? We may be able to do without DEBUG_NAME altogether | |
656 | now. */ | |
657 | ||
658 | static void | |
659 | dbxout_type_method_1 (decl, debug_name) | |
660 | tree decl; | |
661 | char *debug_name; | |
662 | { | |
663 | tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))); | |
664 | char c1 = 'A', c2; | |
665 | ||
666 | if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE) | |
667 | c2 = '?'; | |
668 | else /* it's a METHOD_TYPE. */ | |
669 | { | |
670 | /* A for normal functions. | |
671 | B for `const' member functions. | |
672 | C for `volatile' member functions. | |
673 | D for `const volatile' member functions. */ | |
674 | if (TYPE_READONLY (TREE_TYPE (firstarg))) | |
675 | c1 += 1; | |
676 | if (TYPE_VOLATILE (TREE_TYPE (firstarg))) | |
677 | c1 += 2; | |
678 | ||
679 | if (DECL_VINDEX (decl)) | |
680 | c2 = '*'; | |
681 | else | |
682 | c2 = '.'; | |
683 | } | |
684 | ||
685 | fprintf (asmfile, ":%s;%c%c%c", debug_name, | |
686 | TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2); | |
687 | CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6 | |
688 | - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)))); | |
689 | if (DECL_VINDEX (decl)) | |
690 | { | |
691 | fprintf (asmfile, "%d;", | |
692 | TREE_INT_CST_LOW (DECL_VINDEX (decl))); | |
3a7587e4 | 693 | dbxout_type (DECL_CONTEXT (decl), 0, 0); |
00fe048c RS |
694 | fprintf (asmfile, ";"); |
695 | CHARS (8); | |
696 | } | |
697 | } | |
698 | \f | |
699 | /* Subroutine of `dbxout_type'. Output debug info about the methods defined | |
700 | in TYPE. */ | |
701 | ||
702 | static void | |
703 | dbxout_type_methods (type) | |
704 | register tree type; | |
705 | { | |
706 | /* C++: put out the method names and their parameter lists */ | |
00fe048c | 707 | tree methods = TYPE_METHODS (type); |
95f2ba07 | 708 | tree type_encoding; |
00fe048c RS |
709 | register tree fndecl; |
710 | register tree last; | |
9161aa96 | 711 | char formatted_type_identifier_length[16]; |
00fe048c RS |
712 | register int type_identifier_length; |
713 | ||
714 | if (methods == NULL_TREE) | |
715 | return; | |
716 | ||
3a7587e4 | 717 | type_encoding = DECL_NAME (TYPE_NAME (type)); |
95f2ba07 KR |
718 | |
719 | /* C++: Template classes break some assumptions made by this code about | |
720 | the class names, constructor names, and encodings for assembler | |
721 | label names. For now, disable output of dbx info for them. */ | |
722 | { | |
3a7587e4 | 723 | char *ptr = IDENTIFIER_POINTER (type_encoding); |
1527c38f | 724 | /* This should use index. (mrs) */ |
95f2ba07 KR |
725 | while (*ptr && *ptr != '<') ptr++; |
726 | if (*ptr != 0) | |
727 | { | |
728 | static int warned; | |
729 | if (!warned) | |
730 | { | |
731 | warned = 1; | |
eaff4f5a BK |
732 | #ifdef HAVE_TEMPLATES |
733 | if (warn_template_debugging) | |
734 | warning ("dbx info for template class methods not yet supported"); | |
735 | #endif | |
95f2ba07 KR |
736 | } |
737 | return; | |
738 | } | |
739 | } | |
740 | ||
3a7587e4 | 741 | type_identifier_length = IDENTIFIER_LENGTH (type_encoding); |
95f2ba07 | 742 | |
9161aa96 RS |
743 | sprintf(formatted_type_identifier_length, "%d", type_identifier_length); |
744 | ||
d26ab756 RS |
745 | if (TREE_CODE (methods) == FUNCTION_DECL) |
746 | fndecl = methods; | |
747 | else if (TREE_VEC_ELT (methods, 0) != NULL_TREE) | |
00fe048c | 748 | fndecl = TREE_VEC_ELT (methods, 0); |
196cedd0 RS |
749 | else |
750 | fndecl = TREE_VEC_ELT (methods, 1); | |
00fe048c | 751 | |
00fe048c RS |
752 | while (fndecl) |
753 | { | |
754 | tree name = DECL_NAME (fndecl); | |
3a7587e4 | 755 | int need_prefix = 1; |
00fe048c | 756 | |
3a7587e4 RS |
757 | /* Group together all the methods for the same operation. |
758 | These differ in the types of the arguments. */ | |
00fe048c RS |
759 | for (last = NULL_TREE; |
760 | fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last)); | |
761 | fndecl = TREE_CHAIN (fndecl)) | |
762 | /* Output the name of the field (after overloading), as | |
763 | well as the name of the field before overloading, along | |
764 | with its parameter list */ | |
765 | { | |
3a7587e4 RS |
766 | /* This is the "mangled" name of the method. |
767 | It encodes the argument types. */ | |
00fe048c | 768 | char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)); |
3a7587e4 | 769 | int destructor = 0; |
00fe048c RS |
770 | |
771 | CONTIN; | |
772 | ||
773 | last = fndecl; | |
3a7587e4 RS |
774 | |
775 | if (DECL_IGNORED_P (fndecl)) | |
776 | continue; | |
777 | ||
00fe048c RS |
778 | if (flag_minimal_debug) |
779 | { | |
3a7587e4 RS |
780 | /* Detect ordinary methods because their mangled names |
781 | start with the operation name. */ | |
782 | if (!strncmp (IDENTIFIER_POINTER (name), debug_name, | |
783 | IDENTIFIER_LENGTH (name))) | |
784 | { | |
785 | debug_name += IDENTIFIER_LENGTH (name); | |
786 | if (debug_name[0] == '_' && debug_name[1] == '_') | |
787 | { | |
788 | char *method_name = debug_name + 2; | |
9161aa96 | 789 | char *length_ptr = formatted_type_identifier_length; |
3a7587e4 RS |
790 | /* Get past const and volatile qualifiers. */ |
791 | while (*method_name == 'C' || *method_name == 'V') | |
792 | method_name++; | |
9161aa96 RS |
793 | /* Skip digits for length of type_encoding. */ |
794 | while (*method_name == *length_ptr && *length_ptr) | |
795 | length_ptr++, method_name++; | |
3a7587e4 RS |
796 | if (! strncmp (method_name, |
797 | IDENTIFIER_POINTER (type_encoding), | |
798 | type_identifier_length)) | |
799 | method_name += type_identifier_length; | |
800 | debug_name = method_name; | |
801 | } | |
802 | } | |
803 | /* Detect constructors by their style of name mangling. */ | |
804 | else if (debug_name[0] == '_' && debug_name[1] == '_') | |
805 | { | |
806 | char *ctor_name = debug_name + 2; | |
9161aa96 | 807 | char *length_ptr = formatted_type_identifier_length; |
3a7587e4 RS |
808 | while (*ctor_name == 'C' || *ctor_name == 'V') |
809 | ctor_name++; | |
9161aa96 RS |
810 | /* Skip digits for length of type_encoding. */ |
811 | while (*ctor_name == *length_ptr && *length_ptr) | |
812 | length_ptr++, ctor_name++; | |
3a7587e4 RS |
813 | if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name, |
814 | type_identifier_length)) | |
815 | debug_name = ctor_name + type_identifier_length; | |
816 | } | |
817 | /* The other alternative is a destructor. */ | |
818 | else | |
819 | destructor = 1; | |
820 | ||
821 | /* Output the operation name just once, for the first method | |
822 | that we output. */ | |
823 | if (need_prefix) | |
824 | { | |
825 | fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name)); | |
826 | CHARS (IDENTIFIER_LENGTH (name) + 2); | |
827 | need_prefix = 0; | |
828 | } | |
00fe048c | 829 | } |
3a7587e4 RS |
830 | |
831 | dbxout_type (TREE_TYPE (fndecl), 0, destructor); | |
832 | ||
00fe048c RS |
833 | dbxout_type_method_1 (fndecl, debug_name); |
834 | } | |
52a73899 MS |
835 | if (!need_prefix) |
836 | { | |
837 | putc (';', asmfile); | |
838 | CHARS (1); | |
839 | } | |
00fe048c RS |
840 | } |
841 | } | |
b238f8de PB |
842 | |
843 | /* Emit a "range" type specification, which has the form: | |
844 | "r<index type>;<lower bound>;<upper bound>;". | |
845 | TYPE is an INTEGER_TYPE. */ | |
846 | ||
847 | static void | |
848 | dbxout_range_type (type) | |
849 | tree type; | |
850 | { | |
851 | fprintf (asmfile, "r"); | |
852 | if (TREE_TYPE (type) && TREE_CODE (TREE_TYPE(type)) != INTEGER_TYPE) | |
853 | dbxout_type (TREE_TYPE (type), 0, 0); | |
854 | else | |
855 | { | |
856 | /* This used to say `r1' and we used to take care | |
857 | to make sure that `int' was type number 1. */ | |
858 | fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (integer_type_node)); | |
859 | } | |
860 | if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST) | |
861 | fprintf (asmfile, ";%d", | |
862 | TREE_INT_CST_LOW (TYPE_MIN_VALUE (type))); | |
863 | else | |
864 | fprintf (asmfile, ";0"); | |
865 | if (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST) | |
866 | fprintf (asmfile, ";%d;", | |
867 | TREE_INT_CST_LOW (TYPE_MAX_VALUE (type))); | |
868 | else | |
869 | fprintf (asmfile, ";-1;"); | |
870 | } | |
00fe048c RS |
871 | \f |
872 | /* Output a reference to a type. If the type has not yet been | |
873 | described in the dbx output, output its definition now. | |
874 | For a type already defined, just refer to its definition | |
875 | using the type number. | |
876 | ||
877 | If FULL is nonzero, and the type has been described only with | |
878 | a forward-reference, output the definition now. | |
879 | If FULL is zero in this case, just refer to the forward-reference | |
3a7587e4 RS |
880 | using the number previously allocated. |
881 | ||
882 | If SHOW_ARG_TYPES is nonzero, we output a description of the argument | |
883 | types for a METHOD_TYPE. */ | |
00fe048c RS |
884 | |
885 | static void | |
3a7587e4 | 886 | dbxout_type (type, full, show_arg_types) |
00fe048c RS |
887 | tree type; |
888 | int full; | |
3a7587e4 | 889 | int show_arg_types; |
00fe048c RS |
890 | { |
891 | register tree tem; | |
35571e38 | 892 | static int anonymous_type_number = 0; |
00fe048c RS |
893 | |
894 | /* If there was an input error and we don't really have a type, | |
895 | avoid crashing and write something that is at least valid | |
896 | by assuming `int'. */ | |
897 | if (type == error_mark_node) | |
898 | type = integer_type_node; | |
899 | else | |
900 | { | |
901 | type = TYPE_MAIN_VARIANT (type); | |
902 | if (TYPE_NAME (type) | |
903 | && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
904 | && DECL_IGNORED_P (TYPE_NAME (type))) | |
905 | full = 0; | |
906 | } | |
907 | ||
908 | if (TYPE_SYMTAB_ADDRESS (type) == 0) | |
909 | { | |
910 | /* Type has no dbx number assigned. Assign next available number. */ | |
911 | TYPE_SYMTAB_ADDRESS (type) = next_type_number++; | |
912 | ||
913 | /* Make sure type vector is long enough to record about this type. */ | |
914 | ||
915 | if (next_type_number == typevec_len) | |
916 | { | |
917 | typevec = (enum typestatus *) xrealloc (typevec, typevec_len * 2 * sizeof typevec[0]); | |
918 | bzero (typevec + typevec_len, typevec_len * sizeof typevec[0]); | |
919 | typevec_len *= 2; | |
920 | } | |
921 | } | |
922 | ||
923 | /* Output the number of this type, to refer to it. */ | |
924 | fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type)); | |
925 | CHARS (3); | |
926 | ||
b372168c MM |
927 | #ifdef DBX_TYPE_DEFINED |
928 | if (DBX_TYPE_DEFINED (type)) | |
929 | return; | |
930 | #endif | |
931 | ||
00fe048c RS |
932 | /* If this type's definition has been output or is now being output, |
933 | that is all. */ | |
934 | ||
935 | switch (typevec[TYPE_SYMTAB_ADDRESS (type)]) | |
936 | { | |
937 | case TYPE_UNSEEN: | |
938 | break; | |
939 | case TYPE_XREF: | |
dad0145a RS |
940 | /* If we have already had a cross reference, |
941 | and either that's all we want or that's the best we could do, | |
942 | don't repeat the cross reference. | |
943 | Sun dbx crashes if we do. */ | |
944 | if (! full || TYPE_SIZE (type) == 0 | |
945 | /* No way in DBX fmt to describe a variable size. */ | |
946 | || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) | |
00fe048c RS |
947 | return; |
948 | break; | |
949 | case TYPE_DEFINED: | |
950 | return; | |
951 | } | |
952 | ||
953 | #ifdef DBX_NO_XREFS | |
954 | /* For systems where dbx output does not allow the `=xsNAME:' syntax, | |
955 | leave the type-number completely undefined rather than output | |
956 | a cross-reference. */ | |
957 | if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE | |
c1b98a95 | 958 | || TREE_CODE (type) == QUAL_UNION_TYPE |
00fe048c RS |
959 | || TREE_CODE (type) == ENUMERAL_TYPE) |
960 | ||
961 | if ((TYPE_NAME (type) != 0 && !full) | |
962 | || TYPE_SIZE (type) == 0) | |
963 | { | |
964 | typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF; | |
965 | return; | |
966 | } | |
967 | #endif | |
968 | ||
969 | /* Output a definition now. */ | |
970 | ||
971 | fprintf (asmfile, "="); | |
972 | CHARS (1); | |
973 | ||
974 | /* Mark it as defined, so that if it is self-referent | |
975 | we will not get into an infinite recursion of definitions. */ | |
976 | ||
977 | typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_DEFINED; | |
978 | ||
979 | switch (TREE_CODE (type)) | |
980 | { | |
981 | case VOID_TYPE: | |
982 | case LANG_TYPE: | |
983 | /* For a void type, just define it as itself; ie, "5=5". | |
984 | This makes us consider it defined | |
985 | without saying what it is. The debugger will make it | |
986 | a void type when the reference is seen, and nothing will | |
987 | ever override that default. */ | |
988 | fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type)); | |
989 | CHARS (3); | |
990 | break; | |
991 | ||
992 | case INTEGER_TYPE: | |
993 | if (type == char_type_node && ! TREE_UNSIGNED (type)) | |
994 | /* Output the type `char' as a subrange of itself! | |
995 | I don't understand this definition, just copied it | |
996 | from the output of pcc. | |
997 | This used to use `r2' explicitly and we used to | |
998 | take care to make sure that `char' was type number 2. */ | |
999 | fprintf (asmfile, "r%d;0;127;", TYPE_SYMTAB_ADDRESS (type)); | |
fcf956c0 | 1000 | else if (use_gnu_debug_info_extensions && TYPE_PRECISION (type) > BITS_PER_WORD) |
00fe048c RS |
1001 | { |
1002 | /* This used to say `r1' and we used to take care | |
1003 | to make sure that `int' was type number 1. */ | |
1004 | fprintf (asmfile, "r%d;", TYPE_SYMTAB_ADDRESS (integer_type_node)); | |
1005 | print_int_cst_octal (TYPE_MIN_VALUE (type)); | |
1006 | fprintf (asmfile, ";"); | |
1007 | print_int_cst_octal (TYPE_MAX_VALUE (type)); | |
1008 | fprintf (asmfile, ";"); | |
1009 | } | |
b238f8de PB |
1010 | else /* Output other integer types as subranges of `int'. */ |
1011 | dbxout_range_type (type); | |
00fe048c RS |
1012 | CHARS (25); |
1013 | break; | |
1014 | ||
1015 | case REAL_TYPE: | |
1016 | /* This used to say `r1' and we used to take care | |
1017 | to make sure that `int' was type number 1. */ | |
1018 | fprintf (asmfile, "r%d;%d;0;", TYPE_SYMTAB_ADDRESS (integer_type_node), | |
cdece1ef | 1019 | int_size_in_bytes (type)); |
00fe048c RS |
1020 | CHARS (16); |
1021 | break; | |
1022 | ||
15a5b8a2 RS |
1023 | case CHAR_TYPE: |
1024 | /* Output the type `char' as a subrange of itself. | |
1025 | That is what pcc seems to do. */ | |
1026 | fprintf (asmfile, "r%d;0;%d;", TYPE_SYMTAB_ADDRESS (char_type_node), | |
1027 | TREE_UNSIGNED (type) ? 255 : 127); | |
1028 | CHARS (9); | |
1029 | break; | |
1030 | ||
1031 | case BOOLEAN_TYPE: /* Define as enumeral type (False, True) */ | |
1032 | fprintf (asmfile, "eFalse:0,True:1,;"); | |
1033 | CHARS (17); | |
1034 | break; | |
1035 | ||
1036 | case FILE_TYPE: | |
1037 | putc ('d', asmfile); | |
1038 | CHARS (1); | |
798d99ff | 1039 | dbxout_type (TREE_TYPE (type), 0, 0); |
15a5b8a2 RS |
1040 | break; |
1041 | ||
1042 | case COMPLEX_TYPE: | |
1043 | /* Differs from the REAL_TYPE by its new data type number */ | |
1044 | ||
1045 | if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE) | |
1046 | { | |
1047 | fprintf (asmfile, "r%d;%d;0;", | |
1048 | TYPE_SYMTAB_ADDRESS (type), | |
cdece1ef | 1049 | int_size_in_bytes (TREE_TYPE (type))); |
0e6bbe31 | 1050 | CHARS (15); /* The number is probably incorrect here. */ |
47cc012b RS |
1051 | } |
1052 | else | |
1053 | { | |
1054 | /* Output a complex integer type as a structure, | |
1055 | pending some other way to do it. */ | |
cdece1ef | 1056 | fprintf (asmfile, "s%d", int_size_in_bytes (type)); |
47cc012b RS |
1057 | |
1058 | fprintf (asmfile, "real:"); | |
1059 | CHARS (10); | |
1060 | dbxout_type (TREE_TYPE (type), 0, 0); | |
1061 | fprintf (asmfile, ",%d,%d;", | |
1062 | 0, TYPE_PRECISION (TREE_TYPE (type))); | |
1063 | CHARS (8); | |
1064 | fprintf (asmfile, "imag:"); | |
1065 | CHARS (5); | |
1066 | dbxout_type (TREE_TYPE (type), 0, 0); | |
1067 | fprintf (asmfile, ",%d,%d;;", | |
1068 | TYPE_PRECISION (TREE_TYPE (type)), | |
1069 | TYPE_PRECISION (TREE_TYPE (type))); | |
1070 | CHARS (9); | |
1071 | } | |
15a5b8a2 RS |
1072 | break; |
1073 | ||
1074 | case SET_TYPE: | |
1075 | putc ('S', asmfile); | |
1076 | CHARS (1); | |
798d99ff | 1077 | dbxout_type (TREE_TYPE (type), 0, 0); |
15a5b8a2 RS |
1078 | break; |
1079 | ||
00fe048c RS |
1080 | case ARRAY_TYPE: |
1081 | /* Output "a" followed by a range type definition | |
1082 | for the index type of the array | |
1083 | followed by a reference to the target-type. | |
b238f8de PB |
1084 | ar1;0;N;M for a C array of type M and size N+1. */ |
1085 | tem = TYPE_DOMAIN (type); | |
1086 | if (tem == NULL) | |
3f9bafd7 RS |
1087 | fprintf (asmfile, "ar%d;0;-1;", |
1088 | TYPE_SYMTAB_ADDRESS (integer_type_node)); | |
b238f8de PB |
1089 | else |
1090 | { | |
3f9bafd7 | 1091 | fprintf (asmfile, "a"); |
b238f8de PB |
1092 | dbxout_range_type (tem); |
1093 | } | |
00fe048c | 1094 | CHARS (17); |
3a7587e4 | 1095 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1096 | break; |
1097 | ||
1098 | case RECORD_TYPE: | |
1099 | case UNION_TYPE: | |
c1b98a95 | 1100 | case QUAL_UNION_TYPE: |
00fe048c RS |
1101 | { |
1102 | int i, n_baseclasses = 0; | |
1103 | ||
1104 | if (TYPE_BINFO (type) != 0 && TYPE_BINFO_BASETYPES (type) != 0) | |
1105 | n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type)); | |
1106 | ||
1107 | /* Output a structure type. */ | |
b372168c | 1108 | if ((TYPE_NAME (type) != 0 |
d938afd3 RS |
1109 | /* Long ago, Tiemann said this creates output that "confuses GDB". |
1110 | In April 93, mrs@cygnus.com said there is no such problem. | |
1111 | The type decls made automatically by struct specifiers | |
1112 | are marked with DECL_IGNORED_P in C++. */ | |
af0da0b8 | 1113 | #if 0 /* This creates output for anonymous classes which confuses GDB. */ |
b372168c MM |
1114 | && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL |
1115 | && DECL_IGNORED_P (TYPE_NAME (type))) | |
af0da0b8 | 1116 | #endif |
b372168c | 1117 | && !full) |
3a7587e4 RS |
1118 | || TYPE_SIZE (type) == 0 |
1119 | /* No way in DBX fmt to describe a variable size. */ | |
1120 | || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) | |
00fe048c RS |
1121 | { |
1122 | /* If the type is just a cross reference, output one | |
1123 | and mark the type as partially described. | |
1124 | If it later becomes defined, we will output | |
1125 | its real definition. | |
1126 | If the type has a name, don't nest its definition within | |
1127 | another type's definition; instead, output an xref | |
1128 | and let the definition come when the name is defined. */ | |
1129 | fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu"); | |
1130 | CHARS (3); | |
95f2ba07 | 1131 | #if 0 /* This assertion is legitimately false in C++. */ |
00fe048c RS |
1132 | /* We shouldn't be outputting a reference to a type before its |
1133 | definition unless the type has a tag name. | |
1134 | A typedef name without a tag name should be impossible. */ | |
1135 | if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE) | |
1136 | abort (); | |
1137 | #endif | |
35571e38 RS |
1138 | if (TYPE_NAME (type) != 0) |
1139 | dbxout_type_name (type); | |
1140 | else | |
1141 | fprintf (asmfile, "$$%d", anonymous_type_number++); | |
00fe048c RS |
1142 | fprintf (asmfile, ":"); |
1143 | typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF; | |
1144 | break; | |
1145 | } | |
00fe048c | 1146 | |
00fe048c RS |
1147 | /* Identify record or union, and print its size. */ |
1148 | fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d", | |
cdece1ef | 1149 | int_size_in_bytes (type)); |
00fe048c | 1150 | |
196cedd0 | 1151 | if (use_gnu_debug_info_extensions) |
00fe048c RS |
1152 | { |
1153 | if (n_baseclasses) | |
1154 | { | |
1155 | have_used_extensions = 1; | |
1156 | fprintf (asmfile, "!%d,", n_baseclasses); | |
1157 | CHARS (8); | |
1158 | } | |
1159 | } | |
1160 | for (i = 0; i < n_baseclasses; i++) | |
1161 | { | |
1162 | tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i); | |
196cedd0 | 1163 | if (use_gnu_debug_info_extensions) |
00fe048c RS |
1164 | { |
1165 | have_used_extensions = 1; | |
1166 | putc (TREE_VIA_VIRTUAL (child) ? '1' | |
1167 | : '0', | |
1168 | asmfile); | |
1169 | putc (TREE_VIA_PUBLIC (child) ? '2' | |
1170 | : '0', | |
1171 | asmfile); | |
1172 | fprintf (asmfile, "%d,", | |
1173 | TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT); | |
1174 | CHARS (15); | |
3a7587e4 | 1175 | dbxout_type (BINFO_TYPE (child), 0, 0); |
00fe048c RS |
1176 | putc (';', asmfile); |
1177 | } | |
1178 | else | |
1179 | { | |
1180 | /* Print out the base class information with fields | |
1181 | which have the same names at the types they hold. */ | |
1182 | dbxout_type_name (BINFO_TYPE (child)); | |
1183 | putc (':', asmfile); | |
3a7587e4 | 1184 | dbxout_type (BINFO_TYPE (child), full, 0); |
00fe048c RS |
1185 | fprintf (asmfile, ",%d,%d;", |
1186 | TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT, | |
1187 | TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT); | |
1188 | CHARS (20); | |
1189 | } | |
1190 | } | |
1191 | } | |
1192 | ||
1193 | CHARS (11); | |
1194 | ||
1195 | /* Write out the field declarations. */ | |
1196 | dbxout_type_fields (type); | |
196cedd0 | 1197 | if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE) |
00fe048c RS |
1198 | { |
1199 | have_used_extensions = 1; | |
1200 | dbxout_type_methods (type); | |
1201 | } | |
1202 | putc (';', asmfile); | |
1203 | ||
196cedd0 | 1204 | if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE |
00fe048c RS |
1205 | /* Avoid the ~ if we don't really need it--it confuses dbx. */ |
1206 | && TYPE_VFIELD (type)) | |
1207 | { | |
1208 | have_used_extensions = 1; | |
1209 | ||
1210 | /* Tell GDB+ that it may keep reading. */ | |
1211 | putc ('~', asmfile); | |
1212 | ||
1213 | /* We need to write out info about what field this class | |
1214 | uses as its "main" vtable pointer field, because if this | |
1215 | field is inherited from a base class, GDB cannot necessarily | |
1216 | figure out which field it's using in time. */ | |
1217 | if (TYPE_VFIELD (type)) | |
1218 | { | |
1219 | putc ('%', asmfile); | |
3a7587e4 | 1220 | dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0); |
00fe048c RS |
1221 | } |
1222 | putc (';', asmfile); | |
1223 | CHARS (3); | |
1224 | } | |
1225 | break; | |
1226 | ||
1227 | case ENUMERAL_TYPE: | |
1228 | if ((TYPE_NAME (type) != 0 && !full | |
1229 | && (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
1230 | && ! DECL_IGNORED_P (TYPE_NAME (type)))) | |
1231 | || TYPE_SIZE (type) == 0) | |
1232 | { | |
1233 | fprintf (asmfile, "xe"); | |
1234 | CHARS (3); | |
1235 | dbxout_type_name (type); | |
1236 | typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF; | |
1237 | fprintf (asmfile, ":"); | |
1238 | return; | |
1239 | } | |
01e2750c RS |
1240 | #ifdef DBX_OUTPUT_ENUM |
1241 | DBX_OUTPUT_ENUM (asmfile, type); | |
1242 | #else | |
00fe048c RS |
1243 | putc ('e', asmfile); |
1244 | CHARS (1); | |
1245 | for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem)) | |
1246 | { | |
1247 | fprintf (asmfile, "%s:%d,", IDENTIFIER_POINTER (TREE_PURPOSE (tem)), | |
1248 | TREE_INT_CST_LOW (TREE_VALUE (tem))); | |
1249 | CHARS (11 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem))); | |
1250 | if (TREE_CHAIN (tem) != 0) | |
1251 | CONTIN; | |
1252 | } | |
1253 | putc (';', asmfile); | |
1254 | CHARS (1); | |
01e2750c | 1255 | #endif |
00fe048c RS |
1256 | break; |
1257 | ||
1258 | case POINTER_TYPE: | |
1259 | putc ('*', asmfile); | |
1260 | CHARS (1); | |
3a7587e4 | 1261 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1262 | break; |
1263 | ||
1264 | case METHOD_TYPE: | |
196cedd0 | 1265 | if (use_gnu_debug_info_extensions) |
00fe048c RS |
1266 | { |
1267 | have_used_extensions = 1; | |
1268 | putc ('#', asmfile); | |
1269 | CHARS (1); | |
3a7587e4 | 1270 | if (flag_minimal_debug && !show_arg_types) |
00fe048c | 1271 | { |
3a7587e4 RS |
1272 | /* Normally, just output the return type. |
1273 | The argument types are encoded in the method name. */ | |
00fe048c | 1274 | putc ('#', asmfile); |
3a7587e4 | 1275 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1276 | putc (';', asmfile); |
1277 | CHARS (1); | |
1278 | } | |
1279 | else | |
1280 | { | |
f72aed24 | 1281 | /* When outputting destructors, we need to write |
3a7587e4 RS |
1282 | the argument types out longhand. */ |
1283 | dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0); | |
00fe048c RS |
1284 | putc (',', asmfile); |
1285 | CHARS (1); | |
3a7587e4 | 1286 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1287 | dbxout_args (TYPE_ARG_TYPES (type)); |
1288 | putc (';', asmfile); | |
1289 | CHARS (1); | |
1290 | } | |
1291 | } | |
1292 | else | |
1293 | { | |
1294 | /* Treat it as a function type. */ | |
3a7587e4 | 1295 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1296 | } |
1297 | break; | |
1298 | ||
1299 | case OFFSET_TYPE: | |
196cedd0 | 1300 | if (use_gnu_debug_info_extensions) |
00fe048c RS |
1301 | { |
1302 | have_used_extensions = 1; | |
1303 | putc ('@', asmfile); | |
1304 | CHARS (1); | |
3a7587e4 | 1305 | dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0); |
00fe048c RS |
1306 | putc (',', asmfile); |
1307 | CHARS (1); | |
3a7587e4 | 1308 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1309 | } |
1310 | else | |
1311 | { | |
1312 | /* Should print as an int, because it is really | |
1313 | just an offset. */ | |
3a7587e4 | 1314 | dbxout_type (integer_type_node, 0, 0); |
00fe048c RS |
1315 | } |
1316 | break; | |
1317 | ||
1318 | case REFERENCE_TYPE: | |
196cedd0 | 1319 | if (use_gnu_debug_info_extensions) |
00fe048c | 1320 | have_used_extensions = 1; |
196cedd0 | 1321 | putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile); |
00fe048c | 1322 | CHARS (1); |
3a7587e4 | 1323 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1324 | break; |
1325 | ||
1326 | case FUNCTION_TYPE: | |
1327 | putc ('f', asmfile); | |
1328 | CHARS (1); | |
3a7587e4 | 1329 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c RS |
1330 | break; |
1331 | ||
1332 | default: | |
1333 | abort (); | |
1334 | } | |
1335 | } | |
1336 | ||
1337 | /* Print the value of integer constant C, in octal, | |
1338 | handling double precision. */ | |
1339 | ||
1340 | static void | |
1341 | print_int_cst_octal (c) | |
1342 | tree c; | |
1343 | { | |
0d92cbff RK |
1344 | unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c); |
1345 | unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c); | |
1346 | int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3)); | |
00fe048c RS |
1347 | |
1348 | fprintf (asmfile, "0"); | |
1349 | ||
1350 | if (excess == 3) | |
1351 | { | |
0d92cbff RK |
1352 | print_octal (high, HOST_BITS_PER_WIDE_INT / 3); |
1353 | print_octal (low, HOST_BITS_PER_WIDE_INT / 3); | |
00fe048c RS |
1354 | } |
1355 | else | |
1356 | { | |
0d92cbff RK |
1357 | unsigned HOST_WIDE_INT beg = high >> excess; |
1358 | unsigned HOST_WIDE_INT middle | |
1359 | = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess) | |
1360 | | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3))); | |
1361 | unsigned HOST_WIDE_INT end | |
1362 | = low & (((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 3 * 3)) - 1); | |
00fe048c | 1363 | fprintf (asmfile, "%o%01o", beg, middle); |
0d92cbff | 1364 | print_octal (end, HOST_BITS_PER_WIDE_INT / 3); |
00fe048c RS |
1365 | } |
1366 | } | |
1367 | ||
1368 | static void | |
1369 | print_octal (value, digits) | |
0d92cbff | 1370 | unsigned HOST_WIDE_INT value; |
00fe048c RS |
1371 | int digits; |
1372 | { | |
1373 | int i; | |
1374 | ||
1375 | for (i = digits - 1; i >= 0; i--) | |
1376 | fprintf (asmfile, "%01o", ((value >> (3 * i)) & 7)); | |
1377 | } | |
1378 | ||
1379 | /* Output the name of type TYPE, with no punctuation. | |
1380 | Such names can be set up either by typedef declarations | |
1381 | or by struct, enum and union tags. */ | |
1382 | ||
1383 | static void | |
1384 | dbxout_type_name (type) | |
1385 | register tree type; | |
1386 | { | |
1387 | tree t; | |
1388 | if (TYPE_NAME (type) == 0) | |
1389 | abort (); | |
1390 | if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) | |
1391 | { | |
1392 | t = TYPE_NAME (type); | |
1393 | } | |
1394 | else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL) | |
1395 | { | |
1396 | t = DECL_NAME (TYPE_NAME (type)); | |
1397 | } | |
1398 | else | |
1399 | abort (); | |
1400 | ||
1401 | fprintf (asmfile, "%s", IDENTIFIER_POINTER (t)); | |
1402 | CHARS (IDENTIFIER_LENGTH (t)); | |
1403 | } | |
1404 | \f | |
1405 | /* Output a .stabs for the symbol defined by DECL, | |
1406 | which must be a ..._DECL node in the normal namespace. | |
1407 | It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL. | |
1408 | LOCAL is nonzero if the scope is less than the entire file. */ | |
1409 | ||
1410 | void | |
1411 | dbxout_symbol (decl, local) | |
1412 | tree decl; | |
1413 | int local; | |
1414 | { | |
1415 | int letter = 0; | |
1416 | tree type = TREE_TYPE (decl); | |
1417 | tree context = NULL_TREE; | |
1418 | int regno = -1; | |
1419 | ||
1420 | /* Cast avoids warning in old compilers. */ | |
1421 | current_sym_code = (STAB_CODE_TYPE) 0; | |
1422 | current_sym_value = 0; | |
1423 | current_sym_addr = 0; | |
1424 | ||
1425 | /* Ignore nameless syms, but don't ignore type tags. */ | |
1426 | ||
1427 | if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL) | |
1428 | || DECL_IGNORED_P (decl)) | |
1429 | return; | |
1430 | ||
1431 | dbxout_prepare_symbol (decl); | |
1432 | ||
1433 | /* The output will always start with the symbol name, | |
1434 | so always count that in the length-output-so-far. */ | |
1435 | ||
1436 | if (DECL_NAME (decl) != 0) | |
1437 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl)); | |
1438 | ||
1439 | switch (TREE_CODE (decl)) | |
1440 | { | |
1441 | case CONST_DECL: | |
1442 | /* Enum values are defined by defining the enum type. */ | |
1443 | break; | |
1444 | ||
1445 | case FUNCTION_DECL: | |
1446 | if (DECL_RTL (decl) == 0) | |
1447 | return; | |
0924ddef | 1448 | if (DECL_EXTERNAL (decl)) |
00fe048c RS |
1449 | break; |
1450 | /* Don't mention a nested function under its parent. */ | |
1451 | context = decl_function_context (decl); | |
1452 | if (context == current_function_decl) | |
1453 | break; | |
1454 | if (GET_CODE (DECL_RTL (decl)) != MEM | |
1455 | || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) | |
1456 | break; | |
1457 | FORCE_TEXT; | |
1458 | ||
1459 | fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, | |
1460 | IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), | |
1461 | TREE_PUBLIC (decl) ? 'F' : 'f'); | |
1462 | ||
1463 | current_sym_code = N_FUN; | |
1464 | current_sym_addr = XEXP (DECL_RTL (decl), 0); | |
1465 | ||
1466 | if (TREE_TYPE (type)) | |
3a7587e4 | 1467 | dbxout_type (TREE_TYPE (type), 0, 0); |
00fe048c | 1468 | else |
3a7587e4 | 1469 | dbxout_type (void_type_node, 0, 0); |
00fe048c RS |
1470 | |
1471 | /* For a nested function, when that function is compiled, | |
1472 | mention the containing function name | |
1473 | as well as (since dbx wants it) our own assembler-name. */ | |
1474 | if (context != 0) | |
1475 | fprintf (asmfile, ",%s,%s", | |
1476 | IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), | |
1477 | IDENTIFIER_POINTER (DECL_NAME (context))); | |
1478 | ||
1479 | dbxout_finish_symbol (decl); | |
1480 | break; | |
1481 | ||
1482 | case TYPE_DECL: | |
1483 | #if 0 | |
1484 | /* This seems all wrong. Outputting most kinds of types gives no name | |
1485 | at all. A true definition gives no name; a cross-ref for a | |
1486 | structure can give the tag name, but not a type name. | |
1487 | It seems that no typedef name is defined by outputting a type. */ | |
1488 | ||
1489 | /* If this typedef name was defined by outputting the type, | |
1490 | don't duplicate it. */ | |
1491 | if (typevec[TYPE_SYMTAB_ADDRESS (type)] == TYPE_DEFINED | |
1492 | && TYPE_NAME (TREE_TYPE (decl)) == decl) | |
1493 | return; | |
1494 | #endif | |
1495 | /* Don't output the same typedef twice. | |
1496 | And don't output what language-specific stuff doesn't want output. */ | |
1497 | if (TREE_ASM_WRITTEN (decl) || DECL_IGNORED_P (decl)) | |
1498 | return; | |
1499 | ||
1500 | FORCE_TEXT; | |
1501 | ||
a823f1d8 RS |
1502 | { |
1503 | int tag_needed = 1; | |
3b6c7a7d | 1504 | int did_output = 0; |
25bdb910 | 1505 | |
a823f1d8 RS |
1506 | if (DECL_NAME (decl)) |
1507 | { | |
1508 | /* Nonzero means we must output a tag as well as a typedef. */ | |
1509 | tag_needed = 0; | |
00fe048c | 1510 | |
edbe40ea RS |
1511 | /* Handle the case of a C++ structure or union |
1512 | where the TYPE_NAME is a TYPE_DECL | |
1513 | which gives both a typedef name and a tag. */ | |
bed7dc7a | 1514 | /* dbx requires the tag first and the typedef second. */ |
edbe40ea | 1515 | if ((TREE_CODE (type) == RECORD_TYPE |
c1b98a95 RK |
1516 | || TREE_CODE (type) == UNION_TYPE |
1517 | || TREE_CODE (type) == QUAL_UNION_TYPE) | |
edbe40ea | 1518 | && TYPE_NAME (type) == decl |
196cedd0 | 1519 | && !(use_gnu_debug_info_extensions && have_used_extensions) |
bed7dc7a RS |
1520 | && !TREE_ASM_WRITTEN (TYPE_NAME (type)) |
1521 | /* Distinguish the implicit typedefs of C++ | |
1522 | from explicit ones that might be found in C. */ | |
1523 | && DECL_SOURCE_LINE (decl) == 0) | |
edbe40ea RS |
1524 | { |
1525 | tree name = TYPE_NAME (type); | |
1526 | if (TREE_CODE (name) == TYPE_DECL) | |
1527 | name = DECL_NAME (name); | |
1528 | ||
1529 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; | |
1530 | current_sym_value = 0; | |
1531 | current_sym_addr = 0; | |
1532 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (name); | |
1533 | ||
1534 | fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP, | |
1535 | IDENTIFIER_POINTER (name)); | |
1536 | dbxout_type (type, 1, 0); | |
0d92cbff | 1537 | dbxout_finish_symbol (NULL_TREE); |
edbe40ea RS |
1538 | } |
1539 | ||
a823f1d8 RS |
1540 | /* Output typedef name. */ |
1541 | fprintf (asmfile, "%s \"%s:", ASM_STABS_OP, | |
1542 | IDENTIFIER_POINTER (DECL_NAME (decl))); | |
25bdb910 | 1543 | |
a823f1d8 RS |
1544 | /* Short cut way to output a tag also. */ |
1545 | if ((TREE_CODE (type) == RECORD_TYPE | |
c1b98a95 RK |
1546 | || TREE_CODE (type) == UNION_TYPE |
1547 | || TREE_CODE (type) == QUAL_UNION_TYPE) | |
a823f1d8 RS |
1548 | && TYPE_NAME (type) == decl) |
1549 | { | |
196cedd0 | 1550 | if (use_gnu_debug_info_extensions && have_used_extensions) |
a823f1d8 RS |
1551 | { |
1552 | putc ('T', asmfile); | |
1553 | TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1; | |
1554 | } | |
edbe40ea | 1555 | #if 0 /* Now we generate the tag for this case up above. */ |
a823f1d8 RS |
1556 | else |
1557 | tag_needed = 1; | |
edbe40ea | 1558 | #endif |
a823f1d8 | 1559 | } |
00fe048c | 1560 | |
a823f1d8 | 1561 | putc ('t', asmfile); |
01e2750c | 1562 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; |
25bdb910 | 1563 | |
a823f1d8 RS |
1564 | dbxout_type (type, 1, 0); |
1565 | dbxout_finish_symbol (decl); | |
3b6c7a7d | 1566 | did_output = 1; |
a823f1d8 | 1567 | } |
00fe048c | 1568 | |
98ed4b49 JW |
1569 | /* Don't output a tag if this is an incomplete type (TYPE_SIZE is |
1570 | zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */ | |
1571 | ||
1572 | if (tag_needed && TYPE_NAME (type) != 0 && TYPE_SIZE (type) != 0 | |
a823f1d8 RS |
1573 | && !TREE_ASM_WRITTEN (TYPE_NAME (type))) |
1574 | { | |
1575 | /* For a TYPE_DECL with no name, but the type has a name, | |
1576 | output a tag. | |
1577 | This is what represents `struct foo' with no typedef. */ | |
1578 | /* In C++, the name of a type is the corresponding typedef. | |
1579 | In C, it is an IDENTIFIER_NODE. */ | |
1580 | tree name = TYPE_NAME (type); | |
1581 | if (TREE_CODE (name) == TYPE_DECL) | |
1582 | name = DECL_NAME (name); | |
1583 | ||
01e2750c | 1584 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; |
a823f1d8 RS |
1585 | current_sym_value = 0; |
1586 | current_sym_addr = 0; | |
1587 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (name); | |
1588 | ||
1589 | fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP, | |
1590 | IDENTIFIER_POINTER (name)); | |
1591 | dbxout_type (type, 1, 0); | |
0d92cbff | 1592 | dbxout_finish_symbol (NULL_TREE); |
3b6c7a7d RS |
1593 | did_output = 1; |
1594 | } | |
1595 | ||
1596 | /* If an enum type has no name, it cannot be referred to, | |
1597 | but we must output it anyway, since the enumeration constants | |
1598 | can be referred to. */ | |
1599 | if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE) | |
1600 | { | |
1601 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; | |
1602 | current_sym_value = 0; | |
1603 | current_sym_addr = 0; | |
1604 | current_sym_nchars = 2; | |
1605 | ||
a63067c2 RS |
1606 | /* Some debuggers fail when given NULL names, so give this a |
1607 | harmless name of ` '. */ | |
1608 | fprintf (asmfile, "%s \" :T", ASM_STABS_OP); | |
3b6c7a7d RS |
1609 | dbxout_type (type, 1, 0); |
1610 | dbxout_finish_symbol (NULL_TREE); | |
a823f1d8 RS |
1611 | } |
1612 | ||
1613 | /* Prevent duplicate output of a typedef. */ | |
1614 | TREE_ASM_WRITTEN (decl) = 1; | |
1615 | break; | |
1616 | } | |
00fe048c RS |
1617 | |
1618 | case PARM_DECL: | |
1619 | /* Parm decls go in their own separate chains | |
1620 | and are output by dbxout_reg_parms and dbxout_parms. */ | |
1621 | abort (); | |
1622 | ||
1623 | case RESULT_DECL: | |
1624 | /* Named return value, treat like a VAR_DECL. */ | |
1625 | case VAR_DECL: | |
1626 | if (DECL_RTL (decl) == 0) | |
1627 | return; | |
1628 | /* Don't mention a variable that is external. | |
1629 | Let the file that defines it describe it. */ | |
0924ddef | 1630 | if (DECL_EXTERNAL (decl)) |
00fe048c RS |
1631 | break; |
1632 | ||
1633 | /* If the variable is really a constant | |
1634 | and not written in memory, inform the debugger. */ | |
1635 | if (TREE_STATIC (decl) && TREE_READONLY (decl) | |
1636 | && DECL_INITIAL (decl) != 0 | |
1637 | && ! TREE_ASM_WRITTEN (decl) | |
1638 | && (DECL_FIELD_CONTEXT (decl) == NULL_TREE | |
1639 | || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK)) | |
1640 | { | |
1641 | if (TREE_PUBLIC (decl) == 0) | |
1642 | { | |
1643 | /* The sun4 assembler does not grok this. */ | |
1644 | char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); | |
1645 | if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE | |
1646 | || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) | |
1647 | { | |
0d92cbff | 1648 | HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl)); |
00fe048c RS |
1649 | #ifdef DBX_OUTPUT_CONSTANT_SYMBOL |
1650 | DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival); | |
1651 | #else | |
1652 | fprintf (asmfile, "%s \"%s:c=i%d\",0x%x,0,0,0\n", | |
1653 | ASM_STABS_OP, name, ival, N_LSYM); | |
1654 | #endif | |
1655 | return; | |
1656 | } | |
1657 | else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE) | |
1658 | { | |
1659 | /* don't know how to do this yet. */ | |
1660 | } | |
1661 | break; | |
1662 | } | |
1663 | /* else it is something we handle like a normal variable. */ | |
1664 | } | |
1665 | ||
bece5e07 | 1666 | DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX); |
00fe048c RS |
1667 | #ifdef LEAF_REG_REMAP |
1668 | if (leaf_function) | |
1669 | leaf_renumber_regs_insn (DECL_RTL (decl)); | |
1670 | #endif | |
1671 | ||
47700802 RS |
1672 | dbxout_symbol_location (decl, type, 0, DECL_RTL (decl)); |
1673 | } | |
1674 | } | |
1675 | \f | |
1676 | /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL. | |
1677 | Add SUFFIX to its name, if SUFFIX is not 0. | |
1678 | Describe the variable as residing in HOME | |
1679 | (usually HOME is DECL_RTL (DECL), but not always). */ | |
1680 | ||
1681 | static void | |
1682 | dbxout_symbol_location (decl, type, suffix, home) | |
1683 | tree decl, type; | |
1684 | char *suffix; | |
1685 | rtx home; | |
1686 | { | |
1687 | int letter = 0; | |
1688 | int regno = -1; | |
00fe048c | 1689 | |
47700802 RS |
1690 | /* Don't mention a variable at all |
1691 | if it was completely optimized into nothingness. | |
1692 | ||
1693 | If the decl was from an inline function, then it's rtl | |
1694 | is not identically the rtl that was used in this | |
1695 | particular compilation. */ | |
1696 | if (GET_CODE (home) == REG) | |
1697 | { | |
1698 | regno = REGNO (home); | |
1699 | if (regno >= FIRST_PSEUDO_REGISTER) | |
1700 | return; | |
1701 | } | |
1702 | else if (GET_CODE (home) == SUBREG) | |
1703 | { | |
1704 | rtx value = home; | |
1705 | int offset = 0; | |
1706 | while (GET_CODE (value) == SUBREG) | |
1707 | { | |
1708 | offset += SUBREG_WORD (value); | |
1709 | value = SUBREG_REG (value); | |
1710 | } | |
1711 | if (GET_CODE (value) == REG) | |
00fe048c | 1712 | { |
47700802 | 1713 | regno = REGNO (value); |
00fe048c | 1714 | if (regno >= FIRST_PSEUDO_REGISTER) |
1527c38f | 1715 | return; |
47700802 | 1716 | regno += offset; |
00fe048c | 1717 | } |
47700802 RS |
1718 | alter_subreg (home); |
1719 | } | |
1720 | ||
1721 | /* The kind-of-variable letter depends on where | |
1722 | the variable is and on the scope of its name: | |
1723 | G and N_GSYM for static storage and global scope, | |
1724 | S for static storage and file scope, | |
1725 | V for static storage and local scope, | |
1726 | for those two, use N_LCSYM if data is in bss segment, | |
1727 | N_STSYM if in data segment, N_FUN otherwise. | |
1728 | (We used N_FUN originally, then changed to N_STSYM | |
1729 | to please GDB. However, it seems that confused ld. | |
1730 | Now GDB has been fixed to like N_FUN, says Kingdon.) | |
1731 | no letter at all, and N_LSYM, for auto variable, | |
1732 | r and N_RSYM for register variable. */ | |
1733 | ||
1734 | if (GET_CODE (home) == MEM | |
1735 | && GET_CODE (XEXP (home, 0)) == SYMBOL_REF) | |
1736 | { | |
1737 | if (TREE_PUBLIC (decl)) | |
00fe048c | 1738 | { |
47700802 RS |
1739 | letter = 'G'; |
1740 | current_sym_code = N_GSYM; | |
00fe048c | 1741 | } |
47700802 | 1742 | else |
00fe048c | 1743 | { |
47700802 | 1744 | current_sym_addr = XEXP (home, 0); |
00fe048c | 1745 | |
47700802 | 1746 | letter = decl_function_context (decl) ? 'V' : 'S'; |
00fe048c | 1747 | |
47700802 RS |
1748 | if (!DECL_INITIAL (decl)) |
1749 | current_sym_code = N_LCSYM; | |
1750 | else if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl)) | |
1751 | /* This is not quite right, but it's the closest | |
1752 | of all the codes that Unix defines. */ | |
1753 | current_sym_code = DBX_STATIC_CONST_VAR_CODE; | |
1754 | else | |
1755 | { | |
1756 | /* Ultrix `as' seems to need this. */ | |
00fe048c | 1757 | #ifdef DBX_STATIC_STAB_DATA_SECTION |
47700802 | 1758 | data_section (); |
00fe048c | 1759 | #endif |
47700802 | 1760 | current_sym_code = N_STSYM; |
00fe048c RS |
1761 | } |
1762 | } | |
47700802 RS |
1763 | } |
1764 | else if (regno >= 0) | |
1765 | { | |
1766 | letter = 'r'; | |
1767 | current_sym_code = N_RSYM; | |
1768 | current_sym_value = DBX_REGISTER_NUMBER (regno); | |
1769 | } | |
1770 | else if (GET_CODE (home) == MEM | |
1771 | && (GET_CODE (XEXP (home, 0)) == MEM | |
1772 | || (GET_CODE (XEXP (home, 0)) == REG | |
1773 | && REGNO (XEXP (home, 0)) != FRAME_POINTER_REGNUM))) | |
1774 | /* If the value is indirect by memory or by a register | |
1775 | that isn't the frame pointer | |
1776 | then it means the object is variable-sized and address through | |
1777 | that register or stack slot. DBX has no way to represent this | |
1778 | so all we can do is output the variable as a pointer. | |
1779 | If it's not a parameter, ignore it. | |
1780 | (VAR_DECLs like this can be made by integrate.c.) */ | |
1781 | { | |
1782 | if (GET_CODE (XEXP (home, 0)) == REG) | |
00fe048c RS |
1783 | { |
1784 | letter = 'r'; | |
1785 | current_sym_code = N_RSYM; | |
47700802 | 1786 | current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0))); |
00fe048c | 1787 | } |
47700802 | 1788 | else |
00fe048c RS |
1789 | { |
1790 | current_sym_code = N_LSYM; | |
47700802 | 1791 | /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))). |
00fe048c | 1792 | We want the value of that CONST_INT. */ |
47700802 RS |
1793 | current_sym_value |
1794 | = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0)); | |
b372168c | 1795 | } |
47700802 RS |
1796 | |
1797 | /* Effectively do build_pointer_type, but don't cache this type, | |
1798 | since it might be temporary whereas the type it points to | |
1799 | might have been saved for inlining. */ | |
1800 | /* Don't use REFERENCE_TYPE because dbx can't handle that. */ | |
1801 | type = make_node (POINTER_TYPE); | |
1802 | TREE_TYPE (type) = TREE_TYPE (decl); | |
1803 | } | |
1804 | else if (GET_CODE (home) == MEM | |
1805 | && GET_CODE (XEXP (home, 0)) == REG) | |
1806 | { | |
1807 | current_sym_code = N_LSYM; | |
1808 | current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0)); | |
1809 | } | |
1810 | else if (GET_CODE (home) == MEM | |
1811 | && GET_CODE (XEXP (home, 0)) == PLUS | |
1812 | && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT) | |
1813 | { | |
1814 | current_sym_code = N_LSYM; | |
1815 | /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...))) | |
1816 | We want the value of that CONST_INT. */ | |
1817 | current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0)); | |
1818 | } | |
1819 | else if (GET_CODE (home) == MEM | |
1820 | && GET_CODE (XEXP (home, 0)) == CONST) | |
1821 | { | |
1822 | /* Handle an obscure case which can arise when optimizing and | |
1823 | when there are few available registers. (This is *always* | |
1824 | the case for i386/i486 targets). The RTL looks like | |
1825 | (MEM (CONST ...)) even though this variable is a local `auto' | |
1826 | or a local `register' variable. In effect, what has happened | |
1827 | is that the reload pass has seen that all assignments and | |
1828 | references for one such a local variable can be replaced by | |
1829 | equivalent assignments and references to some static storage | |
1830 | variable, thereby avoiding the need for a register. In such | |
1831 | cases we're forced to lie to debuggers and tell them that | |
1832 | this variable was itself `static'. */ | |
1833 | current_sym_code = N_LCSYM; | |
1834 | letter = 'V'; | |
1835 | current_sym_addr = XEXP (XEXP (home, 0), 0); | |
1836 | } | |
1837 | else if (GET_CODE (home) == CONCAT) | |
1838 | { | |
1839 | tree subtype = TREE_TYPE (type); | |
1840 | ||
1841 | /* If the variable's storage is in two parts, | |
1842 | output each as a separate stab with a modified name. */ | |
1843 | if (WORDS_BIG_ENDIAN) | |
1844 | dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0)); | |
00fe048c | 1845 | else |
47700802 | 1846 | dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0)); |
00fe048c | 1847 | |
47700802 RS |
1848 | /* Cast avoids warning in old compilers. */ |
1849 | current_sym_code = (STAB_CODE_TYPE) 0; | |
1850 | current_sym_value = 0; | |
1851 | current_sym_addr = 0; | |
1852 | dbxout_prepare_symbol (decl); | |
1853 | ||
1854 | if (WORDS_BIG_ENDIAN) | |
1855 | dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1)); | |
1856 | else | |
1857 | dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1)); | |
1858 | return; | |
1859 | } | |
1860 | else | |
1861 | /* Address might be a MEM, when DECL is a variable-sized object. | |
1862 | Or it might be const0_rtx, meaning previous passes | |
1863 | want us to ignore this variable. */ | |
1864 | return; | |
1865 | ||
1866 | /* Ok, start a symtab entry and output the variable name. */ | |
1867 | FORCE_TEXT; | |
b372168c MM |
1868 | |
1869 | #ifdef DBX_STATIC_BLOCK_START | |
47700802 | 1870 | DBX_STATIC_BLOCK_START (asmfile, current_sym_code); |
b372168c MM |
1871 | #endif |
1872 | ||
47700802 RS |
1873 | dbxout_symbol_name (decl, suffix, letter); |
1874 | dbxout_type (type, 0, 0); | |
1875 | dbxout_finish_symbol (decl); | |
b372168c MM |
1876 | |
1877 | #ifdef DBX_STATIC_BLOCK_END | |
47700802 | 1878 | DBX_STATIC_BLOCK_END (asmfile, current_sym_code); |
b372168c | 1879 | #endif |
47700802 RS |
1880 | } |
1881 | \f | |
1882 | /* Output the symbol name of DECL for a stabs, with suffix SUFFIX. | |
1883 | Then output LETTER to indicate the kind of location the symbol has. */ | |
1884 | ||
1885 | static void | |
1886 | dbxout_symbol_name (decl, suffix, letter) | |
1887 | tree decl; | |
1888 | char *suffix; | |
1889 | int letter; | |
1890 | { | |
1891 | /* One slight hitch: if this is a VAR_DECL which is a static | |
1892 | class member, we must put out the mangled name instead of the | |
1893 | DECL_NAME. */ | |
1894 | ||
1895 | char *name; | |
1896 | /* Note also that static member (variable) names DO NOT begin | |
1897 | with underscores in .stabs directives. */ | |
1898 | if (DECL_LANG_SPECIFIC (decl)) | |
1899 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
1900 | else | |
1901 | name = IDENTIFIER_POINTER (DECL_NAME (decl)); | |
1902 | if (name == 0) | |
1903 | name = "(anon)"; | |
1904 | fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name, | |
1905 | (suffix ? suffix : "")); | |
1906 | ||
1907 | if (letter) putc (letter, asmfile); | |
00fe048c RS |
1908 | } |
1909 | ||
1910 | static void | |
1911 | dbxout_prepare_symbol (decl) | |
1912 | tree decl; | |
1913 | { | |
1914 | #ifdef WINNING_GDB | |
1915 | char *filename = DECL_SOURCE_FILE (decl); | |
1916 | ||
1917 | dbxout_source_file (asmfile, filename); | |
1918 | #endif | |
1919 | } | |
1920 | ||
1921 | static void | |
1922 | dbxout_finish_symbol (sym) | |
1923 | tree sym; | |
1924 | { | |
b372168c MM |
1925 | #ifdef DBX_FINISH_SYMBOL |
1926 | DBX_FINISH_SYMBOL (sym); | |
1927 | #else | |
00fe048c | 1928 | int line = 0; |
fcf956c0 | 1929 | if (use_gnu_debug_info_extensions && sym != 0) |
00fe048c | 1930 | line = DECL_SOURCE_LINE (sym); |
b372168c | 1931 | |
00fe048c RS |
1932 | fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line); |
1933 | if (current_sym_addr) | |
1934 | output_addr_const (asmfile, current_sym_addr); | |
1935 | else | |
1936 | fprintf (asmfile, "%d", current_sym_value); | |
1937 | putc ('\n', asmfile); | |
b372168c | 1938 | #endif |
00fe048c RS |
1939 | } |
1940 | ||
1941 | /* Output definitions of all the decls in a chain. */ | |
1942 | ||
b372168c | 1943 | void |
00fe048c RS |
1944 | dbxout_syms (syms) |
1945 | tree syms; | |
1946 | { | |
1947 | while (syms) | |
1948 | { | |
1949 | dbxout_symbol (syms, 1); | |
1950 | syms = TREE_CHAIN (syms); | |
1951 | } | |
1952 | } | |
1953 | \f | |
1954 | /* The following two functions output definitions of function parameters. | |
1955 | Each parameter gets a definition locating it in the parameter list. | |
1956 | Each parameter that is a register variable gets a second definition | |
1957 | locating it in the register. | |
1958 | ||
1959 | Printing or argument lists in gdb uses the definitions that | |
1960 | locate in the parameter list. But reference to the variable in | |
1961 | expressions uses preferentially the definition as a register. */ | |
1962 | ||
1963 | /* Output definitions, referring to storage in the parmlist, | |
1964 | of all the parms in PARMS, which is a chain of PARM_DECL nodes. */ | |
1965 | ||
b372168c | 1966 | void |
00fe048c RS |
1967 | dbxout_parms (parms) |
1968 | tree parms; | |
1969 | { | |
1970 | for (; parms; parms = TREE_CHAIN (parms)) | |
1971 | if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node) | |
1972 | { | |
1973 | dbxout_prepare_symbol (parms); | |
1974 | ||
1975 | /* Perform any necessary register eliminations on the parameter's rtl, | |
1976 | so that the debugging output will be accurate. */ | |
1977 | DECL_INCOMING_RTL (parms) | |
0d92cbff RK |
1978 | = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX); |
1979 | DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX); | |
00fe048c RS |
1980 | #ifdef LEAF_REG_REMAP |
1981 | if (leaf_function) | |
1982 | { | |
1983 | leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms)); | |
1984 | leaf_renumber_regs_insn (DECL_RTL (parms)); | |
1985 | } | |
1986 | #endif | |
1987 | ||
1988 | if (PARM_PASSED_IN_MEMORY (parms)) | |
1989 | { | |
1990 | rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0); | |
1991 | ||
1992 | /* ??? Here we assume that the parm address is indexed | |
1993 | off the frame pointer or arg pointer. | |
1994 | If that is not true, we produce meaningless results, | |
1995 | but do not crash. */ | |
1996 | if (GET_CODE (addr) == PLUS | |
1997 | && GET_CODE (XEXP (addr, 1)) == CONST_INT) | |
1998 | current_sym_value = INTVAL (XEXP (addr, 1)); | |
1999 | else | |
2000 | current_sym_value = 0; | |
2001 | ||
2002 | current_sym_code = N_PSYM; | |
2003 | current_sym_addr = 0; | |
2004 | ||
2005 | FORCE_TEXT; | |
2006 | if (DECL_NAME (parms)) | |
2007 | { | |
2008 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); | |
2009 | ||
01e2750c RS |
2010 | fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, |
2011 | IDENTIFIER_POINTER (DECL_NAME (parms)), | |
2012 | DBX_MEMPARM_STABS_LETTER); | |
00fe048c RS |
2013 | } |
2014 | else | |
2015 | { | |
2016 | current_sym_nchars = 8; | |
01e2750c RS |
2017 | fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, |
2018 | DBX_MEMPARM_STABS_LETTER); | |
00fe048c RS |
2019 | } |
2020 | ||
2021 | if (GET_CODE (DECL_RTL (parms)) == REG | |
2022 | && REGNO (DECL_RTL (parms)) >= 0 | |
2023 | && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) | |
3a7587e4 | 2024 | dbxout_type (DECL_ARG_TYPE (parms), 0, 0); |
00fe048c RS |
2025 | else |
2026 | { | |
2027 | int original_value = current_sym_value; | |
2028 | ||
2029 | /* This is the case where the parm is passed as an int or double | |
2030 | and it is converted to a char, short or float and stored back | |
2031 | in the parmlist. In this case, describe the parm | |
2032 | with the variable's declared type, and adjust the address | |
2033 | if the least significant bytes (which we are using) are not | |
2034 | the first ones. */ | |
2035 | #if BYTES_BIG_ENDIAN | |
2036 | if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) | |
2037 | current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) | |
2038 | - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); | |
2039 | #endif | |
2040 | ||
2041 | if (GET_CODE (DECL_RTL (parms)) == MEM | |
2042 | && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS | |
2043 | && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT | |
2044 | && INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == current_sym_value) | |
3a7587e4 | 2045 | dbxout_type (TREE_TYPE (parms), 0, 0); |
00fe048c RS |
2046 | else |
2047 | { | |
2048 | current_sym_value = original_value; | |
3a7587e4 | 2049 | dbxout_type (DECL_ARG_TYPE (parms), 0, 0); |
00fe048c RS |
2050 | } |
2051 | } | |
2052 | current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr); | |
2053 | dbxout_finish_symbol (parms); | |
2054 | } | |
2055 | else if (GET_CODE (DECL_RTL (parms)) == REG) | |
2056 | { | |
2057 | rtx best_rtl; | |
b372168c | 2058 | char regparm_letter; |
00fe048c RS |
2059 | /* Parm passed in registers and lives in registers or nowhere. */ |
2060 | ||
b372168c MM |
2061 | current_sym_code = DBX_REGPARM_STABS_CODE; |
2062 | regparm_letter = DBX_REGPARM_STABS_LETTER; | |
00fe048c RS |
2063 | current_sym_addr = 0; |
2064 | ||
2065 | /* If parm lives in a register, use that register; | |
2066 | pretend the parm was passed there. It would be more consistent | |
2067 | to describe the register where the parm was passed, | |
2068 | but in practice that register usually holds something else. */ | |
2069 | if (REGNO (DECL_RTL (parms)) >= 0 | |
2070 | && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) | |
2071 | best_rtl = DECL_RTL (parms); | |
2072 | /* If the parm lives nowhere, | |
2073 | use the register where it was passed. */ | |
2074 | else | |
2075 | best_rtl = DECL_INCOMING_RTL (parms); | |
2076 | current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl)); | |
2077 | ||
2078 | FORCE_TEXT; | |
2079 | if (DECL_NAME (parms)) | |
2080 | { | |
2081 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); | |
b372168c MM |
2082 | fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, |
2083 | IDENTIFIER_POINTER (DECL_NAME (parms)), | |
2084 | regparm_letter); | |
00fe048c RS |
2085 | } |
2086 | else | |
2087 | { | |
2088 | current_sym_nchars = 8; | |
b372168c MM |
2089 | fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, |
2090 | regparm_letter); | |
00fe048c RS |
2091 | } |
2092 | ||
3a7587e4 | 2093 | dbxout_type (DECL_ARG_TYPE (parms), 0, 0); |
00fe048c RS |
2094 | dbxout_finish_symbol (parms); |
2095 | } | |
dad0145a | 2096 | else if (GET_CODE (DECL_RTL (parms)) == MEM |
4ee194ec RS |
2097 | && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG) |
2098 | /* && rtx_equal_p (XEXP (DECL_RTL (parms), 0), | |
2099 | DECL_INCOMING_RTL (parms))) */ | |
dad0145a RS |
2100 | { |
2101 | /* Parm was passed via invisible reference. | |
2102 | That is, its address was passed in a register. | |
2103 | Output it as if it lived in that register. | |
2104 | The debugger will know from the type | |
2105 | that it was actually passed by invisible reference. */ | |
2106 | ||
2107 | char regparm_letter; | |
2108 | /* Parm passed in registers and lives in registers or nowhere. */ | |
2109 | ||
2110 | current_sym_code = DBX_REGPARM_STABS_CODE; | |
2111 | regparm_letter = DBX_REGPARM_STABS_LETTER; | |
2112 | ||
2113 | /* DECL_RTL looks like (MEM (REG...). Get the register number. */ | |
2114 | current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0)); | |
2115 | current_sym_addr = 0; | |
2116 | ||
2117 | FORCE_TEXT; | |
2118 | if (DECL_NAME (parms)) | |
2119 | { | |
2120 | current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms))); | |
2121 | ||
2122 | fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, | |
2123 | IDENTIFIER_POINTER (DECL_NAME (parms)), | |
2124 | DBX_REGPARM_STABS_LETTER); | |
2125 | } | |
2126 | else | |
2127 | { | |
2128 | current_sym_nchars = 8; | |
2129 | fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, | |
2130 | DBX_REGPARM_STABS_LETTER); | |
2131 | } | |
2132 | ||
2133 | dbxout_type (TREE_TYPE (parms), 0, 0); | |
2134 | dbxout_finish_symbol (parms); | |
2135 | } | |
00fe048c | 2136 | else if (GET_CODE (DECL_RTL (parms)) == MEM |
8d291181 RS |
2137 | && XEXP (DECL_RTL (parms), 0) != const0_rtx |
2138 | /* ??? A constant address for a parm can happen | |
2139 | when the reg it lives in is equiv to a constant in memory. | |
2140 | Should make this not happen, after 2.4. */ | |
2141 | && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0))) | |
00fe048c RS |
2142 | { |
2143 | /* Parm was passed in registers but lives on the stack. */ | |
2144 | ||
2145 | current_sym_code = N_PSYM; | |
2146 | /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))), | |
2147 | in which case we want the value of that CONST_INT, | |
2148 | or (MEM (REG ...)) or (MEM (MEM ...)), | |
2149 | in which case we use a value of zero. */ | |
2150 | if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG | |
2151 | || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM) | |
2152 | current_sym_value = 0; | |
2153 | else | |
2154 | current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)); | |
2155 | current_sym_addr = 0; | |
2156 | ||
2157 | FORCE_TEXT; | |
2158 | if (DECL_NAME (parms)) | |
2159 | { | |
2160 | current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms))); | |
2161 | ||
01e2750c RS |
2162 | fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, |
2163 | IDENTIFIER_POINTER (DECL_NAME (parms)), | |
2164 | DBX_MEMPARM_STABS_LETTER); | |
00fe048c RS |
2165 | } |
2166 | else | |
2167 | { | |
2168 | current_sym_nchars = 8; | |
01e2750c RS |
2169 | fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, |
2170 | DBX_MEMPARM_STABS_LETTER); | |
00fe048c RS |
2171 | } |
2172 | ||
2173 | current_sym_value | |
2174 | = DEBUGGER_ARG_OFFSET (current_sym_value, | |
2175 | XEXP (DECL_RTL (parms), 0)); | |
3a7587e4 | 2176 | dbxout_type (TREE_TYPE (parms), 0, 0); |
00fe048c RS |
2177 | dbxout_finish_symbol (parms); |
2178 | } | |
2179 | } | |
2180 | } | |
2181 | ||
2182 | /* Output definitions for the places where parms live during the function, | |
2183 | when different from where they were passed, when the parms were passed | |
2184 | in memory. | |
2185 | ||
2186 | It is not useful to do this for parms passed in registers | |
2187 | that live during the function in different registers, because it is | |
2188 | impossible to look in the passed register for the passed value, | |
2189 | so we use the within-the-function register to begin with. | |
2190 | ||
2191 | PARMS is a chain of PARM_DECL nodes. */ | |
2192 | ||
b372168c | 2193 | void |
00fe048c RS |
2194 | dbxout_reg_parms (parms) |
2195 | tree parms; | |
2196 | { | |
2197 | for (; parms; parms = TREE_CHAIN (parms)) | |
2198 | if (DECL_NAME (parms)) | |
2199 | { | |
2200 | dbxout_prepare_symbol (parms); | |
2201 | ||
2202 | /* Report parms that live in registers during the function | |
2203 | but were passed in memory. */ | |
2204 | if (GET_CODE (DECL_RTL (parms)) == REG | |
2205 | && REGNO (DECL_RTL (parms)) >= 0 | |
2206 | && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER | |
2207 | && PARM_PASSED_IN_MEMORY (parms)) | |
47700802 RS |
2208 | dbxout_symbol_location (parms, TREE_TYPE (parms), |
2209 | 0, DECL_RTL (parms)); | |
2210 | else if (GET_CODE (DECL_RTL (parms)) == CONCAT | |
2211 | && PARM_PASSED_IN_MEMORY (parms)) | |
2212 | dbxout_symbol_location (parms, TREE_TYPE (parms), | |
2213 | 0, DECL_RTL (parms)); | |
00fe048c RS |
2214 | /* Report parms that live in memory but not where they were passed. */ |
2215 | else if (GET_CODE (DECL_RTL (parms)) == MEM | |
2216 | && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS | |
2217 | && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT | |
2218 | && PARM_PASSED_IN_MEMORY (parms) | |
2219 | && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms))) | |
2220 | { | |
2221 | #if 0 /* ??? It is not clear yet what should replace this. */ | |
2222 | int offset = DECL_OFFSET (parms) / BITS_PER_UNIT; | |
2223 | /* A parm declared char is really passed as an int, | |
2224 | so it occupies the least significant bytes. | |
2225 | On a big-endian machine those are not the low-numbered ones. */ | |
2226 | #if BYTES_BIG_ENDIAN | |
2227 | if (offset != -1 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms)) | |
2228 | offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms))) | |
2229 | - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))); | |
2230 | #endif | |
2231 | if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...} | |
2232 | #endif | |
47700802 RS |
2233 | dbxout_symbol_location (parms, TREE_TYPE (parms), |
2234 | 0, DECL_RTL (parms)); | |
00fe048c | 2235 | } |
4ee194ec RS |
2236 | #if 0 |
2237 | else if (GET_CODE (DECL_RTL (parms)) == MEM | |
2238 | && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG) | |
2239 | { | |
2240 | /* Parm was passed via invisible reference. | |
2241 | That is, its address was passed in a register. | |
2242 | Output it as if it lived in that register. | |
2243 | The debugger will know from the type | |
2244 | that it was actually passed by invisible reference. */ | |
2245 | ||
2246 | current_sym_code = N_RSYM; | |
2247 | ||
2248 | /* DECL_RTL looks like (MEM (REG...). Get the register number. */ | |
2249 | current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0)); | |
2250 | current_sym_addr = 0; | |
2251 | ||
2252 | FORCE_TEXT; | |
2253 | if (DECL_NAME (parms)) | |
2254 | { | |
2255 | current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms))); | |
2256 | ||
2257 | fprintf (asmfile, "%s \"%s:r", ASM_STABS_OP, | |
2258 | IDENTIFIER_POINTER (DECL_NAME (parms))); | |
2259 | } | |
2260 | else | |
2261 | { | |
2262 | current_sym_nchars = 8; | |
2263 | fprintf (asmfile, "%s \"(anon):r", ASM_STABS_OP); | |
2264 | } | |
2265 | ||
2266 | dbxout_type (TREE_TYPE (parms), 0, 0); | |
2267 | dbxout_finish_symbol (parms); | |
2268 | } | |
2269 | #endif | |
00fe048c RS |
2270 | } |
2271 | } | |
2272 | \f | |
2273 | /* Given a chain of ..._TYPE nodes (as come in a parameter list), | |
2274 | output definitions of those names, in raw form */ | |
2275 | ||
2276 | void | |
2277 | dbxout_args (args) | |
2278 | tree args; | |
2279 | { | |
2280 | while (args) | |
2281 | { | |
2282 | putc (',', asmfile); | |
3a7587e4 | 2283 | dbxout_type (TREE_VALUE (args), 0, 0); |
00fe048c RS |
2284 | CHARS (1); |
2285 | args = TREE_CHAIN (args); | |
2286 | } | |
2287 | } | |
2288 | \f | |
2289 | /* Given a chain of ..._TYPE nodes, | |
2290 | find those which have typedef names and output those names. | |
2291 | This is to ensure those types get output. */ | |
2292 | ||
2293 | void | |
2294 | dbxout_types (types) | |
2295 | register tree types; | |
2296 | { | |
2297 | while (types) | |
2298 | { | |
2299 | if (TYPE_NAME (types) | |
2300 | && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL | |
2301 | && ! TREE_ASM_WRITTEN (TYPE_NAME (types))) | |
2302 | dbxout_symbol (TYPE_NAME (types), 1); | |
2303 | types = TREE_CHAIN (types); | |
2304 | } | |
2305 | } | |
2306 | \f | |
2307 | /* Output everything about a symbol block (a BLOCK node | |
2308 | that represents a scope level), | |
2309 | including recursive output of contained blocks. | |
2310 | ||
2311 | BLOCK is the BLOCK node. | |
2312 | DEPTH is its depth within containing symbol blocks. | |
2313 | ARGS is usually zero; but for the outermost block of the | |
2314 | body of a function, it is a chain of PARM_DECLs for the function parameters. | |
2315 | We output definitions of all the register parms | |
2316 | as if they were local variables of that block. | |
2317 | ||
2318 | If -g1 was used, we count blocks just the same, but output nothing | |
2319 | except for the outermost block. | |
2320 | ||
2321 | Actually, BLOCK may be several blocks chained together. | |
2322 | We handle them all in sequence. */ | |
2323 | ||
2324 | static void | |
2325 | dbxout_block (block, depth, args) | |
2326 | register tree block; | |
2327 | int depth; | |
2328 | tree args; | |
2329 | { | |
2330 | int blocknum; | |
2331 | ||
2332 | while (block) | |
2333 | { | |
2334 | /* Ignore blocks never expanded or otherwise marked as real. */ | |
2335 | if (TREE_USED (block)) | |
2336 | { | |
2337 | #ifndef DBX_LBRAC_FIRST | |
2338 | /* In dbx format, the syms of a block come before the N_LBRAC. */ | |
2339 | if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0) | |
2340 | dbxout_syms (BLOCK_VARS (block)); | |
2341 | if (args) | |
2342 | dbxout_reg_parms (args); | |
2343 | #endif | |
2344 | ||
2345 | /* Now output an N_LBRAC symbol to represent the beginning of | |
2346 | the block. Use the block's tree-walk order to generate | |
2347 | the assembler symbols LBBn and LBEn | |
2348 | that final will define around the code in this block. */ | |
2349 | if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE) | |
2350 | { | |
2351 | char buf[20]; | |
2352 | blocknum = next_block_number++; | |
2353 | ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum); | |
2354 | ||
2355 | if (BLOCK_HANDLER_BLOCK (block)) | |
2356 | { | |
2357 | /* A catch block. Must precede N_LBRAC. */ | |
2358 | tree decl = BLOCK_VARS (block); | |
2359 | while (decl) | |
2360 | { | |
2361 | #ifdef DBX_OUTPUT_CATCH | |
2362 | DBX_OUTPUT_CATCH (asmfile, decl, buf); | |
2363 | #else | |
b372168c | 2364 | fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP, |
00fe048c RS |
2365 | IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH); |
2366 | assemble_name (asmfile, buf); | |
2367 | fprintf (asmfile, "\n"); | |
2368 | #endif | |
2369 | decl = TREE_CHAIN (decl); | |
2370 | } | |
2371 | } | |
2372 | ||
01e2750c RS |
2373 | #ifdef DBX_OUTPUT_LBRAC |
2374 | DBX_OUTPUT_LBRAC (asmfile, buf); | |
2375 | #else | |
00fe048c RS |
2376 | fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC); |
2377 | assemble_name (asmfile, buf); | |
01571284 RS |
2378 | #if DBX_BLOCKS_FUNCTION_RELATIVE |
2379 | fputc ('-', asmfile); | |
ce343979 | 2380 | assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); |
01571284 | 2381 | #endif |
00fe048c | 2382 | fprintf (asmfile, "\n"); |
01e2750c | 2383 | #endif |
00fe048c RS |
2384 | } |
2385 | else if (depth > 0) | |
2386 | /* Count blocks the same way regardless of debug_info_level. */ | |
2387 | next_block_number++; | |
2388 | ||
2389 | #ifdef DBX_LBRAC_FIRST | |
2390 | /* On some weird machines, the syms of a block | |
2391 | come after the N_LBRAC. */ | |
2392 | if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0) | |
2393 | dbxout_syms (BLOCK_VARS (block)); | |
2394 | if (args) | |
2395 | dbxout_reg_parms (args); | |
2396 | #endif | |
2397 | ||
2398 | /* Output the subblocks. */ | |
0d92cbff | 2399 | dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE); |
00fe048c RS |
2400 | |
2401 | /* Refer to the marker for the end of the block. */ | |
2402 | if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE) | |
2403 | { | |
2404 | char buf[20]; | |
2405 | ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum); | |
01e2750c RS |
2406 | #ifdef DBX_OUTPUT_RBRAC |
2407 | DBX_OUTPUT_RBRAC (asmfile, buf); | |
2408 | #else | |
00fe048c RS |
2409 | fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC); |
2410 | assemble_name (asmfile, buf); | |
01571284 RS |
2411 | #if DBX_BLOCKS_FUNCTION_RELATIVE |
2412 | fputc ('-', asmfile); | |
ce343979 | 2413 | assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); |
01571284 | 2414 | #endif |
00fe048c | 2415 | fprintf (asmfile, "\n"); |
01e2750c | 2416 | #endif |
00fe048c RS |
2417 | } |
2418 | } | |
2419 | block = BLOCK_CHAIN (block); | |
2420 | } | |
2421 | } | |
2422 | ||
2423 | /* Output the information about a function and its arguments and result. | |
2424 | Usually this follows the function's code, | |
2425 | but on some systems, it comes before. */ | |
2426 | ||
2427 | static void | |
2428 | dbxout_really_begin_function (decl) | |
2429 | tree decl; | |
2430 | { | |
2431 | dbxout_symbol (decl, 0); | |
2432 | dbxout_parms (DECL_ARGUMENTS (decl)); | |
2433 | if (DECL_NAME (DECL_RESULT (decl)) != 0) | |
2434 | dbxout_symbol (DECL_RESULT (decl), 1); | |
2435 | } | |
2436 | ||
2437 | /* Called at beginning of output of function definition. */ | |
2438 | ||
2439 | void | |
2440 | dbxout_begin_function (decl) | |
2441 | tree decl; | |
2442 | { | |
2443 | #ifdef DBX_FUNCTION_FIRST | |
2444 | dbxout_really_begin_function (decl); | |
2445 | #endif | |
2446 | } | |
2447 | ||
2448 | /* Output dbx data for a function definition. | |
2449 | This includes a definition of the function name itself (a symbol), | |
2450 | definitions of the parameters (locating them in the parameter list) | |
2451 | and then output the block that makes up the function's body | |
2452 | (including all the auto variables of the function). */ | |
2453 | ||
2454 | void | |
2455 | dbxout_function (decl) | |
2456 | tree decl; | |
2457 | { | |
2458 | #ifndef DBX_FUNCTION_FIRST | |
2459 | dbxout_really_begin_function (decl); | |
2460 | #endif | |
2461 | dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl)); | |
2462 | #ifdef DBX_OUTPUT_FUNCTION_END | |
2463 | DBX_OUTPUT_FUNCTION_END (asmfile, decl); | |
2464 | #endif | |
2465 | } | |
00fe048c | 2466 | #endif /* DBX_DEBUGGING_INFO */ |