gpt4 book ai didi

linux - 使用/proc/kcore 调试内核

转载 作者:太空宇宙 更新时间:2023-11-04 11:57:48 31 4
gpt4 key购买 nike

我正在学习使用/proc/kcore 调试内核

我构建了最新的稳定 4.19 Linux 版本并将其安装在我的虚拟机上。

然后我 cd 进入我的 linux 源代码编译的文件夹并运行以下命令。

sudo gdb vmlinux /proc/kcore

它给了我以下错误

Core was generated by `BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893'.
#0 0x0000000000000000 in irq_stack_union ()
warning: File "/home/jamal/linux/linux-4.19.6/scripts/gdb/vmlinux-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /home/jamal/linux/linux-4.19.6/scripts/gdb/vmlinux-gdb.py
line to your configuration file "/home/jamal/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/jamal/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"

所以,我添加了

$ cat /home/jamal/.gdbinit 
add-auto-load-safe-path /home/jamal/linux/linux-4.19.6/scripts/gdb/vmlinux-gdb.py

然后,当我尝试刷新 kcore 文件并打印“jiffies”值时,它一次又一次地打印相同的值。我在这里犯了什么错误。

Reading symbols from vmlinux...done.
[New process 1]
Core was generated by `BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893'.
#0 0x0000000000000000 in irq_stack_union ()
(gdb) print jiffies
$1 = 4294892296
(gdb) core-file /proc/kcore
[New process 1]
Core was generated by `BOOT_IMAGE=/boot/vmlinuz-4.19.6 root=UUID=c17d5f82-e020-4ded-a082-89fd7e54d893'.
#0 0x0000000000000000 in irq_stack_union ()
(gdb) print jiffies
$2 = 4294892296
(gdb)
$3 = 4294892296
(gdb) q

最佳答案

您应该在 .gdbinit 中设置以下内容:

set auto-load safe-path /

然后source或者重启你的机器使之生效。

关于linux - 使用/proc/kcore 调试内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53623870/

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