From: "D. Bahi" <dbahi@enterasys.com>
To: mikado4vn@gmail.com
Cc: user-mode-linux-user@lists.sourceforge.net,
user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] Resend: how to debug module on UML kernel 2.6.15.6 + SKAS mode?
Date: Thu, 23 Mar 2006 23:37:42 -0500 [thread overview]
Message-ID: <44237796.5080803@enterasys.com> (raw)
In-Reply-To: <442366BA.3080902@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2383 bytes --]
i think everytime you load it and unload it you may get different addresses
so you want a few more things in the [Host](gdb) section before loading
a module these stepd should allow you to debug a module_init routine
1) from http://kgdb.linsyssoft.com/downloads/miscmacros
we get an idea how to address modules from within gdb
#Miscellaneous macros
define lsmod
set $mod = (struct module*)module_list
# the last module is the kernel, ignore it
while $mod != &kernel_module
printf "%p\t%s\n", (long)$mod, ($mod)->name
set $mod = $mod->next
end
end
2) you need a break point in module.c (sys_init_module) where we have
the mod pointer in hand and are about to call init. like here in 2.4.26
/* Initialize the module. */
atomic_set(&mod->uc.usecount,1);
mod->flags |= MOD_INITIALIZING;
if (mod->init && (error = mod->init()) != 0) {
3) so when you set this break point you want to do something like this:
(gdb)break module.c:553
# note the breakpoint number xx
(gdb)commands xx
printf "add-symbol-file %s\t%p\n", ($mod)->name, (long)$mod +
$mod->size_of_struct
end
Note the extra size_of_struct to point to the correct area.
Cut-and-Paste the resulting line into your gdb window.
Assuming the path to your module is in the gdb session 'dir' path
(if not you can point it to using a path to the .o)
your symbols should load and you should be able to step into
mod->init() with code you can read.
db
Mikado wrote:
>
> - How can I debug loadable modules at run time?
>
> Here is my way:
>
> ( /tmp/mymodule.ko exists on both [Host] and [UML] )
> + [Host] # gdb linux
> + [Host] (gdb) ...
> + [Host] (gdb) r <params>
> + [UML] # insmod /tmp/mymodule.ko
> + [UML] # cat /sys/module/mymodule/sections/{.text,.bss,.data}
> + [Host] (gdb) add-symbol-file /tmp/mymodule.ko <.text_addr> -s .bss
> <.bss_addr> -s .data <.data_addr>
> + ...
>
> Tell me if I was wrong, thanks!
>
> - How can I set breakpoint at module's init function?
>
> After add module's symbol, I set breakpoint at init function then
> 'rmmod' then re-'insmod' but gdb didn't break at init function. What was
> wrong?
>
> - Sometimes gdb can't follow source codes in '.h' header files. Did I
> miss something?
>
> Thanks in advance,
> Mikado.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 187 bytes --]
next prev parent reply other threads:[~2006-03-24 4:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-24 3:25 [uml-devel] Resend: how to debug module on UML kernel 2.6.15.6 + SKAS mode? Mikado
2006-03-24 4:37 ` D. Bahi [this message]
2006-03-24 14:44 ` Blaisorblade
2006-03-25 16:01 ` Mikado
2006-03-26 17:52 ` Blaisorblade
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44237796.5080803@enterasys.com \
--to=dbahi@enterasys.com \
--cc=mikado4vn@gmail.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
--cc=user-mode-linux-user@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox