Re: Using GDB and debugging a kernel module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Thu, Oct 30, 2008 at 8:05 AM, Ian Brown <ianbrn@xxxxxxxxx> wrote:
Hello,
 I am developing a kernel module (called myModule);
 I have errors when running it in the kernel log; and I want to know in
 which line of my module exactly did this error occur.

 in the kernel log I have:
 ...
 ...
 myModule_ioctl+0x4b1/0x864
 [<ffffffff8025c509>] ret_from_intr+0x0/0xa
 <EOI>  [<ffffffff8025f952>] copy_user_generic+0x9e/0x126
 [<ffffffff8833fe78>] :myModule:myModule_ioctl+0x4b1/0x864
 [<ffffffff802406be>] do_ioctl+0x55/0x6b
 [<ffffffff80230101>] vfs_ioctl+0x256/0x26f
 [<ffffffff8029f1a9>] sys_futex+0x103/0x121
 [<ffffffff8024aec5>] sys_ioctl+0x59/0x78
 [<ffffffff8025c00e>] system_call+0x7e/0x83

 ...
 where myModule_ioctl is a method in myModule.

Can I know with GDB in which line of this method this happened ?


 I tried to follow LDD3. I used the ./gdbline  myModule
and got:
add-symbol-file 0xffffffff88329000 \
      -s .bss 0xffffffff8832eb80 \
      -s .data 0xffffffff8832c7c0 \
      -s .exit.text 0xffffffff8832a8a0 \
      -s .gnu.linkonce.this_module 0xffffffff8832c900 \
      -s .init.text 0xffffffff880c5000 \
      -s .note.gnu.build-id 0xffffffff8832a9dc \
      -s .rodata 0xffffffff8832aa00 \
      -s .rodata.str1.1 0xffffffff8832aae9 \
      -s .smp_locks 0xffffffff8832b4e8 \
      -s .strtab 0xffffffff8832c1a8 \
      -s .symtab 0xffffffff8832b590 \
      -s __param 0xffffffff8832b540

Then I ran:
gdb myModule.ko
and
add-symbol-file 0xffffffff88329000 \
      -s .bss 0xffffffff8832eb80 \
      -s .data 0xffffffff8832c7c0 \
and it was ok.


from the gdb prompt,
(gdb) print   myModule_ioctl
gives:
$10 = {int (struct inode *, struct file *, unsigned int,
   long unsigned int)} 0x9c7 <myModule_ioctl>

Now what should I do in order to know which line of code is:
myModule_ioctl+0x4b1/0x864?

Regards,
Ian

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


You could also use kgdb - kernel debugger (http://kgdb.linsyssoft.com/)
"print myModule_ioctl" would simply give you the signature of this function, instead you perhaps want to use "disassemble myModule_ioctl"


Thanks
Preeti

 


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux