xref: /dflybsd-src/contrib/gdb-7/gdb/f-lang.c (revision a45ae5f869d9cfcb3e41dbab486e10bfa9e336bf)
15796c8dcSSimon Schubert /* Fortran language support routines for GDB, the GNU debugger.
25796c8dcSSimon Schubert 
3*a45ae5f8SJohn Marino    Copyright (C) 1993-1996, 1998-2005, 2007-2012 Free Software
4*a45ae5f8SJohn Marino    Foundation, Inc.
55796c8dcSSimon Schubert 
65796c8dcSSimon Schubert    Contributed by Motorola.  Adapted from the C parser by Farooq Butt
75796c8dcSSimon Schubert    (fmbutt@engage.sps.mot.com).
85796c8dcSSimon Schubert 
95796c8dcSSimon Schubert    This file is part of GDB.
105796c8dcSSimon Schubert 
115796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
125796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
135796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
145796c8dcSSimon Schubert    (at your option) any later version.
155796c8dcSSimon Schubert 
165796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
175796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
185796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
195796c8dcSSimon Schubert    GNU General Public License for more details.
205796c8dcSSimon Schubert 
215796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
225796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
235796c8dcSSimon Schubert 
245796c8dcSSimon Schubert #include "defs.h"
255796c8dcSSimon Schubert #include "gdb_string.h"
265796c8dcSSimon Schubert #include "symtab.h"
275796c8dcSSimon Schubert #include "gdbtypes.h"
285796c8dcSSimon Schubert #include "expression.h"
295796c8dcSSimon Schubert #include "parser-defs.h"
305796c8dcSSimon Schubert #include "language.h"
315796c8dcSSimon Schubert #include "f-lang.h"
325796c8dcSSimon Schubert #include "valprint.h"
335796c8dcSSimon Schubert #include "value.h"
34cf7f2e2dSJohn Marino #include "cp-support.h"
35*a45ae5f8SJohn Marino #include "charset.h"
365796c8dcSSimon Schubert 
375796c8dcSSimon Schubert 
385796c8dcSSimon Schubert /* Following is dubious stuff that had been in the xcoff reader.  */
395796c8dcSSimon Schubert 
405796c8dcSSimon Schubert struct saved_fcn
415796c8dcSSimon Schubert   {
42c50c785cSJohn Marino     long line_offset;		/* Line offset for function.  */
435796c8dcSSimon Schubert     struct saved_fcn *next;
445796c8dcSSimon Schubert   };
455796c8dcSSimon Schubert 
465796c8dcSSimon Schubert 
475796c8dcSSimon Schubert struct saved_bf_symnum
485796c8dcSSimon Schubert   {
49c50c785cSJohn Marino     long symnum_fcn;		/* Symnum of function (i.e. .function
50c50c785cSJohn Marino 				   directive).  */
51c50c785cSJohn Marino     long symnum_bf;		/* Symnum of .bf for this function.  */
525796c8dcSSimon Schubert     struct saved_bf_symnum *next;
535796c8dcSSimon Schubert   };
545796c8dcSSimon Schubert 
555796c8dcSSimon Schubert typedef struct saved_fcn SAVED_FUNCTION, *SAVED_FUNCTION_PTR;
565796c8dcSSimon Schubert typedef struct saved_bf_symnum SAVED_BF, *SAVED_BF_PTR;
575796c8dcSSimon Schubert 
585796c8dcSSimon Schubert /* Local functions */
595796c8dcSSimon Schubert 
605796c8dcSSimon Schubert extern void _initialize_f_language (void);
615796c8dcSSimon Schubert #if 0
625796c8dcSSimon Schubert static void clear_function_list (void);
635796c8dcSSimon Schubert static long get_bf_for_fcn (long);
645796c8dcSSimon Schubert static void clear_bf_list (void);
655796c8dcSSimon Schubert static void patch_all_commons_by_name (char *, CORE_ADDR, int);
665796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR find_first_common_named (char *);
675796c8dcSSimon Schubert static void add_common_entry (struct symbol *);
685796c8dcSSimon Schubert static void add_common_block (char *, CORE_ADDR, int, char *);
695796c8dcSSimon Schubert static SAVED_FUNCTION *allocate_saved_function_node (void);
705796c8dcSSimon Schubert static SAVED_BF_PTR allocate_saved_bf_node (void);
715796c8dcSSimon Schubert static COMMON_ENTRY_PTR allocate_common_entry_node (void);
725796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void);
735796c8dcSSimon Schubert static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int);
745796c8dcSSimon Schubert #endif
755796c8dcSSimon Schubert 
765796c8dcSSimon Schubert static void f_printchar (int c, struct type *type, struct ui_file * stream);
775796c8dcSSimon Schubert static void f_emit_char (int c, struct type *type,
785796c8dcSSimon Schubert 			 struct ui_file * stream, int quoter);
795796c8dcSSimon Schubert 
80*a45ae5f8SJohn Marino /* Return the encoding that should be used for the character type
81*a45ae5f8SJohn Marino    TYPE.  */
82*a45ae5f8SJohn Marino 
83*a45ae5f8SJohn Marino static const char *
84*a45ae5f8SJohn Marino f_get_encoding (struct type *type)
85*a45ae5f8SJohn Marino {
86*a45ae5f8SJohn Marino   const char *encoding;
87*a45ae5f8SJohn Marino 
88*a45ae5f8SJohn Marino   switch (TYPE_LENGTH (type))
89*a45ae5f8SJohn Marino     {
90*a45ae5f8SJohn Marino     case 1:
91*a45ae5f8SJohn Marino       encoding = target_charset (get_type_arch (type));
92*a45ae5f8SJohn Marino       break;
93*a45ae5f8SJohn Marino     case 4:
94*a45ae5f8SJohn Marino       if (gdbarch_byte_order (get_type_arch (type)) == BFD_ENDIAN_BIG)
95*a45ae5f8SJohn Marino 	encoding = "UTF-32BE";
96*a45ae5f8SJohn Marino       else
97*a45ae5f8SJohn Marino 	encoding = "UTF-32LE";
98*a45ae5f8SJohn Marino       break;
99*a45ae5f8SJohn Marino 
100*a45ae5f8SJohn Marino     default:
101*a45ae5f8SJohn Marino       error (_("unrecognized character type"));
102*a45ae5f8SJohn Marino     }
103*a45ae5f8SJohn Marino 
104*a45ae5f8SJohn Marino   return encoding;
105*a45ae5f8SJohn Marino }
106*a45ae5f8SJohn Marino 
1075796c8dcSSimon Schubert /* Print the character C on STREAM as part of the contents of a literal
1085796c8dcSSimon Schubert    string whose delimiter is QUOTER.  Note that that format for printing
1095796c8dcSSimon Schubert    characters and strings is language specific.
1105796c8dcSSimon Schubert    FIXME:  This is a copy of the same function from c-exp.y.  It should
1115796c8dcSSimon Schubert    be replaced with a true F77 version.  */
1125796c8dcSSimon Schubert 
1135796c8dcSSimon Schubert static void
1145796c8dcSSimon Schubert f_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
1155796c8dcSSimon Schubert {
116*a45ae5f8SJohn Marino   const char *encoding = f_get_encoding (type);
1175796c8dcSSimon Schubert 
118*a45ae5f8SJohn Marino   generic_emit_char (c, type, stream, quoter, encoding);
1195796c8dcSSimon Schubert }
1205796c8dcSSimon Schubert 
121*a45ae5f8SJohn Marino /* Implementation of la_printchar.  */
1225796c8dcSSimon Schubert 
1235796c8dcSSimon Schubert static void
1245796c8dcSSimon Schubert f_printchar (int c, struct type *type, struct ui_file *stream)
1255796c8dcSSimon Schubert {
1265796c8dcSSimon Schubert   fputs_filtered ("'", stream);
1275796c8dcSSimon Schubert   LA_EMIT_CHAR (c, type, stream, '\'');
1285796c8dcSSimon Schubert   fputs_filtered ("'", stream);
1295796c8dcSSimon Schubert }
1305796c8dcSSimon Schubert 
1315796c8dcSSimon Schubert /* Print the character string STRING, printing at most LENGTH characters.
1325796c8dcSSimon Schubert    Printing stops early if the number hits print_max; repeat counts
1335796c8dcSSimon Schubert    are printed as appropriate.  Print ellipses at the end if we
1345796c8dcSSimon Schubert    had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
1355796c8dcSSimon Schubert    FIXME:  This is a copy of the same function from c-exp.y.  It should
1365796c8dcSSimon Schubert    be replaced with a true F77 version.  */
1375796c8dcSSimon Schubert 
1385796c8dcSSimon Schubert static void
1395796c8dcSSimon Schubert f_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
140cf7f2e2dSJohn Marino 	    unsigned int length, const char *encoding, int force_ellipses,
1415796c8dcSSimon Schubert 	    const struct value_print_options *options)
1425796c8dcSSimon Schubert {
143*a45ae5f8SJohn Marino   const char *type_encoding = f_get_encoding (type);
1445796c8dcSSimon Schubert 
145*a45ae5f8SJohn Marino   if (TYPE_LENGTH (type) == 4)
146*a45ae5f8SJohn Marino     fputs_filtered ("4_", stream);
1475796c8dcSSimon Schubert 
148*a45ae5f8SJohn Marino   if (!encoding || !*encoding)
149*a45ae5f8SJohn Marino     encoding = type_encoding;
1505796c8dcSSimon Schubert 
151*a45ae5f8SJohn Marino   generic_printstr (stream, type, string, length, encoding,
152*a45ae5f8SJohn Marino 		    force_ellipses, '\'', 0, options);
1535796c8dcSSimon Schubert }
1545796c8dcSSimon Schubert 
1555796c8dcSSimon Schubert 
1565796c8dcSSimon Schubert /* Table of operators and their precedences for printing expressions.  */
1575796c8dcSSimon Schubert 
1585796c8dcSSimon Schubert static const struct op_print f_op_print_tab[] =
1595796c8dcSSimon Schubert {
1605796c8dcSSimon Schubert   {"+", BINOP_ADD, PREC_ADD, 0},
1615796c8dcSSimon Schubert   {"+", UNOP_PLUS, PREC_PREFIX, 0},
1625796c8dcSSimon Schubert   {"-", BINOP_SUB, PREC_ADD, 0},
1635796c8dcSSimon Schubert   {"-", UNOP_NEG, PREC_PREFIX, 0},
1645796c8dcSSimon Schubert   {"*", BINOP_MUL, PREC_MUL, 0},
1655796c8dcSSimon Schubert   {"/", BINOP_DIV, PREC_MUL, 0},
1665796c8dcSSimon Schubert   {"DIV", BINOP_INTDIV, PREC_MUL, 0},
1675796c8dcSSimon Schubert   {"MOD", BINOP_REM, PREC_MUL, 0},
1685796c8dcSSimon Schubert   {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
1695796c8dcSSimon Schubert   {".OR.", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
1705796c8dcSSimon Schubert   {".AND.", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
1715796c8dcSSimon Schubert   {".NOT.", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
1725796c8dcSSimon Schubert   {".EQ.", BINOP_EQUAL, PREC_EQUAL, 0},
1735796c8dcSSimon Schubert   {".NE.", BINOP_NOTEQUAL, PREC_EQUAL, 0},
1745796c8dcSSimon Schubert   {".LE.", BINOP_LEQ, PREC_ORDER, 0},
1755796c8dcSSimon Schubert   {".GE.", BINOP_GEQ, PREC_ORDER, 0},
1765796c8dcSSimon Schubert   {".GT.", BINOP_GTR, PREC_ORDER, 0},
1775796c8dcSSimon Schubert   {".LT.", BINOP_LESS, PREC_ORDER, 0},
1785796c8dcSSimon Schubert   {"**", UNOP_IND, PREC_PREFIX, 0},
1795796c8dcSSimon Schubert   {"@", BINOP_REPEAT, PREC_REPEAT, 0},
1805796c8dcSSimon Schubert   {NULL, 0, 0, 0}
1815796c8dcSSimon Schubert };
1825796c8dcSSimon Schubert 
1835796c8dcSSimon Schubert enum f_primitive_types {
1845796c8dcSSimon Schubert   f_primitive_type_character,
1855796c8dcSSimon Schubert   f_primitive_type_logical,
1865796c8dcSSimon Schubert   f_primitive_type_logical_s1,
1875796c8dcSSimon Schubert   f_primitive_type_logical_s2,
188cf7f2e2dSJohn Marino   f_primitive_type_logical_s8,
1895796c8dcSSimon Schubert   f_primitive_type_integer,
1905796c8dcSSimon Schubert   f_primitive_type_integer_s2,
1915796c8dcSSimon Schubert   f_primitive_type_real,
1925796c8dcSSimon Schubert   f_primitive_type_real_s8,
1935796c8dcSSimon Schubert   f_primitive_type_real_s16,
1945796c8dcSSimon Schubert   f_primitive_type_complex_s8,
1955796c8dcSSimon Schubert   f_primitive_type_complex_s16,
1965796c8dcSSimon Schubert   f_primitive_type_void,
1975796c8dcSSimon Schubert   nr_f_primitive_types
1985796c8dcSSimon Schubert };
1995796c8dcSSimon Schubert 
2005796c8dcSSimon Schubert static void
2015796c8dcSSimon Schubert f_language_arch_info (struct gdbarch *gdbarch,
2025796c8dcSSimon Schubert 		      struct language_arch_info *lai)
2035796c8dcSSimon Schubert {
2045796c8dcSSimon Schubert   const struct builtin_f_type *builtin = builtin_f_type (gdbarch);
2055796c8dcSSimon Schubert 
2065796c8dcSSimon Schubert   lai->string_char_type = builtin->builtin_character;
2075796c8dcSSimon Schubert   lai->primitive_type_vector
2085796c8dcSSimon Schubert     = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_f_primitive_types + 1,
2095796c8dcSSimon Schubert                               struct type *);
2105796c8dcSSimon Schubert 
2115796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_character]
2125796c8dcSSimon Schubert     = builtin->builtin_character;
2135796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_logical]
2145796c8dcSSimon Schubert     = builtin->builtin_logical;
2155796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_logical_s1]
2165796c8dcSSimon Schubert     = builtin->builtin_logical_s1;
2175796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_logical_s2]
2185796c8dcSSimon Schubert     = builtin->builtin_logical_s2;
219cf7f2e2dSJohn Marino   lai->primitive_type_vector [f_primitive_type_logical_s8]
220cf7f2e2dSJohn Marino     = builtin->builtin_logical_s8;
2215796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_real]
2225796c8dcSSimon Schubert     = builtin->builtin_real;
2235796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_real_s8]
2245796c8dcSSimon Schubert     = builtin->builtin_real_s8;
2255796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_real_s16]
2265796c8dcSSimon Schubert     = builtin->builtin_real_s16;
2275796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_complex_s8]
2285796c8dcSSimon Schubert     = builtin->builtin_complex_s8;
2295796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_complex_s16]
2305796c8dcSSimon Schubert     = builtin->builtin_complex_s16;
2315796c8dcSSimon Schubert   lai->primitive_type_vector [f_primitive_type_void]
2325796c8dcSSimon Schubert     = builtin->builtin_void;
2335796c8dcSSimon Schubert 
2345796c8dcSSimon Schubert   lai->bool_type_symbol = "logical";
2355796c8dcSSimon Schubert   lai->bool_type_default = builtin->builtin_logical_s2;
2365796c8dcSSimon Schubert }
2375796c8dcSSimon Schubert 
238cf7f2e2dSJohn Marino /* Remove the modules separator :: from the default break list.  */
239cf7f2e2dSJohn Marino 
240cf7f2e2dSJohn Marino static char *
241cf7f2e2dSJohn Marino f_word_break_characters (void)
242cf7f2e2dSJohn Marino {
243cf7f2e2dSJohn Marino   static char *retval;
244cf7f2e2dSJohn Marino 
245cf7f2e2dSJohn Marino   if (!retval)
246cf7f2e2dSJohn Marino     {
247cf7f2e2dSJohn Marino       char *s;
248cf7f2e2dSJohn Marino 
249cf7f2e2dSJohn Marino       retval = xstrdup (default_word_break_characters ());
250cf7f2e2dSJohn Marino       s = strchr (retval, ':');
251cf7f2e2dSJohn Marino       if (s)
252cf7f2e2dSJohn Marino 	{
253cf7f2e2dSJohn Marino 	  char *last_char = &s[strlen (s) - 1];
254cf7f2e2dSJohn Marino 
255cf7f2e2dSJohn Marino 	  *s = *last_char;
256cf7f2e2dSJohn Marino 	  *last_char = 0;
257cf7f2e2dSJohn Marino 	}
258cf7f2e2dSJohn Marino     }
259cf7f2e2dSJohn Marino   return retval;
260cf7f2e2dSJohn Marino }
261cf7f2e2dSJohn Marino 
262c50c785cSJohn Marino /* Consider the modules separator :: as a valid symbol name character
263c50c785cSJohn Marino    class.  */
264cf7f2e2dSJohn Marino 
265cf7f2e2dSJohn Marino static char **
266cf7f2e2dSJohn Marino f_make_symbol_completion_list (char *text, char *word)
267cf7f2e2dSJohn Marino {
268cf7f2e2dSJohn Marino   return default_make_symbol_completion_list_break_on (text, word, ":");
269cf7f2e2dSJohn Marino }
270cf7f2e2dSJohn Marino 
2715796c8dcSSimon Schubert /* This is declared in c-lang.h but it is silly to import that file for what
2725796c8dcSSimon Schubert    is already just a hack.  */
2735796c8dcSSimon Schubert extern int c_value_print (struct value *, struct ui_file *,
2745796c8dcSSimon Schubert 			  const struct value_print_options *);
2755796c8dcSSimon Schubert 
2765796c8dcSSimon Schubert const struct language_defn f_language_defn =
2775796c8dcSSimon Schubert {
2785796c8dcSSimon Schubert   "fortran",
2795796c8dcSSimon Schubert   language_fortran,
2805796c8dcSSimon Schubert   range_check_on,
2815796c8dcSSimon Schubert   type_check_on,
2825796c8dcSSimon Schubert   case_sensitive_off,
2835796c8dcSSimon Schubert   array_column_major,
2845796c8dcSSimon Schubert   macro_expansion_no,
2855796c8dcSSimon Schubert   &exp_descriptor_standard,
2865796c8dcSSimon Schubert   f_parse,			/* parser */
2875796c8dcSSimon Schubert   f_error,			/* parser error function */
2885796c8dcSSimon Schubert   null_post_parser,
2895796c8dcSSimon Schubert   f_printchar,			/* Print character constant */
2905796c8dcSSimon Schubert   f_printstr,			/* function to print string constant */
2915796c8dcSSimon Schubert   f_emit_char,			/* Function to print a single character */
2925796c8dcSSimon Schubert   f_print_type,			/* Print a type using appropriate syntax */
2935796c8dcSSimon Schubert   default_print_typedef,	/* Print a typedef using appropriate syntax */
2945796c8dcSSimon Schubert   f_val_print,			/* Print a value using appropriate syntax */
2955796c8dcSSimon Schubert   c_value_print,		/* FIXME */
2965796c8dcSSimon Schubert   NULL,				/* Language specific skip_trampoline */
2975796c8dcSSimon Schubert   NULL,                    	/* name_of_this */
298cf7f2e2dSJohn Marino   cp_lookup_symbol_nonlocal,	/* lookup_symbol_nonlocal */
2995796c8dcSSimon Schubert   basic_lookup_transparent_type,/* lookup_transparent_type */
3005796c8dcSSimon Schubert   NULL,				/* Language specific symbol demangler */
301c50c785cSJohn Marino   NULL,				/* Language specific
302c50c785cSJohn Marino 				   class_name_from_physname */
3035796c8dcSSimon Schubert   f_op_print_tab,		/* expression operators for printing */
3045796c8dcSSimon Schubert   0,				/* arrays are first-class (not c-style) */
3055796c8dcSSimon Schubert   1,				/* String lower bound */
306cf7f2e2dSJohn Marino   f_word_break_characters,
307cf7f2e2dSJohn Marino   f_make_symbol_completion_list,
3085796c8dcSSimon Schubert   f_language_arch_info,
3095796c8dcSSimon Schubert   default_print_array_index,
3105796c8dcSSimon Schubert   default_pass_by_reference,
3115796c8dcSSimon Schubert   default_get_string,
312*a45ae5f8SJohn Marino   strcmp_iw_ordered,
313*a45ae5f8SJohn Marino   iterate_over_symbols,
3145796c8dcSSimon Schubert   LANG_MAGIC
3155796c8dcSSimon Schubert };
3165796c8dcSSimon Schubert 
3175796c8dcSSimon Schubert static void *
3185796c8dcSSimon Schubert build_fortran_types (struct gdbarch *gdbarch)
3195796c8dcSSimon Schubert {
3205796c8dcSSimon Schubert   struct builtin_f_type *builtin_f_type
3215796c8dcSSimon Schubert     = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_f_type);
3225796c8dcSSimon Schubert 
3235796c8dcSSimon Schubert   builtin_f_type->builtin_void
3245796c8dcSSimon Schubert     = arch_type (gdbarch, TYPE_CODE_VOID, 1, "VOID");
3255796c8dcSSimon Schubert 
3265796c8dcSSimon Schubert   builtin_f_type->builtin_character
3275796c8dcSSimon Schubert     = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "character");
3285796c8dcSSimon Schubert 
3295796c8dcSSimon Schubert   builtin_f_type->builtin_logical_s1
3305796c8dcSSimon Schubert     = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1");
3315796c8dcSSimon Schubert 
3325796c8dcSSimon Schubert   builtin_f_type->builtin_integer_s2
3335796c8dcSSimon Schubert     = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), 0,
3345796c8dcSSimon Schubert 			 "integer*2");
3355796c8dcSSimon Schubert 
3365796c8dcSSimon Schubert   builtin_f_type->builtin_logical_s2
3375796c8dcSSimon Schubert     = arch_boolean_type (gdbarch, gdbarch_short_bit (gdbarch), 1,
3385796c8dcSSimon Schubert 			 "logical*2");
3395796c8dcSSimon Schubert 
340cf7f2e2dSJohn Marino   builtin_f_type->builtin_logical_s8
341cf7f2e2dSJohn Marino     = arch_boolean_type (gdbarch, gdbarch_long_long_bit (gdbarch), 1,
342cf7f2e2dSJohn Marino 			 "logical*8");
343cf7f2e2dSJohn Marino 
3445796c8dcSSimon Schubert   builtin_f_type->builtin_integer
3455796c8dcSSimon Schubert     = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0,
3465796c8dcSSimon Schubert 			 "integer");
3475796c8dcSSimon Schubert 
3485796c8dcSSimon Schubert   builtin_f_type->builtin_logical
3495796c8dcSSimon Schubert     = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1,
3505796c8dcSSimon Schubert 			 "logical*4");
3515796c8dcSSimon Schubert 
3525796c8dcSSimon Schubert   builtin_f_type->builtin_real
3535796c8dcSSimon Schubert     = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
3545796c8dcSSimon Schubert 		       "real", NULL);
3555796c8dcSSimon Schubert   builtin_f_type->builtin_real_s8
3565796c8dcSSimon Schubert     = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
3575796c8dcSSimon Schubert 		       "real*8", NULL);
3585796c8dcSSimon Schubert   builtin_f_type->builtin_real_s16
3595796c8dcSSimon Schubert     = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
3605796c8dcSSimon Schubert 		       "real*16", NULL);
3615796c8dcSSimon Schubert 
3625796c8dcSSimon Schubert   builtin_f_type->builtin_complex_s8
3635796c8dcSSimon Schubert     = arch_complex_type (gdbarch, "complex*8",
3645796c8dcSSimon Schubert 			 builtin_f_type->builtin_real);
3655796c8dcSSimon Schubert   builtin_f_type->builtin_complex_s16
3665796c8dcSSimon Schubert     = arch_complex_type (gdbarch, "complex*16",
3675796c8dcSSimon Schubert 			 builtin_f_type->builtin_real_s8);
3685796c8dcSSimon Schubert   builtin_f_type->builtin_complex_s32
3695796c8dcSSimon Schubert     = arch_complex_type (gdbarch, "complex*32",
3705796c8dcSSimon Schubert 			 builtin_f_type->builtin_real_s16);
3715796c8dcSSimon Schubert 
3725796c8dcSSimon Schubert   return builtin_f_type;
3735796c8dcSSimon Schubert }
3745796c8dcSSimon Schubert 
3755796c8dcSSimon Schubert static struct gdbarch_data *f_type_data;
3765796c8dcSSimon Schubert 
3775796c8dcSSimon Schubert const struct builtin_f_type *
3785796c8dcSSimon Schubert builtin_f_type (struct gdbarch *gdbarch)
3795796c8dcSSimon Schubert {
3805796c8dcSSimon Schubert   return gdbarch_data (gdbarch, f_type_data);
3815796c8dcSSimon Schubert }
3825796c8dcSSimon Schubert 
3835796c8dcSSimon Schubert void
3845796c8dcSSimon Schubert _initialize_f_language (void)
3855796c8dcSSimon Schubert {
3865796c8dcSSimon Schubert   f_type_data = gdbarch_data_register_post_init (build_fortran_types);
3875796c8dcSSimon Schubert 
3885796c8dcSSimon Schubert   add_language (&f_language_defn);
3895796c8dcSSimon Schubert }
3905796c8dcSSimon Schubert 
3915796c8dcSSimon Schubert #if 0
3925796c8dcSSimon Schubert static SAVED_BF_PTR
3935796c8dcSSimon Schubert allocate_saved_bf_node (void)
3945796c8dcSSimon Schubert {
3955796c8dcSSimon Schubert   SAVED_BF_PTR new;
3965796c8dcSSimon Schubert 
3975796c8dcSSimon Schubert   new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF));
3985796c8dcSSimon Schubert   return (new);
3995796c8dcSSimon Schubert }
4005796c8dcSSimon Schubert 
4015796c8dcSSimon Schubert static SAVED_FUNCTION *
4025796c8dcSSimon Schubert allocate_saved_function_node (void)
4035796c8dcSSimon Schubert {
4045796c8dcSSimon Schubert   SAVED_FUNCTION *new;
4055796c8dcSSimon Schubert 
4065796c8dcSSimon Schubert   new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION));
4075796c8dcSSimon Schubert   return (new);
4085796c8dcSSimon Schubert }
4095796c8dcSSimon Schubert 
4105796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR
4115796c8dcSSimon Schubert allocate_saved_f77_common_node (void)
4125796c8dcSSimon Schubert {
4135796c8dcSSimon Schubert   SAVED_F77_COMMON_PTR new;
4145796c8dcSSimon Schubert 
4155796c8dcSSimon Schubert   new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON));
4165796c8dcSSimon Schubert   return (new);
4175796c8dcSSimon Schubert }
4185796c8dcSSimon Schubert 
4195796c8dcSSimon Schubert static COMMON_ENTRY_PTR
4205796c8dcSSimon Schubert allocate_common_entry_node (void)
4215796c8dcSSimon Schubert {
4225796c8dcSSimon Schubert   COMMON_ENTRY_PTR new;
4235796c8dcSSimon Schubert 
4245796c8dcSSimon Schubert   new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY));
4255796c8dcSSimon Schubert   return (new);
4265796c8dcSSimon Schubert }
4275796c8dcSSimon Schubert #endif
4285796c8dcSSimon Schubert 
4295796c8dcSSimon Schubert SAVED_F77_COMMON_PTR head_common_list = NULL;	/* Ptr to 1st saved COMMON  */
4305796c8dcSSimon Schubert SAVED_F77_COMMON_PTR tail_common_list = NULL;	/* Ptr to last saved COMMON  */
4315796c8dcSSimon Schubert SAVED_F77_COMMON_PTR current_common = NULL;	/* Ptr to current COMMON */
4325796c8dcSSimon Schubert 
4335796c8dcSSimon Schubert #if 0
4345796c8dcSSimon Schubert static SAVED_BF_PTR saved_bf_list = NULL;	/* Ptr to (.bf,function)
4355796c8dcSSimon Schubert 						   list */
4365796c8dcSSimon Schubert static SAVED_BF_PTR saved_bf_list_end = NULL;	/* Ptr to above list's end */
437c50c785cSJohn Marino static SAVED_BF_PTR current_head_bf_list = NULL;    /* Current head of
438c50c785cSJohn Marino 						       above list.  */
4395796c8dcSSimon Schubert 
4405796c8dcSSimon Schubert static SAVED_BF_PTR tmp_bf_ptr;	/* Generic temporary for use
441c50c785cSJohn Marino 				   in macros.  */
4425796c8dcSSimon Schubert 
4435796c8dcSSimon Schubert /* The following function simply enters a given common block onto
444c50c785cSJohn Marino    the global common block chain.  */
4455796c8dcSSimon Schubert 
4465796c8dcSSimon Schubert static void
4475796c8dcSSimon Schubert add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab)
4485796c8dcSSimon Schubert {
4495796c8dcSSimon Schubert   SAVED_F77_COMMON_PTR tmp;
4505796c8dcSSimon Schubert   char *c, *local_copy_func_stab;
4515796c8dcSSimon Schubert 
4525796c8dcSSimon Schubert   /* If the COMMON block we are trying to add has a blank
4535796c8dcSSimon Schubert      name (i.e. "#BLNK_COM") then we set it to __BLANK
4545796c8dcSSimon Schubert      because the darn "#" character makes GDB's input
4555796c8dcSSimon Schubert      parser have fits.  */
4565796c8dcSSimon Schubert 
4575796c8dcSSimon Schubert 
4585796c8dcSSimon Schubert   if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
4595796c8dcSSimon Schubert       || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
4605796c8dcSSimon Schubert     {
4615796c8dcSSimon Schubert 
4625796c8dcSSimon Schubert       xfree (name);
4635796c8dcSSimon Schubert       name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
4645796c8dcSSimon Schubert       strcpy (name, BLANK_COMMON_NAME_LOCAL);
4655796c8dcSSimon Schubert     }
4665796c8dcSSimon Schubert 
4675796c8dcSSimon Schubert   tmp = allocate_saved_f77_common_node ();
4685796c8dcSSimon Schubert 
4695796c8dcSSimon Schubert   local_copy_func_stab = xmalloc (strlen (func_stab) + 1);
4705796c8dcSSimon Schubert   strcpy (local_copy_func_stab, func_stab);
4715796c8dcSSimon Schubert 
4725796c8dcSSimon Schubert   tmp->name = xmalloc (strlen (name) + 1);
4735796c8dcSSimon Schubert 
4745796c8dcSSimon Schubert   /* local_copy_func_stab is a stabstring, let us first extract the
4755796c8dcSSimon Schubert      function name from the stab by NULLing out the ':' character.  */
4765796c8dcSSimon Schubert 
4775796c8dcSSimon Schubert 
4785796c8dcSSimon Schubert   c = NULL;
4795796c8dcSSimon Schubert   c = strchr (local_copy_func_stab, ':');
4805796c8dcSSimon Schubert 
4815796c8dcSSimon Schubert   if (c)
4825796c8dcSSimon Schubert     *c = '\0';
4835796c8dcSSimon Schubert   else
4845796c8dcSSimon Schubert     error (_("Malformed function STAB found in add_common_block()"));
4855796c8dcSSimon Schubert 
4865796c8dcSSimon Schubert 
4875796c8dcSSimon Schubert   tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1);
4885796c8dcSSimon Schubert 
4895796c8dcSSimon Schubert   strcpy (tmp->owning_function, local_copy_func_stab);
4905796c8dcSSimon Schubert 
4915796c8dcSSimon Schubert   strcpy (tmp->name, name);
4925796c8dcSSimon Schubert   tmp->offset = offset;
4935796c8dcSSimon Schubert   tmp->next = NULL;
4945796c8dcSSimon Schubert   tmp->entries = NULL;
4955796c8dcSSimon Schubert   tmp->secnum = secnum;
4965796c8dcSSimon Schubert 
4975796c8dcSSimon Schubert   current_common = tmp;
4985796c8dcSSimon Schubert 
4995796c8dcSSimon Schubert   if (head_common_list == NULL)
5005796c8dcSSimon Schubert     {
5015796c8dcSSimon Schubert       head_common_list = tail_common_list = tmp;
5025796c8dcSSimon Schubert     }
5035796c8dcSSimon Schubert   else
5045796c8dcSSimon Schubert     {
5055796c8dcSSimon Schubert       tail_common_list->next = tmp;
5065796c8dcSSimon Schubert       tail_common_list = tmp;
5075796c8dcSSimon Schubert     }
5085796c8dcSSimon Schubert }
5095796c8dcSSimon Schubert #endif
5105796c8dcSSimon Schubert 
5115796c8dcSSimon Schubert /* The following function simply enters a given common entry onto
5125796c8dcSSimon Schubert    the "current_common" block that has been saved away.  */
5135796c8dcSSimon Schubert 
5145796c8dcSSimon Schubert #if 0
5155796c8dcSSimon Schubert static void
5165796c8dcSSimon Schubert add_common_entry (struct symbol *entry_sym_ptr)
5175796c8dcSSimon Schubert {
5185796c8dcSSimon Schubert   COMMON_ENTRY_PTR tmp;
5195796c8dcSSimon Schubert 
5205796c8dcSSimon Schubert 
5215796c8dcSSimon Schubert 
5225796c8dcSSimon Schubert   /* The order of this list is important, since
5235796c8dcSSimon Schubert      we expect the entries to appear in decl.
524c50c785cSJohn Marino      order when we later issue "info common" calls.  */
5255796c8dcSSimon Schubert 
5265796c8dcSSimon Schubert   tmp = allocate_common_entry_node ();
5275796c8dcSSimon Schubert 
5285796c8dcSSimon Schubert   tmp->next = NULL;
5295796c8dcSSimon Schubert   tmp->symbol = entry_sym_ptr;
5305796c8dcSSimon Schubert 
5315796c8dcSSimon Schubert   if (current_common == NULL)
5325796c8dcSSimon Schubert     error (_("Attempt to add COMMON entry with no block open!"));
5335796c8dcSSimon Schubert   else
5345796c8dcSSimon Schubert     {
5355796c8dcSSimon Schubert       if (current_common->entries == NULL)
5365796c8dcSSimon Schubert 	{
5375796c8dcSSimon Schubert 	  current_common->entries = tmp;
5385796c8dcSSimon Schubert 	  current_common->end_of_entries = tmp;
5395796c8dcSSimon Schubert 	}
5405796c8dcSSimon Schubert       else
5415796c8dcSSimon Schubert 	{
5425796c8dcSSimon Schubert 	  current_common->end_of_entries->next = tmp;
5435796c8dcSSimon Schubert 	  current_common->end_of_entries = tmp;
5445796c8dcSSimon Schubert 	}
5455796c8dcSSimon Schubert     }
5465796c8dcSSimon Schubert }
5475796c8dcSSimon Schubert #endif
5485796c8dcSSimon Schubert 
549c50c785cSJohn Marino /* This routine finds the first encountred COMMON block named "name".  */
5505796c8dcSSimon Schubert 
5515796c8dcSSimon Schubert #if 0
5525796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR
5535796c8dcSSimon Schubert find_first_common_named (char *name)
5545796c8dcSSimon Schubert {
5555796c8dcSSimon Schubert 
5565796c8dcSSimon Schubert   SAVED_F77_COMMON_PTR tmp;
5575796c8dcSSimon Schubert 
5585796c8dcSSimon Schubert   tmp = head_common_list;
5595796c8dcSSimon Schubert 
5605796c8dcSSimon Schubert   while (tmp != NULL)
5615796c8dcSSimon Schubert     {
5625796c8dcSSimon Schubert       if (strcmp (tmp->name, name) == 0)
5635796c8dcSSimon Schubert 	return (tmp);
5645796c8dcSSimon Schubert       else
5655796c8dcSSimon Schubert 	tmp = tmp->next;
5665796c8dcSSimon Schubert     }
5675796c8dcSSimon Schubert   return (NULL);
5685796c8dcSSimon Schubert }
5695796c8dcSSimon Schubert #endif
5705796c8dcSSimon Schubert 
5715796c8dcSSimon Schubert /* This routine finds the first encountred COMMON block named "name"
572c50c785cSJohn Marino    that belongs to function funcname.  */
5735796c8dcSSimon Schubert 
5745796c8dcSSimon Schubert SAVED_F77_COMMON_PTR
5755796c8dcSSimon Schubert find_common_for_function (char *name, char *funcname)
5765796c8dcSSimon Schubert {
5775796c8dcSSimon Schubert 
5785796c8dcSSimon Schubert   SAVED_F77_COMMON_PTR tmp;
5795796c8dcSSimon Schubert 
5805796c8dcSSimon Schubert   tmp = head_common_list;
5815796c8dcSSimon Schubert 
5825796c8dcSSimon Schubert   while (tmp != NULL)
5835796c8dcSSimon Schubert     {
5845796c8dcSSimon Schubert       if (strcmp (tmp->name, name) == 0
5855796c8dcSSimon Schubert 	  && strcmp (tmp->owning_function, funcname) == 0)
5865796c8dcSSimon Schubert 	return (tmp);
5875796c8dcSSimon Schubert       else
5885796c8dcSSimon Schubert 	tmp = tmp->next;
5895796c8dcSSimon Schubert     }
5905796c8dcSSimon Schubert   return (NULL);
5915796c8dcSSimon Schubert }
5925796c8dcSSimon Schubert 
5935796c8dcSSimon Schubert 
5945796c8dcSSimon Schubert #if 0
5955796c8dcSSimon Schubert 
5965796c8dcSSimon Schubert /* The following function is called to patch up the offsets
5975796c8dcSSimon Schubert    for the statics contained in the COMMON block named
5985796c8dcSSimon Schubert    "name."  */
5995796c8dcSSimon Schubert 
6005796c8dcSSimon Schubert static void
6015796c8dcSSimon Schubert patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum)
6025796c8dcSSimon Schubert {
6035796c8dcSSimon Schubert   COMMON_ENTRY_PTR entry;
6045796c8dcSSimon Schubert 
6055796c8dcSSimon Schubert   blk->offset = offset;		/* Keep this around for future use.  */
6065796c8dcSSimon Schubert 
6075796c8dcSSimon Schubert   entry = blk->entries;
6085796c8dcSSimon Schubert 
6095796c8dcSSimon Schubert   while (entry != NULL)
6105796c8dcSSimon Schubert     {
6115796c8dcSSimon Schubert       SYMBOL_VALUE (entry->symbol) += offset;
6125796c8dcSSimon Schubert       SYMBOL_SECTION (entry->symbol) = secnum;
6135796c8dcSSimon Schubert 
6145796c8dcSSimon Schubert       entry = entry->next;
6155796c8dcSSimon Schubert     }
6165796c8dcSSimon Schubert   blk->secnum = secnum;
6175796c8dcSSimon Schubert }
6185796c8dcSSimon Schubert 
6195796c8dcSSimon Schubert /* Patch all commons named "name" that need patching.Since COMMON
6205796c8dcSSimon Schubert    blocks occur with relative infrequency, we simply do a linear scan on
6215796c8dcSSimon Schubert    the name.  Eventually, the best way to do this will be a
6225796c8dcSSimon Schubert    hashed-lookup.  Secnum is the section number for the .bss section
6235796c8dcSSimon Schubert    (which is where common data lives).  */
6245796c8dcSSimon Schubert 
6255796c8dcSSimon Schubert static void
6265796c8dcSSimon Schubert patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum)
6275796c8dcSSimon Schubert {
6285796c8dcSSimon Schubert 
6295796c8dcSSimon Schubert   SAVED_F77_COMMON_PTR tmp;
6305796c8dcSSimon Schubert 
6315796c8dcSSimon Schubert   /* For blank common blocks, change the canonical reprsentation
6325796c8dcSSimon Schubert      of a blank name */
6335796c8dcSSimon Schubert 
6345796c8dcSSimon Schubert   if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
6355796c8dcSSimon Schubert       || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
6365796c8dcSSimon Schubert     {
6375796c8dcSSimon Schubert       xfree (name);
6385796c8dcSSimon Schubert       name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
6395796c8dcSSimon Schubert       strcpy (name, BLANK_COMMON_NAME_LOCAL);
6405796c8dcSSimon Schubert     }
6415796c8dcSSimon Schubert 
6425796c8dcSSimon Schubert   tmp = head_common_list;
6435796c8dcSSimon Schubert 
6445796c8dcSSimon Schubert   while (tmp != NULL)
6455796c8dcSSimon Schubert     {
6465796c8dcSSimon Schubert       if (COMMON_NEEDS_PATCHING (tmp))
6475796c8dcSSimon Schubert 	if (strcmp (tmp->name, name) == 0)
6485796c8dcSSimon Schubert 	  patch_common_entries (tmp, offset, secnum);
6495796c8dcSSimon Schubert 
6505796c8dcSSimon Schubert       tmp = tmp->next;
6515796c8dcSSimon Schubert     }
6525796c8dcSSimon Schubert }
6535796c8dcSSimon Schubert #endif
6545796c8dcSSimon Schubert 
6555796c8dcSSimon Schubert /* This macro adds the symbol-number for the start of the function
6565796c8dcSSimon Schubert    (the symbol number of the .bf) referenced by symnum_fcn to a
6575796c8dcSSimon Schubert    list.  This list, in reality should be a FIFO queue but since
6585796c8dcSSimon Schubert    #line pragmas sometimes cause line ranges to get messed up
6595796c8dcSSimon Schubert    we simply create a linear list.  This list can then be searched
6605796c8dcSSimon Schubert    first by a queueing algorithm and upon failure fall back to
6615796c8dcSSimon Schubert    a linear scan.  */
6625796c8dcSSimon Schubert 
6635796c8dcSSimon Schubert #if 0
6645796c8dcSSimon Schubert #define ADD_BF_SYMNUM(bf_sym,fcn_sym) \
6655796c8dcSSimon Schubert   \
6665796c8dcSSimon Schubert   if (saved_bf_list == NULL) \
6675796c8dcSSimon Schubert { \
6685796c8dcSSimon Schubert     tmp_bf_ptr = allocate_saved_bf_node(); \
6695796c8dcSSimon Schubert       \
6705796c8dcSSimon Schubert 	tmp_bf_ptr->symnum_bf = (bf_sym); \
6715796c8dcSSimon Schubert 	  tmp_bf_ptr->symnum_fcn = (fcn_sym);  \
6725796c8dcSSimon Schubert 	    tmp_bf_ptr->next = NULL; \
6735796c8dcSSimon Schubert 	      \
6745796c8dcSSimon Schubert 		current_head_bf_list = saved_bf_list = tmp_bf_ptr; \
6755796c8dcSSimon Schubert 		  saved_bf_list_end = tmp_bf_ptr; \
6765796c8dcSSimon Schubert 		  } \
6775796c8dcSSimon Schubert else \
6785796c8dcSSimon Schubert {  \
6795796c8dcSSimon Schubert      tmp_bf_ptr = allocate_saved_bf_node(); \
6805796c8dcSSimon Schubert        \
6815796c8dcSSimon Schubert          tmp_bf_ptr->symnum_bf = (bf_sym);  \
6825796c8dcSSimon Schubert 	   tmp_bf_ptr->symnum_fcn = (fcn_sym);  \
6835796c8dcSSimon Schubert 	     tmp_bf_ptr->next = NULL;  \
6845796c8dcSSimon Schubert 	       \
6855796c8dcSSimon Schubert 		 saved_bf_list_end->next = tmp_bf_ptr;  \
6865796c8dcSSimon Schubert 		   saved_bf_list_end = tmp_bf_ptr; \
6875796c8dcSSimon Schubert 		   }
6885796c8dcSSimon Schubert #endif
6895796c8dcSSimon Schubert 
690c50c785cSJohn Marino /* This function frees the entire (.bf,function) list.  */
6915796c8dcSSimon Schubert 
6925796c8dcSSimon Schubert #if 0
6935796c8dcSSimon Schubert static void
6945796c8dcSSimon Schubert clear_bf_list (void)
6955796c8dcSSimon Schubert {
6965796c8dcSSimon Schubert 
6975796c8dcSSimon Schubert   SAVED_BF_PTR tmp = saved_bf_list;
6985796c8dcSSimon Schubert   SAVED_BF_PTR next = NULL;
6995796c8dcSSimon Schubert 
7005796c8dcSSimon Schubert   while (tmp != NULL)
7015796c8dcSSimon Schubert     {
7025796c8dcSSimon Schubert       next = tmp->next;
7035796c8dcSSimon Schubert       xfree (tmp);
7045796c8dcSSimon Schubert       tmp = next;
7055796c8dcSSimon Schubert     }
7065796c8dcSSimon Schubert   saved_bf_list = NULL;
7075796c8dcSSimon Schubert }
7085796c8dcSSimon Schubert #endif
7095796c8dcSSimon Schubert 
7105796c8dcSSimon Schubert int global_remote_debug;
7115796c8dcSSimon Schubert 
7125796c8dcSSimon Schubert #if 0
7135796c8dcSSimon Schubert 
7145796c8dcSSimon Schubert static long
7155796c8dcSSimon Schubert get_bf_for_fcn (long the_function)
7165796c8dcSSimon Schubert {
7175796c8dcSSimon Schubert   SAVED_BF_PTR tmp;
7185796c8dcSSimon Schubert   int nprobes = 0;
7195796c8dcSSimon Schubert 
7205796c8dcSSimon Schubert   /* First use a simple queuing algorithm (i.e. look and see if the
721c50c785cSJohn Marino      item at the head of the queue is the one you want).  */
7225796c8dcSSimon Schubert 
7235796c8dcSSimon Schubert   if (saved_bf_list == NULL)
7245796c8dcSSimon Schubert     internal_error (__FILE__, __LINE__,
7255796c8dcSSimon Schubert 		    _("cannot get .bf node off empty list"));
7265796c8dcSSimon Schubert 
7275796c8dcSSimon Schubert   if (current_head_bf_list != NULL)
7285796c8dcSSimon Schubert     if (current_head_bf_list->symnum_fcn == the_function)
7295796c8dcSSimon Schubert       {
7305796c8dcSSimon Schubert 	if (global_remote_debug)
7315796c8dcSSimon Schubert 	  fprintf_unfiltered (gdb_stderr, "*");
7325796c8dcSSimon Schubert 
7335796c8dcSSimon Schubert 	tmp = current_head_bf_list;
7345796c8dcSSimon Schubert 	current_head_bf_list = current_head_bf_list->next;
7355796c8dcSSimon Schubert 	return (tmp->symnum_bf);
7365796c8dcSSimon Schubert       }
7375796c8dcSSimon Schubert 
7385796c8dcSSimon Schubert   /* If the above did not work (probably because #line directives were
7395796c8dcSSimon Schubert      used in the sourcefile and they messed up our internal tables) we now do
740c50c785cSJohn Marino      the ugly linear scan.  */
7415796c8dcSSimon Schubert 
7425796c8dcSSimon Schubert   if (global_remote_debug)
7435796c8dcSSimon Schubert     fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n");
7445796c8dcSSimon Schubert 
7455796c8dcSSimon Schubert   nprobes = 0;
7465796c8dcSSimon Schubert   tmp = saved_bf_list;
7475796c8dcSSimon Schubert   while (tmp != NULL)
7485796c8dcSSimon Schubert     {
7495796c8dcSSimon Schubert       nprobes++;
7505796c8dcSSimon Schubert       if (tmp->symnum_fcn == the_function)
7515796c8dcSSimon Schubert 	{
7525796c8dcSSimon Schubert 	  if (global_remote_debug)
7535796c8dcSSimon Schubert 	    fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes);
7545796c8dcSSimon Schubert 	  current_head_bf_list = tmp->next;
7555796c8dcSSimon Schubert 	  return (tmp->symnum_bf);
7565796c8dcSSimon Schubert 	}
7575796c8dcSSimon Schubert       tmp = tmp->next;
7585796c8dcSSimon Schubert     }
7595796c8dcSSimon Schubert 
7605796c8dcSSimon Schubert   return (-1);
7615796c8dcSSimon Schubert }
7625796c8dcSSimon Schubert 
7635796c8dcSSimon Schubert static SAVED_FUNCTION_PTR saved_function_list = NULL;
7645796c8dcSSimon Schubert static SAVED_FUNCTION_PTR saved_function_list_end = NULL;
7655796c8dcSSimon Schubert 
7665796c8dcSSimon Schubert static void
7675796c8dcSSimon Schubert clear_function_list (void)
7685796c8dcSSimon Schubert {
7695796c8dcSSimon Schubert   SAVED_FUNCTION_PTR tmp = saved_function_list;
7705796c8dcSSimon Schubert   SAVED_FUNCTION_PTR next = NULL;
7715796c8dcSSimon Schubert 
7725796c8dcSSimon Schubert   while (tmp != NULL)
7735796c8dcSSimon Schubert     {
7745796c8dcSSimon Schubert       next = tmp->next;
7755796c8dcSSimon Schubert       xfree (tmp);
7765796c8dcSSimon Schubert       tmp = next;
7775796c8dcSSimon Schubert     }
7785796c8dcSSimon Schubert 
7795796c8dcSSimon Schubert   saved_function_list = NULL;
7805796c8dcSSimon Schubert }
7815796c8dcSSimon Schubert #endif
782