Dashmips index out of bounds error with Step Over command
Opened this issue · 2 comments
Environment:
Python v3.9.0
dashmips v0.1.10 (latest)
dashmips-debugger v0.1.14 (latest)
Explanation
Hello! Thanks for creating this neat extension to use for Assembly debugging. I'm not certain if this should be considered a bug with dashmips or with this Visual Studio Code extension. Essentially, the issue appears to be that when I set a breakpoint as the last line of assembly code and then give the "Step Over" command, the following index out of bounds error occurs. I'm not sure what exactly you are sending to dashmips when the step over command is sent, but it would appear that dashmips runs out of commands in the array of stored commands.
If I hit "continue" instead of "step over", the program does not error out and instead says:
2021-09-13 15:33:05,532 INFO Recv `{'method': 'continue', 'params': [{'id': 0, 'path': 'd:\\Documents\\Assembly-MIPS\\Hello-World.asm', 'line': 18}]}`
Program counter invalid on (dropped off bottom)
I think the solution on your end is to check what line you are currently debugging, and if it's the last line, change the way you handle the final continue / step over command. If its not something you have the capacity to fix, I can bring up this issue with the dashmips repo instead.
Code
.data
msg: .asciiz "\nHello, World!\n"
.text
main:
li $v0, 4 # $v0 = 4
la $a0, msg # $a0 = msg
syscall
addi $t0, $zero, 12
addi $t1, $zero, 7
add $s0, $t0, $t1
sub $s1, $t0, $t1
addi $s2, $zero, 0x10010000
sw $s0, 0($s2)
sw $s1, 4($s2)
Images
Log
PS D:\Documents\Assembly-MIPS> & 'python' '-m' 'dashmips' 'debug' '-i' 'localhost' '-p' '2390' '-l' 'd:\Documents\Assembly-MIPS\Hello-World.asm'
2021-09-13 15:21:02,835 INFO Serving on: tcp://localhost:2390
2021-09-13 15:21:02,935 INFO 127.0.0.1 wrote: {'method': 'verify_breakpoints', 'params': [{'id': 0, 'path': 'd:\\Documents\\Assembly-MIPS\\Hello-World.asm',
'line': 18}]}
2021-09-13 15:21:02,936 INFO Recv `{'method': 'verify_breakpoints', 'params': [{'id': 0, 'path': 'd:\\Documents\\Assembly-MIPS\\Hello-World.asm', 'line': 18}]}`
2021-09-13 15:21:02,936 INFO Send `{"method": "verify_breakpoints", "result": [[{"id": 0, "path": "d:\\Documents\\Assembly-MIPS\\Hello-World.asm", "line": 18}], [9]]}`
2021-09-13 15:21:02,937 INFO 127.0.0.1 wrote: {'method': 'start', 'params': []}
2021-09-13 15:21:02,938 INFO Recv `{'method': 'start', 'params': []}`
2021-09-13 15:21:02,938 INFO Send `{"method": "start", "result": {"pid": 6576}}`
2021-09-13 15:21:02,938 INFO 127.0.0.1 wrote: {'method': 'continue', 'params': [{'id': 0, 'path': 'd:\\Documents\\Assembly-MIPS\\Hello-World.asm', 'line': 18}]}
2021-09-13 15:21:02,939 INFO Recv `{'method': 'continue', 'params': [{'id': 0, 'path': 'd:\\Documents\\Assembly-MIPS\\Hello-World.asm', 'line': 18}]}`
Hello, World!
2021-09-13 15:21:02,946 INFO Send `{"method": "continue", "result": {"stopped": true, "line": {"filename": "d:\\Documents\\Assembly-MIPS\\Hello-World.asm", "lineno": 18, "line": "sw $s1, 4($s2)"}}}`
2021-09-13 15:21:02,947 INFO 127.0.0.1 wrote: {'method': 'update_visualizer', 'params': ['']}
2021-09-13 15:21:02,948 INFO Recv `{'method': 'update_visualizer', 'params': ['']}`
2021-09-13 15:21:02,948 INFO Send `{"method": "update_visualizer", "result": "&&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&& "}`
2021-09-13 15:21:02,961 INFO 127.0.0.1 wrote: {'method': 'info', 'params': []}
2021-09-13 15:21:02,961 INFO Recv `{'method': 'info', 'params': []}`
2021-09-13 15:21:02,972 INFO Send info response
2021-09-13 15:21:03,414 INFO 127.0.0.1 wrote: {'method': 'info', 'params': []}
2021-09-13 15:21:03,414 INFO Recv `{'method': 'info', 'params': []}`
2021-09-13 15:21:03,424 INFO Send info response
2021-09-13 15:21:15,171 INFO 127.0.0.1 wrote: {'method': 'step', 'params': []}
2021-09-13 15:21:15,172 INFO Recv `{'method': 'step', 'params': []}`
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 56807)
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\socketserver.py", line 316, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Program Files\Python39\lib\socketserver.py", line 347, in process_request
self.finish_request(request, client_address)
File "C:\Program Files\Python39\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python39\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\noahk\AppData\Roaming\Python\Python39\site-packages\dashmips\debuggerserver.py", line 132, in handle
response = run_method(command, self.commands)
File "C:\Users\noahk\AppData\Roaming\Python\Python39\site-packages\dashmips\debuggerserver.py", line 81, in run_method
result = command(params=params)
File "C:\Users\noahk\AppData\Roaming\Python\Python39\site-packages\dashmips\debugger.py", line 37, in debug_step
return {"stopped": True, "line": asdict(program.current_line)}
File "C:\Users\noahk\AppData\Roaming\Python\Python39\site-packages\dashmips\models.py", line 69, in current_line
return self.source[pc]
IndexError: list index out of range
----------------------------------------
The debugger's handling could be improved here but the error is caused by not exiting the program correctly, at least in our simulator, you must run syscall
instruction with $v0
set to 10
at the end of your main function. That is what the "dropped off bottom" is referring to, as in dropped off bottom of the .text
section.
Yes, it’s definitely not correct Assembly code. I was just messing around and figured that the way the error was handled with the continue was much better than the way the step over handled it.