Debugging ModemManager from an IDE
Garfield Watkins
garfield.watkins at gmail.com
Thu Nov 7 08:33:31 UTC 2024
On 11/6/24 09:21, Garfield Watkins wrote:
>
> Hi
>
> I'm using vscode to develop a plugin for ModemManager but find that
> debugging from the IDE is impossible. Can anyone share their setup for
> debugging from an IDE without having to run anything under root ? e.g.
> what is your d-bus policy config for ModemManager ? I'm also getting
> ioctl permission errors. Im also launching a connection from Network
> Manager and getting permission errors there too.
>
> Thanks
>
Ok. I'll answer my own question in case anyone else searches this
mailing list looking for a solution to this.
The idea is to only run gdb under sudo not the entire IDE, so to
facilitate this:
1. create a shell script wrapper around gdb e.g.
~/.local/bin/sudo_gdb.shThe contents being something like:
#!/bin/bash
sudo /usr/bin/gdb "$@"
2. Make it executable
3. Add /usr/bin/gdb to the /etc/sudoers file so that it can be run with
sudo without asking for a password.
yourusername ALL=(ALL) NOPASSWD: /usr/bin/gdb
4. Modify your vscode debug launch configuration to use the script that
wraps gdb as the debugger
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${userHome}/.local/sbin/ModemManager",
"args": ["--debug"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "${userHome}/.local/bin/sudo_gdb.sh",
"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
}
]
}
]
}
5. You might find there are some library files that can't be found if
you installed in a non default location. my install prefix was set
to ${userHome}/.local/ and the /libmm-glib.so* could not be found
so i just copied .local/lib/aarch64-linux-gnu/libmm-glib.so*. to
/usr/lib/aarch64-linux-gnu/
More information about the ModemManager-devel
mailing list