LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Problem Debugging Kernel Module with KGDB (https://www.linuxquestions.org/questions/linux-software-2/problem-debugging-kernel-module-with-kgdb-752688/)

raycope14 09-04-2009 11:29 AM

Problem Debugging Kernel Module with KGDB
 
Dear LinuxQuestioners, I am having a problem debugging a kernel
loadable module (i.e., after insmod'ing a .ko module) using KGDB.

I have spent some time on the setup process just to make sure I have everything right to the best of my knowledge, but here is what I have come down to (close but no cigar yet):

1. Established kgdb session over serial link and successfully able to
break and single step on EMBEDDED routine (e.g., ./kernel/module.c).

2. Start up my target kernel under kgdb host control and able to
insmod the target module and added symbols using add-symbol-file
with target module object (.o) file OK. Note I got .text/.data/
.bss offsets from /sys/module/<target module>/sections as per
standard setup.

3. Used objdump -S -x <target module>.o command to verify target module
was compiled with debug symbols. Seems OK, meaning I see routine
names and source C-code information displayed.

4. Able to break on target module routine name OK. However, when I try
the gdb 'n' or 'list' commands, it says it has **no line number
information**. 'n' acts like 'cont' meanings it just runs through
the whole routine without stopping. 'stepi' works fine in dis-
asembly mode, so for temp workaround I am using stepi combined
with objdump information to debug but NEED FULLY SYMBOLIC SOURCE
CODE DEBUG facility to be really effective.

Any ideas, suggestions what might be wrong? Note I have spent a lot of
time on this and have tried all the basics including running from my native build machine as the kgdb host vs. tarring/un-tarring source code on host machine. Re:linux config, I have the following settings:

CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_PROC_KCORE=y
CONFIG_DEBUG_INFO=y

Any other config settings I might be missing to debug KLM's down-loadable modules)? Module was gcc compiled with -g and -O0 switch settings.

Thanks in advance for all replies.

David1357 09-04-2009 12:38 PM

Quote:

Originally Posted by raycope14 (Post 3669839)
Any ideas, suggestions what might be wrong?

Someone else had the same problem: kgdb module debugging question

raycope14 09-08-2009 11:46 AM

Thanks, that was a good post but not really the same problem. I have
no problem setting breakpoints and geting control back to gdb. My problem is I don't get any source code information after I insmod my .ko module and then do "add-symbol-file" as per standard procedure. I don't think it's necessary but I also tried the solib-search-path command directly on my source file, but that didn't do any good.

What's very strange to me is I can ***break on a routine name in my module but after I hit the breakpoint I can't single-step or list source file***. That's the problem I need to solve.


All times are GMT -5. The time now is 12:18 AM.