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

[compiler] Debugger on windows #939

Closed
water111 opened this issue Oct 24, 2021 · 2 comments
Closed

[compiler] Debugger on windows #939

water111 opened this issue Oct 24, 2021 · 2 comments

Comments

@water111
Copy link
Collaborator

Useful reference https://docs.microsoft.com/en-us/windows/win32/debug/debugging-functions

Thread ID

The "thread ID" type tells the compiler which process and thread are the GOAL runtime. It is converted to a string in the runtime, sent over the normal TCP DECI2 connection, and received by the compiler.

On windows, I imagine it will be a process ID + thread ID. I think you need to get a process handle, then convert that to a process ID, and the same thing for a thread.

This will need the to/from string functions, and the get_current_thread_id function implemented.

Debugging Permissions

On Linux, it was not possible to debug the GOAL process unless the runtime enabled certain permissions. The allow_debugging function is called when the GOAL process starts and is a good place to put any code required to make debugging possible.

Attach/Break

The attach_and_break function might be DebugActiveProcess to attach and DebugBreakProcess to break. Running (:dbg) in the REPL will cause this to happen

Check Stopped

This function is called by the debug watcher thread periodically to check if the process has crashed or hit a breakpoint. If the process is still running, this function should return quickly. This is probably WaitForDebugEvent with a 0 timeout.

Memory

There are functions to read and write GOAL memory. These can probably use ReadProcessMemory. They are used to read the symbol table, and insert break instructions.

Registers

For now, we only need GPRs + RIP. This is only called once the process is stopped. This should probably use the GetThreadContext function.

Tests

There are unit tests for the debugger in test_debugger that should work on windows once this is implemented.

Missing features

The debugger is still pretty basic. It can display registers, a stacktrace, and disassembly with source lines. It does support breakpoints and reading/saving memory, but so far those haven't been useful. One issue is that the backtraces tend to be huge because it displays the disassembly for each function. You can comment out the disassemble_at_rip inside of Debugger::get_backtrace to get rid of this, if needed.

@ManDude
Copy link
Member

ManDude commented Nov 4, 2021

fixed in #942 . missing features could be their own issue

@ManDude
Copy link
Member

ManDude commented Jun 17, 2022

windows debugger has been available (and functional... enough) for quite some time now

@ManDude ManDude closed this as completed Jun 17, 2022
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