]>
Commit | Line | Data |
---|---|---|
946754ae | 1 | /* Output dbx-format symbol table information from GNU compiler. |
ddca3e9d | 2 | Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
cd3034ab | 3 | 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
946754ae | 4 | |
f12b58b3 | 5 | This file is part of GCC. |
946754ae | 6 | |
f12b58b3 | 7 | GCC is free software; you can redistribute it and/or modify it under |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 2, or (at your option) any later | |
10 | version. | |
946754ae | 11 | |
f12b58b3 | 12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
946754ae | 16 | |
17 | You should have received a copy of the GNU General Public License | |
f12b58b3 | 18 | along with GCC; see the file COPYING. If not, write to the Free |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
946754ae | 21 | |
22 | ||
23 | /* Output dbx-format symbol table data. | |
24 | This consists of many symbol table entries, each of them | |
25 | a .stabs assembler pseudo-op with four operands: | |
26 | a "name" which is really a description of one symbol and its type, | |
27 | a "code", which is a symbol defined in stab.h whose name starts with N_, | |
28 | an unused operand always 0, | |
29 | and a "value" which is an address or an offset. | |
30 | The name is enclosed in doublequote characters. | |
31 | ||
32 | Each function, variable, typedef, and structure tag | |
33 | has a symbol table entry to define it. | |
34 | The beginning and end of each level of name scoping within | |
35 | a function are also marked by special symbol table entries. | |
36 | ||
37 | The "name" consists of the symbol name, a colon, a kind-of-symbol letter, | |
38 | and a data type number. The data type number may be followed by | |
39 | "=" and a type definition; normally this will happen the first time | |
40 | the type number is mentioned. The type definition may refer to | |
41 | other types by number, and those type numbers may be followed | |
42 | by "=" and nested definitions. | |
43 | ||
44 | This can make the "name" quite long. | |
45 | When a name is more than 80 characters, we split the .stabs pseudo-op | |
46 | into two .stabs pseudo-ops, both sharing the same "code" and "value". | |
47 | The first one is marked as continued with a double-backslash at the | |
48 | end of its "name". | |
49 | ||
50 | The kind-of-symbol letter distinguished function names from global | |
51 | variables from file-scope variables from parameters from auto | |
52 | variables in memory from typedef names from register variables. | |
53 | See `dbxout_symbol'. | |
54 | ||
55 | The "code" is mostly redundant with the kind-of-symbol letter | |
56 | that goes in the "name", but not entirely: for symbols located | |
57 | in static storage, the "code" says which segment the address is in, | |
58 | which controls how it is relocated. | |
59 | ||
60 | The "value" for a symbol in static storage | |
61 | is the core address of the symbol (actually, the assembler | |
62 | label for the symbol). For a symbol located in a stack slot | |
63 | it is the stack offset; for one in a register, the register number. | |
64 | For a typedef symbol, it is zero. | |
65 | ||
66 | If DEBUG_SYMS_TEXT is defined, all debugging symbols must be | |
67 | output while in the text section. | |
68 | ||
69 | For more on data type definitions, see `dbxout_type'. */ | |
70 | ||
0dbd1c74 | 71 | #include "config.h" |
405711de | 72 | #include "system.h" |
805e22b2 | 73 | #include "coretypes.h" |
74 | #include "tm.h" | |
3ef9782d | 75 | |
946754ae | 76 | #include "tree.h" |
77 | #include "rtl.h" | |
78 | #include "flags.h" | |
79 | #include "regs.h" | |
80 | #include "insn-config.h" | |
81 | #include "reload.h" | |
e3b8b697 | 82 | #include "output.h" |
744d3441 | 83 | #include "dbxout.h" |
0e93a6ac | 84 | #include "toplev.h" |
1dd6c958 | 85 | #include "tm_p.h" |
cff53614 | 86 | #include "ggc.h" |
b896d81b | 87 | #include "debug.h" |
0c87a39e | 88 | #include "function.h" |
2cb4ac60 | 89 | #include "target.h" |
d19bd1f0 | 90 | #include "langhooks.h" |
946754ae | 91 | |
439c05a0 | 92 | #ifdef XCOFF_DEBUGGING_INFO |
3d82b777 | 93 | #include "xcoffout.h" |
439c05a0 | 94 | #endif |
95 | ||
262444a6 | 96 | #define DBXOUT_DECR_NESTING \ |
97 | if (--debug_nesting == 0 && symbol_queue_index > 0) \ | |
51cec339 | 98 | { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); } |
262444a6 | 99 | |
262444a6 | 100 | #define DBXOUT_DECR_NESTING_AND_RETURN(x) \ |
101 | do {--debug_nesting; return (x);} while (0) | |
102 | ||
946754ae | 103 | #ifndef ASM_STABS_OP |
6ae8577b | 104 | #define ASM_STABS_OP "\t.stabs\t" |
946754ae | 105 | #endif |
106 | ||
107 | #ifndef ASM_STABN_OP | |
6ae8577b | 108 | #define ASM_STABN_OP "\t.stabn\t" |
946754ae | 109 | #endif |
110 | ||
98123cec | 111 | #ifndef DBX_TYPE_DECL_STABS_CODE |
112 | #define DBX_TYPE_DECL_STABS_CODE N_LSYM | |
439c05a0 | 113 | #endif |
114 | ||
115 | #ifndef DBX_STATIC_CONST_VAR_CODE | |
116 | #define DBX_STATIC_CONST_VAR_CODE N_FUN | |
117 | #endif | |
118 | ||
119 | #ifndef DBX_REGPARM_STABS_CODE | |
120 | #define DBX_REGPARM_STABS_CODE N_RSYM | |
121 | #endif | |
122 | ||
123 | #ifndef DBX_REGPARM_STABS_LETTER | |
124 | #define DBX_REGPARM_STABS_LETTER 'P' | |
125 | #endif | |
126 | ||
a3407969 | 127 | #ifndef NO_DBX_FUNCTION_END |
128 | #define NO_DBX_FUNCTION_END 0 | |
129 | #endif | |
130 | ||
7d6171f2 | 131 | #ifndef NO_DBX_BNSYM_ENSYM |
132 | #define NO_DBX_BNSYM_ENSYM 0 | |
133 | #endif | |
134 | ||
e3b8b697 | 135 | #ifndef DBX_BLOCKS_FUNCTION_RELATIVE |
136 | #define DBX_BLOCKS_FUNCTION_RELATIVE 0 | |
137 | #endif | |
138 | ||
139 | #ifndef DBX_LINES_FUNCTION_RELATIVE | |
140 | #define DBX_LINES_FUNCTION_RELATIVE 0 | |
141 | #endif | |
142 | ||
946754ae | 143 | enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED}; |
144 | ||
54ae7e56 | 145 | /* Structure recording information about a C data type. |
146 | The status element says whether we have yet output | |
147 | the definition of the type. TYPE_XREF says we have | |
148 | output it as a cross-reference only. | |
149 | The file_number and type_number elements are used if DBX_USE_BINCL | |
150 | is defined. */ | |
151 | ||
573aba85 | 152 | struct typeinfo GTY(()) |
54ae7e56 | 153 | { |
154 | enum typestatus status; | |
54ae7e56 | 155 | int file_number; |
156 | int type_number; | |
54ae7e56 | 157 | }; |
158 | ||
159 | /* Vector recording information about C data types. | |
946754ae | 160 | When we first notice a data type (a tree node), |
161 | we assign it a number using next_type_number. | |
54ae7e56 | 162 | That is its index in this vector. */ |
946754ae | 163 | |
573aba85 | 164 | static GTY ((length ("typevec_len"))) struct typeinfo *typevec; |
946754ae | 165 | |
166 | /* Number of elements of space allocated in `typevec'. */ | |
167 | ||
573aba85 | 168 | static GTY(()) int typevec_len; |
946754ae | 169 | |
170 | /* In dbx output, each type gets a unique number. | |
171 | This is the number for the next type output. | |
172 | The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */ | |
173 | ||
573aba85 | 174 | static GTY(()) int next_type_number; |
54ae7e56 | 175 | |
73ae3ef7 | 176 | /* The C front end may call dbxout_symbol before dbxout_init runs. |
177 | We save all such decls in this list and output them when we get | |
178 | to dbxout_init. */ | |
179 | ||
180 | static GTY(()) tree preinit_symbols; | |
181 | ||
51cec339 | 182 | enum binclstatus {BINCL_NOT_REQUIRED, BINCL_PENDING, BINCL_PROCESSED}; |
183 | ||
54ae7e56 | 184 | /* When using N_BINCL in dbx output, each type number is actually a |
185 | pair of the file number and the type number within the file. | |
186 | This is a stack of input files. */ | |
187 | ||
65f52f4e | 188 | struct dbx_file |
54ae7e56 | 189 | { |
190 | struct dbx_file *next; | |
191 | int file_number; | |
192 | int next_type_number; | |
65f52f4e | 193 | enum binclstatus bincl_status; /* Keep track of lazy bincl. */ |
194 | const char *pending_bincl_name; /* Name of bincl. */ | |
195 | struct dbx_file *prev; /* Chain to traverse all pending bincls. */ | |
54ae7e56 | 196 | }; |
197 | ||
65f52f4e | 198 | /* This is the top of the stack. |
199 | ||
200 | This is not saved for PCH, because restoring a PCH should not change it. | |
201 | next_file_number does have to be saved, because the PCH may use some | |
202 | file numbers; however, just before restoring a PCH, next_file_number | |
203 | should always be 0 because we should not have needed any file numbers | |
204 | yet. */ | |
54ae7e56 | 205 | |
7bff8f28 | 206 | #if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \ |
207 | && defined (DBX_USE_BINCL) | |
65f52f4e | 208 | static struct dbx_file *current_file; |
14f1f66f | 209 | #endif |
54ae7e56 | 210 | |
211 | /* This is the next file number to use. */ | |
212 | ||
573aba85 | 213 | static GTY(()) int next_file_number; |
214 | ||
cf8e41a4 | 215 | /* A counter for dbxout_function_end. */ |
38ac91bf | 216 | |
cf8e41a4 | 217 | static GTY(()) int scope_labelno; |
38ac91bf | 218 | |
b1bd5ac9 | 219 | /* A counter for dbxout_source_line. */ |
220 | ||
221 | static GTY(()) int dbxout_source_line_counter; | |
222 | ||
573aba85 | 223 | /* Nonzero if we have actually used any of the GDB extensions |
224 | to the debugging format. The idea is that we use them for the | |
225 | first time only if there's a strong reason, but once we have done that, | |
226 | we use them whenever convenient. */ | |
227 | ||
cf8e41a4 | 228 | static GTY(()) int have_used_extensions = 0; |
573aba85 | 229 | |
230 | /* Number for the next N_SOL filename stabs label. The number 0 is reserved | |
231 | for the N_SO filename stabs label. */ | |
232 | ||
cf8e41a4 | 233 | static GTY(()) int source_label_number = 1; |
234 | ||
235 | /* Last source file name mentioned in a NOTE insn. */ | |
236 | ||
237 | static GTY(()) const char *lastfile; | |
238 | ||
239 | /* Used by PCH machinery to detect if 'lastfile' should be reset to | |
240 | base_input_file. */ | |
241 | static GTY(()) int lastfile_is_base; | |
242 | ||
243 | /* Typical USG systems don't have stab.h, and they also have | |
244 | no use for DBX-format debugging info. */ | |
245 | ||
246 | #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) | |
247 | ||
241af3cc | 248 | #ifdef DBX_USE_BINCL |
249 | /* If zero then there is no pending BINCL. */ | |
250 | static int pending_bincls = 0; | |
251 | #endif | |
252 | ||
cf8e41a4 | 253 | /* The original input file name. */ |
254 | static const char *base_input_file; | |
255 | ||
573aba85 | 256 | #ifdef DEBUG_SYMS_TEXT |
257 | #define FORCE_TEXT function_section (current_function_decl); | |
258 | #else | |
259 | #define FORCE_TEXT | |
260 | #endif | |
261 | ||
262 | #include "gstab.h" | |
263 | ||
264 | #define STAB_CODE_TYPE enum __stab_debug_code | |
265 | ||
266 | /* 1 if PARM is passed to this function in memory. */ | |
267 | ||
268 | #define PARM_PASSED_IN_MEMORY(PARM) \ | |
e16ceb8e | 269 | (MEM_P (DECL_INCOMING_RTL (PARM))) |
54ae7e56 | 270 | |
573aba85 | 271 | /* A C expression for the integer offset value of an automatic variable |
272 | (N_LSYM) having address X (an RTX). */ | |
273 | #ifndef DEBUGGER_AUTO_OFFSET | |
274 | #define DEBUGGER_AUTO_OFFSET(X) \ | |
275 | (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) | |
276 | #endif | |
277 | ||
278 | /* A C expression for the integer offset value of an argument (N_PSYM) | |
279 | having address X (an RTX). The nominal offset is OFFSET. */ | |
280 | #ifndef DEBUGGER_ARG_OFFSET | |
281 | #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET) | |
282 | #endif | |
283 | ||
946754ae | 284 | /* These variables are for dbxout_symbol to communicate to |
285 | dbxout_finish_symbol. | |
286 | current_sym_code is the symbol-type-code, a symbol N_... define in stab.h. | |
287 | current_sym_value and current_sym_addr are two ways to address the | |
288 | value to store in the symtab entry. | |
289 | current_sym_addr if nonzero represents the value as an rtx. | |
290 | If that is zero, current_sym_value is used. This is used | |
291 | when the value is an offset (such as for auto variables, | |
292 | register variables and parms). */ | |
293 | ||
294 | static STAB_CODE_TYPE current_sym_code; | |
295 | static int current_sym_value; | |
296 | static rtx current_sym_addr; | |
297 | ||
298 | /* Number of chars of symbol-description generated so far for the | |
299 | current symbol. Used by CHARS and CONTIN. */ | |
300 | ||
301 | static int current_sym_nchars; | |
302 | ||
303 | /* Report having output N chars of the current symbol-description. */ | |
304 | ||
305 | #define CHARS(N) (current_sym_nchars += (N)) | |
306 | ||
307 | /* Break the current symbol-description, generating a continuation, | |
308 | if it has become long. */ | |
309 | ||
310 | #ifndef DBX_CONTIN_LENGTH | |
311 | #define DBX_CONTIN_LENGTH 80 | |
312 | #endif | |
313 | ||
314 | #if DBX_CONTIN_LENGTH > 0 | |
315 | #define CONTIN \ | |
316 | do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0) | |
317 | #else | |
fb09780f | 318 | #define CONTIN do { } while (0) |
946754ae | 319 | #endif |
320 | ||
b0eb97d5 | 321 | #ifdef DBX_USE_BINCL |
51cec339 | 322 | static void emit_bincl_stab (const char *c); |
323 | static void emit_pending_bincls (void); | |
2a3d2f63 | 324 | #endif |
51cec339 | 325 | static inline void emit_pending_bincls_if_required (void); |
326 | ||
8ec3a57b | 327 | static void dbxout_init (const char *); |
df49acff | 328 | #ifndef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY |
913910e0 | 329 | static unsigned int get_lang_number (void); |
df49acff | 330 | #endif |
8ec3a57b | 331 | static void dbxout_finish (const char *); |
332 | static void dbxout_start_source_file (unsigned, const char *); | |
333 | static void dbxout_end_source_file (unsigned); | |
334 | static void dbxout_typedefs (tree); | |
8ec3a57b | 335 | static void dbxout_type_index (tree); |
cb264b86 | 336 | #if DBX_CONTIN_LENGTH > 0 |
8ec3a57b | 337 | static void dbxout_continue (void); |
cb264b86 | 338 | #endif |
8ec3a57b | 339 | static void dbxout_args (tree); |
340 | static void dbxout_type_fields (tree); | |
341 | static void dbxout_type_method_1 (tree, const char *); | |
342 | static void dbxout_type_methods (tree); | |
343 | static void dbxout_range_type (tree); | |
344 | static void dbxout_type (tree, int); | |
345 | static bool print_int_cst_bounds_in_octal_p (tree); | |
346 | static void print_int_cst_octal (tree); | |
347 | static void print_octal (unsigned HOST_WIDE_INT, int); | |
348 | static void print_wide_int (HOST_WIDE_INT); | |
349 | static void dbxout_type_name (tree); | |
350 | static void dbxout_class_name_qualifiers (tree); | |
351 | static int dbxout_symbol_location (tree, tree, const char *, rtx); | |
352 | static void dbxout_symbol_name (tree, const char *, int); | |
353 | static void dbxout_prepare_symbol (tree); | |
354 | static void dbxout_finish_symbol (tree); | |
355 | static void dbxout_block (tree, int, tree); | |
356 | static void dbxout_global_decl (tree); | |
fdcda623 | 357 | static void dbxout_type_decl (tree, int); |
8ec3a57b | 358 | static void dbxout_handle_pch (unsigned); |
946754ae | 359 | \f |
c140b944 | 360 | /* The debug hooks structure. */ |
1dff614c | 361 | #if defined (DBX_DEBUGGING_INFO) |
362 | ||
8ec3a57b | 363 | static void dbxout_source_line (unsigned int, const char *); |
4ec92916 | 364 | static void dbxout_begin_prologue (unsigned int, const char *); |
8ec3a57b | 365 | static void dbxout_source_file (FILE *, const char *); |
366 | static void dbxout_function_end (void); | |
367 | static void dbxout_begin_function (tree); | |
368 | static void dbxout_begin_block (unsigned, unsigned); | |
369 | static void dbxout_end_block (unsigned, unsigned); | |
370 | static void dbxout_function_decl (tree); | |
1dff614c | 371 | |
e42f6423 | 372 | const struct gcc_debug_hooks dbx_debug_hooks = |
b896d81b | 373 | { |
374 | dbxout_init, | |
c140b944 | 375 | dbxout_finish, |
376 | debug_nothing_int_charstar, | |
377 | debug_nothing_int_charstar, | |
378 | dbxout_start_source_file, | |
1dff614c | 379 | dbxout_end_source_file, |
380 | dbxout_begin_block, | |
b9b7f8b4 | 381 | dbxout_end_block, |
2b49746a | 382 | debug_true_tree, /* ignore_block */ |
383 | dbxout_source_line, /* source_line */ | |
4ec92916 | 384 | dbxout_begin_prologue, /* begin_prologue */ |
2b49746a | 385 | debug_nothing_int_charstar, /* end_prologue */ |
386 | debug_nothing_int_charstar, /* end_epilogue */ | |
f76df888 | 387 | #ifdef DBX_FUNCTION_FIRST |
388 | dbxout_begin_function, | |
389 | #else | |
2b49746a | 390 | debug_nothing_tree, /* begin_function */ |
f76df888 | 391 | #endif |
2b49746a | 392 | debug_nothing_int, /* end_function */ |
c37d72e9 | 393 | dbxout_function_decl, |
2b49746a | 394 | dbxout_global_decl, /* global_decl */ |
73ae3ef7 | 395 | dbxout_type_decl, /* type_decl */ |
2b49746a | 396 | debug_nothing_tree_tree, /* imported_module_or_decl */ |
397 | debug_nothing_tree, /* deferred_inline_function */ | |
398 | debug_nothing_tree, /* outlining_inline_function */ | |
399 | debug_nothing_rtx, /* label */ | |
5923a5e7 | 400 | dbxout_handle_pch, /* handle_pch */ |
401 | debug_nothing_rtx /* var_location */ | |
b896d81b | 402 | }; |
1dff614c | 403 | #endif /* DBX_DEBUGGING_INFO */ |
404 | ||
405 | #if defined (XCOFF_DEBUGGING_INFO) | |
e42f6423 | 406 | const struct gcc_debug_hooks xcoff_debug_hooks = |
1dff614c | 407 | { |
408 | dbxout_init, | |
409 | dbxout_finish, | |
410 | debug_nothing_int_charstar, | |
411 | debug_nothing_int_charstar, | |
412 | dbxout_start_source_file, | |
413 | dbxout_end_source_file, | |
414 | xcoffout_begin_block, | |
b9b7f8b4 | 415 | xcoffout_end_block, |
2b49746a | 416 | debug_true_tree, /* ignore_block */ |
b9b7f8b4 | 417 | xcoffout_source_line, |
2b49746a | 418 | xcoffout_begin_prologue, /* begin_prologue */ |
419 | debug_nothing_int_charstar, /* end_prologue */ | |
b9b7f8b4 | 420 | xcoffout_end_epilogue, |
2b49746a | 421 | debug_nothing_tree, /* begin_function */ |
c37d72e9 | 422 | xcoffout_end_function, |
2b49746a | 423 | debug_nothing_tree, /* function_decl */ |
424 | dbxout_global_decl, /* global_decl */ | |
73ae3ef7 | 425 | dbxout_type_decl, /* type_decl */ |
2b49746a | 426 | debug_nothing_tree_tree, /* imported_module_or_decl */ |
427 | debug_nothing_tree, /* deferred_inline_function */ | |
428 | debug_nothing_tree, /* outlining_inline_function */ | |
429 | debug_nothing_rtx, /* label */ | |
5923a5e7 | 430 | dbxout_handle_pch, /* handle_pch */ |
431 | debug_nothing_rtx /* var_location */ | |
1dff614c | 432 | }; |
433 | #endif /* XCOFF_DEBUGGING_INFO */ | |
b896d81b | 434 | \f |
0c87a39e | 435 | #if defined (DBX_DEBUGGING_INFO) |
f6e3ef26 | 436 | static void |
8ec3a57b | 437 | dbxout_function_end (void) |
f6e3ef26 | 438 | { |
439 | char lscope_label_name[100]; | |
4f18499c | 440 | |
28a5f832 | 441 | /* The Lscope label must be emitted even if we aren't doing anything |
442 | else; dbxout_block needs it. */ | |
4f18499c | 443 | function_section (current_function_decl); |
444 | ||
f6e3ef26 | 445 | /* Convert Ltext into the appropriate format for local labels in case |
446 | the system doesn't insert underscores in front of user generated | |
447 | labels. */ | |
448 | ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno); | |
e3b8b697 | 449 | targetm.asm_out.internal_label (asm_out_file, "Lscope", scope_labelno); |
f6e3ef26 | 450 | scope_labelno++; |
451 | ||
28a5f832 | 452 | /* The N_FUN tag at the end of the function is a GNU extension, |
453 | which may be undesirable, and is unnecessary if we do not have | |
454 | named sections. */ | |
455 | if (!use_gnu_debug_info_extensions | |
28a5f832 | 456 | || NO_DBX_FUNCTION_END |
28a5f832 | 457 | || !targetm.have_named_sections) |
458 | return; | |
459 | ||
f6e3ef26 | 460 | /* By convention, GCC will mark the end of a function with an N_FUN |
461 | symbol and an empty string. */ | |
12b80435 | 462 | #ifdef DBX_OUTPUT_NFUN |
e3b8b697 | 463 | DBX_OUTPUT_NFUN (asm_out_file, lscope_label_name, current_function_decl); |
12b80435 | 464 | #else |
e3b8b697 | 465 | fprintf (asm_out_file, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN); |
466 | assemble_name (asm_out_file, lscope_label_name); | |
467 | putc ('-', asm_out_file); | |
468 | assemble_name (asm_out_file, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); | |
469 | fprintf (asm_out_file, "\n"); | |
12b80435 | 470 | #endif |
4ec92916 | 471 | |
7d6171f2 | 472 | if (!NO_DBX_BNSYM_ENSYM && !flag_debug_only_used_symbols) |
e3b8b697 | 473 | fprintf (asm_out_file, "%s%d,0,0\n", ASM_STABD_OP, N_ENSYM); |
f6e3ef26 | 474 | } |
0c87a39e | 475 | #endif /* DBX_DEBUGGING_INFO */ |
f6e3ef26 | 476 | |
df49acff | 477 | #ifndef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY |
913910e0 | 478 | /* Get lang description for N_SO stab. */ |
479 | ||
480 | static unsigned int | |
481 | get_lang_number (void) | |
482 | { | |
483 | const char *language_string = lang_hooks.name; | |
484 | ||
485 | if (strcmp (language_string, "GNU C") == 0) | |
486 | return N_SO_C; | |
487 | else if (strcmp (language_string, "GNU C++") == 0) | |
488 | return N_SO_CC; | |
489 | else if (strcmp (language_string, "GNU F77") == 0) | |
490 | return N_SO_FORTRAN; | |
491 | else if (strcmp (language_string, "GNU F95") == 0) | |
492 | return N_SO_FORTRAN90; /* CHECKME */ | |
493 | else if (strcmp (language_string, "GNU Pascal") == 0) | |
494 | return N_SO_PASCAL; | |
495 | else if (strcmp (language_string, "GNU Objective-C") == 0) | |
496 | return N_SO_OBJC; | |
497 | else | |
498 | return 0; | |
499 | ||
500 | } | |
df49acff | 501 | #endif |
913910e0 | 502 | |
946754ae | 503 | /* At the beginning of compilation, start writing the symbol table. |
504 | Initialize `typevec' and output the standard data types of C. */ | |
505 | ||
b896d81b | 506 | static void |
8ec3a57b | 507 | dbxout_init (const char *input_file_name) |
946754ae | 508 | { |
509 | char ltext_label_name[100]; | |
dc24ddbd | 510 | tree syms = lang_hooks.decls.getdecls (); |
946754ae | 511 | |
946754ae | 512 | typevec_len = 100; |
f0af5a88 | 513 | typevec = ggc_calloc (typevec_len, sizeof typevec[0]); |
946754ae | 514 | |
515 | /* Convert Ltext into the appropriate format for local labels in case | |
516 | the system doesn't insert underscores in front of user generated | |
517 | labels. */ | |
518 | ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0); | |
519 | ||
520 | /* Put the current working directory in an N_SO symbol. */ | |
9cdc08c6 | 521 | if (use_gnu_debug_info_extensions) |
439c05a0 | 522 | { |
52cae7bf | 523 | static const char *cwd; |
524 | ||
525 | if (!cwd) | |
439c05a0 | 526 | { |
52cae7bf | 527 | cwd = get_src_pwd (); |
528 | if (cwd[0] == '\0') | |
529 | cwd = "/"; | |
530 | else if (!IS_DIR_SEPARATOR (cwd[strlen (cwd) - 1])) | |
531 | cwd = concat (cwd, "/", NULL); | |
532 | } | |
533 | ||
946754ae | 534 | #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY |
52cae7bf | 535 | DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asm_out_file, cwd); |
946754ae | 536 | #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */ |
52cae7bf | 537 | fprintf (asm_out_file, "%s", ASM_STABS_OP); |
538 | output_quoted_string (asm_out_file, cwd); | |
539 | fprintf (asm_out_file, ",%d,0,%d,", N_SO, get_lang_number ()); | |
540 | assemble_name (asm_out_file, ltext_label_name); | |
541 | fputc ('\n', asm_out_file); | |
946754ae | 542 | #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */ |
439c05a0 | 543 | } |
946754ae | 544 | |
545 | #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME | |
e3b8b697 | 546 | DBX_OUTPUT_MAIN_SOURCE_FILENAME (asm_out_file, input_file_name); |
946754ae | 547 | #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */ |
548 | /* We include outputting `Ltext:' here, | |
549 | because that gives you a way to override it. */ | |
550 | /* Used to put `Ltext:' before the reference, but that loses on sun 4. */ | |
e3b8b697 | 551 | fprintf (asm_out_file, "%s", ASM_STABS_OP); |
552 | output_quoted_string (asm_out_file, input_file_name); | |
553 | fprintf (asm_out_file, ",%d,0,%d,", N_SO, get_lang_number ()); | |
554 | assemble_name (asm_out_file, ltext_label_name); | |
555 | fputc ('\n', asm_out_file); | |
946754ae | 556 | text_section (); |
e3b8b697 | 557 | targetm.asm_out.internal_label (asm_out_file, "Ltext", 0); |
946754ae | 558 | #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */ |
559 | ||
08c78c16 | 560 | #ifdef DBX_OUTPUT_GCC_MARKER |
e3b8b697 | 561 | DBX_OUTPUT_GCC_MARKER (asm_out_file); |
08c78c16 | 562 | #else |
52cae7bf | 563 | /* Emit an N_OPT stab to indicate that this file was compiled by GCC. |
564 | The string used is historical. */ | |
565 | fprintf (asm_out_file, "%s\"gcc2_compiled.\",%d,0,0,0\n", | |
566 | ASM_STABS_OP, N_OPT); | |
08c78c16 | 567 | #endif |
ec6884ea | 568 | |
cf8e41a4 | 569 | base_input_file = lastfile = input_file_name; |
946754ae | 570 | |
571 | next_type_number = 1; | |
946754ae | 572 | |
54ae7e56 | 573 | #ifdef DBX_USE_BINCL |
65f52f4e | 574 | current_file = xmalloc (sizeof *current_file); |
54ae7e56 | 575 | current_file->next = NULL; |
576 | current_file->file_number = 0; | |
577 | current_file->next_type_number = 1; | |
578 | next_file_number = 1; | |
51cec339 | 579 | current_file->prev = NULL; |
580 | current_file->bincl_status = BINCL_NOT_REQUIRED; | |
581 | current_file->pending_bincl_name = NULL; | |
54ae7e56 | 582 | #endif |
583 | ||
54bd1509 | 584 | /* Get all permanent types that have typedef names, and output them |
585 | all, except for those already output. Some language front ends | |
73ae3ef7 | 586 | put these declarations in the top-level scope; some do not; |
587 | the latter are responsible for calling debug_hooks->type_decl from | |
588 | their record_builtin_type function. */ | |
946754ae | 589 | dbxout_typedefs (syms); |
73ae3ef7 | 590 | |
591 | if (preinit_symbols) | |
592 | { | |
593 | tree t; | |
594 | for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t)) | |
595 | dbxout_symbol (TREE_VALUE (t), 0); | |
596 | preinit_symbols = 0; | |
597 | } | |
946754ae | 598 | } |
599 | ||
e9efa031 | 600 | /* Output any typedef names for types described by TYPE_DECLs in SYMS. */ |
946754ae | 601 | |
602 | static void | |
8ec3a57b | 603 | dbxout_typedefs (tree syms) |
946754ae | 604 | { |
132cc6f4 | 605 | for (; syms != NULL_TREE; syms = TREE_CHAIN (syms)) |
946754ae | 606 | { |
946754ae | 607 | if (TREE_CODE (syms) == TYPE_DECL) |
608 | { | |
609 | tree type = TREE_TYPE (syms); | |
610 | if (TYPE_NAME (type) | |
611 | && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
14ce540d | 612 | && COMPLETE_OR_VOID_TYPE_P (type) |
946754ae | 613 | && ! TREE_ASM_WRITTEN (TYPE_NAME (type))) |
614 | dbxout_symbol (TYPE_NAME (type), 0); | |
615 | } | |
616 | } | |
617 | } | |
618 | ||
2a3d2f63 | 619 | #ifdef DBX_USE_BINCL |
81d47035 | 620 | /* Emit BINCL stab using given name. */ |
51cec339 | 621 | static void |
622 | emit_bincl_stab (const char *name) | |
623 | { | |
e3b8b697 | 624 | fprintf (asm_out_file, "%s", ASM_STABS_OP); |
625 | output_quoted_string (asm_out_file, name); | |
626 | fprintf (asm_out_file, ",%d,0,0,0\n", N_BINCL); | |
51cec339 | 627 | } |
628 | ||
629 | /* If there are pending bincls then it is time to emit all of them. */ | |
630 | ||
631 | static inline void | |
a046944b | 632 | emit_pending_bincls_if_required (void) |
51cec339 | 633 | { |
51cec339 | 634 | if (pending_bincls) |
635 | emit_pending_bincls (); | |
51cec339 | 636 | } |
637 | ||
638 | /* Emit all pending bincls. */ | |
639 | ||
640 | static void | |
a046944b | 641 | emit_pending_bincls (void) |
51cec339 | 642 | { |
643 | struct dbx_file *f = current_file; | |
644 | ||
645 | /* Find first pending bincl. */ | |
646 | while (f->bincl_status == BINCL_PENDING) | |
647 | f = f->next; | |
648 | ||
649 | /* Now emit all bincls. */ | |
650 | f = f->prev; | |
651 | ||
652 | while (f) | |
653 | { | |
654 | if (f->bincl_status == BINCL_PENDING) | |
655 | { | |
656 | emit_bincl_stab (f->pending_bincl_name); | |
657 | ||
658 | /* Update file number and status. */ | |
659 | f->file_number = next_file_number++; | |
660 | f->bincl_status = BINCL_PROCESSED; | |
661 | } | |
662 | if (f == current_file) | |
663 | break; | |
664 | f = f->prev; | |
665 | } | |
666 | ||
667 | /* All pending bincls have been emitted. */ | |
668 | pending_bincls = 0; | |
669 | } | |
670 | ||
2a3d2f63 | 671 | #else |
672 | ||
673 | static inline void | |
a046944b | 674 | emit_pending_bincls_if_required (void) {} |
2a3d2f63 | 675 | #endif |
676 | ||
54ae7e56 | 677 | /* Change to reading from a new source file. Generate a N_BINCL stab. */ |
678 | ||
c140b944 | 679 | static void |
8ec3a57b | 680 | dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED, |
681 | const char *filename ATTRIBUTE_UNUSED) | |
54ae7e56 | 682 | { |
683 | #ifdef DBX_USE_BINCL | |
65f52f4e | 684 | struct dbx_file *n = xmalloc (sizeof *n); |
54ae7e56 | 685 | |
686 | n->next = current_file; | |
54ae7e56 | 687 | n->next_type_number = 1; |
51cec339 | 688 | /* Do not assign file number now. |
689 | Delay it until we actually emit BINCL. */ | |
690 | n->file_number = 0; | |
691 | n->prev = NULL; | |
692 | current_file->prev = n; | |
693 | n->bincl_status = BINCL_PENDING; | |
694 | n->pending_bincl_name = filename; | |
695 | pending_bincls = 1; | |
54ae7e56 | 696 | current_file = n; |
54ae7e56 | 697 | #endif |
698 | } | |
699 | ||
700 | /* Revert to reading a previous source file. Generate a N_EINCL stab. */ | |
701 | ||
c140b944 | 702 | static void |
8ec3a57b | 703 | dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED) |
54ae7e56 | 704 | { |
705 | #ifdef DBX_USE_BINCL | |
51cec339 | 706 | /* Emit EINCL stab only if BINCL is not pending. */ |
707 | if (current_file->bincl_status == BINCL_PROCESSED) | |
e3b8b697 | 708 | fprintf (asm_out_file, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL); |
51cec339 | 709 | current_file->bincl_status = BINCL_NOT_REQUIRED; |
573aba85 | 710 | current_file = current_file->next; |
54ae7e56 | 711 | #endif |
712 | } | |
713 | ||
cf8e41a4 | 714 | /* Handle a few odd cases that occur when trying to make PCH files work. */ |
715 | ||
716 | static void | |
717 | dbxout_handle_pch (unsigned at_end) | |
718 | { | |
719 | if (! at_end) | |
720 | { | |
721 | /* When using the PCH, this file will be included, so we need to output | |
722 | a BINCL. */ | |
723 | dbxout_start_source_file (0, lastfile); | |
724 | ||
725 | /* The base file when using the PCH won't be the same as | |
726 | the base file when it's being generated. */ | |
727 | lastfile = NULL; | |
728 | } | |
729 | else | |
730 | { | |
6473f3f4 | 731 | /* ... and an EINCL. */ |
cf8e41a4 | 732 | dbxout_end_source_file (0); |
733 | ||
734 | /* Deal with cases where 'lastfile' was never actually changed. */ | |
735 | lastfile_is_base = lastfile == NULL; | |
736 | } | |
737 | } | |
738 | ||
0c87a39e | 739 | #if defined (DBX_DEBUGGING_INFO) |
946754ae | 740 | /* Output debugging info to FILE to switch to sourcefile FILENAME. */ |
741 | ||
b29760a8 | 742 | static void |
8ec3a57b | 743 | dbxout_source_file (FILE *file, const char *filename) |
946754ae | 744 | { |
cf8e41a4 | 745 | if (lastfile == 0 && lastfile_is_base) |
746 | { | |
747 | lastfile = base_input_file; | |
748 | lastfile_is_base = 0; | |
749 | } | |
750 | ||
946754ae | 751 | if (filename && (lastfile == 0 || strcmp (filename, lastfile))) |
752 | { | |
917938fe | 753 | char ltext_label_name[100]; |
754 | ||
244612e7 | 755 | ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", |
756 | source_label_number); | |
17d8e118 | 757 | fprintf (file, "%s", ASM_STABS_OP); |
cc3c079f | 758 | output_quoted_string (file, filename); |
e3b8b697 | 759 | fprintf (asm_out_file, ",%d,0,0,", N_SOL); |
760 | assemble_name (asm_out_file, ltext_label_name); | |
761 | fputc ('\n', asm_out_file); | |
1dc74225 | 762 | if (current_function_decl != NULL_TREE) |
2f339a71 | 763 | ; /* Don't change section amid function. */ |
764 | else | |
1dc74225 | 765 | text_section (); |
883b2e73 | 766 | targetm.asm_out.internal_label (file, "Ltext", source_label_number); |
15a3d642 | 767 | source_label_number++; |
946754ae | 768 | lastfile = filename; |
769 | } | |
770 | } | |
771 | ||
4ec92916 | 772 | /* Output N_BNSYM and line number symbol entry. */ |
773 | ||
774 | static void | |
775 | dbxout_begin_prologue (unsigned int lineno, const char *filename) | |
776 | { | |
a3407969 | 777 | if (use_gnu_debug_info_extensions |
778 | && !NO_DBX_FUNCTION_END | |
7d6171f2 | 779 | && !NO_DBX_BNSYM_ENSYM |
a3407969 | 780 | && !flag_debug_only_used_symbols) |
e3b8b697 | 781 | fprintf (asm_out_file, "%s%d,0,0\n", ASM_STABD_OP, N_BNSYM); |
4ec92916 | 782 | |
783 | dbxout_source_line (lineno, filename); | |
784 | } | |
785 | ||
f76df888 | 786 | /* Output a line number symbol entry for source file FILENAME and line |
787 | number LINENO. */ | |
5e3b69f4 | 788 | |
b9b7f8b4 | 789 | static void |
8ec3a57b | 790 | dbxout_source_line (unsigned int lineno, const char *filename) |
5e3b69f4 | 791 | { |
e3b8b697 | 792 | dbxout_source_file (asm_out_file, filename); |
5e3b69f4 | 793 | |
e3b8b697 | 794 | #ifdef DBX_OUTPUT_SOURCE_LINE |
b1bd5ac9 | 795 | dbxout_source_line_counter += 1; |
e3b8b697 | 796 | DBX_OUTPUT_SOURCE_LINE (asm_out_file, lineno, dbxout_source_line_counter); |
5e3b69f4 | 797 | #else |
e3b8b697 | 798 | if (DBX_LINES_FUNCTION_RELATIVE) |
799 | { | |
800 | char label[100]; | |
801 | dbxout_source_line_counter += 1; | |
802 | ||
803 | ASM_GENERATE_INTERNAL_LABEL (label, "LM", dbxout_source_line_counter); | |
804 | fprintf (asm_out_file, "%s%d,0,%d,", ASM_STABN_OP, N_SLINE, lineno); | |
805 | assemble_name (asm_out_file, label); | |
806 | putc ('-', asm_out_file); | |
807 | assemble_name (asm_out_file, | |
808 | XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); | |
809 | putc ('\n', asm_out_file); | |
810 | targetm.asm_out.internal_label (asm_out_file, "LM", | |
811 | dbxout_source_line_counter); | |
812 | } | |
813 | else | |
814 | fprintf (asm_out_file, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno); | |
5e3b69f4 | 815 | #endif |
816 | } | |
817 | ||
1dff614c | 818 | /* Describe the beginning of an internal block within a function. */ |
819 | ||
820 | static void | |
8ec3a57b | 821 | dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n) |
1dff614c | 822 | { |
51cec339 | 823 | emit_pending_bincls_if_required (); |
e3b8b697 | 824 | targetm.asm_out.internal_label (asm_out_file, "LBB", n); |
1dff614c | 825 | } |
826 | ||
827 | /* Describe the end line-number of an internal block within a function. */ | |
828 | ||
829 | static void | |
8ec3a57b | 830 | dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n) |
1dff614c | 831 | { |
51cec339 | 832 | emit_pending_bincls_if_required (); |
e3b8b697 | 833 | targetm.asm_out.internal_label (asm_out_file, "LBE", n); |
1dff614c | 834 | } |
835 | ||
c37d72e9 | 836 | /* Output dbx data for a function definition. |
837 | This includes a definition of the function name itself (a symbol), | |
838 | definitions of the parameters (locating them in the parameter list) | |
839 | and then output the block that makes up the function's body | |
840 | (including all the auto variables of the function). */ | |
841 | ||
842 | static void | |
8ec3a57b | 843 | dbxout_function_decl (tree decl) |
c37d72e9 | 844 | { |
51cec339 | 845 | emit_pending_bincls_if_required (); |
c37d72e9 | 846 | #ifndef DBX_FUNCTION_FIRST |
847 | dbxout_begin_function (decl); | |
848 | #endif | |
849 | dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl)); | |
28a5f832 | 850 | dbxout_function_end (); |
c37d72e9 | 851 | } |
852 | ||
1dff614c | 853 | #endif /* DBX_DEBUGGING_INFO */ |
854 | ||
397c7bc7 | 855 | /* Debug information for a global DECL. Called from toplev.c after |
856 | compilation proper has finished. */ | |
857 | static void | |
8ec3a57b | 858 | dbxout_global_decl (tree decl) |
397c7bc7 | 859 | { |
860 | if (TREE_CODE (decl) == VAR_DECL | |
861 | && ! DECL_EXTERNAL (decl) | |
862 | && DECL_RTL_SET_P (decl)) /* Not necessary? */ | |
262444a6 | 863 | { |
864 | int saved_tree_used = TREE_USED (decl); | |
865 | TREE_USED (decl) = 1; | |
866 | dbxout_symbol (decl, 0); | |
867 | TREE_USED (decl) = saved_tree_used; | |
868 | } | |
1eefe280 | 869 | } |
397c7bc7 | 870 | |
73ae3ef7 | 871 | /* This is just a function-type adapter; dbxout_symbol does exactly |
872 | what we want but returns an int. */ | |
873 | static void | |
874 | dbxout_type_decl (tree decl, int local) | |
875 | { | |
876 | dbxout_symbol (decl, local); | |
877 | } | |
878 | ||
946754ae | 879 | /* At the end of compilation, finish writing the symbol table. |
e3b8b697 | 880 | The default is to call debug_free_queue but do nothing else. */ |
946754ae | 881 | |
b896d81b | 882 | static void |
8ec3a57b | 883 | dbxout_finish (const char *filename ATTRIBUTE_UNUSED) |
946754ae | 884 | { |
885 | #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END | |
e3b8b697 | 886 | DBX_OUTPUT_MAIN_SOURCE_FILE_END (asm_out_file, filename); |
887 | #elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END | |
888 | { | |
889 | char letext_label[100]; | |
890 | ASM_GENERATE_INTERNAL_LABEL (letext_label, "Letext", 0); | |
891 | fprintf (asm_out_file, "%s\"\",%d,0,0,", ASM_STABS_OP, N_SO); | |
892 | assemble_name (asm_out_file, letext_label); | |
893 | putc ('\n', asm_out_file); | |
894 | targetm.asm_out.internal_label (asm_out_file, "Letext", 0); | |
895 | } | |
896 | #endif | |
262444a6 | 897 | debug_free_queue (); |
946754ae | 898 | } |
899 | ||
54ae7e56 | 900 | /* Output the index of a type. */ |
901 | ||
902 | static void | |
8ec3a57b | 903 | dbxout_type_index (tree type) |
54ae7e56 | 904 | { |
905 | #ifndef DBX_USE_BINCL | |
e3b8b697 | 906 | fprintf (asm_out_file, "%d", TYPE_SYMTAB_ADDRESS (type)); |
54ae7e56 | 907 | CHARS (3); |
908 | #else | |
909 | struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)]; | |
e3b8b697 | 910 | fprintf (asm_out_file, "(%d,%d)", t->file_number, t->type_number); |
d4b87fe5 | 911 | CHARS (9); |
54ae7e56 | 912 | #endif |
913 | } | |
914 | ||
cb264b86 | 915 | #if DBX_CONTIN_LENGTH > 0 |
946754ae | 916 | /* Continue a symbol-description that gets too big. |
917 | End one symbol table entry with a double-backslash | |
918 | and start a new one, eventually producing something like | |
919 | .stabs "start......\\",code,0,value | |
920 | .stabs "...rest",code,0,value */ | |
921 | ||
922 | static void | |
8ec3a57b | 923 | dbxout_continue (void) |
946754ae | 924 | { |
51cec339 | 925 | emit_pending_bincls_if_required (); |
946754ae | 926 | #ifdef DBX_CONTIN_CHAR |
e3b8b697 | 927 | fprintf (asm_out_file, "%c", DBX_CONTIN_CHAR); |
946754ae | 928 | #else |
e3b8b697 | 929 | fprintf (asm_out_file, "\\\\"); |
946754ae | 930 | #endif |
4303221c | 931 | dbxout_finish_symbol (NULL_TREE); |
e3b8b697 | 932 | fprintf (asm_out_file, "%s\"", ASM_STABS_OP); |
946754ae | 933 | current_sym_nchars = 0; |
934 | } | |
cb264b86 | 935 | #endif /* DBX_CONTIN_LENGTH > 0 */ |
946754ae | 936 | \f |
4bbea254 | 937 | /* Subroutine of `dbxout_type'. Output the type fields of TYPE. |
946754ae | 938 | This must be a separate function because anonymous unions require |
939 | recursive calls. */ | |
940 | ||
941 | static void | |
8ec3a57b | 942 | dbxout_type_fields (tree type) |
946754ae | 943 | { |
944 | tree tem; | |
5d844ba2 | 945 | |
b264b33c | 946 | /* Output the name, type, position (in bits), size (in bits) of each |
5d844ba2 | 947 | field that we can support. */ |
946754ae | 948 | for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) |
949 | { | |
af6ed417 | 950 | /* If one of the nodes is an error_mark or its type is then |
951 | return early. */ | |
11d99e06 | 952 | if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node) |
953 | return; | |
954 | ||
946754ae | 955 | /* Omit here local type decls until we know how to support them. */ |
5d844ba2 | 956 | if (TREE_CODE (tem) == TYPE_DECL |
957 | /* Omit fields whose position or size are variable or too large to | |
958 | represent. */ | |
959 | || (TREE_CODE (tem) == FIELD_DECL | |
960 | && (! host_integerp (bit_position (tem), 0) | |
6460676e | 961 | || ! DECL_SIZE (tem) |
5d844ba2 | 962 | || ! host_integerp (DECL_SIZE (tem), 1))) |
963 | /* Omit here the nameless fields that are used to skip bits. */ | |
964 | || DECL_IGNORED_P (tem)) | |
61be0a71 | 965 | continue; |
5d844ba2 | 966 | |
c40b51de | 967 | else if (TREE_CODE (tem) != CONST_DECL) |
946754ae | 968 | { |
969 | /* Continue the line if necessary, | |
970 | but not before the first field. */ | |
971 | if (tem != TYPE_FIELDS (type)) | |
5d844ba2 | 972 | CONTIN; |
946754ae | 973 | |
c40b51de | 974 | if (DECL_NAME (tem)) |
975 | { | |
e3b8b697 | 976 | fprintf (asm_out_file, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem))); |
c40b51de | 977 | CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem))); |
978 | } | |
979 | else | |
980 | { | |
e3b8b697 | 981 | fprintf (asm_out_file, ":"); |
d4b87fe5 | 982 | CHARS (1); |
c40b51de | 983 | } |
946754ae | 984 | |
9cdc08c6 | 985 | if (use_gnu_debug_info_extensions |
946754ae | 986 | && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem) |
987 | || TREE_CODE (tem) != FIELD_DECL)) | |
988 | { | |
989 | have_used_extensions = 1; | |
e3b8b697 | 990 | putc ('/', asm_out_file); |
946754ae | 991 | putc ((TREE_PRIVATE (tem) ? '0' |
992 | : TREE_PROTECTED (tem) ? '1' : '2'), | |
e3b8b697 | 993 | asm_out_file); |
946754ae | 994 | CHARS (2); |
995 | } | |
996 | ||
997 | dbxout_type ((TREE_CODE (tem) == FIELD_DECL | |
998 | && DECL_BIT_FIELD_TYPE (tem)) | |
9aa97f08 | 999 | ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0); |
946754ae | 1000 | |
1001 | if (TREE_CODE (tem) == VAR_DECL) | |
1002 | { | |
9cdc08c6 | 1003 | if (TREE_STATIC (tem) && use_gnu_debug_info_extensions) |
946754ae | 1004 | { |
d4b87fe5 | 1005 | tree name = DECL_ASSEMBLER_NAME (tem); |
1006 | ||
946754ae | 1007 | have_used_extensions = 1; |
e3b8b697 | 1008 | fprintf (asm_out_file, ":%s;", IDENTIFIER_POINTER (name)); |
d4b87fe5 | 1009 | CHARS (IDENTIFIER_LENGTH (name) + 2); |
946754ae | 1010 | } |
1011 | else | |
d4b87fe5 | 1012 | { |
1013 | /* If TEM is non-static, GDB won't understand it. */ | |
e3b8b697 | 1014 | fprintf (asm_out_file, ",0,0;"); |
d4b87fe5 | 1015 | CHARS (5); |
1016 | } | |
946754ae | 1017 | } |
5d844ba2 | 1018 | else |
946754ae | 1019 | { |
e3b8b697 | 1020 | putc (',', asm_out_file); |
d4b87fe5 | 1021 | print_wide_int (int_bit_position (tem)); |
e3b8b697 | 1022 | putc (',', asm_out_file); |
d4b87fe5 | 1023 | print_wide_int (tree_low_cst (DECL_SIZE (tem), 1)); |
e3b8b697 | 1024 | putc (';', asm_out_file); |
d4b87fe5 | 1025 | CHARS (3); |
946754ae | 1026 | } |
946754ae | 1027 | } |
1028 | } | |
1029 | } | |
1030 | \f | |
4bbea254 | 1031 | /* Subroutine of `dbxout_type_methods'. Output debug info about the |
946754ae | 1032 | method described DECL. DEBUG_NAME is an encoding of the method's |
1033 | type signature. ??? We may be able to do without DEBUG_NAME altogether | |
1034 | now. */ | |
1035 | ||
1036 | static void | |
8ec3a57b | 1037 | dbxout_type_method_1 (tree decl, const char *debug_name) |
946754ae | 1038 | { |
946754ae | 1039 | char c1 = 'A', c2; |
1040 | ||
1041 | if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE) | |
1042 | c2 = '?'; | |
1043 | else /* it's a METHOD_TYPE. */ | |
1044 | { | |
96704d5f | 1045 | tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))); |
946754ae | 1046 | /* A for normal functions. |
1047 | B for `const' member functions. | |
1048 | C for `volatile' member functions. | |
1049 | D for `const volatile' member functions. */ | |
1050 | if (TYPE_READONLY (TREE_TYPE (firstarg))) | |
1051 | c1 += 1; | |
1052 | if (TYPE_VOLATILE (TREE_TYPE (firstarg))) | |
1053 | c1 += 2; | |
1054 | ||
1055 | if (DECL_VINDEX (decl)) | |
1056 | c2 = '*'; | |
1057 | else | |
1058 | c2 = '.'; | |
1059 | } | |
1060 | ||
e3b8b697 | 1061 | fprintf (asm_out_file, ":%s;%c%c%c", debug_name, |
5d844ba2 | 1062 | TREE_PRIVATE (decl) ? '0' |
1063 | : TREE_PROTECTED (decl) ? '1' : '2', c1, c2); | |
946754ae | 1064 | CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6 |
1065 | - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)))); | |
5d844ba2 | 1066 | |
1067 | if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0)) | |
946754ae | 1068 | { |
d4b87fe5 | 1069 | print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0)); |
e3b8b697 | 1070 | putc (';', asm_out_file); |
d4b87fe5 | 1071 | CHARS (1); |
9aa97f08 | 1072 | dbxout_type (DECL_CONTEXT (decl), 0); |
e3b8b697 | 1073 | fprintf (asm_out_file, ";"); |
d4b87fe5 | 1074 | CHARS (1); |
946754ae | 1075 | } |
1076 | } | |
1077 | \f | |
1078 | /* Subroutine of `dbxout_type'. Output debug info about the methods defined | |
1079 | in TYPE. */ | |
1080 | ||
1081 | static void | |
8ec3a57b | 1082 | dbxout_type_methods (tree type) |
946754ae | 1083 | { |
1084 | /* C++: put out the method names and their parameter lists */ | |
946754ae | 1085 | tree methods = TYPE_METHODS (type); |
3d82b777 | 1086 | tree type_encoding; |
19cb6b50 | 1087 | tree fndecl; |
1088 | tree last; | |
c5684a1e | 1089 | char formatted_type_identifier_length[16]; |
19cb6b50 | 1090 | int type_identifier_length; |
946754ae | 1091 | |
1092 | if (methods == NULL_TREE) | |
1093 | return; | |
1094 | ||
d0bcb1eb | 1095 | type_encoding = DECL_NAME (TYPE_NAME (type)); |
3d82b777 | 1096 | |
d0bcb1eb | 1097 | type_identifier_length = IDENTIFIER_LENGTH (type_encoding); |
3d82b777 | 1098 | |
9aa97f08 | 1099 | sprintf (formatted_type_identifier_length, "%d", type_identifier_length); |
c5684a1e | 1100 | |
871b7da1 | 1101 | if (TREE_CODE (methods) != TREE_VEC) |
b23cec01 | 1102 | fndecl = methods; |
1103 | else if (TREE_VEC_ELT (methods, 0) != NULL_TREE) | |
946754ae | 1104 | fndecl = TREE_VEC_ELT (methods, 0); |
9cdc08c6 | 1105 | else |
1106 | fndecl = TREE_VEC_ELT (methods, 1); | |
946754ae | 1107 | |
946754ae | 1108 | while (fndecl) |
1109 | { | |
b769415e | 1110 | int need_prefix = 1; |
1111 | ||
d0bcb1eb | 1112 | /* Group together all the methods for the same operation. |
1113 | These differ in the types of the arguments. */ | |
946754ae | 1114 | for (last = NULL_TREE; |
1115 | fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last)); | |
1116 | fndecl = TREE_CHAIN (fndecl)) | |
1117 | /* Output the name of the field (after overloading), as | |
1118 | well as the name of the field before overloading, along | |
1119 | with its parameter list */ | |
1120 | { | |
d0bcb1eb | 1121 | /* This is the "mangled" name of the method. |
1122 | It encodes the argument types. */ | |
7e64c604 | 1123 | const char *debug_name; |
946754ae | 1124 | |
7e64c604 | 1125 | /* Skip methods that aren't FUNCTION_DECLs. (In C++, these |
1126 | include TEMPLATE_DECLs.) The debugger doesn't know what | |
1127 | to do with such entities anyhow. */ | |
1128 | if (TREE_CODE (fndecl) != FUNCTION_DECL) | |
1129 | continue; | |
1130 | ||
d4b87fe5 | 1131 | debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)); |
7e64c604 | 1132 | |
946754ae | 1133 | CONTIN; |
1134 | ||
1135 | last = fndecl; | |
d0bcb1eb | 1136 | |
8f80e66d | 1137 | /* Also ignore abstract methods; those are only interesting to |
1138 | the DWARF backends. */ | |
1139 | if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl)) | |
d0bcb1eb | 1140 | continue; |
1141 | ||
b769415e | 1142 | /* Redundantly output the plain name, since that's what gdb |
1143 | expects. */ | |
1144 | if (need_prefix) | |
1145 | { | |
1146 | tree name = DECL_NAME (fndecl); | |
e3b8b697 | 1147 | fprintf (asm_out_file, "%s::", IDENTIFIER_POINTER (name)); |
b769415e | 1148 | CHARS (IDENTIFIER_LENGTH (name) + 2); |
1149 | need_prefix = 0; | |
1150 | } | |
1151 | ||
9aa97f08 | 1152 | dbxout_type (TREE_TYPE (fndecl), 0); |
d0bcb1eb | 1153 | |
946754ae | 1154 | dbxout_type_method_1 (fndecl, debug_name); |
1155 | } | |
b769415e | 1156 | if (!need_prefix) |
1157 | { | |
e3b8b697 | 1158 | putc (';', asm_out_file); |
b769415e | 1159 | CHARS (1); |
1160 | } | |
946754ae | 1161 | } |
1162 | } | |
bf503a12 | 1163 | |
1164 | /* Emit a "range" type specification, which has the form: | |
1165 | "r<index type>;<lower bound>;<upper bound>;". | |
a92771b8 | 1166 | TYPE is an INTEGER_TYPE. */ |
bf503a12 | 1167 | |
1168 | static void | |
8ec3a57b | 1169 | dbxout_range_type (tree type) |
bf503a12 | 1170 | { |
e3b8b697 | 1171 | fprintf (asm_out_file, "r"); |
a774577b | 1172 | if (TREE_TYPE (type)) |
9aa97f08 | 1173 | dbxout_type (TREE_TYPE (type), 0); |
0c688ce9 | 1174 | else if (TREE_CODE (type) != INTEGER_TYPE) |
9aa97f08 | 1175 | dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */ |
bf503a12 | 1176 | else |
1177 | { | |
255a4f1f | 1178 | /* Traditionally, we made sure 'int' was type 1, and builtin types |
1179 | were defined to be sub-ranges of int. Unfortunately, this | |
1180 | does not allow us to distinguish true sub-ranges from integer | |
1181 | types. So, instead we define integer (non-sub-range) types as | |
829f57e9 | 1182 | sub-ranges of themselves. This matters for Chill. If this isn't |
1183 | a subrange type, then we want to define it in terms of itself. | |
1184 | However, in C, this may be an anonymous integer type, and we don't | |
1185 | want to emit debug info referring to it. Just calling | |
1186 | dbxout_type_index won't work anyways, because the type hasn't been | |
1187 | defined yet. We make this work for both cases by checked to see | |
1188 | whether this is a defined type, referring to it if it is, and using | |
1189 | 'int' otherwise. */ | |
1190 | if (TYPE_SYMTAB_ADDRESS (type) != 0) | |
1191 | dbxout_type_index (type); | |
1192 | else | |
1193 | dbxout_type_index (integer_type_node); | |
bf503a12 | 1194 | } |
5d844ba2 | 1195 | |
1196 | if (TYPE_MIN_VALUE (type) != 0 | |
1197 | && host_integerp (TYPE_MIN_VALUE (type), 0)) | |
9bf3e679 | 1198 | { |
e3b8b697 | 1199 | putc (';', asm_out_file); |
d4b87fe5 | 1200 | CHARS (1); |
0989224f | 1201 | if (print_int_cst_bounds_in_octal_p (type)) |
1202 | print_int_cst_octal (TYPE_MIN_VALUE (type)); | |
1203 | else | |
1204 | print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0)); | |
9bf3e679 | 1205 | } |
bf503a12 | 1206 | else |
d4b87fe5 | 1207 | { |
e3b8b697 | 1208 | fprintf (asm_out_file, ";0"); |
d4b87fe5 | 1209 | CHARS (2); |
1210 | } | |
5d844ba2 | 1211 | |
1212 | if (TYPE_MAX_VALUE (type) != 0 | |
1213 | && host_integerp (TYPE_MAX_VALUE (type), 0)) | |
9bf3e679 | 1214 | { |
e3b8b697 | 1215 | putc (';', asm_out_file); |
d4b87fe5 | 1216 | CHARS (1); |
0989224f | 1217 | if (print_int_cst_bounds_in_octal_p (type)) |
1218 | print_int_cst_octal (TYPE_MAX_VALUE (type)); | |
1219 | else | |
1220 | print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0)); | |
e3b8b697 | 1221 | putc (';', asm_out_file); |
d4b87fe5 | 1222 | CHARS (1); |
9bf3e679 | 1223 | } |
bf503a12 | 1224 | else |
d4b87fe5 | 1225 | { |
e3b8b697 | 1226 | fprintf (asm_out_file, ";-1;"); |
d4b87fe5 | 1227 | CHARS (4); |
1228 | } | |
bf503a12 | 1229 | } |
946754ae | 1230 | \f |
262444a6 | 1231 | |
946754ae | 1232 | /* Output a reference to a type. If the type has not yet been |
1233 | described in the dbx output, output its definition now. | |
1234 | For a type already defined, just refer to its definition | |
1235 | using the type number. | |
1236 | ||
1237 | If FULL is nonzero, and the type has been described only with | |
1238 | a forward-reference, output the definition now. | |
1239 | If FULL is zero in this case, just refer to the forward-reference | |
9aa97f08 | 1240 | using the number previously allocated. */ |
946754ae | 1241 | |
1242 | static void | |
8ec3a57b | 1243 | dbxout_type (tree type, int full) |
946754ae | 1244 | { |
19cb6b50 | 1245 | tree tem; |
1d971bfd | 1246 | tree main_variant; |
c61d074f | 1247 | static int anonymous_type_number = 0; |
946754ae | 1248 | |
e2ea7e3a | 1249 | if (TREE_CODE (type) == VECTOR_TYPE) |
5efc251c | 1250 | /* The frontend feeds us a representation for the vector as a struct |
1251 | containing an array. Pull out the array type. */ | |
1252 | type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type))); | |
e2ea7e3a | 1253 | |
946754ae | 1254 | /* If there was an input error and we don't really have a type, |
1255 | avoid crashing and write something that is at least valid | |
1256 | by assuming `int'. */ | |
1257 | if (type == error_mark_node) | |
1258 | type = integer_type_node; | |
c48f961d | 1259 | else |
946754ae | 1260 | { |
946754ae | 1261 | if (TYPE_NAME (type) |
1262 | && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
ac3e80e4 | 1263 | && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type))) |
946754ae | 1264 | full = 0; |
1265 | } | |
1266 | ||
1d971bfd | 1267 | /* Try to find the "main variant" with the same name. */ |
1268 | if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
1269 | && DECL_ORIGINAL_TYPE (TYPE_NAME (type))) | |
1270 | main_variant = TREE_TYPE (TYPE_NAME (type)); | |
1271 | else | |
1272 | main_variant = TYPE_MAIN_VARIANT (type); | |
1273 | ||
1274 | /* If we are not using extensions, stabs does not distinguish const and | |
1275 | volatile, so there is no need to make them separate types. */ | |
1276 | if (!use_gnu_debug_info_extensions) | |
1277 | type = main_variant; | |
1278 | ||
946754ae | 1279 | if (TYPE_SYMTAB_ADDRESS (type) == 0) |
1280 | { | |
1281 | /* Type has no dbx number assigned. Assign next available number. */ | |
1282 | TYPE_SYMTAB_ADDRESS (type) = next_type_number++; | |
1283 | ||
1284 | /* Make sure type vector is long enough to record about this type. */ | |
1285 | ||
1286 | if (next_type_number == typevec_len) | |
1287 | { | |
37808e3a | 1288 | typevec |
f0af5a88 | 1289 | = ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0])); |
1290 | memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]); | |
946754ae | 1291 | typevec_len *= 2; |
1292 | } | |
54ae7e56 | 1293 | |
1294 | #ifdef DBX_USE_BINCL | |
51cec339 | 1295 | emit_pending_bincls_if_required (); |
37808e3a | 1296 | typevec[TYPE_SYMTAB_ADDRESS (type)].file_number |
1297 | = current_file->file_number; | |
1298 | typevec[TYPE_SYMTAB_ADDRESS (type)].type_number | |
1299 | = current_file->next_type_number++; | |
54ae7e56 | 1300 | #endif |
946754ae | 1301 | } |
1302 | ||
262444a6 | 1303 | if (flag_debug_only_used_symbols) |
1304 | { | |
1305 | if ((TREE_CODE (type) == RECORD_TYPE | |
1306 | || TREE_CODE (type) == UNION_TYPE | |
1307 | || TREE_CODE (type) == QUAL_UNION_TYPE | |
1308 | || TREE_CODE (type) == ENUMERAL_TYPE) | |
1309 | && TYPE_STUB_DECL (type) | |
ce45a448 | 1310 | && DECL_P (TYPE_STUB_DECL (type)) |
262444a6 | 1311 | && ! DECL_IGNORED_P (TYPE_STUB_DECL (type))) |
1312 | debug_queue_symbol (TYPE_STUB_DECL (type)); | |
1313 | else if (TYPE_NAME (type) | |
1314 | && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL) | |
1315 | debug_queue_symbol (TYPE_NAME (type)); | |
1316 | } | |
8ec3a57b | 1317 | |
946754ae | 1318 | /* Output the number of this type, to refer to it. */ |
54ae7e56 | 1319 | dbxout_type_index (type); |
946754ae | 1320 | |
439c05a0 | 1321 | #ifdef DBX_TYPE_DEFINED |
1322 | if (DBX_TYPE_DEFINED (type)) | |
1323 | return; | |
1324 | #endif | |
1325 | ||
946754ae | 1326 | /* If this type's definition has been output or is now being output, |
1327 | that is all. */ | |
1328 | ||
54ae7e56 | 1329 | switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status) |
946754ae | 1330 | { |
1331 | case TYPE_UNSEEN: | |
1332 | break; | |
1333 | case TYPE_XREF: | |
f10caba4 | 1334 | /* If we have already had a cross reference, |
1335 | and either that's all we want or that's the best we could do, | |
1336 | don't repeat the cross reference. | |
1337 | Sun dbx crashes if we do. */ | |
4b72716d | 1338 | if (! full || !COMPLETE_TYPE_P (type) |
f10caba4 | 1339 | /* No way in DBX fmt to describe a variable size. */ |
79433a4c | 1340 | || ! host_integerp (TYPE_SIZE (type), 1)) |
946754ae | 1341 | return; |
1342 | break; | |
1343 | case TYPE_DEFINED: | |
1344 | return; | |
1345 | } | |
1346 | ||
1347 | #ifdef DBX_NO_XREFS | |
1348 | /* For systems where dbx output does not allow the `=xsNAME:' syntax, | |
1349 | leave the type-number completely undefined rather than output | |
7cac4c57 | 1350 | a cross-reference. If we have already used GNU debug info extensions, |
1351 | then it is OK to output a cross reference. This is necessary to get | |
1352 | proper C++ debug output. */ | |
1353 | if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE | |
1354 | || TREE_CODE (type) == QUAL_UNION_TYPE | |
1355 | || TREE_CODE (type) == ENUMERAL_TYPE) | |
1356 | && ! use_gnu_debug_info_extensions) | |
5c579180 | 1357 | /* We must use the same test here as we use twice below when deciding |
1358 | whether to emit a cross-reference. */ | |
1359 | if ((TYPE_NAME (type) != 0 | |
1360 | && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
1361 | && DECL_IGNORED_P (TYPE_NAME (type))) | |
1362 | && !full) | |
4b72716d | 1363 | || !COMPLETE_TYPE_P (type) |
5c579180 | 1364 | /* No way in DBX fmt to describe a variable size. */ |
79433a4c | 1365 | || ! host_integerp (TYPE_SIZE (type), 1)) |
946754ae | 1366 | { |
54ae7e56 | 1367 | typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF; |
946754ae | 1368 | return; |
1369 | } | |
1370 | #endif | |
1371 | ||
1372 | /* Output a definition now. */ | |
1373 | ||
e3b8b697 | 1374 | fprintf (asm_out_file, "="); |
946754ae | 1375 | CHARS (1); |
1376 | ||
1377 | /* Mark it as defined, so that if it is self-referent | |
1378 | we will not get into an infinite recursion of definitions. */ | |
1379 | ||
54ae7e56 | 1380 | typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED; |
946754ae | 1381 | |
1d971bfd | 1382 | /* If this type is a variant of some other, hand off. Types with |
1383 | different names are usefully distinguished. We only distinguish | |
1384 | cv-qualified types if we're using extensions. */ | |
1385 | if (TYPE_READONLY (type) > TYPE_READONLY (main_variant)) | |
1386 | { | |
e3b8b697 | 1387 | putc ('k', asm_out_file); |
1d971bfd | 1388 | CHARS (1); |
1389 | dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0); | |
1390 | return; | |
1391 | } | |
1392 | else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant)) | |
1393 | { | |
e3b8b697 | 1394 | putc ('B', asm_out_file); |
1d971bfd | 1395 | CHARS (1); |
1396 | dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0); | |
1397 | return; | |
1398 | } | |
1399 | else if (main_variant != TYPE_MAIN_VARIANT (type)) | |
1400 | { | |
262444a6 | 1401 | if (flag_debug_only_used_symbols) |
1402 | { | |
1403 | tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type)); | |
1404 | ||
8ec3a57b | 1405 | if ((TREE_CODE (orig_type) == RECORD_TYPE |
262444a6 | 1406 | || TREE_CODE (orig_type) == UNION_TYPE |
1407 | || TREE_CODE (orig_type) == QUAL_UNION_TYPE | |
1408 | || TREE_CODE (orig_type) == ENUMERAL_TYPE) | |
1409 | && TYPE_STUB_DECL (orig_type) | |
1410 | && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type))) | |
1411 | debug_queue_symbol (TYPE_STUB_DECL (orig_type)); | |
1412 | } | |
1d971bfd | 1413 | /* 'type' is a typedef; output the type it refers to. */ |
9aa97f08 | 1414 | dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0); |
4a4d93c2 | 1415 | return; |
1416 | } | |
1d971bfd | 1417 | /* else continue. */ |
4a4d93c2 | 1418 | |
946754ae | 1419 | switch (TREE_CODE (type)) |
1420 | { | |
1421 | case VOID_TYPE: | |
1422 | case LANG_TYPE: | |
0c6d8c36 | 1423 | /* For a void type, just define it as itself; i.e., "5=5". |
946754ae | 1424 | This makes us consider it defined |
1425 | without saying what it is. The debugger will make it | |
1426 | a void type when the reference is seen, and nothing will | |
1427 | ever override that default. */ | |
54ae7e56 | 1428 | dbxout_type_index (type); |
946754ae | 1429 | break; |
1430 | ||
1431 | case INTEGER_TYPE: | |
78a8ed03 | 1432 | if (type == char_type_node && ! TYPE_UNSIGNED (type)) |
54ae7e56 | 1433 | { |
1434 | /* Output the type `char' as a subrange of itself! | |
1435 | I don't understand this definition, just copied it | |
1436 | from the output of pcc. | |
1437 | This used to use `r2' explicitly and we used to | |
1438 | take care to make sure that `char' was type number 2. */ | |
e3b8b697 | 1439 | fprintf (asm_out_file, "r"); |
d4b87fe5 | 1440 | CHARS (1); |
54ae7e56 | 1441 | dbxout_type_index (type); |
e3b8b697 | 1442 | fprintf (asm_out_file, ";0;127;"); |
d4b87fe5 | 1443 | CHARS (7); |
54ae7e56 | 1444 | } |
155b05dc | 1445 | |
1446 | /* If this is a subtype of another integer type, always prefer to | |
1447 | write it as a subtype. */ | |
1448 | else if (TREE_TYPE (type) != 0 | |
79433a4c | 1449 | && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE) |
1eefe280 | 1450 | { |
153b0682 | 1451 | /* If the size is non-standard, say what it is if we can use |
1452 | GDB extensions. */ | |
1453 | ||
1454 | if (use_gnu_debug_info_extensions | |
1455 | && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node)) | |
1456 | { | |
1457 | have_used_extensions = 1; | |
e3b8b697 | 1458 | fprintf (asm_out_file, "@s%d;", TYPE_PRECISION (type)); |
153b0682 | 1459 | CHARS (5); |
1460 | } | |
1461 | ||
1462 | dbxout_range_type (type); | |
1eefe280 | 1463 | } |
155b05dc | 1464 | |
1465 | else | |
1eefe280 | 1466 | { |
155b05dc | 1467 | /* If the size is non-standard, say what it is if we can use |
1468 | GDB extensions. */ | |
1469 | ||
1470 | if (use_gnu_debug_info_extensions | |
1471 | && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node)) | |
d4b87fe5 | 1472 | { |
1473 | have_used_extensions = 1; | |
e3b8b697 | 1474 | fprintf (asm_out_file, "@s%d;", TYPE_PRECISION (type)); |
d4b87fe5 | 1475 | CHARS (5); |
1476 | } | |
155b05dc | 1477 | |
8ec3a57b | 1478 | if (print_int_cst_bounds_in_octal_p (type)) |
155b05dc | 1479 | { |
e3b8b697 | 1480 | fprintf (asm_out_file, "r"); |
d4b87fe5 | 1481 | CHARS (1); |
bdeba923 | 1482 | |
1483 | /* If this type derives from another type, output type index of | |
1484 | parent type. This is particularly important when parent type | |
1485 | is an enumerated type, because not generating the parent type | |
1486 | index would transform the definition of this enumerated type | |
1487 | into a plain unsigned type. */ | |
1488 | if (TREE_TYPE (type) != 0) | |
1489 | dbxout_type_index (TREE_TYPE (type)); | |
1490 | else | |
1491 | dbxout_type_index (type); | |
1492 | ||
e3b8b697 | 1493 | fprintf (asm_out_file, ";"); |
d4b87fe5 | 1494 | CHARS (1); |
155b05dc | 1495 | print_int_cst_octal (TYPE_MIN_VALUE (type)); |
e3b8b697 | 1496 | fprintf (asm_out_file, ";"); |
d4b87fe5 | 1497 | CHARS (1); |
155b05dc | 1498 | print_int_cst_octal (TYPE_MAX_VALUE (type)); |
e3b8b697 | 1499 | fprintf (asm_out_file, ";"); |
d4b87fe5 | 1500 | CHARS (1); |
155b05dc | 1501 | } |
1502 | ||
1503 | else | |
1504 | /* Output other integer types as subranges of `int'. */ | |
1505 | dbxout_range_type (type); | |
1eefe280 | 1506 | } |
155b05dc | 1507 | |
946754ae | 1508 | break; |
1509 | ||
1510 | case REAL_TYPE: | |
1511 | /* This used to say `r1' and we used to take care | |
1512 | to make sure that `int' was type number 1. */ | |
e3b8b697 | 1513 | fprintf (asm_out_file, "r"); |
d4b87fe5 | 1514 | CHARS (1); |
54ae7e56 | 1515 | dbxout_type_index (integer_type_node); |
e3b8b697 | 1516 | putc (';', asm_out_file); |
d4b87fe5 | 1517 | CHARS (1); |
1518 | print_wide_int (int_size_in_bytes (type)); | |
e3b8b697 | 1519 | fputs (";0;", asm_out_file); |
d4b87fe5 | 1520 | CHARS (3); |
946754ae | 1521 | break; |
1522 | ||
b264b33c | 1523 | case CHAR_TYPE: |
f4267b6f | 1524 | if (use_gnu_debug_info_extensions) |
4d3a9616 | 1525 | { |
d4b87fe5 | 1526 | have_used_extensions = 1; |
e3b8b697 | 1527 | fputs ("@s", asm_out_file); |
d4b87fe5 | 1528 | CHARS (2); |
1529 | print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type)); | |
e3b8b697 | 1530 | fputs (";-20;", asm_out_file); |
d4b87fe5 | 1531 | CHARS (4); |
4d3a9616 | 1532 | } |
f4267b6f | 1533 | else |
54ae7e56 | 1534 | { |
1535 | /* Output the type `char' as a subrange of itself. | |
1536 | That is what pcc seems to do. */ | |
e3b8b697 | 1537 | fprintf (asm_out_file, "r"); |
d4b87fe5 | 1538 | CHARS (1); |
54ae7e56 | 1539 | dbxout_type_index (char_type_node); |
e3b8b697 | 1540 | fprintf (asm_out_file, ";0;%d;", TYPE_UNSIGNED (type) ? 255 : 127); |
d4b87fe5 | 1541 | CHARS (7); |
54ae7e56 | 1542 | } |
b264b33c | 1543 | break; |
1544 | ||
f4267b6f | 1545 | case BOOLEAN_TYPE: |
1546 | if (use_gnu_debug_info_extensions) | |
4d3a9616 | 1547 | { |
d4b87fe5 | 1548 | have_used_extensions = 1; |
e3b8b697 | 1549 | fputs ("@s", asm_out_file); |
d4b87fe5 | 1550 | CHARS (2); |
1551 | print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type)); | |
e3b8b697 | 1552 | fputs (";-16;", asm_out_file); |
d4b87fe5 | 1553 | CHARS (4); |
4d3a9616 | 1554 | } |
f4267b6f | 1555 | else /* Define as enumeral type (False, True) */ |
d4b87fe5 | 1556 | { |
e3b8b697 | 1557 | fprintf (asm_out_file, "eFalse:0,True:1,;"); |
d4b87fe5 | 1558 | CHARS (17); |
1559 | } | |
b264b33c | 1560 | break; |
1561 | ||
1562 | case FILE_TYPE: | |
e3b8b697 | 1563 | putc ('d', asm_out_file); |
b264b33c | 1564 | CHARS (1); |
9aa97f08 | 1565 | dbxout_type (TREE_TYPE (type), 0); |
b264b33c | 1566 | break; |
1567 | ||
1568 | case COMPLEX_TYPE: | |
6b6cb0d6 | 1569 | /* Differs from the REAL_TYPE by its new data type number. |
1570 | R3 is NF_COMPLEX. We don't try to use any of the other NF_* | |
1571 | codes since gdb doesn't care anyway. */ | |
b264b33c | 1572 | |
1573 | if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE) | |
1574 | { | |
e3b8b697 | 1575 | fputs ("R3;", asm_out_file); |
6b6cb0d6 | 1576 | CHARS (3); |
d4b87fe5 | 1577 | print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type))); |
e3b8b697 | 1578 | fputs (";0;", asm_out_file); |
d4b87fe5 | 1579 | CHARS (3); |
c99df4b3 | 1580 | } |
1581 | else | |
1582 | { | |
1583 | /* Output a complex integer type as a structure, | |
1584 | pending some other way to do it. */ | |
e3b8b697 | 1585 | putc ('s', asm_out_file); |
d4b87fe5 | 1586 | CHARS (1); |
1587 | print_wide_int (int_size_in_bytes (type)); | |
e3b8b697 | 1588 | fprintf (asm_out_file, "real:"); |
d4b87fe5 | 1589 | CHARS (5); |
1590 | ||
9aa97f08 | 1591 | dbxout_type (TREE_TYPE (type), 0); |
e3b8b697 | 1592 | fprintf (asm_out_file, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type))); |
d4b87fe5 | 1593 | CHARS (7); |
e3b8b697 | 1594 | fprintf (asm_out_file, "imag:"); |
c99df4b3 | 1595 | CHARS (5); |
9aa97f08 | 1596 | dbxout_type (TREE_TYPE (type), 0); |
e3b8b697 | 1597 | fprintf (asm_out_file, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)), |
c99df4b3 | 1598 | TYPE_PRECISION (TREE_TYPE (type))); |
d4b87fe5 | 1599 | CHARS (10); |
c99df4b3 | 1600 | } |
b264b33c | 1601 | break; |
1602 | ||
1603 | case SET_TYPE: | |
11aea978 | 1604 | if (use_gnu_debug_info_extensions) |
1605 | { | |
1606 | have_used_extensions = 1; | |
e3b8b697 | 1607 | fputs ("@s", asm_out_file); |
d4b87fe5 | 1608 | CHARS (2); |
1609 | print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type)); | |
e3b8b697 | 1610 | putc (';', asm_out_file); |
d4b87fe5 | 1611 | CHARS (1); |
1612 | ||
11aea978 | 1613 | /* Check if a bitstring type, which in Chill is |
a92771b8 | 1614 | different from a [power]set. */ |
11aea978 | 1615 | if (TYPE_STRING_FLAG (type)) |
d4b87fe5 | 1616 | { |
e3b8b697 | 1617 | fprintf (asm_out_file, "@S;"); |
d4b87fe5 | 1618 | CHARS (3); |
1619 | } | |
11aea978 | 1620 | } |
e3b8b697 | 1621 | putc ('S', asm_out_file); |
b264b33c | 1622 | CHARS (1); |
9aa97f08 | 1623 | dbxout_type (TYPE_DOMAIN (type), 0); |
b264b33c | 1624 | break; |
1625 | ||
946754ae | 1626 | case ARRAY_TYPE: |
1020180f | 1627 | /* Make arrays of packed bits look like bitstrings for chill. */ |
1628 | if (TYPE_PACKED (type) && use_gnu_debug_info_extensions) | |
1629 | { | |
1630 | have_used_extensions = 1; | |
e3b8b697 | 1631 | fputs ("@s", asm_out_file); |
d4b87fe5 | 1632 | CHARS (2); |
1633 | print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type)); | |
e3b8b697 | 1634 | fprintf (asm_out_file, ";@S;S"); |
d4b87fe5 | 1635 | CHARS (5); |
9aa97f08 | 1636 | dbxout_type (TYPE_DOMAIN (type), 0); |
1020180f | 1637 | break; |
1638 | } | |
d4b87fe5 | 1639 | |
946754ae | 1640 | /* Output "a" followed by a range type definition |
1641 | for the index type of the array | |
1642 | followed by a reference to the target-type. | |
bf503a12 | 1643 | ar1;0;N;M for a C array of type M and size N+1. */ |
11aea978 | 1644 | /* Check if a character string type, which in Chill is |
a92771b8 | 1645 | different from an array of characters. */ |
11aea978 | 1646 | if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions) |
1647 | { | |
1648 | have_used_extensions = 1; | |
e3b8b697 | 1649 | fprintf (asm_out_file, "@S;"); |
d4b87fe5 | 1650 | CHARS (3); |
11aea978 | 1651 | } |
bf503a12 | 1652 | tem = TYPE_DOMAIN (type); |
1653 | if (tem == NULL) | |
54ae7e56 | 1654 | { |
e3b8b697 | 1655 | fprintf (asm_out_file, "ar"); |
d4b87fe5 | 1656 | CHARS (2); |
54ae7e56 | 1657 | dbxout_type_index (integer_type_node); |
e3b8b697 | 1658 | fprintf (asm_out_file, ";0;-1;"); |
d4b87fe5 | 1659 | CHARS (6); |
54ae7e56 | 1660 | } |
bf503a12 | 1661 | else |
1662 | { | |
e3b8b697 | 1663 | fprintf (asm_out_file, "a"); |
d4b87fe5 | 1664 | CHARS (1); |
bf503a12 | 1665 | dbxout_range_type (tem); |
1666 | } | |
d4b87fe5 | 1667 | |
9aa97f08 | 1668 | dbxout_type (TREE_TYPE (type), 0); |
946754ae | 1669 | break; |
1670 | ||
1671 | case RECORD_TYPE: | |
1672 | case UNION_TYPE: | |
7f8a347a | 1673 | case QUAL_UNION_TYPE: |
946754ae | 1674 | { |
f6cc6a08 | 1675 | tree binfo = TYPE_BINFO (type); |
946754ae | 1676 | |
5c579180 | 1677 | /* Output a structure type. We must use the same test here as we |
1678 | use in the DBX_NO_XREFS case above. */ | |
439c05a0 | 1679 | if ((TYPE_NAME (type) != 0 |
1680 | && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
1681 | && DECL_IGNORED_P (TYPE_NAME (type))) | |
1682 | && !full) | |
4b72716d | 1683 | || !COMPLETE_TYPE_P (type) |
d0bcb1eb | 1684 | /* No way in DBX fmt to describe a variable size. */ |
79433a4c | 1685 | || ! host_integerp (TYPE_SIZE (type), 1)) |
946754ae | 1686 | { |
1687 | /* If the type is just a cross reference, output one | |
1688 | and mark the type as partially described. | |
1689 | If it later becomes defined, we will output | |
1690 | its real definition. | |
1691 | If the type has a name, don't nest its definition within | |
1692 | another type's definition; instead, output an xref | |
1693 | and let the definition come when the name is defined. */ | |
e3b8b697 | 1694 | fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asm_out_file); |
d4b87fe5 | 1695 | CHARS (2); |
c61d074f | 1696 | if (TYPE_NAME (type) != 0) |
1697 | dbxout_type_name (type); | |
1698 | else | |
d4b87fe5 | 1699 | { |
e3b8b697 | 1700 | fprintf (asm_out_file, "$$%d", anonymous_type_number++); |
d4b87fe5 | 1701 | CHARS (5); |
1702 | } | |
1703 | ||
e3b8b697 | 1704 | fprintf (asm_out_file, ":"); |
d4b87fe5 | 1705 | CHARS (1); |
54ae7e56 | 1706 | typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF; |
946754ae | 1707 | break; |
1708 | } | |
946754ae | 1709 | |
946754ae | 1710 | /* Identify record or union, and print its size. */ |
e3b8b697 | 1711 | putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asm_out_file); |
d4b87fe5 | 1712 | CHARS (1); |
1713 | print_wide_int (int_size_in_bytes (type)); | |
946754ae | 1714 | |
f6cc6a08 | 1715 | if (binfo) |
946754ae | 1716 | { |
f6cc6a08 | 1717 | int i; |
1718 | tree child; | |
db77fe17 | 1719 | VEC (tree) *accesses = BINFO_BASE_ACCESSES (binfo); |
f6cc6a08 | 1720 | |
9cdc08c6 | 1721 | if (use_gnu_debug_info_extensions) |
946754ae | 1722 | { |
f6cc6a08 | 1723 | if (BINFO_N_BASE_BINFOS (binfo)) |
1724 | { | |
1725 | have_used_extensions = 1; | |
e3b8b697 | 1726 | fprintf (asm_out_file, "!%u,", BINFO_N_BASE_BINFOS (binfo)); |
f6cc6a08 | 1727 | CHARS (8); |
1728 | } | |
946754ae | 1729 | } |
f6cc6a08 | 1730 | for (i = 0; BINFO_BASE_ITERATE (binfo, i, child); i++) |
946754ae | 1731 | { |
db77fe17 | 1732 | tree access = (accesses ? VEC_index (tree, accesses, i) |
f6cc6a08 | 1733 | : access_public_node); |
1734 | ||
1735 | if (use_gnu_debug_info_extensions) | |
1736 | { | |
1737 | have_used_extensions = 1; | |
e3b8b697 | 1738 | putc (BINFO_VIRTUAL_P (child) ? '1' : '0', asm_out_file); |
f6cc6a08 | 1739 | putc (access == access_public_node ? '2' : |
1740 | (access == access_protected_node ? '1' :'0'), | |
e3b8b697 | 1741 | asm_out_file); |
f6cc6a08 | 1742 | CHARS (2); |
1743 | if (BINFO_VIRTUAL_P (child) | |
1744 | && strcmp (lang_hooks.name, "GNU C++") == 0) | |
1745 | /* For a virtual base, print the (negative) | |
1746 | offset within the vtable where we must look | |
1747 | to find the necessary adjustment. */ | |
1748 | print_wide_int | |
1749 | (tree_low_cst (BINFO_VPTR_FIELD (child), 0) | |
1750 | * BITS_PER_UNIT); | |
1751 | else | |
1752 | print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0) | |
1753 | * BITS_PER_UNIT); | |
e3b8b697 | 1754 | putc (',', asm_out_file); |
f6cc6a08 | 1755 | CHARS (1); |
1756 | dbxout_type (BINFO_TYPE (child), 0); | |
e3b8b697 | 1757 | putc (';', asm_out_file); |
f6cc6a08 | 1758 | CHARS (1); |
1759 | } | |
1760 | else | |
1761 | { | |
1762 | /* Print out the base class information with | |
1763 | fields which have the same names at the types | |
1764 | they hold. */ | |
1765 | dbxout_type_name (BINFO_TYPE (child)); | |
e3b8b697 | 1766 | putc (':', asm_out_file); |
f6cc6a08 | 1767 | CHARS (1); |
1768 | dbxout_type (BINFO_TYPE (child), full); | |
e3b8b697 | 1769 | putc (',', asm_out_file); |
f6cc6a08 | 1770 | CHARS (1); |
1771 | print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0) | |
1772 | * BITS_PER_UNIT); | |
e3b8b697 | 1773 | putc (',', asm_out_file); |
f6cc6a08 | 1774 | CHARS (1); |
1775 | print_wide_int | |
1776 | (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)), 0) | |
1777 | * BITS_PER_UNIT); | |
e3b8b697 | 1778 | putc (';', asm_out_file); |
f6cc6a08 | 1779 | CHARS (1); |
1780 | } | |
946754ae | 1781 | } |
1782 | } | |
1783 | } | |
1784 | ||
946754ae | 1785 | /* Write out the field declarations. */ |
1786 | dbxout_type_fields (type); | |
9cdc08c6 | 1787 | if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE) |
946754ae | 1788 | { |
1789 | have_used_extensions = 1; | |
1790 | dbxout_type_methods (type); | |
1791 | } | |
5d844ba2 | 1792 | |
e3b8b697 | 1793 | putc (';', asm_out_file); |
d4b87fe5 | 1794 | CHARS (1); |
946754ae | 1795 | |
9cdc08c6 | 1796 | if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE |
946754ae | 1797 | /* Avoid the ~ if we don't really need it--it confuses dbx. */ |
1798 | && TYPE_VFIELD (type)) | |
1799 | { | |
1800 | have_used_extensions = 1; | |
1801 | ||
1802 | /* Tell GDB+ that it may keep reading. */ | |
e3b8b697 | 1803 | putc ('~', asm_out_file); |
d4b87fe5 | 1804 | CHARS (1); |
946754ae | 1805 | |
1806 | /* We need to write out info about what field this class | |
1807 | uses as its "main" vtable pointer field, because if this | |
1808 | field is inherited from a base class, GDB cannot necessarily | |
1809 | figure out which field it's using in time. */ | |
1810 | if (TYPE_VFIELD (type)) | |
1811 | { | |
e3b8b697 | 1812 | putc ('%', asm_out_file); |
d4b87fe5 | 1813 | CHARS (1); |
9aa97f08 | 1814 | dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0); |
946754ae | 1815 | } |
d4b87fe5 | 1816 | |
e3b8b697 | 1817 | putc (';', asm_out_file); |
d4b87fe5 | 1818 | CHARS (1); |
946754ae | 1819 | } |
1820 | break; | |
1821 | ||
1822 | case ENUMERAL_TYPE: | |
5c579180 | 1823 | /* We must use the same test here as we use in the DBX_NO_XREFS case |
1824 | above. We simplify it a bit since an enum will never have a variable | |
1825 | size. */ | |
1826 | if ((TYPE_NAME (type) != 0 | |
1827 | && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
1828 | && DECL_IGNORED_P (TYPE_NAME (type))) | |
1829 | && !full) | |
4b72716d | 1830 | || !COMPLETE_TYPE_P (type)) |
946754ae | 1831 | { |
e3b8b697 | 1832 | fprintf (asm_out_file, "xe"); |
d4b87fe5 | 1833 | CHARS (2); |
946754ae | 1834 | dbxout_type_name (type); |
54ae7e56 | 1835 | typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF; |
e3b8b697 | 1836 | putc (':', asm_out_file); |
d4b87fe5 | 1837 | CHARS (1); |
946754ae | 1838 | return; |
1839 | } | |
1b99826f | 1840 | if (use_gnu_debug_info_extensions |
1841 | && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node)) | |
d4b87fe5 | 1842 | { |
e3b8b697 | 1843 | fprintf (asm_out_file, "@s%d;", TYPE_PRECISION (type)); |
d4b87fe5 | 1844 | CHARS (5); |
1845 | } | |
1846 | ||
e3b8b697 | 1847 | putc ('e', asm_out_file); |
946754ae | 1848 | CHARS (1); |
1849 | for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem)) | |
1850 | { | |
e3b8b697 | 1851 | fprintf (asm_out_file, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem))); |
d4b87fe5 | 1852 | CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1); |
01f7da0d | 1853 | if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0) |
d4b87fe5 | 1854 | print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem))); |
fd8acfe0 | 1855 | else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1 |
a0c2c45b | 1856 | && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0) |
d4b87fe5 | 1857 | print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem))); |
01f7da0d | 1858 | else |
1859 | print_int_cst_octal (TREE_VALUE (tem)); | |
d4b87fe5 | 1860 | |
e3b8b697 | 1861 | putc (',', asm_out_file); |
d4b87fe5 | 1862 | CHARS (1); |
946754ae | 1863 | if (TREE_CHAIN (tem) != 0) |
d4b87fe5 | 1864 | CONTIN; |
946754ae | 1865 | } |
d4b87fe5 | 1866 | |
e3b8b697 | 1867 | putc (';', asm_out_file); |
946754ae | 1868 | CHARS (1); |
1869 | break; | |
1870 | ||
1871 | case POINTER_TYPE: | |
e3b8b697 | 1872 | putc ('*', asm_out_file); |
946754ae | 1873 | CHARS (1); |
9aa97f08 | 1874 | dbxout_type (TREE_TYPE (type), 0); |
946754ae | 1875 | break; |
1876 | ||
1877 | case METHOD_TYPE: | |
9cdc08c6 | 1878 | if (use_gnu_debug_info_extensions) |
946754ae | 1879 | { |
1880 | have_used_extensions = 1; | |
e3b8b697 | 1881 | putc ('#', asm_out_file); |
946754ae | 1882 | CHARS (1); |
9aa97f08 | 1883 | |
1884 | /* Write the argument types out longhand. */ | |
1885 | dbxout_type (TYPE_METHOD_BASETYPE (type), 0); | |
e3b8b697 | 1886 | putc (',', asm_out_file); |
9aa97f08 | 1887 | CHARS (1); |
1888 | dbxout_type (TREE_TYPE (type), 0); | |
1889 | dbxout_args (TYPE_ARG_TYPES (type)); | |
e3b8b697 | 1890 | putc (';', asm_out_file); |
9aa97f08 | 1891 | CHARS (1); |
946754ae | 1892 | } |
1893 | else | |
d4b87fe5 | 1894 | /* Treat it as a function type. */ |
1895 | dbxout_type (TREE_TYPE (type), 0); | |
946754ae | 1896 | break; |
1897 | ||
1898 | case OFFSET_TYPE: | |
9cdc08c6 | 1899 | if (use_gnu_debug_info_extensions) |
946754ae | 1900 | { |
1901 | have_used_extensions = 1; | |
e3b8b697 | 1902 | putc ('@', asm_out_file); |
946754ae | 1903 | CHARS (1); |
9aa97f08 | 1904 | dbxout_type (TYPE_OFFSET_BASETYPE (type), 0); |
e3b8b697 | 1905 | putc (',', asm_out_file); |
946754ae | 1906 | CHARS (1); |
9aa97f08 | 1907 | dbxout_type (TREE_TYPE (type), 0); |
946754ae | 1908 | } |
1909 | else | |
d4b87fe5 | 1910 | /* Should print as an int, because it is really just an offset. */ |
1911 | dbxout_type (integer_type_node, 0); | |
946754ae | 1912 | break; |
1913 | ||
1914 | case REFERENCE_TYPE: | |
9cdc08c6 | 1915 | if (use_gnu_debug_info_extensions) |
946754ae | 1916 | have_used_extensions = 1; |
e3b8b697 | 1917 | putc (use_gnu_debug_info_extensions ? '&' : '*', asm_out_file); |
946754ae | 1918 | CHARS (1); |
9aa97f08 | 1919 | dbxout_type (TREE_TYPE (type), 0); |
946754ae | 1920 | break; |
1921 | ||
1922 | case FUNCTION_TYPE: | |
e3b8b697 | 1923 | putc ('f', asm_out_file); |
946754ae | 1924 | CHARS (1); |
9aa97f08 | 1925 | dbxout_type (TREE_TYPE (type), 0); |
946754ae | 1926 | break; |
1927 | ||
1928 | default: | |
7bd4f6b6 | 1929 | gcc_unreachable (); |
946754ae | 1930 | } |
1931 | } | |
1932 | ||
7ef5b942 | 1933 | /* Return nonzero if the given type represents an integer whose bounds |
0989224f | 1934 | should be printed in octal format. */ |
1935 | ||
1936 | static bool | |
8ec3a57b | 1937 | print_int_cst_bounds_in_octal_p (tree type) |
0989224f | 1938 | { |
1939 | /* If we can use GDB extensions and the size is wider than a long | |
1940 | (the size used by GDB to read them) or we may have trouble writing | |
1941 | the bounds the usual way, write them in octal. Note the test is for | |
1942 | the *target's* size of "long", not that of the host. The host test | |
1943 | is just to make sure we can write it out in case the host wide int | |
1944 | is narrower than the target "long". | |
8ec3a57b | 1945 | |
0989224f | 1946 | For unsigned types, we use octal if they are the same size or larger. |
1947 | This is because we print the bounds as signed decimal, and hence they | |
1948 | can't span same size unsigned types. */ | |
1949 | ||
1950 | if (use_gnu_debug_info_extensions | |
1951 | && TYPE_MIN_VALUE (type) != 0 | |
1952 | && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST | |
1953 | && TYPE_MAX_VALUE (type) != 0 | |
1954 | && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST | |
1955 | && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node) | |
1956 | || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)) | |
78a8ed03 | 1957 | && TYPE_UNSIGNED (type)) |
0989224f | 1958 | || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT |
1959 | || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT | |
78a8ed03 | 1960 | && TYPE_UNSIGNED (type)))) |
0989224f | 1961 | return TRUE; |
1962 | else | |
1963 | return FALSE; | |
1964 | } | |
1965 | ||
946754ae | 1966 | /* Print the value of integer constant C, in octal, |
1967 | handling double precision. */ | |
1968 | ||
1969 | static void | |
8ec3a57b | 1970 | print_int_cst_octal (tree c) |
946754ae | 1971 | { |
4303221c | 1972 | unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c); |
1973 | unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c); | |
1974 | int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3)); | |
5d844ba2 | 1975 | unsigned int width = TYPE_PRECISION (TREE_TYPE (c)); |
bdbb0781 | 1976 | |
1977 | /* GDB wants constants with no extra leading "1" bits, so | |
1978 | we need to remove any sign-extension that might be | |
1979 | present. */ | |
1980 | if (width == HOST_BITS_PER_WIDE_INT * 2) | |
1981 | ; | |
1982 | else if (width > HOST_BITS_PER_WIDE_INT) | |
1983 | high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1); | |
bc766fdc | 1984 | else if (width == HOST_BITS_PER_WIDE_INT) |
1985 | high = 0; | |
1986 | else | |
1987 | high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1); | |
946754ae | 1988 | |
e3b8b697 | 1989 | fprintf (asm_out_file, "0"); |
d4b87fe5 | 1990 | CHARS (1); |
946754ae | 1991 | |
1992 | if (excess == 3) | |
1993 | { | |
4303221c | 1994 | print_octal (high, HOST_BITS_PER_WIDE_INT / 3); |
1995 | print_octal (low, HOST_BITS_PER_WIDE_INT / 3); | |
946754ae | 1996 | } |
1997 | else | |
1998 | { | |
4303221c | 1999 | unsigned HOST_WIDE_INT beg = high >> excess; |
2000 | unsigned HOST_WIDE_INT middle | |
2001 | = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess) | |
2002 | | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3))); | |
2003 | unsigned HOST_WIDE_INT end | |
bdbb0781 | 2004 | = low & (((unsigned HOST_WIDE_INT) 1 |
2005 | << (HOST_BITS_PER_WIDE_INT / 3 * 3)) | |
2006 | - 1); | |
2007 | ||
e3b8b697 | 2008 | fprintf (asm_out_file, "%o%01o", (int) beg, (int) middle); |
d4b87fe5 | 2009 | CHARS (2); |
4303221c | 2010 | print_octal (end, HOST_BITS_PER_WIDE_INT / 3); |
946754ae | 2011 | } |
2012 | } | |
2013 | ||
2014 | static void | |
8ec3a57b | 2015 | print_octal (unsigned HOST_WIDE_INT value, int digits) |
946754ae | 2016 | { |
2017 | int i; | |
2018 | ||
2019 | for (i = digits - 1; i >= 0; i--) | |
e3b8b697 | 2020 | fprintf (asm_out_file, "%01o", (int) ((value >> (3 * i)) & 7)); |
d4b87fe5 | 2021 | |
2022 | CHARS (digits); | |
946754ae | 2023 | } |
2024 | ||
d4b87fe5 | 2025 | /* Output C in decimal while adjusting the number of digits written. */ |
2026 | ||
2027 | static void | |
8ec3a57b | 2028 | print_wide_int (HOST_WIDE_INT c) |
d4b87fe5 | 2029 | { |
2030 | int digs = 0; | |
2031 | ||
e3b8b697 | 2032 | fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC, c); |
d4b87fe5 | 2033 | |
2034 | if (c < 0) | |
2035 | digs++, c = -c; | |
2036 | ||
2037 | while (c > 0) | |
2038 | c /= 10; digs++; | |
2039 | ||
2040 | CHARS (digs); | |
2041 | } | |
1eefe280 | 2042 | |
946754ae | 2043 | /* Output the name of type TYPE, with no punctuation. |
2044 | Such names can be set up either by typedef declarations | |
2045 | or by struct, enum and union tags. */ | |
2046 | ||
2047 | static void | |
8ec3a57b | 2048 | dbxout_type_name (tree type) |
946754ae | 2049 | { |
7bd4f6b6 | 2050 | tree t = TYPE_NAME (type); |
2051 | ||
2052 | gcc_assert (t); | |
2053 | switch (TREE_CODE (t)) | |
946754ae | 2054 | { |
7bd4f6b6 | 2055 | case IDENTIFIER_NODE: |
2056 | break; | |
2057 | case TYPE_DECL: | |
2058 | t = DECL_NAME (t); | |
2059 | break; | |
2060 | default: | |
2061 | gcc_unreachable (); | |
946754ae | 2062 | } |
946754ae | 2063 | |
e3b8b697 | 2064 | fprintf (asm_out_file, "%s", IDENTIFIER_POINTER (t)); |
946754ae | 2065 | CHARS (IDENTIFIER_LENGTH (t)); |
2066 | } | |
d251e975 | 2067 | |
2068 | /* Output leading leading struct or class names needed for qualifying | |
2069 | type whose scope is limited to a struct or class. */ | |
2070 | ||
2071 | static void | |
8ec3a57b | 2072 | dbxout_class_name_qualifiers (tree decl) |
d251e975 | 2073 | { |
2074 | tree context = decl_type_context (decl); | |
2075 | ||
8ec3a57b | 2076 | if (context != NULL_TREE |
d251e975 | 2077 | && TREE_CODE(context) == RECORD_TYPE |
8ec3a57b | 2078 | && TYPE_NAME (context) != 0 |
d251e975 | 2079 | && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE |
2080 | || (DECL_NAME (TYPE_NAME (context)) != 0))) | |
2081 | { | |
2082 | tree name = TYPE_NAME (context); | |
2083 | ||
51cec339 | 2084 | emit_pending_bincls_if_required (); |
2085 | ||
d251e975 | 2086 | if (TREE_CODE (name) == TYPE_DECL) |
2087 | { | |
2088 | dbxout_class_name_qualifiers (name); | |
2089 | name = DECL_NAME (name); | |
2090 | } | |
e3b8b697 | 2091 | fprintf (asm_out_file, "%s::", IDENTIFIER_POINTER (name)); |
d251e975 | 2092 | CHARS (IDENTIFIER_LENGTH (name) + 2); |
2093 | } | |
2094 | } | |
946754ae | 2095 | \f |
2096 | /* Output a .stabs for the symbol defined by DECL, | |
2097 | which must be a ..._DECL node in the normal namespace. | |
2098 | It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL. | |
d0309f39 | 2099 | LOCAL is nonzero if the scope is less than the entire file. |
2100 | Return 1 if a stabs might have been emitted. */ | |
946754ae | 2101 | |
d0309f39 | 2102 | int |
8ec3a57b | 2103 | dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED) |
946754ae | 2104 | { |
946754ae | 2105 | tree type = TREE_TYPE (decl); |
2106 | tree context = NULL_TREE; | |
d0309f39 | 2107 | int result = 0; |
946754ae | 2108 | |
262444a6 | 2109 | /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */ |
2110 | ++debug_nesting; | |
2111 | ||
946754ae | 2112 | /* Ignore nameless syms, but don't ignore type tags. */ |
2113 | ||
2114 | if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL) | |
2115 | || DECL_IGNORED_P (decl)) | |
262444a6 | 2116 | DBXOUT_DECR_NESTING_AND_RETURN (0); |
2117 | ||
d01481af | 2118 | /* If we are to generate only the symbols actually used then such |
262444a6 | 2119 | symbol nodees are flagged with TREE_USED. Ignore any that |
2120 | aren't flaged as TREE_USED. */ | |
8ec3a57b | 2121 | |
73ae3ef7 | 2122 | if (flag_debug_only_used_symbols |
2123 | && (!TREE_USED (decl) | |
2124 | && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))) | |
2125 | DBXOUT_DECR_NESTING_AND_RETURN (0); | |
2126 | ||
2127 | /* If dbxout_init has not yet run, queue this symbol for later. */ | |
2128 | if (!typevec) | |
2129 | { | |
2130 | preinit_symbols = tree_cons (0, decl, preinit_symbols); | |
2131 | DBXOUT_DECR_NESTING_AND_RETURN (0); | |
2132 | } | |
2133 | ||
262444a6 | 2134 | if (flag_debug_only_used_symbols) |
2135 | { | |
2136 | tree t; | |
2137 | ||
262444a6 | 2138 | /* We now have a used symbol. We need to generate the info for |
2139 | the symbol's type in addition to the symbol itself. These | |
2140 | type symbols are queued to be generated after were done with | |
2141 | the symbol itself (done because the symbol's info is generated | |
2142 | with fprintf's, etc. as it determines what's needed). | |
2143 | ||
2144 | Note, because the TREE_TYPE(type) might be something like a | |
2145 | pointer to a named type we need to look for the first name | |
2146 | we see following the TREE_TYPE chain. */ | |
2147 | ||
8ec3a57b | 2148 | t = type; |
262444a6 | 2149 | while (POINTER_TYPE_P (t)) |
2150 | t = TREE_TYPE (t); | |
2151 | ||
2152 | /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE | |
2153 | need special treatment. The TYPE_STUB_DECL field in these | |
2154 | types generally represents the tag name type we want to | |
2155 | output. In addition there could be a typedef type with | |
2156 | a different name. In that case we also want to output | |
2157 | that. */ | |
2158 | ||
4f51d5ad | 2159 | if (TREE_CODE (t) == RECORD_TYPE |
262444a6 | 2160 | || TREE_CODE (t) == UNION_TYPE |
2161 | || TREE_CODE (t) == QUAL_UNION_TYPE | |
2162 | || TREE_CODE (t) == ENUMERAL_TYPE) | |
262444a6 | 2163 | { |
4f51d5ad | 2164 | if (TYPE_STUB_DECL (t) |
2165 | && TYPE_STUB_DECL (t) != decl | |
2166 | && DECL_P (TYPE_STUB_DECL (t)) | |
2167 | && ! DECL_IGNORED_P (TYPE_STUB_DECL (t))) | |
2168 | { | |
2169 | debug_queue_symbol (TYPE_STUB_DECL (t)); | |
2170 | if (TYPE_NAME (t) | |
2171 | && TYPE_NAME (t) != TYPE_STUB_DECL (t) | |
2172 | && TYPE_NAME (t) != decl | |
2173 | && DECL_P (TYPE_NAME (t))) | |
2174 | debug_queue_symbol (TYPE_NAME (t)); | |
2175 | } | |
2176 | } | |
262444a6 | 2177 | else if (TYPE_NAME (t) |
2178 | && TYPE_NAME (t) != decl | |
ce45a448 | 2179 | && DECL_P (TYPE_NAME (t))) |
262444a6 | 2180 | debug_queue_symbol (TYPE_NAME (t)); |
2181 | } | |
946754ae | 2182 | |
51cec339 | 2183 | emit_pending_bincls_if_required (); |
2184 | ||
946754ae | 2185 | dbxout_prepare_symbol (decl); |
2186 | ||
2187 | /* The output will always start with the symbol name, | |
2188 | so always count that in the length-output-so-far. */ | |
2189 | ||
2190 | if (DECL_NAME (decl) != 0) | |
2191 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl)); | |
2192 | ||
2193 | switch (TREE_CODE (decl)) | |
2194 | { | |
2195 | case CONST_DECL: | |
2196 | /* Enum values are defined by defining the enum type. */ | |
2197 | break; | |
2198 | ||
2199 | case FUNCTION_DECL: | |
2200 | if (DECL_RTL (decl) == 0) | |
262444a6 | 2201 | DBXOUT_DECR_NESTING_AND_RETURN (0); |
8fc7a3d0 | 2202 | if (DECL_EXTERNAL (decl)) |
946754ae | 2203 | break; |
2204 | /* Don't mention a nested function under its parent. */ | |
2205 | context = decl_function_context (decl); | |
2206 | if (context == current_function_decl) | |
2207 | break; | |
e16ceb8e | 2208 | if (!MEM_P (DECL_RTL (decl)) |
946754ae | 2209 | || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) |
2210 | break; | |
2211 | FORCE_TEXT; | |
2212 | ||
e3b8b697 | 2213 | fprintf (asm_out_file, "%s\"%s:%c", ASM_STABS_OP, |
946754ae | 2214 | IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), |
2215 | TREE_PUBLIC (decl) ? 'F' : 'f'); | |
d0309f39 | 2216 | result = 1; |
946754ae | 2217 | |
2218 | current_sym_code = N_FUN; | |
2219 | current_sym_addr = XEXP (DECL_RTL (decl), 0); | |
2220 | ||
2221 | if (TREE_TYPE (type)) | |
9aa97f08 | 2222 | dbxout_type (TREE_TYPE (type), 0); |
946754ae | 2223 | else |
9aa97f08 | 2224 | dbxout_type (void_type_node, 0); |
946754ae | 2225 | |
2226 | /* For a nested function, when that function is compiled, | |
2227 | mention the containing function name | |
2228 | as well as (since dbx wants it) our own assembler-name. */ | |
2229 | if (context != 0) | |
e3b8b697 | 2230 | fprintf (asm_out_file, ",%s,%s", |
946754ae | 2231 | IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), |
2232 | IDENTIFIER_POINTER (DECL_NAME (context))); | |
2233 | ||
2234 | dbxout_finish_symbol (decl); | |
2235 | break; | |
2236 | ||
2237 | case TYPE_DECL: | |
946754ae | 2238 | /* Don't output the same typedef twice. |
2239 | And don't output what language-specific stuff doesn't want output. */ | |
53aaa4b2 | 2240 | if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl)) |
262444a6 | 2241 | DBXOUT_DECR_NESTING_AND_RETURN (0); |
946754ae | 2242 | |
73ae3ef7 | 2243 | /* Don't output typedefs for types with magic type numbers (XCOFF). */ |
2244 | #ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER | |
2245 | { | |
2246 | int fundamental_type_number = | |
2247 | DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl); | |
2248 | ||
2249 | if (fundamental_type_number != 0) | |
2250 | { | |
2251 | TREE_ASM_WRITTEN (decl) = 1; | |
2252 | TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl)) = fundamental_type_number; | |
2253 | DBXOUT_DECR_NESTING_AND_RETURN (0); | |
2254 | } | |
2255 | } | |
2256 | #endif | |
946754ae | 2257 | FORCE_TEXT; |
d0309f39 | 2258 | result = 1; |
1ecd86ea | 2259 | { |
2260 | int tag_needed = 1; | |
d78a5beb | 2261 | int did_output = 0; |
ef01e856 | 2262 | |
1ecd86ea | 2263 | if (DECL_NAME (decl)) |
2264 | { | |
2265 | /* Nonzero means we must output a tag as well as a typedef. */ | |
2266 | tag_needed = 0; | |
946754ae | 2267 | |
068adc53 | 2268 | /* Handle the case of a C++ structure or union |
2269 | where the TYPE_NAME is a TYPE_DECL | |
2270 | which gives both a typedef name and a tag. */ | |
2be77840 | 2271 | /* dbx requires the tag first and the typedef second. */ |
068adc53 | 2272 | if ((TREE_CODE (type) == RECORD_TYPE |
7f8a347a | 2273 | || TREE_CODE (type) == UNION_TYPE |
2274 | || TREE_CODE (type) == QUAL_UNION_TYPE) | |
068adc53 | 2275 | && TYPE_NAME (type) == decl |
9cdc08c6 | 2276 | && !(use_gnu_debug_info_extensions && have_used_extensions) |
2be77840 | 2277 | && !TREE_ASM_WRITTEN (TYPE_NAME (type)) |
2278 | /* Distinguish the implicit typedefs of C++ | |
2279 | from explicit ones that might be found in C. */ | |
1eefe280 | 2280 | && DECL_ARTIFICIAL (decl) |
262444a6 | 2281 | /* Do not generate a tag for incomplete records. */ |
2282 | && COMPLETE_TYPE_P (type) | |
79433a4c | 2283 | /* Do not generate a tag for records of variable size, |
2284 | since this type can not be properly described in the | |
2285 | DBX format, and it confuses some tools such as objdump. */ | |
dc891f3f | 2286 | && host_integerp (TYPE_SIZE (type), 1)) |
068adc53 | 2287 | { |
2288 | tree name = TYPE_NAME (type); | |
2289 | if (TREE_CODE (name) == TYPE_DECL) | |
2290 | name = DECL_NAME (name); | |
2291 | ||
2292 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; | |
2293 | current_sym_value = 0; | |
2294 | current_sym_addr = 0; | |
2295 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (name); | |
2296 | ||
e3b8b697 | 2297 | fprintf (asm_out_file, "%s\"%s:T", ASM_STABS_OP, |
068adc53 | 2298 | IDENTIFIER_POINTER (name)); |
9aa97f08 | 2299 | dbxout_type (type, 1); |
4303221c | 2300 | dbxout_finish_symbol (NULL_TREE); |
068adc53 | 2301 | } |
2302 | ||
d251e975 | 2303 | /* Output .stabs (or whatever) and leading double quote. */ |
e3b8b697 | 2304 | fprintf (asm_out_file, "%s\"", ASM_STABS_OP); |
d251e975 | 2305 | |
2306 | if (use_gnu_debug_info_extensions) | |
2307 | { | |
2308 | /* Output leading class/struct qualifiers. */ | |
2309 | dbxout_class_name_qualifiers (decl); | |
2310 | } | |
2311 | ||
1ecd86ea | 2312 | /* Output typedef name. */ |
e3b8b697 | 2313 | fprintf (asm_out_file, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl))); |
ef01e856 | 2314 | |
1ecd86ea | 2315 | /* Short cut way to output a tag also. */ |
2316 | if ((TREE_CODE (type) == RECORD_TYPE | |
7f8a347a | 2317 | || TREE_CODE (type) == UNION_TYPE |
2318 | || TREE_CODE (type) == QUAL_UNION_TYPE) | |
3e5c6b4e | 2319 | && TYPE_NAME (type) == decl |
2320 | /* Distinguish the implicit typedefs of C++ | |
2321 | from explicit ones that might be found in C. */ | |
1eefe280 | 2322 | && DECL_ARTIFICIAL (decl)) |
1ecd86ea | 2323 | { |
9cdc08c6 | 2324 | if (use_gnu_debug_info_extensions && have_used_extensions) |
1ecd86ea | 2325 | { |
e3b8b697 | 2326 | putc ('T', asm_out_file); |
1ecd86ea | 2327 | TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1; |
2328 | } | |
1ecd86ea | 2329 | } |
946754ae | 2330 | |
e3b8b697 | 2331 | putc ('t', asm_out_file); |
98123cec | 2332 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; |
ef01e856 | 2333 | |
9aa97f08 | 2334 | dbxout_type (type, 1); |
1ecd86ea | 2335 | dbxout_finish_symbol (decl); |
d78a5beb | 2336 | did_output = 1; |
1ecd86ea | 2337 | } |
946754ae | 2338 | |
79433a4c | 2339 | /* Don't output a tag if this is an incomplete type. This prevents |
2340 | the sun4 Sun OS 4.x dbx from crashing. */ | |
dc891f3f | 2341 | |
06ce1380 | 2342 | if (tag_needed && TYPE_NAME (type) != 0 |
2343 | && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE | |
2344 | || (DECL_NAME (TYPE_NAME (type)) != 0)) | |
4b72716d | 2345 | && COMPLETE_TYPE_P (type) |
1ecd86ea | 2346 | && !TREE_ASM_WRITTEN (TYPE_NAME (type))) |
2347 | { | |
2348 | /* For a TYPE_DECL with no name, but the type has a name, | |
2349 | output a tag. | |
2350 | This is what represents `struct foo' with no typedef. */ | |
2351 | /* In C++, the name of a type is the corresponding typedef. | |
2352 | In C, it is an IDENTIFIER_NODE. */ | |
2353 | tree name = TYPE_NAME (type); | |
2354 | if (TREE_CODE (name) == TYPE_DECL) | |
2355 | name = DECL_NAME (name); | |
2356 | ||
98123cec | 2357 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; |
1ecd86ea | 2358 | current_sym_value = 0; |
2359 | current_sym_addr = 0; | |
2360 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (name); | |
2361 | ||
e3b8b697 | 2362 | fprintf (asm_out_file, "%s\"%s:T", ASM_STABS_OP, |
1ecd86ea | 2363 | IDENTIFIER_POINTER (name)); |
9aa97f08 | 2364 | dbxout_type (type, 1); |
4303221c | 2365 | dbxout_finish_symbol (NULL_TREE); |
d78a5beb | 2366 | did_output = 1; |
2367 | } | |
2368 | ||
2369 | /* If an enum type has no name, it cannot be referred to, | |
2370 | but we must output it anyway, since the enumeration constants | |
2371 | can be referred to. */ | |
2372 | if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE) | |
2373 | { | |
2374 | current_sym_code = DBX_TYPE_DECL_STABS_CODE; | |
2375 | current_sym_value = 0; | |
2376 | current_sym_addr = 0; | |
2377 | current_sym_nchars = 2; | |
2378 | ||
04c6b571 | 2379 | /* Some debuggers fail when given NULL names, so give this a |
2380 | harmless name of ` '. */ | |
e3b8b697 | 2381 | fprintf (asm_out_file, "%s\" :T", ASM_STABS_OP); |
9aa97f08 | 2382 | dbxout_type (type, 1); |
d78a5beb | 2383 | dbxout_finish_symbol (NULL_TREE); |
1ecd86ea | 2384 | } |
2385 | ||
2386 | /* Prevent duplicate output of a typedef. */ | |
2387 | TREE_ASM_WRITTEN (decl) = 1; | |
2388 | break; | |
2389 | } | |
946754ae | 2390 | |
2391 | case PARM_DECL: | |
2392 | /* Parm decls go in their own separate chains | |
2393 | and are output by dbxout_reg_parms and dbxout_parms. */ | |
7bd4f6b6 | 2394 | gcc_unreachable (); |
946754ae | 2395 | |
2396 | case RESULT_DECL: | |
2397 | /* Named return value, treat like a VAR_DECL. */ | |
2398 | case VAR_DECL: | |
634b7df0 | 2399 | if (! DECL_RTL_SET_P (decl)) |
262444a6 | 2400 | DBXOUT_DECR_NESTING_AND_RETURN (0); |
946754ae | 2401 | /* Don't mention a variable that is external. |
2402 | Let the file that defines it describe it. */ | |
8fc7a3d0 | 2403 | if (DECL_EXTERNAL (decl)) |
946754ae | 2404 | break; |
2405 | ||
2406 | /* If the variable is really a constant | |
2407 | and not written in memory, inform the debugger. */ | |
2408 | if (TREE_STATIC (decl) && TREE_READONLY (decl) | |
2409 | && DECL_INITIAL (decl) != 0 | |
5d844ba2 | 2410 | && host_integerp (DECL_INITIAL (decl), 0) |
946754ae | 2411 | && ! TREE_ASM_WRITTEN (decl) |
7e5e198b | 2412 | && (DECL_CONTEXT (decl) == NULL_TREE |
2413 | || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK)) | |
946754ae | 2414 | { |
2415 | if (TREE_PUBLIC (decl) == 0) | |
2416 | { | |
2417 | /* The sun4 assembler does not grok this. */ | |
12fc9462 | 2418 | const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); |
5d844ba2 | 2419 | |
946754ae | 2420 | if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE |
2421 | || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) | |
2422 | { | |
5d844ba2 | 2423 | HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0); |
e3b8b697 | 2424 | fprintf (asm_out_file, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC |
85aa12f7 | 2425 | "\",0x%x,0,0,0\n", |
2426 | ASM_STABS_OP, name, ival, N_LSYM); | |
262444a6 | 2427 | DBXOUT_DECR_NESTING; |
d0309f39 | 2428 | return 1; |
946754ae | 2429 | } |
2430 | else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE) | |
2431 | { | |
21dda4ee | 2432 | /* Don't know how to do this yet. */ |
946754ae | 2433 | } |
2434 | break; | |
2435 | } | |
2436 | /* else it is something we handle like a normal variable. */ | |
2437 | } | |
2438 | ||
0e8e37b2 | 2439 | SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX)); |
946754ae | 2440 | #ifdef LEAF_REG_REMAP |
b3b67b7c | 2441 | if (current_function_uses_only_leaf_regs) |
946754ae | 2442 | leaf_renumber_regs_insn (DECL_RTL (decl)); |
2443 | #endif | |
2444 | ||
d0309f39 | 2445 | result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl)); |
0dbd1c74 | 2446 | break; |
1eefe280 | 2447 | |
0dbd1c74 | 2448 | default: |
2449 | break; | |
3c5d2a1c | 2450 | } |
262444a6 | 2451 | DBXOUT_DECR_NESTING; |
d0309f39 | 2452 | return result; |
3c5d2a1c | 2453 | } |
2454 | \f | |
2455 | /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL. | |
2456 | Add SUFFIX to its name, if SUFFIX is not 0. | |
2457 | Describe the variable as residing in HOME | |
d0309f39 | 2458 | (usually HOME is DECL_RTL (DECL), but not always). |
2459 | Returns 1 if the stab was really emitted. */ | |
3c5d2a1c | 2460 | |
d0309f39 | 2461 | static int |
8ec3a57b | 2462 | dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home) |
3c5d2a1c | 2463 | { |
2464 | int letter = 0; | |
2465 | int regno = -1; | |
946754ae | 2466 | |
51cec339 | 2467 | emit_pending_bincls_if_required (); |
2468 | ||
3c5d2a1c | 2469 | /* Don't mention a variable at all |
2470 | if it was completely optimized into nothingness. | |
1eefe280 | 2471 | |
9e042f31 | 2472 | If the decl was from an inline function, then its rtl |
3c5d2a1c | 2473 | is not identically the rtl that was used in this |
2474 | particular compilation. */ | |
aa6a7ab3 | 2475 | if (GET_CODE (home) == SUBREG) |
3c5d2a1c | 2476 | { |
2477 | rtx value = home; | |
701e46d0 | 2478 | |
3c5d2a1c | 2479 | while (GET_CODE (value) == SUBREG) |
701e46d0 | 2480 | value = SUBREG_REG (value); |
8ad4c111 | 2481 | if (REG_P (value)) |
946754ae | 2482 | { |
701e46d0 | 2483 | if (REGNO (value) >= FIRST_PSEUDO_REGISTER) |
d0309f39 | 2484 | return 0; |
946754ae | 2485 | } |
06b3c9f7 | 2486 | home = alter_subreg (&home); |
aa6a7ab3 | 2487 | } |
8ad4c111 | 2488 | if (REG_P (home)) |
aa6a7ab3 | 2489 | { |
2490 | regno = REGNO (home); | |
2491 | if (regno >= FIRST_PSEUDO_REGISTER) | |
2492 | return 0; | |
3c5d2a1c | 2493 | } |
2494 | ||
2495 | /* The kind-of-variable letter depends on where | |
2496 | the variable is and on the scope of its name: | |
2497 | G and N_GSYM for static storage and global scope, | |
2498 | S for static storage and file scope, | |
2499 | V for static storage and local scope, | |
2500 | for those two, use N_LCSYM if data is in bss segment, | |
2501 | N_STSYM if in data segment, N_FUN otherwise. | |
2502 | (We used N_FUN originally, then changed to N_STSYM | |
2503 | to please GDB. However, it seems that confused ld. | |
2504 | Now GDB has been fixed to like N_FUN, says Kingdon.) | |
2505 | no letter at all, and N_LSYM, for auto variable, | |
2506 | r and N_RSYM for register variable. */ | |
2507 | ||
e16ceb8e | 2508 | if (MEM_P (home) |
3c5d2a1c | 2509 | && GET_CODE (XEXP (home, 0)) == SYMBOL_REF) |
2510 | { | |
2511 | if (TREE_PUBLIC (decl)) | |
946754ae | 2512 | { |
3c5d2a1c | 2513 | letter = 'G'; |
2514 | current_sym_code = N_GSYM; | |
946754ae | 2515 | } |
3c5d2a1c | 2516 | else |
946754ae | 2517 | { |
3c5d2a1c | 2518 | current_sym_addr = XEXP (home, 0); |
946754ae | 2519 | |
3c5d2a1c | 2520 | letter = decl_function_context (decl) ? 'V' : 'S'; |
946754ae | 2521 | |
2def70a8 | 2522 | /* This should be the same condition as in assemble_variable, but |
2523 | we don't have access to dont_output_data here. So, instead, | |
2524 | we rely on the fact that error_mark_node initializers always | |
2525 | end up in bss for C++ and never end up in bss for C. */ | |
2526 | if (DECL_INITIAL (decl) == 0 | |
d19bd1f0 | 2527 | || (!strcmp (lang_hooks.name, "GNU C++") |
2def70a8 | 2528 | && DECL_INITIAL (decl) == error_mark_node)) |
3c5d2a1c | 2529 | current_sym_code = N_LCSYM; |
bcfbda84 | 2530 | else if (DECL_IN_TEXT_SECTION (decl)) |
3c5d2a1c | 2531 | /* This is not quite right, but it's the closest |
2532 | of all the codes that Unix defines. */ | |
2533 | current_sym_code = DBX_STATIC_CONST_VAR_CODE; | |
2534 | else | |
2535 | { | |
58f036fc | 2536 | /* Some ports can transform a symbol ref into a label ref, |
2537 | because the symbol ref is too far away and has to be | |
2538 | dumped into a constant pool. Alternatively, the symbol | |
2539 | in the constant pool might be referenced by a different | |
2540 | symbol. */ | |
2541 | if (GET_CODE (current_sym_addr) == SYMBOL_REF | |
2542 | && CONSTANT_POOL_ADDRESS_P (current_sym_addr)) | |
2543 | { | |
88816742 | 2544 | bool marked; |
2545 | rtx tmp = get_pool_constant_mark (current_sym_addr, &marked); | |
2546 | ||
2547 | if (GET_CODE (tmp) == SYMBOL_REF) | |
2548 | { | |
2549 | current_sym_addr = tmp; | |
2550 | if (CONSTANT_POOL_ADDRESS_P (current_sym_addr)) | |
2551 | get_pool_constant_mark (current_sym_addr, &marked); | |
2552 | else | |
2553 | marked = true; | |
2554 | } | |
2555 | else if (GET_CODE (tmp) == LABEL_REF) | |
2556 | { | |
2557 | current_sym_addr = tmp; | |
2558 | marked = true; | |
2559 | } | |
2560 | ||
2561 | /* If all references to the constant pool were optimized | |
2562 | out, we just ignore the symbol. */ | |
2563 | if (!marked) | |
2564 | return 0; | |
58f036fc | 2565 | } |
1eefe280 | 2566 | |
3c5d2a1c | 2567 | /* Ultrix `as' seems to need this. */ |
946754ae | 2568 | #ifdef DBX_STATIC_STAB_DATA_SECTION |
3c5d2a1c | 2569 | data_section (); |
946754ae | 2570 | #endif |
3c5d2a1c | 2571 | current_sym_code = N_STSYM; |
946754ae | 2572 | } |
2573 | } | |
3c5d2a1c | 2574 | } |
2575 | else if (regno >= 0) | |
2576 | { | |
2577 | letter = 'r'; | |
2578 | current_sym_code = N_RSYM; | |
2579 | current_sym_value = DBX_REGISTER_NUMBER (regno); | |
2580 | } | |
e16ceb8e | 2581 | else if (MEM_P (home) |
2582 | && (MEM_P (XEXP (home, 0)) | |
8ad4c111 | 2583 | || (REG_P (XEXP (home, 0)) |
bca4bea0 | 2584 | && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM |
2585 | && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM | |
2586 | #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM | |
2587 | && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM | |
2588 | #endif | |
2589 | ))) | |
3c5d2a1c | 2590 | /* If the value is indirect by memory or by a register |
2591 | that isn't the frame pointer | |
2592 | then it means the object is variable-sized and address through | |
2593 | that register or stack slot. DBX has no way to represent this | |
2594 | so all we can do is output the variable as a pointer. | |
4ee9c684 | 2595 | If it's not a parameter, ignore it. */ |
3c5d2a1c | 2596 | { |
8ad4c111 | 2597 | if (REG_P (XEXP (home, 0))) |
946754ae | 2598 | { |
2599 | letter = 'r'; | |
2600 | current_sym_code = N_RSYM; | |
756ab748 | 2601 | if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER) |
2602 | return 0; | |
3c5d2a1c | 2603 | current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0))); |
946754ae | 2604 | } |
3c5d2a1c | 2605 | else |
946754ae | 2606 | { |
2607 | current_sym_code = N_LSYM; | |
3c5d2a1c | 2608 | /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))). |
946754ae | 2609 | We want the value of that CONST_INT. */ |
3c5d2a1c | 2610 | current_sym_value |
2611 | = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0)); | |
439c05a0 | 2612 | } |
3c5d2a1c | 2613 | |
2614 | /* Effectively do build_pointer_type, but don't cache this type, | |
2615 | since it might be temporary whereas the type it points to | |
2616 | might have been saved for inlining. */ | |
2617 | /* Don't use REFERENCE_TYPE because dbx can't handle that. */ | |
2618 | type = make_node (POINTER_TYPE); | |
2619 | TREE_TYPE (type) = TREE_TYPE (decl); | |
2620 | } | |
e16ceb8e | 2621 | else if (MEM_P (home) |
8ad4c111 | 2622 | && REG_P (XEXP (home, 0))) |
3c5d2a1c | 2623 | { |
2624 | current_sym_code = N_LSYM; | |
2625 | current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0)); | |
2626 | } | |
e16ceb8e | 2627 | else if (MEM_P (home) |
3c5d2a1c | 2628 | && GET_CODE (XEXP (home, 0)) == PLUS |
2629 | && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT) | |
2630 | { | |
2631 | current_sym_code = N_LSYM; | |
2632 | /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...))) | |
2633 | We want the value of that CONST_INT. */ | |
2634 | current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0)); | |
2635 | } | |
e16ceb8e | 2636 | else if (MEM_P (home) |
3c5d2a1c | 2637 | && GET_CODE (XEXP (home, 0)) == CONST) |
2638 | { | |
2639 | /* Handle an obscure case which can arise when optimizing and | |
2640 | when there are few available registers. (This is *always* | |
2641 | the case for i386/i486 targets). The RTL looks like | |
2642 | (MEM (CONST ...)) even though this variable is a local `auto' | |
2643 | or a local `register' variable. In effect, what has happened | |
2644 | is that the reload pass has seen that all assignments and | |
2645 | references for one such a local variable can be replaced by | |
2646 | equivalent assignments and references to some static storage | |
2647 | variable, thereby avoiding the need for a register. In such | |
2648 | cases we're forced to lie to debuggers and tell them that | |
2649 | this variable was itself `static'. */ | |
2650 | current_sym_code = N_LCSYM; | |
2651 | letter = 'V'; | |
2652 | current_sym_addr = XEXP (XEXP (home, 0), 0); | |
2653 | } | |
2654 | else if (GET_CODE (home) == CONCAT) | |
2655 | { | |
1ae99fd2 | 2656 | tree subtype; |
2657 | ||
2658 | /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE, | |
2659 | for example), then there is no easy way to figure out | |
2660 | what SUBTYPE should be. So, we give up. */ | |
2661 | if (TREE_CODE (type) != COMPLEX_TYPE) | |
2662 | return 0; | |
2663 | ||
2664 | subtype = TREE_TYPE (type); | |
3c5d2a1c | 2665 | |
2666 | /* If the variable's storage is in two parts, | |
2667 | output each as a separate stab with a modified name. */ | |
2668 | if (WORDS_BIG_ENDIAN) | |
2669 | dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0)); | |
946754ae | 2670 | else |
3c5d2a1c | 2671 | dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0)); |
946754ae | 2672 | |
3c5d2a1c | 2673 | dbxout_prepare_symbol (decl); |
2674 | ||
2675 | if (WORDS_BIG_ENDIAN) | |
2676 | dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1)); | |
2677 | else | |
2678 | dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1)); | |
d0309f39 | 2679 | return 1; |
3c5d2a1c | 2680 | } |
2681 | else | |
2682 | /* Address might be a MEM, when DECL is a variable-sized object. | |
2683 | Or it might be const0_rtx, meaning previous passes | |
2684 | want us to ignore this variable. */ | |
d0309f39 | 2685 | return 0; |
3c5d2a1c | 2686 | |
2687 | /* Ok, start a symtab entry and output the variable name. */ | |
2688 | FORCE_TEXT; | |
439c05a0 | 2689 | |
2690 | #ifdef DBX_STATIC_BLOCK_START | |
e3b8b697 | 2691 | DBX_STATIC_BLOCK_START (asm_out_file, current_sym_code); |
439c05a0 | 2692 | #endif |
2693 | ||
3c5d2a1c | 2694 | dbxout_symbol_name (decl, suffix, letter); |
9aa97f08 | 2695 | dbxout_type (type, 0); |
3c5d2a1c | 2696 | dbxout_finish_symbol (decl); |
439c05a0 | 2697 | |
2698 | #ifdef DBX_STATIC_BLOCK_END | |
e3b8b697 | 2699 | DBX_STATIC_BLOCK_END (asm_out_file, current_sym_code); |
439c05a0 | 2700 | #endif |
d0309f39 | 2701 | return 1; |
3c5d2a1c | 2702 | } |
2703 | \f | |
2704 | /* Output the symbol name of DECL for a stabs, with suffix SUFFIX. | |
2705 | Then output LETTER to indicate the kind of location the symbol has. */ | |
2706 | ||
2707 | static void | |
8ec3a57b | 2708 | dbxout_symbol_name (tree decl, const char *suffix, int letter) |
3c5d2a1c | 2709 | { |
b82967bc | 2710 | const char *name; |
2711 | ||
cd3034ab | 2712 | if (DECL_CONTEXT (decl) |
2713 | && (TYPE_P (DECL_CONTEXT (decl)) | |
2714 | || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL)) | |
2715 | /* One slight hitch: if this is a VAR_DECL which is a class member | |
2716 | or a namespace member, we must put out the mangled name instead of the | |
b82967bc | 2717 | DECL_NAME. Note also that static member (variable) names DO NOT begin |
2718 | with underscores in .stabs directives. */ | |
2719 | name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); | |
2720 | else | |
2721 | /* ...but if we're function-local, we don't want to include the junk | |
2722 | added by ASM_FORMAT_PRIVATE_NAME. */ | |
2723 | name = IDENTIFIER_POINTER (DECL_NAME (decl)); | |
2724 | ||
3c5d2a1c | 2725 | if (name == 0) |
2726 | name = "(anon)"; | |
e3b8b697 | 2727 | fprintf (asm_out_file, "%s\"%s%s:", ASM_STABS_OP, name, |
3c5d2a1c | 2728 | (suffix ? suffix : "")); |
2729 | ||
d4b87fe5 | 2730 | if (letter) |
e3b8b697 | 2731 | putc (letter, asm_out_file); |
946754ae | 2732 | } |
2733 | ||
2734 | static void | |
8ec3a57b | 2735 | dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED) |
946754ae | 2736 | { |
d6d30f68 | 2737 | /* Initialize variables used to communicate each symbol's debug |
2738 | information to dbxout_finish_symbol with zeroes. */ | |
2739 | ||
2740 | /* Cast avoids warning in old compilers. */ | |
2741 | current_sym_code = (STAB_CODE_TYPE) 0; | |
2742 | current_sym_value = 0; | |
2743 | current_sym_addr = 0; | |
946754ae | 2744 | } |
2745 | ||
2746 | static void | |
8ec3a57b | 2747 | dbxout_finish_symbol (tree sym) |
946754ae | 2748 | { |
439c05a0 | 2749 | #ifdef DBX_FINISH_SYMBOL |
cadcb290 | 2750 | DBX_FINISH_SYMBOL (asm_out_file, sym); |
439c05a0 | 2751 | #else |
946754ae | 2752 | int line = 0; |
7e9059b9 | 2753 | if (use_gnu_debug_info_extensions && sym != 0) |
346064d9 | 2754 | line = DECL_SOURCE_LINE (sym); |
439c05a0 | 2755 | |
e3b8b697 | 2756 | fprintf (asm_out_file, "\",%d,0,%d,", current_sym_code, line); |
946754ae | 2757 | if (current_sym_addr) |
e3b8b697 | 2758 | output_addr_const (asm_out_file, current_sym_addr); |
946754ae | 2759 | else |
e3b8b697 | 2760 | fprintf (asm_out_file, "%d", current_sym_value); |
2761 | putc ('\n', asm_out_file); | |
439c05a0 | 2762 | #endif |
946754ae | 2763 | } |
2764 | ||
6ef828f9 | 2765 | /* Output definitions of all the decls in a chain. Return nonzero if |
d0309f39 | 2766 | anything was output */ |
946754ae | 2767 | |
d0309f39 | 2768 | int |
8ec3a57b | 2769 | dbxout_syms (tree syms) |
946754ae | 2770 | { |
d0309f39 | 2771 | int result = 0; |
946754ae | 2772 | while (syms) |
2773 | { | |
d0309f39 | 2774 | result += dbxout_symbol (syms, 1); |
946754ae | 2775 | syms = TREE_CHAIN (syms); |
2776 | } | |
d0309f39 | 2777 | return result; |
946754ae | 2778 | } |
2779 | \f | |
2780 | /* The following two functions output definitions of function parameters. | |
2781 | Each parameter gets a definition locating it in the parameter list. | |
2782 | Each parameter that is a register variable gets a second definition | |
2783 | locating it in the register. | |
2784 | ||
2785 | Printing or argument lists in gdb uses the definitions that | |
2786 | locate in the parameter list. But reference to the variable in | |
2787 | expressions uses preferentially the definition as a register. */ | |
2788 | ||
2789 | /* Output definitions, referring to storage in the parmlist, | |
2790 | of all the parms in PARMS, which is a chain of PARM_DECL nodes. */ | |
2791 | ||
439c05a0 | 2792 | void |
8ec3a57b | 2793 | dbxout_parms (tree parms) |
946754ae | 2794 | { |
262444a6 | 2795 | ++debug_nesting; |
2796 | ||
51cec339 | 2797 | emit_pending_bincls_if_required (); |
2798 | ||
946754ae | 2799 | for (; parms; parms = TREE_CHAIN (parms)) |
043dbdf4 | 2800 | if (DECL_NAME (parms) |
2801 | && TREE_TYPE (parms) != error_mark_node | |
2802 | && DECL_RTL_SET_P (parms) | |
2803 | && DECL_INCOMING_RTL (parms)) | |
946754ae | 2804 | { |
2805 | dbxout_prepare_symbol (parms); | |
2806 | ||
2807 | /* Perform any necessary register eliminations on the parameter's rtl, | |
2808 | so that the debugging output will be accurate. */ | |
2809 | DECL_INCOMING_RTL (parms) | |
6182a80f | 2810 | = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX); |
0e8e37b2 | 2811 | SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX)); |
946754ae | 2812 | #ifdef LEAF_REG_REMAP |
b3b67b7c | 2813 | if (current_function_uses_only_leaf_regs) |
946754ae | 2814 | { |
2815 | leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms)); | |
2816 | leaf_renumber_regs_insn (DECL_RTL (parms)); | |
2817 | } | |
2818 | #endif | |
2819 | ||
2820 | if (PARM_PASSED_IN_MEMORY (parms)) | |
2821 | { | |
2822 | rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0); | |
2823 | ||
2824 | /* ??? Here we assume that the parm address is indexed | |
2825 | off the frame pointer or arg pointer. | |
2826 | If that is not true, we produce meaningless results, | |
2827 | but do not crash. */ | |
2828 | if (GET_CODE (addr) == PLUS | |
2829 | && GET_CODE (XEXP (addr, 1)) == CONST_INT) | |
2830 | current_sym_value = INTVAL (XEXP (addr, 1)); | |
2831 | else | |
2832 | current_sym_value = 0; | |
2833 | ||
2834 | current_sym_code = N_PSYM; | |
2835 | current_sym_addr = 0; | |
2836 | ||
2837 | FORCE_TEXT; | |
2838 | if (DECL_NAME (parms)) | |
2839 | { | |
2840 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); | |
52cae7bf | 2841 | fprintf (asm_out_file, "%s\"%s:p", ASM_STABS_OP, |
2842 | IDENTIFIER_POINTER (DECL_NAME (parms))); | |
946754ae | 2843 | } |
2844 | else | |
2845 | { | |
2846 | current_sym_nchars = 8; | |
52cae7bf | 2847 | fprintf (asm_out_file, "%s\"(anon):p", ASM_STABS_OP); |
946754ae | 2848 | } |
2849 | ||
1d7caf49 | 2850 | /* It is quite tempting to use: |
1eefe280 | 2851 | |
9aa97f08 | 2852 | dbxout_type (TREE_TYPE (parms), 0); |
1d7caf49 | 2853 | |
2854 | as the next statement, rather than using DECL_ARG_TYPE(), so | |
2855 | that gcc reports the actual type of the parameter, rather | |
2856 | than the promoted type. This certainly makes GDB's life | |
2857 | easier, at least for some ports. The change is a bad idea | |
2858 | however, since GDB expects to be able access the type without | |
2859 | performing any conversions. So for example, if we were | |
2860 | passing a float to an unprototyped function, gcc will store a | |
2861 | double on the stack, but if we emit a stab saying the type is a | |
2862 | float, then gdb will only read in a single value, and this will | |
dae39efc | 2863 | produce an erroneous value. */ |
1eefe280 | 2864 | dbxout_type (DECL_ARG_TYPE (parms), 0); |
946754ae | 2865 | current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr); |
2866 | dbxout_finish_symbol (parms); | |
2867 | } | |
8ad4c111 | 2868 | else if (REG_P (DECL_RTL (parms))) |
946754ae | 2869 | { |
2870 | rtx best_rtl; | |
439c05a0 | 2871 | char regparm_letter; |
52eab9d6 | 2872 | tree parm_type; |
946754ae | 2873 | /* Parm passed in registers and lives in registers or nowhere. */ |
2874 | ||
439c05a0 | 2875 | current_sym_code = DBX_REGPARM_STABS_CODE; |
2876 | regparm_letter = DBX_REGPARM_STABS_LETTER; | |
946754ae | 2877 | current_sym_addr = 0; |
2878 | ||
2879 | /* If parm lives in a register, use that register; | |
2880 | pretend the parm was passed there. It would be more consistent | |
2881 | to describe the register where the parm was passed, | |
52eab9d6 | 2882 | but in practice that register usually holds something else. |
2883 | ||
2884 | If we use DECL_RTL, then we must use the declared type of | |
2885 | the variable, not the type that it arrived in. */ | |
02e7a332 | 2886 | if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) |
52eab9d6 | 2887 | { |
2888 | best_rtl = DECL_RTL (parms); | |
2889 | parm_type = TREE_TYPE (parms); | |
2890 | } | |
147cb190 | 2891 | /* If the parm lives nowhere, use the register where it was |
2892 | passed. It is also better to use the declared type here. */ | |
946754ae | 2893 | else |
52eab9d6 | 2894 | { |
2895 | best_rtl = DECL_INCOMING_RTL (parms); | |
147cb190 | 2896 | parm_type = TREE_TYPE (parms); |
52eab9d6 | 2897 | } |
946754ae | 2898 | current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl)); |
2899 | ||
2900 | FORCE_TEXT; | |
2901 | if (DECL_NAME (parms)) | |
2902 | { | |
2903 | current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); | |
e3b8b697 | 2904 | fprintf (asm_out_file, "%s\"%s:%c", ASM_STABS_OP, |
439c05a0 | 2905 | IDENTIFIER_POINTER (DECL_NAME (parms)), |
2906 | regparm_letter); | |
946754ae | 2907 | } |
2908 | else | |
2909 | { | |
2910 | current_sym_nchars = 8; | |
e3b8b697 | 2911 | fprintf (asm_out_file, "%s\"(anon):%c", ASM_STABS_OP, |
439c05a0 | 2912 | regparm_letter); |
946754ae | 2913 | } |
2914 | ||
9aa97f08 | 2915 | dbxout_type (parm_type, 0); |
946754ae | 2916 | dbxout_finish_symbol (parms); |
2917 | } | |
e16ceb8e | 2918 | else if (MEM_P (DECL_RTL (parms)) |
8ad4c111 | 2919 | && REG_P (XEXP (DECL_RTL (parms), 0)) |
cb8b8ba0 | 2920 | && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM |
2921 | && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM | |
d13c643a | 2922 | #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM |
cb8b8ba0 | 2923 | && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM |
2924 | #endif | |
2925 | ) | |
f10caba4 | 2926 | { |
2927 | /* Parm was passed via invisible reference. | |
2928 | That is, its address was passed in a register. | |
2929 | Output it as if it lived in that register. | |
2930 | The debugger will know from the type | |
2931 | that it was actually passed by invisible reference. */ | |
2932 | ||
2933 | char regparm_letter; | |
2934 | /* Parm passed in registers and lives in registers or nowhere. */ | |
2935 | ||
2936 | current_sym_code = DBX_REGPARM_STABS_CODE; | |
52cae7bf | 2937 | |
84f564cc | 2938 | if (use_gnu_debug_info_extensions) |
52cae7bf | 2939 | /* GDB likes this marked with a special letter. */ |
2940 | regparm_letter = 'a'; | |
84f564cc | 2941 | else |
2942 | regparm_letter = DBX_REGPARM_STABS_LETTER; | |
f10caba4 | 2943 | |
3bf2cac3 | 2944 | /* DECL_RTL looks like (MEM (REG...). Get the register number. |
2945 | If it is an unallocated pseudo-reg, then use the register where | |
2946 | it was passed instead. */ | |
02e7a332 | 2947 | if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER) |
3bf2cac3 | 2948 | current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0)); |
2949 | else | |
2950 | current_sym_value = REGNO (DECL_INCOMING_RTL (parms)); | |
2951 | ||
f10caba4 | 2952 | current_sym_addr = 0; |
2953 | ||
2954 | FORCE_TEXT; | |
2955 | if (DECL_NAME (parms)) | |
2956 | { | |
d4b87fe5 | 2957 | current_sym_nchars |
2958 | = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms))); | |
f10caba4 | 2959 | |
e3b8b697 | 2960 | fprintf (asm_out_file, "%s\"%s:%c", ASM_STABS_OP, |
f10caba4 | 2961 | IDENTIFIER_POINTER (DECL_NAME (parms)), |
84f564cc | 2962 | regparm_letter); |
f10caba4 | 2963 | } |
2964 | else | |
2965 | { | |
2966 | current_sym_nchars = 8; | |
e3b8b697 | 2967 | fprintf (asm_out_file, "%s\"(anon):%c", ASM_STABS_OP, |
84f564cc | 2968 | regparm_letter); |
f10caba4 | 2969 | } |
2970 | ||
9aa97f08 | 2971 | dbxout_type (TREE_TYPE (parms), 0); |
f10caba4 | 2972 | dbxout_finish_symbol (parms); |
2973 | } | |
e16ceb8e | 2974 | else if (MEM_P (DECL_RTL (parms)) |
2975 | && MEM_P (XEXP (DECL_RTL (parms), 0))) | |
8c03ddcf | 2976 | { |
2977 | /* Parm was passed via invisible reference, with the reference | |
2978 | living on the stack. DECL_RTL looks like | |
eed9d2f3 | 2979 | (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it |
2980 | could look like (MEM (MEM (REG))). */ | |
0d95286f | 2981 | const char *const decl_name = (DECL_NAME (parms) |
8c03ddcf | 2982 | ? IDENTIFIER_POINTER (DECL_NAME (parms)) |
2983 | : "(anon)"); | |
8ad4c111 | 2984 | if (REG_P (XEXP (XEXP (DECL_RTL (parms), 0), 0))) |
1eefe280 | 2985 | current_sym_value = 0; |
eed9d2f3 | 2986 | else |
2987 | current_sym_value | |
2988 | = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1)); | |
8c03ddcf | 2989 | current_sym_addr = 0; |
b109f4ea | 2990 | current_sym_code = N_PSYM; |
1eefe280 | 2991 | |
8c03ddcf | 2992 | FORCE_TEXT; |
e3b8b697 | 2993 | fprintf (asm_out_file, "%s\"%s:v", ASM_STABS_OP, decl_name); |
08ba4893 | 2994 | |
2995 | current_sym_value | |
2996 | = DEBUGGER_ARG_OFFSET (current_sym_value, | |
2997 | XEXP (XEXP (DECL_RTL (parms), 0), 0)); | |
9aa97f08 | 2998 | dbxout_type (TREE_TYPE (parms), 0); |
8c03ddcf | 2999 | dbxout_finish_symbol (parms); |
3000 | } | |
e16ceb8e | 3001 | else if (MEM_P (DECL_RTL (parms)) |
4394fe52 | 3002 | && XEXP (DECL_RTL (parms), 0) != const0_rtx |
3003 | /* ??? A constant address for a parm can happen | |
3004 | when the reg it lives in is equiv to a constant in memory. | |
3005 | Should make this not happen, after 2.4. */ | |
3006 | && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0))) | |
946754ae | 3007 | { |
3008 | /* Parm was passed in registers but lives on the stack. */ | |
3009 | ||
3010 | current_sym_code = N_PSYM; | |
3011 | /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))), | |
3012 | in which case we want the value of that CONST_INT, | |
8c03ddcf | 3013 | or (MEM (REG ...)), |
946754ae | 3014 | in which case we use a value of zero. */ |
8ad4c111 | 3015 | if (REG_P (XEXP (DECL_RTL (parms), 0))) |
946754ae | 3016 | current_sym_value = 0; |
3017 | else | |
155b05dc | 3018 | current_sym_value |
3019 | = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)); | |
3020 | ||
946754ae | 3021 | current_sym_addr = 0; |
3022 | ||
c9452941 | 3023 | /* Make a big endian correction if the mode of the type of the |
3024 | parameter is not the same as the mode of the rtl. */ | |
3025 | if (BYTES_BIG_ENDIAN | |
3026 | && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms)) | |
3027 | && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD) | |
3028 | { | |
1eefe280 | 3029 | current_sym_value += |
869621c0 | 3030 | GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))) |
3031 | - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))); | |
c9452941 | 3032 | } |
3033 | ||
946754ae | 3034 | FORCE_TEXT; |
3035 | if (DECL_NAME (parms)) | |
3036 | { | |
155b05dc | 3037 | current_sym_nchars |
3038 | = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms))); | |
946754ae | 3039 | |
52cae7bf | 3040 | fprintf (asm_out_file, "%s\"%s:p", ASM_STABS_OP, |
3041 | IDENTIFIER_POINTER (DECL_NAME (parms))); | |
946754ae | 3042 | } |
3043 | else | |
3044 | { | |
3045 | current_sym_nchars = 8; | |
52cae7bf | 3046 | fprintf (asm_out_file, "%s\"(anon):p", ASM_STABS_OP); |
946754ae | 3047 | } |
3048 | ||
3049 | current_sym_value | |
3050 | = DEBUGGER_ARG_OFFSET (current_sym_value, | |
3051 | XEXP (DECL_RTL (parms), 0)); | |
9aa97f08 | 3052 | dbxout_type (TREE_TYPE (parms), 0); |
946754ae | 3053 | dbxout_finish_symbol (parms); |
3054 | } | |
3055 | } | |
262444a6 | 3056 | DBXOUT_DECR_NESTING; |
946754ae | 3057 | } |
3058 | ||
3059 | /* Output definitions for the places where parms live during the function, | |
3060 | when different from where they were passed, when the parms were passed | |
3061 | in memory. | |
3062 | ||
3063 | It is not useful to do this for parms passed in registers | |
3064 | that live during the function in different registers, because it is | |
3065 | impossible to look in the passed register for the passed value, | |
3066 | so we use the within-the-function register to begin with. | |
3067 | ||
3068 | PARMS is a chain of PARM_DECL nodes. */ | |
3069 | ||
439c05a0 | 3070 | void |
8ec3a57b | 3071 | dbxout_reg_parms (tree parms) |
946754ae | 3072 | { |
262444a6 | 3073 | ++debug_nesting; |
3074 | ||
946754ae | 3075 | for (; parms; parms = TREE_CHAIN (parms)) |
ae399944 | 3076 | if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms)) |
946754ae | 3077 | { |
3078 | dbxout_prepare_symbol (parms); | |
3079 | ||
3080 | /* Report parms that live in registers during the function | |
3081 | but were passed in memory. */ | |
8ad4c111 | 3082 | if (REG_P (DECL_RTL (parms)) |
ae399944 | 3083 | && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) |
3c5d2a1c | 3084 | dbxout_symbol_location (parms, TREE_TYPE (parms), |
3085 | 0, DECL_RTL (parms)); | |
ae399944 | 3086 | else if (GET_CODE (DECL_RTL (parms)) == CONCAT) |
3c5d2a1c | 3087 | dbxout_symbol_location (parms, TREE_TYPE (parms), |
3088 | 0, DECL_RTL (parms)); | |
946754ae | 3089 | /* Report parms that live in memory but not where they were passed. */ |
e16ceb8e | 3090 | else if (MEM_P (DECL_RTL (parms)) |
946754ae | 3091 | && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms))) |
ae399944 | 3092 | dbxout_symbol_location (parms, TREE_TYPE (parms), |
3093 | 0, DECL_RTL (parms)); | |
946754ae | 3094 | } |
262444a6 | 3095 | DBXOUT_DECR_NESTING; |
946754ae | 3096 | } |
3097 | \f | |
3098 | /* Given a chain of ..._TYPE nodes (as come in a parameter list), | |
3099 | output definitions of those names, in raw form */ | |
3100 | ||
b29760a8 | 3101 | static void |
8ec3a57b | 3102 | dbxout_args (tree args) |
946754ae | 3103 | { |
3104 | while (args) | |
3105 | { | |
e3b8b697 | 3106 | putc (',', asm_out_file); |
9aa97f08 | 3107 | dbxout_type (TREE_VALUE (args), 0); |
946754ae | 3108 | CHARS (1); |
3109 | args = TREE_CHAIN (args); | |
3110 | } | |
3111 | } | |
3112 | \f | |
7850c77b | 3113 | /* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL. |
3114 | BEGIN_LABEL is the name of the beginning of the function, which may | |
3115 | be required. */ | |
3116 | static void | |
3117 | dbx_output_lbrac (const char *label, | |
3118 | const char *begin_label ATTRIBUTE_UNUSED) | |
3119 | { | |
3120 | #ifdef DBX_OUTPUT_LBRAC | |
e3b8b697 | 3121 | DBX_OUTPUT_LBRAC (asm_out_file, label); |
7850c77b | 3122 | #else |
e3b8b697 | 3123 | fprintf (asm_out_file, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC); |
3124 | assemble_name (asm_out_file, label); | |
3125 | if (DBX_BLOCKS_FUNCTION_RELATIVE) | |
3126 | { | |
3127 | putc ('-', asm_out_file); | |
3128 | assemble_name (asm_out_file, begin_label); | |
3129 | } | |
3130 | fprintf (asm_out_file, "\n"); | |
7850c77b | 3131 | #endif |
3132 | } | |
3133 | ||
3134 | /* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL. | |
3135 | BEGIN_LABEL is the name of the beginning of the function, which may | |
3136 | be required. */ | |
3137 | static void | |
3138 | dbx_output_rbrac (const char *label, | |
3139 | const char *begin_label ATTRIBUTE_UNUSED) | |
3140 | { | |
3141 | #ifdef DBX_OUTPUT_RBRAC | |
e3b8b697 | 3142 | DBX_OUTPUT_RBRAC (asm_out_file, label); |
7850c77b | 3143 | #else |
e3b8b697 | 3144 | fprintf (asm_out_file, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC); |
3145 | assemble_name (asm_out_file, label); | |
3146 | if (DBX_BLOCKS_FUNCTION_RELATIVE) | |
3147 | { | |
3148 | putc ('-', asm_out_file); | |
3149 | assemble_name (asm_out_file, begin_label); | |
3150 | } | |
3151 | fprintf (asm_out_file, "\n"); | |
7850c77b | 3152 | #endif |
3153 | } | |
3154 | ||
946754ae | 3155 | /* Output everything about a symbol block (a BLOCK node |
3156 | that represents a scope level), | |
3157 | including recursive output of contained blocks. | |
3158 | ||
3159 | BLOCK is the BLOCK node. | |
3160 | DEPTH is its depth within containing symbol blocks. | |
3161 | ARGS is usually zero; but for the outermost block of the | |
3162 | body of a function, it is a chain of PARM_DECLs for the function parameters. | |
3163 | We output definitions of all the register parms | |
3164 | as if they were local variables of that block. | |
3165 | ||
3166 | If -g1 was used, we count blocks just the same, but output nothing | |
3167 | except for the outermost block. | |
3168 | ||
3169 | Actually, BLOCK may be several blocks chained together. | |
3170 | We handle them all in sequence. */ | |
3171 | ||
3172 | static void | |
8ec3a57b | 3173 | dbxout_block (tree block, int depth, tree args) |
946754ae | 3174 | { |
1eefe280 | 3175 | const char *begin_label; |
e3b8b697 | 3176 | begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); |
946754ae | 3177 | |
3178 | while (block) | |
3179 | { | |
3180 | /* Ignore blocks never expanded or otherwise marked as real. */ | |
5846cb0f | 3181 | if (TREE_USED (block) && TREE_ASM_WRITTEN (block)) |
946754ae | 3182 | { |
a1d829f8 | 3183 | int did_output; |
7850c77b | 3184 | int blocknum = BLOCK_NUMBER (block); |
a1d829f8 | 3185 | |
d0309f39 | 3186 | /* In dbx format, the syms of a block come before the N_LBRAC. |
6312a35e | 3187 | If nothing is output, we don't need the N_LBRAC, either. */ |
a1d829f8 | 3188 | did_output = 0; |
946754ae | 3189 | if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0) |
a1d829f8 | 3190 | did_output = dbxout_syms (BLOCK_VARS (block)); |
946754ae | 3191 | if (args) |
3192 | dbxout_reg_parms (args); | |
946754ae | 3193 | |
3194 | /* Now output an N_LBRAC symbol to represent the beginning of | |
3195 | the block. Use the block's tree-walk order to generate | |
3196 | the assembler symbols LBBn and LBEn | |
3197 | that final will define around the code in this block. */ | |
7850c77b | 3198 | if (did_output) |
946754ae | 3199 | { |
3200 | char buf[20]; | |
7850c77b | 3201 | const char *scope_start; |
3202 | ||
3203 | if (depth == 0) | |
3204 | /* The outermost block doesn't get LBB labels; use | |
3205 | the function symbol. */ | |
3206 | scope_start = begin_label; | |
3207 | else | |
3208 | { | |
3209 | ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum); | |
3210 | scope_start = buf; | |
3211 | } | |
946754ae | 3212 | |
3213 | if (BLOCK_HANDLER_BLOCK (block)) | |
3214 | { | |
3215 | /* A catch block. Must precede N_LBRAC. */ | |
3216 | tree decl = BLOCK_VARS (block); | |
3217 | while (decl) | |
3218 | { | |
e3b8b697 | 3219 | fprintf (asm_out_file, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP, |
946754ae | 3220 | IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH); |
e3b8b697 | 3221 | assemble_name (asm_out_file, scope_start); |
3222 | fprintf (asm_out_file, "\n"); | |
946754ae | 3223 | decl = TREE_CHAIN (decl); |
3224 | } | |
3225 | } | |
7850c77b | 3226 | dbx_output_lbrac (scope_start, begin_label); |
946754ae | 3227 | } |
946754ae | 3228 | |
946754ae | 3229 | /* Output the subblocks. */ |
4303221c | 3230 | dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE); |
946754ae | 3231 | |
3232 | /* Refer to the marker for the end of the block. */ | |
7850c77b | 3233 | if (did_output) |
946754ae | 3234 | { |
7850c77b | 3235 | char buf[100]; |
3236 | if (depth == 0) | |
3237 | /* The outermost block doesn't get LBE labels; | |
3238 | use the "scope" label which will be emitted | |
3239 | by dbxout_function_end. */ | |
3240 | ASM_GENERATE_INTERNAL_LABEL (buf, "Lscope", scope_labelno); | |
3241 | else | |
3242 | ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum); | |
3243 | ||
3244 | dbx_output_rbrac (buf, begin_label); | |
946754ae | 3245 | } |
3246 | } | |
3247 | block = BLOCK_CHAIN (block); | |
3248 | } | |
3249 | } | |
3250 | ||
3251 | /* Output the information about a function and its arguments and result. | |
3252 | Usually this follows the function's code, | |
3253 | but on some systems, it comes before. */ | |
3254 | ||
0c87a39e | 3255 | #if defined (DBX_DEBUGGING_INFO) |
946754ae | 3256 | static void |
8ec3a57b | 3257 | dbxout_begin_function (tree decl) |
946754ae | 3258 | { |
262444a6 | 3259 | int saved_tree_used1 = TREE_USED (decl); |
3260 | TREE_USED (decl) = 1; | |
3261 | if (DECL_NAME (DECL_RESULT (decl)) != 0) | |
3262 | { | |
8ec3a57b | 3263 | int saved_tree_used2 = TREE_USED (DECL_RESULT (decl)); |
262444a6 | 3264 | TREE_USED (DECL_RESULT (decl)) = 1; |
3265 | dbxout_symbol (decl, 0); | |
3266 | TREE_USED (DECL_RESULT (decl)) = saved_tree_used2; | |
3267 | } | |
3268 | else | |
3269 | dbxout_symbol (decl, 0); | |
3270 | TREE_USED (decl) = saved_tree_used1; | |
3271 | ||
946754ae | 3272 | dbxout_parms (DECL_ARGUMENTS (decl)); |
3273 | if (DECL_NAME (DECL_RESULT (decl)) != 0) | |
3274 | dbxout_symbol (DECL_RESULT (decl), 1); | |
3275 | } | |
0c87a39e | 3276 | #endif /* DBX_DEBUGGING_INFO */ |
946754ae | 3277 | |
02da6382 | 3278 | #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */ |
573aba85 | 3279 | |
3280 | #include "gt-dbxout.h" |