]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-bz533176-fortran-omp-step.patch
- rel 5
[packages/gdb.git] / gdb-bz533176-fortran-omp-step.patch
CommitLineData
51a5ef0f
PS
1https://bugzilla.redhat.com/show_bug.cgi?id=533176#c4
2
3I find it a bug in DWARF and gdb behaves correctly according to it. From the
4current DWARF's point of view the is a function call which you skip by "next".
5
6If you hide any /usr/lib/debug such as using:
7gdb -nx -ex 'set debug-file-directory /qwe' -ex 'file ./tpcommon_gfortran44'
8and use "step" command instead of "next" there it will work.
9(You need to hide debuginfo from libgomp as you would step into libgomp sources
10to maintain the threads for execution.)
11
12There should be some DWARF extension for it, currently tried to detect
13substring ".omp_fn." as this function is called "MAIN__.omp_fn.0" and do not
14consider such sub-function as a skippable by "next".
15
16Another problem is that with "set scheduler-locking" being "off" (default
17upstream) or "step" (default in F/RHEL) the simultaneous execution of the
18threads is inconvenient. Setting it to "on" will lockup the debugging as the
19threads need to get synchronized at some point. This is a more general
20debugging problem of GOMP outside of the scope of this Bug.
21
22
23
24--- ./gdb/infrun.c 2009-12-09 22:03:33.000000000 +0100
25+++ ./gdb/infrun.c 2009-12-09 22:29:56.000000000 +0100
26@@ -3994,6 +3994,12 @@ infrun: not switching back to stepped th
27
28 if (ecs->event_thread->step_over_calls == STEP_OVER_ALL)
29 {
30+ struct symbol *stop_fn = find_pc_function (stop_pc);
31+
32+ if (stop_fn == NULL
33+ || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL)
34+{ /* ".omp_fn." */
35+
36 /* We're doing a "next".
37
38 Normal (forward) execution: set a breakpoint at the
39@@ -4020,6 +4026,7 @@ infrun: not switching back to stepped th
40
41 keep_going (ecs);
42 return;
43+} /* ".omp_fn." */
44 }
45
46 /* If we are in a function call trampoline (a stub between the
47--- ./gdb/testsuite/gdb.fortran/omp-step.exp 1970-01-01 01:00:00.000000000 +0100
48+++ ./gdb/testsuite/gdb.fortran/omp-step.exp 2009-12-09 22:31:04.000000000 +0100
49@@ -0,0 +1,31 @@
50+# Copyright 2009 Free Software Foundation, Inc.
51+
52+# This program is free software; you can redistribute it and/or modify
53+# it under the terms of the GNU General Public License as published by
54+# the Free Software Foundation; either version 3 of the License, or
55+# (at your option) any later version.
56+#
57+# This program is distributed in the hope that it will be useful,
58+# but WITHOUT ANY WARRANTY; without even the implied warranty of
59+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60+# GNU General Public License for more details.
61+#
62+# You should have received a copy of the GNU General Public License
63+# along with this program. If not, see <http://www.gnu.org/licenses/>.
64+
65+set testfile "omp-step"
66+set srcfile ${testfile}.f90
67+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f77 additional_flags=-fopenmp}] } {
68+ return -1
69+}
70+
71+if ![runto [gdb_get_line_number "start-here"]] {
72+ perror "Couldn't run to start-here"
73+ return 0
74+}
75+
76+gdb_test "next" {!\$omp parallel} "step closer"
77+gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp"
78+
79+gdb_breakpoint [gdb_get_line_number "success"]
80+gdb_continue_to_breakpoint "success" ".*success.*"
81--- ./gdb/testsuite/gdb.fortran/omp-step.f90 1970-01-01 01:00:00.000000000 +0100
82+++ ./gdb/testsuite/gdb.fortran/omp-step.f90 2009-12-09 22:25:35.000000000 +0100
83@@ -0,0 +1,32 @@
84+! Copyright 2009 Free Software Foundation, Inc.
85+
86+! This program is free software; you can redistribute it and/or modify
87+! it under the terms of the GNU General Public License as published by
88+! the Free Software Foundation; either version 3 of the License, or
89+! (at your option) any later version.
90+!
91+! This program is distributed in the hope that it will be useful,
92+! but WITHOUT ANY WARRANTY; without even the implied warranty of
93+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94+! GNU General Public License for more details.
95+!
96+! You should have received a copy of the GNU General Public License
97+! along with this program. If not, see <http://www.gnu.org/licenses/>.
98+
99+ use omp_lib
100+ integer nthreads, i, a(1000)
101+ nthreads = omp_get_num_threads()
102+ if (nthreads .gt. 1000) call abort
103+
104+ do i = 1, nthreads
105+ a(i) = 0
106+ end do
107+ print *, "start-here"
108+!$omp parallel
109+ a(omp_get_thread_num() + 1) = 1
110+!$omp end parallel
111+ do i = 1, nthreads
112+ if (a(i) .ne. 1) call abort
113+ end do
114+ print *, "success"
115+ end
This page took 0.484323 seconds and 4 git commands to generate.