All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] Resend: how to debug module on UML kernel 2.6.15.6 + SKAS mode?
@ 2006-03-24  3:25 Mikado
  2006-03-24  4:37 ` D. Bahi
  2006-03-24 14:44 ` Blaisorblade
  0 siblings, 2 replies; 5+ messages in thread
From: Mikado @ 2006-03-24  3:25 UTC (permalink / raw)
  To: user-mode-linux-user, user-mode-linux-devel

-----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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [uml-devel] Resend: how to debug module on UML kernel 2.6.15.6 +  SKAS mode?
  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
  2006-03-24 14:44 ` Blaisorblade
  1 sibling, 0 replies; 5+ messages in thread
From: D. Bahi @ 2006-03-24  4:37 UTC (permalink / raw)
  To: mikado4vn; +Cc: user-mode-linux-user, user-mode-linux-devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [uml-devel] Resend: how to debug module on UML kernel 2.6.15.6 + SKAS mode?
  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
@ 2006-03-24 14:44 ` Blaisorblade
  2006-03-25 16:01   ` Mikado
  1 sibling, 1 reply; 5+ messages in thread
From: Blaisorblade @ 2006-03-24 14:44 UTC (permalink / raw)
  To: user-mode-linux-devel, mikado4vn; +Cc: user-mode-linux-user

On Friday 24 March 2006 04:25, 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?

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.

> - 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.
-- 
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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [uml-devel] Resend: how to debug module on UML kernel 2.6.15.6 + SKAS mode?
  2006-03-24 14:44 ` Blaisorblade
@ 2006-03-25 16:01   ` Mikado
  2006-03-26 17:52     ` Blaisorblade
  0 siblings, 1 reply; 5+ messages in thread
From: Mikado @ 2006-03-25 16:01 UTC (permalink / raw)
  To: Blaisorblade, D.Bahi; +Cc: user-mode-linux-user, user-mode-linux-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thank D. Bahi and Blaisorblade for your replies.

Blaisorblade wrote:
> On Friday 24 March 2006 04:25, Mikado wrote:
>> - 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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [uml-devel] Resend: how to debug module on UML kernel 2.6.15.6 + SKAS mode?
  2006-03-25 16:01   ` Mikado
@ 2006-03-26 17:52     ` Blaisorblade
  0 siblings, 0 replies; 5+ messages in thread
From: Blaisorblade @ 2006-03-26 17:52 UTC (permalink / raw)
  To: mikado4vn; +Cc: D.Bahi, user-mode-linux-user, user-mode-linux-devel

On Saturday 25 March 2006 17:01, Mikado wrote:
> Thank D. Bahi and Blaisorblade for your replies.

> Blaisorblade wrote:
> > On Friday 24 March 2006 04:25, Mikado wrote:

> > 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.
-- 
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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-03-26 19:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2006-03-24 14:44 ` Blaisorblade
2006-03-25 16:01   ` Mikado
2006-03-26 17:52     ` Blaisorblade

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.