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 the necessary setup steps and got a sample code as described in the Get Started Guide.

Basic Debugging#

52        h.parallel_for(data_range, [=](id<1> index) {
53            int id0 = GetDim(index, 0);
54            int element = in[index];  // breakpoint-here
55            int result = element + 50;
56            if (id0 % 2 == 0) {
57                result = result + 50;  // then-branch
58            } else {
59                result = -1;  // else-branch
60            }
61            out[index] = result;
62        });
  1. Set a breakpoint inside the kernel at line 54 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.