Help answer threads with 0 replies.
Go Back > Blogs > hi2arun
User Name


Rate this Entry

Mapping address to line - Linux

Posted 08-31-2011 at 01:20 AM by hi2arun
Tags debug, kernel, panic

Well.. when you write your own kernel module, in the devel stage, chances for bringin down the kernel (panic.. ah sick) are huge.
Oops (pet name for kernel panic) mostly spits lots of martian traces that include stack addresses, registers and its value, EIP, etc.

To know the culprit line that caused panic, decode the address to line as follows:
EIP wud luk like...
EIP: [] ip_check+0x45a/0x21a [ip_tables] SS:ESP 0049:c098281a
Look at the selection in blue color. The word within square brackets is the module name and the word before '+' is the function name.

Now, do objdump for the module:
# objdump -d ip_tables.ko
Search for ip_check and make a note of its address
Now, do a simple math:
+ 0x21a = address of the culprit line
Letz translate the address to line...
# addr2line -e ip_tables.ko

Thatz it! Now you should see the file name and line number where panic happened (most likely).

PS: addr2line can also be used for any linux binaries (ELF)
Posted in Uncategorized
Views 1911 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 07:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration