Skip to content

pickRemoteProcess relies on personality-depenendent behavior of ps that breaks on some systems #14442

@nluchuk-ai

Description

@nluchuk-ai

Environment

  • OS and version: Ubuntu 24.04.4 LTS running in WSL2 under Windows 11
  • VS Code: 1.1119.0
  • C/C++ extension: 1.32.2
  • OS and version of remote machine: Bespoke Linux distro via Buildroot
  • GDB / LLDB version: Any (not relevant)

Bug Summary and Steps to Reproduce

Bug Summary: The ps options this command uses on the remote system depends on a behavior that is not the default on all systems (see the additional information), and breaks on systems that use a different default.

Steps to reproduce:

  1. With a remote system that uses an undesirable default (unfortunately, the only system I have identified where this is the case is a bespoke buildroot distro, and I can't share details; maybe try a default buildroot?)
  2. Make a debug config that specifies "processId": "${command:pickRemoteProcess}"
  3. Try to use that config to attach to a process on that remote system
  4. The dropdown in VSCode will be empty, despite ps working just fine on the remote system.

Debugger Configurations

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Pipe Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "enter program name, for example ${workspaceFolder}/a.out",
            "processId": "${command:pickRemoteProcess}",
            "pipeTransport": {
                "debuggerPath": "/usr/bin/gdb",
                "pipeProgram": "/usr/bin/ssh",
                "pipeArgs": [],
                "pipeCwd": ""
            },
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        },
    ]
}

Debugger Logs

N/A

Other Extensions

No response

Additional Information

The pickRemoteProcess/extension.pickRemoteNativeProcess command runs ps on the remote system with arguments that may or may not work, depending on the ps "personality," which is a mode-type setting that changes how various details of the ps command work, which is a problem because the remote system may not use the personality which is necessary for this command to work as expected.

Specifically, the command runs something like

ps axww -o pid=,comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,args=

The man page for ps explicitly documents that syntax like ps -o pid=X,comm=Y can either

  • show both a pid and a comm column with headers X and Y respectively (which appears to be the behavior this pickRemoteProcess is expecting), or
  • show just a pid column with header X,comm=Y (which is what my remote system does).
    Which behavior this syntax has depends on the personality setting. The man page for ps claims can be set via the environment variable PS_PERSONALITY, though I was not able to observe this.

In this case, there is a simpler solution: don't use syntax that relies on the personality. Multiple uses of -o should each make their own column, so the command should be changed to

ps axww -o pid= -o comm=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -o args=

This should behave identically on systems that already worked, but should fix the problem on systems that default to a different personality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions