PA环境记录
时间:2020-11-27 22:15:54
收藏:0
阅读:44
实验环境
-
虚拟机 / 云服务器
-
vscode remote-ssh
相关资源:
代码仓库:参考http://archeng.top/pa/0.6.html
实验文档: 参考http://archeng.top/pa
完成后的调试环境大概这样,和调试本地文件的步骤和方法基本一致
大概有以下步骤
-
安装虚拟机环境/云服务器,centos7或者其他均可
-
虚拟机上安装好ssh,安装方式自己搜,安装相关工具链,包括gdb/cgdb,gcc,make~
-
本地vscode安装好remote ssh 插件,连上虚拟机,在本地vscode能写程序 算成功
调试环境
调试方式可以有这两种
-
cgdb / gdb中调试(有门槛)
-
Vscode 界面调试(推荐)
主要记录一下vscode的配置方式
-
按照实验文档完成首次编译和运行,中间可能会对makefile做一定修改,问题太杂不记录
-
在完成首次运行以后可以配置以下的配置文件
-
在项目根目录下创建 .vscode文件夹,文件夹下包括以下两个文件
tasks.json
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "make nemu", "type": "shell", "command": "cd nemu && make app", } ] }
lanuch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "gcc - 生成和调试活动文件", "type": "cppdbg", "request": "launch", "program": "/home/zhuzhicheng/project/PA/ics2019/nemu/build/mips32-nemu", "args": [ "-l","/home/zhuzhicheng/project/PA/ics2019/nemu/build/nemu-log.txt", "-d","/home/zhuzhicheng/project/PA/ics2019/nemu/tools/qemu-diff/build/mips32-qemu-so"], "stopAtEntry": true, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "make nemu", "miDebuggerPath": "/usr/bin/gdb" } ] }
launch.json中 program 和 args 项 的目录 /home/zhuzhicheng/project/PA/ 需要替换成自己的代码仓库目录
-l 参数 后跟的是日志路径
-d 参数 后跟的是nemu运行时加载程序的路径
这里的参数 和 makefile 中 make run 参数 保持一致即可
-
-
后续即可开启正常调试
可能碰到的一些问题:
- 初始化相关环境变量,根目录init.sh中注释掉第十行return,第13-15行 ,后执行 bash init.sh ,如果使用的不是默认shell,需要更改20-21 行
- 设置$ISA环境变量
- nemu/makefile 中
- 第33行:FLAGS += -O0 -g -MMD -Wall -ggdb3 -std=c99 $(INCLUDES) -D__ISA__=$(ISA) -fomit-frame-pointer # -mmanual-endbr -fcf-protection=none #-Werror 禁止编译器优化,调试时使用
- 第71行:@$(LD) -O0 -rdynamic $(SO_LDLAGS) -o $@ $^ -lSDL2 -lreadline -ldl
- 注释掉第25行关闭自动添加commit历史
- ···
原文:https://www.cnblogs.com/ar-cheng/p/14050377.html
评论(0)