无法使gdb在Qemu下运行的Linux内核中的断点处停止>

问题描述 投票:0回答:1
已经编译了Linux 5.5.5内核,并通过make menuconfig添加了选项CONFIG_GDB_SCRIPTS并关闭了选项CONFIG_DEBUG_INFO_REDUCED。运行的qemu

qemu-system-x86_64 \ -kernel arch/x86/boot/bzImage \ -append "root=/dev/sda1" \ -device virtio-scsi-pci,id=scsi0 \ -drive file=../../zso2020_cow.qcow2,if=none,id=drive0 \ -device scsi-hd,bus=scsi0.0,drive=drive0 \ -enable-kvm \ -smp 1 \ -net nic,model=virtio -net user \ -net user,hostfwd=tcp::2222-:22 \ -m 1G -balloon virtio \ -fsdev local,id=hshare,path=$(pwd),security_model=none -device virtio-9p-pci,fsdev=hshare,mount_tag=hshare \ -chardev stdio,id=cons,signal=off -device virtio-serial-pci -device virtconsole,chardev=cons \ -soundhw hda \ -usb -device usb-mouse \ -gdb tcp::23308 \ -display none \ -S

Qemu使用编译的内核运行,这是我在源代码中使用kprint检查过的内容。然后我就跑了

gdb \ -ex "add-auto-load-safe-path $(pwd)" \ -ex "file vmlinux" \ -ex 'target remote localhost:23308' \ -ex 'break start_kernel' \ -ex 'continue'

(两个脚本都从具有编译内核的目录运行)

Qemu进入用户登录,并且gdb输出(等待断点)

GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git Copyright (C) 2018 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 "x86_64-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. Remote debugging using localhost:23308 0x000000000000fff0 in exception_stacks () Breakpoint 1 at 0xffffffff8271db30: file init/main.c, line 577. Continuing.

我也尝试过

  • [hbr插入br

  • 首先target remote :23308 i并设置断点,然后设置file vmlinux
  • 转到已编译的内核目录并从qemu级别安装内核
  • 在每种情况下,gdb都不会在断点处停止。

如何使用gdb正确连接到内核,在哪里查找错误?

已经编译了Linux 5.5.5内核,并通过make menuconfig添加了选项CONFIG_GDB_SCRIPTS并关闭了选项CONFIG_DEBUG_INFO_REDUCED。运行qemu qemu-system-x86_64 \ -kernel arch / x86 / boot / ...

linux-kernel gdb kernel breakpoints qemu
1个回答
0
投票
解决该问题的方法是添加nokaslr选项并使用hbreak。那意味着替换
© www.soinside.com 2019 - 2024. All rights reserved.