I've now made a simple program with two files
main.cpp which contains
Code:
#include "myworld3.h"
#include <stdio.h>
int main(int argc, char **argv)
{
myWorld3 *mainWin = 0;
int i;
i=99;
printf("%d\n",i);
mainWin = new myWorld3();
}
and myworld3.cpp which contains
Code:
#include "myworld3.h"
#include <stdio.h>
myWorld3::myWorld3()
{
printf("Hello World\n");
}
myWorld3::~myWorld3()
{
}
Possibly the relevant part of the compilation for the two files is
if g++ -DHAVE_CONFIG_H -I. -I/home/alex/myworld3/src -I.. -I/opt/kde/include -I/usr/lib/qt/include -I/usr/X11R6/include -DQT_THREAD_SUPPORT -D_REENTRANT -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -ggdb3 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o /home/alex/myworld3/src/main.cpp;
and
if g++ -DHAVE_CONFIG_H -I. -I/home/alex/myworld3/src -I.. -I/opt/kde/include -I/usr/lib/qt/include -I/usr/X11R6/include -DQT_THREAD_SUPPORT -D_REENTRANT -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -ggdb3 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -MT myworld3.o -MD -MP -MF ".deps/myworld3.Tpo" -c -o myworld3.o /home/alex/myworld3/src/myworld3.cpp;
then for libtool - not sure where this comes into the picture -
/bin/sh ../libtool --silent --tag=CXX --mode=link g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall -W -Wpointer-arith -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -ggdb3 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -o myworld3 -R /opt/kde/lib -R /usr/lib/qt/lib -R /usr/X11R6/lib -L/usr/X11R6/lib -L/usr/lib/qt/lib -L/opt/kde/lib main.o myworld3.o -lkdeui
I then run gdb on the executable setting 1 breakpoint in main.cpp and another in myworld3.cpp. gdb stops at the first breakpoint but not the second.
alex@LINUX:~/myworld3/debug/src$ gdb myworld3
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main.cpp:10
Breakpoint 1 at 0x8048766: file /home/alex/myworld3/src/main.cpp, line 10.
(gdb) b myworld3.cpp:6
Breakpoint 2 at 0x804879f: file /home/alex/myworld3/src/myworld3.cpp, line 6.
(gdb) run
Starting program: /home/alex/myworld3/debug/src/myworld3
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 25813)]
99
[Switching to Thread 16384 (LWP 25813)]
Breakpoint 1, main (argc=1, argv=0xbfffe924) at /home/alex/myworld3/src/main.cpp:10
10 mainWin = new myWorld3();
(gdb) c
Continuing.
Hello World
Program exited normally.
(gdb) quit
alex@LINUX:~/myworld3/debug/src$
Also I can step from the first breakpoint(in main.cpp) into myworld3.cpp like so
alex@LINUX:~/myworld3/debug/src$ gdb myworld3
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main.cpp:10
Breakpoint 1 at 0x8048766: file /home/alex/myworld3/src/main.cpp, line 10.
(gdb) b myworld3.cpp:6
Breakpoint 2 at 0x804879f: file /home/alex/myworld3/src/myworld3.cpp, line 6.
(gdb) run
Starting program: /home/alex/myworld3/debug/src/myworld3
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 26441)]
99
[Switching to Thread 16384 (LWP 26441)]
Breakpoint 1, main (argc=1, argv=0xbfffef24) at /home/alex/myworld3/src/main.cpp:10
10 mainWin = new myWorld3();
(gdb) s
myWorld3 (this=0x804fad8) at /home/alex/myworld3/src/myworld3.cpp:5
5 {
(gdb) s
6 printf("Hello World\n");
(gdb) c
Continuing.
Hello World
Program exited normally.
(gdb)
Notice that it didn't stop at
Code:
printf("Hello World\n");
Has anyone any suggestions as to why this should be so?