linux – 如何在QEMU上的GDB中单步执行ARM程序集?

前端之家收集整理的这篇文章主要介绍了linux – 如何在QEMU上的GDB中单步执行ARM程序集?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试使用GNU汇编程序学习ARM汇编程序编程.我用QEmu设置了我的PC,并拥有Debian ARM-HF chroot环境.

如果我汇编并链接我的测试程序:

.text
.global _start
_start:
        mov     r0,#6
        bx      lr

有:

as test.s -o test.o
ld test.o -o test

然后将文件加载到gdb并在_start上设置断点:

root@Latitude-E6420:/root# gdb test
GNU gdb (GDB) 7.6.1 (Debian 7.6.1-1)
Copyright (C) 2013 Free Software Foundation,Inc.
License GPLv3+: GNU GPL version 3 or later 
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 "arm-linux-gnueabihf".
For bug reporting instructions,please see:
...
Reading symbols from /root/test...(no debugging symbols found)...done.
(gdb) break _start
Breakpoint 1 at 0x8054
(gdb)

如何单步执行代码,显示汇编程序源代码并监视寄存器?
我尝试了一些基本的命令,但它们不起作用:

(gdb) break _start
Breakpoint 1 at 0x8054
(gdb) info regi
The program has no registers now.
(gdb) stepi
The program is not being run.
(gdb) disas
No frame selected.
(gdb) r
Starting program: /root/test 
qemu: Unsupported syscall: 26
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
qemu: Unsupported syscall: 26
During startup program terminated with signal SIGSEGV,Segmentation fault.
(gdb) 
最佳答案
这里的问题是你试图在QEMU的用户模式仿真下运行ARM gdb. QEMU不支持ptrace系统调用(这就是系统调用号26),所以这永远不会起作用.

您需要做的是在QEMU下使用QEMU选项运行测试二进制文件,以启用QEMU自己的内置gdb存根,该存根将侦听TCP端口.然后,您可以运行编译为在主机系统上运行但支持ARM目标的gdb,并告诉它连接到TCP端口.

(在QEMU中模拟ptrace在技术上非常棘手,并且它不会提供许多你无法通过QEMU内置gdbstub实现的额外功能.它不太可能实现.)

原文链接:https://www.f2er.com/linux/440531.html

猜你在找的Linux相关文章