Page 1 of 1

Keep debug window open after program ends

Posted: Tue Apr 30, 2024 10:59 pm
by jassing
Is there a way to keep the debug window open after a program ends? or at east, not loose what's in there (so you can use debugger->debugger output to view it?

Re: Keep debug window open after program ends

Posted: Wed May 01, 2024 2:26 am
by Allen
Hi Jassing,

May be you could try to use the standalone debugger.

Thanks

Allen

Re: Keep debug window open after program ends

Posted: Wed May 01, 2024 9:28 am
by spikey
There are two options in the IDE preferences under Menu → Preferences → Debugger. The second will preserve the current content of the debugger windows until you manually end the program:
"Stop execution at program start"
"Stop execution before program end"

Or you can put "CallDebugger" at the end of the code.

Or there is SaveDebugOutput which will write the content of the window to a file.

Re: Keep debug window open after program ends

Posted: Wed May 01, 2024 11:07 am
by mk-soft
Preferences -> Debugger -> Enable: Keep all debugger windows on top

Re: Keep debug window open after program ends

Posted: Wed May 01, 2024 1:06 pm
by Michael Vogel
Maybe the following macro could be useful, but then you need to modify all debug lines

Code: Select all

Macro Log(log)
	If OpenFile(666,#PB_Compiler_FilePath+"Debug.log",#PB_File_Append)
		Debug RSet(Str(#PB_Compiler_Line),4)+" | "+log
		WriteStringN(666,FormatDate("%DD.%MM.%YYYY %HH:%II:%SS #",Date())+RSet(Str(#PB_Compiler_Line),5,"0")+":"+LSet(#PB_Compiler_Procedure,10)+"| "+log)
		CloseFile(666)
	EndIf
EndMacro

Procedure Test(a,e)
	For i=a To e
		Log(Str(i))
	Next i
EndProcedure

Log("Start")
test(1,5)
Log("Stop")

Re: Keep debug window open after program ends

Posted: Wed May 01, 2024 3:12 pm
by mk-soft
In my case, the debug window remains open after exiting with my setting.

Re: Keep debug window open after program ends

Posted: Wed May 01, 2024 4:15 pm
by Axolotl
Michael Vogel wrote: Wed May 01, 2024 1:06 pm Maybe the following macro could be useful, but then you need to modify all debug lines

Code: Select all

Macro Log(log)
...

Please bear in mind that Log() is a Math-Lib command and overlaying existing commands can lead to problems later on. (smartass alert) :oops:
BTW: Sometimes I use OutputDebugString_() while "debugging" release versions.

Re: Keep debug window open after program ends

Posted: Thu May 02, 2024 11:30 pm
by jassing
mk-soft wrote: Wed May 01, 2024 3:12 pm In my case, the debug window remains open after exiting with my setting.

If the program crashes, or you stop it - the debug window closes.

Here's an example.
When it crashes, you cannot review the debug output, and it closes.

Code: Select all

For x = 1 To 300
  Debug Random(20000,1)/Random(10,1)
Next
RaiseError(#ERROR_INVALID_ADDRESS)

Re: Keep debug window open after program ends

Posted: Fri May 03, 2024 1:17 am
by BarryG
The Debug Output window stays open here with your example, Jassing. It only closes if I click the "Kill Program" button (red X).

Re: Keep debug window open after program ends

Posted: Sat May 11, 2024 1:17 am
by jassing
BarryG wrote: Fri May 03, 2024 1:17 am The Debug Output window stays open here with your example, Jassing. It only closes if I click the "Kill Program" button (red X).

OK -- Still, would be useful to still have this output available.

Re: Keep debug window open after program ends

Posted: Sat May 11, 2024 1:53 am
by BarryG
jassing wrote: Sat May 11, 2024 1:17 amwould be useful to still have this output available
You can send the debug output to the IDE so that it's always available and not lose it. You can copy the output from there, too.

Image

Re: Keep debug window open after program ends

Posted: Sat May 11, 2024 2:29 am
by jassing
BarryG wrote: Sat May 11, 2024 1:53 am You can send the debug output to the IDE so that it's always available and not lose it. You can copy the output from there, too.
sure, but that's not the same as just leaving the debug window open...