2

I need to debug a C++ library function invoked by a Python module in VSCode on a remote server.

I'm using VSCode Remote Development extensions, and debugging C++ code using gdb inside vscode on the remote server works fine, as does debugging Python on the remote.

I've tried both attaching to a paused (waiting for input) python process started from the terminal, and attaching to a python process at a breakpoint launched using the python (remote) debugger in vscode.

In both cases, I attach to the process ID using this launch.json config:

{
            "name": "GDB Attach proc 0",
            "type": "cppdbg",
            "request": "attach",
            "program": "/home/nfs/mharris/anaconda3/envs/cudf_dev/bin/python",
            "processId": "${command:pickProcess}",
            "linux": {
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "text": "-enable-pretty-printing",
                        "description": "enable pretty printing",
                        "ignoreFailures": true
                    },
                    {
                        "text": "handle SIGPIPE nostop noprint pass",
                        "description": "ignore SIGPIPE",
                        "ignoreFailures": true
                    }
                ]
            },
        },

It prints the following in the gdb terminal window:

==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/bin/gdb' as the super user
Authenticating as: aseadmin,,, (aseadmin)
Password: [1] + Stopped (tty output)       /usr/bin/pkexec /usr/bin/gdb --interpreter=mi --tty=${DbgTerm} 0</tmp/Microsoft-MIEngine-In-bydexniu.cf5 1>/tmp/Microsoft-MIEngine-Out-mo618uzc.30l
You have stopped jobs.

I believe aseadmin is an admin user on the server. I don't know why it's trying to run gdb as the superuser. I'm connected to the remote using VSCode remote - SSH using ssh key authentication (my username is not aseadmin, so I'm not sure why it's using that).

I'm running vscode-insider (Version: 1.37.0-insider) with the remote development extensions (0.15.0), on Ubuntu 16.04 LTS.

1 Answer 1

0

If you try to attach to Python process with GDB from the terminal using gdb --pid=XXX, you might see the output that can help you to resolve authentication issue in one way:

...
Attaching to process 30428
Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.

Thus, ptrace setting kernel.yama.ptrace_scope=1 is not permitting GDB to attach to the process to not direct childs (see /etc/sysctl.d/10-ptrace.conf for explanation).

To avoid authentication, either:

  • change config setting (requires reboot)
  • and/or set value in /proc/sys/kernel/yama/ptrace_scope to 0 (reboot is not required, but not permanent), e.g. sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.