基于 qemu 的低级调试 [英] Low level qemu based debugging

查看:20
本文介绍了基于 qemu 的低级调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在 ARM 架构上测试一些低级代码.通常在实际电路板上进行实验非常复杂,所以我在考虑 QEMU.

I've to test some low level code on an ARM architecture. Typically experimentation is quite complicated on the real board, so I was thinking about QEMU.

我想获得一些调试信息,例如 printfs 或 gdb.我知道这对 linux 很简单,因为它实现了 QEMU Integrator 的设备驱动程序和 gdb 功能,但我没有使用 Linux.另外我怀疑从 Linux 内核源代码中提取这种功能会很复杂.

What I'd like to get is some kind of debugging information like printfs or gdb. I know that this is simple with linux since it implements both the device driver for the QEMU Integrator and the gdb feature, but I'm not working with Linux. Also I suspect that extracting this kind of functionality from the Linux kernel source code would be complicated.

我正在从一些已经实现其中一项功能的简单操作系统中进行搜索.你有什么建议吗?

I'm searching from some simple operating system that already implements one of those features. Do you have some advice?

推荐答案

您不需要目标操作系统来调试在 QEMU 中运行的代码——QEMU 已经为您做到了.

You don't need a target OS to debug code that's running inside QEMU -- QEMU already does that for you.

具体来说,QEMU 支持从 GDB 进行远程调试——您可以使用适当的命令行选项运行 QEMU,它将导出一个 GDB 副本(在主机上运行)可以连接到的接口.此时,您可以在 GDB 中调试程序,就像在主机上运行它一样.

Specifically, QEMU supports remote debugging from GDB -- you can run QEMU with the appropriate command-line options and it will export an interface that a copy of GDB (running on the host machine) can connect to. At that point, you can debug the program in GDB pretty much just as if you were running it on the host machine.

http://wiki.osdev.org/GDB 似乎有更多的基本信息;可能不足以让你完全入门,但至少给你基本的想法和一些在 QEMU 和 GDB 文档中寻找的术语.跳过关于实现 GDB 存根"的部分,这里不适用,因为 QEMU 已经有了,从使用仿真器存根"部分开始.简而言之,您使用 -s 选项(在 localhost:1234 上导出 GDB 连接)和 -S 选项(等待 GDB 继续"启动 QEMU" 开始执行之前的命令),然后在主机上的 GDB 中说 target remote :1234 而不是 run.此外,当然,您需要使用 GDB 的 ARM 版本,而不是原生 x86 版本.

http://wiki.osdev.org/GDB appears to have a bit more basic information; possibly not enough to completely get you started, but at least give you the basic idea and some terms to look for in the QEMU and GDB documentation. Skip over the bit about "Implementing GDB Stubs", which doesn't apply here since QEMU has one already, and start at the section on "Using Emulator Stubs". The short form is simply that you start QEMU with the -s option (export a GDB connection on localhost:1234) and the -S option (wait for a GDB "continue" command before starting execution), and then in GDB on your host you say target remote :1234 instead of run. Also, of course, you need to be using an ARM version of GDB rather than a native-x86 one.

(此外,如果您愿意为商业解决方案付费,CodeSourcery 的 ARM 工具链具有 IDE 集成,可以自动设置所有这些,包括支持printf"打印到调试器控制台.这适用于如果您有硬件调试器,也可以使用物理板.关于我是 CodeSourcery 员工的通常免责声明适用——但我确实发现它非常易于使用.)

(In addition, if you're willing to pay for a commercial solution, CodeSourcery's ARM toolchain has the IDE integration to set all of this up automatically, including support for "printf" to print into the debugger console. That works on a physical board, too, if you've got a hardware debugger. Usual disclaimer about me being a CodeSourcery employee applies -- but I do find it very easy to use.)

2012 年更新: CodeSourcery 的工具链现在称为 Mentor Graphics Sourcery CodeBench,但以上所有内容仍然适用.

Update, 2012: CodeSourcery's toolchain is now called Mentor Graphics Sourcery CodeBench, but all the above still applies.

这篇关于基于 qemu 的低级调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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