Skip to content

cppdbg attach issues #5287

@gustavomassa

Description

@gustavomassa
  • 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}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    debuggerfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions