ROCgdb icon indicating copy to clipboard operation
ROCgdb copied to clipboard

[Issue]: Line breakpoint can be missed when disabling deferred loading

Open lancesix opened this issue 9 months ago • 0 comments

Problem Description

Take the following sample contrived program:

#include <hip/hip_runtime.h>
#include <type_traits>

template<typename T>
__device__ __host__ void
classify (T k)
{
  if constexpr (std::is_floating_point_v<T>)
    printf ("This is some sort of float\n");
  else
    printf ("Not a float\n");
}

__global__ void
kern1 ()
{
  classify (1);
}
__global__ void
kern2 ()
{
  classify (1.);
}

int
main ()
{
  classify (1);
  kern1<<<1, 1>>> ();
  return hipDeviceSynchronize () != hipSuccess;
}

Build it as usual with hipcc -g -O0 repro.cpp, we can try to debug and set a breakpoint at the "if constexpr" line:

 rocgdb  -q -ex "with breakpoint pending on -- b 8" -ex r -args a.out
Reading symbols from a.out...
Breakpoint 1 at 0x201d5b: file repro.cpp, line 11.
Starting program: /home/lancesix/work/HTEC/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, classify<int> (k=1) at repro.cpp:11
11          printf ("Not a float\n");
(gdb)

If we disable deferred loading, then we miss hitting the breakpoint:

$ HIP_ENABLE_DEFERRED_LOADING=0 rocgdb  -q -ex "with breakpoint pending on -- b 8" -ex r -args a.out
Reading symbols from a.out...
Breakpoint 1 at 0x201e5b: file repro.cpp, line 11.
Starting program: /home/lancesix/work/HTEC/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff55ff6c0 (LWP 125008)]
[New Thread 0x7ffef4bff6c0 (LWP 125009)]
[Thread 0x7ffef4bff6c0 (LWP 125009) exited]
[New Thread 0x7ffee37ff6c0 (LWP 125010)]
Not a float
[New Thread 0x7ffee11ff6c0 (LWP 125011)]
[Thread 0x7ffee11ff6c0 (LWP 125011) exited]
[New Thread 0x7ffff619f6c0 (LWP 125012)]
Not a float
warning: Temporarily disabling breakpoints for unloaded shared library "file:///home/lancesix/work/HTEC/a.out#offset=12288&size=82936"
[Thread 0x7ffff619f6c0 (LWP 125012) exited]
[Thread 0x7ffee37ff6c0 (LWP 125010) exited]
[Thread 0x7ffff55ff6c0 (LWP 125008) exited]
[Inferior 1 (process 125001) exited normally]
(gdb)

The breakpoint should be hit regardless of the value of the HIP_ENABLE_DEFERRED_LOADING environment variable.

Operating System

Any

CPU

Any

GPU

Any

ROCm Version

Any

ROCm Component

ROCgdb

Steps to Reproduce

No response

(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support

No response

Additional Information

No response

lancesix avatar Apr 29 '25 13:04 lancesix