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