[all-commits] [llvm/llvm-project] 0f0462: [vscode] Improve runInTerminal and support linux
walter erquinigo via All-commits
all-commits at lists.llvm.org
Mon Jan 25 12:34:46 PST 2021
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 0f0462cacf34aa88ae71a13c4199c1b1e70f3ee6
https://github.com/llvm/llvm-project/commit/0f0462cacf34aa88ae71a13c4199c1b1e70f3ee6
Author: Walter Erquinigo <a20012251 at gmail.com>
Date: 2021-01-25 (Mon, 25 Jan 2021)
Changed paths:
M lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
M lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
M lldb/test/API/tools/lldb-vscode/runInTerminal/TestVSCode_runInTerminal.py
M lldb/tools/lldb-vscode/CMakeLists.txt
A lldb/tools/lldb-vscode/FifoFiles.cpp
A lldb/tools/lldb-vscode/FifoFiles.h
M lldb/tools/lldb-vscode/JSONUtils.cpp
M lldb/tools/lldb-vscode/JSONUtils.h
M lldb/tools/lldb-vscode/Options.td
A lldb/tools/lldb-vscode/RunInTerminal.cpp
A lldb/tools/lldb-vscode/RunInTerminal.h
M lldb/tools/lldb-vscode/VSCode.h
M lldb/tools/lldb-vscode/lldb-vscode.cpp
Log Message:
-----------
[vscode] Improve runInTerminal and support linux
Depends on D93874.
runInTerminal was using --wait-for, but it was some problems because it uses process polling looking for a single instance of the debuggee:
- it gets to know of the target late, which renders breakpoints in the main function almost impossible
- polling might fail if there are already other processes with the same name
- polling might also fail on some linux machine, as it's implemented with the ps command, and the ps command's args and output are not standard everywhere
As a better way to implement this so that it works well on Darwin and Linux, I'm using now the following process:
- lldb-vscode notices the runInTerminal, so it spawns lldb-vscode with a special flag --launch-target <target>. This flags tells lldb-vscode to wait to be attached and then it execs the target program. I'm using lldb-vscode itself to do this, because it makes finding the launcher program easier. Also no CMAKE INSTALL scripts are needed.
- Besides this, the debugger creates a temporary FIFO file where the launcher program will write its pid to. That way the debugger will be sure of which program to attach.
- Once attach happend, the debugger creates a second temporary file to notify the launcher program that it has been attached, so that it can then exec. I'm using this instead of using a signal or a similar mechanism because I don't want the launcher program to wait indefinitely to be attached in case the debugger crashed. That would pollute the process list with a lot of hanging processes. Instead, I'm setting a 20 seconds timeout (that's an overkill) and the launcher program seeks in intervals the second tepmorary file.
Some notes:
- I preferred not to use sockets because it requires a lot of code and I only need a pid. It would also require a lot of code when windows support is implemented.
- I didn't add Windows support, as I don't have a windows machine, but adding support for it should be easy, as the FIFO file can be implemented with a named pipe, which is standard on Windows and works pretty much the same way.
The existing test which didn't pass on Linux, now passes.
Differential Revision: https://reviews.llvm.org/D93951
More information about the All-commits
mailing list