0
votes

I am debugging linux kernel using two virtual machines connected via serial port.

Target machine awaits connection from remote gdb, by inserting kgdbwait() and kgdboc=ttyS0,115200 in the correct entry in /boot/grub/grub.cfg.

In Host machine

sudo gdb ./vmlinux

Symbols are read and I am supposed to be able to put breakpoints on function names.

(gdb) break oom_kill_process
Breakpoint 1 at 0xc1172ef0: file mm/oom_kill.c, line 843.

Works fine!

However, if I set a breakpoint at htb_dequeue_tree which is found here, I get the following error:

(gdb) break htb_dequeue_tree

No symbol "htb_dequeue_tree" in current context.

2
this function may be inlined. Try to set a break on a concrete address (b *0x12345678)Alex Hoppus
@AlexHoppus I tried break net/sched/sch_htb.c:htb_dequeue_tree and it didn't work. When I did this for mm/oom_kill.c:oom_kill_process it succeeded so for some reason sch_htb.c is not recognized? anyway, thanks for your comment, but how do I find that address of the function?Tony Tannous
use objdump vmlinux . I didn't get how what you are saying refutes my assumption about inlined function.Alex Hoppus
@AlexHoppus didn't mean to refute your suggestion, I wanted to add that sch_htb.c is not found. I am getting No source file named net/sched/sch_htb.cTony Tannous
if you can rebuild the kernel use attribute__((optimize("O0"))) and __attribute ((noinline))Alex Hoppus

2 Answers

0
votes

The most typical cause is the function getting inlined - then there is no symbol to begin with. Quite often you can put a break on a file+line pair (e.g. foo.c:42).

In your particular case the function is static and has only one user: htp_dequeue. If you disassemble it you will probably see the code from htp_dequeue_tree slurped in. If not, there is some other breakage going on(does breaking on other functions work?)

0
votes

The problem was that HTB is a built-in module which is dynamically inserted, hence when making, it is not included in the vmlinux file which contains the symbols.

To fix this, it has to be changed to an internal part and not a module, and this can be done in menuconfig

Just run

make menuconfig

Find the module, and change it from <m> to <*>

Remake your kernel, install modules and install, this should result in a new vmlinux which will contain the symbols of the desired module so you will be able to breakpoint at any line\function name.