Skip to content

Commit

Permalink
VSCode: modified the configuration files to support debugging based o…
Browse files Browse the repository at this point in the history
…n the CyberRT framework.
  • Loading branch information
davidhopper2003 authored and ycool committed Jan 15, 2019
1 parent 547591c commit 8bd9293
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
12 changes: 5 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
// You can change the "planning" to your module name, but it should be
// same as those in gdbserver of the docker container.
"program": "${workspaceRoot}/bazel-bin/modules/planning/planning",
"program": "${workspaceRoot}/bazel-bin/cyber/mainboard",
// You can change "localhost:1111" to another "IP:port" name, but it
// should be same as those in gdbserver of the docker container.
"miDebuggerServerAddress": "localhost:1111",
// You can change the task to meet your demands in the
// ".vscode/tasks.json" file (search the label:
// "start gdbserver"), but the module name and the port
// number should be consistent with this file.
// You can set the name of the module to be debugged in the
// ".vscode/tasks.json" file, for example "planning".
// Tips: search the label "start gdbserver" in ".vscode/tasks.json".
// The port number should be consistent with this file.
"preLaunchTask": "start gdbserver",
"args": [],
"stopAtEntry": false,
Expand Down
5 changes: 2 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@
"label": "start gdbserver",
"type": "shell",
// you can change the "planning" module name to another one and
// change the "1111" to another port number.
// Note: the module name and port number should be same as those in
// the "launch.json" file.
// change the "1111" to another port number. The port number should
// be same as that in the "launch.json" file.
"command": "bash docker/scripts/dev_start_gdb_server.sh planning 1111",
"isBackground": true,
"problemMatcher": {
Expand Down
11 changes: 5 additions & 6 deletions scripts/start_gdb_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ if [ ${GDBSERVER_NUMS} -ne 0 ]; then
sudo pkill -SIGKILL -f "gdbserver"
fi

echo ${MODULE_NAME}
# Because the "grep ${MODULE_NAME}" always generates a process with the name of
# "${MODULE_NAME}", I added another grep to remove grep itself from the output.
# The following command got a wrong result and I can't find the reason.
#PROCESS_ID=$(ps -eo pid,command | grep "${MODULE_NAME}" | grep -v "grep" | awk '{print $1}')
# This one is OK.
PROCESS_ID=$(pgrep -o -x "${MODULE_NAME}")
#echo ${PROCESS_ID}
PROCESS_ID=$(ps -ef | grep "mainboard" | grep "${MODULE_NAME}" | grep -v "grep" | awk '{print $2}')
echo ${PROCESS_ID}

# If the moudle is not started, start it first.
if [ -z ${PROCESS_ID} ]; then
Expand All @@ -70,7 +68,8 @@ if [ -z ${PROCESS_ID} ]; then
# run command_name module_name
run ${MODULE_NAME} "$@"

PROCESS_ID=$(pgrep -o -x "${MODULE_NAME}")
PROCESS_ID=$(ps -ef | grep "mainboard" | grep "${MODULE_NAME}" | grep -v "grep" | awk '{print $2}')
echo ${PROCESS_ID}
fi

sudo gdbserver :${PORT_NUM} --attach ${PROCESS_ID}

0 comments on commit 8bd9293

Please sign in to comment.