Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Items of an object with custom enumerator are not listed by the debugger #325

Open
Lexikos opened this issue Apr 26, 2024 · 4 comments
Open

Comments

@Lexikos
Copy link

Lexikos commented Apr 26, 2024

If an object has an __Enum property which refers to a built-in (native) method, the debugger engine calls the enumerator automatically and includes the items directly as child properties of the object. Built-in enumerators all support the following pattern described in the documentation, and are assumed safe to execute automatically:

If NumberOfVars is 2, the enumerator is expected to assign the key or index of an item to the first parameter and the value to the second parameter. Each key or index should be accepted as a parameter of the __Item property. This enables DBGp-based debuggers to get or set a specific item after listing them by invoking the enumerator.

If the method is instead user-defined, the debugger engine outputs the <enum> property to allow the client or user to choose whether to execute the enumerator. Without any special handling, SciTE4AutoHotkey and DebugVars.ahk are able to use this to display the items of an object with custom enumerator.

However, as noted in #133, vscode-autohotkey-debug filters out the <enum> property.

getting its value through the debugger will cause errors in subsequent communication with the debugger.

Other clients handle it without problem. dbgp_console.ahk can be used to verify that the response is valid and susequent commands work.

The engine currently does not suppress exceptions thrown by the enumerator (it should), but this does not appear to cause any issues with debugger communication. Once the error dialog is dismissed, the debugger engine ends enumeration and completes the response as if there were no further items.

@Lexikos
Copy link
Author

Lexikos commented Apr 26, 2024

The engine currently does not suppress exceptions thrown by the enumerator (it should), but this does not appear to cause any issues with debugger communication.

I spoke too soon..

If redirection has been enabled with stdout or stderr and the enumerator causes output (OutputDebug, FileAppend or throwing an exception), the engine outputs an incomplete property response followed by a stream packet. This bug might have been the cause of the communication error.

@zero-plusplus
Copy link
Owner

Thank you.

Is there a temporary workaround for this issue?

@Lexikos
Copy link
Author

Lexikos commented Apr 26, 2024

AutoHotkey/AutoHotkey@41710ffd fixes the stdout/stderr issue. I tested OutputDebug during property evaluation with your extension, and it is working.

A workaround for v2.0.13 and v2.1-alpha.9 would be to disable stderr/stdout redirection before evaluating properties. (Ideally you would do this at most once each time the debugger enters a break state, and re-enable it prior to issuing a continuation command.)

@zero-plusplus
Copy link
Owner

Thanks, I'll add that workaround in vscode-autohotkey-debug v2.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants