29da877
http://sourceware.org/ml/archer/2010-q1/msg00047.html
29da877
Subject: [fortran-module] [commit] Fix a regression on setting breakpoint at
29da877
29da877
[ Backport for F-12.  ]
29da877
29da877
f5c7672a52316155bc3367cbc2f0e7db22523634
29da877
29da877
https://bugzilla.redhat.com/show_bug.cgi?id=559291
29da877
29da877
gdb/
29da877
2010-02-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
29da877
	    David Moore  <david.moore@intel.com>
29da877
	* f-lang.c (f_lookup_symbol_nonlocal): Always fallback on
29da877
	basic_lookup_symbol_nonlocal.
29da877
29da877
gdb/testsuite/
29da877
2010-02-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
29da877
	* gdb.fortran/module.exp (show language, setting breakpoint at module):
29da877
	New.
29da877
	* gdb.fortran/module.f90: New statement program module.
29da877
29da877
--- ./gdb/f-lang.c	2010-02-03 01:50:07.000000000 +0100
29da877
+++ ./gdb/f-lang.c	2010-02-03 01:49:06.000000000 +0100
29da877
@@ -308,33 +308,33 @@ f_lookup_symbol_nonlocal (const char *na
29da877
 			  const struct block *block,
29da877
 			  const domain_enum domain)
29da877
 {
29da877
-  struct fortran_using *use;
29da877
-
29da877
-  if (!block)
29da877
-    return NULL;
29da877
-
29da877
-  for (use = BLOCK_FORTRAN_USE (block); use; use = use->next)
29da877
+  if (block)
29da877
     {
29da877
-      struct symbol *sym;
29da877
-      struct type *type;
29da877
-      struct symbol *retval;
29da877
-
29da877
-      sym = lookup_symbol_global (use->module_name, block, MODULE_DOMAIN);
29da877
-
29da877
-      /* Module name lookup should not fail with correct debug info.  */
29da877
-      if (sym == NULL)
29da877
-	continue;
29da877
-
29da877
-      type = SYMBOL_TYPE (sym);
29da877
-      gdb_assert (TYPE_CODE (type) == TYPE_CODE_MODULE);
29da877
-      gdb_assert (TYPE_MODULE_BLOCK (type) != NULL);
29da877
-
29da877
-      retval = lookup_block_symbol (TYPE_MODULE_BLOCK (type), name, domain);
29da877
-      if (retval)
29da877
-	return retval;
29da877
+      struct fortran_using *use;
29da877
+
29da877
+      for (use = BLOCK_FORTRAN_USE (block); use; use = use->next)
29da877
+	{
29da877
+	  struct symbol *sym;
29da877
+	  struct type *type;
29da877
+	  struct symbol *retval;
29da877
+
29da877
+	  sym = lookup_symbol_global (use->module_name, block, MODULE_DOMAIN);
29da877
+
29da877
+	  /* Module name lookup should not fail with correct debug info.  */
29da877
+	  if (sym == NULL)
29da877
+	    continue;
29da877
+
29da877
+	  type = SYMBOL_TYPE (sym);
29da877
+	  gdb_assert (TYPE_CODE (type) == TYPE_CODE_MODULE);
29da877
+	  gdb_assert (TYPE_MODULE_BLOCK (type) != NULL);
29da877
+
29da877
+	  retval = lookup_block_symbol (TYPE_MODULE_BLOCK (type), name, domain);
29da877
+	  if (retval)
29da877
+	    return retval;
29da877
+	}
29da877
     }
29da877
 
29da877
-  return NULL;
29da877
+  return basic_lookup_symbol_nonlocal (name, block, domain);
29da877
 }
29da877
 
29da877
 /* This is declared in c-lang.h but it is silly to import that file for what
29da877
--- ./gdb/testsuite/gdb.fortran/module.exp	2010-02-03 01:50:13.000000000 +0100
29da877
+++ ./gdb/testsuite/gdb.fortran/module.exp	2010-02-03 01:47:42.000000000 +0100
29da877
@@ -43,3 +43,13 @@ gdb_test "print var_b" " = 11"
29da877
 gdb_test "print var_c" "No symbol \"var_c\" in current context\\."
29da877
 gdb_test "print var_d" " = 12"
29da877
 gdb_test "print var_i" " = 14" "print var_i value 14"
29da877
+
29da877
+# Breakpoint would work in language "c".
29da877
+gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
29da877
+
29da877
+# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
29da877
+# works.  But DWARF DW_TAG_subprogram contains the name specified by
29da877
+# the "program" Fortran statement.
29da877
+if [gdb_breakpoint "module"] {
29da877
+    pass "setting breakpoint at module"
29da877
+}
29da877
--- ./gdb/testsuite/gdb.fortran/module.f90	2010-02-03 01:50:07.000000000 +0100
29da877
+++ ./gdb/testsuite/gdb.fortran/module.f90	2010-02-03 01:47:42.000000000 +0100
29da877
@@ -37,6 +37,8 @@ end module modmany
29da877
         var_i = var_i                         ! i-is-2
29da877
         end
29da877
 
29da877
+        program module
29da877
+
29da877
         use modmany, only: var_b, var_d => var_c, var_i
29da877
 
29da877
         call sub1