Skip to contentSkip to conversation

Debug Kernel Modules With KGDB

DISCUSSION Freeman Zhang 2 participants 5 messages Dec 1, 2014

lore
Share & tools
lore
#0 lore raw

Hi list,

I've been trying to setup a debug environment for linux kernel(v3.4,Android,ARM) with kgdb. It worked fine untill I tried to use it to debug a module. Under the instruction from LDD, I add module debug info in gdb with command:

add-symbol-file test-module.ko address

LDD uses cat /sys/module/test-module/sections/.text to get the address where the module has been loaded. However, I got:

	0x00000000

When I use lsmod, I got:

	test-module 15278 0 - Live 0x00000000 (O)

Why nothing but 0x00000000 ??

So I have to do some research in kernel/module.c, and find out that struct module -> module_core = 0xbf000000. But when I try these in gdb:

	add-symbol-file test-module.ko  0xbf000000
	break one_of_my_function

I got:

	Cannot access memory at address 0xbf002350

:(
Could somebody help?

All the best!
Freeman Zhang

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141201/0c8874e6/attachment.bin

#1 lore raw
Quoted 7 lines · Freeman Zhang

Hi list,

I've been trying to setup a debug environment for linux kernel(v3.4,Android,ARM) with kgdb. It worked fine untill I tried to use it to debug a module. Under the instruction from LDD, I add module debug info in gdb with command:

Quoted 6 lines

add-symbol-file test-module.ko address

LDD uses cat /sys/module/test-module/sections/.text to get the address where the module has been loaded. However, I got:

	0x00000000

Try reading the file as a root.

$ sudo cat /sys/module/test-module/sections/.text
Quoted 30 lines

When I use lsmod, I got:

	test-module 15278 0 - Live 0x00000000 (O)

Why nothing but 0x00000000 ??

So I have to do some research in kernel/module.c, and find out that struct module -> module_core = 0xbf000000. But when I try these in gdb:

	add-symbol-file test-module.ko  0xbf000000
	break one_of_my_function

I got:

	Cannot access memory at address 0xbf002350

:(
Could somebody help?

All the best!
Freeman Zhang

Quoted 4 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------------------------------------------------------------------------------------------------------------------------
[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141201/bed63263/attachment-0001.html

#2 lore raw

Hi Raghavendra,

Thanks for your reply, but sudo doesn't solve the problem :(

All the best!

Freeman Zhang

-------- Original Message --------

Quoted 69 lines · Freeman Zhang
Quoted 7 lines

Hi list,

I've been trying to setup a debug environment for linux kernel(v3.4,Android,ARM) with kgdb. It worked fine untill I tried to use it to debug a module. Under the instruction from LDD, I add module debug info in gdb with command:

Quoted 6 lines

add-symbol-file test-module.ko address

LDD uses cat /sys/module/test-module/sections/.text to get the address where the module has been loaded. However, I got:

    0x00000000

Try reading the file as a root.

$ sudo cat /sys/module/test-module/sections/.text
Quoted 30 lines

When I use lsmod, I got:

    test-module 15278 0 - Live 0x00000000 (O)

Why nothing but 0x00000000 ??

So I have to do some research in kernel/module.c, and find out that struct module -> module_core = 0xbf000000. But when I try these in gdb:

    add-symbol-file test-module.ko  0xbf000000
    break one_of_my_function

I got:

    Cannot access memory at address 0xbf002350

:(
Could somebody help?

All the best!
Freeman Zhang

Quoted 4 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------------------------------------------------------------------------------------------------------------------------

[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------

Quoted 5 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141201/0b502f4d/attachment.bin

#3 lore raw

Hi Zhang,

Quoted 3 lines · Freeman Zhang

Hi Raghavendra,

Thanks for your reply, but sudo doesn't solve the problem :(

Well then I guess 'sudo' isn't implemented in android. Any way, ultimately you may wan't to login as root and then try reading the file in order to get the address.
Regards,
Raghavendra

Quoted 78 lines

All the best!

Freeman Zhang

-------- Original Message --------

Quoted 72 lines · Freeman Zhang
Quoted 7 lines

Hi list,

I've been trying to setup a debug environment for linux kernel(v3.4,Android,ARM) with kgdb. It worked fine untill I tried to use it to debug a module. Under the instruction from LDD, I add module debug info in gdb with command:

Quoted 6 lines

add-symbol-file test-module.ko address

LDD uses cat /sys/module/test-module/sections/.text to get the address where the module has been loaded. However, I got:

     0x00000000

Try reading the file as a root.

$ sudo cat /sys/module/test-module/sections/.text
Quoted 29 lines

When I use lsmod, I got:

     test-module 15278 0 - Live 0x00000000 (O)

Why nothing but 0x00000000 ??

So I have to do some research in kernel/module.c, and find out that struct module -> module_core = 0xbf000000. But when I try these in gdb:

     add-symbol-file test-module.ko  0xbf000000
     break one_of_my_function

I got:

     Cannot access memory at address 0xbf002350

:(
Could somebody help?

All the best!
Freeman Zhang

Quoted 4 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------------------------------------------------------------------------------------------------------------------------

[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------------------------------------------------------------------------------------------------------------------------
[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------

#4 lore raw

Hi Raghavendra,

Yes, you are right, 'sudo' isn't implemented in android. However, su enable me to read the .text as root. It's the same, 0x00000000.

So I guess something else should be wrong.

Thanks anyway!

Freeman Zhang

-------- Original Message --------

Quoted 99 lines

Hi Zhang,

Quoted 3 lines · Freeman Zhang

Hi Raghavendra,

Thanks for your reply, but sudo doesn't solve the problem :(

Well then I guess 'sudo' isn't implemented in android. Any way, ultimately you may wan't to login as root and then try reading the file in order to get the address.
Regards,
Raghavendra

Quoted 81 lines

All the best!

Freeman Zhang

-------- Original Message --------

Quoted 75 lines · Freeman Zhang
Quoted 9 lines

Hi list,

I've been trying to setup a debug environment for linux kernel(v3.4,Android,ARM) with kgdb. It worked fine untill I tried to use
it to debug a module. Under the instruction from LDD, I add module debug
info in gdb with command:

Quoted 6 lines

add-symbol-file test-module.ko address

LDD uses cat /sys/module/test-module/sections/.text to get the address
where the module has been loaded. However, I got:

          0x00000000

Try reading the file as a root.

$ sudo cat /sys/module/test-module/sections/.text
Quoted 27 lines

When I use lsmod, I got:

     test-module 15278 0 - Live 0x00000000 (O)

Why nothing but 0x00000000 ??

So I have to do some research in kernel/module.c, and find out that struct module -> module_core = 0xbf000000. But when I try these in gdb:

     add-symbol-file test-module.ko  0xbf000000
     break one_of_my_function

I got:

     Cannot access memory at address 0xbf002350

:(
Could somebody help?

All the best!
Freeman Zhang

Quoted 4 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------------------------------------------------------------------------------------------------------------------------

[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------------------------------------------------------------------------------------------------------------------------

[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA & Twitter: @cdacindia ]

Quoted 9 lines

This e-mail is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies and the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email is strictly prohibited and appropriate legal action will be taken.
-------------------------------------------------------------------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141201/be2301f2/attachment.bin