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

67 lines
2.0 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 GDB 调试快速测试脚本
echo "================================"
echo "MIPS translate.c GDB 调试向导"
echo "================================"
echo ""
# 检查 Renode 是否在运行
if pgrep -f Renode.dll > /dev/null; then
PID=$(pgrep -f Renode.dll)
echo "✅ 检测到 Renode 正在运行 (PID: $PID)"
echo ""
echo "现在将执行以下操作:"
echo "1. 附加 GDB 到 Renode"
echo "2. 设置断点在 gen_intermediate_code"
echo "3. 等待您在 Renode 中执行 'cpu Step 1'"
echo ""
echo "⚠️ 重要提示:"
echo " 请确保您在 Renode 中已经执行了:"
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 ""
echo " 但是 ⚠️ 不要执行 'cpu Step 1' ⚠️"
echo ""
read -p "按 Enter 继续附加 GDB..."
# 创建 GDB 命令文件
cat > /tmp/gdb_commands.txt << 'EOF'
set breakpoint pending on
break gen_intermediate_code
info breakpoints
echo \n==============================================\n
echo ✅ 断点已设置!\n
echo \n现在请切换到 Renode 窗口执行: cpu Step 1\n
echo ==============================================\n\n
continue
EOF
echo ""
echo "启动 GDB..."
sudo gdb -p $PID -x /tmp/gdb_commands.txt
else
echo "❌ 错误Renode 没有运行"
echo ""
echo "请先在另一个终端启动 Renode"
echo " cd ~/source/renode"
echo " ./renode"
echo ""
echo "然后在 Renode Monitor 中执行:"
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 ""
echo "⚠️ 不要执行 'cpu Step 1',然后再运行此脚本"
exit 1
fi