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