PDA

View Full Version : very strange behaviour



regix
19th July 2006, 20:04
Hi,

I'm develloping a GPL application and for the last weeks I have noticed a very strange behaviour of my application. I'm using kdevelop to write the code.
I have added a screenshot of the strange fact that although during the debuggingsession you can see tha the value of the variable is false, during testing in an if construction, execution goes on inside the if construction. It's a pity that I can't post a bigger screenshot (limitations of this forum).
What is going on, the laws of physics seem broken.

Regix

wysota
19th July 2006, 20:12
Did you check the value during runtime? Maybe there it is true and not false? Maybe you have some uninitialised variable somewhere which causes a random value during runtime and is zeroed while under debugger?

gfunk
19th July 2006, 20:21
heh, I hate when physics is broken. :p
maybe the executable code is out of sync? do a full clean rebuild? maybe the wrong dll/debug symbols is being loaded?
maybe there's a background thread running? but that would take some really weird timing.
can you look at the assembly code that is being run? maybe that might give a hint.

regix
19th July 2006, 20:46
Thanks for replying,

I have put a qDebug() statement in the method, but that doesn't show up in the output also.
It seems as my code is getting randomly executed. I will check for the variables to see if they are all initialized. About the assemblycode: How does one look at the assemblycode?

Rgx

wysota
19th July 2006, 20:50
I have put a qDebug() statement in the method, but that doesn't show up in the output also.

Is the application compiled in debug mode?

regix
19th July 2006, 21:00
No, in Release mode with Enable warnings,
should I compile it in Debug mode?

regix
19th July 2006, 21:07
I changed the project options in kdevelop to compile in debug mode

g++ -c -pipe -O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -Wall -W -g -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -I/usr/lib/qt3/mkspecs/default -I. -I/usr/include/Magick++ -I/usr/include/magick -I/usr/include -I/usr/lib/qt3/include -o dlgtexteffect.o dlgtexteffect.cpp

this is part of the output: it seems to me that NO_DEBUG is still active and the application is still build in release mode??

Rgx

gfunk
19th July 2006, 21:52
LOL, I'm surprised you could even step through code in release mode.

wysota
19th July 2006, 23:14
this is part of the output: it seems to me that NO_DEBUG is still active and the application is still build in release mode??

If you didn't forget to run qmake after the change in the project file, then it's ok. How does the application behave now? Can you, for example set a breakpoint in the troublesome code and step through it monitoring the behaviour?

regix
20th July 2006, 07:20
# File generated by kdevelop's qmake manager.
# -------------------------------------------
# Subdir relative project main directory: ./src
# Target is an application:

LIBS += -lMagick \
-lMagick++
INCLUDEPATH += /usr/include/Magick++ \
/usr/include/magick
CONFIG += debug \
warn_on \
qt
TEMPLATE = app
FORMS += backgrounddlg.ui \
CreateDialogBase.ui \
dlgCSS.ui \
dlgTextEffectBase.ui \
dlgTextForAllBase.ui \
EditCSSDlgBase.ui \
MagickFontDlg.ui \
ThemeBase.ui \
websitedialog.ui
HEADERS += BackGroundDlgImpl.h \
createdialog.h \
css.h \
dlgcssimpl.h \
dlgtexteffect.h \
dlgtextforall.h \
editcssdlg.h \
htmlgenerator.h \
htmlpage.h \
listviewbackground.h \
magickfontdlgimpl.h \
mysettings.h \
myspeciallabel.h \
mystatuslabel.h \
saxhandler.h \
texteffect.h \
theme.h \
themeimpl.h \
thumbnailgenerator.h \
websitedialogimpl.h
SOURCES += BackGroundDlgImpl.cpp \
createdialog.cpp \
css.cpp \
dlgcssimpl.cpp \
dlgtexteffect.cpp \
dlgtextforall.cpp \
editcssdlg.cpp \
htmlgenerator.cpp \
htmlpage.cpp \
listviewbackground.cpp \
magickfontdlgimpl.cpp \
mysettings.cpp \
myspeciallabel.cpp \
mystatuslabel.cpp \
saxhandler.cpp \
texteffect.cpp \
theme.cpp \
themeimpl.cpp \
thumbnailgenerator.cpp \
websitecreator.cpp \
websitedialogimpl.cpp


This is my .pro file.
I ran qmake followed by make.
Although debug is marked in the pro file during compilation g++ uses -D NO_DEBUG
I am able to put a breakpoint in the sourcecode but unable to debug it.

Rgx

regix
20th July 2006, 07:27
After a second look:

I am actually able to debug the application. It just didnt stop at the second breakpoint. As I can see now several of my bool variables have a numerical value???
I will have a look at the constructor where I give a value to them.

Rgx

:o

incubator
20th July 2006, 08:06
I dont understand how that code evne compiles, since when is


if (condition1 and condition2) {}


valid C++ ?

I thought it should be


if (condition1 && condition2) {}

regix
20th July 2006, 09:22
yes I know, I've tried both and it looks that both compile. The strange thing about my code is: I put a QMessageBox statement in a constructor that gets executed and the code compiles but doesn't get executed. Nothing I change in the code gets executed!!!
It's driving me nuts!

Rgx:eek: :eek:

wysota
20th July 2006, 10:32
Try cleaning your build and rebuilding the application from scratch (make distclean && qmake && make).

regix
20th July 2006, 12:01
I have made a new project with kdevelop on a fresh suse 10.0 installation. I imported only the sourcefiles, headers and ui files. I added the config macros and the libs and includes in the pro file, I ran qmake and it issued warnings about possible symbol conflicts in a lot of sourcefiles. I tried to build the project: no luck. I tried to build the subproject (what is the difference between a project and subproject??) and it compiled all the sourcefiles but failed to link the application properly

On the computer where the app is still compiling I ran make distclean in the src directory
It replied no rule to make or something like that probably because I removed all the .o files as well as the moc* files as well as the Makefile. So I ran qmake and in kdev I chose for build project and it compiled and linked fine. When I chose start debug, the application started but jumped over the breakpoint I had put in a constructor that is executed.

????
Rgx :crying:

Big Duck
20th July 2006, 12:23
perhaps you could try compiling with the -g and -O0, so no optimisations.
This would help when debugging, the lines dont jump around seemingly random.

And then put a watch for the variable so the debugger stops at it, or when it changes.

regix
20th July 2006, 13:38
no effect after compiling with O0

Rgx

wysota
20th July 2006, 16:54
I have made a new project with kdevelop on a fresh suse 10.0 installation. I imported only the sourcefiles, headers and ui files. I added the config macros and the libs and includes in the pro file, I ran qmake and it issued warnings about possible symbol conflicts in a lot of sourcefiles. I tried to build the project: no luck. I tried to build the subproject (what is the difference between a project and subproject??) and it compiled all the sourcefiles but failed to link the application properly

Did you clean all the temporary files (especially ones that moc created) before moving them to the new project?

regix
20th July 2006, 17:03
I went into the src directory and did
rm *.o
rm moc*
rm Makefile

Are there any more files I should delete?

Rgx

wysota
20th July 2006, 17:04
Try running 'make clean' or even 'make distclean'.

regix
20th July 2006, 17:07
These are the flags that are set in the makefile for compiling

CFLAGS = -pipe -O0 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -Wall -W -g -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT
CXXFLAGS = -pipe -O0 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -Wall -W -g -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT

Rgx

Chicken Blood Machine
20th July 2006, 17:32
I dont understand how that code evne compiles, since when is


if (condition1 and condition2) {}


valid C++ ?

I thought it should be


if (condition1 && condition2) {}


'and', 'or' and 'xor' are all valid C++. I was suprised when I found out about it too! (it's in the back of The C++ Programming Language by Bjarne Stroustroup). They were added to the language to get around the fact that in some regions of the world, the characters '&', '|' and '^' are not available on the keyboard layout.

It's probably nice for ex-Pascal programmers too!

regix
20th July 2006, 17:32
Hi,

The solution of the problem was found by a friend of mine who suggested that kdevelop didn't search for the executable in de src directory and that I would probably find the actual executable in this src directory. And indeed there was the executable I was expecting...
Hope this helps other people with similar problems.
Does anybody know what I should change in the .pro or Makefile so that kdevelop runs the right executable?

Rgx ;) ;)

wysota
20th July 2006, 17:38
Maybe you should change KDevelop's project settings instead?

But if you insist on changing the project file, you can set a DESTDIR variable and point it to the directory where the binary is to be stored.