15796c8dcSSimon Schubert /* Fortran language support routines for GDB, the GNU debugger. 25796c8dcSSimon Schubert 35796c8dcSSimon Schubert Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 4*c50c785cSJohn Marino 2004, 2005, 2007, 2008, 2009, 2010, 2011 Free Software 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" 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert 375796c8dcSSimon Schubert /* Following is dubious stuff that had been in the xcoff reader. */ 385796c8dcSSimon Schubert 395796c8dcSSimon Schubert struct saved_fcn 405796c8dcSSimon Schubert { 41*c50c785cSJohn Marino long line_offset; /* Line offset for function. */ 425796c8dcSSimon Schubert struct saved_fcn *next; 435796c8dcSSimon Schubert }; 445796c8dcSSimon Schubert 455796c8dcSSimon Schubert 465796c8dcSSimon Schubert struct saved_bf_symnum 475796c8dcSSimon Schubert { 48*c50c785cSJohn Marino long symnum_fcn; /* Symnum of function (i.e. .function 49*c50c785cSJohn Marino directive). */ 50*c50c785cSJohn Marino long symnum_bf; /* Symnum of .bf for this function. */ 515796c8dcSSimon Schubert struct saved_bf_symnum *next; 525796c8dcSSimon Schubert }; 535796c8dcSSimon Schubert 545796c8dcSSimon Schubert typedef struct saved_fcn SAVED_FUNCTION, *SAVED_FUNCTION_PTR; 555796c8dcSSimon Schubert typedef struct saved_bf_symnum SAVED_BF, *SAVED_BF_PTR; 565796c8dcSSimon Schubert 575796c8dcSSimon Schubert /* Local functions */ 585796c8dcSSimon Schubert 595796c8dcSSimon Schubert extern void _initialize_f_language (void); 605796c8dcSSimon Schubert #if 0 615796c8dcSSimon Schubert static void clear_function_list (void); 625796c8dcSSimon Schubert static long get_bf_for_fcn (long); 635796c8dcSSimon Schubert static void clear_bf_list (void); 645796c8dcSSimon Schubert static void patch_all_commons_by_name (char *, CORE_ADDR, int); 655796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR find_first_common_named (char *); 665796c8dcSSimon Schubert static void add_common_entry (struct symbol *); 675796c8dcSSimon Schubert static void add_common_block (char *, CORE_ADDR, int, char *); 685796c8dcSSimon Schubert static SAVED_FUNCTION *allocate_saved_function_node (void); 695796c8dcSSimon Schubert static SAVED_BF_PTR allocate_saved_bf_node (void); 705796c8dcSSimon Schubert static COMMON_ENTRY_PTR allocate_common_entry_node (void); 715796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void); 725796c8dcSSimon Schubert static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int); 735796c8dcSSimon Schubert #endif 745796c8dcSSimon Schubert 755796c8dcSSimon Schubert static void f_printchar (int c, struct type *type, struct ui_file * stream); 765796c8dcSSimon Schubert static void f_emit_char (int c, struct type *type, 775796c8dcSSimon Schubert struct ui_file * stream, int quoter); 785796c8dcSSimon Schubert 795796c8dcSSimon Schubert /* Print the character C on STREAM as part of the contents of a literal 805796c8dcSSimon Schubert string whose delimiter is QUOTER. Note that that format for printing 815796c8dcSSimon Schubert characters and strings is language specific. 825796c8dcSSimon Schubert FIXME: This is a copy of the same function from c-exp.y. It should 835796c8dcSSimon Schubert be replaced with a true F77 version. */ 845796c8dcSSimon Schubert 855796c8dcSSimon Schubert static void 865796c8dcSSimon Schubert f_emit_char (int c, struct type *type, struct ui_file *stream, int quoter) 875796c8dcSSimon Schubert { 88*c50c785cSJohn Marino c &= 0xFF; /* Avoid sign bit follies. */ 895796c8dcSSimon Schubert 905796c8dcSSimon Schubert if (PRINT_LITERAL_FORM (c)) 915796c8dcSSimon Schubert { 925796c8dcSSimon Schubert if (c == '\\' || c == quoter) 935796c8dcSSimon Schubert fputs_filtered ("\\", stream); 945796c8dcSSimon Schubert fprintf_filtered (stream, "%c", c); 955796c8dcSSimon Schubert } 965796c8dcSSimon Schubert else 975796c8dcSSimon Schubert { 985796c8dcSSimon Schubert switch (c) 995796c8dcSSimon Schubert { 1005796c8dcSSimon Schubert case '\n': 1015796c8dcSSimon Schubert fputs_filtered ("\\n", stream); 1025796c8dcSSimon Schubert break; 1035796c8dcSSimon Schubert case '\b': 1045796c8dcSSimon Schubert fputs_filtered ("\\b", stream); 1055796c8dcSSimon Schubert break; 1065796c8dcSSimon Schubert case '\t': 1075796c8dcSSimon Schubert fputs_filtered ("\\t", stream); 1085796c8dcSSimon Schubert break; 1095796c8dcSSimon Schubert case '\f': 1105796c8dcSSimon Schubert fputs_filtered ("\\f", stream); 1115796c8dcSSimon Schubert break; 1125796c8dcSSimon Schubert case '\r': 1135796c8dcSSimon Schubert fputs_filtered ("\\r", stream); 1145796c8dcSSimon Schubert break; 1155796c8dcSSimon Schubert case '\033': 1165796c8dcSSimon Schubert fputs_filtered ("\\e", stream); 1175796c8dcSSimon Schubert break; 1185796c8dcSSimon Schubert case '\007': 1195796c8dcSSimon Schubert fputs_filtered ("\\a", stream); 1205796c8dcSSimon Schubert break; 1215796c8dcSSimon Schubert default: 1225796c8dcSSimon Schubert fprintf_filtered (stream, "\\%.3o", (unsigned int) c); 1235796c8dcSSimon Schubert break; 1245796c8dcSSimon Schubert } 1255796c8dcSSimon Schubert } 1265796c8dcSSimon Schubert } 1275796c8dcSSimon Schubert 1285796c8dcSSimon Schubert /* FIXME: This is a copy of the same function from c-exp.y. It should 1295796c8dcSSimon Schubert be replaced with a true F77version. */ 1305796c8dcSSimon Schubert 1315796c8dcSSimon Schubert static void 1325796c8dcSSimon Schubert f_printchar (int c, struct type *type, struct ui_file *stream) 1335796c8dcSSimon Schubert { 1345796c8dcSSimon Schubert fputs_filtered ("'", stream); 1355796c8dcSSimon Schubert LA_EMIT_CHAR (c, type, stream, '\''); 1365796c8dcSSimon Schubert fputs_filtered ("'", stream); 1375796c8dcSSimon Schubert } 1385796c8dcSSimon Schubert 1395796c8dcSSimon Schubert /* Print the character string STRING, printing at most LENGTH characters. 1405796c8dcSSimon Schubert Printing stops early if the number hits print_max; repeat counts 1415796c8dcSSimon Schubert are printed as appropriate. Print ellipses at the end if we 1425796c8dcSSimon Schubert had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. 1435796c8dcSSimon Schubert FIXME: This is a copy of the same function from c-exp.y. It should 1445796c8dcSSimon Schubert be replaced with a true F77 version. */ 1455796c8dcSSimon Schubert 1465796c8dcSSimon Schubert static void 1475796c8dcSSimon Schubert f_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string, 148cf7f2e2dSJohn Marino unsigned int length, const char *encoding, int force_ellipses, 1495796c8dcSSimon Schubert const struct value_print_options *options) 1505796c8dcSSimon Schubert { 1515796c8dcSSimon Schubert unsigned int i; 1525796c8dcSSimon Schubert unsigned int things_printed = 0; 1535796c8dcSSimon Schubert int in_quotes = 0; 1545796c8dcSSimon Schubert int need_comma = 0; 1555796c8dcSSimon Schubert 1565796c8dcSSimon Schubert if (length == 0) 1575796c8dcSSimon Schubert { 1585796c8dcSSimon Schubert fputs_filtered ("''", gdb_stdout); 1595796c8dcSSimon Schubert return; 1605796c8dcSSimon Schubert } 1615796c8dcSSimon Schubert 1625796c8dcSSimon Schubert for (i = 0; i < length && things_printed < options->print_max; ++i) 1635796c8dcSSimon Schubert { 1645796c8dcSSimon Schubert /* Position of the character we are examining 1655796c8dcSSimon Schubert to see whether it is repeated. */ 1665796c8dcSSimon Schubert unsigned int rep1; 1675796c8dcSSimon Schubert /* Number of repetitions we have detected so far. */ 1685796c8dcSSimon Schubert unsigned int reps; 1695796c8dcSSimon Schubert 1705796c8dcSSimon Schubert QUIT; 1715796c8dcSSimon Schubert 1725796c8dcSSimon Schubert if (need_comma) 1735796c8dcSSimon Schubert { 1745796c8dcSSimon Schubert fputs_filtered (", ", stream); 1755796c8dcSSimon Schubert need_comma = 0; 1765796c8dcSSimon Schubert } 1775796c8dcSSimon Schubert 1785796c8dcSSimon Schubert rep1 = i + 1; 1795796c8dcSSimon Schubert reps = 1; 1805796c8dcSSimon Schubert while (rep1 < length && string[rep1] == string[i]) 1815796c8dcSSimon Schubert { 1825796c8dcSSimon Schubert ++rep1; 1835796c8dcSSimon Schubert ++reps; 1845796c8dcSSimon Schubert } 1855796c8dcSSimon Schubert 1865796c8dcSSimon Schubert if (reps > options->repeat_count_threshold) 1875796c8dcSSimon Schubert { 1885796c8dcSSimon Schubert if (in_quotes) 1895796c8dcSSimon Schubert { 1905796c8dcSSimon Schubert if (options->inspect_it) 1915796c8dcSSimon Schubert fputs_filtered ("\\', ", stream); 1925796c8dcSSimon Schubert else 1935796c8dcSSimon Schubert fputs_filtered ("', ", stream); 1945796c8dcSSimon Schubert in_quotes = 0; 1955796c8dcSSimon Schubert } 1965796c8dcSSimon Schubert f_printchar (string[i], type, stream); 1975796c8dcSSimon Schubert fprintf_filtered (stream, " <repeats %u times>", reps); 1985796c8dcSSimon Schubert i = rep1 - 1; 1995796c8dcSSimon Schubert things_printed += options->repeat_count_threshold; 2005796c8dcSSimon Schubert need_comma = 1; 2015796c8dcSSimon Schubert } 2025796c8dcSSimon Schubert else 2035796c8dcSSimon Schubert { 2045796c8dcSSimon Schubert if (!in_quotes) 2055796c8dcSSimon Schubert { 2065796c8dcSSimon Schubert if (options->inspect_it) 2075796c8dcSSimon Schubert fputs_filtered ("\\'", stream); 2085796c8dcSSimon Schubert else 2095796c8dcSSimon Schubert fputs_filtered ("'", stream); 2105796c8dcSSimon Schubert in_quotes = 1; 2115796c8dcSSimon Schubert } 2125796c8dcSSimon Schubert LA_EMIT_CHAR (string[i], type, stream, '"'); 2135796c8dcSSimon Schubert ++things_printed; 2145796c8dcSSimon Schubert } 2155796c8dcSSimon Schubert } 2165796c8dcSSimon Schubert 2175796c8dcSSimon Schubert /* Terminate the quotes if necessary. */ 2185796c8dcSSimon Schubert if (in_quotes) 2195796c8dcSSimon Schubert { 2205796c8dcSSimon Schubert if (options->inspect_it) 2215796c8dcSSimon Schubert fputs_filtered ("\\'", stream); 2225796c8dcSSimon Schubert else 2235796c8dcSSimon Schubert fputs_filtered ("'", stream); 2245796c8dcSSimon Schubert } 2255796c8dcSSimon Schubert 2265796c8dcSSimon Schubert if (force_ellipses || i < length) 2275796c8dcSSimon Schubert fputs_filtered ("...", stream); 2285796c8dcSSimon Schubert } 2295796c8dcSSimon Schubert 2305796c8dcSSimon Schubert 2315796c8dcSSimon Schubert /* Table of operators and their precedences for printing expressions. */ 2325796c8dcSSimon Schubert 2335796c8dcSSimon Schubert static const struct op_print f_op_print_tab[] = 2345796c8dcSSimon Schubert { 2355796c8dcSSimon Schubert {"+", BINOP_ADD, PREC_ADD, 0}, 2365796c8dcSSimon Schubert {"+", UNOP_PLUS, PREC_PREFIX, 0}, 2375796c8dcSSimon Schubert {"-", BINOP_SUB, PREC_ADD, 0}, 2385796c8dcSSimon Schubert {"-", UNOP_NEG, PREC_PREFIX, 0}, 2395796c8dcSSimon Schubert {"*", BINOP_MUL, PREC_MUL, 0}, 2405796c8dcSSimon Schubert {"/", BINOP_DIV, PREC_MUL, 0}, 2415796c8dcSSimon Schubert {"DIV", BINOP_INTDIV, PREC_MUL, 0}, 2425796c8dcSSimon Schubert {"MOD", BINOP_REM, PREC_MUL, 0}, 2435796c8dcSSimon Schubert {"=", BINOP_ASSIGN, PREC_ASSIGN, 1}, 2445796c8dcSSimon Schubert {".OR.", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0}, 2455796c8dcSSimon Schubert {".AND.", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0}, 2465796c8dcSSimon Schubert {".NOT.", UNOP_LOGICAL_NOT, PREC_PREFIX, 0}, 2475796c8dcSSimon Schubert {".EQ.", BINOP_EQUAL, PREC_EQUAL, 0}, 2485796c8dcSSimon Schubert {".NE.", BINOP_NOTEQUAL, PREC_EQUAL, 0}, 2495796c8dcSSimon Schubert {".LE.", BINOP_LEQ, PREC_ORDER, 0}, 2505796c8dcSSimon Schubert {".GE.", BINOP_GEQ, PREC_ORDER, 0}, 2515796c8dcSSimon Schubert {".GT.", BINOP_GTR, PREC_ORDER, 0}, 2525796c8dcSSimon Schubert {".LT.", BINOP_LESS, PREC_ORDER, 0}, 2535796c8dcSSimon Schubert {"**", UNOP_IND, PREC_PREFIX, 0}, 2545796c8dcSSimon Schubert {"@", BINOP_REPEAT, PREC_REPEAT, 0}, 2555796c8dcSSimon Schubert {NULL, 0, 0, 0} 2565796c8dcSSimon Schubert }; 2575796c8dcSSimon Schubert 2585796c8dcSSimon Schubert enum f_primitive_types { 2595796c8dcSSimon Schubert f_primitive_type_character, 2605796c8dcSSimon Schubert f_primitive_type_logical, 2615796c8dcSSimon Schubert f_primitive_type_logical_s1, 2625796c8dcSSimon Schubert f_primitive_type_logical_s2, 263cf7f2e2dSJohn Marino f_primitive_type_logical_s8, 2645796c8dcSSimon Schubert f_primitive_type_integer, 2655796c8dcSSimon Schubert f_primitive_type_integer_s2, 2665796c8dcSSimon Schubert f_primitive_type_real, 2675796c8dcSSimon Schubert f_primitive_type_real_s8, 2685796c8dcSSimon Schubert f_primitive_type_real_s16, 2695796c8dcSSimon Schubert f_primitive_type_complex_s8, 2705796c8dcSSimon Schubert f_primitive_type_complex_s16, 2715796c8dcSSimon Schubert f_primitive_type_void, 2725796c8dcSSimon Schubert nr_f_primitive_types 2735796c8dcSSimon Schubert }; 2745796c8dcSSimon Schubert 2755796c8dcSSimon Schubert static void 2765796c8dcSSimon Schubert f_language_arch_info (struct gdbarch *gdbarch, 2775796c8dcSSimon Schubert struct language_arch_info *lai) 2785796c8dcSSimon Schubert { 2795796c8dcSSimon Schubert const struct builtin_f_type *builtin = builtin_f_type (gdbarch); 2805796c8dcSSimon Schubert 2815796c8dcSSimon Schubert lai->string_char_type = builtin->builtin_character; 2825796c8dcSSimon Schubert lai->primitive_type_vector 2835796c8dcSSimon Schubert = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_f_primitive_types + 1, 2845796c8dcSSimon Schubert struct type *); 2855796c8dcSSimon Schubert 2865796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_character] 2875796c8dcSSimon Schubert = builtin->builtin_character; 2885796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_logical] 2895796c8dcSSimon Schubert = builtin->builtin_logical; 2905796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_logical_s1] 2915796c8dcSSimon Schubert = builtin->builtin_logical_s1; 2925796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_logical_s2] 2935796c8dcSSimon Schubert = builtin->builtin_logical_s2; 294cf7f2e2dSJohn Marino lai->primitive_type_vector [f_primitive_type_logical_s8] 295cf7f2e2dSJohn Marino = builtin->builtin_logical_s8; 2965796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_real] 2975796c8dcSSimon Schubert = builtin->builtin_real; 2985796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_real_s8] 2995796c8dcSSimon Schubert = builtin->builtin_real_s8; 3005796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_real_s16] 3015796c8dcSSimon Schubert = builtin->builtin_real_s16; 3025796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_complex_s8] 3035796c8dcSSimon Schubert = builtin->builtin_complex_s8; 3045796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_complex_s16] 3055796c8dcSSimon Schubert = builtin->builtin_complex_s16; 3065796c8dcSSimon Schubert lai->primitive_type_vector [f_primitive_type_void] 3075796c8dcSSimon Schubert = builtin->builtin_void; 3085796c8dcSSimon Schubert 3095796c8dcSSimon Schubert lai->bool_type_symbol = "logical"; 3105796c8dcSSimon Schubert lai->bool_type_default = builtin->builtin_logical_s2; 3115796c8dcSSimon Schubert } 3125796c8dcSSimon Schubert 313cf7f2e2dSJohn Marino /* Remove the modules separator :: from the default break list. */ 314cf7f2e2dSJohn Marino 315cf7f2e2dSJohn Marino static char * 316cf7f2e2dSJohn Marino f_word_break_characters (void) 317cf7f2e2dSJohn Marino { 318cf7f2e2dSJohn Marino static char *retval; 319cf7f2e2dSJohn Marino 320cf7f2e2dSJohn Marino if (!retval) 321cf7f2e2dSJohn Marino { 322cf7f2e2dSJohn Marino char *s; 323cf7f2e2dSJohn Marino 324cf7f2e2dSJohn Marino retval = xstrdup (default_word_break_characters ()); 325cf7f2e2dSJohn Marino s = strchr (retval, ':'); 326cf7f2e2dSJohn Marino if (s) 327cf7f2e2dSJohn Marino { 328cf7f2e2dSJohn Marino char *last_char = &s[strlen (s) - 1]; 329cf7f2e2dSJohn Marino 330cf7f2e2dSJohn Marino *s = *last_char; 331cf7f2e2dSJohn Marino *last_char = 0; 332cf7f2e2dSJohn Marino } 333cf7f2e2dSJohn Marino } 334cf7f2e2dSJohn Marino return retval; 335cf7f2e2dSJohn Marino } 336cf7f2e2dSJohn Marino 337*c50c785cSJohn Marino /* Consider the modules separator :: as a valid symbol name character 338*c50c785cSJohn Marino class. */ 339cf7f2e2dSJohn Marino 340cf7f2e2dSJohn Marino static char ** 341cf7f2e2dSJohn Marino f_make_symbol_completion_list (char *text, char *word) 342cf7f2e2dSJohn Marino { 343cf7f2e2dSJohn Marino return default_make_symbol_completion_list_break_on (text, word, ":"); 344cf7f2e2dSJohn Marino } 345cf7f2e2dSJohn Marino 3465796c8dcSSimon Schubert /* This is declared in c-lang.h but it is silly to import that file for what 3475796c8dcSSimon Schubert is already just a hack. */ 3485796c8dcSSimon Schubert extern int c_value_print (struct value *, struct ui_file *, 3495796c8dcSSimon Schubert const struct value_print_options *); 3505796c8dcSSimon Schubert 3515796c8dcSSimon Schubert const struct language_defn f_language_defn = 3525796c8dcSSimon Schubert { 3535796c8dcSSimon Schubert "fortran", 3545796c8dcSSimon Schubert language_fortran, 3555796c8dcSSimon Schubert range_check_on, 3565796c8dcSSimon Schubert type_check_on, 3575796c8dcSSimon Schubert case_sensitive_off, 3585796c8dcSSimon Schubert array_column_major, 3595796c8dcSSimon Schubert macro_expansion_no, 3605796c8dcSSimon Schubert &exp_descriptor_standard, 3615796c8dcSSimon Schubert f_parse, /* parser */ 3625796c8dcSSimon Schubert f_error, /* parser error function */ 3635796c8dcSSimon Schubert null_post_parser, 3645796c8dcSSimon Schubert f_printchar, /* Print character constant */ 3655796c8dcSSimon Schubert f_printstr, /* function to print string constant */ 3665796c8dcSSimon Schubert f_emit_char, /* Function to print a single character */ 3675796c8dcSSimon Schubert f_print_type, /* Print a type using appropriate syntax */ 3685796c8dcSSimon Schubert default_print_typedef, /* Print a typedef using appropriate syntax */ 3695796c8dcSSimon Schubert f_val_print, /* Print a value using appropriate syntax */ 3705796c8dcSSimon Schubert c_value_print, /* FIXME */ 3715796c8dcSSimon Schubert NULL, /* Language specific skip_trampoline */ 3725796c8dcSSimon Schubert NULL, /* name_of_this */ 373cf7f2e2dSJohn Marino cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ 3745796c8dcSSimon Schubert basic_lookup_transparent_type,/* lookup_transparent_type */ 3755796c8dcSSimon Schubert NULL, /* Language specific symbol demangler */ 376*c50c785cSJohn Marino NULL, /* Language specific 377*c50c785cSJohn Marino class_name_from_physname */ 3785796c8dcSSimon Schubert f_op_print_tab, /* expression operators for printing */ 3795796c8dcSSimon Schubert 0, /* arrays are first-class (not c-style) */ 3805796c8dcSSimon Schubert 1, /* String lower bound */ 381cf7f2e2dSJohn Marino f_word_break_characters, 382cf7f2e2dSJohn Marino f_make_symbol_completion_list, 3835796c8dcSSimon Schubert f_language_arch_info, 3845796c8dcSSimon Schubert default_print_array_index, 3855796c8dcSSimon Schubert default_pass_by_reference, 3865796c8dcSSimon Schubert default_get_string, 3875796c8dcSSimon Schubert LANG_MAGIC 3885796c8dcSSimon Schubert }; 3895796c8dcSSimon Schubert 3905796c8dcSSimon Schubert static void * 3915796c8dcSSimon Schubert build_fortran_types (struct gdbarch *gdbarch) 3925796c8dcSSimon Schubert { 3935796c8dcSSimon Schubert struct builtin_f_type *builtin_f_type 3945796c8dcSSimon Schubert = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_f_type); 3955796c8dcSSimon Schubert 3965796c8dcSSimon Schubert builtin_f_type->builtin_void 3975796c8dcSSimon Schubert = arch_type (gdbarch, TYPE_CODE_VOID, 1, "VOID"); 3985796c8dcSSimon Schubert 3995796c8dcSSimon Schubert builtin_f_type->builtin_character 4005796c8dcSSimon Schubert = arch_integer_type (gdbarch, TARGET_CHAR_BIT, 0, "character"); 4015796c8dcSSimon Schubert 4025796c8dcSSimon Schubert builtin_f_type->builtin_logical_s1 4035796c8dcSSimon Schubert = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1"); 4045796c8dcSSimon Schubert 4055796c8dcSSimon Schubert builtin_f_type->builtin_integer_s2 4065796c8dcSSimon Schubert = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch), 0, 4075796c8dcSSimon Schubert "integer*2"); 4085796c8dcSSimon Schubert 4095796c8dcSSimon Schubert builtin_f_type->builtin_logical_s2 4105796c8dcSSimon Schubert = arch_boolean_type (gdbarch, gdbarch_short_bit (gdbarch), 1, 4115796c8dcSSimon Schubert "logical*2"); 4125796c8dcSSimon Schubert 413cf7f2e2dSJohn Marino builtin_f_type->builtin_logical_s8 414cf7f2e2dSJohn Marino = arch_boolean_type (gdbarch, gdbarch_long_long_bit (gdbarch), 1, 415cf7f2e2dSJohn Marino "logical*8"); 416cf7f2e2dSJohn Marino 4175796c8dcSSimon Schubert builtin_f_type->builtin_integer 4185796c8dcSSimon Schubert = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, 4195796c8dcSSimon Schubert "integer"); 4205796c8dcSSimon Schubert 4215796c8dcSSimon Schubert builtin_f_type->builtin_logical 4225796c8dcSSimon Schubert = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, 4235796c8dcSSimon Schubert "logical*4"); 4245796c8dcSSimon Schubert 4255796c8dcSSimon Schubert builtin_f_type->builtin_real 4265796c8dcSSimon Schubert = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), 4275796c8dcSSimon Schubert "real", NULL); 4285796c8dcSSimon Schubert builtin_f_type->builtin_real_s8 4295796c8dcSSimon Schubert = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch), 4305796c8dcSSimon Schubert "real*8", NULL); 4315796c8dcSSimon Schubert builtin_f_type->builtin_real_s16 4325796c8dcSSimon Schubert = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch), 4335796c8dcSSimon Schubert "real*16", NULL); 4345796c8dcSSimon Schubert 4355796c8dcSSimon Schubert builtin_f_type->builtin_complex_s8 4365796c8dcSSimon Schubert = arch_complex_type (gdbarch, "complex*8", 4375796c8dcSSimon Schubert builtin_f_type->builtin_real); 4385796c8dcSSimon Schubert builtin_f_type->builtin_complex_s16 4395796c8dcSSimon Schubert = arch_complex_type (gdbarch, "complex*16", 4405796c8dcSSimon Schubert builtin_f_type->builtin_real_s8); 4415796c8dcSSimon Schubert builtin_f_type->builtin_complex_s32 4425796c8dcSSimon Schubert = arch_complex_type (gdbarch, "complex*32", 4435796c8dcSSimon Schubert builtin_f_type->builtin_real_s16); 4445796c8dcSSimon Schubert 4455796c8dcSSimon Schubert return builtin_f_type; 4465796c8dcSSimon Schubert } 4475796c8dcSSimon Schubert 4485796c8dcSSimon Schubert static struct gdbarch_data *f_type_data; 4495796c8dcSSimon Schubert 4505796c8dcSSimon Schubert const struct builtin_f_type * 4515796c8dcSSimon Schubert builtin_f_type (struct gdbarch *gdbarch) 4525796c8dcSSimon Schubert { 4535796c8dcSSimon Schubert return gdbarch_data (gdbarch, f_type_data); 4545796c8dcSSimon Schubert } 4555796c8dcSSimon Schubert 4565796c8dcSSimon Schubert void 4575796c8dcSSimon Schubert _initialize_f_language (void) 4585796c8dcSSimon Schubert { 4595796c8dcSSimon Schubert f_type_data = gdbarch_data_register_post_init (build_fortran_types); 4605796c8dcSSimon Schubert 4615796c8dcSSimon Schubert add_language (&f_language_defn); 4625796c8dcSSimon Schubert } 4635796c8dcSSimon Schubert 4645796c8dcSSimon Schubert #if 0 4655796c8dcSSimon Schubert static SAVED_BF_PTR 4665796c8dcSSimon Schubert allocate_saved_bf_node (void) 4675796c8dcSSimon Schubert { 4685796c8dcSSimon Schubert SAVED_BF_PTR new; 4695796c8dcSSimon Schubert 4705796c8dcSSimon Schubert new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF)); 4715796c8dcSSimon Schubert return (new); 4725796c8dcSSimon Schubert } 4735796c8dcSSimon Schubert 4745796c8dcSSimon Schubert static SAVED_FUNCTION * 4755796c8dcSSimon Schubert allocate_saved_function_node (void) 4765796c8dcSSimon Schubert { 4775796c8dcSSimon Schubert SAVED_FUNCTION *new; 4785796c8dcSSimon Schubert 4795796c8dcSSimon Schubert new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION)); 4805796c8dcSSimon Schubert return (new); 4815796c8dcSSimon Schubert } 4825796c8dcSSimon Schubert 4835796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR 4845796c8dcSSimon Schubert allocate_saved_f77_common_node (void) 4855796c8dcSSimon Schubert { 4865796c8dcSSimon Schubert SAVED_F77_COMMON_PTR new; 4875796c8dcSSimon Schubert 4885796c8dcSSimon Schubert new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON)); 4895796c8dcSSimon Schubert return (new); 4905796c8dcSSimon Schubert } 4915796c8dcSSimon Schubert 4925796c8dcSSimon Schubert static COMMON_ENTRY_PTR 4935796c8dcSSimon Schubert allocate_common_entry_node (void) 4945796c8dcSSimon Schubert { 4955796c8dcSSimon Schubert COMMON_ENTRY_PTR new; 4965796c8dcSSimon Schubert 4975796c8dcSSimon Schubert new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY)); 4985796c8dcSSimon Schubert return (new); 4995796c8dcSSimon Schubert } 5005796c8dcSSimon Schubert #endif 5015796c8dcSSimon Schubert 5025796c8dcSSimon Schubert SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */ 5035796c8dcSSimon Schubert SAVED_F77_COMMON_PTR tail_common_list = NULL; /* Ptr to last saved COMMON */ 5045796c8dcSSimon Schubert SAVED_F77_COMMON_PTR current_common = NULL; /* Ptr to current COMMON */ 5055796c8dcSSimon Schubert 5065796c8dcSSimon Schubert #if 0 5075796c8dcSSimon Schubert static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function) 5085796c8dcSSimon Schubert list */ 5095796c8dcSSimon Schubert static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */ 510*c50c785cSJohn Marino static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of 511*c50c785cSJohn Marino above list. */ 5125796c8dcSSimon Schubert 5135796c8dcSSimon Schubert static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use 514*c50c785cSJohn Marino in macros. */ 5155796c8dcSSimon Schubert 5165796c8dcSSimon Schubert /* The following function simply enters a given common block onto 517*c50c785cSJohn Marino the global common block chain. */ 5185796c8dcSSimon Schubert 5195796c8dcSSimon Schubert static void 5205796c8dcSSimon Schubert add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab) 5215796c8dcSSimon Schubert { 5225796c8dcSSimon Schubert SAVED_F77_COMMON_PTR tmp; 5235796c8dcSSimon Schubert char *c, *local_copy_func_stab; 5245796c8dcSSimon Schubert 5255796c8dcSSimon Schubert /* If the COMMON block we are trying to add has a blank 5265796c8dcSSimon Schubert name (i.e. "#BLNK_COM") then we set it to __BLANK 5275796c8dcSSimon Schubert because the darn "#" character makes GDB's input 5285796c8dcSSimon Schubert parser have fits. */ 5295796c8dcSSimon Schubert 5305796c8dcSSimon Schubert 5315796c8dcSSimon Schubert if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 5325796c8dcSSimon Schubert || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) 5335796c8dcSSimon Schubert { 5345796c8dcSSimon Schubert 5355796c8dcSSimon Schubert xfree (name); 5365796c8dcSSimon Schubert name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); 5375796c8dcSSimon Schubert strcpy (name, BLANK_COMMON_NAME_LOCAL); 5385796c8dcSSimon Schubert } 5395796c8dcSSimon Schubert 5405796c8dcSSimon Schubert tmp = allocate_saved_f77_common_node (); 5415796c8dcSSimon Schubert 5425796c8dcSSimon Schubert local_copy_func_stab = xmalloc (strlen (func_stab) + 1); 5435796c8dcSSimon Schubert strcpy (local_copy_func_stab, func_stab); 5445796c8dcSSimon Schubert 5455796c8dcSSimon Schubert tmp->name = xmalloc (strlen (name) + 1); 5465796c8dcSSimon Schubert 5475796c8dcSSimon Schubert /* local_copy_func_stab is a stabstring, let us first extract the 5485796c8dcSSimon Schubert function name from the stab by NULLing out the ':' character. */ 5495796c8dcSSimon Schubert 5505796c8dcSSimon Schubert 5515796c8dcSSimon Schubert c = NULL; 5525796c8dcSSimon Schubert c = strchr (local_copy_func_stab, ':'); 5535796c8dcSSimon Schubert 5545796c8dcSSimon Schubert if (c) 5555796c8dcSSimon Schubert *c = '\0'; 5565796c8dcSSimon Schubert else 5575796c8dcSSimon Schubert error (_("Malformed function STAB found in add_common_block()")); 5585796c8dcSSimon Schubert 5595796c8dcSSimon Schubert 5605796c8dcSSimon Schubert tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1); 5615796c8dcSSimon Schubert 5625796c8dcSSimon Schubert strcpy (tmp->owning_function, local_copy_func_stab); 5635796c8dcSSimon Schubert 5645796c8dcSSimon Schubert strcpy (tmp->name, name); 5655796c8dcSSimon Schubert tmp->offset = offset; 5665796c8dcSSimon Schubert tmp->next = NULL; 5675796c8dcSSimon Schubert tmp->entries = NULL; 5685796c8dcSSimon Schubert tmp->secnum = secnum; 5695796c8dcSSimon Schubert 5705796c8dcSSimon Schubert current_common = tmp; 5715796c8dcSSimon Schubert 5725796c8dcSSimon Schubert if (head_common_list == NULL) 5735796c8dcSSimon Schubert { 5745796c8dcSSimon Schubert head_common_list = tail_common_list = tmp; 5755796c8dcSSimon Schubert } 5765796c8dcSSimon Schubert else 5775796c8dcSSimon Schubert { 5785796c8dcSSimon Schubert tail_common_list->next = tmp; 5795796c8dcSSimon Schubert tail_common_list = tmp; 5805796c8dcSSimon Schubert } 5815796c8dcSSimon Schubert } 5825796c8dcSSimon Schubert #endif 5835796c8dcSSimon Schubert 5845796c8dcSSimon Schubert /* The following function simply enters a given common entry onto 5855796c8dcSSimon Schubert the "current_common" block that has been saved away. */ 5865796c8dcSSimon Schubert 5875796c8dcSSimon Schubert #if 0 5885796c8dcSSimon Schubert static void 5895796c8dcSSimon Schubert add_common_entry (struct symbol *entry_sym_ptr) 5905796c8dcSSimon Schubert { 5915796c8dcSSimon Schubert COMMON_ENTRY_PTR tmp; 5925796c8dcSSimon Schubert 5935796c8dcSSimon Schubert 5945796c8dcSSimon Schubert 5955796c8dcSSimon Schubert /* The order of this list is important, since 5965796c8dcSSimon Schubert we expect the entries to appear in decl. 597*c50c785cSJohn Marino order when we later issue "info common" calls. */ 5985796c8dcSSimon Schubert 5995796c8dcSSimon Schubert tmp = allocate_common_entry_node (); 6005796c8dcSSimon Schubert 6015796c8dcSSimon Schubert tmp->next = NULL; 6025796c8dcSSimon Schubert tmp->symbol = entry_sym_ptr; 6035796c8dcSSimon Schubert 6045796c8dcSSimon Schubert if (current_common == NULL) 6055796c8dcSSimon Schubert error (_("Attempt to add COMMON entry with no block open!")); 6065796c8dcSSimon Schubert else 6075796c8dcSSimon Schubert { 6085796c8dcSSimon Schubert if (current_common->entries == NULL) 6095796c8dcSSimon Schubert { 6105796c8dcSSimon Schubert current_common->entries = tmp; 6115796c8dcSSimon Schubert current_common->end_of_entries = tmp; 6125796c8dcSSimon Schubert } 6135796c8dcSSimon Schubert else 6145796c8dcSSimon Schubert { 6155796c8dcSSimon Schubert current_common->end_of_entries->next = tmp; 6165796c8dcSSimon Schubert current_common->end_of_entries = tmp; 6175796c8dcSSimon Schubert } 6185796c8dcSSimon Schubert } 6195796c8dcSSimon Schubert } 6205796c8dcSSimon Schubert #endif 6215796c8dcSSimon Schubert 622*c50c785cSJohn Marino /* This routine finds the first encountred COMMON block named "name". */ 6235796c8dcSSimon Schubert 6245796c8dcSSimon Schubert #if 0 6255796c8dcSSimon Schubert static SAVED_F77_COMMON_PTR 6265796c8dcSSimon Schubert find_first_common_named (char *name) 6275796c8dcSSimon Schubert { 6285796c8dcSSimon Schubert 6295796c8dcSSimon Schubert SAVED_F77_COMMON_PTR tmp; 6305796c8dcSSimon Schubert 6315796c8dcSSimon Schubert tmp = head_common_list; 6325796c8dcSSimon Schubert 6335796c8dcSSimon Schubert while (tmp != NULL) 6345796c8dcSSimon Schubert { 6355796c8dcSSimon Schubert if (strcmp (tmp->name, name) == 0) 6365796c8dcSSimon Schubert return (tmp); 6375796c8dcSSimon Schubert else 6385796c8dcSSimon Schubert tmp = tmp->next; 6395796c8dcSSimon Schubert } 6405796c8dcSSimon Schubert return (NULL); 6415796c8dcSSimon Schubert } 6425796c8dcSSimon Schubert #endif 6435796c8dcSSimon Schubert 6445796c8dcSSimon Schubert /* This routine finds the first encountred COMMON block named "name" 645*c50c785cSJohn Marino that belongs to function funcname. */ 6465796c8dcSSimon Schubert 6475796c8dcSSimon Schubert SAVED_F77_COMMON_PTR 6485796c8dcSSimon Schubert find_common_for_function (char *name, char *funcname) 6495796c8dcSSimon Schubert { 6505796c8dcSSimon Schubert 6515796c8dcSSimon Schubert SAVED_F77_COMMON_PTR tmp; 6525796c8dcSSimon Schubert 6535796c8dcSSimon Schubert tmp = head_common_list; 6545796c8dcSSimon Schubert 6555796c8dcSSimon Schubert while (tmp != NULL) 6565796c8dcSSimon Schubert { 6575796c8dcSSimon Schubert if (strcmp (tmp->name, name) == 0 6585796c8dcSSimon Schubert && strcmp (tmp->owning_function, funcname) == 0) 6595796c8dcSSimon Schubert return (tmp); 6605796c8dcSSimon Schubert else 6615796c8dcSSimon Schubert tmp = tmp->next; 6625796c8dcSSimon Schubert } 6635796c8dcSSimon Schubert return (NULL); 6645796c8dcSSimon Schubert } 6655796c8dcSSimon Schubert 6665796c8dcSSimon Schubert 6675796c8dcSSimon Schubert #if 0 6685796c8dcSSimon Schubert 6695796c8dcSSimon Schubert /* The following function is called to patch up the offsets 6705796c8dcSSimon Schubert for the statics contained in the COMMON block named 6715796c8dcSSimon Schubert "name." */ 6725796c8dcSSimon Schubert 6735796c8dcSSimon Schubert static void 6745796c8dcSSimon Schubert patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum) 6755796c8dcSSimon Schubert { 6765796c8dcSSimon Schubert COMMON_ENTRY_PTR entry; 6775796c8dcSSimon Schubert 6785796c8dcSSimon Schubert blk->offset = offset; /* Keep this around for future use. */ 6795796c8dcSSimon Schubert 6805796c8dcSSimon Schubert entry = blk->entries; 6815796c8dcSSimon Schubert 6825796c8dcSSimon Schubert while (entry != NULL) 6835796c8dcSSimon Schubert { 6845796c8dcSSimon Schubert SYMBOL_VALUE (entry->symbol) += offset; 6855796c8dcSSimon Schubert SYMBOL_SECTION (entry->symbol) = secnum; 6865796c8dcSSimon Schubert 6875796c8dcSSimon Schubert entry = entry->next; 6885796c8dcSSimon Schubert } 6895796c8dcSSimon Schubert blk->secnum = secnum; 6905796c8dcSSimon Schubert } 6915796c8dcSSimon Schubert 6925796c8dcSSimon Schubert /* Patch all commons named "name" that need patching.Since COMMON 6935796c8dcSSimon Schubert blocks occur with relative infrequency, we simply do a linear scan on 6945796c8dcSSimon Schubert the name. Eventually, the best way to do this will be a 6955796c8dcSSimon Schubert hashed-lookup. Secnum is the section number for the .bss section 6965796c8dcSSimon Schubert (which is where common data lives). */ 6975796c8dcSSimon Schubert 6985796c8dcSSimon Schubert static void 6995796c8dcSSimon Schubert patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum) 7005796c8dcSSimon Schubert { 7015796c8dcSSimon Schubert 7025796c8dcSSimon Schubert SAVED_F77_COMMON_PTR tmp; 7035796c8dcSSimon Schubert 7045796c8dcSSimon Schubert /* For blank common blocks, change the canonical reprsentation 7055796c8dcSSimon Schubert of a blank name */ 7065796c8dcSSimon Schubert 7075796c8dcSSimon Schubert if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0 7085796c8dcSSimon Schubert || strcmp (name, BLANK_COMMON_NAME_MF77) == 0) 7095796c8dcSSimon Schubert { 7105796c8dcSSimon Schubert xfree (name); 7115796c8dcSSimon Schubert name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1); 7125796c8dcSSimon Schubert strcpy (name, BLANK_COMMON_NAME_LOCAL); 7135796c8dcSSimon Schubert } 7145796c8dcSSimon Schubert 7155796c8dcSSimon Schubert tmp = head_common_list; 7165796c8dcSSimon Schubert 7175796c8dcSSimon Schubert while (tmp != NULL) 7185796c8dcSSimon Schubert { 7195796c8dcSSimon Schubert if (COMMON_NEEDS_PATCHING (tmp)) 7205796c8dcSSimon Schubert if (strcmp (tmp->name, name) == 0) 7215796c8dcSSimon Schubert patch_common_entries (tmp, offset, secnum); 7225796c8dcSSimon Schubert 7235796c8dcSSimon Schubert tmp = tmp->next; 7245796c8dcSSimon Schubert } 7255796c8dcSSimon Schubert } 7265796c8dcSSimon Schubert #endif 7275796c8dcSSimon Schubert 7285796c8dcSSimon Schubert /* This macro adds the symbol-number for the start of the function 7295796c8dcSSimon Schubert (the symbol number of the .bf) referenced by symnum_fcn to a 7305796c8dcSSimon Schubert list. This list, in reality should be a FIFO queue but since 7315796c8dcSSimon Schubert #line pragmas sometimes cause line ranges to get messed up 7325796c8dcSSimon Schubert we simply create a linear list. This list can then be searched 7335796c8dcSSimon Schubert first by a queueing algorithm and upon failure fall back to 7345796c8dcSSimon Schubert a linear scan. */ 7355796c8dcSSimon Schubert 7365796c8dcSSimon Schubert #if 0 7375796c8dcSSimon Schubert #define ADD_BF_SYMNUM(bf_sym,fcn_sym) \ 7385796c8dcSSimon Schubert \ 7395796c8dcSSimon Schubert if (saved_bf_list == NULL) \ 7405796c8dcSSimon Schubert { \ 7415796c8dcSSimon Schubert tmp_bf_ptr = allocate_saved_bf_node(); \ 7425796c8dcSSimon Schubert \ 7435796c8dcSSimon Schubert tmp_bf_ptr->symnum_bf = (bf_sym); \ 7445796c8dcSSimon Schubert tmp_bf_ptr->symnum_fcn = (fcn_sym); \ 7455796c8dcSSimon Schubert tmp_bf_ptr->next = NULL; \ 7465796c8dcSSimon Schubert \ 7475796c8dcSSimon Schubert current_head_bf_list = saved_bf_list = tmp_bf_ptr; \ 7485796c8dcSSimon Schubert saved_bf_list_end = tmp_bf_ptr; \ 7495796c8dcSSimon Schubert } \ 7505796c8dcSSimon Schubert else \ 7515796c8dcSSimon Schubert { \ 7525796c8dcSSimon Schubert tmp_bf_ptr = allocate_saved_bf_node(); \ 7535796c8dcSSimon Schubert \ 7545796c8dcSSimon Schubert tmp_bf_ptr->symnum_bf = (bf_sym); \ 7555796c8dcSSimon Schubert tmp_bf_ptr->symnum_fcn = (fcn_sym); \ 7565796c8dcSSimon Schubert tmp_bf_ptr->next = NULL; \ 7575796c8dcSSimon Schubert \ 7585796c8dcSSimon Schubert saved_bf_list_end->next = tmp_bf_ptr; \ 7595796c8dcSSimon Schubert saved_bf_list_end = tmp_bf_ptr; \ 7605796c8dcSSimon Schubert } 7615796c8dcSSimon Schubert #endif 7625796c8dcSSimon Schubert 763*c50c785cSJohn Marino /* This function frees the entire (.bf,function) list. */ 7645796c8dcSSimon Schubert 7655796c8dcSSimon Schubert #if 0 7665796c8dcSSimon Schubert static void 7675796c8dcSSimon Schubert clear_bf_list (void) 7685796c8dcSSimon Schubert { 7695796c8dcSSimon Schubert 7705796c8dcSSimon Schubert SAVED_BF_PTR tmp = saved_bf_list; 7715796c8dcSSimon Schubert SAVED_BF_PTR next = NULL; 7725796c8dcSSimon Schubert 7735796c8dcSSimon Schubert while (tmp != NULL) 7745796c8dcSSimon Schubert { 7755796c8dcSSimon Schubert next = tmp->next; 7765796c8dcSSimon Schubert xfree (tmp); 7775796c8dcSSimon Schubert tmp = next; 7785796c8dcSSimon Schubert } 7795796c8dcSSimon Schubert saved_bf_list = NULL; 7805796c8dcSSimon Schubert } 7815796c8dcSSimon Schubert #endif 7825796c8dcSSimon Schubert 7835796c8dcSSimon Schubert int global_remote_debug; 7845796c8dcSSimon Schubert 7855796c8dcSSimon Schubert #if 0 7865796c8dcSSimon Schubert 7875796c8dcSSimon Schubert static long 7885796c8dcSSimon Schubert get_bf_for_fcn (long the_function) 7895796c8dcSSimon Schubert { 7905796c8dcSSimon Schubert SAVED_BF_PTR tmp; 7915796c8dcSSimon Schubert int nprobes = 0; 7925796c8dcSSimon Schubert 7935796c8dcSSimon Schubert /* First use a simple queuing algorithm (i.e. look and see if the 794*c50c785cSJohn Marino item at the head of the queue is the one you want). */ 7955796c8dcSSimon Schubert 7965796c8dcSSimon Schubert if (saved_bf_list == NULL) 7975796c8dcSSimon Schubert internal_error (__FILE__, __LINE__, 7985796c8dcSSimon Schubert _("cannot get .bf node off empty list")); 7995796c8dcSSimon Schubert 8005796c8dcSSimon Schubert if (current_head_bf_list != NULL) 8015796c8dcSSimon Schubert if (current_head_bf_list->symnum_fcn == the_function) 8025796c8dcSSimon Schubert { 8035796c8dcSSimon Schubert if (global_remote_debug) 8045796c8dcSSimon Schubert fprintf_unfiltered (gdb_stderr, "*"); 8055796c8dcSSimon Schubert 8065796c8dcSSimon Schubert tmp = current_head_bf_list; 8075796c8dcSSimon Schubert current_head_bf_list = current_head_bf_list->next; 8085796c8dcSSimon Schubert return (tmp->symnum_bf); 8095796c8dcSSimon Schubert } 8105796c8dcSSimon Schubert 8115796c8dcSSimon Schubert /* If the above did not work (probably because #line directives were 8125796c8dcSSimon Schubert used in the sourcefile and they messed up our internal tables) we now do 813*c50c785cSJohn Marino the ugly linear scan. */ 8145796c8dcSSimon Schubert 8155796c8dcSSimon Schubert if (global_remote_debug) 8165796c8dcSSimon Schubert fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n"); 8175796c8dcSSimon Schubert 8185796c8dcSSimon Schubert nprobes = 0; 8195796c8dcSSimon Schubert tmp = saved_bf_list; 8205796c8dcSSimon Schubert while (tmp != NULL) 8215796c8dcSSimon Schubert { 8225796c8dcSSimon Schubert nprobes++; 8235796c8dcSSimon Schubert if (tmp->symnum_fcn == the_function) 8245796c8dcSSimon Schubert { 8255796c8dcSSimon Schubert if (global_remote_debug) 8265796c8dcSSimon Schubert fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes); 8275796c8dcSSimon Schubert current_head_bf_list = tmp->next; 8285796c8dcSSimon Schubert return (tmp->symnum_bf); 8295796c8dcSSimon Schubert } 8305796c8dcSSimon Schubert tmp = tmp->next; 8315796c8dcSSimon Schubert } 8325796c8dcSSimon Schubert 8335796c8dcSSimon Schubert return (-1); 8345796c8dcSSimon Schubert } 8355796c8dcSSimon Schubert 8365796c8dcSSimon Schubert static SAVED_FUNCTION_PTR saved_function_list = NULL; 8375796c8dcSSimon Schubert static SAVED_FUNCTION_PTR saved_function_list_end = NULL; 8385796c8dcSSimon Schubert 8395796c8dcSSimon Schubert static void 8405796c8dcSSimon Schubert clear_function_list (void) 8415796c8dcSSimon Schubert { 8425796c8dcSSimon Schubert SAVED_FUNCTION_PTR tmp = saved_function_list; 8435796c8dcSSimon Schubert SAVED_FUNCTION_PTR next = NULL; 8445796c8dcSSimon Schubert 8455796c8dcSSimon Schubert while (tmp != NULL) 8465796c8dcSSimon Schubert { 8475796c8dcSSimon Schubert next = tmp->next; 8485796c8dcSSimon Schubert xfree (tmp); 8495796c8dcSSimon Schubert tmp = next; 8505796c8dcSSimon Schubert } 8515796c8dcSSimon Schubert 8525796c8dcSSimon Schubert saved_function_list = NULL; 8535796c8dcSSimon Schubert } 8545796c8dcSSimon Schubert #endif 855