fsquillace / junest

The lightweight Arch Linux based distro that runs, without root privileges, on top of any other Linux distro.
GNU General Public License v3.0
2.08k stars 111 forks source link

Attaching gdb from junest, to a process launched outside of junest fails #269

Open jcelerier opened 3 years ago

jcelerier commented 3 years ago

Hello,

I installed Junest in the hope of being able to use GDB 10 on my raspberry pi (running Debian Buster). If I run Debian's gdb 8 I can attach to my process. But if I run under junest's gdb 10.2, then I get a "ptrace: operation not permitted" error. I tried running under root and junest -f but that did not change anything.

What else could I look at ?

Thanks !

fsquillace commented 3 years ago

Can you provide the exact steps that brought you to the error? I can try to reproduce.

jcelerier commented 3 years ago

I'll look into my bash history !

jcelerier commented 3 years ago
pi $ git clone git://github.com/fsquillace/junest ~/.local/share/junest
pi $ export PATH=~/.local/share/junest/bin:$PATH
pi $ junest setup
pi $ junest -f
junest-root $ pacman -S gdb
junest-root $ exit
pi $ junest
junest $ gdb
(gdb) attach <some pid>
Attaching to process <...>
ptrace: Operation not permitted.
fsquillace commented 2 years ago

Not all processes can be debugged. Consider that this can happen even if you try using gdb outside junest, I'd suggest to try that first if you can.

In order to enable ptrace capabilities in junest you'd need to run something like:

junest -f -b "--cap-add ALL"

I am inclined to use it --cap-add ALL as default option when running as fakeroot. I will check if there are no side-effects.

jcelerier commented 2 years ago

Not all processes can be debugged. Consider that this can happen even if you try using gdb outside junest, I'd suggest to try that first if you can.

I can debug the process I want with my Pi's /usr/bin/gdb without issues (except that it's too old for the DWARF-5 debug info format used by the app I want to debug)

I'll try the ptrace thing, thanks !

fsquillace commented 2 years ago

Cool, thanks. Let me know if that works :crossed_fingers:

fsquillace commented 2 years ago

In the latest junest change I put --cap-add ALL as default to the ns fakeroot mode.