Debugging.

Propose new features and changes
User avatar
maestrith
Posts: 825
Joined: 16 Oct 2013, 13:52

Debugging.

15 Apr 2014, 22:04

I have a bit of a concern.
This is the debugging output for OutputDebug,flan

Code: Select all

<stream type="stderr">ZmxhbgA=</stream>
and this is an actual error

Code: Select all

<stream type="stderr">RXJyb3IgaW4gI2luY2x1ZGUgZmlsZSAiRDpcQUhLIFN0dWRpbyBHaXRcUHJvamVjdHNcVW50aXRsZWRcVW50aXRsZWQzXGZsYW4uYWhrIjoKICAgICBBIGNvbnRyb2wncyB2YXJpYWJsZSBtdXN0IGJlIGdsb2JhbCBvciBzdGF0aWMuCgpTcGVjaWZpY2FsbHk6IHZmbGFuCgoJTGluZSMKCTAwNDogZmxhbigpICAKCTAwMTogewotLS0+CTAwMjogR3VpLEFkZCxCdXR0b24sdmZsYW4KCTAwNDogfQoJMDA3OiBFeGl0CgkwMDg6IEV4aXQKCTAwODogRXhpdAoKVGhlIGN1cnJlbnQgdGhyZWFkIHdpbGwgZXhpdC4A</stream>
Would there be a way to add just a simple line attribute

Code: Select all

<stream type="stderr" line="2">
so that we can tell easily that it is an actual error rather than just a standard message.

Thanks in advance :)
edit:
I did some digging in the source:

Code: Select all

int Debugger::WriteStreamPacket(LPCTSTR aText, LPCSTR aType)
{
	ASSERT(!mResponseBuf.mFailed);
	mResponseBuf.WriteF("<stream type=\"%s\">", aType);
	CStringUTF8FromTChar packet(aText);
	mResponseBuf.WriteEncodeBase64(packet, packet.GetLength() + 1); // Includes the null-terminator.
	mResponseBuf.Write("</stream>");
	return SendResponse();
}
I am not too sure how many other functions use this, but I did notice that void Debugger::OutputDebug(LPCTSTR aText) and bool
Debugger::FileAppendStdOut(LPCTSTR aText) use it. Even adding a message="1" or something like that to the stream as an attribute
would be helpful but adding a line="(lineno)" would make my life a whole lot easier.
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
User avatar
LinearSpoon
Posts: 156
Joined: 29 Sep 2013, 22:55

Re: Debugging.

16 Apr 2014, 12:55

AHK implements DBGp for debugging, which specifies messages are passed with base64 encoding.
source: http://xdebug.org/docs-dbgp.php#debugge ... unications
For example, your error decoded:

Code: Select all

Error in #include file "D:\AHK Studio Git\Projects\Untitled\Untitled3\flan.ahk":
     A control's variable must be global or static.

Specifically: vflan

	Line#
	004: flan()  
	001: {
--->	002: Gui,Add,Button,vflan
	004: }
	007: Exit
	008: Exit
	008: Exit

The current thread will exit.
I feel like your IDE should handle the conversion for you... what program are you using for debugging?
Last edited by LinearSpoon on 19 Apr 2014, 01:21, edited 1 time in total.
User avatar
maestrith
Posts: 825
Joined: 16 Oct 2013, 13:52

Re: Debugging.

16 Apr 2014, 12:59

LinearSpoon wrote:AHK uses implements DBGp for debugging, which specifies messages are passed with base64 encoding.
source: http://xdebug.org/docs-dbgp.php#debugge ... unications
For example, your error decoded:

Code: Select all

Error in #include file "D:\AHK Studio Git\Projects\Untitled\Untitled3\flan.ahk":
     A control's variable must be global or static.

Specifically: vflan

	Line#
	004: flan()  
	001: {
--->	002: Gui,Add,Button,vflan
	004: }
	007: Exit
	008: Exit
	008: Exit

The current thread will exit.
I feel like your IDE should handle the conversion for you... what program are you using for debugging?
I am using my own AHK Studio. I understand that it is base64 and I am decoding it. the problem is that an error message comes across the same as a OutputDebug message and if a user sends a debug message that looks closely like an error message my program will exit and display the message. I was wondering if there would be a way that just a OutputDebug message could have a message attribute, or if an error could have a line attribute so that it would be a bit easier and more reliable to detect an actual error.
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Debugging.

18 Apr 2014, 20:00

It is feasible, but I won't do it. I prefer not to deviate from the DBGp (debugger protocol) standard. You can use some simple pattern matching to detect errors, and if a user's debug output matches an AutoHotkey error (especially showing line number information!), you can/should treat it the same.

Personally, I'm not so sure it was a good idea to output error messages that way in the first place (I think it was fincs' idea). If AutoHotkey showed the MsgBox as per usual, would that solve your problem? Why does your program exit? Do you mean the "program" you are debugging or your AHK Studio?

Some years ago I had planned to implement "exception breakpoints" (part of the DBGp specification), which would cause the debugger to enter a break state when an error occurs, allowing the user to inspect the state of the script at the point that it failed. It would also allow the IDE to reliably detect critical errors.
User avatar
maestrith
Posts: 825
Joined: 16 Oct 2013, 13:52

Re: Debugging.

18 Apr 2014, 20:07

Ok :) thank you very much. Is there a way to get the information on how all of the different error messages are displayed? There are some that do not provide the filename and some that have the line number after a ---> and some that have the line number in something like "error at line x"
John H Wilson III 05/29/51 - 03/01/2020. You will be missed.AHK Studio OSDGUI Creator
Donations
Discord
All code is done on a 64 bit Windows 10 PC Running AutoHotkey x32
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: Debugging.

19 Apr 2014, 04:54

lexikos wrote:Some years ago I had planned to implement "exception breakpoints" (part of the DBGp specification), which would cause the debugger to enter a break state when an error occurs, allowing the user to inspect the state of the script at the point that it failed. It would also allow the IDE to reliably detect critical errors.
That sounds great, would love that feature :D
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Debugging.

19 Apr 2014, 21:20

I think Line::FormatError in script.cpp covers all of the error messages output to the debugger. "Error at line x" means there was an error (generally a syntax error) before the line was preparsed. ---> is used at any later point when context (the current and surrounding lines) is available. File name is only shown if the error occurred in an include file.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 26 guests