1 /* Fortran language support routines for GDB, the GNU debugger.
2 Copyright 1993, 1994, 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include "gdb_string.h"
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 /* Following is dubious stuff that had been in the xcoff reader. */
52 long line_offset; /* Line offset for function */
53 struct saved_fcn *next;
57 struct saved_bf_symnum
59 long symnum_fcn; /* Symnum of function (i.e. .function directive) */
60 long symnum_bf; /* Symnum of .bf for this function */
61 struct saved_bf_symnum *next;
64 typedef struct saved_fcn SAVED_FUNCTION, *SAVED_FUNCTION_PTR;
65 typedef struct saved_bf_symnum SAVED_BF, *SAVED_BF_PTR;
70 static void clear_function_list PARAMS ((void));
71 static long get_bf_for_fcn PARAMS ((long));
72 static void clear_bf_list PARAMS ((void));
73 static void patch_all_commons_by_name PARAMS ((char *, CORE_ADDR, int));
74 static SAVED_F77_COMMON_PTR find_first_common_named PARAMS ((char *));
75 static void add_common_entry PARAMS ((struct symbol *));
76 static void add_common_block PARAMS ((char *, CORE_ADDR, int, char *));
77 static SAVED_FUNCTION *allocate_saved_function_node PARAMS ((void));
78 static SAVED_BF_PTR allocate_saved_bf_node PARAMS ((void));
79 static COMMON_ENTRY_PTR allocate_common_entry_node PARAMS ((void));
80 static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node PARAMS ((void));
81 static void patch_common_entries PARAMS ((SAVED_F77_COMMON_PTR, CORE_ADDR, int));
84 static struct type *f_create_fundamental_type PARAMS ((struct objfile *, int));
85 static void f_printstr PARAMS ((GDB_FILE *stream, char *string, unsigned int length, int width, int force_ellipses));
86 static void f_printchar PARAMS ((int c, GDB_FILE *stream));
87 static void f_emit_char PARAMS ((int c, GDB_FILE *stream, int quoter));
89 /* Print the character C on STREAM as part of the contents of a literal
90 string whose delimiter is QUOTER. Note that that format for printing
91 characters and strings is language specific.
92 FIXME: This is a copy of the same function from c-exp.y. It should
93 be replaced with a true F77 version. */
96 f_emit_char (c, stream, quoter)
101 c &= 0xFF; /* Avoid sign bit follies */
103 if (PRINT_LITERAL_FORM (c))
105 if (c == '\\' || c == quoter)
106 fputs_filtered ("\\", stream);
107 fprintf_filtered (stream, "%c", c);
114 fputs_filtered ("\\n", stream);
117 fputs_filtered ("\\b", stream);
120 fputs_filtered ("\\t", stream);
123 fputs_filtered ("\\f", stream);
126 fputs_filtered ("\\r", stream);
129 fputs_filtered ("\\e", stream);
132 fputs_filtered ("\\a", stream);
135 fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
141 /* FIXME: This is a copy of the same function from c-exp.y. It should
142 be replaced with a true F77version. */
145 f_printchar (c, stream)
149 fputs_filtered ("'", stream);
150 LA_EMIT_CHAR (c, stream, '\'');
151 fputs_filtered ("'", stream);
154 /* Print the character string STRING, printing at most LENGTH characters.
155 Printing stops early if the number hits print_max; repeat counts
156 are printed as appropriate. Print ellipses at the end if we
157 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
158 FIXME: This is a copy of the same function from c-exp.y. It should
159 be replaced with a true F77 version. */
162 f_printstr (stream, string, length, width, force_ellipses)
169 register unsigned int i;
170 unsigned int things_printed = 0;
173 extern int inspect_it;
174 extern int repeat_count_threshold;
175 extern int print_max;
179 fputs_filtered ("''", stdout);
183 for (i = 0; i < length && things_printed < print_max; ++i)
185 /* Position of the character we are examining
186 to see whether it is repeated. */
188 /* Number of repetitions we have detected so far. */
195 fputs_filtered (", ", stream);
201 while (rep1 < length && string[rep1] == string[i])
207 if (reps > repeat_count_threshold)
212 fputs_filtered ("\\', ", stream);
214 fputs_filtered ("', ", stream);
217 f_printchar (string[i], stream);
218 fprintf_filtered (stream, " <repeats %u times>", reps);
220 things_printed += repeat_count_threshold;
228 fputs_filtered ("\\'", stream);
230 fputs_filtered ("'", stream);
233 LA_EMIT_CHAR (string[i], stream, '"');
238 /* Terminate the quotes if necessary. */
242 fputs_filtered ("\\'", stream);
244 fputs_filtered ("'", stream);
247 if (force_ellipses || i < length)
248 fputs_filtered ("...", stream);
251 /* FIXME: This is a copy of c_create_fundamental_type(), before
252 all the non-C types were stripped from it. Needs to be fixed
253 by an experienced F77 programmer. */
256 f_create_fundamental_type (objfile, typeid)
257 struct objfile *objfile;
260 register struct type *type = NULL;
265 type = init_type (TYPE_CODE_VOID,
266 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
270 type = init_type (TYPE_CODE_BOOL,
271 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
272 TYPE_FLAG_UNSIGNED, "boolean", objfile);
275 type = init_type (TYPE_CODE_STRING,
276 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
277 0, "string", objfile);
280 type = init_type (TYPE_CODE_INT,
281 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
282 0, "character", objfile);
285 type = init_type (TYPE_CODE_INT,
286 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
287 0, "integer*1", objfile);
289 case FT_UNSIGNED_CHAR:
290 type = init_type (TYPE_CODE_BOOL,
291 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
292 TYPE_FLAG_UNSIGNED, "logical*1", objfile);
295 type = init_type (TYPE_CODE_INT,
296 TARGET_SHORT_BIT / TARGET_CHAR_BIT,
297 0, "integer*2", objfile);
299 case FT_SIGNED_SHORT:
300 type = init_type (TYPE_CODE_INT,
301 TARGET_SHORT_BIT / TARGET_CHAR_BIT,
302 0, "short", objfile); /* FIXME-fnf */
304 case FT_UNSIGNED_SHORT:
305 type = init_type (TYPE_CODE_BOOL,
306 TARGET_SHORT_BIT / TARGET_CHAR_BIT,
307 TYPE_FLAG_UNSIGNED, "logical*2", objfile);
310 type = init_type (TYPE_CODE_INT,
311 TARGET_INT_BIT / TARGET_CHAR_BIT,
312 0, "integer*4", objfile);
314 case FT_SIGNED_INTEGER:
315 type = init_type (TYPE_CODE_INT,
316 TARGET_INT_BIT / TARGET_CHAR_BIT,
317 0, "integer", objfile); /* FIXME -fnf */
319 case FT_UNSIGNED_INTEGER:
320 type = init_type (TYPE_CODE_BOOL,
321 TARGET_INT_BIT / TARGET_CHAR_BIT,
322 TYPE_FLAG_UNSIGNED, "logical*4", objfile);
324 case FT_FIXED_DECIMAL:
325 type = init_type (TYPE_CODE_INT,
326 TARGET_INT_BIT / TARGET_CHAR_BIT,
327 0, "fixed decimal", objfile);
330 type = init_type (TYPE_CODE_INT,
331 TARGET_LONG_BIT / TARGET_CHAR_BIT,
335 type = init_type (TYPE_CODE_INT,
336 TARGET_LONG_BIT / TARGET_CHAR_BIT,
337 0, "long", objfile); /* FIXME -fnf */
339 case FT_UNSIGNED_LONG:
340 type = init_type (TYPE_CODE_INT,
341 TARGET_LONG_BIT / TARGET_CHAR_BIT,
342 TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
345 type = init_type (TYPE_CODE_INT,
346 TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
347 0, "long long", objfile);
349 case FT_SIGNED_LONG_LONG:
350 type = init_type (TYPE_CODE_INT,
351 TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
352 0, "signed long long", objfile);
354 case FT_UNSIGNED_LONG_LONG:
355 type = init_type (TYPE_CODE_INT,
356 TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
357 TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
360 type = init_type (TYPE_CODE_FLT,
361 TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
364 case FT_DBL_PREC_FLOAT:
365 type = init_type (TYPE_CODE_FLT,
366 TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
367 0, "real*8", objfile);
369 case FT_FLOAT_DECIMAL:
370 type = init_type (TYPE_CODE_FLT,
371 TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
372 0, "floating decimal", objfile);
374 case FT_EXT_PREC_FLOAT:
375 type = init_type (TYPE_CODE_FLT,
376 TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
377 0, "real*16", objfile);
380 type = init_type (TYPE_CODE_COMPLEX,
381 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
382 0, "complex*8", objfile);
383 TYPE_TARGET_TYPE (type) = builtin_type_f_real;
385 case FT_DBL_PREC_COMPLEX:
386 type = init_type (TYPE_CODE_COMPLEX,
387 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
388 0, "complex*16", objfile);
389 TYPE_TARGET_TYPE (type) = builtin_type_f_real_s8;
391 case FT_EXT_PREC_COMPLEX:
392 type = init_type (TYPE_CODE_COMPLEX,
393 2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
394 0, "complex*32", objfile);
395 TYPE_TARGET_TYPE (type) = builtin_type_f_real_s16;
398 /* FIXME: For now, if we are asked to produce a type not in this
399 language, create the equivalent of a C integer type with the
400 name "<?type?>". When all the dust settles from the type
401 reconstruction work, this should probably become an error. */
402 type = init_type (TYPE_CODE_INT,
403 TARGET_INT_BIT / TARGET_CHAR_BIT,
404 0, "<?type?>", objfile);
405 warning ("internal error: no F77 fundamental type %d", typeid);
412 /* Table of operators and their precedences for printing expressions. */
414 static const struct op_print f_op_print_tab[] = {
415 { "+", BINOP_ADD, PREC_ADD, 0 },
416 { "+", UNOP_PLUS, PREC_PREFIX, 0 },
417 { "-", BINOP_SUB, PREC_ADD, 0 },
418 { "-", UNOP_NEG, PREC_PREFIX, 0 },
419 { "*", BINOP_MUL, PREC_MUL, 0 },
420 { "/", BINOP_DIV, PREC_MUL, 0 },
421 { "DIV", BINOP_INTDIV, PREC_MUL, 0 },
422 { "MOD", BINOP_REM, PREC_MUL, 0 },
423 { "=", BINOP_ASSIGN, PREC_ASSIGN, 1 },
424 { ".OR.", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0 },
425 { ".AND.", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0 },
426 { ".NOT.", UNOP_LOGICAL_NOT, PREC_PREFIX, 0 },
427 { ".EQ.", BINOP_EQUAL, PREC_EQUAL, 0 },
428 { ".NE.", BINOP_NOTEQUAL, PREC_EQUAL, 0 },
429 { ".LE.", BINOP_LEQ, PREC_ORDER, 0 },
430 { ".GE.", BINOP_GEQ, PREC_ORDER, 0 },
431 { ".GT.", BINOP_GTR, PREC_ORDER, 0 },
432 { ".LT.", BINOP_LESS, PREC_ORDER, 0 },
433 { "**", UNOP_IND, PREC_PREFIX, 0 },
434 { "@", BINOP_REPEAT, PREC_REPEAT, 0 },
438 struct type ** CONST_PTR (f_builtin_types[]) =
440 &builtin_type_f_character,
441 &builtin_type_f_logical,
442 &builtin_type_f_logical_s1,
443 &builtin_type_f_logical_s2,
444 &builtin_type_f_integer,
445 &builtin_type_f_integer_s2,
446 &builtin_type_f_real,
447 &builtin_type_f_real_s8,
448 &builtin_type_f_real_s16,
449 &builtin_type_f_complex_s8,
450 &builtin_type_f_complex_s16,
452 &builtin_type_f_complex_s32,
454 &builtin_type_f_void,
458 /* This is declared in c-lang.h but it is silly to import that file for what
459 is already just a hack. */
461 c_value_print PARAMS ((struct value *, GDB_FILE *, int, enum val_prettyprint));
463 const struct language_defn f_language_defn = {
469 f_parse, /* parser */
470 f_error, /* parser error function */
471 evaluate_subexp_standard,
472 f_printchar, /* Print character constant */
473 f_printstr, /* function to print string constant */
474 f_emit_char, /* Function to print a single character */
475 f_create_fundamental_type, /* Create fundamental type in this language */
476 f_print_type, /* Print a type using appropriate syntax */
477 f_val_print, /* Print a value using appropriate syntax */
478 c_value_print, /* FIXME */
479 {"", "", "", ""}, /* Binary format info */
480 {"0%o", "0", "o", ""}, /* Octal format info */
481 {"%d", "", "d", ""}, /* Decimal format info */
482 {"0x%x", "0x", "x", ""}, /* Hex format info */
483 f_op_print_tab, /* expression operators for printing */
484 0, /* arrays are first-class (not c-style) */
485 1, /* String lower bound */
486 &builtin_type_f_character, /* Type of string elements */
491 _initialize_f_language ()
493 builtin_type_f_void =
494 init_type (TYPE_CODE_VOID, 1,
496 "VOID", (struct objfile *) NULL);
498 builtin_type_f_character =
499 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
501 "character", (struct objfile *) NULL);
503 builtin_type_f_logical_s1 =
504 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
506 "logical*1", (struct objfile *) NULL);
508 builtin_type_f_integer_s2 =
509 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
511 "integer*2", (struct objfile *) NULL);
513 builtin_type_f_logical_s2 =
514 init_type (TYPE_CODE_BOOL, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
516 "logical*2", (struct objfile *) NULL);
518 builtin_type_f_integer =
519 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
521 "integer", (struct objfile *) NULL);
523 builtin_type_f_logical =
524 init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT,
526 "logical*4", (struct objfile *) NULL);
528 builtin_type_f_real =
529 init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
531 "real", (struct objfile *) NULL);
533 builtin_type_f_real_s8 =
534 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
536 "real*8", (struct objfile *) NULL);
538 builtin_type_f_real_s16 =
539 init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
541 "real*16", (struct objfile *) NULL);
543 builtin_type_f_complex_s8 =
544 init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
546 "complex*8", (struct objfile *) NULL);
547 TYPE_TARGET_TYPE (builtin_type_f_complex_s8) = builtin_type_f_real;
549 builtin_type_f_complex_s16 =
550 init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
552 "complex*16", (struct objfile *) NULL);
553 TYPE_TARGET_TYPE (builtin_type_f_complex_s16) = builtin_type_f_real_s8;
555 /* We have a new size == 4 double floats for the
556 complex*32 data type */
558 builtin_type_f_complex_s32 =
559 init_type (TYPE_CODE_COMPLEX, 2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
561 "complex*32", (struct objfile *) NULL);
562 TYPE_TARGET_TYPE (builtin_type_f_complex_s32) = builtin_type_f_real_s16;
564 builtin_type_string =
565 init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
567 "character string", (struct objfile *) NULL);
569 add_language (&f_language_defn);
574 allocate_saved_bf_node()
578 new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF));
582 static SAVED_FUNCTION *
583 allocate_saved_function_node()
587 new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION));
591 static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node()
593 SAVED_F77_COMMON_PTR new;
595 new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON));
599 static COMMON_ENTRY_PTR allocate_common_entry_node()
601 COMMON_ENTRY_PTR new;
603 new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY));
608 SAVED_F77_COMMON_PTR head_common_list=NULL; /* Ptr to 1st saved COMMON */
609 SAVED_F77_COMMON_PTR tail_common_list=NULL; /* Ptr to last saved COMMON */
610 SAVED_F77_COMMON_PTR current_common=NULL; /* Ptr to current COMMON */
613 static SAVED_BF_PTR saved_bf_list=NULL; /* Ptr to (.bf,function)
615 static SAVED_BF_PTR saved_bf_list_end=NULL; /* Ptr to above list's end */
616 static SAVED_BF_PTR current_head_bf_list=NULL; /* Current head of above list
619 static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use
622 /* The following function simply enters a given common block onto
623 the global common block chain */
626 add_common_block(name,offset,secnum,func_stab)
632 SAVED_F77_COMMON_PTR tmp;
633 char *c,*local_copy_func_stab;
635 /* If the COMMON block we are trying to add has a blank
636 name (i.e. "#BLNK_COM") then we set it to __BLANK
637 because the darn "#" character makes GDB's input
641 if (STREQ(name,BLANK_COMMON_NAME_ORIGINAL) ||
642 STREQ(name,BLANK_COMMON_NAME_MF77))
646 name = alloca(strlen(BLANK_COMMON_NAME_LOCAL) + 1);
647 strcpy(name,BLANK_COMMON_NAME_LOCAL);
650 tmp = allocate_saved_f77_common_node();
652 local_copy_func_stab = xmalloc (strlen(func_stab) + 1);
653 strcpy(local_copy_func_stab,func_stab);
655 tmp->name = xmalloc(strlen(name) + 1);
657 /* local_copy_func_stab is a stabstring, let us first extract the
658 function name from the stab by NULLing out the ':' character. */
662 c = strchr(local_copy_func_stab,':');
667 error("Malformed function STAB found in add_common_block()");
670 tmp->owning_function = xmalloc (strlen(local_copy_func_stab) + 1);
672 strcpy(tmp->owning_function,local_copy_func_stab);
674 strcpy(tmp->name,name);
675 tmp->offset = offset;
678 tmp->secnum = secnum;
680 current_common = tmp;
682 if (head_common_list == NULL)
684 head_common_list = tail_common_list = tmp;
688 tail_common_list->next = tmp;
689 tail_common_list = tmp;
694 /* The following function simply enters a given common entry onto
695 the "current_common" block that has been saved away. */
699 add_common_entry(entry_sym_ptr)
700 struct symbol *entry_sym_ptr;
702 COMMON_ENTRY_PTR tmp;
706 /* The order of this list is important, since
707 we expect the entries to appear in decl.
708 order when we later issue "info common" calls */
710 tmp = allocate_common_entry_node();
713 tmp->symbol = entry_sym_ptr;
715 if (current_common == NULL)
716 error("Attempt to add COMMON entry with no block open!");
719 if (current_common->entries == NULL)
721 current_common->entries = tmp;
722 current_common->end_of_entries = tmp;
726 current_common->end_of_entries->next = tmp;
727 current_common->end_of_entries = tmp;
733 /* This routine finds the first encountred COMMON block named "name" */
736 static SAVED_F77_COMMON_PTR
737 find_first_common_named(name)
741 SAVED_F77_COMMON_PTR tmp;
743 tmp = head_common_list;
747 if (STREQ(tmp->name,name))
756 /* This routine finds the first encountred COMMON block named "name"
757 that belongs to function funcname */
759 SAVED_F77_COMMON_PTR find_common_for_function(name, funcname)
764 SAVED_F77_COMMON_PTR tmp;
766 tmp = head_common_list;
770 if (STREQ(tmp->name,name) && STREQ(tmp->owning_function,funcname))
781 /* The following function is called to patch up the offsets
782 for the statics contained in the COMMON block named
786 patch_common_entries (blk, offset, secnum)
787 SAVED_F77_COMMON_PTR blk;
791 COMMON_ENTRY_PTR entry;
793 blk->offset = offset; /* Keep this around for future use. */
795 entry = blk->entries;
797 while (entry != NULL)
799 SYMBOL_VALUE (entry->symbol) += offset;
800 SYMBOL_SECTION (entry->symbol) = secnum;
804 blk->secnum = secnum;
807 /* Patch all commons named "name" that need patching.Since COMMON
808 blocks occur with relative infrequency, we simply do a linear scan on
809 the name. Eventually, the best way to do this will be a
810 hashed-lookup. Secnum is the section number for the .bss section
811 (which is where common data lives). */
814 patch_all_commons_by_name (name, offset, secnum)
820 SAVED_F77_COMMON_PTR tmp;
822 /* For blank common blocks, change the canonical reprsentation
825 if ((STREQ(name,BLANK_COMMON_NAME_ORIGINAL)) ||
826 (STREQ(name,BLANK_COMMON_NAME_MF77)))
829 name = alloca(strlen(BLANK_COMMON_NAME_LOCAL) + 1);
830 strcpy(name,BLANK_COMMON_NAME_LOCAL);
833 tmp = head_common_list;
837 if (COMMON_NEEDS_PATCHING(tmp))
838 if (STREQ(tmp->name,name))
839 patch_common_entries(tmp,offset,secnum);
846 /* This macro adds the symbol-number for the start of the function
847 (the symbol number of the .bf) referenced by symnum_fcn to a
848 list. This list, in reality should be a FIFO queue but since
849 #line pragmas sometimes cause line ranges to get messed up
850 we simply create a linear list. This list can then be searched
851 first by a queueing algorithm and upon failure fall back to
855 #define ADD_BF_SYMNUM(bf_sym,fcn_sym) \
857 if (saved_bf_list == NULL) \
859 tmp_bf_ptr = allocate_saved_bf_node(); \
861 tmp_bf_ptr->symnum_bf = (bf_sym); \
862 tmp_bf_ptr->symnum_fcn = (fcn_sym); \
863 tmp_bf_ptr->next = NULL; \
865 current_head_bf_list = saved_bf_list = tmp_bf_ptr; \
866 saved_bf_list_end = tmp_bf_ptr; \
870 tmp_bf_ptr = allocate_saved_bf_node(); \
872 tmp_bf_ptr->symnum_bf = (bf_sym); \
873 tmp_bf_ptr->symnum_fcn = (fcn_sym); \
874 tmp_bf_ptr->next = NULL; \
876 saved_bf_list_end->next = tmp_bf_ptr; \
877 saved_bf_list_end = tmp_bf_ptr; \
881 /* This function frees the entire (.bf,function) list */
888 SAVED_BF_PTR tmp = saved_bf_list;
889 SAVED_BF_PTR next = NULL;
897 saved_bf_list = NULL;
901 int global_remote_debug;
906 get_bf_for_fcn (the_function)
912 /* First use a simple queuing algorithm (i.e. look and see if the
913 item at the head of the queue is the one you want) */
915 if (saved_bf_list == NULL)
916 fatal ("cannot get .bf node off empty list");
918 if (current_head_bf_list != NULL)
919 if (current_head_bf_list->symnum_fcn == the_function)
921 if (global_remote_debug)
924 tmp = current_head_bf_list;
925 current_head_bf_list = current_head_bf_list->next;
926 return(tmp->symnum_bf);
929 /* If the above did not work (probably because #line directives were
930 used in the sourcefile and they messed up our internal tables) we now do
931 the ugly linear scan */
933 if (global_remote_debug)
934 fprintf(stderr,"\ndefaulting to linear scan\n");
941 if (tmp->symnum_fcn == the_function)
943 if (global_remote_debug)
944 fprintf(stderr,"Found in %d probes\n",nprobes);
945 current_head_bf_list = tmp->next;
946 return(tmp->symnum_bf);
954 static SAVED_FUNCTION_PTR saved_function_list=NULL;
955 static SAVED_FUNCTION_PTR saved_function_list_end=NULL;
958 clear_function_list()
960 SAVED_FUNCTION_PTR tmp = saved_function_list;
961 SAVED_FUNCTION_PTR next = NULL;
970 saved_function_list = NULL;