Created attachment 10488 [details] Test case demonstrating problem with printing all variables in scope in OpenMP program When a breakpoint is placed within a parallel region within an OpenMP program, GDB is unable to print variables which are in scope, but which are not referenced within the parallel region. I've attached an example which I intend to use as a test which I plan to post to gdb-patches. (I'm filing this bug so I have a bug id to use for tests which I need to kfail.) This program can be compiled with the following command: gcc -o omp-par-scope -g -fopenmp omp-par-scope.c Debugging it in gdb and placing a breakpoint on the first printf (on line 39) and running to that breakpoint reveals that variable i3 cannot be printed... (gdb) b 39 Breakpoint 1 at 0x400b20: file omp-par-scope.c, line 39. (gdb) run Starting program: omp-par-scope [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7ffff73d6700 (LWP 8483)] Breakpoint 1, single_scope._omp_fn.0 () at omp-par-scope.c:39 39 printf ("single_scope: thread_num=%d, s1=%d, i1=%d, s2=%d, i2=%d\n", (gdb) print i3 No symbol "i3" in current context. This is what it looks like when it works correctly: (gdb) b 39 Breakpoint 1 at 0x400a6a: file omp-par-scope.c, line 39. (gdb) run Starting program: /mesquite2/sourceware-git/binutils-gdb/gdb/testsuite/gdb.threads/omp-par-scope [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7ffff73cb700 (LWP 8504)] [Switching to Thread 0x7ffff73cb700 (LWP 8504)] Thread 2 "omp-par-scope" hit Breakpoint 1, single_scope._omp_fn.0 () at omp-par-scope.c:39 39 printf ("single_scope: thread_num=%d, s1=%d, i1=%d, s2=%d, i2=%d\n", (gdb) print i3 $1 = 13 Moreover, continuing to the breakpoint again in the second/other thread should also correctly print i3: (gdb) c Continuing. single_scope: thread_num=1, s1=-41, i1=11, s2=202, i2=212 [Switching to Thread 0x7ffff7fd9780 (LWP 8500)] Thread 1 "omp-par-scope" hit Breakpoint 1, single_scope._omp_fn.0 () at omp-par-scope.c:39 39 printf ("single_scope: thread_num=%d, s1=%d, i1=%d, s2=%d, i2=%d\n", (gdb) print i3 $2 = 13
Proposed test case (or something very much like it) is now part of the GDB test suite. Work continues on the problem of being able to access each in-scope variable from threads other than the master thread.