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

Vscode debug #297

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc-9 - Debug speed tester",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/examples/speed_tester/build/app/speed_tester",
"args": ["-l", "0", "-n", "3", "--proc-type=secondary", "--", "-r", "1", "--", "-d", "1", "-c", "16000"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "${workspaceFolder}/examples/gdb.sh"
}
]
}
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"tasks": [
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We either need to fix this so it works and can compile the code or delete it

Copy link
Contributor Author

@elliotthenne elliotthenne Jul 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean. Are you referring to the entire file or those 3 lines?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean this tasks section. You can just delete it

"type": "cppbuild",
"label": "C/C++: gcc-9 build active file",
"command": "/usr/bin/gcc-9",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
1 change: 1 addition & 0 deletions examples/gdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkexec /usr/bin/gdb "$@"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a header comment explaining what this file is for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I entirely understand the purpose of this file. I think it allows administrator privileges for gdb, which is why the pkexec command is used, but I don't think I can succinctly summarize it in a comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a suggestion:

Suggested change
pkexec /usr/bin/gdb "$@"
# This is a wrapper script for GDB that allows it to run as root. This is necessary if you are calling
# gdb from an IDE like VS Code that by itself does not run as root.
# NOTE: In some cases we have found that you must use `sudo` instead of `pkexec` here.
pkexec /usr/bin/gdb "$@"

We will need to test this on a few different setups to understand whether to use sudo or pkexec. My memory is that when we tried to use this on Noah's machine it only worked with sudo, but on yours you needed pkexec. We will want to set this to whichever is needed on CloudLab since it is our "standard" platform.