dd46ae6
Index: gdb-7.1.90.20100711/gdb/dwarf2read.c
8c4c91e
===================================================================
dd46ae6
--- gdb-7.1.90.20100711.orig/gdb/dwarf2read.c	2010-07-13 00:13:02.000000000 +0200
dd46ae6
+++ gdb-7.1.90.20100711/gdb/dwarf2read.c	2010-07-13 00:26:25.000000000 +0200
dd46ae6
@@ -5727,12 +5727,14 @@ read_set_type (struct die_info *die, str
8c4c91e
   return set_die_type (die, set_type, cu);
8c4c91e
 }
8c4c91e
 
8c4c91e
-/* First cut: install each common block member as a global variable.  */
8c4c91e
+/* Create appropriate locally-scoped variables for all the DW_TAG_common_block
8c4c91e
+   entries.  Create also TYPE_CODE_STRUCT listing all such variables to be
8c4c91e
+   available for `info common'.  COMMON_BLOCK_DOMAIN is used to sepate the
8c4c91e
+   common blocks name namespace from regular variable names.  */
8c4c91e
 
8c4c91e
 static void
8c4c91e
 read_common_block (struct die_info *die, struct dwarf2_cu *cu)
8c4c91e
 {
8c4c91e
-  struct die_info *child_die;
8c4c91e
   struct attribute *attr;
8c4c91e
   struct symbol *sym;
8c4c91e
   CORE_ADDR base = (CORE_ADDR) 0;
dd46ae6
@@ -5757,10 +5759,40 @@ read_common_block (struct die_info *die,
8c4c91e
     }
8c4c91e
   if (die->child != NULL)
8c4c91e
     {
8c4c91e
+      struct objfile *objfile = cu->objfile;
8c4c91e
+      struct die_info *child_die;
8c4c91e
+      struct type *type;
8c4c91e
+      struct field *field;
8c4c91e
+      char *name;
8c4c91e
+      struct symbol *sym;
8c4c91e
+
8c4c91e
+      type = alloc_type (objfile);
8c4c91e
+      TYPE_CODE (type) = TYPE_CODE_STRUCT;
8c4c91e
+      /* Artificial type to be used only by `info common'.  */
8c4c91e
+      TYPE_NAME (type) = "<common>";
8c4c91e
+
8c4c91e
+      child_die = die->child;
8c4c91e
+      while (child_die && child_die->tag)
8c4c91e
+	{
8c4c91e
+	  TYPE_NFIELDS (type)++;
8c4c91e
+	  child_die = sibling_die (child_die);
8c4c91e
+	}
8c4c91e
+
8c4c91e
+      TYPE_FIELDS (type) = obstack_alloc (&objfile->objfile_obstack,
8c4c91e
+					  sizeof (*TYPE_FIELDS (type))
8c4c91e
+					  * TYPE_NFIELDS (type));
8c4c91e
+      memset (TYPE_FIELDS (type), 0, sizeof (*TYPE_FIELDS (type))
8c4c91e
+				     * TYPE_NFIELDS (type));
8c4c91e
+      
8c4c91e
+      field = TYPE_FIELDS (type);
8c4c91e
       child_die = die->child;
8c4c91e
       while (child_die && child_die->tag)
8c4c91e
 	{
8c4c91e
+	  /* Create the symbol in the DW_TAG_common_block block in the current
8c4c91e
+	     symbol scope.  */
8c4c91e
 	  sym = new_symbol (child_die, NULL, cu);
8c4c91e
+
8c4c91e
+	  /* Undocumented in DWARF3, when it can be present?  */
8c4c91e
 	  attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu);
8c4c91e
 	  if (attr)
8c4c91e
 	    {
dd46ae6
@@ -5778,8 +5810,25 @@ read_common_block (struct die_info *die,
8c4c91e
 	      SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
8c4c91e
 	      add_symbol_to_list (sym, &global_symbols);
8c4c91e
 	    }
8c4c91e
+
8c4c91e
+	  if (SYMBOL_CLASS (sym) == LOC_STATIC)
8c4c91e
+	    SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym));
8c4c91e
+	  else
8c4c91e
+	    SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym));
8c4c91e
+	  FIELD_TYPE (*field) = SYMBOL_TYPE (sym);
8c4c91e
+	  FIELD_NAME (*field) = SYMBOL_NATURAL_NAME (sym);
8c4c91e
+	  field++;
8c4c91e
 	  child_die = sibling_die (child_die);
8c4c91e
 	}
8c4c91e
+
8c4c91e
+      /* TYPE_LENGTH (type) is left 0 - it is only a virtual structure even
8c4c91e
+	 with no consecutive address space.  */
8c4c91e
+
8c4c91e
+      sym = new_symbol (die, type, cu);
8c4c91e
+      /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static.  */
8c4c91e
+      SYMBOL_VALUE_ADDRESS (sym) = base;
8c4c91e
+
8c4c91e
+      set_die_type (die, type, cu);
8c4c91e
     }
8c4c91e
 }
8c4c91e
 
dd46ae6
@@ -9106,6 +9155,13 @@ new_symbol (struct die_info *die, struct
8c4c91e
 	    {
8c4c91e
 	      var_decode_location (attr, sym, cu);
8c4c91e
 	      attr2 = dwarf2_attr (die, DW_AT_external, cu);
8c4c91e
+
8c4c91e
+	      /* Fortran explicitly imports any global symbols to the local
8c4c91e
+		 scope by DW_TAG_common_block.  */
8c4c91e
+	      if (cu->language == language_fortran && die->parent
8c4c91e
+		  && die->parent->tag == DW_TAG_common_block)
8c4c91e
+		attr2 = NULL;
8c4c91e
+
8c4c91e
 	      if (attr2 && (DW_UNSND (attr2) != 0))
8c4c91e
 		{
45f7971
 		  struct pending **list_to_add;
dd46ae6
@@ -9277,6 +9333,11 @@ new_symbol (struct die_info *die, struct
dd46ae6
 	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;
8c4c91e
 	  add_symbol_to_list (sym, &global_symbols);
8c4c91e
 	  break;
8c4c91e
+	case DW_TAG_common_block:
8c4c91e
+	  SYMBOL_CLASS (sym) = LOC_STATIC;
8c4c91e
+	  SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN;
8c4c91e
+	  add_symbol_to_list (sym, cu->list_in_scope);
8c4c91e
+	  break;
8c4c91e
 	default:
8c4c91e
 	  /* Not a tag we recognize.  Hopefully we aren't processing
8c4c91e
 	     trash data, but since we must specifically ignore things
dd46ae6
Index: gdb-7.1.90.20100711/gdb/f-lang.c
8c4c91e
===================================================================
dd46ae6
--- gdb-7.1.90.20100711.orig/gdb/f-lang.c	2010-07-13 00:24:04.000000000 +0200
dd46ae6
+++ gdb-7.1.90.20100711/gdb/f-lang.c	2010-07-13 00:25:56.000000000 +0200
dd46ae6
@@ -443,27 +443,3 @@ _initialize_f_language (void)
8c4c91e
 
8c4c91e
   add_language (&f_language_defn);
8c4c91e
 }
8c4c91e
-
8c4c91e
-SAVED_F77_COMMON_PTR head_common_list = NULL;	/* Ptr to 1st saved COMMON  */
8c4c91e
-
8c4c91e
-/* This routine finds the first encountred COMMON block named "name" 
8c4c91e
-   that belongs to function funcname */
8c4c91e
-
8c4c91e
-SAVED_F77_COMMON_PTR
8c4c91e
-find_common_for_function (char *name, char *funcname)
8c4c91e
-{
8c4c91e
-
8c4c91e
-  SAVED_F77_COMMON_PTR tmp;
8c4c91e
-
8c4c91e
-  tmp = head_common_list;
8c4c91e
-
8c4c91e
-  while (tmp != NULL)
8c4c91e
-    {
8c4c91e
-      if (strcmp (tmp->name, name) == 0
8c4c91e
-	  && strcmp (tmp->owning_function, funcname) == 0)
8c4c91e
-	return (tmp);
8c4c91e
-      else
8c4c91e
-	tmp = tmp->next;
8c4c91e
-    }
8c4c91e
-  return (NULL);
8c4c91e
-}
dd46ae6
Index: gdb-7.1.90.20100711/gdb/f-lang.h
8c4c91e
===================================================================
dd46ae6
--- gdb-7.1.90.20100711.orig/gdb/f-lang.h	2010-07-13 00:24:04.000000000 +0200
dd46ae6
+++ gdb-7.1.90.20100711/gdb/f-lang.h	2010-07-13 00:25:56.000000000 +0200
dd46ae6
@@ -52,36 +52,8 @@ enum f90_range_type
8c4c91e
     NONE_BOUND_DEFAULT		/* "(low:high)"  */
8c4c91e
   };
8c4c91e
 
8c4c91e
-struct common_entry
8c4c91e
-  {
8c4c91e
-    struct symbol *symbol;	/* The symbol node corresponding
8c4c91e
-				   to this component */
8c4c91e
-    struct common_entry *next;	/* The next component */
8c4c91e
-  };
8c4c91e
-
8c4c91e
-struct saved_f77_common
8c4c91e
-  {
8c4c91e
-    char *name;			/* Name of COMMON */
8c4c91e
-    char *owning_function;	/* Name of parent function */
8c4c91e
-    int secnum;			/* Section # of .bss */
8c4c91e
-    CORE_ADDR offset;		/* Offset from .bss for 
8c4c91e
-				   this block */
8c4c91e
-    struct common_entry *entries;	/* List of block's components */
8c4c91e
-    struct common_entry *end_of_entries;	/* ptr. to end of components */
8c4c91e
-    struct saved_f77_common *next;	/* Next saved COMMON block */
8c4c91e
-  };
8c4c91e
-
8c4c91e
-typedef struct saved_f77_common SAVED_F77_COMMON, *SAVED_F77_COMMON_PTR;
8c4c91e
-
8c4c91e
-typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR;
8c4c91e
-
8c4c91e
-extern SAVED_F77_COMMON_PTR head_common_list;	/* Ptr to 1st saved COMMON  */
8c4c91e
-
8c4c91e
-extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *);
8c4c91e
-
8c4c91e
 #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM"	/* XLF assigned  */
8c4c91e
 #define BLANK_COMMON_NAME_MF77     "__BLNK__"	/* MF77 assigned  */
8c4c91e
-#define BLANK_COMMON_NAME_LOCAL    "__BLANK"	/* Local GDB */
8c4c91e
 
8c4c91e
 /* When reasonable array bounds cannot be fetched, such as when 
8c4c91e
    you ask to 'mt print symbols' and there is no stack frame and 
dd46ae6
Index: gdb-7.1.90.20100711/gdb/f-valprint.c
8c4c91e
===================================================================
dd46ae6
--- gdb-7.1.90.20100711.orig/gdb/f-valprint.c	2010-07-13 00:24:25.000000000 +0200
dd46ae6
+++ gdb-7.1.90.20100711/gdb/f-valprint.c	2010-07-13 00:32:05.000000000 +0200
8c4c91e
@@ -34,6 +34,8 @@
8c4c91e
 #include "gdbcore.h"
8c4c91e
 #include "command.h"
8c4c91e
 #include "block.h"
8c4c91e
+#include "dictionary.h"
8c4c91e
+#include "gdb_assert.h"
8c4c91e
 
8c4c91e
 extern void _initialize_f_valprint (void);
8c4c91e
 static void info_common_command (char *, int);
dd46ae6
@@ -486,22 +488,54 @@ f_val_print (struct type *type, const gd
8c4c91e
   return 0;
8c4c91e
 }
8c4c91e
 
8c4c91e
-static void
8c4c91e
-list_all_visible_commons (char *funname)
8c4c91e
+static int
8c4c91e
+info_common_command_for_block (struct block *block, struct frame_info *frame,
8c4c91e
+			       const char *comname)
8c4c91e
 {
8c4c91e
-  SAVED_F77_COMMON_PTR tmp;
8c4c91e
-
8c4c91e
-  tmp = head_common_list;
8c4c91e
+  struct dict_iterator iter;
8c4c91e
+  struct symbol *sym;
8c4c91e
+  int values_printed = 0;
8c4c91e
+  const char *name;
8c4c91e
+  struct value_print_options opts;
8c4c91e
+
8c4c91e
+  get_user_print_options (&opts);
8c4c91e
+
8c4c91e
+  ALL_BLOCK_SYMBOLS (block, iter, sym)
8c4c91e
+    if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
8c4c91e
+      {
8c4c91e
+      	struct type *type = SYMBOL_TYPE (sym);
8c4c91e
+	int index;
8c4c91e
+
8c4c91e
+	gdb_assert (SYMBOL_CLASS (sym) == LOC_STATIC);
8c4c91e
+	gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT);
8c4c91e
+
8c4c91e
+	if (comname && (!SYMBOL_LINKAGE_NAME (sym)
8c4c91e
+	                || strcmp (comname, SYMBOL_LINKAGE_NAME (sym)) != 0))
8c4c91e
+	  continue;
8c4c91e
+
8c4c91e
+	values_printed = 1;
8c4c91e
+	if (SYMBOL_PRINT_NAME (sym))
8c4c91e
+	  printf_filtered (_("Contents of F77 COMMON block '%s':\n"),
8c4c91e
+			   SYMBOL_PRINT_NAME (sym));
8c4c91e
+	else
8c4c91e
+	  printf_filtered (_("Contents of blank COMMON block:\n"));
8c4c91e
+	
8c4c91e
+	for (index = 0; index < TYPE_NFIELDS (type); index++)
8c4c91e
+	  {
8c4c91e
+	    struct value *val;
8c4c91e
+
8c4c91e
+	    gdb_assert (field_is_static (&TYPE_FIELD (type, index)));
8c4c91e
+	    val = value_static_field (type, index);
8c4c91e
+
8c4c91e
+	    printf_filtered ("%s = ", TYPE_FIELD_NAME (type, index));
8c4c91e
+	    value_print (val, gdb_stdout, &opts);
8c4c91e
+	    putchar_filtered ('\n');
8c4c91e
+	  }
8c4c91e
 
8c4c91e
-  printf_filtered (_("All COMMON blocks visible at this level:\n\n"));
8c4c91e
+	putchar_filtered ('\n');
8c4c91e
+      }
8c4c91e
 
8c4c91e
-  while (tmp != NULL)
8c4c91e
-    {
8c4c91e
-      if (strcmp (tmp->owning_function, funname) == 0)
8c4c91e
-	printf_filtered ("%s\n", tmp->name);
8c4c91e
-
8c4c91e
-      tmp = tmp->next;
8c4c91e
-    }
8c4c91e
+  return values_printed;
8c4c91e
 }
8c4c91e
 
8c4c91e
 /* This function is used to print out the values in a given COMMON 
dd46ae6
@@ -511,11 +545,9 @@ list_all_visible_commons (char *funname)
8c4c91e
 static void
8c4c91e
 info_common_command (char *comname, int from_tty)
8c4c91e
 {
8c4c91e
-  SAVED_F77_COMMON_PTR the_common;
8c4c91e
-  COMMON_ENTRY_PTR entry;
8c4c91e
   struct frame_info *fi;
8c4c91e
-  char *funname = 0;
8c4c91e
-  struct symbol *func;
8c4c91e
+  struct block *block;
8c4c91e
+  int values_printed = 0;
8c4c91e
 
8c4c91e
   /* We have been told to display the contents of F77 COMMON 
8c4c91e
      block supposedly visible in this function.  Let us 
dd46ae6
@@ -527,74 +559,31 @@ info_common_command (char *comname, int 
8c4c91e
   /* The following is generally ripped off from stack.c's routine 
8c4c91e
      print_frame_info() */
8c4c91e
 
8c4c91e
-  func = find_pc_function (get_frame_pc (fi));
8c4c91e
-  if (func)
8c4c91e
+  block = get_frame_block (fi, 0);
8c4c91e
+  if (block == NULL)
8c4c91e
     {
8c4c91e
-      /* In certain pathological cases, the symtabs give the wrong
8c4c91e
-         function (when we are in the first function in a file which
8c4c91e
-         is compiled without debugging symbols, the previous function
8c4c91e
-         is compiled with debugging symbols, and the "foo.o" symbol
8c4c91e
-         that is supposed to tell us where the file with debugging symbols
8c4c91e
-         ends has been truncated by ar because it is longer than 15
8c4c91e
-         characters).
8c4c91e
-
8c4c91e
-         So look in the minimal symbol tables as well, and if it comes
8c4c91e
-         up with a larger address for the function use that instead.
8c4c91e
-         I don't think this can ever cause any problems; there shouldn't
8c4c91e
-         be any minimal symbols in the middle of a function.
8c4c91e
-         FIXME:  (Not necessarily true.  What about text labels) */
8c4c91e
-
8c4c91e
-      struct minimal_symbol *msymbol = 
8c4c91e
-	lookup_minimal_symbol_by_pc (get_frame_pc (fi));
8c4c91e
-
8c4c91e
-      if (msymbol != NULL
8c4c91e
-	  && (SYMBOL_VALUE_ADDRESS (msymbol)
8c4c91e
-	      > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
8c4c91e
-	funname = SYMBOL_LINKAGE_NAME (msymbol);
8c4c91e
-      else
8c4c91e
-	funname = SYMBOL_LINKAGE_NAME (func);
8c4c91e
-    }
8c4c91e
-  else
8c4c91e
-    {
8c4c91e
-      struct minimal_symbol *msymbol =
dd46ae6
-	lookup_minimal_symbol_by_pc (get_frame_pc (fi));
8c4c91e
-
8c4c91e
-      if (msymbol != NULL)
8c4c91e
-	funname = SYMBOL_LINKAGE_NAME (msymbol);
8c4c91e
-      else /* Got no 'funname', code below will fail.  */
8c4c91e
-	error (_("No function found for frame."));
8c4c91e
+      printf_filtered (_("No symbol table info available.\n"));
8c4c91e
+      return;
8c4c91e
     }
8c4c91e
 
8c4c91e
-  /* If comname is NULL, we assume the user wishes to see the 
8c4c91e
-     which COMMON blocks are visible here and then return */
8c4c91e
-
8c4c91e
-  if (comname == 0)
8c4c91e
+  while (block)
8c4c91e
     {
8c4c91e
-      list_all_visible_commons (funname);
8c4c91e
-      return;
8c4c91e
+      if (info_common_command_for_block (block, fi, comname))
8c4c91e
+	values_printed = 1;
8c4c91e
+      /* After handling the function's top-level block, stop.  Don't
8c4c91e
+         continue to its superblock, the block of per-file symbols.  */
8c4c91e
+      if (BLOCK_FUNCTION (block))
8c4c91e
+	break;
8c4c91e
+      block = BLOCK_SUPERBLOCK (block);
8c4c91e
     }
8c4c91e
 
8c4c91e
-  the_common = find_common_for_function (comname, funname);
8c4c91e
-
8c4c91e
-  if (the_common)
8c4c91e
+  if (!values_printed)
8c4c91e
     {
8c4c91e
-      if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0)
8c4c91e
-	printf_filtered (_("Contents of blank COMMON block:\n"));
8c4c91e
+      if (comname)
8c4c91e
+	printf_filtered (_("No common block '%s'.\n"), comname);
8c4c91e
       else
8c4c91e
-	printf_filtered (_("Contents of F77 COMMON block '%s':\n"), comname);
8c4c91e
-
8c4c91e
-      printf_filtered ("\n");
8c4c91e
-      entry = the_common->entries;
8c4c91e
-
8c4c91e
-      while (entry != NULL)
8c4c91e
-	{
8c4c91e
-	  print_variable_and_value (NULL, entry->symbol, fi, gdb_stdout, 0);
8c4c91e
-	  entry = entry->next;
8c4c91e
-	}
8c4c91e
+	printf_filtered (_("No common blocks.\n"));
8c4c91e
     }
8c4c91e
-  else
8c4c91e
-    printf_filtered (_("Cannot locate the common block %s in function '%s'\n"),
8c4c91e
-		     comname, funname);
8c4c91e
 }
8c4c91e
 
8c4c91e
 void
dd46ae6
Index: gdb-7.1.90.20100711/gdb/stack.c
8c4c91e
===================================================================
dd46ae6
--- gdb-7.1.90.20100711.orig/gdb/stack.c	2010-07-01 17:36:17.000000000 +0200
dd46ae6
+++ gdb-7.1.90.20100711/gdb/stack.c	2010-07-13 00:29:49.000000000 +0200
dd46ae6
@@ -1484,6 +1484,8 @@ iterate_over_block_locals (struct block 
8c4c91e
 	case LOC_COMPUTED:
8c4c91e
 	  if (SYMBOL_IS_ARGUMENT (sym))
8c4c91e
 	    break;
8c4c91e
+	  if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
8c4c91e
+	    break;
dd46ae6
 	  (*cb) (SYMBOL_PRINT_NAME (sym), sym, cb_data);
8c4c91e
 	  break;
dd46ae6
 
dd46ae6
Index: gdb-7.1.90.20100711/gdb/symtab.h
8c4c91e
===================================================================
dd46ae6
--- gdb-7.1.90.20100711.orig/gdb/symtab.h	2010-07-12 23:07:33.000000000 +0200
dd46ae6
+++ gdb-7.1.90.20100711/gdb/symtab.h	2010-07-13 00:27:02.000000000 +0200
dd46ae6
@@ -396,7 +396,10 @@ typedef enum domain_enum_tag
dd46ae6
   FUNCTIONS_DOMAIN,
8c4c91e
 
dd46ae6
   /* All defined types */
dd46ae6
-  TYPES_DOMAIN
dd46ae6
+  TYPES_DOMAIN,
8c4c91e
+
8c4c91e
+  /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.  */
8c4c91e
+  COMMON_BLOCK_DOMAIN
8c4c91e
 }
8c4c91e
 domain_enum;
8c4c91e
 
dd46ae6
Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.exp
45f7971
===================================================================
45f7971
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
dd46ae6
+++ gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.exp	2010-07-13 00:25:56.000000000 +0200
8c4c91e
@@ -0,0 +1,101 @@
8c4c91e
+# Copyright 2008 Free Software Foundation, Inc.
8c4c91e
+
8c4c91e
+# This program is free software; you can redistribute it and/or modify
8c4c91e
+# it under the terms of the GNU General Public License as published by
8c4c91e
+# the Free Software Foundation; either version 2 of the License, or
8c4c91e
+# (at your option) any later version.
8c4c91e
+# 
8c4c91e
+# This program is distributed in the hope that it will be useful,
8c4c91e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
8c4c91e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8c4c91e
+# GNU General Public License for more details.
8c4c91e
+# 
8c4c91e
+# You should have received a copy of the GNU General Public License
8c4c91e
+# along with this program; if not, write to the Free Software
8c4c91e
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
8c4c91e
+
8c4c91e
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
8c4c91e
+
8c4c91e
+set testfile "common-block"
8c4c91e
+set srcfile ${testfile}.f90
8c4c91e
+set binfile ${objdir}/${subdir}/${testfile}
8c4c91e
+
8c4c91e
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
8c4c91e
+    untested "Couldn't compile ${srcfile}"
8c4c91e
+    return -1
8c4c91e
+}
8c4c91e
+
8c4c91e
+gdb_exit
8c4c91e
+gdb_start
8c4c91e
+gdb_reinitialize_dir $srcdir/$subdir
8c4c91e
+gdb_load ${binfile}
8c4c91e
+
8c4c91e
+if ![runto MAIN__] then {
8c4c91e
+    perror "couldn't run to breakpoint MAIN__"
8c4c91e
+    continue
8c4c91e
+}
8c4c91e
+
8c4c91e
+gdb_breakpoint [gdb_get_line_number "stop-here-out"]
8c4c91e
+gdb_continue_to_breakpoint "stop-here-out"
8c4c91e
+
8c4c91e
+# Common block naming with source name /foo/:
8c4c91e
+#                .symtab  DW_TAG_common_block's DW_AT_name
8c4c91e
+# Intel Fortran  foo_     foo_
8c4c91e
+# GNU Fortran    foo_     foo
8c4c91e
+#set suffix "_"
8c4c91e
+set suffix ""
8c4c91e
+
8c4c91e
+set int4 {(integer\(kind=4\)|INTEGER\(4\))}
8c4c91e
+set real4 {(real\(kind=4\)|REAL\(4\))}
8c4c91e
+set real8 {(real\(kind=8\)|REAL\(8\))}
8c4c91e
+
8c4c91e
+gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context."
8c4c91e
+gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context."
8c4c91e
+gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context."
8c4c91e
+gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context."
8c4c91e
+gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context."
8c4c91e
+gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context."
8c4c91e
+
8c4c91e
+gdb_test "info locals" "ix_x = 11\r\niy_y = 22\r\niz_z = 33\r\nix = 1\r\niy = 2\r\niz = 3" "info locals out"
8c4c91e
+gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix_x = 11\r\niy_y = 22\r\niz_z = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix = 1\r\niy = 2\r\niz = 3" "info common out"
8c4c91e
+
8c4c91e
+gdb_test "ptype ix" "type = $int4" "ptype ix out"
8c4c91e
+gdb_test "ptype iy" "type = $real4" "ptype iy out"
8c4c91e
+gdb_test "ptype iz" "type = $real8" "ptype iz out"
8c4c91e
+gdb_test "ptype ix_x" "type = $int4" "ptype ix_x out"
8c4c91e
+gdb_test "ptype iy_y" "type = $real4" "ptype iy_y out"
8c4c91e
+gdb_test "ptype iz_z" "type = $real8" "ptype iz_z out"
8c4c91e
+
8c4c91e
+gdb_test "p ix" " = 1 *" "p ix out"
8c4c91e
+gdb_test "p iy" " = 2 *" "p iy out"
8c4c91e
+gdb_test "p iz" " = 3 *" "p iz out"
8c4c91e
+gdb_test "p ix_x" " = 11 *" "p ix_x out"
8c4c91e
+gdb_test "p iy_y" " = 22 *" "p iy_y out"
8c4c91e
+gdb_test "p iz_z" " = 33 *" "p iz_z out"
8c4c91e
+
8c4c91e
+gdb_breakpoint [gdb_get_line_number "stop-here-in"]
8c4c91e
+gdb_continue_to_breakpoint "stop-here-in"
8c4c91e
+
8c4c91e
+gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." "whatis foo$suffix in"
8c4c91e
+gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." "ptype foo$suffix in"
8c4c91e
+gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." "p foo$suffix in"
8c4c91e
+gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "whatis fo_o$suffix in"
8c4c91e
+gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "ptype fo_o$suffix in"
8c4c91e
+gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "p fo_o$suffix in"
8c4c91e
+
8c4c91e
+gdb_test "info locals" "ix = 11\r\niy2 = 22\r\niz = 33\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3\r\niy = 5\r\niz_z = 55" "info locals in"
8c4c91e
+gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix = 11\r\niy2 = 22\r\niz = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3" "info common in"
8c4c91e
+
8c4c91e
+gdb_test "ptype ix" "type = $int4" "ptype ix in"
8c4c91e
+gdb_test "ptype iy2" "type = $real4" "ptype iy2 in"
8c4c91e
+gdb_test "ptype iz" "type = $real8" "ptype iz in"
8c4c91e
+gdb_test "ptype ix_x" "type = $int4" "ptype ix_x in"
8c4c91e
+gdb_test "ptype iy_y" "type = $real4" "ptype iy_y in"
8c4c91e
+gdb_test "ptype iz_z2" "type = $real8" "ptype iz_z2 in"
8c4c91e
+
8c4c91e
+gdb_test "p ix" " = 11 *" "p ix in"
8c4c91e
+gdb_test "p iy2" " = 22 *" "p iy2 in"
8c4c91e
+gdb_test "p iz" " = 33 *" "p iz in"
8c4c91e
+gdb_test "p ix_x" " = 1 *" "p ix_x in"
8c4c91e
+gdb_test "p iy_y" " = 2 *" "p iy_y in"
8c4c91e
+gdb_test "p iz_z2" " = 3 *" "p iz_z2 in"
dd46ae6
Index: gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.f90
45f7971
===================================================================
45f7971
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
dd46ae6
+++ gdb-7.1.90.20100711/gdb/testsuite/gdb.fortran/common-block.f90	2010-07-13 00:25:56.000000000 +0200
8c4c91e
@@ -0,0 +1,67 @@
8c4c91e
+! Copyright 2008 Free Software Foundation, Inc.
8c4c91e
+!
8c4c91e
+! This program is free software; you can redistribute it and/or modify
8c4c91e
+! it under the terms of the GNU General Public License as published by
8c4c91e
+! the Free Software Foundation; either version 2 of the License, or
8c4c91e
+! (at your option) any later version.
8c4c91e
+!
8c4c91e
+! This program is distributed in the hope that it will be useful,
8c4c91e
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
8c4c91e
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8c4c91e
+! GNU General Public License for more details.
8c4c91e
+!
8c4c91e
+! You should have received a copy of the GNU General Public License
8c4c91e
+! along with this program; if not, write to the Free Software
8c4c91e
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
8c4c91e
+!
8c4c91e
+! Ihis file is the Fortran source file for dynamic.exp.
8c4c91e
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
8c4c91e
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
8c4c91e
+
8c4c91e
+subroutine in
8c4c91e
+
8c4c91e
+   INTEGER*4            ix
8c4c91e
+   REAL*4               iy2
8c4c91e
+   REAL*8               iz
8c4c91e
+
8c4c91e
+   INTEGER*4            ix_x
8c4c91e
+   REAL*4               iy_y
8c4c91e
+   REAL*8               iz_z2
8c4c91e
+
8c4c91e
+   common /fo_o/ix,iy2,iz
8c4c91e
+   common /foo/ix_x,iy_y,iz_z2
8c4c91e
+
8c4c91e
+   iy = 5
8c4c91e
+   iz_z = 55
8c4c91e
+
8c4c91e
+   if (ix .ne. 11 .or. iy2 .ne. 22.0 .or. iz .ne. 33.0) call abort
8c4c91e
+   if (ix_x .ne. 1 .or. iy_y .ne. 2.0 .or. iz_z2 .ne. 3.0) call abort
8c4c91e
+
8c4c91e
+   ix = 0					! stop-here-in
8c4c91e
+
8c4c91e
+end subroutine in
8c4c91e
+
8c4c91e
+program common_test
8c4c91e
+
8c4c91e
+   INTEGER*4            ix
8c4c91e
+   REAL*4               iy
8c4c91e
+   REAL*8               iz
8c4c91e
+
8c4c91e
+   INTEGER*4            ix_x
8c4c91e
+   REAL*4               iy_y
8c4c91e
+   REAL*8               iz_z
8c4c91e
+
8c4c91e
+   common /foo/ix,iy,iz
8c4c91e
+   common /fo_o/ix_x,iy_y,iz_z
8c4c91e
+
8c4c91e
+   ix = 1
8c4c91e
+   iy = 2.0
8c4c91e
+   iz = 3.0
8c4c91e
+
8c4c91e
+   ix_x = 11
8c4c91e
+   iy_y = 22.0
8c4c91e
+   iz_z = 33.0
8c4c91e
+
8c4c91e
+   call in					! stop-here-out
8c4c91e
+
8c4c91e
+end program common_test