|
| 1 | +Breakpoints |
| 2 | +=========== |
| 3 | + |
| 4 | +A `breakpoint` makes your program stop whenever a certain point in the program is reached. |
| 5 | + |
| 6 | +You can set breakpoints with the ``break`` command to specify the place where your program should stop in the kernel by line number or function name. |
| 7 | + |
| 8 | +You have several ways to set breakpoints: |
| 9 | + - break function |
| 10 | + - break filename:function |
| 11 | + - break filename:linenumber |
| 12 | + |
| 13 | +See also: |
| 14 | + - `GDB documentation of breakpoints`_. |
| 15 | + |
| 16 | +.. _GDB documentation of breakpoints: https://sourceware.org/gdb/current/onlinedocs/gdb/Set-Breaks.html#Set-Breaks |
| 17 | + |
| 18 | +Consider ``numba-dppy`` kernel code. See source file ``numba_dppy/examples/debug/simple_sum.py``: |
| 19 | + |
| 20 | +.. literalinclude:: ../../../numba_dppy/examples/debug/simple_sum.py |
| 21 | + :lines: 15- |
| 22 | + :linenos: |
| 23 | + |
| 24 | +Run debugger: |
| 25 | + |
| 26 | +.. code-block:: bash |
| 27 | +
|
| 28 | + export NUMBA_DPPY_DEBUGINFO=1 |
| 29 | + gdb-oneapi -q --args python simple_sum.py |
| 30 | +
|
| 31 | +``break function`` |
| 32 | +------------------ |
| 33 | + |
| 34 | +GDB output: |
| 35 | + |
| 36 | +.. code-block:: bash |
| 37 | +
|
| 38 | + (gdb) break data_parallel_sum |
| 39 | + Breakpoint 1 (data_parallel_sum) pending. |
| 40 | + (gdb) run |
| 41 | +
|
| 42 | + Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::data_parallel_sum () at simple_sum.py:20 |
| 43 | + 20 @dppy.kernel |
| 44 | +
|
| 45 | +``break filename: linenumber`` |
| 46 | +------------------------------ |
| 47 | + |
| 48 | +GDB output: |
| 49 | + |
| 50 | +.. code-block:: bash |
| 51 | +
|
| 52 | + (gdb) break simple_sum.py:20 |
| 53 | + Breakpoint 1 (simple_sum.py:20) pending. |
| 54 | + (gdb) run |
| 55 | + |
| 56 | + Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::data_parallel_sum () at simple_sum.py:20 |
| 57 | + 20 @dppy.kernel |
| 58 | +
|
| 59 | +``break filename: function`` |
| 60 | +---------------------------- |
| 61 | + |
| 62 | +GDB output: |
| 63 | + |
| 64 | +.. code-block:: bash |
| 65 | +
|
| 66 | + (gdb) break simple_sum.py:data_parallel_sum |
| 67 | + Breakpoint 1 (simple_sum.py:data_parallel_sum) pending. |
| 68 | + (gdb) run |
| 69 | + |
| 70 | + Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::data_parallel_sum () at simple_sum.py:20 |
| 71 | + 20 @dppy.kernel |
| 72 | +
|
| 73 | +Breakpoints with nested functions |
| 74 | +------------------------------------- |
| 75 | + |
| 76 | +Consider ``numba-dppy`` kernel code. See source file ``numba_dppy/examples/debug/simple_dppy_func.py``: |
| 77 | + |
| 78 | +.. literalinclude:: ../../../numba_dppy/examples/debug/simple_dppy_func.py |
| 79 | + :lines: 15- |
| 80 | + :linenos: |
| 81 | + |
| 82 | +GDB output: |
| 83 | + |
| 84 | +.. code-block:: bash |
| 85 | +
|
| 86 | + export NUMBA_DPPY_DEBUGINFO=1 |
| 87 | + gdb-oneapi -q --args python simple_sum.py |
| 88 | + (gdb) break func_sum |
| 89 | + Breakpoint 1 (func_sum) pending. |
| 90 | + (gdb) run |
| 91 | +
|
| 92 | + Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], __main__::func_sum () at simple_dppy_func.py:22 |
| 93 | + 22 result = a_in_func + b_in_func |
0 commit comments