Author Topic: Debugging doesnt work in CodeBlocks, [GDB][GCC]  (Read 7362 times)

Offline tomb_unaff

  • Single posting newcomer
  • *
  • Posts: 6
Debugging doesnt work in CodeBlocks, [GDB][GCC]
« on: December 07, 2008, 05:40:01 pm »
Hi,

Can anyone tell me why debugging doesnt work in CodeBlocks but its working fine in command line debuger -GDB.

In CodeBlocks it says: "No symbol table is loaded.  Use the "file" command."  How do I load symbol table, AFAIK debugging symbols are already placed in compiled executable file - in my case: clamscan.

Please have a look @ screenshot:   http://omploader.org/vengw

From other hand if I run command line GDB debuger it seems to be ok:

Code
tomb@tomb_localhost ~/projects/aau/virus_scanner/codeblocks/clamAV/clamscan $ ls
Makefile     cfgparser.o  clamscan.o      ex2.layout  manager.c  misc.o     others.h  work.workspace
Makefile.am  clamscan     clamscan_opt.h  getopt.o    manager.h  options.o  others.o  workspace.workspace
Makefile.in  clamscan.c   ex2.cbp         global.h    manager.o  others.c   output.o

tomb@tomb_localhost ~/projects/aau/virus_scanner/codeblocks/clamAV/clamscan $ gdb clamscan
GNU gdb 6.7.1
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x404cd0: file clamscan.c, line 63.
(gdb) r
Starting program: /home/tomb/projects/aau/virus_scanner/codeblocks/clamAV/clamscan/clamscan
[Thread debugging using libthread_db enabled]
[New Thread 0x7f06de5fa6f0 (LWP 19649)]
[Switching to Thread 0x7f06de5fa6f0 (LWP 19649)]

Breakpoint 1, main (argc=1, argv=0x7fffe6610708) at clamscan.c:63
63 {
(gdb) n
82     sigemptyset(&sigset);
(gdb) n
83     sigaddset(&sigset, SIGXFSZ);
(gdb) n
84     sigprocmask(SIG_SETMASK, &sigset, NULL);
(gdb) n
87     opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, NULL, clamscan_deprecated);
(gdb) n
88     if(!opt) {
(gdb) n
87     opt = opt_parse(argc, argv, clamscan_shortopt, clamscan_longopt, NULL, clamscan_deprecated);
(gdb)

Thanks in advance for help,
Tom

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Debugging doesnt work in CodeBlocks, [GDB][GCC]
« Reply #1 on: December 07, 2008, 07:02:32 pm »
The problem is most likely, that C::B uses absolute paths for setting breakpoints, but your program is compiled with relative paths.

You have the following lines in your makefile:;

Code
abs_top_builddir = /home/tomb/projects/aau/virus_scanner/av_scan/example/my_ex1
abs_top_srcdir = /home/tomb/projects/aau/virus_scanner/av_scan/example/my_ex1

Code
top_builddir = .
top_srcdir = .

Building is done with the relative paths, not the absolute.

If that's the case and gdb is not started from the correct directory it will not work.

One solution would be to replace all relative paths with absolute ones in the makefile.

It might be enought to change the defines with relative paths to:

Code
top_builddir = ${abs_top_builddir}
top_srcdir = {abs_top_srcdir}

There are some more relative paths to change, the two lines above are just an example how it might work.

Here are some topics about the same problem:
http://forums.codeblocks.org/index.php/topic,9673.msg67893.html#msg67893
http://forums.codeblocks.org/index.php/topic,9689.msg67971.html#msg67971