os:ubuntu 18.04 x64
使用qemu 作为模拟器,gdb 为作为调试器。
-
安装相关软件
sudo apt install gdb-multiarch qemu qemu-user gcc-multilib gcc-multilib-mips64-linux-gnuabi64
-
测试代码
$ cat code.c
#include<stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}
3.编译调试
$ mips64-linux-gnuabi64-gcc code.c -static -g3
And start emulation in qemu with debug session:
$ qemu-mips64 -g 1234 ./a.out
In gdb-multiarch use the following routine:
symbol-file a.out
set arch mips:isa64
target remote :1234
b main
c
And here is your goal:
(gdb) x/5i main
0x120003850 <main>: daddiu sp,sp,-32
0x120003854 <main+4>: sd ra,24(sp)
0x120003858 <main+8>: sd s8,16(sp)
0x12000385c <main+12>: sd gp,8(sp)
0x120003860 <main+16>: move s8,sp
4.更详细的请查看 gdb
set
arch
等指令的用法
5.参考链接
[1]. https://stackoverflow.com/questions/59906042/how-to-debug-mips-interactively