This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to correctly load debug symbol?



Hi to all!
    
I try to debug my simple kernel module via jtag, but I've insuperable problem.
I set breakpoint into function int "__init_or_module do_one_initcall(initcall_t fn)"(/linux/init/main.c file) at line "ret = fn();".
This is place where I am supposed to get into "module_init" function of my module.
But due to some reasons, when I add symbol of my *.ko  I get into "module_exit" function!
Please could somebody explain me what I'm doing wrong here?

Below is my screenshots:

  • Hi,

    How exactly do you know the breakpoint you set is exactly inside your module? In other words, how did you find out the exact address to set your breakpoint?

    The reason of my question is that the base address of a module changes every time it is started, but you can't figure out its address before it returns. One idea is to add a while(1) loop (or another delay mechanism) inside the module to allow you to find out its start address, load the symbols and break down the process.

    You can find a module base address after started by issuing grep '<mod_name>' /proc/modules

    The details above do not cover other possible sources of symbol disconnect such as compiler optimization, which sometimes make the debugger confused as it suppresses code it deems unnecessary.

    Regards,
    Rafael