1. 前言
本文主要介绍qemu下调试arm64应用程序的环境搭建过程。通过gdbserver和gdb配合,用来调试应用程序代码。 qemu: qemu-system-arm64 gdb: gdb-8.2
2. 宿主机与qemu通信网络配置
可参考 qemu与宿主机网络通信配置 一文,经过配置后宿主机和qemu可以相互ping通,这为gdbserver调试提供了基础的通信条件。
3. 下载编译gdbserver
4. gdbserver调试arm64应用
启动qemu,执行./gdbserver 172.17.0.9:1234 a.out 其中172.17.0.9为宿主机的ip地址,1234为监听端口
/ # ./gdbserver 172.17.0.9:1234 a.out
Process /a.out created; pid = 123
Listening on port 1234
宿主机执行aarch64-linux-gnu-gdb a.out
ubuntu@VM-0-9-ubuntu$ aarch64-linux-gnu-gdb a.out
GNU gdb (Linaro_GDB-2017.01) 7.12.1.20170127-git
Copyright (C) 2017 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-unknown-linux-gnu --target=aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/ubuntu/test/a.out...done.
(gdb)
(gdb) target remote 172.17.0.2:1234
Remote debugging using 172.17.0.2:1234
Reading /lib/ld-linux-aarch64.so.1 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-linux-aarch64.so.1 from remote target...
Reading symbols from target:/lib/ld-linux-aarch64.so.1...Reading /lib/ld-2.27.so from remote target...
Reading /lib/.debug/ld-2.27.so from remote target...
(no debugging symbols found)...done.
0x0000fffff7fd21c0 in ?? () from target:/lib/ld-linux-aarch64.so.1
(gdb)
|