是否可以在Gem5系统调用仿真模式下运行Python代码?

问题描述

我需要在Gem5内运行一些Python代码。作为测试,我创建了一个名为hello.py的Python程序,该程序打印“ Hello World from Python”。我使用Pyinstaller创建了hello.py文件的二进制文件。二进制文件名为hello。接下来,我尝试使用以下命令./build/X86/gem5.opt --debug-flags=DRAM --debug-file=gem5-helloworld.out ./configs/example/se.py -c ./tests/test-progs/myFile/hello运行Gem5。但是,我收到以下消息fatal: syscall fchmod (#91) unimplemented.,并且Gem5没有打印“来自Python的Hello World”。信息。如何解决以上问题?是否可以在Gem5中运行Python代码? Gem5正在终端中打印以下内容

./build/X86/gem5.opt --debug-flags=DRAM --debug-file=gem5-helloworld.out ./configs/example/se.py -c ./tests/test-progs/myFile/hello

warn: CheckedInt already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
warn: Enum already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
warn: ScopedEnum already exists in allParams. This may be caused by the Python 2.7 compatibility layer.
gem5 Simulator System.  http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.

gem5 version 20.0.0.3
gem5 compiled Aug  5 2020 12:06:57
gem5 started Sep 21 2020 16:31:18
gem5 executing on LAPWF05588,pid 248502
command line: ./build/X86/gem5.opt --debug-flags=DRAM --debug-file=gem5-helloworld.out ./configs/example/se.py -c ./tests/test-progs/myFile/hello

Global frequency set at 1000000000000 ticks per second
warn: No dot file generated. Please install pydot to generate the dot file and pdf.
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0.  Starting simulation...
warn: ignoring syscall access(...)
info: Increasing stack size by one page.
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
warn: ignoring syscall mprotect(...)
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
info: Increasing stack size by one page.
warn: MOVNTDQ: Ignoring non-temporal hint,modeling as cacheable!
fatal: syscall fchmod (#91) unimplemented.
Memory Usage: 688628 KBytes

解决方法

您必须一一实现所有缺少的必需系统调用。

其中有些不是基本的,并且可以与ignoreFunc未实现的存根一起使用,只需快速浏览一下syscall描述并尝试猜测它是否是基本的,例如https://github.com/gem5/gem5/blob/fa70478413e4650d0058cbfe81fd5ce362101994/src/arch/arm/linux/process.cc#L179

我怀疑这不会太难。没有尝试就无法确定,这完全取决于缺少了多少个不可忽略的系统调用,以及实现起来有多复杂。

情况与Java类似:Running Java programs in gem5(or any language which is not C)

相关: