Files
simulation_core/fix_mips_debug.sh

112 lines
2.8 KiB
Bash
Raw Permalink Normal View History

2026-03-13 13:54:49 +08:00
#!/bin/bash
# 修复 MIPS 调试问题 - 重新编译 Debug 版本
set -e
echo "=========================================="
echo " 修复 MIPS 调试问题"
echo "=========================================="
echo ""
echo "问题诊断:"
echo "- MIPS tlib 只有 Release 版本"
echo "- Release 版本没有调试符号"
echo "- 因此 GDB 无法设置断点"
echo ""
echo "解决方案:"
echo "- 重新编译 MIPS tlib (Debug 模式)"
echo ""
read -p "是否继续编译?[y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "已取消"
exit 1
fi
echo ""
echo "=========================================="
echo " 步骤 1: 清理旧的 Debug 目录"
echo "=========================================="
echo ""
DEBUG_DIR="src/Infrastructure/src/Emulator/Cores/bin/Debug"
if [ -d "$DEBUG_DIR" ]; then
echo "清理 $DEBUG_DIR ..."
rm -rf "$DEBUG_DIR"
fi
DEBUG_OBJ_DIR="src/Infrastructure/src/Emulator/Cores/obj/Debug"
if [ -d "$DEBUG_OBJ_DIR" ]; then
echo "清理 $DEBUG_OBJ_DIR ..."
rm -rf "$DEBUG_OBJ_DIR"
fi
echo ""
echo "=========================================="
echo " 步骤 2: 编译 MIPS tlib (Debug 模式)"
echo "=========================================="
echo ""
echo "执行: ./build.sh --external-lib-arch mips.le -d"
./build.sh --external-lib-arch mips.le -d
echo ""
echo "=========================================="
echo " 步骤 3: 验证编译结果"
echo "=========================================="
echo ""
MIPS_SO="src/Infrastructure/src/Emulator/Cores/bin/Debug/lib/translate-mips-le.so"
if [ -f "$MIPS_SO" ]; then
echo "✅ MIPS SO 文件已生成: $MIPS_SO"
# 检查调试符号
if file "$MIPS_SO" | grep -q "not stripped"; then
echo "✅ 包含调试符号 (not stripped)"
echo ""
file "$MIPS_SO"
else
echo "⚠️ 警告: SO 文件可能不包含调试符号"
echo ""
file "$MIPS_SO"
fi
else
echo "❌ 编译失败: SO 文件未生成"
exit 1
fi
echo ""
echo "=========================================="
echo " 步骤 4: 编译 Renode 主程序 (Debug)"
echo "=========================================="
echo ""
read -p "是否编译 Renode 主程序?[y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "执行: ./build.sh -d"
./build.sh -d
echo "✅ Renode 主程序编译完成"
fi
echo ""
echo "=========================================="
echo " ✅ 修复完成!"
echo "=========================================="
echo ""
echo "下一步:"
echo "1. 启动 Renode: ./renode"
echo "2. 加载 MIPS 平台: machine LoadPlatformDescription @platforms/cpus/mips32_simple.repl"
echo "3. VSCode 附加调试器: F5 → 选择 'MIPS Debug'"
echo "4. 在 translate.c 打断点"
echo "5. 执行: cpu Step 1"
echo "6. 断点应该会触发了!"
echo ""