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

How to spawn gdb with superuser permission (sudo)? #61

Closed
yakamoz423 opened this issue Mar 10, 2022 · 3 comments
Closed

How to spawn gdb with superuser permission (sudo)? #61

yakamoz423 opened this issue Mar 10, 2022 · 3 comments

Comments

@yakamoz423
Copy link

yakamoz423 commented Mar 10, 2022

I installed cdt-gdb-vscode in VS Code on Windows, and opened a folder in Remote WSL mode. Then start debugging, gdb says ptrace: Operation not permitted. The same warning is shown when I use bash instead. But in bash, debugging session works via sudo gdb attach xxxcommand. So how to launch "sudo gdb" to start debugging? Thanks for replying!

launch.json configurations is:

        {
            "type": "gdb",
            "request": "attach",
            "name": "linux",
            "gdb": "gdb",
            "processId": "${command:askProcessId}",
            "program": "/usr/bin/vi",
            "verbose": "true",
        }
@paul-marechal
Copy link
Member

I don't know if it would work but I'd make a sudo_gdb.sh script like:

#!/bin/bash
sudo gdb $@

And then point the configuration to spawn this script instead of gdb directly?

@yakamoz423
Copy link
Author

Thank you, it works. I used expect script instead.

#!/usr/bin/expect

spawn sudo gdb $argv
expect "password for <username>: "
send "<password>\n"
interact

@jonahgraham
Copy link
Contributor

The workaround of using the script is ok, but the other solution may be to enable ptrace, see for example this SO answer https://stackoverflow.com/a/32274645/2796832

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants