LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
LinkBack Search this Thread
Old 02-05-2012, 12:14 PM   #1
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 7

Rep: Reputation: Disabled
LKM init module debugging.


Hi All,

I got the linux kernel and LKM to get debugged using KGDB. To debug the module I use add-symbol-file with the virtual address where the module is loaded in target machine. But with this approach I am unable to debug the init module because the virtual address can be found only after the module is loaded.

So please can I know how to debug the init module?!?

Thanks.
 
Old 02-06-2012, 01:24 AM   #2
bsat
Member
 
Registered: Feb 2009
Posts: 278

Rep: Reputation: 39
You could try using printk at various levels or creating proc entry that gives you the relevant info.
 
Old 02-07-2012, 04:46 AM   #3
vedasolutions
LQ Newbie
 
Registered: Feb 2012
Posts: 5

Rep: Reputation: Disabled
You can do one thing. You put a break point at sys_init_module() function and
run the program step by step until you reach the following code in the sys_init_module().

/* Start the module */
if (mod->init != NULL)
ret = do_one_initcall(mod->init);

Before the if condition is executed, you can check the value of mod->init and load the symobol file like this in the gdb.

add-symbol-file <module.ko> 000000 -s .init.text <mod->init>

This only works for init. Please let me know if it works.
 
1 members found this post helpful.
Old 02-09-2012, 04:39 AM   #4
$ubbu
LQ Newbie
 
Registered: Sep 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
@vedasolutions

Perfect works like a charm but with little modification.

I set a breakpoint at do_one_initcall function. The argument address was 0xe0892850 (in my case). Using objdump I found that my init module was 850 bytes away from the beginning of my text segment. Hence I loaded the symbol file as follows

add-symbol-file <module.ko> 0xe0892000

which allowed me to set a breakpoint to any of my module functions including init.

Thanks a lot!!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
loadable kernel module (LKM) issues shakthi Linux - Kernel 4 07-26-2011 09:02 AM
[SOLVED] Possible to make a application module similar to LKM? yaplej Programming 2 03-19-2011 11:06 PM
Debugging kernel module kewl Linux - Newbie 2 07-13-2010 07:34 AM
kernel module debugging jinochiramel Linux - Newbie 1 07-01-2009 12:23 PM
I want add my own system call using LKM (loadable kernel module)... raga4223688 Linux - Software 1 03-07-2007 07:21 AM


All times are GMT -5. The time now is 12:38 PM.

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