Can KGDB debug a device driver?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Can KGDB debug a device driver?
# 1  
Old 10-26-2011
Can KGDB debug a device driver?

Hi, all:

I am using the KGDB to debug my own network driver on linux. But I suspect if my KGDB work nomally. When I set a breakpoint at "do_one_initcall" function, the kernel function that will call my driver module, and continue to reach there, the "step" command of GDB cannot enter into my own driver(the initiate function of my driver)! Is this correct?

What are the right ways and commands to get the GDB to reach the initiate function of my driver from kernel? What is the best way to debug the initalization codes of a driver? Whether or not can the "step" command enter into my driver on earth?

Thanks!
li, kunlun
# 2  
Old 10-26-2011
The kernel is what starts and stops processes on breakpoints, watches memory, etc. on command -- gdb just tells the kernel what to do. Without a kernel to facilitate them, these features are not available.

gdb or any other process gets halted by the kernel when making a system call anyway. It doesn't "step in" because there's nothing to step in to; it's not a function call, it calls INT 0x20 (I think) and suspends itself until the system call is done. Once the system call is done, it starts again.

The traditional way to debug the kernel is lots of debugging spew, preferably directly to an external device so it doesn't get lost on crash.

To get that level of debugging on the kernel itself, you would need some sort of virtual machine, I think.
# 3  
Old 10-27-2011
How can I watch the running details of a kernel function?

Hi:

Thanks! But my program is also a kernel device driver module and isn't a process!

What should I do to watch the running details of a kernel function called in my own driver? Especially the driver initalization codes such as "register_netdev()" function. My linux kernel is 3.0.4 and KGDB enabled. Two PC linked by serial cable on serial port are there for debugging.


li, kunlun

---------- Post updated at 10:36 PM ---------- Previous update was at 09:12 PM ----------

Following are my actual methord of debugging into my own driver module from kernel:

at development end for example:

(gdb) br do_one_initcall
/*it will reply information such as "fn=0xd0a5c020", for example*/

(gdb)add-symbol-file path/to/rtl8139_driver.ko 0xd0a5c000
/*the address is geted from above fn-0x20*/

(gdb)hb 0xd0a5c000

when continue to the hard break, debugger can step into my driver module from kernel.

My question is whether this methord is right or not? What is the best or right methord?


thanks!
li, kunlun

---------- Post updated at 11:05 PM ---------- Previous update was at 10:36 PM ----------

(gdb) info br
Num Type Disp Enb Address What
1 breakpoint keep y 0xc0101104 in do_one_initcall
at init/main.c:671
breakpoint already hit 1 time
(gdb) n
671 in init/main.c
(gdb) n
668 in init/main.c
(gdb) s
671 in init/main.c
(gdb) n
674 in init/main.c
(gdb) step

Program received signal SIGSEGV, Segmentation fault.
0xf3983128 in ?? ()
(gdb)



and the related source code is here:

666 int __init_or_module do_one_initcall(initcall_t fn)
667 {
668 int count = preempt_count();
669 int ret;
670
671 if (initcall_debug)
672 ret = do_one_initcall_debug(fn);
673 else
674 ret = fn();


my linux kernel is 3.0.4;

Is there anyone who have any idea?
# 4  
Old 10-27-2011
Quote:
Originally Posted by liklstar
Hi:

Thanks! But my program is also a kernel device driver module and isn't a process!
Oh. I was thinking of the wrong kgdb.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. What is on Your Mind?

Device driver programming

I want to work one day as a device driver programmer, OS I'm in love is Solaris :D I am learning C in my free time which I don't have because college took my life and I need to study to pass. In college we work in C++ / Java. These languages aren't inteded for device driver programming , saying... (0 Replies)
Discussion started by: solaris_user
0 Replies

2. Programming

regarding device driver

Hi All, I have a device driver that uses UARTserial port to write/read to-from a device. That device driver is working fine on FC3 machine( kernel version 2.6.12)... Now I am switching to FC9 (kernel version 2.6.25.11-97).I have changed the interrupt flag SA_INTERRUPT to IRQF_DISABLED... (0 Replies)
Discussion started by: rajuprade
0 Replies

3. UNIX for Advanced & Expert Users

help regarding device driver

Hi All, I have a device driver that uses UARTserial port to write/read to-from a device. That device driver is working fine on FC3 machine( kernel version 2.6.12)... Now I am switching to FC9 (kernel version 2.6.25.11-97).I have changed the interrupt flag SA_INTERRUPT to IRQF_DISABLED... (0 Replies)
Discussion started by: rajuprade
0 Replies

4. Programming

Network device driver

HI, I am writing a network device driver for RTL8139c card on 2.6.18 kernel ... I am facing few queries listed below 1. Can i able to at all write a driver for RTL8139C or Realtek had designed new chip for 2.6 series kernel? 2. If no then which driver file 2.6.18 uses .. Is it 8139too.c or... (1 Reply)
Discussion started by: niketan
1 Replies

5. Solaris

SUNWglmr -- rasctrl environment monitoring driver for i2c or SCSI device driver ?

I've been researching minimizeing Solaris 8 and found that on the web page http://www.sun.com/bigadmin/content/packagelist/s8u7PkgList/p2.html the package SUNWglmr is listed as "rasctrl environment monitoring driver for i2c, (Root) (32-bit)" while in the document "Solaris 8 minimize-updt1.pdf"... (1 Reply)
Discussion started by: roygoodwin
1 Replies
Login or Register to Ask a Question