qemu下gdbsever调试arm64应用

1. 前言

本文主要介绍qemu下调试arm64应用程序的环境搭建过程。通过gdbserver和gdb配合,用来调试应用程序代码。
qemu: qemu-system-arm64
gdb: gdb-8.2

2. 宿主机与qemu通信网络配置

可参考 qemu与宿主机网络通信配置 一文,经过配置后宿主机和qemu可以相互ping通,这为gdbserver调试提供了基础的通信条件。

3. 下载编译gdbserver

  • 下载
    http://www.gnu.org/software/gdb/download/
    此处我选择下载版本为 gdb-8.2.tar.gz
  • 编译
    ./configure --target=aarch64-linux-gnu --host=aarch64-linux-gnu --static
    make
    将编译出的gdbserver拷贝到qemu下的根文件系统中

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) 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值