Search code examples
clinuxdebugginglinux-kernelkgdb

Not able to set breakpoint on some functions in kgdb setup


I have kgdb setup using two virtual machines, both are having CentOs 6.4(actually kgdb host is clone of target). I am successfully able to connect to remote target and start debugging. I want to debug RAID driver, specifically raid456.ko. My problem is I am able to set breakpoint on few functions after loading symbols of this raid456.ko using add-symbol-file command under gdb, but I am not able to set breakpoint on few functions. For example, I can set breakpoint on ops_run_biofill function but not on ops_run_biodrain function. Both are static functions and part of raid5.c file. If I try to set breakpoint on ops_run_biodrain then it shows:

(gdb) b ops_run_biodrain

Function "ops_run_biodrain" not defined. Make breakpoint pending on future shared library load? (y or [n])

Why few function can be debugged and why some others not?

[EDIT]--------------------- I further investigated the issue and I found that using nm utility we can find name and virtual address of any symbol part of some particular object file. I tried nm on raid456.ko and found that ops_run_biofill function is in output of nm command, but ops_run_biodrain is not in the output. Does this mean ops_run_biodrain is not in raid456.ko? If yes then why it is not part of raid456.ko? ops_run_biodrain is not under any macro check.


Solution

  • Found solution of the problem. Due to compilation optimization, few symbols were not getting detected. After disabling the optimization for raid driver, KGDB could detect those symbols and able to set breakpoint on them.