On Wed, Apr 28, 2010 at 12:07 AM, Venkatram Tummala
<[email protected]>wrote:

> On Tue, Apr 27, 2010 at 11:58 PM, Joel Fernandes <[email protected]>wrote:
>
>> Hey Venkatram,
>>
>> On Wed, Apr 28, 2010 at 11:33 AM, Venkatram Tummala <
>> [email protected]> wrote:
>>>
>>> to find these addresses by "p modules", the module has to be already
>>> loaded.....right? So, the initialization function of the module must have
>>> been  already executed....right? So, the question is how can we step through
>>> the initialization function of the module..? "p modules" won't help
>>> us..probably looking at /sys is a faster way to find module segment
>>> addresses, or am I missing something here in "p modules"??
>>>
>>>
>> Why don't you try setting breakpoints in kernel (kernel/module.c) after
>> the module has been loaded but before your modules' init function is called?
>>
>> From kernel/module.c , in SYSCALL_DEFINE3(init_module..):
>> the line load_module(...) loads your module into the kernel, and  the line
>> do_one_initcall(mod->init); calls the init functions.
>>  So I think if you set a break point in between these lines, you should be
>> able to get the address of text section etc just in time before the init
>> functions is called, using p modules or something.
>>
>
Apparently the trick didn't work for me because the vm in vmware workstation
is supposed to get freezed  when a breakpoint is encountered. So, the kernel
freezes & we only have the gdb console to play with. Once we hit continue,
the vm & hence the kernel comes back alive but again by that time, the
initialization function finishes executing.

So, i cannot look at a /sys entry to find the module section addresses while
gdb is sitting on a breakpoint. We only have the gdb console to look the
section address & nothing else while at a breakpoint. "p modules" will help
but it is too much of a work every time one tries to debug.

In Summary, the only way is to force the kernel to place the module at
exactly the same address everytime. Anybody has any ideas as to how we can
achieve this?

Thanks.
Venkatram

>
> Hey Joel,
>
> Yup, that is exactly the trick mentioned by Mulyadi in the previous post.
> Will try that & there is no reason why this won't work. This will definitely
> solve the problem.
>
> Thanks Everybody,
> Venkatram
>
>>
>> -Joel
>>
>>
>

Reply via email to