简体   繁体   English

GDB:linux内置模块中的断点失败

[英]GDB: breakpoint in linux built-in module fails

I am debugging linux kernel using two virtual machines connected via serial port. 我正在使用通过串行端口连接的两个虚拟机调试linux内核。

Target machine awaits connection from remote gdb, by inserting kgdbwait() and kgdboc=ttyS0,115200 in the correct entry in /boot/grub/grub.cfg . 通过在/boot/grub/grub.cfg的正确条目中插入kgdbwait()kgdboc=ttyS0,115200目标计算机将等待来自远程gdb的连接。

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: 但是,如果我在htb_dequeue_tree处设置了一个断点,则在找到以下错误:

(gdb) break htb_dequeue_tree

No symbol "htb_dequeue_tree" in current context. 当前上下文中没有符号“ htb_dequeue_tree”。

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 (eg foo.c:42). 通常,您可以在文件+行对上暂停一下(例如foo.c:42)。

In your particular case the function is static and has only one user: htp_dequeue. 在您的特定情况下,该函数是静态的,并且只有一个用户: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?) 如果您将其反汇编,则可能会看到htp_dequeue_tree中的代码被拖入其中。如果没有,则发生了其他一些破坏(破坏其他功能是否起作用?)

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. 问题在于, HTB是动态插入的内置模块,因此在制作时,它不包含在包含符号的vmlinux文件中。

To fix this, it has to be changed to an internal part and not a module, and this can be done in menuconfig 要解决此问题,必须将其更改为内部部件而不是模块,这可以在menuconfig完成

Just run 赶紧跑

make menuconfig

Find the module, and change it from <m> to <*> 查找模块,并将其从<m>更改为<*>

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. 重新制作内核,安装模块并安装,这将导致一个新的vmlinux ,其中将包含所需模块的符号,因此您可以在任何行\\函数名称处断点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM