Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Fortran language support routines for GDB, the GNU debugger. |
ce27fb25 | 2 | |
6aba47ca DJ |
3 | Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, |
4 | 2004, 2005, 2007 Free Software Foundation, Inc. | |
ce27fb25 | 5 | |
c906108c SS |
6 | Contributed by Motorola. Adapted from the C parser by Farooq Butt |
7 | (fmbutt@engage.sps.mot.com). | |
8 | ||
c5aa993b | 9 | This file is part of GDB. |
c906108c | 10 | |
c5aa993b JM |
11 | This program is free software; you can redistribute it and/or modify |
12 | it under the terms of the GNU General Public License as published by | |
13 | the Free Software Foundation; either version 2 of the License, or | |
14 | (at your option) any later version. | |
c906108c | 15 | |
c5aa993b JM |
16 | This program is distributed in the hope that it will be useful, |
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | GNU General Public License for more details. | |
c906108c | 20 | |
c5aa993b JM |
21 | You should have received a copy of the GNU General Public License |
22 | along with this program; if not, write to the Free Software | |
197e01b6 EZ |
23 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 | Boston, MA 02110-1301, USA. */ | |
c906108c SS |
25 | |
26 | #include "defs.h" | |
27 | #include "gdb_string.h" | |
28 | #include "symtab.h" | |
29 | #include "gdbtypes.h" | |
30 | #include "expression.h" | |
31 | #include "parser-defs.h" | |
32 | #include "language.h" | |
33 | #include "f-lang.h" | |
745b8ca0 | 34 | #include "valprint.h" |
5f9a71c3 | 35 | #include "value.h" |
c906108c | 36 | |
c906108c SS |
37 | |
38 | /* Following is dubious stuff that had been in the xcoff reader. */ | |
39 | ||
40 | struct saved_fcn | |
c5aa993b JM |
41 | { |
42 | long line_offset; /* Line offset for function */ | |
43 | struct saved_fcn *next; | |
44 | }; | |
c906108c SS |
45 | |
46 | ||
c5aa993b JM |
47 | struct saved_bf_symnum |
48 | { | |
49 | long symnum_fcn; /* Symnum of function (i.e. .function directive) */ | |
50 | long symnum_bf; /* Symnum of .bf for this function */ | |
51 | struct saved_bf_symnum *next; | |
52 | }; | |
c906108c | 53 | |
c5aa993b JM |
54 | typedef struct saved_fcn SAVED_FUNCTION, *SAVED_FUNCTION_PTR; |
55 | typedef struct saved_bf_symnum SAVED_BF, *SAVED_BF_PTR; | |
c906108c SS |
56 | |
57 | /* Local functions */ | |
58 | ||
a14ed312 | 59 | extern void _initialize_f_language (void); |
c906108c | 60 | #if 0 |
a14ed312 KB |
61 | static void clear_function_list (void); |
62 | static long get_bf_for_fcn (long); | |
63 | static void clear_bf_list (void); | |
64 | static void patch_all_commons_by_name (char *, CORE_ADDR, int); | |
65 | static SAVED_F77_COMMON_PTR find_first_common_named (char *); | |
66 | static void add_common_entry (struct symbol *); | |
67 | static void add_common_block (char *, CORE_ADDR, int, char *); | |
68 | static SAVED_FUNCTION *allocate_saved_function_node (void); | |
69 | static SAVED_BF_PTR allocate_saved_bf_node (void); | |
70 | static COMMON_ENTRY_PTR allocate_common_entry_node (void); | |
71 | static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void); | |
72 | static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int); | |
c906108c SS |
73 | #endif |
74 | ||
a14ed312 | 75 | static struct type *f_create_fundamental_type (struct objfile *, int); |
d9fcf2fb JM |
76 | static void f_printchar (int c, struct ui_file * stream); |
77 | static void f_emit_char (int c, struct ui_file * stream, int quoter); | |
c906108c SS |
78 | |
79 | /* Print the character C on STREAM as part of the contents of a literal | |
80 | string whose delimiter is QUOTER. Note that that format for printing | |
81 | characters and strings is language specific. | |
82 | FIXME: This is a copy of the same function from c-exp.y. It should | |
83 | be replaced with a true F77 version. */ | |
84 | ||
85 | static void | |
f86f5ca3 | 86 | f_emit_char (int c, struct ui_file *stream, int quoter) |
c906108c SS |
87 | { |
88 | c &= 0xFF; /* Avoid sign bit follies */ | |
c5aa993b | 89 | |
c906108c SS |
90 | if (PRINT_LITERAL_FORM (c)) |
91 | { | |
92 | if (c == '\\' || c == quoter) | |
93 | fputs_filtered ("\\", stream); | |
94 | fprintf_filtered (stream, "%c", c); | |
95 | } | |
96 | else | |
97 | { | |
98 | switch (c) | |
99 | { | |
100 | case '\n': | |
101 | fputs_filtered ("\\n", stream); | |
102 | break; | |
103 | case '\b': | |
104 | fputs_filtered ("\\b", stream); | |
105 | break; | |
106 | case '\t': | |
107 | fputs_filtered ("\\t", stream); | |
108 | break; | |
109 | case '\f': | |
110 | fputs_filtered ("\\f", stream); | |
111 | break; | |
112 | case '\r': | |
113 | fputs_filtered ("\\r", stream); | |
114 | break; | |
115 | case '\033': | |
116 | fputs_filtered ("\\e", stream); | |
117 | break; | |
118 | case '\007': | |
119 | fputs_filtered ("\\a", stream); | |
120 | break; | |
121 | default: | |
122 | fprintf_filtered (stream, "\\%.3o", (unsigned int) c); | |
123 | break; | |
124 | } | |
125 | } | |
126 | } | |
127 | ||
128 | /* FIXME: This is a copy of the same function from c-exp.y. It should | |
129 | be replaced with a true F77version. */ | |
130 | ||
131 | static void | |
fba45db2 | 132 | f_printchar (int c, struct ui_file *stream) |
c906108c SS |
133 | { |
134 | fputs_filtered ("'", stream); | |
135 | LA_EMIT_CHAR (c, stream, '\''); | |
136 | fputs_filtered ("'", stream); | |
137 | } | |
138 | ||
139 | /* Print the character string STRING, printing at most LENGTH characters. | |
140 | Printing stops early if the number hits print_max; repeat counts | |
141 | are printed as appropriate. Print ellipses at the end if we | |
142 | had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. | |
143 | FIXME: This is a copy of the same function from c-exp.y. It should | |
144 | be replaced with a true F77 version. */ | |
145 | ||
146 | static void | |
fc1a4b47 | 147 | f_printstr (struct ui_file *stream, const gdb_byte *string, |
ce27fb25 | 148 | unsigned int length, int width, int force_ellipses) |
c906108c | 149 | { |
f86f5ca3 | 150 | unsigned int i; |
c906108c SS |
151 | unsigned int things_printed = 0; |
152 | int in_quotes = 0; | |
153 | int need_comma = 0; | |
c5aa993b | 154 | |
c906108c SS |
155 | if (length == 0) |
156 | { | |
157 | fputs_filtered ("''", gdb_stdout); | |
158 | return; | |
159 | } | |
c5aa993b | 160 | |
c906108c SS |
161 | for (i = 0; i < length && things_printed < print_max; ++i) |
162 | { | |
163 | /* Position of the character we are examining | |
c5aa993b | 164 | to see whether it is repeated. */ |
c906108c SS |
165 | unsigned int rep1; |
166 | /* Number of repetitions we have detected so far. */ | |
167 | unsigned int reps; | |
c5aa993b | 168 | |
c906108c | 169 | QUIT; |
c5aa993b | 170 | |
c906108c SS |
171 | if (need_comma) |
172 | { | |
173 | fputs_filtered (", ", stream); | |
174 | need_comma = 0; | |
175 | } | |
c5aa993b | 176 | |
c906108c SS |
177 | rep1 = i + 1; |
178 | reps = 1; | |
179 | while (rep1 < length && string[rep1] == string[i]) | |
180 | { | |
181 | ++rep1; | |
182 | ++reps; | |
183 | } | |
c5aa993b | 184 | |
c906108c SS |
185 | if (reps > repeat_count_threshold) |
186 | { | |
187 | if (in_quotes) | |
188 | { | |
189 | if (inspect_it) | |
190 | fputs_filtered ("\\', ", stream); | |
191 | else | |
192 | fputs_filtered ("', ", stream); | |
193 | in_quotes = 0; | |
194 | } | |
195 | f_printchar (string[i], stream); | |
196 | fprintf_filtered (stream, " <repeats %u times>", reps); | |
197 | i = rep1 - 1; | |
198 | things_printed += repeat_count_threshold; | |
199 | need_comma = 1; | |
200 | } | |
201 | else | |
202 | { | |
203 | if (!in_quotes) | |
204 | { | |
205 | if (inspect_it) | |
206 | fputs_filtered ("\\'", stream); | |
207 | else | |
208 | fputs_filtered ("'", stream); | |
209 | in_quotes = 1; | |
210 | } | |
211 | LA_EMIT_CHAR (string[i], stream, '"'); | |
212 | ++things_printed; | |
213 | } | |
214 | } | |
c5aa993b | 215 | |
c906108c SS |
216 | /* Terminate the quotes if necessary. */ |
217 | if (in_quotes) | |
218 | { | |
219 | if (inspect_it) | |
220 | fputs_filtered ("\\'", stream); | |
221 | else | |
222 | fputs_filtered ("'", stream); | |
223 | } | |
c5aa993b | 224 | |
c906108c SS |
225 | if (force_ellipses || i < length) |
226 | fputs_filtered ("...", stream); | |
227 | } | |
228 | ||
229 | /* FIXME: This is a copy of c_create_fundamental_type(), before | |
230 | all the non-C types were stripped from it. Needs to be fixed | |
231 | by an experienced F77 programmer. */ | |
232 | ||
233 | static struct type * | |
fba45db2 | 234 | f_create_fundamental_type (struct objfile *objfile, int typeid) |
c906108c | 235 | { |
f86f5ca3 | 236 | struct type *type = NULL; |
c5aa993b | 237 | |
c906108c SS |
238 | switch (typeid) |
239 | { | |
240 | case FT_VOID: | |
241 | type = init_type (TYPE_CODE_VOID, | |
242 | TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
243 | 0, "VOID", objfile); | |
244 | break; | |
245 | case FT_BOOLEAN: | |
246 | type = init_type (TYPE_CODE_BOOL, | |
247 | TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
248 | TYPE_FLAG_UNSIGNED, "boolean", objfile); | |
249 | break; | |
250 | case FT_STRING: | |
251 | type = init_type (TYPE_CODE_STRING, | |
252 | TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
253 | 0, "string", objfile); | |
254 | break; | |
255 | case FT_CHAR: | |
256 | type = init_type (TYPE_CODE_INT, | |
257 | TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
258 | 0, "character", objfile); | |
259 | break; | |
260 | case FT_SIGNED_CHAR: | |
261 | type = init_type (TYPE_CODE_INT, | |
262 | TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
263 | 0, "integer*1", objfile); | |
264 | break; | |
265 | case FT_UNSIGNED_CHAR: | |
266 | type = init_type (TYPE_CODE_BOOL, | |
267 | TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
268 | TYPE_FLAG_UNSIGNED, "logical*1", objfile); | |
269 | break; | |
270 | case FT_SHORT: | |
271 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 272 | gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
273 | 0, "integer*2", objfile); |
274 | break; | |
275 | case FT_SIGNED_SHORT: | |
276 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 277 | gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
278 | 0, "short", objfile); /* FIXME-fnf */ |
279 | break; | |
280 | case FT_UNSIGNED_SHORT: | |
281 | type = init_type (TYPE_CODE_BOOL, | |
9a76efb6 | 282 | gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
283 | TYPE_FLAG_UNSIGNED, "logical*2", objfile); |
284 | break; | |
285 | case FT_INTEGER: | |
286 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 287 | gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
288 | 0, "integer*4", objfile); |
289 | break; | |
290 | case FT_SIGNED_INTEGER: | |
291 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 292 | gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c5aa993b | 293 | 0, "integer", objfile); /* FIXME -fnf */ |
c906108c SS |
294 | break; |
295 | case FT_UNSIGNED_INTEGER: | |
c5aa993b | 296 | type = init_type (TYPE_CODE_BOOL, |
9a76efb6 | 297 | gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
298 | TYPE_FLAG_UNSIGNED, "logical*4", objfile); |
299 | break; | |
300 | case FT_FIXED_DECIMAL: | |
301 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 302 | gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
303 | 0, "fixed decimal", objfile); |
304 | break; | |
305 | case FT_LONG: | |
306 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 307 | gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
308 | 0, "long", objfile); |
309 | break; | |
310 | case FT_SIGNED_LONG: | |
311 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 312 | gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c5aa993b | 313 | 0, "long", objfile); /* FIXME -fnf */ |
c906108c SS |
314 | break; |
315 | case FT_UNSIGNED_LONG: | |
316 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 | 317 | gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
318 | TYPE_FLAG_UNSIGNED, "unsigned long", objfile); |
319 | break; | |
320 | case FT_LONG_LONG: | |
321 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 UW |
322 | gdbarch_long_long_bit (current_gdbarch) |
323 | / TARGET_CHAR_BIT, | |
c906108c SS |
324 | 0, "long long", objfile); |
325 | break; | |
326 | case FT_SIGNED_LONG_LONG: | |
327 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 UW |
328 | gdbarch_long_long_bit (current_gdbarch) |
329 | / TARGET_CHAR_BIT, | |
c906108c SS |
330 | 0, "signed long long", objfile); |
331 | break; | |
332 | case FT_UNSIGNED_LONG_LONG: | |
333 | type = init_type (TYPE_CODE_INT, | |
9a76efb6 UW |
334 | gdbarch_long_long_bit (current_gdbarch) |
335 | / TARGET_CHAR_BIT, | |
c906108c SS |
336 | TYPE_FLAG_UNSIGNED, "unsigned long long", objfile); |
337 | break; | |
338 | case FT_FLOAT: | |
339 | type = init_type (TYPE_CODE_FLT, | |
ea06eb3d | 340 | gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
341 | 0, "real", objfile); |
342 | break; | |
343 | case FT_DBL_PREC_FLOAT: | |
344 | type = init_type (TYPE_CODE_FLT, | |
ea06eb3d | 345 | gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
346 | 0, "real*8", objfile); |
347 | break; | |
348 | case FT_FLOAT_DECIMAL: | |
349 | type = init_type (TYPE_CODE_FLT, | |
ea06eb3d | 350 | gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
351 | 0, "floating decimal", objfile); |
352 | break; | |
353 | case FT_EXT_PREC_FLOAT: | |
354 | type = init_type (TYPE_CODE_FLT, | |
ea06eb3d UW |
355 | gdbarch_long_double_bit (current_gdbarch) |
356 | / TARGET_CHAR_BIT, | |
c906108c SS |
357 | 0, "real*16", objfile); |
358 | break; | |
359 | case FT_COMPLEX: | |
360 | type = init_type (TYPE_CODE_COMPLEX, | |
ea06eb3d | 361 | 2 * gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c SS |
362 | 0, "complex*8", objfile); |
363 | TYPE_TARGET_TYPE (type) = builtin_type_f_real; | |
364 | break; | |
365 | case FT_DBL_PREC_COMPLEX: | |
366 | type = init_type (TYPE_CODE_COMPLEX, | |
ea06eb3d UW |
367 | 2 * gdbarch_double_bit (current_gdbarch) |
368 | / TARGET_CHAR_BIT, | |
c906108c SS |
369 | 0, "complex*16", objfile); |
370 | TYPE_TARGET_TYPE (type) = builtin_type_f_real_s8; | |
371 | break; | |
372 | case FT_EXT_PREC_COMPLEX: | |
373 | type = init_type (TYPE_CODE_COMPLEX, | |
ea06eb3d UW |
374 | 2 * gdbarch_long_double_bit (current_gdbarch) |
375 | / TARGET_CHAR_BIT, | |
c906108c SS |
376 | 0, "complex*32", objfile); |
377 | TYPE_TARGET_TYPE (type) = builtin_type_f_real_s16; | |
378 | break; | |
379 | default: | |
380 | /* FIXME: For now, if we are asked to produce a type not in this | |
c5aa993b JM |
381 | language, create the equivalent of a C integer type with the |
382 | name "<?type?>". When all the dust settles from the type | |
383 | reconstruction work, this should probably become an error. */ | |
c906108c | 384 | type = init_type (TYPE_CODE_INT, |
9a76efb6 | 385 | gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, |
c906108c | 386 | 0, "<?type?>", objfile); |
8a3fe4f8 | 387 | warning (_("internal error: no F77 fundamental type %d"), typeid); |
c906108c SS |
388 | break; |
389 | } | |
390 | return (type); | |
391 | } | |
c906108c | 392 | \f |
c5aa993b | 393 | |
c906108c SS |
394 | /* Table of operators and their precedences for printing expressions. */ |
395 | ||
c5aa993b JM |
396 | static const struct op_print f_op_print_tab[] = |
397 | { | |
398 | {"+", BINOP_ADD, PREC_ADD, 0}, | |
399 | {"+", UNOP_PLUS, PREC_PREFIX, 0}, | |
400 | {"-", BINOP_SUB, PREC_ADD, 0}, | |
401 | {"-", UNOP_NEG, PREC_PREFIX, 0}, | |
402 | {"*", BINOP_MUL, PREC_MUL, 0}, | |
403 | {"/", BINOP_DIV, PREC_MUL, 0}, | |
404 | {"DIV", BINOP_INTDIV, PREC_MUL, 0}, | |
405 | {"MOD", BINOP_REM, PREC_MUL, 0}, | |
406 | {"=", BINOP_ASSIGN, PREC_ASSIGN, 1}, | |
407 | {".OR.", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, | |
408 | {".AND.", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, | |
409 | {".NOT.", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, | |
410 | {".EQ.", BINOP_EQUAL, PREC_EQUAL, 0}, | |
411 | {".NE.", BINOP_NOTEQUAL, PREC_EQUAL, 0}, | |
412 | {".LE.", BINOP_LEQ, PREC_ORDER, 0}, | |
413 | {".GE.", BINOP_GEQ, PREC_ORDER, 0}, | |
414 | {".GT.", BINOP_GTR, PREC_ORDER, 0}, | |
415 | {".LT.", BINOP_LESS, PREC_ORDER, 0}, | |
416 | {"**", UNOP_IND, PREC_PREFIX, 0}, | |
417 | {"@", BINOP_REPEAT, PREC_REPEAT, 0}, | |
418 | {NULL, 0, 0, 0} | |
c906108c SS |
419 | }; |
420 | \f | |
cad351d1 UW |
421 | enum f_primitive_types { |
422 | f_primitive_type_character, | |
423 | f_primitive_type_logical, | |
424 | f_primitive_type_logical_s1, | |
425 | f_primitive_type_logical_s2, | |
426 | f_primitive_type_integer, | |
427 | f_primitive_type_integer_s2, | |
428 | f_primitive_type_real, | |
429 | f_primitive_type_real_s8, | |
430 | f_primitive_type_real_s16, | |
431 | f_primitive_type_complex_s8, | |
432 | f_primitive_type_complex_s16, | |
433 | f_primitive_type_void, | |
434 | nr_f_primitive_types | |
c906108c SS |
435 | }; |
436 | ||
cad351d1 UW |
437 | static void |
438 | f_language_arch_info (struct gdbarch *gdbarch, | |
439 | struct language_arch_info *lai) | |
440 | { | |
54ef06c7 UW |
441 | const struct builtin_f_type *builtin = builtin_f_type (gdbarch); |
442 | ||
443 | lai->string_char_type = builtin->builtin_character; | |
cad351d1 UW |
444 | lai->primitive_type_vector |
445 | = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_f_primitive_types + 1, | |
446 | struct type *); | |
447 | ||
448 | lai->primitive_type_vector [f_primitive_type_character] | |
54ef06c7 | 449 | = builtin->builtin_character; |
cad351d1 | 450 | lai->primitive_type_vector [f_primitive_type_logical] |
54ef06c7 | 451 | = builtin->builtin_logical; |
cad351d1 | 452 | lai->primitive_type_vector [f_primitive_type_logical_s1] |
54ef06c7 | 453 | = builtin->builtin_logical_s1; |
cad351d1 | 454 | lai->primitive_type_vector [f_primitive_type_logical_s2] |
54ef06c7 | 455 | = builtin->builtin_logical_s2; |
cad351d1 | 456 | lai->primitive_type_vector [f_primitive_type_real] |
54ef06c7 | 457 | = builtin->builtin_real; |
cad351d1 | 458 | lai->primitive_type_vector [f_primitive_type_real_s8] |
54ef06c7 | 459 | = builtin->builtin_real_s8; |
cad351d1 | 460 | lai->primitive_type_vector [f_primitive_type_real_s16] |
54ef06c7 | 461 | = builtin->builtin_real_s16; |
cad351d1 | 462 | lai->primitive_type_vector [f_primitive_type_complex_s8] |
54ef06c7 | 463 | = builtin->builtin_complex_s8; |
cad351d1 | 464 | lai->primitive_type_vector [f_primitive_type_complex_s16] |
54ef06c7 | 465 | = builtin->builtin_complex_s16; |
cad351d1 | 466 | lai->primitive_type_vector [f_primitive_type_void] |
54ef06c7 | 467 | = builtin->builtin_void; |
cad351d1 UW |
468 | } |
469 | ||
c906108c SS |
470 | /* This is declared in c-lang.h but it is silly to import that file for what |
471 | is already just a hack. */ | |
d9fcf2fb JM |
472 | extern int c_value_print (struct value *, struct ui_file *, int, |
473 | enum val_prettyprint); | |
c906108c | 474 | |
c5aa993b JM |
475 | const struct language_defn f_language_defn = |
476 | { | |
c906108c SS |
477 | "fortran", |
478 | language_fortran, | |
cad351d1 | 479 | NULL, |
c906108c SS |
480 | range_check_on, |
481 | type_check_on, | |
63872f9d | 482 | case_sensitive_off, |
7ca2d3a3 | 483 | array_column_major, |
5f9769d1 | 484 | &exp_descriptor_standard, |
c906108c SS |
485 | f_parse, /* parser */ |
486 | f_error, /* parser error function */ | |
e85c3284 | 487 | null_post_parser, |
c906108c SS |
488 | f_printchar, /* Print character constant */ |
489 | f_printstr, /* function to print string constant */ | |
490 | f_emit_char, /* Function to print a single character */ | |
491 | f_create_fundamental_type, /* Create fundamental type in this language */ | |
c5aa993b | 492 | f_print_type, /* Print a type using appropriate syntax */ |
c906108c | 493 | f_val_print, /* Print a value using appropriate syntax */ |
c5aa993b | 494 | c_value_print, /* FIXME */ |
f636b87d | 495 | NULL, /* Language specific skip_trampoline */ |
5f9a71c3 DC |
496 | value_of_this, /* value_of_this */ |
497 | basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ | |
b368761e | 498 | basic_lookup_transparent_type,/* lookup_transparent_type */ |
9a3d7dfd | 499 | NULL, /* Language specific symbol demangler */ |
31c27f77 | 500 | NULL, /* Language specific class_name_from_physname */ |
c906108c SS |
501 | f_op_print_tab, /* expression operators for printing */ |
502 | 0, /* arrays are first-class (not c-style) */ | |
503 | 1, /* String lower bound */ | |
cad351d1 | 504 | NULL, |
6084f43a | 505 | default_word_break_characters, |
cad351d1 | 506 | f_language_arch_info, |
e79af960 | 507 | default_print_array_index, |
c906108c | 508 | LANG_MAGIC |
c5aa993b | 509 | }; |
c906108c | 510 | |
54ef06c7 UW |
511 | static void * |
512 | build_fortran_types (struct gdbarch *gdbarch) | |
c906108c | 513 | { |
54ef06c7 UW |
514 | struct builtin_f_type *builtin_f_type |
515 | = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_f_type); | |
516 | ||
517 | builtin_f_type->builtin_void = | |
c906108c SS |
518 | init_type (TYPE_CODE_VOID, 1, |
519 | 0, | |
520 | "VOID", (struct objfile *) NULL); | |
c5aa993b | 521 | |
54ef06c7 | 522 | builtin_f_type->builtin_character = |
c906108c SS |
523 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, |
524 | 0, | |
525 | "character", (struct objfile *) NULL); | |
c5aa993b | 526 | |
54ef06c7 | 527 | builtin_f_type->builtin_logical_s1 = |
c906108c SS |
528 | init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT, |
529 | TYPE_FLAG_UNSIGNED, | |
530 | "logical*1", (struct objfile *) NULL); | |
c5aa993b | 531 | |
54ef06c7 | 532 | builtin_f_type->builtin_integer_s2 = |
9a76efb6 UW |
533 | init_type (TYPE_CODE_INT, |
534 | gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
535 | 0, "integer*2", (struct objfile *) NULL); | |
c5aa993b | 536 | |
54ef06c7 | 537 | builtin_f_type->builtin_logical_s2 = |
9a76efb6 UW |
538 | init_type (TYPE_CODE_BOOL, |
539 | gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
540 | TYPE_FLAG_UNSIGNED, "logical*2", (struct objfile *) NULL); | |
c5aa993b | 541 | |
54ef06c7 | 542 | builtin_f_type->builtin_integer = |
9a76efb6 UW |
543 | init_type (TYPE_CODE_INT, |
544 | gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
545 | 0, "integer", (struct objfile *) NULL); | |
c5aa993b | 546 | |
54ef06c7 | 547 | builtin_f_type->builtin_logical = |
9a76efb6 UW |
548 | init_type (TYPE_CODE_BOOL, |
549 | gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
550 | TYPE_FLAG_UNSIGNED, "logical*4", (struct objfile *) NULL); | |
c5aa993b | 551 | |
54ef06c7 | 552 | builtin_f_type->builtin_real = |
ea06eb3d UW |
553 | init_type (TYPE_CODE_FLT, |
554 | gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
c906108c SS |
555 | 0, |
556 | "real", (struct objfile *) NULL); | |
c5aa993b | 557 | |
54ef06c7 | 558 | builtin_f_type->builtin_real_s8 = |
ea06eb3d UW |
559 | init_type (TYPE_CODE_FLT, |
560 | gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
c906108c SS |
561 | 0, |
562 | "real*8", (struct objfile *) NULL); | |
c5aa993b | 563 | |
54ef06c7 | 564 | builtin_f_type->builtin_real_s16 = |
ea06eb3d UW |
565 | init_type (TYPE_CODE_FLT, |
566 | gdbarch_long_double_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
c906108c SS |
567 | 0, |
568 | "real*16", (struct objfile *) NULL); | |
c5aa993b | 569 | |
54ef06c7 | 570 | builtin_f_type->builtin_complex_s8 = |
ea06eb3d UW |
571 | init_type (TYPE_CODE_COMPLEX, |
572 | 2 * gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
c906108c SS |
573 | 0, |
574 | "complex*8", (struct objfile *) NULL); | |
54ef06c7 UW |
575 | TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s8) |
576 | = builtin_f_type->builtin_real; | |
c5aa993b | 577 | |
54ef06c7 | 578 | builtin_f_type->builtin_complex_s16 = |
ea06eb3d UW |
579 | init_type (TYPE_CODE_COMPLEX, |
580 | 2 * gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
c906108c SS |
581 | 0, |
582 | "complex*16", (struct objfile *) NULL); | |
54ef06c7 UW |
583 | TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s16) |
584 | = builtin_f_type->builtin_real_s8; | |
c5aa993b | 585 | |
c906108c SS |
586 | /* We have a new size == 4 double floats for the |
587 | complex*32 data type */ | |
c5aa993b | 588 | |
54ef06c7 | 589 | builtin_f_type->builtin_complex_s32 = |
ea06eb3d UW |
590 | init_type (TYPE_CODE_COMPLEX, |
591 | 2 * gdbarch_long_double_bit (current_gdbarch) / TARGET_CHAR_BIT, | |
c906108c SS |
592 | 0, |
593 | "complex*32", (struct objfile *) NULL); | |
54ef06c7 UW |
594 | TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s32) |
595 | = builtin_f_type->builtin_real_s16; | |
596 | ||
597 | return builtin_f_type; | |
598 | } | |
599 | ||
600 | static struct gdbarch_data *f_type_data; | |
601 | ||
602 | const struct builtin_f_type * | |
603 | builtin_f_type (struct gdbarch *gdbarch) | |
604 | { | |
605 | return gdbarch_data (gdbarch, f_type_data); | |
4e845cd3 MS |
606 | } |
607 | ||
608 | void | |
609 | _initialize_f_language (void) | |
610 | { | |
54ef06c7 | 611 | f_type_data = gdbarch_data_register_post_init (build_fortran_types); |
c906108c | 612 | |
c906108c SS |
613 | add_language (&f_language_defn); |
614 | } | |
615 | ||
616 | #if 0 | |
617 | static SAVED_BF_PTR | |
fba45db2 | 618 | allocate_saved_bf_node (void) |
c906108c SS |
619 | { |
620 | SAVED_BF_PTR new; | |
c5aa993b | 621 | |
c906108c | 622 | new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF)); |
c5aa993b | 623 | return (new); |
c906108c SS |
624 | } |
625 | ||
626 | static SAVED_FUNCTION * | |
fba45db2 | 627 | allocate_saved_function_node (void) |
c906108c SS |
628 | { |
629 | SAVED_FUNCTION *new; | |
c5aa993b | 630 | |
c906108c | 631 | new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION)); |
c5aa993b | 632 | return (new); |
c906108c SS |
633 | } |
634 | ||
c5aa993b | 635 | static SAVED_F77_COMMON_PTR |
fba45db2 | 636 | allocate_saved_f77_common_node (void) |
c906108c SS |
637 | { |
638 | SAVED_F77_COMMON_PTR new; | |
c5aa993b | 639 | |
c906108c | 640 | new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON)); |
c5aa993b | 641 | return (new); |
c906108c SS |
642 | } |
643 | ||
c5aa993b | 644 | static COMMON_ENTRY_PTR |
fba45db2 | 645 | allocate_common_entry_node (void) |
c906108c SS |
646 | { |
647 | COMMON_ENTRY_PTR new; | |
c5aa993b | 648 | |
c906108c | 649 | new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY)); |
c5aa993b | 650 | return (new); |
c906108c SS |
651 | } |
652 | #endif | |
653 | ||
c5aa993b JM |
654 | SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */ |
655 | SAVED_F77_COMMON_PTR tail_common_list = NULL; /* Ptr to last saved COMMON */ | |
656 | SAVED_F77_COMMON_PTR current_common = NULL; /* Ptr to current COMMON */ | |
c906108c SS |
657 | |
658 | #if 0 | |
c5aa993b JM |
659 | static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function) |
660 | list */ | |
661 | static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */ | |
662 | static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of above list | |
663 | */ | |
c906108c | 664 | |
c5aa993b JM |
665 | static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use |
666 | in macros */ | |
c906108c SS |
667 | |
668 | /* The following function simply enters a given common block onto | |
669 | the global common block chain */ | |
670 | ||
671 | static void | |
fba45db2 | 672 | add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab) |
c906108c SS |
673 | { |
674 | SAVED_F77_COMMON_PTR tmp; | |
c5aa993b JM |
675 | char *c, *local_copy_func_stab; |
676 | ||
c906108c SS |
677 | /* If the COMMON block we are trying to add has a blank |
678 | name (i.e. "#BLNK_COM") then we set it to __BLANK | |
679 | because the darn "#" character makes GDB's input | |
c5aa993b JM |
680 | parser have fits. */ |
681 | ||
682 | ||
6314a349 AC |
683 | if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 |
684 | || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) | |
c906108c | 685 | { |
c5aa993b | 686 | |
b8c9b27d | 687 | xfree (name); |
c5aa993b JM |
688 | name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); |
689 | strcpy (name, BLANK_COMMON_NAME_LOCAL); | |
c906108c | 690 | } |
c5aa993b JM |
691 | |
692 | tmp = allocate_saved_f77_common_node (); | |
693 | ||
694 | local_copy_func_stab = xmalloc (strlen (func_stab) + 1); | |
695 | strcpy (local_copy_func_stab, func_stab); | |
696 | ||
697 | tmp->name = xmalloc (strlen (name) + 1); | |
698 | ||
c906108c | 699 | /* local_copy_func_stab is a stabstring, let us first extract the |
c5aa993b JM |
700 | function name from the stab by NULLing out the ':' character. */ |
701 | ||
702 | ||
703 | c = NULL; | |
704 | c = strchr (local_copy_func_stab, ':'); | |
705 | ||
c906108c SS |
706 | if (c) |
707 | *c = '\0'; | |
708 | else | |
8a3fe4f8 | 709 | error (_("Malformed function STAB found in add_common_block()")); |
c5aa993b JM |
710 | |
711 | ||
712 | tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1); | |
713 | ||
714 | strcpy (tmp->owning_function, local_copy_func_stab); | |
715 | ||
716 | strcpy (tmp->name, name); | |
717 | tmp->offset = offset; | |
c906108c SS |
718 | tmp->next = NULL; |
719 | tmp->entries = NULL; | |
c5aa993b JM |
720 | tmp->secnum = secnum; |
721 | ||
c906108c | 722 | current_common = tmp; |
c5aa993b | 723 | |
c906108c SS |
724 | if (head_common_list == NULL) |
725 | { | |
726 | head_common_list = tail_common_list = tmp; | |
727 | } | |
728 | else | |
729 | { | |
c5aa993b | 730 | tail_common_list->next = tmp; |
c906108c SS |
731 | tail_common_list = tmp; |
732 | } | |
733 | } | |
734 | #endif | |
735 | ||
736 | /* The following function simply enters a given common entry onto | |
c5aa993b | 737 | the "current_common" block that has been saved away. */ |
c906108c SS |
738 | |
739 | #if 0 | |
740 | static void | |
fba45db2 | 741 | add_common_entry (struct symbol *entry_sym_ptr) |
c906108c SS |
742 | { |
743 | COMMON_ENTRY_PTR tmp; | |
c5aa993b JM |
744 | |
745 | ||
746 | ||
c906108c SS |
747 | /* The order of this list is important, since |
748 | we expect the entries to appear in decl. | |
c5aa993b JM |
749 | order when we later issue "info common" calls */ |
750 | ||
751 | tmp = allocate_common_entry_node (); | |
752 | ||
c906108c SS |
753 | tmp->next = NULL; |
754 | tmp->symbol = entry_sym_ptr; | |
c5aa993b | 755 | |
c906108c | 756 | if (current_common == NULL) |
8a3fe4f8 | 757 | error (_("Attempt to add COMMON entry with no block open!")); |
c5aa993b | 758 | else |
c906108c SS |
759 | { |
760 | if (current_common->entries == NULL) | |
761 | { | |
762 | current_common->entries = tmp; | |
c5aa993b | 763 | current_common->end_of_entries = tmp; |
c906108c SS |
764 | } |
765 | else | |
766 | { | |
c5aa993b JM |
767 | current_common->end_of_entries->next = tmp; |
768 | current_common->end_of_entries = tmp; | |
c906108c SS |
769 | } |
770 | } | |
771 | } | |
772 | #endif | |
773 | ||
c5aa993b | 774 | /* This routine finds the first encountred COMMON block named "name" */ |
c906108c SS |
775 | |
776 | #if 0 | |
777 | static SAVED_F77_COMMON_PTR | |
fba45db2 | 778 | find_first_common_named (char *name) |
c906108c | 779 | { |
c5aa993b | 780 | |
c906108c | 781 | SAVED_F77_COMMON_PTR tmp; |
c5aa993b | 782 | |
c906108c | 783 | tmp = head_common_list; |
c5aa993b | 784 | |
c906108c SS |
785 | while (tmp != NULL) |
786 | { | |
6314a349 | 787 | if (strcmp (tmp->name, name) == 0) |
c5aa993b | 788 | return (tmp); |
c906108c SS |
789 | else |
790 | tmp = tmp->next; | |
791 | } | |
c5aa993b | 792 | return (NULL); |
c906108c SS |
793 | } |
794 | #endif | |
795 | ||
796 | /* This routine finds the first encountred COMMON block named "name" | |
c5aa993b | 797 | that belongs to function funcname */ |
c906108c | 798 | |
c5aa993b | 799 | SAVED_F77_COMMON_PTR |
fba45db2 | 800 | find_common_for_function (char *name, char *funcname) |
c906108c | 801 | { |
c5aa993b | 802 | |
c906108c | 803 | SAVED_F77_COMMON_PTR tmp; |
c5aa993b | 804 | |
c906108c | 805 | tmp = head_common_list; |
c5aa993b | 806 | |
c906108c SS |
807 | while (tmp != NULL) |
808 | { | |
cb137aa5 AC |
809 | if (DEPRECATED_STREQ (tmp->name, name) |
810 | && DEPRECATED_STREQ (tmp->owning_function, funcname)) | |
c5aa993b | 811 | return (tmp); |
c906108c SS |
812 | else |
813 | tmp = tmp->next; | |
814 | } | |
c5aa993b | 815 | return (NULL); |
c906108c SS |
816 | } |
817 | ||
818 | ||
819 | #if 0 | |
820 | ||
821 | /* The following function is called to patch up the offsets | |
822 | for the statics contained in the COMMON block named | |
c5aa993b | 823 | "name." */ |
c906108c SS |
824 | |
825 | static void | |
fba45db2 | 826 | patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum) |
c906108c SS |
827 | { |
828 | COMMON_ENTRY_PTR entry; | |
c5aa993b JM |
829 | |
830 | blk->offset = offset; /* Keep this around for future use. */ | |
831 | ||
c906108c | 832 | entry = blk->entries; |
c5aa993b | 833 | |
c906108c SS |
834 | while (entry != NULL) |
835 | { | |
c5aa993b | 836 | SYMBOL_VALUE (entry->symbol) += offset; |
c906108c | 837 | SYMBOL_SECTION (entry->symbol) = secnum; |
c5aa993b | 838 | |
c906108c SS |
839 | entry = entry->next; |
840 | } | |
c5aa993b | 841 | blk->secnum = secnum; |
c906108c SS |
842 | } |
843 | ||
844 | /* Patch all commons named "name" that need patching.Since COMMON | |
845 | blocks occur with relative infrequency, we simply do a linear scan on | |
846 | the name. Eventually, the best way to do this will be a | |
847 | hashed-lookup. Secnum is the section number for the .bss section | |
848 | (which is where common data lives). */ | |
849 | ||
850 | static void | |
fba45db2 | 851 | patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum) |
c906108c | 852 | { |
c5aa993b | 853 | |
c906108c | 854 | SAVED_F77_COMMON_PTR tmp; |
c5aa993b | 855 | |
c906108c SS |
856 | /* For blank common blocks, change the canonical reprsentation |
857 | of a blank name */ | |
c5aa993b | 858 | |
6314a349 AC |
859 | if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 |
860 | || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) | |
c906108c | 861 | { |
b8c9b27d | 862 | xfree (name); |
c5aa993b JM |
863 | name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); |
864 | strcpy (name, BLANK_COMMON_NAME_LOCAL); | |
c906108c | 865 | } |
c5aa993b | 866 | |
c906108c | 867 | tmp = head_common_list; |
c5aa993b | 868 | |
c906108c SS |
869 | while (tmp != NULL) |
870 | { | |
c5aa993b | 871 | if (COMMON_NEEDS_PATCHING (tmp)) |
6314a349 | 872 | if (strcmp (tmp->name, name) == 0) |
c5aa993b JM |
873 | patch_common_entries (tmp, offset, secnum); |
874 | ||
c906108c | 875 | tmp = tmp->next; |
c5aa993b | 876 | } |
c906108c SS |
877 | } |
878 | #endif | |
879 | ||
880 | /* This macro adds the symbol-number for the start of the function | |
881 | (the symbol number of the .bf) referenced by symnum_fcn to a | |
882 | list. This list, in reality should be a FIFO queue but since | |
883 | #line pragmas sometimes cause line ranges to get messed up | |
884 | we simply create a linear list. This list can then be searched | |
885 | first by a queueing algorithm and upon failure fall back to | |
c5aa993b | 886 | a linear scan. */ |
c906108c SS |
887 | |
888 | #if 0 | |
889 | #define ADD_BF_SYMNUM(bf_sym,fcn_sym) \ | |
890 | \ | |
891 | if (saved_bf_list == NULL) \ | |
892 | { \ | |
893 | tmp_bf_ptr = allocate_saved_bf_node(); \ | |
894 | \ | |
895 | tmp_bf_ptr->symnum_bf = (bf_sym); \ | |
896 | tmp_bf_ptr->symnum_fcn = (fcn_sym); \ | |
897 | tmp_bf_ptr->next = NULL; \ | |
898 | \ | |
899 | current_head_bf_list = saved_bf_list = tmp_bf_ptr; \ | |
900 | saved_bf_list_end = tmp_bf_ptr; \ | |
901 | } \ | |
902 | else \ | |
903 | { \ | |
904 | tmp_bf_ptr = allocate_saved_bf_node(); \ | |
905 | \ | |
906 | tmp_bf_ptr->symnum_bf = (bf_sym); \ | |
907 | tmp_bf_ptr->symnum_fcn = (fcn_sym); \ | |
908 | tmp_bf_ptr->next = NULL; \ | |
909 | \ | |
910 | saved_bf_list_end->next = tmp_bf_ptr; \ | |
911 | saved_bf_list_end = tmp_bf_ptr; \ | |
c5aa993b | 912 | } |
c906108c SS |
913 | #endif |
914 | ||
c5aa993b | 915 | /* This function frees the entire (.bf,function) list */ |
c906108c SS |
916 | |
917 | #if 0 | |
c5aa993b | 918 | static void |
fba45db2 | 919 | clear_bf_list (void) |
c906108c | 920 | { |
c5aa993b | 921 | |
c906108c | 922 | SAVED_BF_PTR tmp = saved_bf_list; |
c5aa993b JM |
923 | SAVED_BF_PTR next = NULL; |
924 | ||
c906108c SS |
925 | while (tmp != NULL) |
926 | { | |
927 | next = tmp->next; | |
b8c9b27d | 928 | xfree (tmp); |
c5aa993b | 929 | tmp = next; |
c906108c SS |
930 | } |
931 | saved_bf_list = NULL; | |
932 | } | |
933 | #endif | |
934 | ||
935 | int global_remote_debug; | |
936 | ||
937 | #if 0 | |
938 | ||
939 | static long | |
fba45db2 | 940 | get_bf_for_fcn (long the_function) |
c906108c SS |
941 | { |
942 | SAVED_BF_PTR tmp; | |
943 | int nprobes = 0; | |
c5aa993b | 944 | |
c906108c SS |
945 | /* First use a simple queuing algorithm (i.e. look and see if the |
946 | item at the head of the queue is the one you want) */ | |
c5aa993b | 947 | |
c906108c | 948 | if (saved_bf_list == NULL) |
8e65ff28 | 949 | internal_error (__FILE__, __LINE__, |
e2e0b3e5 | 950 | _("cannot get .bf node off empty list")); |
c5aa993b JM |
951 | |
952 | if (current_head_bf_list != NULL) | |
c906108c SS |
953 | if (current_head_bf_list->symnum_fcn == the_function) |
954 | { | |
c5aa993b | 955 | if (global_remote_debug) |
dac8068e | 956 | fprintf_unfiltered (gdb_stderr, "*"); |
c906108c | 957 | |
c5aa993b | 958 | tmp = current_head_bf_list; |
c906108c | 959 | current_head_bf_list = current_head_bf_list->next; |
c5aa993b | 960 | return (tmp->symnum_bf); |
c906108c | 961 | } |
c5aa993b | 962 | |
c906108c SS |
963 | /* If the above did not work (probably because #line directives were |
964 | used in the sourcefile and they messed up our internal tables) we now do | |
965 | the ugly linear scan */ | |
c5aa993b JM |
966 | |
967 | if (global_remote_debug) | |
dac8068e | 968 | fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n"); |
c5aa993b JM |
969 | |
970 | nprobes = 0; | |
c906108c SS |
971 | tmp = saved_bf_list; |
972 | while (tmp != NULL) | |
973 | { | |
c5aa993b | 974 | nprobes++; |
c906108c | 975 | if (tmp->symnum_fcn == the_function) |
c5aa993b | 976 | { |
c906108c | 977 | if (global_remote_debug) |
dac8068e | 978 | fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes); |
c906108c | 979 | current_head_bf_list = tmp->next; |
c5aa993b JM |
980 | return (tmp->symnum_bf); |
981 | } | |
982 | tmp = tmp->next; | |
c906108c | 983 | } |
c5aa993b JM |
984 | |
985 | return (-1); | |
c906108c SS |
986 | } |
987 | ||
c5aa993b JM |
988 | static SAVED_FUNCTION_PTR saved_function_list = NULL; |
989 | static SAVED_FUNCTION_PTR saved_function_list_end = NULL; | |
c906108c SS |
990 | |
991 | static void | |
fba45db2 | 992 | clear_function_list (void) |
c906108c SS |
993 | { |
994 | SAVED_FUNCTION_PTR tmp = saved_function_list; | |
c5aa993b JM |
995 | SAVED_FUNCTION_PTR next = NULL; |
996 | ||
c906108c SS |
997 | while (tmp != NULL) |
998 | { | |
999 | next = tmp->next; | |
b8c9b27d | 1000 | xfree (tmp); |
c906108c SS |
1001 | tmp = next; |
1002 | } | |
c5aa993b | 1003 | |
c906108c SS |
1004 | saved_function_list = NULL; |
1005 | } | |
1006 | #endif |