Setting Breakpoints

Setting Line Breakpoints

When using msDebug to debug an operator, you can set line breakpoints on the execution program of the operator, that is, set breakpoints at a specific line in the operator code file.

  1. Add a breakpoint in line 114 of the kernel function implementation file matmul_leakyrelu. If the following information is displayed, one breakpoint is successfully added:
    (msdebug) b matmul_leakyrelu_kernel.cpp:114
    Breakpoint 1: where = device_debugdata`_ZN17MatmulLeakyKernelIDhDhffE7CopyOutEj_mix_aiv + 240 at matmul_leakyrelu_kernel.cpp:114:14, address = 0x000000000000ff88
    For details about the command output, see the following table.
    Table 1 Information description

    Field

    Definition

    device_debugdata

    Name of the .o file on the device.

    matmul_leakyrelu_kernel.cpp

    Name of the kernel function where the breakpoint is located.

    CopyOut

    Current function.

    240

    Offset of the breakpoint address relative to the address of the CopyOut function. For example, the offset of 0xff88 relative to the address of the CopyOut function is 240.

    address = 0x000000000000ff88

    Breakpoint address, that is, the logical relative address.

    • If an operator implementation file with the same name exists on both the host and kernel side, you are advised to use an absolute path to set a breakpoint to ensure that the breakpoint is set on the target file.
    • When a breakpoint is set on the source code file, an alarm indicating that the actual location cannot be found may be displayed, as shown in the following:
      (msdebug) b /home/xx/op_host/matmul_leakyrelu_kernel.cpp:24
      Breakpoint 1: no locations (pending on future shared by library load).
      WARNING:  Unable to resolve breakpoint to any actual locations.
      (msdebug)

      After an operator is executed, the actual position is automatically found and a breakpoint is automatically set.

  2. Run the operator program and wait until the breakpoint is reached.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    (msdebug) run
    Process 165366 launched: '${INSTALL_DIR}/projects/normal_sample/mix/matmul_leakyrelu.fatbin' (aarch64)
    [Launch of Kernel matmul_leakyrelu_custom on Device 1]
    Process 165366 stopped
    [Switching to focus on Kernel matmul_leakyrelu_custom, CoreId 14, Type aiv]
    * thread #1, name = 'matmul_leakyrel', stop reason = breakpoint 1.1
        frame #0: 0x000000000000ff88 device_debugdata`_ZN17MatmulLeakyKernelIDhDhffE7CopyOutEj_mix_aiv(this=0x000000000019fb60, count=0) at matmul_leakyrelu_kernel.cpp:114:14
       111          (uint16_t)(tiling.baseN * sizeof(cType) / DEFAULT_C0_SIZE),
       112          0,
       113          (uint16_t)((tiling.N - tiling.baseN) * sizeof(cType) / DEFAULT_C0_SIZE)};
    -> 114      DataCopy(cGlobal[startOffset], reluOutLocal, copyParam);
       115      reluOutQueue_.FreeTensor(reluOutLocal);
       116  }
       117
    (msdebug)
    

    0x000000000000ff88 indicates the address of the PC where the breakpoint is located.

If the operator code is compiled into the dynamic library and loaded by using the operator launch symbol, when a breakpoint is set before the run command is executed, the command output indicates that the breakpoint position is not found (pending on future shared library load). The dynamic library is loaded only after the program is executed. The operator debugging information is parsed after the run command is executed, and then the breakpoint is updated and reset.
(msdebug) b matmul_leakyrelu_kernel.cpp:55 
Breakpoint 1: no locations (pending on future shared library load). 
WARNING:  Unable to resolve breakpoint to any actual locations. 
(msdebug) run 
... 
1 location added to breakpoint 1
...  

Displaying Breakpoints

The following commands display the positions and sequence numbers of all breakpoints that have been set.

(msdebug) breakpoint list 
Current breakpoints:
1: file = 'add_custom.cpp', line = 85, exact_match = 0, locations = 1, resolved = 1, hit count = 1
  1.1: where = device_debugdata`::add_custom(uint8_t *__restrict, uint8_t *__restrict, uint8_t *__restrict) + 14348 [inlined] KernelAdd::CopyOut(int) + 1700 at add_custom.cpp:85:9, address = 0x000000000000380c, resolved, hit count = 1 

Deleting Breakpoints

  1. Delete the breakpoint with a specific line number.
    (msdebug) breakpoint delete 1
    1 breakpoints deleted; 0 breakpoint locations disabled.
  2. Resume the running of the program. Due to breakpoint deletion, the program keeps running to the last minute.
    1
    2
    3
    4
    5
    6
    7
    8
    (msdebug) c
    Process 165366 resuming
    4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00
    4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00
    4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00
    4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00 4096.00
    Process 165366 exited with status = 0 (0x00000000)
    (msdebug)