Hi
I think the title says it all ... thanks in advance
Said
What is the right way to debug a threaded proc
Re: What is the right way to debug a threaded proc
It does depend what your thread is supposed to be doing and what sort of problem you are running into.
1) If it's feasible to do so, extract the thread logic into a separate synchronous/sequential test file and use that to debug and eliminate any non-threading related logic errors so that these aren't making matters worse in the threaded version.
2) Make sure that you're using mutexes for all shared resources, especially if your thread could be multi-threaded.
3) Get one of the assert macros running around the forum and use it to make sure that critical states are valid at points which might derail your thread. Remember that in multi-thread situations just because a particular state was true at the start of the thread doesn't mean that this state will still be around further down the line...
4) Get Rescator's debug api macro from http://www.purebasic.fr/english/viewtop ... 12&t=14231
and DebugView from https://docs.microsoft.com/en-gb/sysint ... /debugview if you don't already have something similar; so you can get feedback from the real live thread if the problem doesn't exhibit within the IDE/debugger.
1) If it's feasible to do so, extract the thread logic into a separate synchronous/sequential test file and use that to debug and eliminate any non-threading related logic errors so that these aren't making matters worse in the threaded version.
2) Make sure that you're using mutexes for all shared resources, especially if your thread could be multi-threaded.
3) Get one of the assert macros running around the forum and use it to make sure that critical states are valid at points which might derail your thread. Remember that in multi-thread situations just because a particular state was true at the start of the thread doesn't mean that this state will still be around further down the line...
4) Get Rescator's debug api macro from http://www.purebasic.fr/english/viewtop ... 12&t=14231
and DebugView from https://docs.microsoft.com/en-gb/sysint ... /debugview if you don't already have something similar; so you can get feedback from the real live thread if the problem doesn't exhibit within the IDE/debugger.
Re: What is the right way to debug a threaded proc
@spikey many thanks for your valuable tips and the links, really appreciated. I will try to use them
My question is too general and it is not easy to guess what i have in mind To be more specific, how would you properly debug a thread inside the IDE using Breakpoints (F9,F7,F8) ... sometimes i just loose track of a running thread, the ide seems to mostly focus on the main thread or probably i am doing something wrong
thanks again
Said
My question is too general and it is not easy to guess what i have in mind To be more specific, how would you properly debug a thread inside the IDE using Breakpoints (F9,F7,F8) ... sometimes i just loose track of a running thread, the ide seems to mostly focus on the main thread or probably i am doing something wrong
thanks again
Said
Re: What is the right way to debug a threaded proc
I also attempt debugging threaded apps within the IDE.
If you set a breakpoint in Main, before stepping into your threaded procedure, you can step into the thread and view as normal.
If you only put a breakpoint in the threaded procedure, there is no guarantee the debugger will stop.
It would be great if there was a help doc for debugging threaded apps.
If you set a breakpoint in Main, before stepping into your threaded procedure, you can step into the thread and view as normal.
If you only put a breakpoint in the threaded procedure, there is no guarantee the debugger will stop.
It would be great if there was a help doc for debugging threaded apps.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: What is the right way to debug a threaded proc
My main method, as spikey suggests, is to separate the threaded portion into a non-threaded procedure - that way, using breakpoints and program stepping, you can see what the thread is doing - also, display your variables with the debugger window
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
Re: What is the right way to debug a threaded proc
@skywalk , @citystate, thanks for your feedback, so that's the best we can have there must be a more reliable and systematic way
Not sure, this always works fine, what i have noticed is, as soon as an event is present in the main thread loop then you loose track of the other threadskywalk wrote: If you set a breakpoint in Main, before stepping into your threaded procedure, you can step into the thread and view as normal.
If you only put a breakpoint in the threaded procedure, there is no guarantee the debugger will stop.
the best would be if the ide can track 2 threads at a time, if this cant be done, then yes a little help would be really helpful maybe we should post a doc feature request aboutskywalk wrote: It would be great if there was a help doc for debugging threaded apps.