How to print global variables/arrays in cuda-gdb

I was trying debugging the Cuda Fortran code using the cuda-gdb. However, I got wrong values when I printed the global variables inside the cude-gdb.
Here is the source code:

module test
attributes(global) subroutine saxpy(x,y,a)
implicit none
real,device :: x(:), y(:)
real,value :: a
integer :: i, n

n = size(x)
i = blockDim%x * (blockIdx%x - 1) + threadIdx%x
if (i <= n) y(i) = y(i) + a*x(i)

end subroutine saxpy
end module test

program testSaxpy
use test
use cudafor
implicit none
integer, parameter :: N = 40000
real :: x(N), y(N), result(N), a
real, device :: x_d(N), y_d(N)
type(dim3) :: grid, tBlock
integer :: i

tBlock = dim3(256,1,1)
grid = dim3(ceiling(real(N)/tBlock%x),1,1)

a = 2.0

do i = 1,N
x(i) = float(i)
y(i) = 3.0*float(i)

result = a*x + y

x_d = x
y_d = y
call saxpy<<<grid, tBlock>>>(x_d,y_d,a)
y = y_d
write( , ) 'Max error: ', maxval(abs(y-result))
end program testSaxpy

The file was compiled using the following command:
pgf90 -Mcuda=cc8.0 testSaxpy.cuf -O0 -g -Mcuda=debug -Mcuda=nordc
Then I ran:
cuda-gdb ./a.out
Then I set a break point:
b 10
Then run the code:
Then at the break point, I tried to print the value of x(1):
p x(1)
and it displayed:
$1 = -6.75539944e+15
which was not correct.

Did I miss anything?
Please let me know if you know how to print the global variables correctly in cuda-gdb. Thanks a lot!

Thank you for reporting this!
This is a known issue with our tools and we are working to get this fixed in upcoming CUDA toolkit releases. I will update this topic once the fixed tools are available.

Hi @XZHU1,
This problem should be fixed now in CUDA 11.5. You can download it from CUDA Toolkit | NVIDIA Developer