Debugging OpenMP* Programs

The debugger is capable of providing information on OpenMP* locks, teams and threads when debugging an OpenMP application.

note:

OpenMP programs debugging is not supported on Mac OS* X.

To enable this support, make sure the debugger has access to the shared library libomp_db.so, which by default is in the lib directory in your compiler installation.

The debugger automatically enables OpenMP support when it detects that the debuggee is an OpenMP program. To switch off OpenMP support, use the following command:

(idb) set $threadlevel="native"

To switch it back on, use the following command:

(idb) set $threadlevel="openmp"

When OpenMP support is on, use the following commands to inspect the states of the OpenMP objects in your program. Note that the thread IDs used in the following commands are debugger thread IDs and not the OpenMP thread IDs. Use these thread IDs in any debugger command that takes a thread ID, such as show_thread.:

1. show_lock_command

:show lock [lock_id, ...]

This command displays the state of the locks that are specified, or the state of all the locks if none is specified. For example:

(idb) show lock nlk

Id                  Type    State   Holder Id     Level     Waiters

0x6000000000009e00  nested  held    1             1         3 threads: 2, 3, 4

In this example, the nlk lock is a nested lock that is being held by Thread 1, which has set it only once (the Level). Threads 2, 3, and 4 are waiting for it.

2. show_openmp_thread_tree_command

This command displays the threads in the process in a tree format to illustrate the team master/member relation between threads. For example:

(idb) show openmp thread tree

Team 6917529027641117440

`--[0] Thread 1

   #--Team 6917529027641120768

      |--[0] Thread 1

      |  #--Team 6917529027641153024

      |     |--[0] Thread 1

      |     |--[1] Thread 5

      |     `--[2] Thread 4

      `--[1] Thread 3

         #--Team 6917529027641184768

            |--[0] Thread 3

            |--[1] Thread 7

            `--[2] Thread 6

The numbers in square brackets are the OpenMP thread IDs in their respective team.

3. show_team_command

: show team [team_id, ...]

This command displays the information of the OpenMP teams. If you specify one or more team identifiers, the debugger displays information about the teams you specify. If you omit a team specification, the debugger displays information for all teams. For example:

(idb) show team 6917529027641120768

OpenMP Team:  6917529027641120768

Parent Team:  6917529027641117440

Created At:   "/projects/OpenMP/src/c_omp.c":main:58:98

Team members

  [0] Thread 1, is master of team 6917529027641153024

  [1] Thread 3, is master of team 6917529027641184768