DisableDebugger not actually disabling the debugger?

Just starting out? Need help? Post your questions and find answers here.
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

DisableDebugger not actually disabling the debugger?

Post by nsstudios »

Maybe I'm just misunderstanding the purpose, but DisableDebugger still lets the ide/dedicated debugger catch errors like invalid memory access unless I specifically turn the debugger off in the ide, or use the compile without debugger option.
Tried with v6 lts asm and c, 64 and 32 bit, and also 5.73 just in case, all of them do it, which makes me think I'm just misunderstanding how this command works.

Code: Select all

PurifierGranularity(0, 0, 0, 0); just in case DisableDebugger doesn't disable Purifier
DisableDebugger; seems to do nothing?
CompilerIf #PB_Compiler_Debugger
MessageRequester("Warning", "Debugger is still on.", #PB_MessageRequester_Warning); reports on unless I manually disable the debugger or compile without debugger
CompilerEndIf
Procedure err()
MessageRequester("error", ErrorMessage(), #PB_MessageRequester_Error)
End
EndProcedure
OnErrorCall(@err()); will never be called because debugger will still catch it first
PokeS(0, "test"); will trigger the debugger warning/error
Thank you for reading.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 579
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: DisableDebugger not actually disabling the debugger?

Post by spikey »

I see where your thinking comes from, but it's not a bug. It might be more accurate if the instruction were called 'DisableDebuggerUpdates' but this is more cumbersome and also not entirely accurate either.
Compare with the behaviour of this variant. The 'Debugger is still on' messages won't be displayed in this example and this program won't break at the CallDebugger breakpoint either.

Code: Select all

PurifierGranularity(0, 0, 0, 0); just in case DisableDebugger doesn't disable Purifier
Debug "Hello!"
DisableDebugger
Debug "Debugger is still on 1."
CallDebugger
CompilerIf #PB_Compiler_Debugger
  Debug "Debugger is still on 2."
CompilerEndIf
Procedure err()
MessageRequester("error", ErrorMessage(), #PB_MessageRequester_Error)
End
EndProcedure
OnErrorCall(@err()); will never be called because debugger will still catch it first
PokeS(0, "test"); will trigger the debugger warning/error
The debugging tools take time to update. So for example it takes time for the Variable Viewer to be updated, the Data Breakpoint tool to check if a break is needed, to update the Watchlist or the Debug output window. DisableDebugger stops these updates occurring so the code in these sections should run faster. This isn't always true though, but it will be true if you're using several Data Breakpoints for example. It also stops code stepping which is tedious in big loops.

The program is still running under the control of the IDE though so it will trap any fatal runtime errors so the error can be displayed, and the error you're simulating is a fatal one. Your error handler will be called properly when a fully standalone executable is published.
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: DisableDebugger not actually disabling the debugger?

Post by nsstudios »

Thank you, Spikey!
That makes sense, sorry if that is common knowledge I have somehow missed out on.
It may be good to clerify the behavior in the documentation perhaps.
So since the debugger still catches errors, does that mean there's still some overhead with DisableDebugger? Would you recommend to run the code without debugger as opposed to DisableDebugger when running speed benchmarks (alongside setting realtime+time critical priority)?
User avatar
spikey
Enthusiast
Enthusiast
Posts: 579
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: DisableDebugger not actually disabling the debugger?

Post by spikey »

I should also have mentioned that there's a menu item "Use debugger" at the top of the Debugger menu, if you uncheck that you'll get the behaviour you were expecting in the IDE too...

Yes, you should turn it off when you are benchmarking otherwise you won't be getting truly accurate results.
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: DisableDebugger not actually disabling the debugger?

Post by nsstudios »

Thank you! I really appreciate your help/clarification.
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: DisableDebugger not actually disabling the debugger?

Post by Little John »

spikey wrote: Wed Nov 30, 2022 6:29 pm I should also have mentioned that there's a menu item "Use debugger" at the top of the Debugger menu, if you uncheck that you'll get the behaviour you were expecting in the IDE too...

Yes, you should turn it off when you are benchmarking otherwise you won't be getting truly accurate results.
And when you put these lines

Code: Select all

CompilerIf #PB_Compiler_Debugger
   CompilerError "Switch the debugger *off* in the IDE"
CompilerEndIf
at the beginning of your benchmark code, then you can't forget switching the debugger off. :D
nsstudios
Enthusiast
Enthusiast
Posts: 274
Joined: Wed Aug 28, 2019 1:01 pm
Location: Serbia
Contact:

Re: DisableDebugger not actually disabling the debugger?

Post by nsstudios »

Thank you Little John.
I used to see speed benchmarks that make use of DisableDebugger, so I thought that was enough in the past, but I will make sure to disable it from the ide/use the compile without debugger option from now on.
Post Reply