Enable Debugging with GDB in Edge Microvisor Toolkit Developer Node#
In a mutable developer node installed from an ISO image, you can enable
unrestricted debugging. To debug any process in the system, you need to change
the value of the kernel.yama.ptrace_scope configuration parameter of
Yama - Linux Security Module (LSM)
that does Discretionary Access Control of kernel related functions.
The ptrace_scope parameter defines whether selected processes can be debugged
with ptrace (process tracing).
Configure Yama
ptracesettings.Open the
99-yama-ptrace.confconfiguration file with a chosen editor:sudo vi /lib/sysctl.d/99-yama-ptrace.conf
Add or modify the following line:
kernel.yama.ptrace_scope = 0
Setting the parameter’s value to
0allows you to debug any process in the system.Rebuild initramfs and reboot the device.
sudo dracut --force sudo reboot
Verify the
ptracesettings after reboot.sudo sysctl kernel.yama.ptrace_scope
If properly set, it should return
0.Install GDB - the GNU Project Debugger.
sudo apt install gdb
Compile your program with debug symbols.
Compile your code, using gcc with the
-goption, which enables extra debugging information for GDB to process, and the-ooption, that allows you to save the output to a specified file.gcc -g sum.c -o sum_debug
Run GDB and debug the output file.
To debug the
sum_debugoutput file you need to specify it as an argument togdb.gdb ./sum_debugOr, run the output file inside
gdbusing thefilecommand.gdb file sum_debugNow, you can set breakpoints and debug normally.