1 /* Fortran language support routines for GDB, the GNU debugger.
2 Copyright 1993, 1994 Free Software Foundation, Inc.
3 Contributed by Motorola. Adapted from the C parser by Farooq Butt
4 (fmbutt@engage.sps.mot.com).
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26 #include "expression.h"
27 #include "parser-defs.h"
31 /* The built-in types of F77. FIXME: integer*4 is missing, plain
32 logical is missing (builtin_type_logical is logical*4). */
34 struct type
*builtin_type_f_character
;
35 struct type
*builtin_type_f_logical
;
36 struct type
*builtin_type_f_logical_s1
;
37 struct type
*builtin_type_f_logical_s2
;
38 struct type
*builtin_type_f_integer
;
39 struct type
*builtin_type_f_integer_s2
;
40 struct type
*builtin_type_f_real
;
41 struct type
*builtin_type_f_real_s8
;
42 struct type
*builtin_type_f_real_s16
;
43 struct type
*builtin_type_f_complex_s8
;
44 struct type
*builtin_type_f_complex_s16
;
45 struct type
*builtin_type_f_complex_s32
;
46 struct type
*builtin_type_f_void
;
48 /* Print the character C on STREAM as part of the contents of a literal
49 string whose delimiter is QUOTER. Note that that format for printing
50 characters and strings is language specific.
51 FIXME: This is a copy of the same function from c-exp.y. It should
52 be replaced with a true F77 version. */
55 emit_char (c
, stream
, quoter
)
60 c
&= 0xFF; /* Avoid sign bit follies */
62 if (PRINT_LITERAL_FORM (c
))
64 if (c
== '\\' || c
== quoter
)
65 fputs_filtered ("\\", stream
);
66 fprintf_filtered (stream
, "%c", c
);
73 fputs_filtered ("\\n", stream
);
76 fputs_filtered ("\\b", stream
);
79 fputs_filtered ("\\t", stream
);
82 fputs_filtered ("\\f", stream
);
85 fputs_filtered ("\\r", stream
);
88 fputs_filtered ("\\e", stream
);
91 fputs_filtered ("\\a", stream
);
94 fprintf_filtered (stream
, "\\%.3o", (unsigned int) c
);
100 /* FIXME: This is a copy of the same function from c-exp.y. It should
101 be replaced with a true F77version. */
104 f_printchar (c
, stream
)
108 fputs_filtered ("'", stream
);
109 emit_char (c
, stream
, '\'');
110 fputs_filtered ("'", stream
);
113 /* Print the character string STRING, printing at most LENGTH characters.
114 Printing stops early if the number hits print_max; repeat counts
115 are printed as appropriate. Print ellipses at the end if we
116 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
117 FIXME: This is a copy of the same function from c-exp.y. It should
118 be replaced with a true F77 version. */
121 f_printstr (stream
, string
, length
, force_ellipses
)
127 register unsigned int i
;
128 unsigned int things_printed
= 0;
131 extern int inspect_it
;
132 extern int repeat_count_threshold
;
133 extern int print_max
;
137 fputs_filtered ("''", stdout
);
141 for (i
= 0; i
< length
&& things_printed
< print_max
; ++i
)
143 /* Position of the character we are examining
144 to see whether it is repeated. */
146 /* Number of repetitions we have detected so far. */
153 fputs_filtered (", ", stream
);
159 while (rep1
< length
&& string
[rep1
] == string
[i
])
165 if (reps
> repeat_count_threshold
)
170 fputs_filtered ("\\', ", stream
);
172 fputs_filtered ("', ", stream
);
175 f_printchar (string
[i
], stream
);
176 fprintf_filtered (stream
, " <repeats %u times>", reps
);
178 things_printed
+= repeat_count_threshold
;
186 fputs_filtered ("\\'", stream
);
188 fputs_filtered ("'", stream
);
191 emit_char (string
[i
], stream
, '"');
196 /* Terminate the quotes if necessary. */
200 fputs_filtered ("\\'", stream
);
202 fputs_filtered ("'", stream
);
205 if (force_ellipses
|| i
< length
)
206 fputs_filtered ("...", stream
);
209 /* FIXME: This is a copy of c_create_fundamental_type(), before
210 all the non-C types were stripped from it. Needs to be fixed
211 by an experienced F77 programmer. */
214 f_create_fundamental_type (objfile
, typeid)
215 struct objfile
*objfile
;
218 register struct type
*type
= NULL
;
223 type
= init_type (TYPE_CODE_VOID
,
224 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
228 type
= init_type (TYPE_CODE_BOOL
,
229 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
230 TYPE_FLAG_UNSIGNED
, "boolean", objfile
);
233 type
= init_type (TYPE_CODE_STRING
,
234 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
235 0, "string", objfile
);
238 type
= init_type (TYPE_CODE_INT
,
239 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
240 0, "character", objfile
);
243 type
= init_type (TYPE_CODE_INT
,
244 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
245 0, "integer*1", objfile
);
247 case FT_UNSIGNED_CHAR
:
248 type
= init_type (TYPE_CODE_BOOL
,
249 TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
250 TYPE_FLAG_UNSIGNED
, "logical*1", objfile
);
253 type
= init_type (TYPE_CODE_INT
,
254 TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
255 0, "integer*2", objfile
);
257 case FT_SIGNED_SHORT
:
258 type
= init_type (TYPE_CODE_INT
,
259 TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
260 0, "short", objfile
); /* FIXME-fnf */
262 case FT_UNSIGNED_SHORT
:
263 type
= init_type (TYPE_CODE_BOOL
,
264 TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
265 TYPE_FLAG_UNSIGNED
, "logical*2", objfile
);
268 type
= init_type (TYPE_CODE_INT
,
269 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
270 0, "integer*4", objfile
);
272 case FT_SIGNED_INTEGER
:
273 type
= init_type (TYPE_CODE_INT
,
274 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
275 0, "integer", objfile
); /* FIXME -fnf */
277 case FT_UNSIGNED_INTEGER
:
278 type
= init_type (TYPE_CODE_BOOL
,
279 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
280 TYPE_FLAG_UNSIGNED
, "logical*4", objfile
);
282 case FT_FIXED_DECIMAL
:
283 type
= init_type (TYPE_CODE_INT
,
284 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
285 0, "fixed decimal", objfile
);
288 type
= init_type (TYPE_CODE_INT
,
289 TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
293 type
= init_type (TYPE_CODE_INT
,
294 TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
295 0, "long", objfile
); /* FIXME -fnf */
297 case FT_UNSIGNED_LONG
:
298 type
= init_type (TYPE_CODE_INT
,
299 TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
300 TYPE_FLAG_UNSIGNED
, "unsigned long", objfile
);
303 type
= init_type (TYPE_CODE_INT
,
304 TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
305 0, "long long", objfile
);
307 case FT_SIGNED_LONG_LONG
:
308 type
= init_type (TYPE_CODE_INT
,
309 TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
310 0, "signed long long", objfile
);
312 case FT_UNSIGNED_LONG_LONG
:
313 type
= init_type (TYPE_CODE_INT
,
314 TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
315 TYPE_FLAG_UNSIGNED
, "unsigned long long", objfile
);
318 type
= init_type (TYPE_CODE_FLT
,
319 TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
322 case FT_DBL_PREC_FLOAT
:
323 type
= init_type (TYPE_CODE_FLT
,
324 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
325 0, "real*8", objfile
);
327 case FT_FLOAT_DECIMAL
:
328 type
= init_type (TYPE_CODE_FLT
,
329 TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
330 0, "floating decimal", objfile
);
332 case FT_EXT_PREC_FLOAT
:
333 type
= init_type (TYPE_CODE_FLT
,
334 TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
335 0, "real*16", objfile
);
338 type
= init_type (TYPE_CODE_COMPLEX
,
339 2 * TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
340 0, "complex*8", objfile
);
341 TYPE_TARGET_TYPE (type
) = builtin_type_f_real
;
343 case FT_DBL_PREC_COMPLEX
:
344 type
= init_type (TYPE_CODE_COMPLEX
,
345 2 * TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
346 0, "complex*16", objfile
);
347 TYPE_TARGET_TYPE (type
) = builtin_type_f_real_s8
;
349 case FT_EXT_PREC_COMPLEX
:
350 type
= init_type (TYPE_CODE_COMPLEX
,
351 2 * TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
352 0, "complex*32", objfile
);
353 TYPE_TARGET_TYPE (type
) = builtin_type_f_real_s16
;
356 /* FIXME: For now, if we are asked to produce a type not in this
357 language, create the equivalent of a C integer type with the
358 name "<?type?>". When all the dust settles from the type
359 reconstruction work, this should probably become an error. */
360 type
= init_type (TYPE_CODE_INT
,
361 TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
362 0, "<?type?>", objfile
);
363 warning ("internal error: no F77 fundamental type %d", typeid);
370 /* Table of operators and their precedences for printing expressions. */
372 static const struct op_print f_op_print_tab
[] = {
373 { "+", BINOP_ADD
, PREC_ADD
, 0 },
374 { "+", UNOP_PLUS
, PREC_PREFIX
, 0 },
375 { "-", BINOP_SUB
, PREC_ADD
, 0 },
376 { "-", UNOP_NEG
, PREC_PREFIX
, 0 },
377 { "*", BINOP_MUL
, PREC_MUL
, 0 },
378 { "/", BINOP_DIV
, PREC_MUL
, 0 },
379 { "DIV", BINOP_INTDIV
, PREC_MUL
, 0 },
380 { "MOD", BINOP_REM
, PREC_MUL
, 0 },
381 { "=", BINOP_ASSIGN
, PREC_ASSIGN
, 1 },
382 { ".OR.", BINOP_LOGICAL_OR
, PREC_LOGICAL_OR
, 0 },
383 { ".AND.", BINOP_LOGICAL_AND
, PREC_LOGICAL_AND
, 0 },
384 { ".NOT.", UNOP_LOGICAL_NOT
, PREC_PREFIX
, 0 },
385 { ".EQ.", BINOP_EQUAL
, PREC_EQUAL
, 0 },
386 { ".NE.", BINOP_NOTEQUAL
, PREC_EQUAL
, 0 },
387 { ".LE.", BINOP_LEQ
, PREC_ORDER
, 0 },
388 { ".GE.", BINOP_GEQ
, PREC_ORDER
, 0 },
389 { ".GT.", BINOP_GTR
, PREC_ORDER
, 0 },
390 { ".LT.", BINOP_LESS
, PREC_ORDER
, 0 },
391 { "**", UNOP_IND
, PREC_PREFIX
, 0 },
392 { "@", BINOP_REPEAT
, PREC_REPEAT
, 0 },
396 struct type
** const (f_builtin_types
[]) =
398 &builtin_type_f_character
,
399 &builtin_type_f_logical
,
400 &builtin_type_f_logical_s1
,
401 &builtin_type_f_logical_s2
,
402 &builtin_type_f_integer
,
403 &builtin_type_f_integer_s2
,
404 &builtin_type_f_real
,
405 &builtin_type_f_real_s8
,
406 &builtin_type_f_real_s16
,
407 &builtin_type_f_complex_s8
,
408 &builtin_type_f_complex_s16
,
410 &builtin_type_f_complex_s32
,
412 &builtin_type_f_void
,
418 const struct language_defn f_language_defn
= {
424 f_parse
, /* parser */
425 f_error
, /* parser error function */
426 f_printchar
, /* Print character constant */
427 f_printstr
, /* function to print string constant */
428 f_create_fundamental_type
, /* Create fundamental type in this language */
429 f_print_type
, /* Print a type using appropriate syntax */
430 f_val_print
, /* Print a value using appropriate syntax */
431 c_value_print
, /* FIXME */
432 {"", "", "", ""}, /* Binary format info */
433 {"0%o", "0", "o", ""}, /* Octal format info */
434 {"%d", "", "d", ""}, /* Decimal format info */
435 {"0x%x", "0x", "x", ""}, /* Hex format info */
436 f_op_print_tab
, /* expression operators for printing */
437 0, /* arrays are first-class (not c-style) */
438 1, /* String lower bound */
439 &builtin_type_f_character
, /* Type of string elements */
444 _initialize_f_language ()
446 builtin_type_f_void
=
447 init_type (TYPE_CODE_VOID
, 1,
449 "VOID", (struct objfile
*) NULL
);
451 builtin_type_f_character
=
452 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
454 "character", (struct objfile
*) NULL
);
456 builtin_type_f_logical_s1
=
457 init_type (TYPE_CODE_BOOL
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
459 "logical*1", (struct objfile
*) NULL
);
461 builtin_type_f_integer_s2
=
462 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
464 "integer*2", (struct objfile
*) NULL
);
466 builtin_type_f_logical_s2
=
467 init_type (TYPE_CODE_BOOL
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
469 "logical*2", (struct objfile
*) NULL
);
471 builtin_type_f_integer
=
472 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
474 "integer", (struct objfile
*) NULL
);
476 builtin_type_f_logical
=
477 init_type (TYPE_CODE_BOOL
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
479 "logical*4", (struct objfile
*) NULL
);
481 builtin_type_f_real
=
482 init_type (TYPE_CODE_FLT
, TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
484 "real", (struct objfile
*) NULL
);
486 builtin_type_f_real_s8
=
487 init_type (TYPE_CODE_FLT
, TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
489 "real*8", (struct objfile
*) NULL
);
491 builtin_type_f_real_s16
=
492 init_type (TYPE_CODE_FLT
, TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
494 "real*16", (struct objfile
*) NULL
);
496 builtin_type_f_complex_s8
=
497 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
499 "complex*8", (struct objfile
*) NULL
);
500 TYPE_TARGET_TYPE (builtin_type_f_complex_s8
) = builtin_type_f_real
;
502 builtin_type_f_complex_s16
=
503 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
505 "complex*16", (struct objfile
*) NULL
);
506 TYPE_TARGET_TYPE (builtin_type_f_complex_s16
) = builtin_type_f_real_s8
;
508 /* We have a new size == 4 double floats for the
509 complex*32 data type */
511 builtin_type_f_complex_s32
=
512 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
514 "complex*32", (struct objfile
*) NULL
);
515 TYPE_TARGET_TYPE (builtin_type_f_complex_s32
) = builtin_type_f_real_s16
;
517 builtin_type_string
=
518 init_type (TYPE_CODE_STRING
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
520 "character string", (struct objfile
*) NULL
);
522 add_language (&f_language_defn
);
525 /* Following is dubious stuff that had been in the xcoff reader. */
529 long line_offset
; /* Line offset for function */
530 struct saved_fcn
*next
;
534 struct saved_bf_symnum
536 long symnum_fcn
; /* Symnum of function (i.e. .function directive) */
537 long symnum_bf
; /* Symnum of .bf for this function */
538 struct saved_bf_symnum
*next
;
541 typedef struct saved_fcn SAVED_FUNCTION
, *SAVED_FUNCTION_PTR
;
542 typedef struct saved_bf_symnum SAVED_BF
, *SAVED_BF_PTR
;
545 SAVED_BF_PTR
allocate_saved_bf_node()
549 new = (SAVED_BF_PTR
) malloc (sizeof (SAVED_BF
));
552 fatal("could not allocate enough memory to save one more .bf on save list");
556 SAVED_FUNCTION
*allocate_saved_function_node()
560 new = (SAVED_FUNCTION
*) malloc (sizeof (SAVED_FUNCTION
));
563 fatal("could not allocate enough memory to save one more function on save list");
568 SAVED_F77_COMMON_PTR
allocate_saved_f77_common_node()
570 SAVED_F77_COMMON_PTR
new;
572 new = (SAVED_F77_COMMON_PTR
) malloc (sizeof (SAVED_F77_COMMON
));
575 fatal("could not allocate enough memory to save one more F77 COMMON blk on save list");
580 COMMON_ENTRY_PTR
allocate_common_entry_node()
582 COMMON_ENTRY_PTR
new;
584 new = (COMMON_ENTRY_PTR
) malloc (sizeof (COMMON_ENTRY
));
587 fatal("could not allocate enough memory to save one more COMMON entry on save list");
593 SAVED_F77_COMMON_PTR head_common_list
=NULL
; /* Ptr to 1st saved COMMON */
594 SAVED_F77_COMMON_PTR tail_common_list
=NULL
; /* Ptr to last saved COMMON */
595 SAVED_F77_COMMON_PTR current_common
=NULL
; /* Ptr to current COMMON */
597 static SAVED_BF_PTR saved_bf_list
=NULL
; /* Ptr to (.bf,function)
599 static SAVED_BF_PTR saved_bf_list_end
=NULL
; /* Ptr to above list's end */
600 static SAVED_BF_PTR current_head_bf_list
=NULL
; /* Current head of above list
603 static SAVED_BF_PTR tmp_bf_ptr
; /* Generic temporary for use
607 /* The following function simply enters a given common block onto
608 the global common block chain */
610 void add_common_block(name
,offset
,secnum
,func_stab
)
617 SAVED_F77_COMMON_PTR tmp
;
618 char *c
,*local_copy_func_stab
;
620 /* If the COMMON block we are trying to add has a blank
621 name (i.e. "#BLNK_COM") then we set it to __BLANK
622 because the darn "#" character makes GDB's input
626 if (STREQ(name
,BLANK_COMMON_NAME_ORIGINAL
) ||
627 STREQ(name
,BLANK_COMMON_NAME_MF77
))
631 name
= alloca(strlen(BLANK_COMMON_NAME_LOCAL
) + 1);
632 strcpy(name
,BLANK_COMMON_NAME_LOCAL
);
635 tmp
= allocate_saved_f77_common_node();
637 local_copy_func_stab
= malloc (strlen(func_stab
) + 1);
638 strcpy(local_copy_func_stab
,func_stab
);
640 tmp
->name
= malloc(strlen(name
) + 1);
642 /* local_copy_func_stab is a stabstring, let us first extract the
643 function name from the stab by NULLing out the ':' character. */
647 c
= strchr(local_copy_func_stab
,':');
652 error("Malformed function STAB found in add_common_block()");
655 tmp
->owning_function
= malloc (strlen(local_copy_func_stab
) + 1);
657 strcpy(tmp
->owning_function
,local_copy_func_stab
);
659 strcpy(tmp
->name
,name
);
660 tmp
->offset
= offset
;
663 tmp
->secnum
= secnum
;
665 current_common
= tmp
;
667 if (head_common_list
== NULL
)
669 head_common_list
= tail_common_list
= tmp
;
673 tail_common_list
->next
= tmp
;
674 tail_common_list
= tmp
;
680 /* The following function simply enters a given common entry onto
681 the "current_common" block that has been saved away. */
683 void add_common_entry(entry_sym_ptr
)
684 struct symbol
*entry_sym_ptr
;
686 COMMON_ENTRY_PTR tmp
;
690 /* The order of this list is important, since
691 we expect the entries to appear in decl.
692 order when we later issue "info common" calls */
694 tmp
= allocate_common_entry_node();
697 tmp
->symbol
= entry_sym_ptr
;
699 if (current_common
== NULL
)
700 error("Attempt to add COMMON entry with no block open!");
703 if (current_common
->entries
== NULL
)
705 current_common
->entries
= tmp
;
706 current_common
->end_of_entries
= tmp
;
710 current_common
->end_of_entries
->next
= tmp
;
711 current_common
->end_of_entries
= tmp
;
718 /* This routine finds the first encountred COMMON block named "name" */
720 SAVED_F77_COMMON_PTR
find_first_common_named(name
)
724 SAVED_F77_COMMON_PTR tmp
;
726 tmp
= head_common_list
;
730 if (STREQ(tmp
->name
,name
))
738 /* This routine finds the first encountred COMMON block named "name"
739 that belongs to function funcname */
741 SAVED_F77_COMMON_PTR
find_common_for_function(name
, funcname
)
746 SAVED_F77_COMMON_PTR tmp
;
748 tmp
= head_common_list
;
752 if (STREQ(tmp
->name
,name
) && STREQ(tmp
->owning_function
,funcname
))
763 /* The following function is called to patch up the offsets
764 for the statics contained in the COMMON block named
768 void patch_common_entries (blk
, offset
, secnum
)
769 SAVED_F77_COMMON_PTR blk
;
773 COMMON_ENTRY_PTR entry
;
775 blk
->offset
= offset
; /* Keep this around for future use. */
777 entry
= blk
->entries
;
779 while (entry
!= NULL
)
781 SYMBOL_VALUE (entry
->symbol
) += offset
;
782 SYMBOL_SECTION (entry
->symbol
) = secnum
;
786 blk
->secnum
= secnum
;
790 /* Patch all commons named "name" that need patching.Since COMMON
791 blocks occur with relative infrequency, we simply do a linear scan on
792 the name. Eventually, the best way to do this will be a
793 hashed-lookup. Secnum is the section number for the .bss section
794 (which is where common data lives). */
797 void patch_all_commons_by_name (name
, offset
, secnum
)
803 SAVED_F77_COMMON_PTR tmp
;
805 /* For blank common blocks, change the canonical reprsentation
808 if ((STREQ(name
,BLANK_COMMON_NAME_ORIGINAL
)) ||
809 (STREQ(name
,BLANK_COMMON_NAME_MF77
)))
812 name
= alloca(strlen(BLANK_COMMON_NAME_LOCAL
) + 1);
813 strcpy(name
,BLANK_COMMON_NAME_LOCAL
);
816 tmp
= head_common_list
;
820 if (COMMON_NEEDS_PATCHING(tmp
))
821 if (STREQ(tmp
->name
,name
))
822 patch_common_entries(tmp
,offset
,secnum
);
833 /* This macro adds the symbol-number for the start of the function
834 (the symbol number of the .bf) referenced by symnum_fcn to a
835 list. This list, in reality should be a FIFO queue but since
836 #line pragmas sometimes cause line ranges to get messed up
837 we simply create a linear list. This list can then be searched
838 first by a queueing algorithm and upon failure fall back to
841 #define ADD_BF_SYMNUM(bf_sym,fcn_sym) \
843 if (saved_bf_list == NULL) \
845 tmp_bf_ptr = allocate_saved_bf_node(); \
847 tmp_bf_ptr->symnum_bf = (bf_sym); \
848 tmp_bf_ptr->symnum_fcn = (fcn_sym); \
849 tmp_bf_ptr->next = NULL; \
851 current_head_bf_list = saved_bf_list = tmp_bf_ptr; \
852 saved_bf_list_end = tmp_bf_ptr; \
856 tmp_bf_ptr = allocate_saved_bf_node(); \
858 tmp_bf_ptr->symnum_bf = (bf_sym); \
859 tmp_bf_ptr->symnum_fcn = (fcn_sym); \
860 tmp_bf_ptr->next = NULL; \
862 saved_bf_list_end->next = tmp_bf_ptr; \
863 saved_bf_list_end = tmp_bf_ptr; \
867 /* This function frees the entire (.bf,function) list */
873 SAVED_BF_PTR tmp
= saved_bf_list
;
874 SAVED_BF_PTR next
= NULL
;
882 saved_bf_list
= NULL
;
885 int global_remote_debug
;
888 get_bf_for_fcn (the_function
)
894 /* First use a simple queuing algorithm (i.e. look and see if the
895 item at the head of the queue is the one you want) */
897 if (saved_bf_list
== NULL
)
898 fatal ("cannot get .bf node off empty list");
900 if (current_head_bf_list
!= NULL
)
901 if (current_head_bf_list
->symnum_fcn
== the_function
)
903 if (global_remote_debug
)
906 tmp
= current_head_bf_list
;
907 current_head_bf_list
= current_head_bf_list
->next
;
908 return(tmp
->symnum_bf
);
911 /* If the above did not work (probably because #line directives were
912 used in the sourcefile and they messed up our internal tables) we now do
913 the ugly linear scan */
915 if (global_remote_debug
)
916 fprintf(stderr
,"\ndefaulting to linear scan\n");
923 if (tmp
->symnum_fcn
== the_function
)
925 if (global_remote_debug
)
926 fprintf(stderr
,"Found in %d probes\n",nprobes
);
927 current_head_bf_list
= tmp
->next
;
928 return(tmp
->symnum_bf
);
936 static SAVED_FUNCTION_PTR saved_function_list
=NULL
;
937 static SAVED_FUNCTION_PTR saved_function_list_end
=NULL
;
939 void clear_function_list()
941 SAVED_FUNCTION_PTR tmp
= saved_function_list
;
942 SAVED_FUNCTION_PTR next
= NULL
;
951 saved_function_list
= NULL
;