gpt4 book ai didi

linux - gdb远程内核调试添加bug

转载 作者:太空宇宙 更新时间:2023-11-04 12:05:41 25 4
gpt4 key购买 nike

我正在使用两个虚拟机(主机和目标)调试 linux-kernel。通过串口连接/dev/ttyS0 .


HOST
命令行以--> <--高亮显示

--> root@tony-VirtualBox:~/linux# gdb ./vmlinux <--

GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vmlinux...done.

--> (gdb) target remote /dev/ttyS0 <--

Remote debugging using /dev/ttyS0
0xc1119026 in free_rp_inst (rp=<optimized out>)
at kernel/kprobes.c:1248
1248 kfree(ri);
(gdb) break htb_dequeue_tree
Breakpoint 1 at 0xc17165a9: file net/sched/sch_htb.c, line 850.
(gdb) continue
continuing.

从这一点开始,我连接到目标机器,我在感兴趣的点插入断点,然后 continue启动它的目标机器。当我到达该断点时,控制将返回(HTB 是一个帮助控制给定链接上出站带宽使用的模块)。


目标

使用 iperf测试 linux htb

tc qdisc add dev eno2 root handle 1: htb 
tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps
tc class add dev eno2 parent 1:1 classid 1:10 htb rate 30kbps ceil 100kbps
tc class add dev eno2 parent 1:1 classid 1:20 htb rate 10kbps ceil 100kbps
tc filter add dev eno2 protocol ip parent 1:0 prio 1 u32 match ip dport 80 0xffff flowid 1:10
tc filter add dev eno2 protocol ip parent 1:0 prio 1 u32 match ip dport 25 0xffff flowid 1:20

问题

当我启动服务器并连接到它时,为了到达该断点,我收到了 SIGILL在达到该断点之前。没有 Debug模式,它可以完美运行。而且我能够测试 HTB 并得到我期望的结果(按照我的预期方式调整流量)。

[New Thread -2]

Program received signal SIGILL, Illegal instruction.
[Switching to Thread -2]
0xc17165a8 in ffz (word=3889660160)
at ./arch/x86/include/asm/bitops.h:381
381 : "r" (~word));

(gdb)

它可能是什么?这里是ffz已定义,它不应该崩溃......我很困惑。

最佳答案

尝试添加 rodata=off 和 nokaslr 内核引导参数。

这里是添加内核启动参数的方法: https://askubuntu.com/questions/19486/how-do-i-add-a-kernel-boot-parameter

关于linux - gdb远程内核调试添加bug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50811961/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com