-
Notifications
You must be signed in to change notification settings - Fork 1
Debugger
If you haven't checked it out already Visual Studio Code is a really neat open source code editor. When you come to the point in your mips development that you need to debug your programs, there is a vscode extension for you!
Find the extension here or search dashmips
in the extension tab in vscode.
You need to create a folder for your current mips project regardless of the number of files you are working with.
Now you'll want to File > Open Folder...
to the new folder with your mips files in it.
By the way, vscode requires you to work on folders for projects that use the debugger since the settings for the debugger get put in a folder named
.vscode
in the current working directory.
Follow these steps:
- Navigate to the debug tab (looks like a bug with an
X
on it). - In the menu box with a play button you will see "No Configurations". Click the menu box and select "Add Configuration..."
- "Dashmips" should be among the options displayed in a pop up.
- Two default "debug configurations" will be generated into a file
.vscode/launch.json
- Notice in the first of the configurations the line
"program": "${file}",
This will run the debugger with the file that is currently in focus. (For example.vscode/launch.json
is probably in focus / foreground for you right now) We recommend changing this to your mips file with themain
function label in it just to make debugger runnable no matter what file is in focus. (Right click the tab of said mips file and selectCopy Relative Path
to ensure you have the correct filename).
- Two default "debug configurations" will be generated into a file
- Going back to the debugger tab, you should see "dashmips (Run Current File)" in the menu box (or whatever is in the
name
property of the configuration) - Press play! You should see the dashmips command appear in a terminal built in to the editor appear.
- The debugger will always stop at the first instruction in your program.
- Use step and continue buttons (Hover your mouse of the newly appeared buttons panel to see which one is which).
- Set breakpoints by clicking ahead of the line number.
- Inspect register and memory values in the variables section.
Below are common or known issues, we apologize for potentially inconvenient behavior but hope that at least the debugger is helpful despite minor issues.
This is a silly error relating to python event loops and we hope to have it fixed soon. Please click on the terminal where the debugger is running and press ctrl-C
to exit it.
- "Do I have an infinite loop in my program?"
-
Workaround: place a breakpoint before your exit syscall and ensure you make it there. Also test with
dashmips run
.
-
Workaround: place a breakpoint before your exit syscall and ensure you make it there. Also test with
- "How can I confirm the exit code of my program after it has actually exited?"
-
Workaround: same as above and check the
$a0
register. Also test withdashmips run
.
-
Workaround: same as above and check the
This is a bug that has been annoying to reproduce as it happens occasionally on some OSes and not others. Sorry if you are unfortunate to be on such a setup. Luckily, there is a solution!
When you generated the debug configuration, you may have noticed a second configuration that looked something like the one below:
{
"type": "dashmips",
"request": "attach",
"name": "dashmips (Attach)",
"registerFormat": "dec",
"host": "localhost",
"port": 2390
}
Notice the "request": "attach",
line, this tells vscode to attach to an already running debugger instance rather than attempting to run one.
- Open your own terminal (this can be the terminal program from your OS or ctrl+` for vscode's built in one).
- Run
dashmips debug FILE
where FILE is the full name of your mips file with themain
function label. - On the debug tab of vscode select the
attach
configuration in the menu box. - Press Play!
- You will need to launch your own
dashmips debug
instance each time you want to debug.
- You will need to launch your own
Happy Coding!