1

两台虚拟机(我们称之为开发和测试)Ubuntu 17.10。我在两个内核 4.15 上都安装了以下设置:

CONFIG_DEBUG_INFO=y
CONFIG_HAVE_ARCH_KGDB=y                                                                                               
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y

在 /boot 目录中的两台机器上,我都有这些新文件:

$ ll /boot/*4.15*
-rw-r--r-- 1 root root    213741 gen 30 21:36 /boot/config-4.15.0
-rw-r--r-- 1 root root 527443588 gen 30 21:37 /boot/initrd.img-4.15.0
-rw-r--r-- 1 root root   3956360 gen 30 21:36 /boot/System.map-4.15.0
-rw-r--r-- 1 root root   7989008 gen 30 21:36 /boot/vmlinuz-4.15.0

在测试机器上,我以这种方式修改了 grub.cfg:

linux   /boot/vmlinuz-4.15.0 root=UUID=2f89c974-19ab-4b5f-96cc871c8aded5b ro  quiet splash $vt_handoff kgdbwait kgdboc=ttyS0,115200

我启动测试机,它停止进入 kdb

在此处输入图像描述

我启动开发机器并运行 gdb(版本 8.0.1)

# gdb /usr/src/linux-4.15/vmlinux
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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-pc-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 /usr/src/linux-4.15/vmlinux...done.
(gdb) target remote /dev/ttyS0
Remote debugging using /dev/ttyS0
0xffffffffb9f4ae04 in ?? ()
(gdb) continue 
Continuing.

关于“测试”

# echo g > /proc/sysrq-trigger

正如预期的那样,我得到了关于开发的 SIGTRAP。最后,当我应该开始享受设置断点的时候,灾难发生了

Thread 62 received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 1698]
0xffffffffb9f4ae04 in ?? ()
(gdb) break oom_kill_process
Breakpoint 1 at 0xffffffff811cc0e0: file mm/oom_kill.c, line 837.
(gdb) continue 
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0xffffffff811cc0e0

Command aborted.
(gdb) 

我究竟做错了什么?

4

1 回答 1

0

添加rodata=off nokaslr到内核命令行。这应该可以解决这个问题。

于 2018-03-08T01:10:00.283 回答