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).

  1. Configure Yama ptrace settings.

    Open the 99-yama-ptrace.conf configuration 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 0 allows you to debug any process in the system.

  2. Rebuild initramfs and reboot the device.

    sudo dracut --force
    sudo reboot
    
  3. Verify the ptrace settings after reboot.

    sudo sysctl kernel.yama.ptrace_scope
    

    If properly set, it should return 0.

  4. Install GDB - the GNU Project Debugger.

    sudo apt install gdb
    
  5. Compile your program with debug symbols.

    Compile your code, using gcc with the -g option, which enables extra debugging information for GDB to process, and the -o option, that allows you to save the output to a specified file.

    gcc -g sum.c -o sum_debug
    
  6. Run GDB and debug the output file.

    To debug the sum_debug output file you need to specify it as an argument to gdb.

    gdb ./sum_debug
    

    Or, run the output file inside gdb using the file command.

    gdb
    file sum_debug
    
  7. Now, you can set breakpoints and debug normally.