Skip to content

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

@lancesix

Description

@lancesix

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions