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