Skip to content

Support multi-threading #129

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

Merged
merged 4 commits into from
Feb 21, 2018

Conversation

LeszekSwirski
Copy link
Contributor

Fixes #36. Not everything works perfectly, in particular non-varobj local don't have a well-defined thread, but it's a good base to build on. I'm not 100% sure about the logic behind VAR_HANDLES_START, so the current array size increase may be overkills

Also includes some odds-and-ends fixing parsing and reference printing.

return [];
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh any reason for this change? Could you include some test what this is supposed to fix or what didn't work in the tests file please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember the exact command that caused it, but it was to do with an mi command returning {} followed by other data, where the other data was getting lost

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added an (artificial) test, which I can confirm did fail before this patch.

@WebFreak001
Copy link
Owner

ok while quickly going over the changes I didn't notice any major issues so I will do more extensive testing later with all supported debuggers (not sure if mago supports multithreading, but it's just a side product anyway to allow D people on windows to debug if they really want to).

I don't really know anything about async in js so I need to lookup if any thread safety issues can occur there or if it's just fancy promises.

Otherwise I don't know how I feel about all the missing semicolons and using ' for strings longer than 1 character yet lol

But this seems like a good and useful PR, thanks

@LeszekSwirski
Copy link
Contributor Author

LeszekSwirski commented Feb 2, 2018

async in JS is effectively equivalent to promise then chains, there's still no actual parallelism or threading. I can fix the semicolons and 's (EDIT: Done.)

I've only tested with gdb so YMMV, single-threaded functionality shouldn't change with other compilers though I think.

@LeszekSwirski
Copy link
Contributor Author

Gentle reminder.

@WebFreak001
Copy link
Owner

sorry was kind of busy with other stuff and didn't really feel like reviewing something large, I can do it now

@WebFreak001
Copy link
Owner

GDB

  • single threaded still works locally
  • multi threaded now works locally
  • single threaded still works over SSH
  • multi threaded now works over SSH
  • single threaded still works over gdbserver
  • multi threaded now works over gdbserver
  • single threaded still works when attaching
  • multi threaded now works when attaching
    Exception:
TypeError: Cannot read property 'getThreads' of undefined
    at GDBDebugSession.threadsRequest (/tmp/code-debug/out/src/mibase.js:239:24)
    at GDBDebugSession.dispatchRequest (/tmp/code-debug/node_modules/vscode-debugadapter/lib/debugSession.js:398:22)
    at GDBDebugSession._handleData (/tmp/code-debug/node_modules/vscode-debugadapter/lib/protocol.js:97:38)
    at Socket.inStream.on (/tmp/code-debug/node_modules/vscode-debugadapter/lib/protocol.js:18:44)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20): Error: TypeError: Cannot read property 'getThreads' of undefined
    at GDBDebugSession.threadsRequest (/tmp/code-debug/out/src/mibase.js:239:24)
    at GDBDebugSession.dispatchRequest (/tmp/code-debug/node_modules/vscode-debugadapter/lib/debugSession.js:398:22)
    at GDBDebugSession._handleData (/tmp/code-debug/node_modules/vscode-debugadapter/lib/protocol.js:97:38)
    at Socket.inStream.on (/tmp/code-debug/node_modules/vscode-debugadapter/lib/protocol.js:18:44)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at readableAddChunk (_stream_readable.js:178:18)
    at Socket.Readable.push (_stream_readable.js:136:10)
    at Pipe.onread (net.js:560:20)
    at file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:2644:530
    at Object.v [as _notify] (file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:140:302)
    at Object.enter (file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:143:568)
    at n.Class.derive._oncancel._run (file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:144:866)
    at n.Class.derive._oncancel._error (file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:144:383)
    at file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:2223:975
    at _.e.dispatch (file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:2225:291)
    at _.e.handleData (file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:2224:815)
    at Socket.<anonymous> (file:///opt/visual-studio-code/resources/app/out/vs/workbench/workbench.main.js:2223:835)
    at emitOne (events.js:96:13)

LLDB

  • single threaded still works locally
  • multi threaded now works locally.
    minor issue: thread names say undefined https://wfr.moe/fCbQ1G.png
  • single threaded still works over SSH (breakpoints don't work)
  • multi threaded now works over SSH (breakpoints don't work)
  • single threaded still works when attaching
  • multi threaded now works when attaching
    https://wfr.moe/fCAUR0.png

Mago-MI
- [ ] single threaded still works locally (can't test because I can't run a VM because I disabled AMD-V in my bios because it locks my CPU after some random amount of time)
I don't think testing anything else here makes sense, because it is very limited

But I supposed most of these issues were present already, I am going to check for completeness though. The only thing I see when testing here right now is therefore that undefined in the thread name of lldb.

@WebFreak001
Copy link
Owner

ok so the Thread exception when it fails to connect is new, but gdbserver still doesn't work.

I did find one issue though: breakpoints show as verified in the broken lldb ssh connection now, they were unverified like this https://wfr.moe/fCA70H.png before

@WebFreak001
Copy link
Owner

WebFreak001 commented Feb 19, 2018

I can merge this as it is now because it is a good start, but I would prefer it if there were some // TODO comments where I just commented what behaviour changed (notably the exceptions always being verified, I saw there were some changes in exception mapping) and the undefined label for threads in lldb

@LeszekSwirski
Copy link
Contributor Author

Thanks for the review, I've added some defensive ifs and TODOs. Regarding the breakpoints being verified, I think there's some semantic difference between breakpoints being verified, and being enabled. Since I get the "done" response back from lldb, I assume they're verified as far as lldb is concerned (modulo lldb mi bugs), but they might not actually be enabled because of various reasons. Regardless, there's a new callback-based breakpoint API coming, so that might do a better job of maintaining breakpoint state.

src/mibase.ts Outdated
@@ -256,13 +258,24 @@ export class MI2DebugSession extends DebugSession {
}

protected threadsRequest(response: DebugProtocol.ThreadsResponse): void {
if (!this.miDebugger) {
this.sendResponse(response);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm this should also return so the next call doesn't crash

Not sure why it only happens for this function but this fixes the error in the console.
@WebFreak001 WebFreak001 merged commit bcbbda1 into WebFreak001:master Feb 21, 2018
@LeszekSwirski LeszekSwirski deleted the multi-threading branch February 21, 2018 17:29
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

Successfully merging this pull request may close these issues.

support multithread debugging
2 participants