Debugger not stepping properly with Arduino
Quote from szaydel on November 3, 2024, 11:32 pmI want to report an issue with the debugger in the latest stable version of the program. I am running it on an M1 Macbook Pro. I created an assembly program, assembled and uploaded it to the emulated board. The program appears to be fine. However, when I attempt to debug I see there are problems. I can set multiple breakpoints, but the debugger cannot step past the first step. If I set the breakpoint quite early on in the program and then select "Run To Breakpoint", the program seems to be running and does not stop on the breakpoint. If I hit pause, no matter where I set the breakpoint the program always ends-up on the same line. I then hit pause again and again, same thing, I hit the "step" button and the program is running again. It is not single-stepping. The only two buttons I can hit at this point are "Pause" and "Stop The Debugger".
I am attaching all the files from the project.
Here's an example program:
.INCLUDE "m328Pdef.inc" .ORG 0x0000 ; the next instruction has to be written to ; address 0x0000 rjmp START ; the reset vector: jump to "main" START: ldi r16, low(RAMEND) ; set up the stack out SPL, r16 ldi r16, high(RAMEND) out SPH, r16 ldi r16, 0xFF ; load register 16 with 0xFF (all bits 1) out DDRB, r16 ; write the value in r16 (0xFF) to Data ; Direction Register B LOOP: sbi PortB, 5 ; switch off the LED rcall delay_05 ; wait for half a second cbi PortB, 5 ; switch it on rcall delay_05 ; wait for half a secon rjmp LOOP ; jump to loop DELAY_05: ; the subroutine: ldi r16, 31 ; load r16 with 31 OUTER_LOOP: ; outer loop label ldi r24, low(1021) ; load registers r24:r25 with 1021, our new ; init value ldi r25, high(1021) ; the loop label DELAY_LOOP: ; "add immediate to word": r24:r25 are ; incremented adiw r24, 1 ; if no overflow ("branch if not equal"), go ; back to "delay_loop" brne DELAY_LOOP dec r16 ; decrement r16 brne OUTER_LOOP ; and loop if outer loop not finished ret ; return from subroutine
I want to report an issue with the debugger in the latest stable version of the program. I am running it on an M1 Macbook Pro. I created an assembly program, assembled and uploaded it to the emulated board. The program appears to be fine. However, when I attempt to debug I see there are problems. I can set multiple breakpoints, but the debugger cannot step past the first step. If I set the breakpoint quite early on in the program and then select "Run To Breakpoint", the program seems to be running and does not stop on the breakpoint. If I hit pause, no matter where I set the breakpoint the program always ends-up on the same line. I then hit pause again and again, same thing, I hit the "step" button and the program is running again. It is not single-stepping. The only two buttons I can hit at this point are "Pause" and "Stop The Debugger".
I am attaching all the files from the project.
Here's an example program:
.INCLUDE "m328Pdef.inc"
.ORG 0x0000 ; the next instruction has to be written to
; address 0x0000
rjmp START ; the reset vector: jump to "main"
START:
ldi r16, low(RAMEND) ; set up the stack
out SPL, r16
ldi r16, high(RAMEND)
out SPH, r16
ldi r16, 0xFF ; load register 16 with 0xFF (all bits 1)
out DDRB, r16 ; write the value in r16 (0xFF) to Data
; Direction Register B
LOOP:
sbi PortB, 5 ; switch off the LED
rcall delay_05 ; wait for half a second
cbi PortB, 5 ; switch it on
rcall delay_05 ; wait for half a secon
rjmp LOOP ; jump to loop
DELAY_05: ; the subroutine:
ldi r16, 31 ; load r16 with 31
OUTER_LOOP: ; outer loop label
ldi r24, low(1021) ; load registers r24:r25 with 1021, our new
; init value
ldi r25, high(1021) ; the loop label
DELAY_LOOP: ; "add immediate to word": r24:r25 are
; incremented
adiw r24, 1 ; if no overflow ("branch if not equal"), go
; back to "delay_loop"
brne DELAY_LOOP
dec r16 ; decrement r16
brne OUTER_LOOP ; and loop if outer loop not finished
ret ; return from subroutine
Quote from arcachofo on November 3, 2024, 11:50 pmHi.
Not sure what can be the problem, I can debug your code in SimulIDE 1.1.0-SR1
Can you show what is the output at the bottom panel after you click the debug button?
Hi.
Not sure what can be the problem, I can debug your code in SimulIDE 1.1.0-SR1
Can you show what is the output at the bottom panel after you click the debug button?
Quote from KerimF on November 4, 2024, 4:25 amThis may not be relevant to the topic.
I started a new project using ATmega8 and forgot to change the MCU clock frequency from 0 (default) to 8 MHz. By running the debugger, the simulation starts and runs, though without doing anything (for instance, perhaps a popup warning that the MCU clock frequency is 0 may help).
This may not be relevant to the topic.
I started a new project using ATmega8 and forgot to change the MCU clock frequency from 0 (default) to 8 MHz. By running the debugger, the simulation starts and runs, though without doing anything (for instance, perhaps a popup warning that the MCU clock frequency is 0 may help).
Quote from arcachofo on November 5, 2024, 1:11 amQuote from KerimF on November 4, 2024, 4:25 amThis may not be relevant to the topic.
I started a new project using ATmega8 and forgot to change the MCU clock frequency from 0 (default) to 8 MHz. By running the debugger, the simulation starts and runs, though without doing anything (for instance, perhaps a popup warning that the MCU clock frequency is 0 may help).
You are right, default frequency 0 was a problem, but it is solved is last versions.
Quote from KerimF on November 4, 2024, 4:25 amThis may not be relevant to the topic.
I started a new project using ATmega8 and forgot to change the MCU clock frequency from 0 (default) to 8 MHz. By running the debugger, the simulation starts and runs, though without doing anything (for instance, perhaps a popup warning that the MCU clock frequency is 0 may help).
You are right, default frequency 0 was a problem, but it is solved is last versions.
Quote from szaydel on November 10, 2024, 5:22 pmTo make things a bit easier to explain, I hope, I recorded a video of what I am seeing. We can see in the video that I cannot step all the way through the code. It seems like I can get to line 5, then the Step button turns gray. The little pointer icon is remaining on line 5, and the debugger output at the bottom seems to suggest that the system stopped on line 5. I cannot continue stepping, which I expect to be able to do. I am also expecting that I should be able to step indefinitely, since the
rjmp
call should jump back to line 5 every time. So I should be able to go 5 -> 6 -> 7 -> 8 -> 5 ....include "m328Pdef.inc" .cseg loop: ldi r16, 0xab out PORTB, r16 nop rjmp loop
The video is too large to upload due to the very limited upload size here. Thus, here's a link to the compressed mov file: https://drive.google.com/file/d/1Ax3w7zE2lMj9bZlYwRN9rDGQWcU-9z30/view?usp=drive_link
I am sorry about the inconvenience with the download link. I wish the limit here was much less restrictive.
Regards, Sam.
To make things a bit easier to explain, I hope, I recorded a video of what I am seeing. We can see in the video that I cannot step all the way through the code. It seems like I can get to line 5, then the Step button turns gray. The little pointer icon is remaining on line 5, and the debugger output at the bottom seems to suggest that the system stopped on line 5. I cannot continue stepping, which I expect to be able to do. I am also expecting that I should be able to step indefinitely, since the rjmp
call should jump back to line 5 every time. So I should be able to go 5 -> 6 -> 7 -> 8 -> 5 ...
.include "m328Pdef.inc"
.cseg
loop:
ldi r16, 0xab
out PORTB, r16
nop
rjmp loop
The video is too large to upload due to the very limited upload size here. Thus, here's a link to the compressed mov file: https://drive.google.com/file/d/1Ax3w7zE2lMj9bZlYwRN9rDGQWcU-9z30/view?usp=drive_link
I am sorry about the inconvenience with the download link. I wish the limit here was much less restrictive.
Regards, Sam.
Quote from szaydel on November 10, 2024, 5:39 pmThe other thing I am noticing is that I can click Run To Breakpoint and that seems to work, but the arrow icon on the left hand side does not appear to advance. Yet, as can be seen from the screenshot, the values in the
R16
andPORTB
are indeed updated. You can see that I added a nonsense modification of theSREG
register and it is reflected in the MCU monitor. Yet, at the same time the arrow on left hand side is still pointing to line 5. Clearly the MCU advanced past line 5, but the arrow does not appear to be moving. This may be an unrelated issue.
The other thing I am noticing is that I can click Run To Breakpoint and that seems to work, but the arrow icon on the left hand side does not appear to advance. Yet, as can be seen from the screenshot, the values in the R16
and PORTB
are indeed updated. You can see that I added a nonsense modification of the SREG
register and it is reflected in the MCU monitor. Yet, at the same time the arrow on left hand side is still pointing to line 5. Clearly the MCU advanced past line 5, but the arrow does not appear to be moving. This may be an unrelated issue.
Quote from szaydel on November 13, 2024, 3:47 pmI am sorry, could you please try again and let me know if there's a problem. You _should_ be able to access it. https://drive.google.com/file/d/1Ax3w7zE2lMj9bZlYwRN9rDGQWcU-9z30/view?usp=drive_link
I am sorry, could you please try again and let me know if there's a problem. You _should_ be able to access it. https://drive.google.com/file/d/1Ax3w7zE2lMj9bZlYwRN9rDGQWcU-9z30/view?usp=drive_link
Quote from arcachofo on November 13, 2024, 4:24 pmThanks, I could download it.
I can't replicate your results with file extension .s
Not sure how are you compiling, but I think you should use extension .asm with Avra.
Thanks, I could download it.
I can't replicate your results with file extension .s
Not sure how are you compiling, but I think you should use extension .asm with Avra.