Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to show source code when debugging Linux kernel(When debugging kernel in source code level, source code is not shown when debugging stops in breakpoint)
icon9.gif  How to show source code when debugging Linux kernel [message #1260179] Sat, 01 March 2014 06:29 Go to next message
Winston Gao is currently offline Winston GaoFriend
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?

Re: How to show source code when debugging Linux kernel [message #1721803 is a reply to message #1260179] Sun, 31 January 2016 06:28 Go to previous messageGo to next message
vlad solov is currently offline vlad solovFriend
Messages: 2
Registered: January 2016
Junior Member
same issue,did you figured it out?
Re: How to show source code when debugging Linux kernel [message #1721941 is a reply to message #1721803] Mon, 01 February 2016 18:13 Go to previous message
David VavraFriend
Messages: 1430
Registered: October 2012
Senior Member
You need to specify where the source can be found. Use the Source tab of Debug Configuration dialog.
Previous Topic:I cannot run project once I quit eclipse and launch it again.
Next Topic:LOG4CXX and 'Invalid argument' problem
Goto Forum:

Current Time: Wed Aug 10 21:27:50 GMT 2022

Powered by FUDForum. Page generated in 0.02066 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top