如何模拟ARM处理器运行时环境并将Linux内核模块加载到其中?

时间:2013-04-24 21:02:55

标签: android linux linux-kernel gdb arm

我尝试将vmlinux加载到gdb并使用ARM核心模拟器。

但我无法理解为什么会得到Undefined target command: "sim".

这是shell输出:

$ arm-eabi-gdb vmlinux
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-android".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /repo/kernel/kernel/vmlinux...done.
(gdb) target sim
Undefined target command: "sim".  Try "help target".
(gdb) help target
Connect to a target machine or process.
The first argument is the type or protocol of the target machine.
Remaining arguments are interpreted by the target protocol.  For more
information on the arguments for a particular protocol, type
`help target ' followed by the protocol name.

List of target subcommands:

target core -- Use a core file as a target
target exec -- Use an executable file as a target
target extended-remote -- Use a remote computer via a serial line
target record -- Log program while executing and replay execution from log
target record-core -- Log program while executing and replay execution from log
target remote -- Use a remote computer via a serial line
target tfile -- Use a trace file as a target

2 个答案:

答案 0 :(得分:3)

根据此email和手册中的gdb target command页面,您的流程正确无误。

但是, gdb 配置脚本有一个选项 - disable-sim crosstool-ng项目使用此option by default。大多数交叉编译器都是使用这个项目 Note1 构建的,因为这是一个相当漫长的过程。您的 gdb 很可能没有内置模拟器

似乎没有命令行选项来打印 gdb 配置。但是,运行strings -n 3 arm-eabi-gdb | grep -iw sim时应验证 gdb 是否具有 sim 选项;如果 gdb 中没有 sim 选项,则该命令不返回任何内容。

注1:至少,Linaro,Ubuntu,Debian和Ltib使用 crosstool-ng 。我不确定Android套件。

答案 1 :(得分:3)

GDB中的ARM模拟器不会模拟能够运行Linux内核的ARM应用程序处理器,例如:我相信它不会模拟内存管理单元。要运行Linux,请改用QEMU及其内置gdb服务器:https://plus.google.com/100386424363328269117/posts/RhdQmjz4gBJ