gdb/kdevelop and make dbg=1

I am using kdevelop and in order to use the debug symbols and need to set the “dbg=1” flag for make.

if I put it into Project->Project Options->Build Options->Make and set the Additional Make options to “dbg=1”, or even if I directly use the “make dbg=1” command in the terminal, I get the following error

g++ -m32 -fPIC -o …/…/bin/linux32/debug/gpumain gpumain.c …/…/bin/obj/debug/mylib.cu_o -L/usr/local/cuda/lib -L…/…/lib -lcuda -lcudart -lGL -lGLU -l cutilD

/usr/bin/ld: cannot find -lcutilD

collect2: ld returned 1 exit status

make: *** […/…/bin/linux32/debug/gpumain] Error 1

if I do not build with dbg=1 i don’t create debug symbols and gdb doesn’t work ( it works and creates a binary without error, but I need to debug it now)

if I just “Make” the lib is -lcutil and not -lcutilD which I don’t seem to have

You don’t have cutilD because you forgot to build it.

After installing the SDK (the cutil lib is the helper lib in there), you need to run both ‘make’ and ‘make dbg=1’ to build both versions of the helper lib and the examples.

Peter

Thanks - that made it for the -lcutilD error
but I still get the same error message from gdb using the new build -

No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
at each line with a breakpoint???
I’m sure the file is there of course, and that the binary used by gdb is the result of the “make dbg=1” command

  • can I trust common.mk to add the necessary flags for gdb using the dbg=1 flag or do I need to add them manually and tweak the makefile???
    thanks a lot for the help

Not sure what you mean by “necessary flags”. For debugging -g is sufficient. This is done by common.mk.

Can you post the full shell output? To me it looks like you are running in the wrong pwd.

Peter

I don’t know what pwd I’m in when I run gdb through kdevelop - i don’t want to use gdb in the terminal as I’m used with debugging through xcode and kdevelop
I placed a copy of the binary produced in …/linux32/debug in my project folder in order to have both binary and source files in the same folder
maybe I haven’t got a variable properly set in kdevelop project options that makes me run gdb from another directory??? I’ve set the run and build options

full output:

<edit: new output with proper folder in “build options”, same errors">

gdb gpumain -fullname -quiet
(gdb) set edit off
(gdb) set confirm off
Using host libthread_db library “/lib/tls/i686/cmov/libthread_db.so.1”.
(gdb)
(gdb)
(gdb) set print static-members off
(gdb) tty /dev/pts/3
(gdb) set width 0
(gdb) set height 0
(gdb) set stop-on 1
(gdb) handle SIG32 pass nostop noprint
(gdb) handle SIG41 pass nostop noprint
(gdb) handle SIG42 pass nostop noprint
(gdb) handle SIG43 pass nostop noprint
(gdb) set print asm-demangle on
(gdb) set output-radix 10
(gdb) cd /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/
(gdb) set args /home/alex/NVIDIA_CUDA_SDK/bin/linux32/release/test_files/fp793.wsq.xyt /home/alex/NVIDIA_CUDA_SDK/bin/linux32/release/test_files/fp793.wsq.xyt
(gdb) set environment LD_LIBRARY_PATH=/usr/local/cuda/lib
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:92
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:86
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:88
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:89
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:90
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:30
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:32
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:18
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) run
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
Stopped due to shared library event
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:92
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:86
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:88
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:89
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:90
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:30
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:32
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:18
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) continue
[Thread debugging using libthread_db enabled]
[New Thread -1223338256 (LWP 28595)]
Stopped due to shared library event
(gdb) info thread
1 Thread -1223338256 (LWP 28595) 0xb7fa76f0 in _dl_debug_state () from /lib/ld-linux.so.2
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:92
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:86
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:88
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:89
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:90
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:30
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:32
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

(gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:18
No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
(gdb) continue

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1223338256 (LWP 28595)]
0xb7c1bdc9 in vfprintf () from /lib/tls/i686/cmov/libc.so.6
(gdb) info thread

  • 1 Thread -1223338256 (LWP 28595) 0xb7c1bdc9 in vfprintf () from /lib/tls/i686/cmov/libc.so.6
    (gdb) backtrace
    #0 0xb7c1bdc9 in vfprintf () from /lib/tls/i686/cmov/libc.so.6
    #1 0xb7c24d22 in fprintf () from /lib/tls/i686/cmov/libc.so.6
    #2 0x0804af18 in zs_rcp_load ()
    #3 0x0804b225 in match ()
    #4 0x0804b52f in main ()
    (gdb) info args
    No symbol table info available.
    (gdb) info local
    No symbol table info available.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:92
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:86
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:88
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:89
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:90
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:30
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:32
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.
    (gdb) break /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c:18
    No source file named /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/gpumain.c.

I would say it tries to run the release version and finds no symbols.

Peter

there is a debug binary in /home/alex/NVIDIA_CUDA_SDK/projects/libFingCUDA/
and the 2 args that refer to the …/release directory
/home/alex/NVIDIA_CUDA_SDK/bin/linux32/release/test_files/fp793.wsq.xyt
are data files that the binary needs to run (that are in the /release folder. I could place them in another folder, but it wouldn’t change anything, would it?)