1 Index: gdb-7.2.50.20110117/gdb/f-lang.c
2 ===================================================================
3 --- gdb-7.2.50.20110117.orig/gdb/f-lang.c 2011-01-07 20:36:16.000000000 +0100
4 +++ gdb-7.2.50.20110117/gdb/f-lang.c 2011-01-17 15:56:07.000000000 +0100
5 @@ -57,20 +57,6 @@ typedef struct saved_bf_symnum SAVED_BF,
8 extern void _initialize_f_language (void);
10 -static void clear_function_list (void);
11 -static long get_bf_for_fcn (long);
12 -static void clear_bf_list (void);
13 -static void patch_all_commons_by_name (char *, CORE_ADDR, int);
14 -static SAVED_F77_COMMON_PTR find_first_common_named (char *);
15 -static void add_common_entry (struct symbol *);
16 -static void add_common_block (char *, CORE_ADDR, int, char *);
17 -static SAVED_FUNCTION *allocate_saved_function_node (void);
18 -static SAVED_BF_PTR allocate_saved_bf_node (void);
19 -static COMMON_ENTRY_PTR allocate_common_entry_node (void);
20 -static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void);
21 -static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int);
24 static void f_printchar (int c, struct type *type, struct ui_file * stream);
25 static void f_emit_char (int c, struct type *type,
26 @@ -461,185 +447,7 @@ _initialize_f_language (void)
27 add_language (&f_language_defn);
32 -allocate_saved_bf_node (void)
36 - new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF));
40 -static SAVED_FUNCTION *
41 -allocate_saved_function_node (void)
43 - SAVED_FUNCTION *new;
45 - new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION));
49 -static SAVED_F77_COMMON_PTR
50 -allocate_saved_f77_common_node (void)
52 - SAVED_F77_COMMON_PTR new;
54 - new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON));
58 -static COMMON_ENTRY_PTR
59 -allocate_common_entry_node (void)
61 - COMMON_ENTRY_PTR new;
63 - new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY));
68 SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */
69 -SAVED_F77_COMMON_PTR tail_common_list = NULL; /* Ptr to last saved COMMON */
70 -SAVED_F77_COMMON_PTR current_common = NULL; /* Ptr to current COMMON */
73 -static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function)
75 -static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */
76 -static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of
79 -static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use
82 -/* The following function simply enters a given common block onto
83 - the global common block chain. */
86 -add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab)
88 - SAVED_F77_COMMON_PTR tmp;
89 - char *c, *local_copy_func_stab;
91 - /* If the COMMON block we are trying to add has a blank
92 - name (i.e. "#BLNK_COM") then we set it to __BLANK
93 - because the darn "#" character makes GDB's input
94 - parser have fits. */
97 - if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
98 - || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
102 - name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
103 - strcpy (name, BLANK_COMMON_NAME_LOCAL);
106 - tmp = allocate_saved_f77_common_node ();
108 - local_copy_func_stab = xmalloc (strlen (func_stab) + 1);
109 - strcpy (local_copy_func_stab, func_stab);
111 - tmp->name = xmalloc (strlen (name) + 1);
113 - /* local_copy_func_stab is a stabstring, let us first extract the
114 - function name from the stab by NULLing out the ':' character. */
118 - c = strchr (local_copy_func_stab, ':');
123 - error (_("Malformed function STAB found in add_common_block()"));
126 - tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1);
128 - strcpy (tmp->owning_function, local_copy_func_stab);
130 - strcpy (tmp->name, name);
131 - tmp->offset = offset;
133 - tmp->entries = NULL;
134 - tmp->secnum = secnum;
136 - current_common = tmp;
138 - if (head_common_list == NULL)
140 - head_common_list = tail_common_list = tmp;
144 - tail_common_list->next = tmp;
145 - tail_common_list = tmp;
150 -/* The following function simply enters a given common entry onto
151 - the "current_common" block that has been saved away. */
155 -add_common_entry (struct symbol *entry_sym_ptr)
157 - COMMON_ENTRY_PTR tmp;
161 - /* The order of this list is important, since
162 - we expect the entries to appear in decl.
163 - order when we later issue "info common" calls. */
165 - tmp = allocate_common_entry_node ();
168 - tmp->symbol = entry_sym_ptr;
170 - if (current_common == NULL)
171 - error (_("Attempt to add COMMON entry with no block open!"));
174 - if (current_common->entries == NULL)
176 - current_common->entries = tmp;
177 - current_common->end_of_entries = tmp;
181 - current_common->end_of_entries->next = tmp;
182 - current_common->end_of_entries = tmp;
188 -/* This routine finds the first encountred COMMON block named "name". */
191 -static SAVED_F77_COMMON_PTR
192 -find_first_common_named (char *name)
195 - SAVED_F77_COMMON_PTR tmp;
197 - tmp = head_common_list;
199 - while (tmp != NULL)
201 - if (strcmp (tmp->name, name) == 0)
210 /* This routine finds the first encountred COMMON block named "name"
211 that belongs to function funcname. */
212 @@ -662,193 +470,3 @@ find_common_for_function (char *name, ch
220 -/* The following function is called to patch up the offsets
221 - for the statics contained in the COMMON block named
225 -patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum)
227 - COMMON_ENTRY_PTR entry;
229 - blk->offset = offset; /* Keep this around for future use. */
231 - entry = blk->entries;
233 - while (entry != NULL)
235 - SYMBOL_VALUE (entry->symbol) += offset;
236 - SYMBOL_SECTION (entry->symbol) = secnum;
238 - entry = entry->next;
240 - blk->secnum = secnum;
243 -/* Patch all commons named "name" that need patching.Since COMMON
244 - blocks occur with relative infrequency, we simply do a linear scan on
245 - the name. Eventually, the best way to do this will be a
246 - hashed-lookup. Secnum is the section number for the .bss section
247 - (which is where common data lives). */
250 -patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum)
253 - SAVED_F77_COMMON_PTR tmp;
255 - /* For blank common blocks, change the canonical reprsentation
258 - if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
259 - || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
262 - name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
263 - strcpy (name, BLANK_COMMON_NAME_LOCAL);
266 - tmp = head_common_list;
268 - while (tmp != NULL)
270 - if (COMMON_NEEDS_PATCHING (tmp))
271 - if (strcmp (tmp->name, name) == 0)
272 - patch_common_entries (tmp, offset, secnum);
279 -/* This macro adds the symbol-number for the start of the function
280 - (the symbol number of the .bf) referenced by symnum_fcn to a
281 - list. This list, in reality should be a FIFO queue but since
282 - #line pragmas sometimes cause line ranges to get messed up
283 - we simply create a linear list. This list can then be searched
284 - first by a queueing algorithm and upon failure fall back to
288 -#define ADD_BF_SYMNUM(bf_sym,fcn_sym) \
290 - if (saved_bf_list == NULL) \
292 - tmp_bf_ptr = allocate_saved_bf_node(); \
294 - tmp_bf_ptr->symnum_bf = (bf_sym); \
295 - tmp_bf_ptr->symnum_fcn = (fcn_sym); \
296 - tmp_bf_ptr->next = NULL; \
298 - current_head_bf_list = saved_bf_list = tmp_bf_ptr; \
299 - saved_bf_list_end = tmp_bf_ptr; \
303 - tmp_bf_ptr = allocate_saved_bf_node(); \
305 - tmp_bf_ptr->symnum_bf = (bf_sym); \
306 - tmp_bf_ptr->symnum_fcn = (fcn_sym); \
307 - tmp_bf_ptr->next = NULL; \
309 - saved_bf_list_end->next = tmp_bf_ptr; \
310 - saved_bf_list_end = tmp_bf_ptr; \
314 -/* This function frees the entire (.bf,function) list. */
318 -clear_bf_list (void)
321 - SAVED_BF_PTR tmp = saved_bf_list;
322 - SAVED_BF_PTR next = NULL;
324 - while (tmp != NULL)
330 - saved_bf_list = NULL;
334 -int global_remote_debug;
339 -get_bf_for_fcn (long the_function)
344 - /* First use a simple queuing algorithm (i.e. look and see if the
345 - item at the head of the queue is the one you want). */
347 - if (saved_bf_list == NULL)
348 - internal_error (__FILE__, __LINE__,
349 - _("cannot get .bf node off empty list"));
351 - if (current_head_bf_list != NULL)
352 - if (current_head_bf_list->symnum_fcn == the_function)
354 - if (global_remote_debug)
355 - fprintf_unfiltered (gdb_stderr, "*");
357 - tmp = current_head_bf_list;
358 - current_head_bf_list = current_head_bf_list->next;
359 - return (tmp->symnum_bf);
362 - /* If the above did not work (probably because #line directives were
363 - used in the sourcefile and they messed up our internal tables) we now do
364 - the ugly linear scan. */
366 - if (global_remote_debug)
367 - fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n");
370 - tmp = saved_bf_list;
371 - while (tmp != NULL)
374 - if (tmp->symnum_fcn == the_function)
376 - if (global_remote_debug)
377 - fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes);
378 - current_head_bf_list = tmp->next;
379 - return (tmp->symnum_bf);
387 -static SAVED_FUNCTION_PTR saved_function_list = NULL;
388 -static SAVED_FUNCTION_PTR saved_function_list_end = NULL;
391 -clear_function_list (void)
393 - SAVED_FUNCTION_PTR tmp = saved_function_list;
394 - SAVED_FUNCTION_PTR next = NULL;
396 - while (tmp != NULL)
403 - saved_function_list = NULL;
406 Index: gdb-7.2.50.20110117/gdb/f-lang.h
407 ===================================================================
408 --- gdb-7.2.50.20110117.orig/gdb/f-lang.h 2011-01-17 15:47:37.000000000 +0100
409 +++ gdb-7.2.50.20110117/gdb/f-lang.h 2011-01-17 15:54:14.000000000 +0100
410 @@ -76,14 +76,9 @@ typedef struct saved_f77_common SAVED_F7
411 typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR;
413 extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */
414 -extern SAVED_F77_COMMON_PTR tail_common_list; /* Ptr to last saved COMMON */
415 -extern SAVED_F77_COMMON_PTR current_common; /* Ptr to current COMMON */
417 extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *);
419 -#define UNINITIALIZED_SECNUM -1
420 -#define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM)
422 #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */
423 #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */
424 #define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */
425 Index: gdb-7.2.50.20110117/gdb/f-valprint.c
426 ===================================================================
427 --- gdb-7.2.50.20110117.orig/gdb/f-valprint.c 2011-01-17 15:47:37.000000000 +0100
428 +++ gdb-7.2.50.20110117/gdb/f-valprint.c 2011-01-17 15:54:36.000000000 +0100
434 -static int there_is_a_visible_common_named (char *);
437 extern void _initialize_f_valprint (void);
438 static void info_common_command (char *, int);
439 static void list_all_visible_commons (char *);
440 @@ -604,67 +600,6 @@ info_common_command (char *comname, int
444 -/* This function is used to determine whether there is a
445 - F77 common block visible at the current scope called 'comname'. */
449 -there_is_a_visible_common_named (char *comname)
451 - SAVED_F77_COMMON_PTR the_common;
452 - struct frame_info *fi;
454 - struct symbol *func;
456 - if (comname == NULL)
457 - error (_("Cannot deal with NULL common name!"));
459 - fi = get_selected_frame (_("No frame selected"));
461 - /* The following is generally ripped off from stack.c's routine
462 - print_frame_info(). */
464 - func = find_pc_function (fi->pc);
467 - /* In certain pathological cases, the symtabs give the wrong
468 - function (when we are in the first function in a file which
469 - is compiled without debugging symbols, the previous function
470 - is compiled with debugging symbols, and the "foo.o" symbol
471 - that is supposed to tell us where the file with debugging symbols
472 - ends has been truncated by ar because it is longer than 15
475 - So look in the minimal symbol tables as well, and if it comes
476 - up with a larger address for the function use that instead.
477 - I don't think this can ever cause any problems; there shouldn't
478 - be any minimal symbols in the middle of a function.
479 - FIXME: (Not necessarily true. What about text labels?) */
481 - struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
483 - if (msymbol != NULL
484 - && (SYMBOL_VALUE_ADDRESS (msymbol)
485 - > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
486 - funname = SYMBOL_LINKAGE_NAME (msymbol);
488 - funname = SYMBOL_LINKAGE_NAME (func);
492 - struct minimal_symbol *msymbol =
493 - lookup_minimal_symbol_by_pc (fi->pc);
495 - if (msymbol != NULL)
496 - funname = SYMBOL_LINKAGE_NAME (msymbol);
499 - the_common = find_common_for_function (comname, funname);
501 - return (the_common ? 1 : 0);
506 _initialize_f_valprint (void)