Files
simulation_core/debug_mips.sh
2026-03-13 13:54:49 +08:00

61 lines
1.9 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# MIPS translate.c 调试快速启动脚本
echo "========================================"
echo " MIPS translate.c GDB 调试助手"
echo "========================================"
echo ""
# 查找 Renode 进程
PID=$(pgrep -f Renode.dll)
if [ -z "$PID" ]; then
echo "❌ 错误Renode 没有运行!"
echo ""
echo "请先在另一个终端启动 Renode"
echo " cd /home/simulation/source/renode"
echo " ./renode"
echo ""
echo "然后在 Renode Monitor 中执行(但不要 Step"
echo " mach create \"MIPS-Test\""
echo " machine LoadPlatformDescription @platforms/cpus/mips32_simple.repl"
echo " cpu PC 0x80000000"
echo " cpu A0 5"
echo " cpu A1 3"
echo " sysbus WriteDoubleWord 0x80000000 0x00851020"
echo ""
exit 1
fi
echo "✅ 检测到 Renode 进程: PID=$PID"
echo ""
echo "将设置以下断点:"
echo " 1. gen_intermediate_code (主翻译函数)"
echo " 2. decode_and_translate (指令解码)"
echo ""
echo "⚠️ 重要提示:"
echo " - 确保在 Renode 中已加载平台但未执行 'cpu Step 1'"
echo " - 断点触发后使用以下命令:"
echo " list 查看代码"
echo " next 下一行(不进入函数)"
echo " step 下一行(进入函数)"
echo " print/x insn 查看指令16进制"
echo " info locals 查看局部变量"
echo " bt 查看调用栈"
echo " continue 继续运行"
echo ""
read -p "按 Enter 继续启动 GDB..."
# 启动 GDB 并自动设置断点
sudo gdb -p $PID \
-ex "set breakpoint pending on" \
-ex "break gen_intermediate_code" \
-ex "break decode_and_translate" \
-ex "info breakpoints" \
-ex "echo \n========================================\n" \
-ex "echo ✅ 断点已设置!\n" \
-ex "echo 现在切换到 Renode 窗口执行: cpu Step 1\n" \
-ex "echo ========================================\n\n" \
-ex "continue"