aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads/omp-task.c
diff options
context:
space:
mode:
authorAlok Kumar Sharma <AlokKumar.Sharma@amd.com>2022-05-22 21:46:06 +0530
committerKavitha Natarajan <kavitha.natarajan@amd.com>2022-05-22 21:46:06 +0530
commit6f9b09edaee43ea34d34b1998fe7b844834f251a (patch)
treec0ae8cd64603201c664070d06c2efdc9dcee4bab /gdb/testsuite/gdb.threads/omp-task.c
parentcb3a7614feb82ffdc25161bf60529116c6112ab3 (diff)
downloadgdb-6f9b09edaee43ea34d34b1998fe7b844834f251a.zip
gdb-6f9b09edaee43ea34d34b1998fe7b844834f251a.tar.gz
gdb-6f9b09edaee43ea34d34b1998fe7b844834f251a.tar.bz2
Accept functions with DW_AT_linkage_name present
Currently GDB is not able to debug (Binary generated with Clang) variables present in shared/private clause of OpenMP Task construct. Please note that LLVM debugger LLDB is able to debug. In case of OpenMP, compilers generate artificial functions which are not present in actual program. This is done to apply parallelism to block of code. For non-artifical functions, DW_AT_name attribute should contains the name exactly as present in actual program. (Ref# http://wiki.dwarfstd.org/index.php?title=Best_Practices) Since artificial functions are not present in actual program they not having DW_AT_name and having DW_AT_linkage_name instead should be fine. Currently GDB is invalidating any function not havnig DW_AT_name which is why it is not able to debug OpenMP (Clang). It should be fair to fallback to check DW_AT_linkage_name in case DW_AT_name is absent.
Diffstat (limited to 'gdb/testsuite/gdb.threads/omp-task.c')
-rw-r--r--gdb/testsuite/gdb.threads/omp-task.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/omp-task.c b/gdb/testsuite/gdb.threads/omp-task.c
new file mode 100644
index 0000000..bdeeae5
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/omp-task.c
@@ -0,0 +1,49 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2022 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/>.
+
+ Tests which verify (or not) that GDB can access shared and private
+ clauses of OpenMP task construct.
+*/
+
+#include <stdio.h>
+#include <omp.h>
+
+int foo(int n) {
+ int share1 = 9, share2 = 11, share3 = 13, priv1, priv2, fpriv;
+ fpriv = n + 4;
+
+ if (n < 2)
+ return n;
+ else {
+#pragma omp task shared(share1, share2) private(priv1, priv2) firstprivate(fpriv) shared(share3)
+ {
+ priv1 = n;
+ priv2 = n + 2;
+ share2 += share3;
+ printf("share1 = %d, share2 = %d, share3 = %d\n", share1, share2, share3);
+ share1 = priv1 + priv2 + fpriv + foo(n - 1) + share2 + share3;
+ }
+#pragma omp taskwait
+ return share1 + share2 + share3;
+ }
+}
+
+int main() {
+ int n = 10;
+ printf("foo(%d) = %d\n", n, foo(n));
+ return 0;
+}