Using GDB I can\'t seem to print the value of shared variables within OpenMP threads. For example, using the following program:
#include
#inclu
When I run your code I get similar results. If you look at the backtrace, it tells you that you are inside an OpenMP environment that is related to how GCC implements OpenMP.
(gdb) backtrace
#0 main._omp_fn.0 () at tmp.c:15
#1 0x000000000040082e in main (argc=1, argv=0x7fffffffe6c8) at tmp.c:7
You can get a value of pub by:
(gdb) up
(gdb) print pub
$1 = 100
but this only gets you the value of pub before the parallel region. You should check the answer by Hristo Iliev for a much more detailed and better description of the situation.