Repository navigation
cppdbg attach issues #5287
Copy link
Copy link
Closed
Labels
debuggerfixedCheck the Milestone for the release in which the fix is or will be available.Check the Milestone for the release in which the fix is or will be available.
Milestone
Description
- OS and Version: Linux Mint 19.3 x64
- VS Code Version: 1.44.0
- C/C++ Extension Version: 0.27.0
Issue 1:
When attaching to a program using cppdbg with processId as ${command:pickProcess}, the command pick does not wait for the preLaunchTask initialization/finalization, processId command pick should start just after the preLaunchTask finalization.
Issue 2:
Not able to pass environment variables values to cppdbg when attaching to a program, but is possible when launching. Why? Let's say I have a PID stored inside an environment variable and I would like to use this variable for the attach processId property, how I would do that?
Launch/Tasks examples:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/mnt/ssd/Steam/steamapps/common/Half-Life/hl_linux",
"processId": "${command:pickProcess}",
"preLaunchTask": "attach",
"MIMode": "gdb",
//"additionalSOLibSearchPath": "/lib/i386-linux-gnu;/usr/lib/i386-linux-gnu/",
"setupCommands": [
/* {
"description": "Command-line arguments",
"text": "-exec set args ",
}, */
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Auto load symbols when loading an .so file",
"text": "set auto-solib-add",
"ignoreFailures": false
}
]
},
]
}
{
"version": "2.0.0",
"options": {
"env": {
"GAME_ID": "xxxxxxxxxxxxx",
"HL_PATH": "/mnt/ssd/Steam/steamapps/common/Half-Life",
"HL_PID": ""
}
},
"tasks": [
{
"label": "build",
"type": "shell",
"command": "./linux/build.sh",
"args": [],
"group": "build",
"isBackground": false,
"options": {
"cwd": "${workspaceFolder}"
},
"presentation": {
"reveal": "always",
"panel": "shared"
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "attach",
"type": "shell",
"command": "./linux/attach.sh",
"args": [],
"group": "build",
"isBackground": false,
"options": {
"cwd": "${workspaceFolder}"
},
"presentation": {
"reveal": "always",
"panel": "shared"
},
"problemMatcher": [
"$gcc"
],
"dependsOn": [
"build"
]
}
]
}
build/attach scripts:
#!/bin/bash
export AG_PATH=${HL_PATH}/ag
echo "HL_PATH: ${HL_PATH}"
echo "AG_PATH: ${AG_PATH}"
echo "GAME_ID: ${GAME_ID}"
dir=$(pwd)
echo "Starting build.."
git submodule update --init
mkdir -p build
cd build
cmake -DCMAKE_RULE_MESSAGES:BOOL=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Debug ..
make --no-print-directory
#!/bin/bash
echo "GAME_ID: ${GAME_ID}"
dir=$(pwd)
echo "Killing olds hl_linux instances.."
killall hl_linux
/usr/bin/steam steam://rungameid/${GAME_ID} && sleep 5
#PID=$(pgrep -f "hl_linux" | xargs)
PID=$(pidof hl_linux)
export HL_PID=$PID
echo "hl_linux PID: ${HL_PID}"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
debuggerfixedCheck the Milestone for the release in which the fix is or will be available.Check the Milestone for the release in which the fix is or will be available.
Activity
WardenGnaw commentedon Apr 13, 2020
Unfortunately.
preLaunchTaskis handled by VSCode, they only guarantee that it will be completed before debug session starts.${command:pickProcess}runs when VS Code callsresolveDebugConfigurationwhich is done also before the debug session starts. You will want to file an issue on the VS Code issues page to have a way to have thepreLaunchTaskcomplete before sending it toresolveDebugConfiguration.The
environmentconfiguration in launch is to set thedebuggeeprocesses' environment variables before starting up the debuggee process. During attach, there is no way for us to inject the environment variables into the debuggee process before attaching to the process.Also setting up environment variables in
tasks.jsonwould require that VS Code uses the same terminal session for launching the debug adapter for the debugger to get the setup environment variables.gustavomassa commentedon Apr 13, 2020
Andrew Wang (@WardenGnaw) I will open an issue on the vscode issues page. Regarding the issue 2, vscode should provide a way to read the processId, reading an environment variable/file or something else, like process name or pidof... I will make a point about it on the issue.
WardenGnaw commentedon Apr 13, 2020
VS Code has a way to provide custom inputs. I haven't tried this out myself, but this may possible with
commandinputs.However, this may require a change on the extension side to use
resolveDebugConfigurationWithSubstitutedVariablesgustavomassa commentedon Apr 14, 2020
I could help you with the changes.
Also, an option to pass y/n to the superuser confirmation directly from the launch.json would be nice. Something like "allowSuperuser": true
sean-mcmanus commentedon Nov 4, 2020
Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.1.0-insiders4