Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropped 'gdb' connection #348

Closed
4 of 8 tasks
ericashede opened this issue Apr 26, 2022 · 20 comments
Closed
4 of 8 tasks

Dropped 'gdb' connection #348

ericashede opened this issue Apr 26, 2022 · 20 comments
Labels
Milestone

Comments

@ericashede
Copy link

Environment:

OS: Windows 10, 11, MacOS (tried in all)
Visual Studio Code
Native Debug version v0.26.0
OpenOCD session running in background
Hardware ESP32
JTAG hardware ESP-prog

Issue:

My debugging environment stops working after updating to v0.26.0. When starting a session openocd reports gdb session as dropped.
After reverting to v0.25.1 it works as usual.

Copy of launch.json

{
  "version": "0.2.0",
  "configurations": [

    {
      "type": "gdb",
      "request": "launch",
      "name": "Flash and Debug Jlink",
      "target": "./build/ninja-fiw.elf",
      "cwd": "${workspaceFolder}",
      "gdbpath": "xtensa-esp32-elf-gdb",
      "autorun": [
        "target remote :3333",
        "mon reset halt",
        "flushregs",
        "thb app_main",
        "c"
      ]
    }
  ]
}

If submitting a bug please make sure

  • If you are using gdb
    • gdb --version >= 7.7.1
    • it works on the command line with gdb
    • cwd and target are properly set
  • If you are using lldb
    • lldb --version >= 3.7.1
    • it works on the command line with lldb-mi
    • cwd and target are properly set

Screenshots are helpful but not required

@GitMensch
Copy link
Collaborator

GitMensch commented Apr 26, 2022

Thanks for the report, I guess that's an issue with the new startup.

Please report xtensa-esp32-elf-gdb --version and do a run with added "showDevDebugOutput": true,"printCalls": true, this way we can see what the difference is.

Other than this you possibly could try to configure remote debugging instead of the launch option, see https://github.com/WebFreak001/code-debug#using-gdbserver-for-remote-debugging-gdb-only for details.

@GitMensch GitMensch added this to the v0.26.1 milestone Apr 26, 2022
@ericashede
Copy link
Author

xtensa version:

C:\.\.>xtensa-esp32-elf-gdb --version
GNU gdb (crosstool-NG esp-2020r3) 8.1.0.20180627-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-host_w64-mingw32 --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".

Debug console output:

1-gdb-set target-async on
2-list-features
3-environment-directory "C:\\Ninjastep\\ninja-fiw"
4-file-exec-and-symbols "C:\\Ninjastep\\ninja-fiw\\build\\ninja-fiw.elf"
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-added","output":[["id","i1"]]}]}
GDB -> App: {"token":1,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"token":2,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["features",["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","language-option","info-gdb-mi-command","undefined-command-error-code","exec-run-start-option"]]]}}
GDB -> App: {"token":3,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["source-path","C:\\Ninjastep\\ninja-fiw;$cdir;$cwd"]]}}
GDB -> App: {"token":4,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
5-interpreter-exec console "target remote :3333"
6-interpreter-exec console "mon reset halt"
7-interpreter-exec console "flushregs"
8-interpreter-exec console "thb app_main"
9-interpreter-exec console "c"
10-break-insert -f "c:\\Ninjastep\\ninja-fiw\\ninja-core\\impulse_response\\impulse_response.c:88"
11-break-insert -f "c:\\Ninjastep\\ninja-fiw\\ninja-core\\impulse_response\\impulse_response.c:89"
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Remote debugging using :3333\n"}]}
Remote debugging using :3333
12-break-insert -f "c:\\Ninjastep\\ninja-fiw\\main\\main.c:55"
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-started","output":[["id","i1"],["pid","42000"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","1"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"0x4018339a in esp_pm_impl_waiti () at C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c:484\n"}]}
0x4018339a in esp_pm_impl_waiti () at C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c:484
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"484\t    asm(\"waiti 0\");\n"}]}
484	    asm("waiti 0");
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["frame",[["addr","0x4018339a"],["func","esp_pm_impl_waiti"],["args",[]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\pm_esp32.c"],["line","484"]]],["thread-id","1"],["stopped-threads","all"]]}]}
13-thread-info
GDB -> App: {"token":5,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"}]}
JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"}]}
JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
14-thread-info
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu0: Debug controller was reset.\n"}]}
esp32.cpu0: Debug controller was reset.
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu0: Core was reset.\n"}]}
esp32.cpu0: Core was reset.
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu0: Target halted, PC=0x500000CF, debug_reason=00000000\n"}]}
esp32.cpu0: Target halted, PC=0x500000CF, debug_reason=00000000
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu0: Core was reset.\n"}]}
esp32.cpu0: Core was reset.
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu0: Target halted, PC=0x40000400, debug_reason=00000000\n"}]}
esp32.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu1: Debug controller was reset.\n"}]}
esp32.cpu1: Debug controller was reset.
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu1: Core was reset.\n"}]}
esp32.cpu1: Core was reset.
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu1: Target halted, PC=0x40000400, debug_reason=00000000\n"}]}
esp32.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
GDB -> App: {"token":6,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Register cache flushed.\n"}]}
Register cache flushed.
GDB -> App: {"token":7,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Hardware assisted breakpoint 1 at 0x400d84bb: file ../main/main.c, line 52.\n"}]}
Hardware assisted breakpoint 1 at 0x400d84bb: file ../main/main.c, line 52.
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-created","output":[["bkpt",[["number","1"],["type","hw breakpoint"],["disp","del"],["enabled","y"],["addr","0x400d84bb"],["func","app_main"],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"],["thread-groups",["i1"]],["times","0"],["original-location","app_main"]]]]}]}
GDB -> App: {"token":8,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Continuing.\n"}]}
Continuing.
GDB -> App: {"token":9,"outOfBandRecord":[],"resultRecords":{"resultClass":"running","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"running","output":[["thread-id","all"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu0: Detected debug stubs @ 3ffb471c\n"}]}
esp32.cpu0: Detected debug stubs @ 3ffb471c
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu0: Target halted, PC=0x400D84BB, debug_reason=00000001\n"}]}
esp32.cpu0: Target halted, PC=0x400D84BB, debug_reason=00000001
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"Set GDB target to 'esp32.cpu0'\n"}]}
Set GDB target to 'esp32.cpu0'
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"esp32.cpu1: Target halted, PC=0x4018339A, debug_reason=00000000\n"}]}
esp32.cpu1: Target halted, PC=0x4018339A, debug_reason=00000000
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"target","content":"Not full dbg stub table 1 of 2\n"}]}
Not full dbg stub table 1 of 2
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-modified","output":[["bkpt",[["number","1"],["type","hw breakpoint"],["disp","del"],["enabled","y"],["addr","0x400d84bb"],["func","app_main"],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"],["thread-groups",["i1"]],["times","1"],["original-location","app_main"]]]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","2"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[New Thread 1073516140]\n"}]}
[New Thread 1073516140]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","3"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[New Thread 1073514228]\n"}]}
[New Thread 1073514228]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","4"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[New Thread 1073518816]\n"}]}
[New Thread 1073518816]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","5"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[New Thread 1073506448]\n"}]}
[New Thread 1073506448]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","6"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[New Thread 1073412796]\n"}]}
[New Thread 1073412796]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","7"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[New Thread 1073413760]\n"}]}
[New Thread 1073413760]
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-created","output":[["id","8"],["group-id","i1"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[New Thread 1073507620]\n"}]}
[New Thread 1073507620]
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"[Switching to Thread 1073512316]\n"}]}
[Switching to Thread 1073512316]
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"\n"}]}

GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"Thread 1 hit Temporary breakpoint 1, app_main () at ../main/main.c:52\n"}]}
Thread 1 hit Temporary breakpoint 1, app_main () at ../main/main.c:52
GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"52\t  flash_config_init();\n"}]}
52	  flash_config_init();
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"exec","asyncClass":"stopped","output":[["reason","breakpoint-hit"],["disp","del"],["bkptno","1"],["frame",[["addr","0x400d84bb"],["func","app_main"],["args",[]],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["thread-id","1"],["stopped-threads","all"]]}]}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"breakpoint-deleted","output":[["id","1"]]}]}
15-thread-info
GDB -> App: {"token":10,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","2"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x400da038"],["func","sample_task"],["file","../ninja-core/impulse_response/impulse_response.c"],["fullname","c:\\ninjastep\\ninja-fiw\\ninja-core\\impulse_response\\impulse_response.c"],["line","88"],["thread-groups",["i1"]],["times","0"],["original-location","c:\\Ninjastep\\ninja-fiw\\ninja-core\\impulse_response\\impulse_response.c:88"]]]]}}
GDB -> App: {"token":11,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","3"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x400da038"],["func","sample_task"],["file","../ninja-core/impulse_response/impulse_response.c"],["fullname","c:\\ninjastep\\ninja-fiw\\ninja-core\\impulse_response\\impulse_response.c"],["line","89"],["thread-groups",["i1"]],["times","0"],["original-location","c:\\Ninjastep\\ninja-fiw\\ninja-core\\impulse_response\\impulse_response.c:89"]]]]}}
GDB -> App: {"token":12,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["bkpt",[["number","4"],["type","breakpoint"],["disp","keep"],["enabled","y"],["addr","0x400d84c4"],["func","app_main"],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","55"],["thread-groups",["i1"]],["times","0"],["original-location","c:\\Ninjastep\\ninja-fiw\\main\\main.c:55"]]]]}}
GDB -> App: {"token":13,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1073512316"],["details","Name: main, State: Running @CPU0"],["frame",[["level","0"],["addr","0x400d84bb"],["func","app_main"],["args",[]],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["state","stopped"]],[["id","2"],["target-id","Thread 1073516140"],["details","Name: IDLE1, State: Running @CPU1"],["frame",[["level","0"],["addr","0x4018339a"],["func","esp_pm_impl_waiti"],["args",[]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\pm_esp32.c"],["line","484"]]],["state","stopped"]],[["id","3"],["target-id","Thread 1073514228"],["details","Name: IDLE0"],["frame",[["level","0"],["addr","0x4008c7b0"],["func","vPortTaskWrapper"],["args",[[["name","pxCode"],["value","0x0"]],[["name","pvParameters"],["value","0x0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/port.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\port.c"],["line","142"]]],["state","stopped"]],[["id","4"],["target-id","Thread 1073518816"],["details","Name: Tmr Svc"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","5"],["target-id","Thread 1073506448"],["details","Name: ipc1"],["frame",[["level","0"],["addr","0x4008bcf8"],["func","xQueueGenericReceive"],["args",[[["name","xQueue"],["value","0x3ffc6030"]],[["name","pvBuffer"],["value","0x0"]],[["name","xTicksToWait"],["value","<optimized out>"]],[["name","xJustPeeking"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/include/freertos/portable.h"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\include\\freertos\\portable.h"],["line","215"]]],["state","stopped"]],[["id","6"],["target-id","Thread 1073412796"],["details","Name: esp_timer"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","7"],["target-id","Thread 1073413760"],["details","Name: ipc0"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","8"],["target-id","Thread 1073507620"],["details","Name: dport"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
Running executable
16-exec-run
17-stack-info-depth --thread 1
GDB -> App: {"token":14,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1073512316"],["details","Name: main, State: Running @CPU0"],["frame",[["level","0"],["addr","0x400d84bb"],["func","app_main"],["args",[]],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["state","stopped"]],[["id","2"],["target-id","Thread 1073516140"],["details","Name: IDLE1, State: Running @CPU1"],["frame",[["level","0"],["addr","0x4018339a"],["func","esp_pm_impl_waiti"],["args",[]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\pm_esp32.c"],["line","484"]]],["state","stopped"]],[["id","3"],["target-id","Thread 1073514228"],["details","Name: IDLE0"],["frame",[["level","0"],["addr","0x4008c7b0"],["func","vPortTaskWrapper"],["args",[[["name","pxCode"],["value","0x0"]],[["name","pvParameters"],["value","0x0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/port.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\port.c"],["line","142"]]],["state","stopped"]],[["id","4"],["target-id","Thread 1073518816"],["details","Name: Tmr Svc"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","5"],["target-id","Thread 1073506448"],["details","Name: ipc1"],["frame",[["level","0"],["addr","0x4008bcf8"],["func","xQueueGenericReceive"],["args",[[["name","xQueue"],["value","0x3ffc6030"]],[["name","pvBuffer"],["value","0x0"]],[["name","xTicksToWait"],["value","<optimized out>"]],[["name","xJustPeeking"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/include/freertos/portable.h"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\include\\freertos\\portable.h"],["line","215"]]],["state","stopped"]],[["id","6"],["target-id","Thread 1073412796"],["details","Name: esp_timer"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","7"],["target-id","Thread 1073413760"],["details","Name: ipc0"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","8"],["target-id","Thread 1073507620"],["details","Name: dport"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
GDB -> App: {"token":15,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1073512316"],["details","Name: main, State: Running @CPU0"],["frame",[["level","0"],["addr","0x400d84bb"],["func","app_main"],["args",[]],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["state","stopped"]],[["id","2"],["target-id","Thread 1073516140"],["details","Name: IDLE1, State: Running @CPU1"],["frame",[["level","0"],["addr","0x4018339a"],["func","esp_pm_impl_waiti"],["args",[]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\pm_esp32.c"],["line","484"]]],["state","stopped"]],[["id","3"],["target-id","Thread 1073514228"],["details","Name: IDLE0"],["frame",[["level","0"],["addr","0x4008c7b0"],["func","vPortTaskWrapper"],["args",[[["name","pxCode"],["value","0x0"]],[["name","pvParameters"],["value","0x0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/port.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\port.c"],["line","142"]]],["state","stopped"]],[["id","4"],["target-id","Thread 1073518816"],["details","Name: Tmr Svc"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","5"],["target-id","Thread 1073506448"],["details","Name: ipc1"],["frame",[["level","0"],["addr","0x4008bcf8"],["func","xQueueGenericReceive"],["args",[[["name","xQueue"],["value","0x3ffc6030"]],[["name","pvBuffer"],["value","0x0"]],[["name","xTicksToWait"],["value","<optimized out>"]],[["name","xJustPeeking"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/include/freertos/portable.h"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\include\\freertos\\portable.h"],["line","215"]]],["state","stopped"]],[["id","6"],["target-id","Thread 1073412796"],["details","Name: esp_timer"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","7"],["target-id","Thread 1073413760"],["details","Name: ipc0"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","8"],["target-id","Thread 1073507620"],["details","Name: dport"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
GDB -> App: {"token":16,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Don't know how to run.  Try \"help target\"."]]}}
18-thread-info
GDB -> App: {"token":17,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["depth","3"]]}}
19-stack-list-frames --thread 1 0 2
20-stack-info-depth --thread 1
-gdb-exit
GDB -> App: {"token":18,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1073512316"],["details","Name: main, State: Running @CPU0"],["frame",[["level","0"],["addr","0x400d84bb"],["func","app_main"],["args",[]],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["state","stopped"]],[["id","2"],["target-id","Thread 1073516140"],["details","Name: IDLE1, State: Running @CPU1"],["frame",[["level","0"],["addr","0x4018339a"],["func","esp_pm_impl_waiti"],["args",[]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\pm_esp32.c"],["line","484"]]],["state","stopped"]],[["id","3"],["target-id","Thread 1073514228"],["details","Name: IDLE0"],["frame",[["level","0"],["addr","0x4008c7b0"],["func","vPortTaskWrapper"],["args",[[["name","pxCode"],["value","0x0"]],[["name","pvParameters"],["value","0x0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/port.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\port.c"],["line","142"]]],["state","stopped"]],[["id","4"],["target-id","Thread 1073518816"],["details","Name: Tmr Svc"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","5"],["target-id","Thread 1073506448"],["details","Name: ipc1"],["frame",[["level","0"],["addr","0x4008bcf8"],["func","xQueueGenericReceive"],["args",[[["name","xQueue"],["value","0x3ffc6030"]],[["name","pvBuffer"],["value","0x0"]],[["name","xTicksToWait"],["value","<optimized out>"]],[["name","xJustPeeking"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/include/freertos/portable.h"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\include\\freertos\\portable.h"],["line","215"]]],["state","stopped"]],[["id","6"],["target-id","Thread 1073412796"],["details","Name: esp_timer"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","7"],["target-id","Thread 1073413760"],["details","Name: ipc0"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","8"],["target-id","Thread 1073507620"],["details","Name: dport"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
GDB -> App: {"token":19,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["stack",[["frame",[["level","0"],["addr","0x400d84bb"],["func","app_main"],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["frame",[["level","1"],["addr","0x400d40c9"],["func","main_task"],["file","C:/ESP/esp-idf/esp-idf/components/esp32/cpu_start.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\cpu_start.c"],["line","590"]]],["frame",[["level","2"],["addr","0x4008c7b8"],["func","vPortTaskWrapper"],["file","C:/ESP/esp-idf/esp-idf/components/freertos/port.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\port.c"],["line","143"]]]]]]}}
GDB -> App: {"token":20,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["depth","3"]]}}
GDB -> App: {"outOfBandRecord":[],"resultRecords":{"resultClass":"exit","results":[]}}
GDB -> App: {"outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"thread-group-exited","output":[["id","i1"]]}]}
21-stack-list-frames --thread 1 0 2

@WebFreak001
Copy link
Owner

hm this seems like weird output:

Running executable
16-exec-run
17-stack-info-depth --thread 1
GDB -> App: {"token":14,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1073512316"],["details","Name: main, State: Running @CPU0"],["frame",[["level","0"],["addr","0x400d84bb"],["func","app_main"],["args",[]],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["state","stopped"]],[["id","2"],["target-id","Thread 1073516140"],["details","Name: IDLE1, State: Running @CPU1"],["frame",[["level","0"],["addr","0x4018339a"],["func","esp_pm_impl_waiti"],["args",[]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\pm_esp32.c"],["line","484"]]],["state","stopped"]],[["id","3"],["target-id","Thread 1073514228"],["details","Name: IDLE0"],["frame",[["level","0"],["addr","0x4008c7b0"],["func","vPortTaskWrapper"],["args",[[["name","pxCode"],["value","0x0"]],[["name","pvParameters"],["value","0x0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/port.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\port.c"],["line","142"]]],["state","stopped"]],[["id","4"],["target-id","Thread 1073518816"],["details","Name: Tmr Svc"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","5"],["target-id","Thread 1073506448"],["details","Name: ipc1"],["frame",[["level","0"],["addr","0x4008bcf8"],["func","xQueueGenericReceive"],["args",[[["name","xQueue"],["value","0x3ffc6030"]],[["name","pvBuffer"],["value","0x0"]],[["name","xTicksToWait"],["value","<optimized out>"]],[["name","xJustPeeking"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/include/freertos/portable.h"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\include\\freertos\\portable.h"],["line","215"]]],["state","stopped"]],[["id","6"],["target-id","Thread 1073412796"],["details","Name: esp_timer"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","7"],["target-id","Thread 1073413760"],["details","Name: ipc0"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","8"],["target-id","Thread 1073507620"],["details","Name: dport"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
GDB -> App: {"token":15,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["threads",[[["id","1"],["target-id","Thread 1073512316"],["details","Name: main, State: Running @CPU0"],["frame",[["level","0"],["addr","0x400d84bb"],["func","app_main"],["args",[]],["file","../main/main.c"],["fullname","c:\\ninjastep\\ninja-fiw\\main\\main.c"],["line","52"]]],["state","stopped"]],[["id","2"],["target-id","Thread 1073516140"],["details","Name: IDLE1, State: Running @CPU1"],["frame",[["level","0"],["addr","0x4018339a"],["func","esp_pm_impl_waiti"],["args",[]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/pm_esp32.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\pm_esp32.c"],["line","484"]]],["state","stopped"]],[["id","3"],["target-id","Thread 1073514228"],["details","Name: IDLE0"],["frame",[["level","0"],["addr","0x4008c7b0"],["func","vPortTaskWrapper"],["args",[[["name","pxCode"],["value","0x0"]],[["name","pvParameters"],["value","0x0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/port.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\port.c"],["line","142"]]],["state","stopped"]],[["id","4"],["target-id","Thread 1073518816"],["details","Name: Tmr Svc"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","5"],["target-id","Thread 1073506448"],["details","Name: ipc1"],["frame",[["level","0"],["addr","0x4008bcf8"],["func","xQueueGenericReceive"],["args",[[["name","xQueue"],["value","0x3ffc6030"]],[["name","pvBuffer"],["value","0x0"]],[["name","xTicksToWait"],["value","<optimized out>"]],[["name","xJustPeeking"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/freertos/include/freertos/portable.h"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\freertos\\include\\freertos\\portable.h"],["line","215"]]],["state","stopped"]],[["id","6"],["target-id","Thread 1073412796"],["details","Name: esp_timer"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","7"],["target-id","Thread 1073413760"],["details","Name: ipc0"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]],[["id","8"],["target-id","Thread 1073507620"],["details","Name: dport"],["frame",[["level","0"],["addr","0x4008197c"],["func","esp_crosscore_int_send_yield"],["args",[[["name","core_id"],["value","0"]]]],["file","C:/ESP/esp-idf/esp-idf/components/esp32/crosscore_int.c"],["fullname","C:\\ESP\\esp-idf\\esp-idf\\components\\esp32\\crosscore_int.c"],["line","116"]]],["state","stopped"]]]],["current-thread-id","1"]]}}
GDB -> App: {"token":16,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","Don't know how to run.  Try \"help target\"."]]}}

can you also run again with downgradede extension where it works and send the log there?

@brownts
Copy link
Collaborator

brownts commented Apr 27, 2022

My suspicion is that this has to do with the timing changes that occurred between v0.25.1 and v0.26.0. In the previous version we'd try to start running 50ms after the debugger was started. This means, we weren't waiting for the rest of the initialization to complete (i.e., setting breakpoints, etc). My guess is that the run command was executed earlier than it currently is.

According to the normal "target remote mode" (Types of Remote Connections), the run command is not supported. So, it likely shouldn't have worked before, but maybe the target server that this was used with allowed it, or allowed it before a continue command. Anyway, my suspicion is that the run was initiated earlier, possibly before the continue command, was therefore accepted...or at least didn't fail this way.

Looking at the configuration, this really should be described as an attach. I'd recommend starting with the following rewrite of the original configuration and see if that works as expected.

{
  "version": "0.2.0",
  "configurations": [

    {
      "type": "gdb",
      "request": "attach",
      "name": "Flash and Debug Jlink",
      "executable": "./build/ninja-fiw.elf",
      "cwd": "${workspaceFolder}",
      "gdbpath": "xtensa-esp32-elf-gdb",
      "target": ":3333",
      "remote": true,
      "stopAtEntry": "app_main",
      "autorun": [
        "mon reset halt",
        "flushregs"
      ]
    }
  ]
}

@abgironne
Copy link

I have the same problem using the esp32 and I can confirm that using type "attach" instead of type "launch" resolved it for me and everyone here.

@GitMensch
Copy link
Collaborator

MAybe it would be good to inspect the launch configuration at start (we already do this) and when we get a launch inspect the autorun commands for an "attach" or "target" - and in this case create at least a stderr message that this likely should be adjusted to the attach configuration - or better do this with a popup and as the user if we should create a converted configuration...

If any of the windows users doing embedded debugging here could check if using gdb-multiarch from MSYS2 works at least as well a special debugger like xtensa-esp32-elf-gdb, this would be useful.
If it works, then you get the newest stable GDB (currently 12.1) with full python and python based source highlighting support, as well es defaulting to multithreading for reading symbol files which should speedup starting the debugger, too; and can also debug native Windows/Linux/other environments for both 32/64bit programs.

@higaski
Copy link

higaski commented Jul 4, 2022

I can confirm that changing the request to an "attach" also works for xtensa-esp32s3-elf-gdb.

@higaski
Copy link

higaski commented Jul 4, 2022

Well, or not. This is... weird.

I'm currently trying to use the built-in USB JTAG thing the new ESP32S3 chips have.
This works, but only if I start the OpenOCD server as SU. Native-Debug gives me a Failed to get Stack Trace message and then I'm good to go.

bin/openocd -f board/esp32s3-builtin.cfg
Open On-Chip Debugger  v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
Warn : Transport "jtag" was already selected
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: serial (F4:12:FA:42:B0:A8)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 40000 kHz
Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s3.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
Info : esp32s3.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
Info : starting gdb server for esp32s3.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Warn : No symbols for FreeRTOS!
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Set GDB target to 'esp32s3.cpu0'
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 30 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 93 KB
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Auto-detected flash bank 'esp32s3.cpu0.flash' size 8192 KB
Info : Using flash bank 'esp32s3.cpu0.flash' size 8192 KB
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 30 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 93 KB
Info : Using flash bank 'esp32s3.cpu0.irom' size 96 KB
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 30 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 93 KB
Info : Using flash bank 'esp32s3.cpu0.drom' size 32 KB
Info : New GDB Connection: 1, Target esp32s3.cpu0, state: halted
Warn : negative reply, retrying
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
Info : Detected FreeRTOS version: (10.4.3)
Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s3.cpu0: Debug controller was reset.
Info : esp32s3.cpu0: Core was reset.
Info : esp32s3.cpu0: Target halted, PC=0x500000EF, debug_reason=00000000
Info : esp32s3.cpu0: Core was reset.
Info : esp32s3.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
Info : esp32s3.cpu1: Debug controller was reset.
Info : esp32s3.cpu1: Core was reset.
Info : esp32s3.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
Info : esp32s3.cpu1: Debug controller was reset.
Info : esp32s3.cpu1: Core was reset.
Info : esp32s3.cpu0: Target halted, PC=0x42005937, debug_reason=00000001
Info : Set GDB target to 'esp32s3.cpu0'
Info : esp32s3.cpu1: Target halted, PC=0x4037829E, debug_reason=00000000
Info : Detected FreeRTOS version: (10.4.3)

When I start OpenOCD as normal user the log looks exactly the same as when launching it as SU, but connecting GDB with Native-Debug suddenly gives me a could not run message again and then the GDB connection gets dropped.

bin/openocd -f board/esp32s3-builtin.cfg
Open On-Chip Debugger  v0.11.0-esp32-20220411 (2022-04-11-08:47)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
Warn : Transport "jtag" was already selected
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: serial (F4:12:FA:42:B0:A8)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 40000 kHz
Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s3.cpu0: Target halted, PC=0x42005937, debug_reason=00000001
Info : esp32s3.cpu1: Target halted, PC=0x4037829E, debug_reason=00000000
Info : starting gdb server for esp32s3.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Warn : No symbols for FreeRTOS!
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Set GDB target to 'esp32s3.cpu0'
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 30 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 93 KB
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Auto-detected flash bank 'esp32s3.cpu0.flash' size 8192 KB
Info : Using flash bank 'esp32s3.cpu0.flash' size 8192 KB
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 30 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 93 KB
Info : Using flash bank 'esp32s3.cpu0.irom' size 96 KB
Info : esp32s3.cpu0: Target halted, PC=0x403B245E, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3c020020, 30 KB
Info : Flash mapping 1: 0x20020 -> 0x42000020, 93 KB
Info : Using flash bank 'esp32s3.cpu0.drom' size 32 KB
Info : New GDB Connection: 1, Target esp32s3.cpu0, state: halted
Warn : negative reply, retrying
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
Info : Detected FreeRTOS version: (10.4.3)
Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32s3.cpu0: Debug controller was reset.
Info : esp32s3.cpu0: Core was reset.
Info : esp32s3.cpu0: Target halted, PC=0x500000EF, debug_reason=00000000
Info : esp32s3.cpu0: Core was reset.
Info : esp32s3.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
Info : esp32s3.cpu1: Debug controller was reset.
Info : esp32s3.cpu1: Core was reset.
Info : esp32s3.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
Info : dropped 'gdb' connection

@GitMensch
Copy link
Collaborator

Your output says:

Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"

That's likely a good idea, see #330 for the documentation of how this needs to be setup (so far no one has provided a PR to get the missing pieces into README).

In any case - can you please provide the debug console log output from the extension in both cases so we see what is happening on the GDB side?

@higaski
Copy link

higaski commented Jul 4, 2022

In any case - can you please provide the debug console log output from the extension in both cases so we see what is happening on the GDB side?

Well... not really no. Don't get me wrong, I'd like to, I just discovered that changing the tiniest thing in the configuration leads to the GDB connection to get established. So, for example, setting "showDevDebugOutput": true or starting the OpenOCD server from a "preLaunchTask" makes everything work...

Also, even if OpenOCD complains about the GDB connection getting dropped, simply running GDB again by re-running the launch configuration is enough to make it work.

Someone above mentioned something about a timeout or delay... this smells a lot like a timing issue to me.

@GitMensch
Copy link
Collaborator

Someone above mentioned something about a timeout or delay... this smells a lot like a timing issue to me.

Hm, then I suggest to post the log with "showDevDebugOutput": true (which would be expected to work) and one without (which would be expected to fail). Is the output on the gdb server side identical in both cases? Is there a "verbose" / "log" mode in this server to possibly see more?

Any thoughts about using extended-remote?

@higaski
Copy link

higaski commented Jul 4, 2022

Someone above mentioned something about a timeout or delay... this smells a lot like a timing issue to me.

Hm, then I suggest to post the log with "showDevDebugOutput": true (which would be expected to work) and one without (which would be expected to fail). Is the output on the gdb server side identical in both cases? Is there a "verbose" / "log" mode in this server to possibly see more?

Oh I'm sorry. Now I get it. I thought the showDevDebugOutput flag gives me the GDB output. Turns out the extension prints the GDB output to the Debug Console anyhow... I'm just stupid. 😄

Not working. (started OpenOCD manually)

Reading symbols from /home/vinci/Develop/VSCode/ESP32Playground/build/ESP32Playground.elf...
0x4037829e in esp_cpu_wait_for_intr () at /home/vinci/esp/esp-idf/components/xtensa/include/xt_utils.h:81
81	    asm volatile ("waiti 0\n");
[New Thread 1070547120]
[New Thread 1070545232]
[New Thread 1070536052]
[New Thread 1070540500]
[New Thread 1070534676]
[Switching to thread 1 (Thread 1070549008)]
JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
esp32s3.cpu0: Debug controller was reset.
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x500000EF, debug_reason=00000000
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
esp32s3.cpu1: Debug controller was reset.
esp32s3.cpu1: Core was reset.
esp32s3.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
Hardware assisted breakpoint 1 at 0x42005937: file /home/vinci/Develop/VSCode/ESP32Playground/main/main.cpp, line 20.
Register cache flushed.
[Inferior 1 (Remote target) detached]

Working. (started OpenOCD with preLaunchTask)

Reading symbols from /home/vinci/Develop/VSCode/ESP32Playground/build/ESP32Playground.elf...
0x40000400 in ?? ()
JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
esp32s3.cpu0: Debug controller was reset.
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x500000EF, debug_reason=00000000
esp32s3.cpu0: Core was reset.
esp32s3.cpu0: Target halted, PC=0x40000400, debug_reason=00000000
esp32s3.cpu1: Debug controller was reset.
esp32s3.cpu1: Core was reset.
esp32s3.cpu1: Target halted, PC=0x40000400, debug_reason=00000000
Hardware assisted breakpoint 1 at 0x42005937: file /home/vinci/Develop/VSCode/ESP32Playground/main/main.cpp, line 20.
Register cache flushed.
esp32s3.cpu1: Debug controller was reset.
esp32s3.cpu1: Core was reset.
esp32s3.cpu0: Target halted, PC=0x42005937, debug_reason=00000001
Set GDB target to 'esp32s3.cpu0'
esp32s3.cpu1: Target halted, PC=0x4037829E, debug_reason=00000000
[New Thread 1070549008]
[New Thread 1070547120]
[New Thread 1070536052]
[New Thread 1070540500]
[New Thread 1070534676]
[Switching to Thread 1070545232]

Thread 1 "main" hit Temporary breakpoint 1, app_main () at /home/vinci/Develop/VSCode/ESP32Playground/main/main.cpp:20

Any thoughts about using extended-remote?

Well, yes. Switching from this

      "target": ":3333",
      "remote": true

to this

      "target": "extended-remote :3333"

basically works. But again the latter seems to produce timings which result in the initial connection getting dropped...

@brownts
Copy link
Collaborator

brownts commented Jul 4, 2022

@higaski, looking at your logs above, it appears when you run OpenOCD manually, it starts running the inferior before the extension has even finished initialization (seeing that the "[New Thread ...]" lines show up before we've set the "app_main" breakpoint). I'm not familiar with OpenOCD or with your target, so just asking as part of trying to understand what normally happens on startup. I assume the target may start running, but that you issue "monitor reset halt" in the autorun command list to get that under control. If that is the case, I'm surprised that some of the other commands continue to work (setting breakpoints) when the target is running, but maybe for that target, OpenOCD/GDB doesn't have a problem with that.

Look at where the "[New Thread ...]" lines are between the two different logs. When you manually start, those occur much earlier in the log, which means the inferior has started running at that point in time. This happens before we can even set the breakpoint for "app_main" as part of the stopAtEntry configuration. The extension has not told the debugger to run yet, so this must be happening by OpenOCD or something else in that path, not by the extension.

In the second log, you can see the "[New Thread ...]" lines appearing after the breakpoint is set. That is consistent with what I would expect. As part of the stopAtEntry configuration, we issue a breakpoint for "app_main" and then we send a "continue" to the debugger to run the inferior to the breakpoint. The second log looks normal as far as that is concerned.

As far as the disconnect in the first log, I do have a suspicion about what might be happening. As part of the extension's default behavior (unless stopAtConnect is used), the extension tries to run/continue execution. When I looked in the implementation, I don't believe we are necessarily waiting for the autorun commands to complete before we issue the "continue". Therefore, I wonder if our issuing the "continue" may occur while still processing one of the autorun commands.

As an experiment to help prove if this is what is happening, can you make the following changes to your configuration and let me know if this fixes the issue:

  • Remove the "stopAtEntry" configuration option.
  • Add "b app_main" as the last autorun command.
  • Add "stopAtConnect": true to your configuration.

See if when you run this, and then manually continue (by pressing the continue button), if this fixes your problem. If so, this is likely an indication of my suspicion of the extension issuing the "continue" command before all of the autorun commands have finished being processed.

@higaski
Copy link

higaski commented Jul 4, 2022

I've updated the launch config just as you've described and the behavior is exactly as predicted.

@brownts
Copy link
Collaborator

brownts commented Jul 9, 2022

@higaski, I've created an update that hopefully addresses the issue you are having. I'm hoping you can install the attached VSIX to confirm if this fixes your problem. If so, this will get rolled into the next official release. The current set of changes are in my forked branch here.

If you're unsure how to manually install an extension, refer to the Install from a VSIX. Note, you will need to rename the .zip extension to .vsix before following those instructions...apparently Github only allows attachments with certain file extensions and .vsix was not one of them.

debug-0.26.1-beta.0.zip

@higaski
Copy link

higaski commented Jul 10, 2022

Using the old configuration

      "stopAtEntry": "app_main",
      "autorun": [
        "mon reset halt",
        "thb app_main",
        "flushregs"
      ],

this now works yes. The only time I can still trigger the "dropped connection" message is by trying to restart the target (green circle arrow button).

@brownts
Copy link
Collaborator

brownts commented Jul 10, 2022

I'm glad to hear that is working properly now. As for the "restart" scenario, do you have a log for that you can post? Does the "dropped connection" happen at the same spot as the previous scenario? I think the restart is equivalent to hitting the stop button and then relaunching the debug configuration...I assume that sequence works as expected.

@GitMensch
Copy link
Collaborator

Actually there are two options depending on the support the debug extension claims. If it claims it supports a restart then an appropriate command is executed, if it doesn't then dap issues a stop and then a start command.

In both cases it could be that the server side has an issue, especially in the "supported" case if the extension does not execute the autorun commands and/or more are needed for the restart scenario.

@brownts
Copy link
Collaborator

brownts commented Jul 10, 2022

It would also be good to know if the "restart" behavior differs between the use of the "remote" configuration and the "extended remote" configuration. Looking at the internals for handling the disconnect request, it appears for an "extended remote" we send "-target-detach" and for the regular "remote", we just send "-gdb-exit". I wonder if the "dropped connection" only happens with one of these.

@brownts
Copy link
Collaborator

brownts commented Dec 14, 2022

I'm claiming this as fixed with f37ffb2, which is the proposed fix that was successfully verified to address the original issue. Feel free to create a new issue for the "restart" behavior if you are still seeing that problem.

@brownts brownts closed this as completed Dec 14, 2022
@brownts brownts added the bug label Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants