2c2fa1
https://bugzilla.redhat.com/show_bug.cgi?id=533176#c4
2c2fa1
2c2fa1
I find it a bug in DWARF and gdb behaves correctly according to it.  From the
2c2fa1
current DWARF's point of view the is a function call which you skip by "next".
2c2fa1
2c2fa1
If you hide any /usr/lib/debug such as using:
2c2fa1
gdb -nx -ex 'set debug-file-directory /qwe' -ex 'file ./tpcommon_gfortran44'
2c2fa1
and use "step" command instead of "next" there it will work.
2c2fa1
(You need to hide debuginfo from libgomp as you would step into libgomp sources
2c2fa1
to maintain the threads for execution.)
2c2fa1
2c2fa1
There should be some DWARF extension for it, currently tried to detect
2c2fa1
substring ".omp_fn." as this function is called "MAIN__.omp_fn.0" and do not
2c2fa1
consider such sub-function as a skippable by "next".
2c2fa1
2c2fa1
Another problem is that with "set scheduler-locking" being "off" (default
2c2fa1
upstream) or "step" (default in F/RHEL) the simultaneous execution of the
2c2fa1
threads is inconvenient.  Setting it to "on" will lockup the debugging as the
2c2fa1
threads need to get synchronized at some point.  This is a more general
2c2fa1
debugging problem of GOMP outside of the scope of this Bug.
2c2fa1
2c2fa1
2c2fa1
2c2fa1
Index: gdb-7.5.50.20130118/gdb/infrun.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.5.50.20130118.orig/gdb/infrun.c	2013-01-19 23:38:22.329371410 +0100
2c2fa1
+++ gdb-7.5.50.20130118/gdb/infrun.c	2013-01-19 23:39:03.322429041 +0100
2c2fa1
@@ -4918,6 +4918,16 @@ process_event_stop_test:
2c2fa1
 
2c2fa1
       if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
2c2fa1
 	{
2c2fa1
+	  struct symbol *stop_fn = find_pc_function (stop_pc);
2c2fa1
+	  struct minimal_symbol *stopf = lookup_minimal_symbol_by_pc (stop_pc);
2c2fa1
+
2c2fa1
+	  if ((stop_fn == NULL
2c2fa1
+	       || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL)
2c2fa1
+	      /* gcc-4.7.2-9.fc19.x86_64 uses a new format.  */
2c2fa1
+	      && (stopf == NULL
2c2fa1
+		  || strstr (SYMBOL_LINKAGE_NAME (stopf), "._omp_fn.") == NULL))
2c2fa1
+{	/* ".omp_fn." */
2c2fa1
+
2c2fa1
 	  /* We're doing a "next".
2c2fa1
 
2c2fa1
 	     Normal (forward) execution: set a breakpoint at the
2c2fa1
@@ -4953,6 +4963,7 @@ process_event_stop_test:
2c2fa1
 
2c2fa1
 	  keep_going (ecs);
2c2fa1
 	  return;
2c2fa1
+}	/* ".omp_fn." */
2c2fa1
 	}
2c2fa1
 
2c2fa1
       /* If we are in a function call trampoline (a stub between the
2c2fa1
Index: gdb-7.5.50.20130118/gdb/testsuite/gdb.fortran/omp-step.exp
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.5.50.20130118/gdb/testsuite/gdb.fortran/omp-step.exp	2013-01-19 23:38:23.213372622 +0100
2c2fa1
@@ -0,0 +1,31 @@
2c2fa1
+# Copyright 2009 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 3 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+#
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+#
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+set testfile "omp-step"
2c2fa1
+set srcfile ${testfile}.f90
2c2fa1
+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90 additional_flags=-fopenmp}] } {
2c2fa1
+    return -1
2c2fa1
+}
2c2fa1
+
2c2fa1
+if ![runto [gdb_get_line_number "start-here"]] {
2c2fa1
+    perror "Couldn't run to start-here"
2c2fa1
+    return 0
2c2fa1
+}
2c2fa1
+
2c2fa1
+gdb_test "next" {!\$omp parallel} "step closer"
2c2fa1
+gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp"
2c2fa1
+
2c2fa1
+gdb_breakpoint [gdb_get_line_number "success"]
2c2fa1
+gdb_continue_to_breakpoint "success" ".*success.*"
2c2fa1
Index: gdb-7.5.50.20130118/gdb/testsuite/gdb.fortran/omp-step.f90
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.5.50.20130118/gdb/testsuite/gdb.fortran/omp-step.f90	2013-01-19 23:38:23.213372622 +0100
2c2fa1
@@ -0,0 +1,32 @@
2c2fa1
+! Copyright 2009 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+! This program is free software; you can redistribute it and/or modify
2c2fa1
+! it under the terms of the GNU General Public License as published by
2c2fa1
+! the Free Software Foundation; either version 3 of the License, or
2c2fa1
+! (at your option) any later version.
2c2fa1
+!
2c2fa1
+! This program is distributed in the hope that it will be useful,
2c2fa1
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+! GNU General Public License for more details.
2c2fa1
+!
2c2fa1
+! You should have received a copy of the GNU General Public License
2c2fa1
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
2c2fa1
+
2c2fa1
+      use omp_lib
2c2fa1
+      integer nthreads, i, a(1000)
2c2fa1
+      nthreads = omp_get_num_threads()
2c2fa1
+      if (nthreads .gt. 1000) call abort
2c2fa1
+
2c2fa1
+      do i = 1, nthreads
2c2fa1
+          a(i) = 0
2c2fa1
+      end do
2c2fa1
+      print *, "start-here"
2c2fa1
+!$omp parallel
2c2fa1
+      a(omp_get_thread_num() + 1) = 1
2c2fa1
+!$omp end parallel
2c2fa1
+      do i = 1, nthreads
2c2fa1
+          if (a(i) .ne. 1) call abort
2c2fa1
+      end do
2c2fa1
+      print *, "success"
2c2fa1
+      end