When you just make program from single source file, debug is easy. When you make a typical c++ program from three files ( header file, implementation class, main program ), it is still easy to debug with gdb. Just set breakpoint in main source code, then step, step, step, step. Although you don't set breakpoint in implementation file, it will bring you into it because you just step step step from main file.
But if you make a GUI--C++ based program like qt, or gtk applications, it become complicated. Right now I am making C++ program using gtkmm library. The main file is so simple that put breakpoint in this file is unneccessary. Look my main program:
Code:
#include <config.h>
#include <gtkmm/main.h>
#include "window1.hh"
int main(int argc, char **argv)
{
Gtk::Main m(&argc, &argv);
window1 *window1 = new class window1();
m.run(*window1);
delete window1;
return 0;
}
Nothing usefull here for our debugging process. What I want to watch is the functions in implementation file, let's said it window1.cc:
Code:
.............
//Here's the stuff I want to keep my eye on
void on_button_click() {
int blabla;
float blablabla();
switch(blablaba) {
case blabla1: doing_blabla(); //I want to set my breakpoint here
............
How can I set breakpoint in implementation file?
$ gdb the_binary
gdb> list
This will list my main program file, so nothing useful.
If I set breakpoint in this line:
m.run(*window1);
Hopefully, after stop in this breakpoint I will step, step, step until I come in implementation file. But I got this error/warning if I step from there:
Gtk::Main::run (window=Internal: global symbol `Window' found in window.cc psymtab but not in symtab.
Window may be an inlined function, or may be a template function
(if a template, try specifying an instantiation: Window<type>).
) at main.cc:422
422 main.cc: No such file or directory.
in main.cc
Step again, got this:
Gtk::Widget::show (this=0x807f4d0) at widget.h:312
312 widget.h: No such file or directory.
in widget.h
And so on.....................
I know if I use IDE like Anjuta, it will set my debugger option automatically. But unfortunately, the editor in Anjuta sucks. I use Vim as my text editor, Glade to make user interface, and console to compile this program.
I have used something so called gdb frontend:
ddd ------------> I got the same problem...... no main.cc, no blablabla......
insight -------------> This is almost perfect........ It set up the option for debugger automatically so I can put breakpoint in implementation file...... Unfortunately, because maybe I make a serious bug in my program, the debugger hang up when I continue after breakpoint in m.run(*window1);.
Kdbg -------------> My program has very very serious bug because I got this message after I load the executable: gdb: Using host libthread_db library "/lib/libthread_db.so.1".
So I want to try gdb console alternative to debug my buggy program. Help me, buddies!!!!