# qemu_gdb_mips_hello **Repository Path**: caogos/qemu_gdb_mips_hello ## Basic Information - **Project Name**: qemu_gdb_mips_hello - **Description**: 在qemu上运行裸机版的helloworld,并用gdb实现单步调试。 - **Primary Language**: C - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 8 - **Forks**: 3 - **Created**: 2017-09-19 - **Last Updated**: 2023-12-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # qemu_gdb_mips_hello 在qemu上运行裸机版的helloworld,并用gdb实现单步调试。 # qemu qemu中已经包含了gdb server,只需要在qemu命令中增加参数“-gdb tcp::1234 -S”即可. 假设,待调试的可执行文件为“image.elf”,在当前目录的子目录“image.elf”内,那么完整的qemu命令为 `qemu-system-mipsel -M mipssim -nographic -kernel bin/image.elf -gdb tcp::1234 -S` 使用命令`qemu-system-mipsel -cpu ?`查看支持的所有CPU型号 使用命令`qemu-system-mipsel -M ?`查看支持的所有machine,命令中的“-M mipssim”表示使用mipssim机器。(注意,mipssim默认使用的24Kf CPU并不兼容所有的MIPS32r2功能,如果有需求可以指定P5600 CPU) # gdb x64 pc上默认的gdb不能用来调试MIPS程序,第三方工具链Sourcery CodeBench中的windows版本的“mips-sde-elf-gdb.exe”也不能用,但是MIPS提供的[mips-mti-elf](https://codescape.mips.com/components/toolchain/2019.09-01/downloads.html)工具链可以使用。将工具链安装并加入PATH后,我们可以直接运行。 `mips-mti-elf-gdb` 然后执行命令`target remote 127.0.0.1:1234`,连接qemu中的gdb server(假设qemu所在IP为127.0.01,也就是本机) 再然后执行命令`symbol-file /xxx/bin/image.elf`,加载符号表。注意在编译可执行文件image.elf时,gcc需要有参数"-g",否则生成的可执行文件image.elf中没有符号表等调试信息。 好,可以用s,c,b等命令调试了。