Debugging kernel using kgdb/gdb on arm target?

791 Views Asked by At

I got vmlinux.uimg and vmlinux from my friend. The vmlinux is build with Linux version 4.14.10. I have two machines:

  • target (arm 32 bit architecture) and
  • host (x86 architecture)

Both systems are connected with wire, port numbers are /dev/ttySAC3 and /dev/ttyUSB0 respectively. Target boot up by reading image file vmlinux.uimg from sd card. I want to debug this vmlinux from my host machine.

The steps I am following are:

  1. Start minicom in host.
  2. Type

    echo ttySAC3,115200 > /sys/module/kgdboc/parameters/kgdboc in minicom.
    

    I am getting "KGDB: Registered I/O driver kgdboc".

  3. Type

    echo g >/proc/sysrq-trigger in minicom
    

    I am getting "sysrq DEBUG and Entering KGDB".

  4. Close minicom.
  5. Go to vmlinux folder through terminal in host machine.
  6. Type

    gdb vmlinux
    

    [Note: this gdb I am using is 7.10 version for arm]

  7. In GDB type

    target remote /dev/ttyUSB0
    

    It give me a message

    Remote debugging using /dev/ttyUSB0 0xc0d14f5 in sysrq_dbg_op()
    
  8. In GDB type

    b do_mmap_pgoff
    

    I am getting a message

    breakpoint 1 at xxxx: do_map_pgoff (4 location)
    
  9. In GDB type

    cont
    

    This gives me a message

    Continuing.
    

    and then does nothing..

The problems:

  1. GDB continue is not working as expected. I am expecting last step(9) to continue with target restart and hit the break point instead it is getting crash.

  2. GDB step and next are not working as expected. Single stepping until exit from sysrq_dbg_op() which has no line number information. "Warning: invalid remote reply".

  3. GDB 'run' is also not working. It display a message "The remote target does not support run"

  4. How can I call a module on my target on which I have put breakpoint as I can not use minicom and gdb concurrently.

  5. What all steps I should follow after I freeze the kernel.

What is wrong in this process?

0

There are 0 best solutions below