Integrate with VS Code debugging (#1444)

This commit is contained in:
Maik Riechert 2020-07-29 16:54:46 +01:00 коммит произвёл GitHub
Родитель dbff495a03
Коммит bb3ed4f361
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 53 добавлений и 1 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -3,7 +3,8 @@ _build/
Debug*/
Release*/
CMakeFiles/
.vscode/
.vscode/*
!.vscode/launch.json
.vs/
libuv/
raft_tests.md

41
.vscode/launch.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1,41 @@
{
"version": "0.2.0",
"inputs": [{
"id": "node",
"default": "0",
"description": "Choose the node to debug (must be enabled with -d <n>)",
"options": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],
"type": "pickString"
}],
"configurations": [
{
"name": "Debug node",
"type": "cppdbg",
"request": "launch",
"program": "/bin/bash",
"args": ["${workspaceFolder}/build/vscode-gdb.sh", "${input:node}"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Follow fork",
"text": "set follow-fork-mode child",
"ignoreFailures": false
},
{
"description": "Ignore SIGILL",
"text": "handle SIGILL nostop",
"ignoreFailures": false
},
{
"description": "Enable pretty-printing",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

Просмотреть файл

@ -122,6 +122,10 @@ class Network:
self.dbg_nodes = dbg_nodes
self.perf_nodes = perf_nodes
try:
os.remove(os.path.join(self.binary_dir, "vscode-gdb.sh"))
except FileNotFoundError:
pass
for host in hosts:
self.create_node(host)

Просмотреть файл

@ -167,6 +167,12 @@ class Node:
self.remote.setup()
self.network_state = NodeNetworkState.started
if self.debug:
with open(os.path.join(self.binary_dir, "vscode-gdb.sh"), "a") as f:
f.write(f"if [ $1 -eq {self.remote.local_node_id} ]; then\n")
f.write(f"cd {self.remote.remote.root}\n")
f.write(f"{' '.join(self.remote.remote.cmd)}\n")
f.write("fi\n")
print("")
phost = "localhost" if self.host.startswith("127.") else self.host
print(