Using GDB I cannot print the value of shared variables in OpenMP streams. For example, using the following program:
#include <omp.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int priv, tid, pub = 100; #pragma omp parallel private(priv, tid) num_threads(2) { tid = omp_get_thread_num(); priv = tid * 10; #pragma omp sections { #pragma omp section { printf("SECTION 0: tid=%d, priv=%d, pub=%d\n", tid, priv, pub); } #pragma omp section { printf("SECTION 1: tid=%d, priv=%d, pub=%d\n", tid, priv, pub); } } } return EXIT_SUCCESS; }
In GDB, if I break line 15 (printf of section 0) and I try to print the value "pub", I get the pub "No symbol" in the current context. "message:
Breakpoint 1, main._omp_fn.0 () at omp_simplesec.c:15 15 printf("SECTION 0: tid=%d, priv=%d, pub=%d\n", tid, priv, pub); (gdb) print pub No symbol "pub" in current context.
I compile with GCC and unsuccessfully try various debug flags (-g3 -ggdb3 -gstabs3 -gstabs + 3). I also tried disabling all optimizations with -O0, again without success. However, I see the value of private variables using the -gstabs + flag.
Thanks in advance.
faken source share