]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-bz533176-fortran-omp-step.patch
- typo
[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
6ed6bacf
AM
24Index: gdb-7.2.50.20101231/gdb/infrun.c
25===================================================================
26--- gdb-7.2.50.20101231.orig/gdb/infrun.c 2011-01-01 01:02:45.000000000 +0100
27+++ gdb-7.2.50.20101231/gdb/infrun.c 2011-01-01 01:10:22.000000000 +0100
28@@ -4585,6 +4585,12 @@ infrun: not switching back to stepped th
51a5ef0f 29
6ed6bacf 30 if (ecs->event_thread->control.step_over_calls == STEP_OVER_ALL)
51a5ef0f
PS
31 {
32+ struct symbol *stop_fn = find_pc_function (stop_pc);
33+
34+ if (stop_fn == NULL
35+ || strstr (SYMBOL_LINKAGE_NAME (stop_fn), ".omp_fn.") == NULL)
36+{ /* ".omp_fn." */
37+
38 /* We're doing a "next".
39
40 Normal (forward) execution: set a breakpoint at the
6ed6bacf 41@@ -4612,6 +4618,7 @@ infrun: not switching back to stepped th
51a5ef0f
PS
42
43 keep_going (ecs);
44 return;
45+} /* ".omp_fn." */
46 }
47
48 /* If we are in a function call trampoline (a stub between the
6ed6bacf
AM
49Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.exp
50===================================================================
51--- /dev/null 1970-01-01 00:00:00.000000000 +0000
52+++ gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.exp 2011-01-01 01:09:58.000000000 +0100
51a5ef0f
PS
53@@ -0,0 +1,31 @@
54+# Copyright 2009 Free Software Foundation, Inc.
55+
56+# This program is free software; you can redistribute it and/or modify
57+# it under the terms of the GNU General Public License as published by
58+# the Free Software Foundation; either version 3 of the License, or
59+# (at your option) any later version.
60+#
61+# This program is distributed in the hope that it will be useful,
62+# but WITHOUT ANY WARRANTY; without even the implied warranty of
63+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+# GNU General Public License for more details.
65+#
66+# You should have received a copy of the GNU General Public License
67+# along with this program. If not, see <http://www.gnu.org/licenses/>.
68+
69+set testfile "omp-step"
70+set srcfile ${testfile}.f90
f412e1b4 71+if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90 additional_flags=-fopenmp}] } {
51a5ef0f
PS
72+ return -1
73+}
74+
75+if ![runto [gdb_get_line_number "start-here"]] {
76+ perror "Couldn't run to start-here"
77+ return 0
78+}
79+
80+gdb_test "next" {!\$omp parallel} "step closer"
81+gdb_test "next" {a\(omp_get_thread_num\(\) \+ 1\) = 1} "step into omp"
82+
83+gdb_breakpoint [gdb_get_line_number "success"]
84+gdb_continue_to_breakpoint "success" ".*success.*"
6ed6bacf
AM
85Index: gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.f90
86===================================================================
87--- /dev/null 1970-01-01 00:00:00.000000000 +0000
88+++ gdb-7.2.50.20101231/gdb/testsuite/gdb.fortran/omp-step.f90 2011-01-01 01:09:58.000000000 +0100
51a5ef0f
PS
89@@ -0,0 +1,32 @@
90+! Copyright 2009 Free Software Foundation, Inc.
91+
92+! This program is free software; you can redistribute it and/or modify
93+! it under the terms of the GNU General Public License as published by
94+! the Free Software Foundation; either version 3 of the License, or
95+! (at your option) any later version.
96+!
97+! This program is distributed in the hope that it will be useful,
98+! but WITHOUT ANY WARRANTY; without even the implied warranty of
99+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100+! GNU General Public License for more details.
101+!
102+! You should have received a copy of the GNU General Public License
103+! along with this program. If not, see <http://www.gnu.org/licenses/>.
104+
105+ use omp_lib
106+ integer nthreads, i, a(1000)
107+ nthreads = omp_get_num_threads()
108+ if (nthreads .gt. 1000) call abort
109+
110+ do i = 1, nthreads
111+ a(i) = 0
112+ end do
113+ print *, "start-here"
114+!$omp parallel
115+ a(omp_get_thread_num() + 1) = 1
116+!$omp end parallel
117+ do i = 1, nthreads
118+ if (a(i) .ne. 1) call abort
119+ end do
120+ print *, "success"
121+ end
This page took 0.046078 seconds and 4 git commands to generate.