Hello all,

I got another problem while I'm trying to debug mine kernel module. Here is procedure that I perform while setting up debug session and results.

First run the UML kernel with:

   dzwiedz ~/projekty/uml_debug/linux-2.6.32.19 [3387] ./linux
   ubda=../debian_uml ubdc=../swap mem=128M con0=fd:0,fd:1 con=pts
   Locating the bottom of the address space ... 0x10000
   [....kernel is booting....]
   Last login: Wed Sep  1 10:55:00 UTC 2010 on tty0
   Linux uml 2.6.32.19 #3 Thu Aug 26 13:56:25 CEST 2010 i686

   The programs included with the Debian GNU/Linux system are free
   software;
   the exact distribution terms for each program are described in the
   individual files in /usr/share/doc/*/copyright.

   Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
   permitted by applicable law.
   uml:~#

Then run gdb and attach it to UML process:

   dzwiedz ~/projekty/uml_debug/linux-2.6.32.19 [3362] gdb ./linux
   32764     13:21
   GNU gdb (GDB) 7.1-ubuntu
   Copyright (C) 2010 Free Software Foundation, Inc.
   License GPLv3+: GNU GPL version 3 or later
   <http://gnu.org/licenses/gpl.html>
   This is free software: you are free to change and redistribute it.
   There is NO WARRANTY, to the extent permitted by law.  Type "show
   copying"
   and "show warranty" for details.
   This GDB was configured as "i486-linux-gnu".
   For bug reporting instructions, please see:
   <http://www.gnu.org/software/gdb/bugs/>...
   Reading symbols from
   /home/dzwiedz/projekty/uml_debug/linux-2.6.32.19/linux...done.
   Attaching to program:
   /home/dzwiedz/projekty/uml_debug/linux-2.6.32.19/linux, process 32764
   Reading symbols from /lib/tls/i686/cmov/libutil.so.1...(no debugging
   symbols found)...done.
   Loaded symbols for /lib/tls/i686/cmov/libutil.so.1
   Reading symbols from /lib/tls/i686/cmov/libc.so.6...(no debugging
   symbols found)...done.
   Loaded symbols for /lib/tls/i686/cmov/libc.so.6
   Reading symbols from /lib/ld-linux.so.2...(no debugging symbols
   found)...done.
   Loaded symbols for /lib/ld-linux.so.2
   Reading symbols from /lib/tls/i686/cmov/libnss_compat.so.2...(no
   debugging symbols found)...done.
   Loaded symbols for /lib/tls/i686/cmov/libnss_compat.so.2
   Reading symbols from /lib/tls/i686/cmov/libnsl.so.1...(no debugging
   symbols found)...done.
   Loaded symbols for /lib/tls/i686/cmov/libnsl.so.1
   Reading symbols from /lib/tls/i686/cmov/libnss_nis.so.2...(no
   debugging symbols found)...done.
   Loaded symbols for /lib/tls/i686/cmov/libnss_nis.so.2
   Reading symbols from /lib/tls/i686/cmov/libnss_files.so.2...(no
   debugging symbols found)...done.
   Loaded symbols for /lib/tls/i686/cmov/libnss_files.so.2
   0x00835422 in __kernel_vsyscall ()

Check existing breakpoints and then, setup handlers for signals and breakpoint at line with mod->init (kernel/module.c)

   (gdb) info break
   No breakpoints or watchpoints.
   (gdb) b module.c:2613
   No line 2613 in file "drivers/base/module.c".
   (gdb) b sys_module_init
   Function "sys_module_init" not defined.
   Make breakpoint pending on future shared library load? (y or [n]) n
   (gdb) b sys_init_module
   Breakpoint 1 at 0x80945a6: file kernel/module.c, line 2591.
   (gdb) b module.c:2613
   Breakpoint 2 at 0x809461b: file kernel/module.c, line 2613.
   (gdb) handle SIGSEGV pass noprint nostop
   Signal        Stop    Print    Pass to program    Description
   SIGSEGV       No    No    Yes        Segmentation fault
   (gdb) handle SIGUSR1 pass noprint nostop
   Signal        Stop    Print    Pass to program    Description
   SIGUSR1       No    No    Yes        User defined signal 1
   (gdb) info b
   Num     Type           Disp Enb Address    What
   1       breakpoint     keep y   0x080945a6 in sys_init_module
                                           at kernel/module.c:2591
   2       breakpoint     keep y   0x0809461b in sys_init_module
                                           at kernel/module.c:2613
   (gdb) c
   Continuing.

Then insmod my module with insmod mapper_test.ko. After reaching second breakpoint I check module list for memory address of mapper_test module as described in tutorial on UML home page. Then I set breakpoints for interesting init and cleanup function. Which are properly recognized and found by GDB with print command. But when I try to continue to reach this new breakpoints then I got errors. Below is whole listing.

   Breakpoint 1, sys_init_module (umod=0x804b018, len=50866,
        uargs=0x804b008 "\377P\211\303\350ג\001") at kernel/module.c:2591
   2591        if (!capable(CAP_SYS_MODULE) || modules_disabled)
   (gdb) c
   Continuing.

   Breakpoint 2, sys_init_module (umod=0x804b018, len=50866,
        uargs=0x804b008 "\377P\211\303\350ג\001") at kernel/module.c:2613
   2613        if (mod->init != NULL)
   (gdb) p modules
   $1 = {next = 0x1256d7f0, prev = 0x125478dc}
   (gdb) p 0x1256d7ec
   $2 = 307681260
   (gdb) p *((struct module *)0x1256d7ec)
   $3 = {state = MODULE_STATE_COMING, list = {next = 0x125478dc,
        prev = 0x8236ab0}, name = "mapper_test", '\000' <repeats 48
   times>,
      mkobj = {kobj = {name = 0x10ac26e0 "mapper_test", entry = {
            next = 0x118499a0, prev = 0x12547924}, parent = 0x118499b8,
          kset = 0x118499a0, ktype = 0x82363c8, sd = 0x11a22198, kref = {
            refcount = {counter = 3}}, state_initialized = 1,
   state_in_sysfs = 1,
          state_add_uevent_sent = 1, state_remove_uevent_sent = 0,
          uevent_suppress = 0}, mod = 0x1256d7ec, drivers_dir = 0x0, mp
   = 0x0},
      modinfo_attrs = 0x11a062e0, version = 0x0, srcversion = 0x0,
      holders_dir = 0x119abd60, syms = 0x0, crcs = 0x0, num_syms = 0,
   kp = 0x0,
      num_kp = 0, num_gpl_syms = 0, gpl_syms = 0x0, gpl_crcs = 0x0,
      unused_syms = 0x0, unused_crcs = 0x0, num_unused_syms = 0,
      num_unused_gpl_syms = 0, unused_gpl_syms = 0x0, unused_gpl_crcs =
   0x0,
      gpl_future_syms = 0x0, gpl_future_crcs = 0x0, num_gpl_future_syms
   = 0,
      num_exentries = 0, extable = 0x0, init = 0x1256d00a,
      module_init = 0x12570000, module_core = 0x1256d000, init_size =
   2322,
      core_size = 3353, init_text_size = 421, core_text_size = 1039,
      arch = {<No data fields>}, taints = 0, num_bugs = 0, bug_list = {
        next = 0x125479d0, prev = 0x823a118}, bug_table = 0x0,
      symtab = 0x125701a8, core_symtab = 0x1256da74, num_symtab = 70,
      core_num_syms = 19, strtab = 0x12570608 "", core_strtab =
   0x1256dba4 "",
      sect_attrs = 0x10ac4200, notes_attrs = 0x119abd20, percpu = 0x0,
      args = 0x10ac2880 "", modules_which_use_me = {next = 0x1256d918,
        prev = 0x1256d918}, waiter = 0x11874060, exit = 0x1256d000, ref
   = {a = {
          counter = 1}}}
   (gdb) add-symbol-file /home/dzwiedz/projekty/BIS/mapper_test.ko
   0x1256d000
   add symbol table from file
   "/home/dzwiedz/projekty/BIS/mapper_test.ko" at
        .text_addr = 0x1256d000
   (y or n) y
   Reading symbols from /home/dzwiedz/projekty/BIS/mapper_test.ko...done.
   (gdb) p nf_mapper_init
   $7 = {int (void)} 0x274 <nf_mapper_init>
   (gdb) p nf_mapper_cleanup
   $8 = {void (void)} 0xa9 <nf_mapper_cleanup>
   (gdb) b nf_mapper_init
   Breakpoint 3 at 0x274: file
   /home/dzwiedz/projekty/BIS/nf_bis_mapper.c, line 48.
   (gdb) b nf_mapper_cleanup
   Breakpoint 4 at 0xa9: file
   /home/dzwiedz/projekty/BIS/nf_bis_mapper.c, line 75.
   (gdb) s
   Warning:
   Cannot insert breakpoint 4.
   Error accessing memory address 0xa9: Input/output error.
   Cannot insert breakpoint 3.
   Error accessing memory address 0x274: Input/output error.

   hard_handler (sig=29) at arch/um/os-Linux/sys-i386/signal.c:11
   11    {
   (gdb)

What am I doing wrong? As anybody could help to make this config working? :)

regards,
--
Paweł R.
<pawel.ru...@wp.pl>
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to