kgdb.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. A Simple Guide to Configure KGDB
  2. Sonic Zhang <sonic.zhang@analog.com>
  3. Aug. 24th 2006
  4. This KGDB patch enables the kernel developer to do source level debugging on
  5. the kernel for the Blackfin architecture. The debugging works over either the
  6. ethernet interface or one of the uarts. Both software breakpoints and
  7. hardware breakpoints are supported in this version.
  8. http://docs.blackfin.uclinux.org/doku.php?id=kgdb
  9. 2 known issues:
  10. 1. This bug:
  11. http://blackfin.uclinux.org/tracker/index.php?func=detail&aid=544&group_id=18&atid=145
  12. The GDB client for Blackfin uClinux causes incorrect values of local
  13. variables to be displayed when the user breaks the running of kernel in GDB.
  14. 2. Because of a hardware bug in Blackfin 533 v1.0.3:
  15. 05000067 - Watchpoints (Hardware Breakpoints) are not supported
  16. Hardware breakpoints cannot be set properly.
  17. Debug over Ethernet:
  18. 1. Compile and install the cross platform version of gdb for blackfin, which
  19. can be found at $(BINROOT)/bfin-elf-gdb.
  20. 2. Apply this patch to the 2.6.x kernel. Select the menuconfig option under
  21. "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".
  22. With this selected, option "Full Symbolic/Source Debugging support" and
  23. "Compile the kernel with frame pointers" are also selected.
  24. 3. Select option "KGDB: connect over (Ethernet)". Add "kgdboe=@target-IP/,@host-IP/" to
  25. the option "Compiled-in Kernel Boot Parameter" under "Kernel hacking".
  26. 4. Connect minicom to the serial port and boot the kernel image.
  27. 5. Configure the IP "/> ifconfig eth0 target-IP"
  28. 6. Start GDB client "bfin-elf-gdb vmlinux".
  29. 7. Connect to the target "(gdb) target remote udp:target-IP:6443".
  30. 8. Set software breakpoint "(gdb) break sys_open".
  31. 9. Continue "(gdb) c".
  32. 10. Run ls in the target console "/> ls".
  33. 11. Breakpoint hits. "Breakpoint 1: sys_open(..."
  34. 12. Display local variables and function paramters.
  35. (*) This operation gives wrong results, see known issue 1.
  36. 13. Single stepping "(gdb) si".
  37. 14. Remove breakpoint 1. "(gdb) del 1"
  38. 15. Set hardware breakpoint "(gdb) hbreak sys_open".
  39. 16. Continue "(gdb) c".
  40. 17. Run ls in the target console "/> ls".
  41. 18. Hardware breakpoint hits. "Breakpoint 1: sys_open(...".
  42. (*) This hardware breakpoint will not be hit, see known issue 2.
  43. 19. Continue "(gdb) c".
  44. 20. Interrupt the target in GDB "Ctrl+C".
  45. 21. Detach from the target "(gdb) detach".
  46. 22. Exit GDB "(gdb) quit".
  47. Debug over the UART:
  48. 1. Compile and install the cross platform version of gdb for blackfin, which
  49. can be found at $(BINROOT)/bfin-elf-gdb.
  50. 2. Apply this patch to the 2.6.x kernel. Select the menuconfig option under
  51. "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".
  52. With this selected, option "Full Symbolic/Source Debugging support" and
  53. "Compile the kernel with frame pointers" are also selected.
  54. 3. Select option "KGDB: connect over (UART)". Set "KGDB: UART port number" to be
  55. a different one from the console. Don't forget to change the mode of
  56. blackfin serial driver to PIO. Otherwise kgdb works incorrectly on UART.
  57. 4. If you want connect to kgdb when the kernel boots, enable
  58. "KGDB: Wait for gdb connection early"
  59. 5. Compile kernel.
  60. 6. Connect minicom to the serial port of the console and boot the kernel image.
  61. 7. Start GDB client "bfin-elf-gdb vmlinux".
  62. 8. Set the baud rate in GDB "(gdb) set remotebaud 57600".
  63. 9. Connect to the target on the second serial port "(gdb) target remote /dev/ttyS1".
  64. 10. Set software breakpoint "(gdb) break sys_open".
  65. 11. Continue "(gdb) c".
  66. 12. Run ls in the target console "/> ls".
  67. 13. A breakpoint is hit. "Breakpoint 1: sys_open(..."
  68. 14. All other operations are the same as that in KGDB over Ethernet.
  69. Debug over the same UART as console:
  70. 1. Compile and install the cross platform version of gdb for blackfin, which
  71. can be found at $(BINROOT)/bfin-elf-gdb.
  72. 2. Apply this patch to the 2.6.x kernel. Select the menuconfig option under
  73. "Kernel hacking" -> "Kernel debugging" -> "KGDB: kernel debug with remote gdb".
  74. With this selected, option "Full Symbolic/Source Debugging support" and
  75. "Compile the kernel with frame pointers" are also selected.
  76. 3. Select option "KGDB: connect over UART". Set "KGDB: UART port number" to console.
  77. Don't forget to change the mode of blackfin serial driver to PIO.
  78. Otherwise kgdb works incorrectly on UART.
  79. 4. If you want connect to kgdb when the kernel boots, enable
  80. "KGDB: Wait for gdb connection early"
  81. 5. Connect minicom to the serial port and boot the kernel image.
  82. 6. (Optional) Ask target to wait for gdb connection by entering Ctrl+A. In minicom, you should enter Ctrl+A+A.
  83. 7. Start GDB client "bfin-elf-gdb vmlinux".
  84. 8. Set the baud rate in GDB "(gdb) set remotebaud 57600".
  85. 9. Connect to the target "(gdb) target remote /dev/ttyS0".
  86. 10. Set software breakpoint "(gdb) break sys_open".
  87. 11. Continue "(gdb) c". Then enter Ctrl+C twice to stop GDB connection.
  88. 12. Run ls in the target console "/> ls". Dummy string can be seen on the console.
  89. 13. Then connect the gdb to target again. "(gdb) target remote /dev/ttyS0".
  90. Now you will find a breakpoint is hit. "Breakpoint 1: sys_open(..."
  91. 14. All other operations are the same as that in KGDB over Ethernet. The only
  92. difference is that after continue command in GDB, please stop GDB
  93. connection by 2 "Ctrl+C"s and connect again after breakpoints are hit or
  94. Ctrl+A is entered.