gdb 添加新目标,如 ROCgdb

发布于 2025-01-10 08:07:10 字数 116 浏览 0 评论 0原文

如何向GDB添加目标,完成对新CPU的支持。我看了一下 GDB 内部结构。我只是介绍了添加一个xxx_tdep.c文件,但没有说xxx_tdep.c需要详细描述哪些信息。我参考了RAM架构的ROCgdb,但我也看不懂。

How to add a target to GDB, complete support for a new CPU. I took a look at GDB Internals. I just introduced adding a xxx_tdep.c file, but did not say what information xxx_tdep.c needs to describe in detail. I refer to ROCgdb of RAM architecture, but I don't understand either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉栀 2025-01-17 08:07:10

我不知道您可以阅读一个包含添加新目标的完整步骤的文档。

我认为最好的策略是找到最近添加的目标,并查看添加该目标的提交,我建议 RISC-V 目标作为一个很好的例子。

我将从 git log -- gdb/riscv* 开始,然后从列表的底部开始向上工作。

您找到的第一个提交应该是这个。

上面没有向您展示的一件事是,在添加 GDB 支持之前,您需要 bfd 库(binutils-gdb/bfd 目录)中的目标支持,这就是 GDB 能够打开的方式并为您的 ARCH 处理文件。此外,如果您希望 GDB 能够反汇编 ARCH 的指令,您至少需要向操作码库(binutils-gdb/opcodes 目录)添加反汇编程序支持。一旦你有了 bfd 支持和操作码支持,像 readelf、objdump 和 objcopy 这样的东西要么就能工作,要么只需要很少的额外努力就可以工作。那时您就可以开始使用 GDB 了。

ARCH-tdep.[ch] 文件处理裸机目标内容,因此每个架构都需要这些文件之一。然后,如果您想添加 Linux 支持(例如),您将需要 ARCH-linux-tdep.[ch] 文件。这是通用的 Linux 支持,因此本地和远程 Linux 目标都可以使用。要真正支持在 Linux 上针对特定目标本地运行 GDB,您将添加 ARCH-linux-nat.[ch] 文件。

I'm not aware that there is a single document that you can read that contains complete steps for adding a new target.

The best strategy, I think, would be to find a recently added target, and look at the commits that added that target, I would recommend the RISC-V target as being a good example.

I'd start with git log -- gdb/riscv* and then start at the bottom of the list and work upwards.

The first commit you find should be this one.

The one thing the above doesn't show you though, is that before you can add GDB support, you'll need support for your target in the bfd library (the binutils-gdb/bfd directory), that's how GDB is able to open and process files for your ARCH. Additionally, if you want GDB to be able to disassemble the instructions for ARCH you'll need to add at least disassembler support to the opcodes library (the binutils-gdb/opcodes directory). Once you have bfd support and opcodes support things like readelf, objdump, and objcopy either will work, or will require minimal extra effort to get working. At that point you're ready to start working on GDB.

The ARCH-tdep.[ch] files deal with bare metal target stuff, so every architecture is going to need one of these files. Then if you want to add Linux support (for example), you'll need ARCH-linux-tdep.[ch] files. This is generic Linux support, so used by both local and remote Linux targets. To actually support running GDB natively on Linux for a particular target, you will add ARCH-linux-nat.[ch] files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文