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
Jan Kratochvil eb6cb2d
Index: gdb-7.7.90.20140613/gdb/infrun.c
Jan Kratochvil 6fa2f55
===================================================================
Jan Kratochvil eb6cb2d
--- gdb-7.7.90.20140613.orig/gdb/infrun.c	2014-06-13 21:59:10.835805512 +0200
Jan Kratochvil eb6cb2d
+++ gdb-7.7.90.20140613/gdb/infrun.c	2014-06-13 21:59:31.064829121 +0200
Jan Kratochvil eb6cb2d
@@ -4820,6 +4820,16 @@ process_event_stop_test (struct executio
0911f37
 
Jan Kratochvil 6fa2f55
       if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
0911f37
 	{
0911f37
+	  struct symbol *stop_fn = find_pc_function (stop_pc);
Jan Kratochvil 872aab0
+	  struct minimal_symbol *stopf = lookup_minimal_symbol_by_pc (stop_pc).minsym;
0911f37
+
Jan Kratochvil 556378e
+	  if ((stop_fn == NULL
Jan Kratochvil 556378e
+	       || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL)
Jan Kratochvil 556378e
+	      /* gcc-4.7.2-9.fc19.x86_64 uses a new format.  */
Jan Kratochvil 556378e
+	      && (stopf == NULL
Jan Kratochvil eb6cb2d
+		  || strstr (MSYMBOL_LINKAGE_NAME (stopf), "._omp_fn.") == NULL))
0911f37
+{	/* ".omp_fn." */
0911f37
+
0911f37
 	  /* We're doing a "next".
0911f37
 
0911f37
 	     Normal (forward) execution: set a breakpoint at the
Jan Kratochvil eb6cb2d
@@ -4855,6 +4865,7 @@ process_event_stop_test (struct executio
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
Jan Kratochvil eb6cb2d
Index: gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/omp-step.exp
Jan Kratochvil 6fa2f55
===================================================================
Jan Kratochvil 6fa2f55
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil eb6cb2d
+++ gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/omp-step.exp	2014-06-13 21:59:22.801819481 +0200
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
Jan Kratochvil 3b55f78
+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90 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.*"
Jan Kratochvil eb6cb2d
Index: gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/omp-step.f90
Jan Kratochvil 6fa2f55
===================================================================
Jan Kratochvil 6fa2f55
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil eb6cb2d
+++ gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/omp-step.f90	2014-06-13 21:59:22.801819481 +0200
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