Tutorial: Debugging with Intel® Distribution for GDB*

Debug an Application on a CPU

This section describes a basic scenario of debugging a sample SYCL* app, Array Transform, with the kernel offloaded to the CPU.

Before you proceed, make sure you have completed all necessary setup steps and got a sample code as described in the Get Started Guide.

Basic Debugging

54        h.parallel_for(data_range, [=](id<1> index) {
55            int id0 = GetDim(index, 0);
56            int element = in[index];  // breakpoint-here
57            int result = element + 50;
58            if (id0 % 2 == 0) {
59                result = result + 50;  // then-branch
60            } else {
61                result = -1;  // else-branch
62            }
63            out[index] = result;
64        });
  1. Set a breakpoint inside the kernel at line 56 marked as breakpoint-here in the array-transform.cpp file.

  2. To run the application, on the Debug toolbar, click image0Local Windows Debugger button.

    The program stops at the breakpoint.

  3. Now you can investigate local variables, print a stack trace, and get information on threads by opening the corresponding windows from the Debug tab.

    • To investigate local variables, go to Debug > Windows > Locals.

    • To get information on threads, go to Debug > Windows > Threads.

    • To look into disassembly, go to Debug > Windows > Disassembly.

    • To investigate general purpose registers, go to Debug > Windows > Registers.

Limitations

Kernel Functions

Kernel functions that have a call-by-value parameter of a class/struct type (for example, cl::sycl::id) cannot be used in the Watch window.

Accessor’s Operator []

The operator [] of an accessor object cannot be used in the Watch window.