I checked with my friend and he made a mistake in the initial tests, he placed a breakpoint in the loop, and this changed step behaviour.
Without breakpoint, the problem affects Ubuntu too.
---
However, we conducted some more tests on ARM (using a STM32F103RB), and during what appears to be an endless loop entered after issuing the 's' command, is in fact a lot of activity between the GDB client and the GDB server.
Below is an excerpt from the J-Link GDB server log:
As you can see, the GDB client issues the single step command, execution halts, but for unknown reasons, the GDB client does not return to the user, but issues another single step command, and so on.
To me, the problem seems to be inside the GDB client.
I checked with my friend and he made a mistake in the initial tests, he placed a breakpoint in the loop, and this changed step behaviour.
Without breakpoint, the problem affects Ubuntu too.
---
However, we conducted some more tests on ARM (using a STM32F103RB), and during what appears to be an endless loop entered after issuing the 's' command, is in fact a lot of activity between the GDB client and the GDB server.
Below is an excerpt from the J-Link GDB server log:
03-00000000- 00-00055137- 0019: Performing single step... 00-00055137- 0080: TDD3F9700 055:137 JLINK_Step() -- Read from flash cache (2 bytes @ 0x080006BC) -- Simulated returns 0x00 (0000ms, 1574ms total) 00-00055137- 0047: TDD3F9700 055:137 JLINK_IsHalted() returns TRUE (0000ms, 1574ms total) 00-00055137- 0054: TDD3F9700 055:137 JLINK_ReadReg(R15 (PC)) returns 0x080006BC (0000ms, 1574ms total) 00-00055137- 00A2: TDD3F9700 055:137 JLINK_ReadMem (0x080006BC, 0x0002 Bytes, ...) -- Read from flash cache (2 bytes @ 0x080006BC) - Data: FE E7 returns 0x00 (0000ms, 1574ms total) 00-00055137- 005C: TDD3F9700 055:137 JLINK_FindBP(Addr = 0x080006BC) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 0048: TDD3F9700 055:137 JLINK_GetNumWPs() returns 0x00 (0000ms, 1574ms total) 00-00055137- 0022: ...Target halted (PC = 0x080006BC) 00-00055137- 0007: $T05#b9 00-00055137- 0005: $g#67 00-00055137- 0015: Reading all registers 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R0) returns 0x00000001 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R1) returns 0x080006D4 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R2) returns 0x080006D4 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R3) returns 0x00000001 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R4) returns 0x200006B4 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R5) returns 0x2000070C (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R6) returns 0x2000070C (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R7) returns 0x20004FA8 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R8) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R9) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 004F: TDD3F9700 055:137 JLINK_ReadReg(R10) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 004F: TDD3F9700 055:137 JLINK_ReadReg(R11) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 004F: TDD3F9700 055:137 JLINK_ReadReg(R12) returns 0x20000628 (0000ms, 1574ms total) 00-00055137- 0054: TDD3F9700 055:137 JLINK_ReadReg(R13 (SP)) returns 0x20004FA8 (0000ms, 1574ms total) 00-00055137- 004F: TDD3F9700 055:137 JLINK_ReadReg(R14) returns 0x08000357 (0000ms, 1574ms total) 00-00055137- 0054: TDD3F9700 055:137 JLINK_ReadReg(R15 (PC)) returns 0x080006BC (0000ms, 1574ms total) 00-00055137- 0050: TDD3F9700 055:137 JLINK_ReadReg(XPSR) returns 0x01000000 (0000ms, 1574ms total) 00-00055137- 004F: TDD3F9700 055:137 JLINK_ReadReg(MSP) returns 0x20004FA8 (0000ms, 1574ms total) 00-00055137- 004F: TDD3F9700 055:137 JLINK_ReadReg(PSP) returns 0x802337EC (0000ms, 1574ms total) 00-00055137- 0053: TDD3F9700 055:137 JLINK_ReadReg( PRIMASK) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 0053: TDD3F9700 055:137 JLINK_ReadReg( BASEPRI) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 0055: TDD3F9700 055:137 JLINK_ReadReg( FAULTMASK) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 0053: TDD3F9700 055:137 JLINK_ReadReg( CONTROL) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 00BC: $01000000d40600 08d406000801000 000b40600200c07 00200c070020a84 f00200000000000 000000000000000 000000028060020 a84f00205703000 8bc060008000000 01a84f0020ec372 380000000000000 000000000000000 00000#3f 00-00055137- 000C: $qTStatus#49 00-00055137- 0004: $#00 00-00055137- 0005: $s#73 00-00055137- 0019: Performing single step... 00-00055137- 0080: TDD3F9700 055:137 JLINK_Step() -- Read from flash cache (2 bytes @ 0x080006BC) -- Simulated returns 0x00 (0000ms, 1574ms total) 00-00055137- 0047: TDD3F9700 055:137 JLINK_IsHalted() returns TRUE (0000ms, 1574ms total) 00-00055137- 0054: TDD3F9700 055:137 JLINK_ReadReg(R15 (PC)) returns 0x080006BC (0000ms, 1574ms total) 00-00055137- 00A2: TDD3F9700 055:137 JLINK_ReadMem (0x080006BC, 0x0002 Bytes, ...) -- Read from flash cache (2 bytes @ 0x080006BC) - Data: FE E7 returns 0x00 (0000ms, 1574ms total) 00-00055137- 005C: TDD3F9700 055:137 JLINK_FindBP(Addr = 0x080006BC) returns 0x00000000 (0000ms, 1574ms total) 00-00055137- 0048: TDD3F9700 055:137 JLINK_GetNumWPs() returns 0x00 (0000ms, 1574ms total) 00-00055137- 0022: ...Target halted (PC = 0x080006BC) 00-00055137- 0007: $T05#b9 00-00055137- 0005: $g#67 00-00055137- 0015: Reading all registers 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R0) returns 0x00000001 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R1) returns 0x080006D4 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R2) returns 0x080006D4 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R3) returns 0x00000001 (0000ms, 1574ms total) 00-00055137- 004E: TDD3F9700 055:137 JLINK_ReadReg(R4) returns 0x200006B4 (0000ms, 1574ms total) 00-00055138- 004E: TDD3F9700 055:137 JLINK_ReadReg(R5) returns 0x2000070C (0001ms, 1575ms total) 00-00055138- 004E: TDD3F9700 055:138 JLINK_ReadReg(R6) returns 0x2000070C (0000ms, 1575ms total) 00-00055138- 004E: TDD3F9700 055:138 JLINK_ReadReg(R7) returns 0x20004FA8 (0000ms, 1575ms total) 00-00055138- 004E: TDD3F9700 055:138 JLINK_ReadReg(R8) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 004E: TDD3F9700 055:138 JLINK_ReadReg(R9) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 004F: TDD3F9700 055:138 JLINK_ReadReg(R10) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 004F: TDD3F9700 055:138 JLINK_ReadReg(R11) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 004F: TDD3F9700 055:138 JLINK_ReadReg(R12) returns 0x20000628 (0000ms, 1575ms total) 00-00055138- 0054: TDD3F9700 055:138 JLINK_ReadReg(R13 (SP)) returns 0x20004FA8 (0000ms, 1575ms total) 00-00055138- 004F: TDD3F9700 055:138 JLINK_ReadReg(R14) returns 0x08000357 (0000ms, 1575ms total) 00-00055138- 0054: TDD3F9700 055:138 JLINK_ReadReg(R15 (PC)) returns 0x080006BC (0000ms, 1575ms total) 00-00055138- 0050: TDD3F9700 055:138 JLINK_ReadReg(XPSR) returns 0x01000000 (0000ms, 1575ms total) 00-00055138- 004F: TDD3F9700 055:138 JLINK_ReadReg(MSP) returns 0x20004FA8 (0000ms, 1575ms total) 00-00055138- 004F: TDD3F9700 055:138 JLINK_ReadReg(PSP) returns 0x802337EC (0000ms, 1575ms total) 00-00055138- 0053: TDD3F9700 055:138 JLINK_ReadReg( PRIMASK) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 0053: TDD3F9700 055:138 JLINK_ReadReg( BASEPRI) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 0055: TDD3F9700 055:138 JLINK_ReadReg( FAULTMASK) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 0053: TDD3F9700 055:138 JLINK_ReadReg( CONTROL) returns 0x00000000 (0000ms, 1575ms total) 00-00055138- 00BC: $01000000d40600 08d406000801000 000b40600200c07 00200c070020a84 f00200000000000 000000000000000 000000028060020 a84f00205703000 8bc060008000000 01a84f0020ec372 380000000000000 000000000000000 00000#3f 00-00055138- 000C: $qTStatus#49 00-00055138- 0004: $#00 00-00055138- 0005: $s#73 00-00055138- 0019: Performing single step...
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
03-00000000-
01-0000000F-
00-0000000F-
03-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
01-0000000F-
00-0000000F-
01-0000000F-
00-0000000F-
03-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
03-00000000-
01-0000000F-
00-0000000F-
03-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
02-00000000-
01-0000000F-
00-0000000F-
01-0000000F-
00-0000000F-
03-00000000-
As you can see, the GDB client issues the single step command, execution halts, but for unknown reasons, the GDB client does not return to the user, but issues another single step command, and so on.
To me, the problem seems to be inside the GDB client.