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

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

问题描述

我必须在ARM架构上测试一些低级代码。通常实验在实际上是相当复杂的,所以我正在考虑QEMU。



我想要得到的是某种调试信息,如printfs或gdb。我知道这很简单,因为它实现了QEMU Integrator和gdb功能的设备驱动程序,但是我不使用Linux。另外我怀疑从Linux内核源代码中提取这种功能会很复杂。



我正在搜索一些简单的操作系统已经实现了这些功能之一。你有什么建议吗?

解决方案

您不需要目标操作系统来调试在QEMU内运行的代码 - QEMU已经



具体来说,QEMU支持从GDB进行远程调试 - 您可以使用相应的命令行选项运行QEMU,并将导出一个副本的GDB(在主机上运行)可以连接到。在这一点上,您可以在GDB中调试程序,就像在主机上运行一样。



http://wiki.osdev.org/GDB 似乎有一些更基本的信息;可能不足以完全让你开始,但至少给你在QEMU和GDB文档中寻找基本的想法和一些条款。跳过关于实现GDB存根的位,Qml有一个已经存在的,并且从使用模拟器存根开始。简短的表格只是您使用 -s 选项启动QEMU(在localhost:1234上导出GDB连接)和 -S 选项(在开始执行之前等待GDB继续命令),然后在主机上的GDB中,您说 target remote:1234 而不是运行。此外,当然,您需要使用ARM版本的GDB而不是native-x86。



(另外,如果您愿意支付一个商业解决方案,CodeSourcery的ARM工具链具有IDE集成,可以自动设置所有这一切,包括支持printf打印到调试器控制台中,如果您有一个硬件调试器,也可以在物理板上工作。 CodeSourcery的工具链更新,2012:



现在称为Mentor Graphics Sourcery CodeBench,但以上所有内容仍然适用。


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.

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?

解决方案

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

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 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.

(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.)

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

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

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