-
Notifications
You must be signed in to change notification settings - Fork 2
Description
There are 4 different scenarios requiring different mechanisms for interrupting the target.
On POSIX systems:
- Local child processes must be sent
SIGINTdirectly to the child - For remote targets
SIGINTmust be sent to GDB
On Windows systems:
- Local targets must have a debug exception generated by calling
DebugBreakProcesswith a handle to the child process. - For remote targets
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0)can be used to sendSIGINTto GDB, but this requires the sender to share a console window with GDB, and ignore the signal.
POSIX signals are easily sent with Node's process.kill(pid, signal). The problem remains of how to tell if the target is remote. These are options:
- Have a check box in the config dialog
- Check for magic pid 42000 reported by GDB
- Try send
SIGINTto GDB, and then to reported PID if it hasn't halted after a timeout.
How to even make Windows API calls from JS remains a mystery.
Windows API calls that may be useful to achieve this nonsense:
/* Get the Windows handle from the PID reported by GDB */
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
/* Attach to another process' console window */
AttachConsole(pid);
/* Make the console Window invisible, so users don't see the ugly DOS box */
SetWindowPos(GetConsoleWindow(), HWND_BOTTOM, 0, 0, 0, 0, SWP_HIDEWINDOW);GDB async-mi mode may also be used to make MI run command asynchronous. Sending -gdb-set async-mi on puts GDB into async mode. After this the -exec-* commands that resume execution run in the background, and further commands may be sent while the inferior is running. The -exec-interrupt command may be sent to GDB to interrupt the target.
CLI commands that resume the target will still block until the inferior stops. They may be explicitly run in the background by adding an ampersand to the command line.