远程 gdb 调试不会在断点处停止 [英] Remote gdb debugging does not stop at breakpoints

查看:90
本文介绍了远程 gdb 调试不会在断点处停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调试修改后的 Linux-3.11.0 内核时遇到问题.为了调试代码,我使用:

I'm having problems with debugging my modified Linux-3.11.0 kernel. For debugging the code, I use:

  1. GDB 7.6
  2. QEMU 1.6.5
  3. Linux 内核 3.11.0

我的系统有 Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz,运行 Ubuntu 12.10

My system has Intel(R) Core(TM) i7-2760QM CPU @ 2.40GHz running Ubuntu 12.10

我使用make menuconfig"创建的配置文件编译了修改后的内核.(在内核黑客"类别中进行了修改)

I compiled the modified kernel with a configuration file that I created using 'make menuconfig'. (with modifications in the "kernel hacking" category)

这里引用了一些 .config 文件行(我认为相关):

Some of the .config file lines (that I find relevant) are quoted here:

CONFIG_DEBUG_INFO=y 
CONFIG_DEBUG_KERNEL=y
CONFIG_MAGIC_SYSRQ=y
CONFIG_DEBUG_FS=y
CONFIG_HAVE_HW_BREAKPOINT=y
CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y

我使用带有-S"选项的 qemu 来引导我的内核,并使用 gdb 连接到 qemu 并恢复它的执行:

I use qemu with the "-S" option to boot my kernel, and using gdb I connect to qemu and resume it's execution:

(gdb) target remote :1234
(gdb) continue

设置断点时,例如:break schedule 我收到一条确认消息,例如:

When setting breakpoints, for an example: break schedule I get a confirmation message such as:

Breakpoint 1 at 0xffffffff81736400: file kernel/sched/core.c, line 2509.

所以到这里为止一切都很好!

So till here everything seems fine!

问题是 gdb 和 qemu 并没有在断点处停止!他们都只是继续运行......

The problem is that gdb and qemu does not stop at the breakpoints! They both simply continue running...

我尝试按照某些地方的建议设置硬件断点,但收到以下消息:

I tried to set hardware breakpoints as suggested in some places, but I get the message:

No hardware breakpoint support in the target.

这很奇怪,因为我设置了 CONFIG_HAVE_HW_BREAKPOINT.

which is weird because I have the CONFIG_HAVE_HW_BREAKPOINT set.

我也按照其他地方的建议取消了 CONFIG_DEBUG_RODATA,但仍然没有结果...

I also unset CONFIG_DEBUG_RODATA as suggested in other places,but still no results...

我尝试按照此处的建议处理 .config 文件:qemu 中的 gdbserver 不会在断点处停止 但我无法弄清楚工作 .config 文件和我的 .config 文件之间的相关差异...(差异太大!)

I tried to mess around with the .config file as suggested here: gdbserver inside qemu does not stop on breakpoints but I couldn't figure out the relevant differences between the working .config file and my .config file... (There are too much differences!)

谁能帮帮我?

谢谢你!!

推荐答案

好的,我发现了问题,所以我在这里为其他人发帖:显然这是一个非常微妙的过程......我的配置文件很好.我需要做的只是在我连接到 qemu 之后才定义断点,而不是在加载 vmlinux 之后.这些断点必须是硬件断点...否则它们不会中断!

OK, I found the problem so I'm posting here for other people: Apparently this is a very delicate procedure... My config file was fine. All I needed to do is to define the breakpoints only after I connect to qemu, and not after loading the vmlinux. These breakpoints have to be HARDWARE breakpoints... otherwise they don't break!

这篇关于远程 gdb 调试不会在断点处停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆