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