Resend: how to debug module on UML kernel 2.6.15.6 + SKAS mode?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
- - 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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEI2a6NWc9T2Wr2JcRAiHtAJ0eenkXD5OpYyh6NgIalIqjYleU+ACfWn3i ivKO51h+ATarQaxt+VNhhxs=
=cvsa
-----END PGP SIGNATURE-----
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
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
endend
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
Quoted 28 lines · Mikado
- How can I debug loadable modules at run time?
Here is my way:
(
/tmp/mymodule.koexists 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.
Quoted 14 lines · Mikado
- How can I debug loadable modules at run time?
Here is my way:
(
/tmp/mymodule.koexists 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>
+ ...
Quoted 7 lines
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?
gdb modifies the program code to set breakpoints, but the code is reloaded on module reload.
So, break on the caller of the module init function, and step from there. Maybe Bahi's mail refers to 2.4, I'm not sure, but the concepts are the same.
Most module-related code is in kernel/module.c, as for instance static LIST_HEAD(modules);
which is the new name for module_list.
Quoted 2 lines
- Sometimes gdb can't follow source codes in '.h' header files. Did I miss something?
What happens? Maybe gdb is stepping there but the calls are inlined and it's not apparent that it's looking at source code. However I've not clear what you describe, anyway.
Signature · 22 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894) http://www.user-mode-linux.org/~blaisorblade ___________________________________ Yahoo! Messenger with Voice: chiama da PC a telefono a tariffe esclusive http://it.messenger.yahoo.com ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thank D. Bahi and Blaisorblade for your replies.
Quoted 7 lines · Blaisorblade
Quoted 2 lines · Mikado
- Sometimes gdb can't follow source codes in '.h' header files. Did I miss something?
What happens? Maybe gdb is stepping there but the calls are inlined and it's not apparent that it's looking at source code. However I've not clear what you describe, anyway.
Sometimes gdb can't access macros included in header files and it dumped "some_header.h: No such file or directory". Those macros can contain function calls so that I cannot trace that calls. Got any ideas?
Cheers,
Mikado.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEJWl2NWc9T2Wr2JcRAib5AJ0TNyrDrXzhiu+l6scUBokqOJ03ggCgp0+3 bMnAeWM3wMQPfFgHB3vJRp8=
=SLX8
-----END PGP SIGNATURE-----
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Quoted 5 lines · Mikado
Thank D. Bahi and Blaisorblade for your replies.
Quoted 1 line · Blaisorblade
On Friday 24 March 2006 04:25, Mikado wrote:
Quoted 7 lines
Quoted 3 lines
What happens? Maybe gdb is stepping there but the calls are inlined and it's not apparent that it's looking at source code. However I've not clear what you describe, anyway.
Sometimes gdb can't access macros included in header files and it dumped "
some_header.h: No such file or directory". Those macros can contain function calls so that I cannot trace that calls. Got any ideas?
I remember this happens, but I usually ignore it so I don't know which is the case.
If you post the header name I'll now better.
Anyway, I'm not sure, but maybe it happens for system headers, maybe it happens for headers located in strange place and in this case, you can likely modify the source-path (where gdb looks for files) and add more header folders, after finding where the header is in the source tree.
Signature · 22 lines
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!". Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894) http://www.user-mode-linux.org/~blaisorblade ___________________________________ Yahoo! Messenger with Voice: chiama da PC a telefono a tariffe esclusive http://it.messenger.yahoo.com ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel