How to show source code when debugging Linux kernel [message #1260179] |
Sat, 01 March 2014 06:29 |
Winston Gao Messages: 1 Registered: March 2014 |
Junior Member |
|
|
I am trying to debugging kernel in source code level. I have below configuration:
Connect target machine (the machine on which the kernel is debugged) and host machine (machine on which user sends debug commands) using serial cable. Both target machine and host machine run Ubuntu 13.10, and use /dev/ttyS0 for connection.
Build kernel with debug information and install the kernel in target machine, and copy the whole kernel source code folder to host machine.
Launch new installed kernel in target machine. and run below command:
#sysctl -w kernel.sysrq=1
#echo ttyS0,15200 > /sys/module/kgdboc/parameters/kgdboc
In host machine, enter linux source code folder and run below command to launch gdb:
$gdb ./vmlinux
in gdb console, run:
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyS0
then in target machine, run:
#echo g > /proc/sysrq-trigger SysRq
the target machine stops and the gdb console stop in break point and you can use gdb list command to see current source code the debugger stops at.
To make the debugging process easier, I would like to find a gdb GUI front end. Eclipse is promising however, I could not make it working. Below is my steps for doing the debug via Eclipse:
Create a project using exiting source code. since it is built already I think I do not need to build the kernel inside eclipse.
In debug configuration, I create a debug configuration under "Attach an application". After setting gdbserver debugging, vmlinux as debug application, and connection method to be serial port, I can launch the debugging in Eclipse.
After running #echo g > /proc/sysrq-trigger SysRq in target machine, eclipse debugger stops,and here is the problem --- the source code is not displayed. Instead it says no source code is available. After I click "continue to run" button in the debug menu, the target machine continue to run without problem. So the connection between host and target machine is connected properly. Also gdb command is sent properly. The problem is why the source code cannot be found while in gdb it works like a charm.
Should I choose "Attach ab application" in debug configuration? In some post it says we should use "Debug local application", which apparently does not work in my test. Also "Debug remote application" seems make sense, also it turned out it does not work.
I also check the currently working directory using pwd command in gdb console, and it points to linux kernel source folder.
What would be wrong?
Thanks,
Winston
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03216 seconds