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