Skip to content

Exit debugging using jlink. MCU unexpectedly paused. #1185

@stbanana

Description

@stbanana

Describe the bug

Using JLink for debugging.

In version 1.13.0-pre8(Latest pre-release), when exiting the debugging mode, the MCU will enter a suspended state.

In version 1.12.1(Latest vscode release), this problem will not occur.

I have confirmed that it is a problem with the gdb server command. But it's not certain whether it's a problem with the JLink server version(JLink_V794f).

To Reproduce
Steps to reproduce the behavior:

  1. Start debug session
  2. Click on 'Continue(F5)'
  3. Click on 'stop(shift + F5)'
  4. MCU stop

Expected behavior

Step.4, It should be running. such as LED flashing.

Environment (please complete the following information):

  • Cortex-Debug Version: 1.13.0-pre8
  • OS: Windows 11
  • GDB Version: JLinkGDBServer V794f

Please include launch.json

    "launch": {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "CMake: Script debugging",
                "type": "cmake",
                "request": "launch",
                "cmakeDebugType": "configure"
            },
            {
                "cwd": "${workspaceRoot}",
                "executable": "./build/AsRemake.elf",
                "name": "Debug with JLink",
                "request": "launch",
                "type": "cortex-debug",
                "device": "STM32H743ZI",
                "rtos": "Azure",
                "runToEntryPoint": "main",
                "showDevDebugOutput": "raw",
                "servertype": "jlink",
                "interface": "swd",
                // "overridePreEndSessionCommands": [
                //     "interpreter-exec console \"monitor go\""
                // ],
                "svdFile": "./5_PhysicalChip/CPU/STM32H743.svd",
                "liveWatch": {
                    "enabled": true,
                    "samplesPerSecond": 4
                },
                "rttConfig": {
                    "enabled": true,
                    "address": "auto",
                    "decoders": [
                        {
                            "label": "",
                            "port": 0,
                            "type": "console"
                        }
                    ]
                }
            }
    }

Attach text from Debug Console

In click stop

Debug Console

-> =thread-created,id="14",group-id="i1"
-> ~"[New Thread 604096688]\n"
[New Thread 604096688]
-> ~"\nThread "

Thread
-> ~"3 received signal SIGTRAP, Trace/breakpoint trap.\n"
3 received signal SIGTRAP, Trace/breakpoint trap.
-> ~"[Switching to Thread 603980548]\n"
[Switching to Thread 603980548]
-> ~"__tx_ts_wait () at E:\STM32_PROJECT\25_11_17_ASREMAKE\src\6_Rtos\threadx\ports_module\cortex_m7\gnu\module_manager\src\tx_thread_schedule.S:367\n"
__tx_ts_wait () at E:\STM32_PROJECT\25_11_17_ASREMAKE\src\6_Rtos\threadx\ports_module\cortex_m7\gnu\module_manager\src\tx_thread_schedule.S:367
-> ~"367\t B __tx_ts_wait // Loop to continue waiting\n"
367 B __tx_ts_wait // Loop to continue waiting
-> *stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",frame={addr="0x0802425a",func="__tx_ts_wait",args=[],file="E:\STM32_PROJECT\25_11_17_ASREMAKE\src\6_Rtos\threadx\ports_module\cortex_m7\gnu\module_manager\src\tx_thread_schedule.S",fullname="E:\STM32_PROJECT\25_11_17_ASREMAKE\src\6_Rtos\threadx\ports_module\cortex_m7\gnu\module_manager\src\tx_thread_schedule.S",line="367",arch="armv7e-m"},thread-id="3",stopped-threads="all"
mi2.status = stopped
LiveGDB: 103-target-detach
LiveGDB: -> =thread-exited,id="1",group-id="i1"
LiveGDB: -> =thread-group-exited,id="i1"
LiveGDB: -> ~"[Inferior 1 (Remote target) detached]\n"
LiveGDB: [Inferior 1 (Remote target) detached]
LiveGDB: -> 103^done
LiveGDB: 104-interpreter-exec console "monitor exit"
LiveGDB: -> &"Target does not support this command.\n"
LiveGDB: Target does not support this command.
LiveGDB: -> 104^error,msg="Target does not support this command."
38-break-delete
-> 38^done
39-interpreter-exec console "monitor exit"
-> &"Target does not support this command.\n"
Target does not support this command.
-> 39^error,msg="Target does not support this command."
LiveGDB: 105-var-update --all-values *
LiveGDB: -> 105^done,changelist=[]
LiveGDB: 106-var-update --all-values *
LiveGDB: -> 106^done,changelist=[]
LiveGDB: kill failed for -22704Error: kill ESRCH
kill failed for -34920Error: kill ESRCH
GDB session ended. exit-code: -1

gdb-server terminal

Azure RTOS: thread[11].name: NetX IP Instance 0
Azure RTOS: thread[11].state: 0x7
Azure RTOS: 'current' thread: 0x24000304
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0xBC010024
Read register 'r1' (4 bytes) from hardware: 0x00000000
Read register 'r2' (4 bytes) from hardware: 0xC0010024
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0xF8070024
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0x30220324
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0xEC210324
Read register 'sp' (4 bytes) from hardware: 0x98130020
Read register 'lr' (4 bytes) from hardware: 0xFDFFFFFF
Read register 'pc' (4 bytes) from hardware: 0x5A420208
Read register 'xpsr' (4 bytes) from hardware: 0x0E000021
Read 4 bytes @ address 0x0802425A (Data = 0xF04FE7FA)
Read 2 bytes @ address 0x0802425A (Data = 0xE7FA)
WARNING: Unsupported remote command "exit"
WARNING: Unsupported remote command "exit"
[2026-01-21T06:56:42.874Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...

Additional context

A temporary solution is to add(above explanatory part)

      "overridePreEndSessionCommands": [
          "interpreter-exec console \"monitor go\""
      ],

In version 1.12.1(Latest vscode release).Everything is good.

In click stop

Debug Console

LiveGDB: -> ~"[Inferior 1 (Remote target) detached]\n"
LiveGDB: [Inferior 1 (Remote target) detached]
LiveGDB: -> 24^done
35-break-delete
LiveGDB: 25-target-disconnect
-> 35^done
LiveGDB: -> 25^done
LiveGDB: 26-var-update  --all-values *
LiveGDB: -> 26^done,changelist=[]
36-target-disconnect
-> =thread-exited,id="3",group-id="i1"
-> =thread-exited,id="4",group-id="i1"
-> =thread-exited,id="5",group-id="i1"
-> =thread-exited,id="6",group-id="i1"
-> =thread-exited,id="7",group-id="i1"
-> =thread-exited,id="8",group-id="i1"
-> =thread-exited,id="9",group-id="i1"
-> =thread-exited,id="10",group-id="i1"
-> =thread-exited,id="11",group-id="i1"
-> =thread-exited,id="12",group-id="i1"
-> =thread-exited,id="13",group-id="i1"
-> =thread-exited,id="14",group-id="i1"
-> =thread-group-exited,id="i1"
-> 36^done
LiveGDB: -gdb-exit
LiveGDB: -> ^exit
-gdb-exit
-> ^exit

gdb-server terminal

Azure RTOS: thread[11].state: 0x0
Azure RTOS: 'current' thread: 0x2401c8b0
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x69090000
Read register 'r1' (4 bytes) from hardware: 0x01000000
Read register 'r2' (4 bytes) from hardware: 0x69090000
Read register 'r3' (4 bytes) from hardware: 0xB8BF0324
Read register 'r4' (4 bytes) from hardware: 0x4CB40124
Read register 'r5' (4 bytes) from hardware: 0xEC5D0908
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0xE4B30124
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x04000000
Read register 'sp' (4 bytes) from hardware: 0xE4B30124
Read register 'lr' (4 bytes) from hardware: 0x2D540808
Read register 'pc' (4 bytes) from hardware: 0x66A40608
Read register 'xpsr' (4 bytes) from hardware: 0x00000081
Read 4 bytes @ address 0x0806A466 (Data = 0x4618681B)
GDB closed TCP/IP connection (Socket 2100)
GDB closed TCP/IP connection (Socket 1160)
Restoring target state and closing J-Link connection...
Shutting down...
[2026-01-21T07:39:50.518Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions