Tutorial: Debugging with Intel® Distribution for GDB*
A common debugging activity is single-stepping in the source. To check the current thread data, run the thread command. You should get the following output:
[Current thread is 3 (Thread 0x7fffdba79700 (LWP 21605))]
To check the data of a particular thread, run the following command:
info thread 3
Example output:
Id Target Id Frame * 3 Thread <id omitted> main::$_1::operator()<omitted> at array-transform.cpp:56
If now you run next to make the thread 3 move forward by one source line, you should see the following output:
[Switching to Thread 0x7fffdb277700 (LWP 21607)] Thread 5 "array-transform" hit Breakpoint 1, main::$_1::operator()<omitted> at array-transform.cpp:56 56 int element = in[index]; // breakpoint-here
Stepping has not occurred. Instead, a breakpoint event from thread 5 is received and the debugger switched the context to that thread. This happens because you are debugging a multi-threaded program and multiple events may be received from different threads. This is the default behavior but you can configure it for more efficient debugging. To ensure the current thread executes a single line without interference, set the scheduler-locking setting to on or step:
set scheduler-locking step
Continue executing the next command. You should see the following outputs:
57 int result = element + 50;
58 if (id0 % 2 == 0) {
If you run print index now, you should see the following output:
$6 = cl::sycl::id<1> = {16}
Run print in[index] - the expected output looks as follows:
$7 = 116
Finally, run print result to see the following:
$8 = 166