gdb is powerfull but kinda hard to use. Dowload DrMingw, set it as default window$ debugger and you'll get the call stack when it crash. That could help, huh?Originally Posted by wysota
gdb is powerfull but kinda hard to use. Dowload DrMingw, set it as default window$ debugger and you'll get the call stack when it crash. That could help, huh?Originally Posted by wysota
Last edited by fullmetalcoder; 13th June 2006 at 13:31. Reason: added link to Dr Mingw
Current Qt projects : QCodeEdit, RotiDeCode
What's so hard in a sequence of:Originally Posted by fullmetalcoder
$ gdb appname
run
bt
quit
The problem with gdb is that sometimes it could be interesting to see the functions called BEFORE the crash and not only the stack. In my own problem (another post), I know where it crashes (and, as it is an assert, it was not necessary) but I don't know why it crashes.
I remember of another program, the same as gdb but with graphics, it sounded like ddd ...![]()
You can do the same with gdb. But in 90% of cases it's enough to have a backtrace to see what went wrong (a vast number of segfaults is caused by dereferencing a null pointer or corrupting the stack frame). In this case the most important is to see where in Qt library the app crashes and what was the call chain that led to the crash.
Ok,I have compiled the debug libraries to finally debug the program and now the program works!!! Hrmmm.......bah......![]()
Try again with release mode. Just make sure your project is cleaned and recompiled from scratch.Originally Posted by vratojr
Dunno what's hard but I know what's driving me mad. When I use such a command I only get a call stack, and none of the graphical interface to gdb allow me to see the debug symbols from the shared librarieslinked to my program...Originally Posted by wysota
Current Qt projects : QCodeEdit, RotiDeCode
Well, in fact the in release mode the programs doens't work, it simply stalls as before. The problem is that I don't know how to debug it since it doens't crashes but stalls. Moreover,as I said the debug version runs correctly... How could it be?
Do it the old way: uses QMessageBox::warning(), filled with crucial paramteres at points you consider as potentially problematic... I've always worked that way since I switched to Linux where, even in release mode, qDebug() works fine...
![]()
Current Qt projects : QCodeEdit, RotiDeCode
It could be that you rely on some condition which behaves differently between debug and release (for example debug might be setting all int variables to '0' and release might leave it uninitialised -- of course I don't say that it actually happens).Originally Posted by vratojr
Well I found the problem... But still I don't know why it happens... From the father of UserThread I call:
withQt Code:
if(!userThread->isRunning()){ userThread->start(); while(!userThread->inizializzato()); //Stalls here }To copy to clipboard, switch view to plain text mode
the program stalls in the "while".Now, if i run in debug mode, _inizializzato is correcly set up to TRUE and the program doesn't stall, in release mode, _inizializzato is never set to TRUE (_inzializzato is set to FALSE in the constructor) and the programs stalls.Qt Code:
void UserThread::run(){ //....... _inizializzato=TRUE; exec(); } bool UserThread::inizializzato() const {return _inizializzato;}To copy to clipboard, switch view to plain text mode
I suppose I can delete the problem if I wait for a signal coming from the thread instead of using that while but... Is this mine a bad style of programming?
Thanks for the attention and the patience!
Yes. You should use a QWaitCondition here.Originally Posted by vratojr
Thanks, but if I am not too annoying, could you explain me why I can't use the while?Is this because I continuosly pool on a member of another thread and this generates a conflict with the owner thread? I mean, theoretically I could resolve this also by placing a mutexlocker in run() and in inzializzato() ?
Excuse me but I want also to learn!![]()
It's because you are waiting in a so called "busy loop".Originally Posted by vratojr
Try to compile such program:
Run it and see the CPU usage. You'll notice that it'll go up to 100%.Qt Code:
int main(){ while(1); return 0; }To copy to clipboard, switch view to plain text mode
Now compile and run this one:
This one won't eat up all your CPU power (and it'll be easier to kill such a task) -- this is called "semi-busy loop". The only difference between those two applications is that the second one forces a context switch of the processor (changes the "active" process) allowing other applications to run. As a result all your applications will run more efficiently.Qt Code:
int main(){ while(1) sleep(0); return 0; }To copy to clipboard, switch view to plain text mode
The "next step" is to use some kind of lock which will suspend your process (thread) and wake it up only where a certain condition is met. A pseudocode follows:
Qt Code:
//... // instead of while(!someEventHappened); -- busy loop // or instead of while(!someEventHappend) sleep(0); -- semi busy loop goToSleepUntil(someEventHappend); doSomething(); //...To copy to clipboard, switch view to plain text modeI think so (depends where exactly you want to put it), but using a wait condition is more "elegant".I mean, theoretically I could resolve this also by placing a mutexlocker in run() and in inzializzato()?
Good for youExcuse me but I want also to learn!![]()
![]()
sunil.thaha (12th October 2006), vratojr (16th June 2006)
Bookmarks