如何设置Eclipse IDE进行gem5开发?
由于:
- 广泛使用代码自动生成功能(尤其是
.isa
指令和解码器子语言) - 将原始资源符号链接到构建树中,尤其是符号链接
src/arch/ARCH
到src/ARCH
- extensive usage of code auto-generation (notably for the
.isa
instruction and decoder sublanguage) - scons symlinking sources into the build tree, and in particular symlinking
src/arch/ARCH
tosrc/ARCH
设置Eclipse以使其与gem5配合使用变得非常困难.
it becomes very hard to setup Eclipse to work well with gem5.
有人成功实现了良好的设置吗?对Linux主机特别感兴趣.
Has anyone managed to achieve a good setup? Especially interested in Linux hosts.
通过以下可怕的技巧,我已经实现了很好的设置:在build/ARM
目录本身内定义Eclipse项目!
I have achieved a very good setup with the following horrendous hack: define the Eclipse project inside the build/ARM
directory itself!
这是通过在构建目录中创建具有现有代码的新Makefile项目"来完成的.您还需要修复C ++标准库,如以下所述:
This is done by creating a "New makefile project with existing code" in the build directory. You will also want to fix the C++ standard library as mentioned at: How to solve "Unresolved inclusion: <iostream>" in a C++ file in Eclipse CDT?
之所以如此有效,是因为gem5构建系统从2020年5月开始运作,build/ARM
目录完全包含最终的编译树,包括所有源符号链接和自动生成的代码.
This works amazingly because the way the gem5 build system works as of May 2020, the build/ARM
directory contains exactly the final compilation tree, including all the source symlinks and autogenerated code,.
此设置并不完美,因为ARM
之外的build/
中还有一些C ++内容,例如ext
,但是99%的时间我们都不在乎那些,而且我可以完美地浏览自动生成的关键代码,例如指令和解码器.
This setup is not perfect because there is still some C++ stuff in build/
outside of ARM
, e.g. ext
, but 99% of the time we don't care about those, and I can perfectly navigate key autogenerated code such as instructions and decoder.
然后我通常使用scons
通过命令行进行构建.
I then just build via the command line normally with scons
.
大量自动生成的文件(例如exec-ns.cc.inc)打开Eclipse的大文件限制模式.值得注意的是,如果您想跳转到定义,则Ctrl +单击对我不起作用,因此我只复制感兴趣的符号,然后按Ctrl + Shift + T转到其定义.
Humongous autogenerated files like exec-ns.cc.inc turn on Eclipse's large file limited mode. Notably, if you want to jump to a definition, Ctrl + click does not work for me, so I just copy the symbol of interest and Ctrl + Shift + T to go to its definition.
由于在情况严重时进行反向调试.
I don't usually bother to try GDB step debug gem5 through Eclipse and use it mostly for code navigation, since GDB Dashboard tends to work well enough for me, and I often need to do new log collection runs and I sometimes use reverse debugging when things get serious.
但是我已经测试了通过Eclipse进行的逐步调试,并且idd可以正常工作(我猜没有理由),您只需将其设置为与使用Makefile的任何其他C ++应用程序完全相同的设置即可,也就是说,基本上在调试配置中告诉Eclipse二进制名称和所需的CLI.
But I have tested step debugging through Eclipse, and it idd work normally (no reason not to I guess), you just have to set it up in exactly the same was as for any other C++ application with a Makefile, i.e. basically tell eclipse the Binary name and the desired CLI on the debug configurations.
您当然可以像往常一样在gem5.debug调试版本或gem5.opt版本之间进行选择,其中.debug
版本与
You have of course as usual to choose between a gem5.debug debug build or a gem5.opt build, where the .debug
build is about 10-20x slower but gives greater debug visibility. In general, if the time to reach the point of interest in a debug build starts to annoy you however, what you tend to really want is to do use reverse debugging.
在以下位置也提到了这一点: https://cirosantilli. com/linux-kernel-module-cheat/#gem5-eclipse-configuration
This is also mentioned at: https://cirosantilli.com/linux-kernel-module-cheat/#gem5-eclipse-configuration
在Eclipse 2020-03中进行了测试.
Tested in Eclipse 2020-03.