microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.51k stars 1.55k forks source link

Remote Debugging of ESP32 causes EXCEPTION: System.ArgumentOutOfRangeException #763

Closed gojimmypi closed 3 years ago

gojimmypi commented 7 years ago

I'm trying to use VSCode on Windows to remote debug the ESP32 using Olimex ARM-USB-OCD-H JTAG debugger connected to a Linux (Ubuntu) server that is running espressif openocd. The binaries are compiled on the Ubuntu server. The local Windows machine has a the xtensa gdb client that (in theory) should be able to single-step debug the ESP32 when connecting to the remote OpenOCD server. Instead, an error occurs.

This is my launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "OpenOCD Debug",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerPath": "C:/msys32/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe",
            "miDebuggerServerAddress": "192.168.174.129:3333",
            "program": "Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "text": "file 'Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf'"
                },
                {
                    "text": "target remote 192.168.174.129:3333"
                },
                {
                    "text": "monitor reset init"
                }
            ],
            "externalConsole": false,
            "cwd": "Z:/home/gojimmypi/esp/hello_world/build/",
            "logging": {
                "trace": true,
                "traceResponse": true,
                "engineLogging": true
            }
        }
    ]
}

Note that my Z: drive on Windows is mapped to the root of the Ubuntu file system (running samba there).

When I press F5 to debug, this output appears on the OpenOCD session:

gojimmypi@ubuntu : ~/workspace/ESP32/openocd/scripts
0 $ sudo openocd -f interface/ftdi/olimex-arm-usb-ocd-h-1MHz.cfg -c "transport select jtag"  -f target/ESP32-RTOS-none.cfg
Open On-Chip Debugger 0.10.0-dev-g372bb59 (2017-05-19-10:35)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
jtag
force hard breakpoints
Info : clock speed 1000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32.cpu0: Target halted, pc=0x40000400
Info : accepting 'gdb' connection on tcp/3333
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32.cpu0: Target halted, pc=0x40000400
esp32.cpu0: target state: halted
Error: timed out while waiting for target halted
TARGET: esp32.cpu1 - Not halted
in procedure 'reset'
in procedure 'ocd_bouncer'

Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Info : dropped 'gdb' connection

The line Info : esp32.cpu0: Target halted, pc=0x40000400 is the last displayed before gdb debugging begins. Shown below is the debug console output in VSCode. Note EXCEPTION: System.ArgumentOutOfRangeException

1: (149) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (158) LaunchOptions  ExePath='Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf'
1: (158) LaunchOptions  WorkingDirectory='Z:\home\gojimmypi\esp\hello_world\build\'
1: (158) LaunchOptions  ExeArguments=''
1: (158) LaunchOptions  MIDebuggerPath='C:/msys32/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe'
1: (158) LaunchOptions  WaitDynamicLibLoad='false'
1: (158) LaunchOptions  MIDebuggerServerAddress='192.168.174.129:3333'
1: (158) LaunchOptions>
1: (158) LaunchOptions    <SetupCommands>
1: (159) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (159) LaunchOptions        <Command IgnoreFailures='false' Description=''>file 'Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf'</Command>
1: (159) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote 192.168.174.129:3333</Command>
1: (159) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (159) LaunchOptions    </SetupCommands>
1: (159) LaunchOptions</LocalLaunchOptions>
1: (292) Starting: "C:/msys32/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe" --interpreter=mi
1: (304) DebuggerPid=7928
1: (335) ->=thread-group-added,id="i1"
1: (336) ->~"GNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10\n"
1: (336) ->~"Copyright (C) 2015 Free Software Foundation, Inc.\n"
1: (336) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (336) ->~"This GDB was configured as \"--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf\".\nType \"show configuration\" for configuration details."
1: (336) ->~"\nFor bug reporting instructions, please see:\n"
1: (336) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (336) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (336) ->~"For help, type \"help\".\n"
1: (336) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (336) ->(gdb)
1: (341) <-1001-gdb-set target-async on
1: (346) ->1001^done
1: (346) ->(gdb)
1: (347) 1001: elapsed time 5
1: (352) <-1002-enable-pretty-printing
1: (357) ->1002^done
1: (357) ->(gdb)
1: (357) 1002: elapsed time 4
1: (359) <-1003-interpreter-exec console "file 'Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf'"
1: (373) ->~"Reading symbols from Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf..."
1: (399) ->~"done.\n"
1: (400) ->1003^done
1: (400) ->(gdb)
1: (401) 1003: elapsed time 41
1: (401) <-1004-interpreter-exec console "target remote 192.168.174.129:3333"
1: (428) ->~"Remote debugging using 192.168.174.129:3333\n"
1: (429) ->=thread-group-started,id="i1",pid="42000"
1: (430) ->=thread-created,id="1",group-id="i1"
1: (433) ->~"0x40000400 in ?? ()\n"
1: (433) ->*stopped,frame={addr="0x40000400",func="??",args=[]},thread-id="1",stopped-threads="all"
1: (433) ->1004^done
1: (433) ->(gdb)
1: (445) 1004: elapsed time 44
1: (445) <-1005-thread-info 1
1: (453) ->1005^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x40000400",func="??",args=[]},state="stopped"}]
1: (453) ->(gdb)
1: (454) 1005: elapsed time 9
1: (454) <-1006-interpreter-exec console "monitor reset init"
E thread: {"reason":"started","threadId":-2,"type":"thread"}
1: (491) ->@"JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
1: (491) ->@"JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
1: (502) ->@"esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).\n"
1: (549) ->@"esp32.cpu0: Target halted, pc=0x40000400\n"
1: (564) ->@"esp32.cpu0: target state: halted\n"
1: (1573) ->@"timed out while waiting for target halted\n"
1: (1573) ->@"TARGET: esp32.cpu1 - Not halted\n"
1: (1574) ->@"in procedure 'reset' \n"
1: (1574) ->@"in procedure 'ocd_bouncer'\n"
1: (1574) ->@"\n"
1: (1574) ->@"\n"
1: (1585) ->1006^done
1: (1585) ->(gdb)
1: (1585) 1006: elapsed time 1131
1: (1585) <-1007-gdb-set solib-search-path Z:/home/gojimmypi/esp/hello_world/build;
1: (1600) ->1007^done
1: (1600) ->(gdb)
1: (1600) 1007: elapsed time 15
1: (1600) <-1008-environment-cd Z:\\home\\gojimmypi\\esp\\hello_world\\build\\
1: (1610) ->1008^done
1: (1610) ->(gdb)
1: (1610) 1008: elapsed time 10
1: (1610) <-1009-interpreter-exec console "show configuration"
1: (1620) ->~"This GDB was configured as follows:\n   configure --host=i686-host_pc-mingw32 --target=xtensa-esp32-elf\n"
1: (1620) ->~"             --with-auto-load-dir=$debugdir:$datadir/auto-load\n             --with-auto-load-safe-path=$debugdir:$datadir/auto-load\n"
1: (1620) ->~"             --with-expat\n"
1: (1620) ->~"             --with-gdb-datadir=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/share/gdb (relocatable)\n"
1: (1620) ->~"             --with-jit-reader-dir=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/lib/gdb (relocatable)\n"
1: (1620) ->~"             --without-libunwind-ia64\n"
1: (1620) ->~"             --without-lzma\n"
1: (1620) ->~"             --without-guile\n"
1: (1620) ->~"             --with-separate-debug-dir=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/lib/debug (relocatable)\n"
1: (1620) ->~"             --with-sysroot=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf/sysroot (relocatable)\n"
1: (1620) ->~"             --without-babeltrace\n"
1: (1620) ->~"\n(\"Relocatable\" means the directory can be moved with the GDB installation\ntree, and GDB will still find it.)\n"
1: (1620) ->1009^done
1: (1620) ->(gdb)
1: (1620) 1009: elapsed time 10
E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/MIEngine/WindowsRuntime","data":{"VS.Diagnostics.Debugger.MIEngine.WindowsRuntime":"MinGW"},"type":"output"}
1: (1623) <-1010-file-exec-and-symbols Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf
1: (1647) ->1010^done
1: (1647) ->(gdb)
1: (1647) 1010: elapsed time 24
1: (1647) <-1011-interpreter-exec console "show architecture"
1: (1657) ->~"The target architecture is set automatically (currently xtensa)\n"
1: (1657) ->1011^done
1: (1657) ->(gdb)
1: (1657) 1011: elapsed time 10
1: (1658) <-1012-break-insert main
1: (1674) ->1012^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x400f4ab0",func="main",file="/home/gojimmypi/esp/hello_world/main/./hello_world_main.c",fullname="Z:\\home\\gojimmypi\\esp\\hello_world\\main\\hello_world_main.c",line="15",thread-groups=["i1"],times="0",original-location="main"}
1: (1674) ->(gdb)
1: (1675) 1012: elapsed time 17
1: (1675) <-1013-target-select remote 192.168.174.129:3333
1: (1685) ->=thread-group-exited,id="i1"
1: (1696) <-logout
E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/NonFatalError","data":{"VS.Diagnostics.Debugger.NonFatalError.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.NonFatalError.ExceptionType":"System.ArgumentOutOfRangeException","VS.Diagnostics.Debugger.NonFatalError.ExceptionStack":"   at OpenDebugAD7.AD7Impl.AD7Port.RemoveProcess(IDebugProcess2 process)\r\n   at OpenDebugAD7.AD7DebugSession.<.ctor>b__34_8(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, IDebugEvent2 eventObject)\r\n   at OpenDebugAD7.AD7DebugSession.Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, IDebugEvent2 eventObject, Guid& riidEvent, UInt32 dwAttrib)\r\n   at Microsoft.MIDebugEngine.EngineCallback.Send(IDebugEvent2 eventObject, String iidEvent, IDebugProgram2 program, IDebugThread2 thread)\r\n   at Microsoft.MIDebugEngine.EngineCallback.OnProcessExit(UInt32 exitCode)\r\n   at Microsoft.MIDebugEngine.DebuggedProcess.<>c__DisplayClass53_0.<.ctor>b__3(Object o, EventArgs args)\r\n   at System.EventHandler.Invoke(Object sender, EventArgs e)\r\n   at MICore.Debugger.OnDebuggerProcessExit(String exitCode)\r\n   at MICore.Debugger.OnStateChanged(String mode, Results results)\r\n   at MICore.Debugger.OnStateChanged(String mode, String strresult)\r\n   at MICore.Debugger.OnResult(String cmd, String token)\r\n   at MICore.Debugger.ProcessStdOutLine(String line)\r\n   at Microsoft.MIDebugEngine.DebuggedProcess.<>c__DisplayClass74_0.<ScheduleStdOutProcessing>b__0()\r\n   at Microsoft.MIDebugEngine.WorkerThread.ThreadFunc()","VS.Diagnostics.Debugger.NonFatalError.HResult":-2146233086,"VS.Diagnostics.Debugger.EngineVersion":"14.0.40306.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.HostVersion":"1.0.30301.1"},"type":"output"}
1: (1705) EXCEPTION: System.ArgumentOutOfRangeException
1: (1705) EXCEPTION:    at OpenDebugAD7.AD7Impl.AD7Port.RemoveProcess(IDebugProcess2 process)
1: (1705) EXCEPTION:    at OpenDebugAD7.AD7DebugSession.<.ctor>b__34_8(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, IDebugEvent2 eventObject)
1: (1705) EXCEPTION:    at OpenDebugAD7.AD7DebugSession.Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, IDebugEvent2 eventObject, Guid& riidEvent, UInt32 dwAttrib)
1: (1705) EXCEPTION:    at Microsoft.MIDebugEngine.EngineCallback.Send(IDebugEvent2 eventObject, String iidEvent, IDebugProgram2 program, IDebugThread2 thread)
1: (1705) EXCEPTION:    at Microsoft.MIDebugEngine.EngineCallback.OnProcessExit(UInt32 exitCode)
1: (1705) EXCEPTION:    at Microsoft.MIDebugEngine.DebuggedProcess.<>c__DisplayClass53_0.<.ctor>b__3(Object o, EventArgs args)
1: (1705) EXCEPTION:    at System.EventHandler.Invoke(Object sender, EventArgs e)
1: (1705) EXCEPTION:    at MICore.Debugger.OnDebuggerProcessExit(String exitCode)
1: (1705) EXCEPTION:    at MICore.Debugger.OnStateChanged(String mode, Results results)
1: (1705) EXCEPTION:    at MICore.Debugger.OnStateChanged(String mode, String strresult)
1: (1705) EXCEPTION:    at MICore.Debugger.OnResult(String cmd, String token)
1: (1705) EXCEPTION:    at MICore.Debugger.ProcessStdOutLine(String line)
1: (1705) EXCEPTION:    at Microsoft.MIDebugEngine.DebuggedProcess.<>c__DisplayClass74_0.<ScheduleStdOutProcessing>b__0()
1: (1705) EXCEPTION:    at Microsoft.MIDebugEngine.WorkerThread.ThreadFunc()
1: (1707) <--gdb-exit
 R: {"success":false,"message":"Unable to start debugging. GDB exited unexpectedly.","request_seq":2,"command":"launch","body":{"error":{"id":1104,"format":"Unable to start debugging. GDB exited unexpectedly.","variables":null}},"running":false,"refs":null,"seq":0,"type":"response"}
C threads: null
 R: {"success":true,"message":null,"request_seq":3,"command":"threads","body":{"threads":[{"id":-2,"name":"Thread #-2"}]},"running":false,"refs":null,"seq":0,"type":"response"}
C disconnect: {"restart":false}
 R: {"success":true,"message":null,"request_seq":4,"command":"disconnect","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

My VSCode version:

[Window Title]
Visual Studio Code
[Main Instruction]
Visual Studio Code
[Content]
Version 1.12.2
Commit 19222cdc84ce72202478ba1cec5cb557b71163de
Date 2017-05-10T13:20:36.315Z
Shell 1.6.6
Renderer 56.0.2924.87
Node 7.4.0
[OK]

The target code is the FreeRTOS "hello world" Espressif sample - that needed to be modified a bit as VSCode was complaining that there was no void main(), so I added a little wrapper to appease it. I also disabled the reset with a simple loop.

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"

int main() {
    while (1 == 1)
    {

        printf("Hello world!\n");

        /* Print chip information */
        esp_chip_info_t chip_info;
        esp_chip_info(&chip_info);
        printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
               chip_info.cores,
               (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
               (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");

        printf("silicon revision %d, ", chip_info.revision);

        printf("%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024),
               (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");

        for (int i = 10; i >= 0; i--)
        {
            printf("Looping in %d seconds...\n", i);
            vTaskDelay(1000 / portTICK_PERIOD_MS);
        }
        printf("Looping now.\n");
        fflush(stdout);
    }

}

void app_main()
{
    main();
}

After this error, the ESP32 seems to be unstable and needs to be reset. I was able to otherwise successfully use the GDB client on Linux.

pieandcakes commented 7 years ago

@gojimmypi Can you either remove the target remote call or the miDebuggerServerAddress? I think its trying to do it twice and the second is causing gdb to terminate the program which hasn't started running yet, causing the crash.

gojimmypi commented 7 years ago

@pieandcakes thanks - I appreciate your response. That suggestion helped quite a bit (I probably would have never guessed that on my own) but there's still some sort of problem. I commented out the miDebuggerServerAddress line and the most serious exception error went away. However, debugging in VSCode is still not working. Close, but not there. Perhaps I only need to know the value for TargetArchitecture.

the xtensa gdb works in DOS (the same Windows 10 machine that we're talking about with VSCode, and the same exe configured in miDebuggerPath)

Z:\home\gojimmypi\esp\hello_world\build>C:\msys32\opt\xtensa-esp32-elf\bin\xtensa-esp32-elf-gdb.exe hello-world.elf
GNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10
Copyright (C) 2015 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=i686-host_pc-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"...
Reading symbols from hello-world.elf...done.
(gdb)  target remote 192.168.174.129:3333
Remote debugging using 192.168.174.129:3333
prvIdleTask (pvParameters=0x0) at /home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c:3270
3270                    prvCheckTasksWaitingTermination();
(gdb) n
esp32.cpu0: Target halted, pc=0x40084938
esp32.cpu0: Target halted, pc=0x400849BE
3319                            esp_vApplicationIdleHook();
(gdb) n
esp32.cpu0: Target halted, pc=0x400D1274
esp32.cpu0: Target halted, pc=0x400849C1
esp32.cpu0: Target halted, pc=0x400849BB
3270                    prvCheckTasksWaitingTermination();

as well as on the Linux machine:

gojimmypi@ubuntu : ~/esp/hello_world/build
0 $ xtensa-esp32-elf-gdb  hello-world.elf
GNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10
Copyright (C) 2015 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-build_pc-linux-gnu --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"...
Reading symbols from hello-world.elf...done.
(gdb)  target remote 192.168.174.129:3333
Remote debugging using 192.168.174.129:3333
0x400d129c in esp_vApplicationIdleHook () at /home/gojimmypi/esp/esp-idf/components/esp32/./freertos_hooks.c:52
52              asm("waiti 0");
(gdb) n
esp32.cpu0: Target halted, pc=0x400849C1
esp32.cpu0: Target halted, pc=0x400849BB
prvIdleTask (pvParameters=0x0) at /home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c:3270
3270                    prvCheckTasksWaitingTermination();
(gdb) quit
A debugging session is active.

        Inferior 1 [Remote target] will be detached.

Quit anyway? (y or n) y
Detaching from program: /home/gojimmypi/esp/hello_world/build/hello-world.elf, Remote target
Ending remote debugging.
gojimmypi@ubuntu : ~/esp/hello_world/build

however from GDB, it starts out exiting as if it is paused, but then there's an error and GDB disconnects.

The problem here was buried in the logs: Warning: Debuggee TargetArchitecture not detected, assuming x86_64. Feature request to auto-detect hardware :) So I added another line "targetArchitecture": "xtensa" but that fails, too:

1: (155) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (162) LaunchOptions  ExePath='Z:\home\gojimmypi\esp\hello_world\build\hello-world.elf'
1: (162) LaunchOptions  WorkingDirectory='Z:\home\gojimmypi\esp\hello_world\build\'
1: (162) LaunchOptions  TargetArchitecture='xtensa'
1: (162) LaunchOptions  ExeArguments=''
1: (162) LaunchOptions  MIDebuggerPath='C:/msys32/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe'
1: (162) LaunchOptions  WaitDynamicLibLoad='false'
1: (162) LaunchOptions>
1: (162) LaunchOptions    <SetupCommands>
1: (163) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (163) LaunchOptions        <Command IgnoreFailures='false' Description=''>file 'Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf'</Command>
1: (163) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote 192.168.174.129:3333</Command>
1: (163) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (163) LaunchOptions    </SetupCommands>
1: (163) LaunchOptions</LocalLaunchOptions>
 R: {"success":false,"message":"Unable to start debugging. Launch options string provided by the project system is invalid. Instance validation error: 'xtensa' is not a valid value for TargetArchitecture.","request_seq":2,"command":"launch","body":{"error":{"id":1104,"format":"Unable to start debugging. Launch options string provided by the project system is invalid. Instance validation error: 'xtensa' is not a valid value for TargetArchitecture.","variables":null}},"running":false,"refs":null,"seq":0,"type":"response"}
C disconnect: {"restart":false}
 R: {"success":true,"message":null,"request_seq":3,"command":"disconnect","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

I also tried "targetArchitecture": "xtensa-esp32" - same result. As well as extensa-esp32-elf, esp32, espressif, espressif-esp32. Do you know what value should go here?

Note that I found issue 303 on the espressif site that makes no mention of TargetArchitecture (and perhaps I should be asking this question there?)

https://github.com/espressif/esp-idf/issues/303

*edit: formatting

pieandcakes commented 7 years ago

@gojimmypi Yea,xtensa is not a supported architecture from our point of view. This is what we support: https://github.com/Microsoft/MIEngine/blob/release-cpptools/src/MICore/LaunchOptions.cs#L1519 If you don't specify it, can you provide a log? I think the architecture error might not be the problem.

Also, we use gdb's MI interpreter. you can try it from the command line and pass the same commands we do by starting gdb with --interpreter=MI from your commandline and then issuing the corresponding MI commands if you want to verify that the version of gdb you are using has the correct implementations we need.

gojimmypi commented 7 years ago

Yea,xtensa is not a supported architecture from our point of view

@pieandcakes oh, that's a bummer. I've added extensa as a feature request in issue #772 :)

As for the log: I first confirmed command-line gdb working properly... then exit from that & try to F5 in VSCode. Here's the full log, first what happens in openocd:

0 $ sudo openocd -f interface/ftdi/olimex-arm-usb-ocd-h-1MHz.cfg -c "transport select jtag"  -f target/ESP32-RTOS-none.cfg
Open On-Chip Debugger 0.10.0-dev-g372bb59 (2017-05-19-10:35)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
jtag
force hard breakpoints
Info : clock speed 1000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32.cpu0: Target halted, pc=0x400849BB
Info : accepting 'gdb' connection on tcp/3333
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).
Info : esp32.cpu0: Target halted, pc=0x40000400
esp32.cpu0: target state: halted
Error: timed out while waiting for target halted
TARGET: esp32.cpu1 - Not halted
in procedure 'reset'
in procedure 'ocd_bouncer'

Info : esp32.cpu0: placed hw breakpoint 0 at 0x400F4BF4
Info : esp32.cpu0: Target halted, pc=0x40080E74
Info : esp32.cpu0: cleared hw breakpoint 0 at 0x400F4BF4

and the full debug log in VSCode (sorry it is so long, but ya - this whole log just from F5)

1: (149) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (155) LaunchOptions  ExePath='Z:\home\gojimmypi\esp\hello_world\build\hello-world.elf'
1: (155) LaunchOptions  WorkingDirectory='Z:\home\gojimmypi\esp\hello_world\build\'
1: (156) LaunchOptions  ExeArguments=''
1: (156) LaunchOptions  MIDebuggerPath='C:/msys32/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe'
1: (156) LaunchOptions  WaitDynamicLibLoad='false'
1: (156) LaunchOptions>
1: (156) LaunchOptions    <SetupCommands>
1: (156) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>
1: (156) LaunchOptions        <Command IgnoreFailures='false' Description=''>file 'Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf'</Command>
1: (156) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote 192.168.174.129:3333</Command>
1: (156) LaunchOptions        <Command IgnoreFailures='false' Description=''>monitor reset init</Command>
1: (156) LaunchOptions    </SetupCommands>
1: (156) LaunchOptions</LocalLaunchOptions>
1: (297) Starting: "C:/msys32/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe" --interpreter=mi
1: (306) DebuggerPid=19392
1: (336) ->=thread-group-added,id="i1"
1: (337) ->~"GNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10\n"
1: (337) ->~"Copyright (C) 2015 Free Software Foundation, Inc.\n"
1: (337) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
1: (337) ->~"This GDB was configured as \"--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf\".\nType \"show configuration\" for configuration details."
1: (337) ->~"\nFor bug reporting instructions, please see:\n"
1: (337) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"
1: (337) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"
1: (337) ->~"For help, type \"help\".\n"
1: (337) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (337) ->(gdb)
1: (343) <-1001-gdb-set target-async on
1: (347) ->1001^done
1: (347) ->(gdb)
1: (348) 1001: elapsed time 5
1: (354) <-1002-enable-pretty-printing
1: (357) ->1002^done
1: (357) ->(gdb)
1: (357) 1002: elapsed time 3
1: (359) <-1003-interpreter-exec console "file 'Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf'"
1: (372) ->~"Reading symbols from Z:/home/gojimmypi/esp/hello_world/build/hello-world.elf..."
1: (393) ->~"done.\n"
1: (395) ->1003^done
1: (395) ->(gdb)
1: (395) 1003: elapsed time 35
1: (396) <-1004-interpreter-exec console "target remote 192.168.174.129:3333"
1: (414) ->~"Remote debugging using 192.168.174.129:3333\n"
1: (416) ->=thread-group-started,id="i1",pid="42000"
1: (416) ->=thread-created,id="1",group-id="i1"
1: (429) ->~"prvIdleTask (pvParameters=0x0) at /home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c:3270\n"
1: (430) ->&"3270\t/home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c: No such file or directory.\n"
1: (430) ->*stopped,frame={addr="0x400849bb",func="prvIdleTask",args=[{name="pvParameters",value="0x0"}],file="/home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c",fullname="/home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c",line="3270"},thread-id="1",stopped-threads="all"
1: (430) ->1004^done
1: (431) ->(gdb)
1: (436) 1004: elapsed time 40
1: (436) <-1005-thread-info 1
1: (441) ->1005^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x400849bb",func="prvIdleTask",args=[{name="pvParameters",value="0x0"}],file="/home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c",fullname="/home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c",line="3270"},state="stopped"}]
1: (441) ->(gdb)
1: (441) 1005: elapsed time 5
1: (441) <-1006-interpreter-exec console "monitor reset init"
E thread: {"reason":"started","threadId":-2,"type":"thread"}
1: (485) ->@"JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
1: (485) ->@"JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)\n"
1: (496) ->@"esp32.cpu0: Core was reset (pwrstat=0x1F, after clear 0x0F).\n"
1: (546) ->@"esp32.cpu0: Target halted, pc=0x40000400\n"
1: (562) ->@"esp32.cpu0: target state: halted\n"
1: (1569) ->@"timed out while waiting for target halted\n"
1: (1570) ->@"TARGET: esp32.cpu1 - Not halted\n"
1: (1570) ->@"in procedure 'reset' \n"
1: (1570) ->@"in procedure 'ocd_bouncer'\n"
1: (1570) ->@"\n"
1: (1570) ->@"\n"
1: (1581) ->1006^done
1: (1581) ->(gdb)
1: (1581) 1006: elapsed time 1140
1: (1581) <-1007-gdb-set solib-search-path Z:\\home\\gojimmypi\\esp\\hello_world\\build;
1: (1601) ->1007^done
1: (1601) ->(gdb)
1: (1601) 1007: elapsed time 20
1: (1601) <-1008-environment-cd Z:\\home\\gojimmypi\\esp\\hello_world\\build\\
1: (1611) ->1008^done
1: (1611) ->(gdb)
1: (1611) 1008: elapsed time 10
1: (1611) <-1009-interpreter-exec console "show configuration"
1: (1621) ->~"This GDB was configured as follows:\n   configure --host=i686-host_pc-mingw32 --target=xtensa-esp32-elf\n"
1: (1621) ->~"             --with-auto-load-dir=$debugdir:$datadir/auto-load\n             --with-auto-load-safe-path=$debugdir:$datadir/auto-load\n"
1: (1621) ->~"             --with-expat\n"
1: (1621) ->~"             --with-gdb-datadir=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/share/gdb (relocatable)\n"
1: (1621) ->~"             --with-jit-reader-dir=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/lib/gdb (relocatable)\n"
1: (1621) ->~"             --without-libunwind-ia64\n"
1: (1621) ->~"             --without-lzma\n"
1: (1621) ->~"             --without-guile\n"
1: (1621) ->~"             --with-separate-debug-dir=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/lib/debug (relocatable)\n"
1: (1621) ->~"             --with-sysroot=/home/ivan/e/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf/sysroot (relocatable)\n"
1: (1621) ->~"             --without-babeltrace\n"
1: (1621) ->~"\n(\"Relocatable\" means the directory can be moved with the GDB installation\ntree, and GDB will still find it.)\n"
1: (1621) ->1009^done
1: (1621) ->(gdb)
1: (1621) 1009: elapsed time 10
E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/MIEngine/WindowsRuntime","data":{"VS.Diagnostics.Debugger.MIEngine.WindowsRuntime":"MinGW"},"type":"output"}
1: (1624) <-1010-file-exec-and-symbols Z:\\home\\gojimmypi\\esp\\hello_world\\build\\hello-world.elf
1: (1647) ->1010^done
1: (1647) ->(gdb)
1: (1647) 1010: elapsed time 23
1: (1647) <-1011-interpreter-exec console "show architecture"
1: (1657) ->~"The target architecture is set automatically (currently xtensa)\n"
1: (1657) ->1011^done
1: (1657) ->(gdb)
1: (1657) 1011: elapsed time 10
1: (1658) <-1012-break-insert main
1: (1672) ->1012^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x400f4bf4",func="main",file="/home/gojimmypi/esp/hello_world/main/./hello_world_main.c",fullname="Z:\\home\\gojimmypi\\esp\\hello_world\\main\\hello_world_main.c",line="15",thread-groups=["i1"],times="0",original-location="main"}
1: (1672) ->(gdb)
1: (1672) 1012: elapsed time 14
E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/Launch","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.40306.1","VS.Diagnostics.Debugger.HostVersion":"1.0.30301.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Launch.Duration":1620,"VS.Diagnostics.Debugger.Launch.IsCoreDump":false,"VS.Diagnostics.Debugger.VisualizerFileUsed":false,"VS.Diagnostics.Debugger.SourceFileMappings":0},"type":"output"}
 R: {"success":true,"message":null,"request_seq":2,"command":"launch","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
E initialized: {"type":"initialized"}
C threads: null
 R: {"success":true,"message":null,"request_seq":3,"command":"threads","body":{"threads":[{"id":-2,"name":"Thread #-2"}]},"running":false,"refs":null,"seq":0,"type":"response"}
C setFunctionBreakpoints: {"breakpoints":[]}
 R: {"success":true,"message":null,"request_seq":4,"command":"setFunctionBreakpoints","body":{"breakpoints":[]},"running":false,"refs":null,"seq":0,"type":"response"}
C configurationDone: null
 R: {"success":true,"message":null,"request_seq":5,"command":"configurationDone","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
C threads: null
 R: {"success":true,"message":null,"request_seq":6,"command":"threads","body":{"threads":[{"id":-2,"name":"Thread #-2"}]},"running":false,"refs":null,"seq":0,"type":"response"}
E output: {"category":"stdout","output":"=thread-group-added,id=\"i1\"\nGNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10\nCopyright (C) 2015 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\nThis GDB was configured as \"--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf\".\nType \"show configuration\" for configuration details.\nFor bug reporting instructions, please see:\n<http://www.gnu.org/software/gdb/bugs/>.\nFind the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\nFor help, type \"help\".\nType \"apropos word\" to search for commands related to \"word\".\nWarning: Debuggee TargetArchitecture not detected, assuming x86_64.\n","data":null,"type":"output"}
=thread-group-added,id="i1"
GNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10
Copyright (C) 2015 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=i686-host_pc-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".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
1: (1714) <-1013-interpreter-exec console "info sharedlibrary"
1: (1722) ->~"No shared libraries loaded at this time.\n"
1: (1722) ->1013^done
1: (1722) ->(gdb)
1: (1722) 1013: elapsed time 8
E output: {"category":"console","output":"Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.\r\n","data":null,"type":"output"}
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
1: (1733) <-1014-thread-info
1: (1743) ->1014^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x40000400",func="??",args=[]},state="stopped"}],current-thread-id="1"
1: (1743) ->(gdb)
1: (1743) 1014: elapsed time 10
1: (1753) <-1015-stack-list-frames 0 1000
1: (1763) ->1015^done,stack=[frame={level="0",addr="0x40000400",func="??"}]
1: (1763) ->(gdb)
1: (1763) 1015: elapsed time 10
1: (1768) <--exec-continue
1: (1773) ->^running
1: (1773) ->*running,thread-id="all"
1: (1773) ->(gdb)
1: (1788) ->(gdb)
1: (3745) ->@"esp32.cpu0: Target halted, pc=0x40080E74\n"
E output: {"category":"stdout","output":"@\"esp32.cpu0: Target halted, pc=0x40080E74\\n\"\n","data":null,"type":"output"}
@"esp32.cpu0: Target halted, pc=0x40080E74\n"
1: (3772) ->~"\nProgram received signal "
E output: {"category":"stdout","output":"\nProgram received signal ","data":null,"type":"output"}
Program received signal 
1: (3773) ->~"SIGTRAP, Trace/breakpoint trap.\n"
E output: {"category":"stdout","output":"SIGTRAP, Trace/breakpoint trap.\n","data":null,"type":"output"}
SIGTRAP, Trace/breakpoint trap.
1: (3778) ->~"ipc_task (arg=0x0) at /home/gojimmypi/esp/esp-idf/components/esp32/./ipc.c:45\n"
E output: {"category":"stdout","output":"ipc_task (arg=0x0) at /home/gojimmypi/esp/esp-idf/components/esp32/./ipc.c:45\n","data":null,"type":"output"}
ipc_task (arg=0x0) at /home/gojimmypi/esp/esp-idf/components/esp32/./ipc.c:45
1: (3779) ->~"45\t{\n"
E output: {"category":"stdout","output":"45\t{\n","data":null,"type":"output"}
45  {
1: (3779) ->*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",frame={addr="0x40080e74",func="ipc_task",args=[{name="arg",value="0x0"}],file="/home/gojimmypi/esp/esp-idf/components/esp32/./ipc.c",fullname="Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\ipc.c",line="45"},thread-id="1",stopped-threads="all"
1: (3784) <-1016-stack-list-frames 0 1000
1: (3789) ->1016^done,stack=[frame={level="0",addr="0x40080e74",func="ipc_task",file="/home/gojimmypi/esp/esp-idf/components/esp32/./ipc.c",fullname="Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\ipc.c",line="45"},frame={level="1",addr="0x40000000",func="??"}]
1: (3789) ->(gdb)
1: (3789) 1016: elapsed time 5
E output: {"category":"console","output":"Execute debugger commands using \"-exec <command>\", for example \"-exec info registers\" will list registers in use (when GDB is the debugger)\r\n","data":null,"type":"output"}
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
E stopped: {"threadId":-2,"reason":"exception","source":{"name":"ipc.c","path":"Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\ipc.c","sourceReference":0},"line":45,"column":1,"text":"Trace/breakpoint trap","allThreadsStopped":true,"type":"stopped"}
C threads: null
 R: {"success":true,"message":null,"request_seq":7,"command":"threads","body":{"threads":[{"id":-2,"name":"Thread #-2"}]},"running":false,"refs":null,"seq":0,"type":"response"}
C stackTrace: {"threadId":-2,"startFrame":0,"levels":20}
1: (3824) <-1017-stack-list-arguments 2 0 1
1: (3829) ->1017^done,stack-args=[frame={level="0",args=[{name="arg",type="void *",value="0x0"}]},frame={level="1",args=[]}]
1: (3829) ->(gdb)
1: (3829) 1017: elapsed time 5
 R: {"success":true,"message":null,"request_seq":8,"command":"stackTrace","body":{"stackFrames":[{"id":1000,"source":{"name":"ipc.c","path":"Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\ipc.c","sourceReference":0},"line":45,"column":1,"name":"ipc_task(void * arg)"},{"id":1001,"source":null,"line":0,"column":0,"name":"[Unknown/Just-In-Time compiled code]"}],"totalFrames":2},"running":false,"refs":null,"seq":0,"type":"response"}
C scopes: {"frameId":1000}
1: (3851) <-1018-stack-list-variables 0
1: (3859) ->1018^done,variables=[{name="arg",arg="1"},{name="cpuid"},{name="__func__"}]
1: (3859) ->(gdb)
1: (3859) 1018: elapsed time 8
1: (3865) <-1019-var-create - * "arg"
1: (3869) ->1019^done,name="var1",numchild="0",value="0x0",type="void *",thread-id="1",has_more="0"
1: (3869) ->(gdb)
1: (3869) 1019: elapsed time 4
1: (3869) <-1020-var-create - * "cpuid"
1: (3879) ->1020^done,name="var2",numchild="0",value="0",type="const uint32_t",thread-id="1",has_more="0"
1: (3879) ->(gdb)
1: (3879) 1020: elapsed time 10
1: (3879) <-1021-var-create - * "__func__"
1: (3880) ->1021^done,name="var3",numchild="9",value="[9]",type="const char [9]",has_more="0"
1: (3880) ->(gdb)
1: (3880) 1021: elapsed time 1
 R: {"success":true,"message":null,"request_seq":9,"command":"scopes","body":{"scopes":[{"name":"Locals","variablesReference":1000,"expensive":false}]},"running":false,"refs":null,"seq":0,"type":"response"}
C variables: {"variablesReference":1000}
 R: {"success":true,"message":null,"request_seq":10,"command":"variables","body":{"variables":[{"name":"cpuid","value":"0","type":"const uint32_t","variablesReference":0,"evaluateName":"cpuid"},{"name":"__func__","value":"[9]","type":"const char [9]","variablesReference":1001,"evaluateName":"__func__"},{"name":"arg","value":"0x0","type":"void *","variablesReference":0,"evaluateName":"arg"}]},"running":false,"refs":null,"seq":0,"type":"response"}
C evaluate: {"expression":"s_ipc_wait","frameId":1000,"context":"hover"}
1: (7839) <-1022-var-create - * "s_ipc_wait"
1: (7846) ->1022^done,name="var4",numchild="0",value="IPC_WAIT_FOR_START",type="volatile esp_ipc_wait_t",has_more="0"
1: (7846) ->(gdb)
1: (7846) 1022: elapsed time 6
 R: {"success":true,"message":null,"request_seq":11,"command":"evaluate","body":{"result":"IPC_WAIT_FOR_START","variablesReference":0,"type":"volatile esp_ipc_wait_t"},"running":false,"refs":null,"seq":0,"type":"response"}

It looks at first like it might be working: step1

but then some sort of error occurs when single stepping:

C next: {"threadId":-2}
1: (812785) <-1022-exec-next
1: (812793) ->1022^running
1: (812793) ->*running,thread-id="all"
1: (812793) ->(gdb)
1: (812793) 1022: elapsed time 8
1: (812794) ->(gdb)
 R: {"success":true,"message":null,"request_seq":11,"command":"next","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
1: (812903) ->@"esp32.cpu0: Target halted, pc=0x40080E77\n"
E output: {"category":"stdout","output":"@\"esp32.cpu0: Target halted, pc=0x40080E77\\n\"\n","data":null,"type":"output"}
@"esp32.cpu0: Target halted, pc=0x40080E77\n"
1: (812932) ->~"/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? "
1: (812932) ->~"(y or n) [answered Y; input not from terminal]\n"
E output: {"category":"stdout","output":"/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? ","data":null,"type":"output"}
1: (812932) ->&"\nThis is a bug, please report it."
/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? 
1: (812932) ->&"  For instructions, see:\n<http://www.gnu.org/software/gdb/bugs/>."
1: (812932) ->&"\n\n"
E output: {"category":"stdout","output":"(y or n) [answered Y; input not from terminal]\n","data":null,"type":"output"}
(y or n) [answered Y; input not from terminal]
1: (812932) ->~"/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nCreate a core file of GDB? "
E output: {"category":"stdout","output":"/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nCreate a core file of GDB? ","data":null,"type":"output"}
/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? 
1: (812932) ->~"(y or n) [answered Y; input not from terminal]\n"
E output: {"category":"stdout","output":"(y or n) [answered Y; input not from terminal]\n","data":null,"type":"output"}
(y or n) [answered Y; input not from terminal]
1: (812933) STDERR: This application has requested the Runtime to terminate it in an unusual way.
1: (812933) STDERR: Please contact the application's support team for more information.
1: (812943) "C:/msys32/opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe" exited with code 3 (0x3).
1: (812947) <-logout
E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/MIEngine/DebuggerAborted","data":{"VS.Diagnostics.Debugger.MIEngine.DebuggerName":"GDB","VS.Diagnostics.Debugger.MIEngine.LastSentCommandName":"-exec-next","VS.Diagnostics.Debugger.MIEngine.DebuggerExitCode":"3 (0x3)"},"type":"output"}
E output: {"category":"stderr","output":"ERROR: GDB exited unexpectedly with exit code 3 (0x3). Debugging will now abort.\r\n","data":null,"type":"output"}
ERROR: GDB exited unexpectedly with exit code 3 (0x3). Debugging will now abort.
E output: {"category":"console","output":"The program 'Z:\\home\\gojimmypi\\esp\\hello_world\\build\\hello-world.elf' has exited with code -1 (0xffffffff).\r\n\r\n","data":null,"type":"output"}
The program 'Z:\home\gojimmypi\esp\hello_world\build\hello-world.elf' has exited with code -1 (0xffffffff).

E exited: {"exitCode":-1,"type":"exited"}
E terminated: {"type":"terminated"}
E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/DebugCompleted","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.40306.1","VS.Diagnostics.Debugger.HostVersion":"1.0.30301.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.DebugCompleted.BreakCounter":1},"type":"output"}
C disconnect: {"restart":false}
 R: {"success":true,"message":null,"request_seq":12,"command":"disconnect","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

No error is actually shown at the top on the menu bar, VSCode just quietly stops debugging.

btw - note that as I mentioned in issue #760, that VSCode is also incorrectly auto-detecting the ESP8266, instead of the ESP32 (but apparently caused by different extension team: surely not related to this issue?)

At this point things are so bad, that I can also no longer debug even from the Linux prompt withxtensa-esp32-elf-gdb hello-world.elf as the Olimex ARM-USB-OCD-H is now so unhappy that it needs to be power cycled for any further debugging:

gojimmypi@ubuntu : ~/esp/hello_world/build
0 $ xtensa-esp32-elf-gdb  hello-world.elf
GNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10
Copyright (C) 2015 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-build_pc-linux-gnu --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"...
Reading symbols from hello-world.elf...done.
(gdb) target remote 192.168.174.129:3333
Remote debugging using 192.168.174.129:3333
/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

So it seems VSCode sends some sort of Really Bad command to the Olimex. I had assumed this was because of the incorrect default architecture of (to my surprise!) 1: (1657) ->~"The target architecture is set automatically (currently xtensa)\n" - so it appears somehow VSCode "remembered" that, even though it is commented out in the launch.json.

I repeated the whole exercise, deleting the lines from launch.json, ensured the file was saved, power cycle the Olimex, make sure command-line gdb working, and received the same result in VSCode, still auto-detecting xtensa. I am certain on the occasion when I first started this - before having an explicit architecture, that VSCode complained that it could not auto-detect, and picked some sort of x86.

*edit: added missing portion debug log after pressing F5

*edit: note in January that espressif/esp-idf/issues/303 others apparently had this working using tasks.json and c_cpp_properties.json - has that since changed to use launch.json instead?

pieandcakes commented 7 years ago

@gojimmypi your issue is here:

1: (517496) ->~"/home/ivan/e/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nCreate a core file of GDB? "
1: (517496) ->~"(y or n) [answered Y; input not from terminal]\n"

Like I mentioned in my previous message, we use gdb in MI interpreter mode. This is required to remotely control gdb. The error looks like an issue in the gdb version you are using. Can you try updating it? if you locate the commands that start with <- those are the MI Commands we send to gdb and we get back -> from gdb as a response. If you put your local gdb into MI mode using --interpreter=MI and issue all the commands we do, you might be able to reproduce the error and file a bug against the version of gdb you are using.

So it seems VSCode sends some sort of Really Bad command to the Olimex. I had assumed this was because of the incorrect default architecture of (to my surprise!) 1: (1657) ->~"The target architecture is set automatically (currently xtensa)\n" - so it appears somehow VSCode "remembered" that, even though it is commented out in the launch.json.

That's not correct. we sent the command -exec-next which is a step and then gdb told us it was in an unstable state.

For architecture, IF you don't specify it, we let gdb determine what it is. By default, it tries to match the host machine

This GDB was configured as "--host=i686-host_pc-mingw32 --target=xtensa-esp32-elf".
~
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.

and then it guesses it from the debuggee

1: (1647) <-1011-interpreter-exec console "show architecture"
1: (1657) ->~"The target architecture is set automatically (currently xtensa)\n"

This is the behavior we expect and there isn't additional work needed to "support" xtensa architecture. If you want to be able to specify xtensa in the UI and are willing to contribute, the block of code I sent in the previous post is an open-source project called MIEngine that we use and you can contribute there and we can work it into our future release but this only allows you to explicitly set xtensa instead of letting gdb decide.

gojimmypi commented 7 years ago

The gdb I am using is the latest from http://esp-idf.readthedocs.io/en/latest/get-started/linux-setup.html more specifically: https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz

@igrr @espressif is one of the driving architects there. They have a custom openocd (that I am using) but I don't see gdb there. I'll take your advice and open an issue for gdb in the main espressif idf repository. I appreciate the tips on the MI Commands.

That's not correct. we sent the command -exec-next which is a step and then gdb told us it was in an unstable state.

Interesting, as that would imply the -exec-next from the MI does something a bit different from me simply typing N - which otherwise works interactively.

As a side note, it was suggested to me via twitter that I modify my ESP32.cfg to disable RTOS support (some issue related to debugging the multi-core processor). Perhaps useful for future visitor:

#With no variables set, openocd will configure JTAG for the two cores of the ESP32 and
#will not automatic RTOS detection. This can be be adjusted:

#set ESP32_ONLYCPU 1        # Only configure the PRO CPU
#set ESP32_ONLYCPU 2        # Only configure the APP CPU

# Disable RTOS support
set ESP32_RTOS none        

#set ESP32_RTOS freertos    # Force RTOS to be FreeRTOS
... [snip, etc]

@pieandcakes thanks for your help. I'll update this when I have more information.

*edit: I created a new issue in espressif/idf for the gdb problem https://github.com/espressif/esp-idf/issues/645

pieandcakes commented 7 years ago

Interesting, as that would imply the -exec-next from the MI does something a bit different from me simply typing N - which otherwise works interactively.

The MI Layer provides a different command route within gdb than n, and they then convert the response back to an MI response. I'm guessing they have a bug in the code, which we have seen in different versions. Unfortunately since I work on the debugger team at Microsoft, I can't look at or contribute to the gdb source code base. Someone will need to debug this scenario and figure out what is wrong with gdb under the covers.

@gojimmypi If you want to contribute documentation, you can probably create a document in this repo under Debugger/gdb/xtensa and provide some help so that other users will be able to find it. If you do this, just send me a PR for me to review :)

Thanks!

gojimmypi commented 7 years ago

@pieandcakes OK! I have this working, even if a little wonky. I think the problem is some sort of state synchronization between VSCode and GDB. VSCode thinks GDB is in initially in break mode, when it is not. I was also incorrect about the Olimex needing reset; pressing the EN button on the ESP32 seems to resolve the "weird state" noted above.

Your suggestion of trying the MI commands manually was very helpful!

  1. Press F5 to start debugging (screen looks the same as above screen snip with Exception has occurred. Trace/breakpoint trap. It appears we are debugging, but we are not. Target (appears to be) running. VSCode thinks it is paused.

  2. type -exec continue at the VSCode > prompt. step2

  3. Observe debug output. Note that despite -exec continue we are now actually in halt state.

    -exec continue
    C evaluate: {"expression":"-exec continue","frameId":1000,"context":"repl"}
    1: (15631) <-1022-interpreter-exec console "continue"
    1: (15634) ->~"Continuing.\n"
    1: (15634) ->1022^running
    1: (15634) ->*running,thread-id="all"
    1: (15634) ->(gdb)
    1: (15634) 1022: elapsed time 3
    E output: {"category":"stdout","output":"Continuing.\n\n","data":null,"type":"output"}
    Continuing.
    E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/Evaluate","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.40306.1","VS.Diagnostics.Debugger.HostVersion":"1.0.30301.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Evaluate.Duration":6.0,"VS.Diagnostics.Debugger.Evaluate.IsError":false,"VS.Diagnostics.Debugger.Evaluate.ExecuteInConsole":true},"type":"output"}
    R: {"success":true,"message":null,"request_seq":11,"command":"evaluate","body":{"result":"","variablesReference":0,"type":null},"running":false,"refs":null,"seq":0,"type":"response"}
    1: (15794) ->@"esp32.cpu0: Target halted, pc=0x400F4AB0\n"
    E output: {"category":"stdout","output":"@\"esp32.cpu0: Target halted, pc=0x400F4AB0\\n\"\n","data":null,"type":"output"}
    @"esp32.cpu0: Target halted, pc=0x400F4AB0\n"
    1: (15817) ->=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x400f4ab0",func="main",file="/home/gojimmypi/esp/hello_world/main/./hello_world_main.c",fullname="Z:\\home\\gojimmypi\\esp\\hello_world\\main\\hello_world_main.c",line="15",thread-groups=["i1"],times="1",original-location="main"}
    1: (15819) ->~"\nBreakpoint "
    1: (15819) ->~"1, main () at /home/gojimmypi/esp/hello_world/main/./hello_world_main.c:15\n"
    E output: {"category":"stdout","output":"\nBreakpoint ","data":null,"type":"output"}
    Breakpoint 
    E output: {"category":"stdout","output":"1, main () at /home/gojimmypi/esp/hello_world/main/./hello_world_main.c:15\n","data":null,"type":"output"}
    1, main () at /home/gojimmypi/esp/hello_world/main/./hello_world_main.c:15
    1: (15820) ->~"15\tint main() {\n"
    E output: {"category":"stdout","output":"15\tint main() {\n","data":null,"type":"output"}
    15  int main() {
    1: (15820) ->*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x400f4ab0",func="main",args=[],file="/home/gojimmypi/esp/hello_world/main/./hello_world_main.c",fullname="Z:\\home\\gojimmypi\\esp\\hello_world\\main\\hello_world_main.c",line="15"},thread-id="1",stopped-threads="all"
    1: (15821) <-1023-stack-list-frames 0 1000
    1: (15830) ->1023^done,stack=[frame={level="0",addr="0x400f4ab0",func="main",file="/home/gojimmypi/esp/hello_world/main/./hello_world_main.c",fullname="Z:\\home\\gojimmypi\\esp\\hello_world\\main\\hello_world_main.c",line="15"}]
    1: (15830) ->(gdb)
    1: (15830) 1023: elapsed time 9
    1: (15831) <-1024-var-delete var1
    1: (15840) ->1024^done,ndeleted="1"
    1: (15840) ->(gdb)
    1: (15840) 1024: elapsed time 9
    1: (15840) <-1025-var-delete var2
    1: (15851) ->1025^done,ndeleted="1"
    1: (15851) ->(gdb)
    1: (15851) 1025: elapsed time 10
    1: (15851) <-1026-var-delete var3
    1: (15861) ->1026^done,ndeleted="1"
    1: (15861) ->(gdb)
    1: (15861) 1026: elapsed time 10
    1: (15863) <--exec-continue
    1: (15871) ->^running
    1: (15871) ->*running,thread-id="all"
    1: (15871) ->(gdb)
    1: (15871) ->(gdb)
    1: (16086) ->@"esp32.cpu0: Target halted, pc=0x400F4AB3\n"
    E output: {"category":"stdout","output":"@\"esp32.cpu0: Target halted, pc=0x400F4AB3\\n\"\n","data":null,"type":"output"}
    @"esp32.cpu0: Target halted, pc=0x400F4AB3\n"
    C evaluate: {"expression":"void","frameId":1000,"context":"hover"}
    1: (20188) <-1027-var-create - * "void"
    1: (20190) ->&"Attempt to use a type name as an expression.\n"
    1: (20190) ->1027^error,msg="-var-create: unable to create variable object"
    1: (20190) ->(gdb)
    1: (20190) 1027: elapsed time 2
    R: {"success":false,"message":"Evaluation error","request_seq":12,"command":"evaluate","body":{"error":{"id":1101,"format":"Evaluation error","variables":null}},"running":false,"refs":null,"seq":0,"type":"response"}
  4. Press the VSCode Play button (F5). Observe error:

    C continue: {"threadId":-2}
    1: (167521) <--exec-continue
    R: {"success":true,"message":null,"request_seq":13,"command":"continue","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
    1: (167529) ->^error,msg="Cannot execute this command while the selected thread is running."
    1: (167529) ->(gdb)
    E output: {"category":"stderr","output":"ERROR: Cannot execute this command while the selected thread is running.\r\n","data":null,"type":"output"}
    ERROR: Cannot execute this command while the selected thread is running.
  5. Only after the above steps are completed, now press the pause button. Observe output:

    C pause: {"threadId":-2}
    1: (241477) <-1027-exec-interrupt
    1: (241483) ->1027^done
    1: (241483) ->(gdb)
    1: (241483) 1027: elapsed time 5
    R: {"success":true,"message":null,"request_seq":14,"command":"pause","body":null,"running":false,"refs":null,"seq":0,"type":"response"}
    1: (241635) ->@"esp32.cpu0: Target halted, pc=0x400D1158\n"
    E output: {"category":"stdout","output":"@\"esp32.cpu0: Target halted, pc=0x400D1158\\n\"\n","data":null,"type":"output"}
    @"esp32.cpu0: Target halted, pc=0x400D1158\n"
    1: (241663) ->~"\nProgram received signal "
    E output: {"category":"stdout","output":"\nProgram received signal ","data":null,"type":"output"}
    1: (241663) ->~"SIGINT, Interrupt.\n"
    Program received signal 
    E output: {"category":"stdout","output":"SIGINT, Interrupt.\n","data":null,"type":"output"}
    SIGINT, Interrupt.
    1: (241666) ->~"0x400d1158 in esp_vApplicationIdleHook () at /home/gojimmypi/esp/esp-idf/components/esp32/./freertos_hooks.c:52\n"
    E output: {"category":"stdout","output":"0x400d1158 in esp_vApplicationIdleHook () at /home/gojimmypi/esp/esp-idf/components/esp32/./freertos_hooks.c:52\n","data":null,"type":"output"}
    0x400d1158 in esp_vApplicationIdleHook () at /home/gojimmypi/esp/esp-idf/components/esp32/./freertos_hooks.c:52
    1: (241667) ->~"52\t        asm(\"waiti 0\");\n"
    E output: {"category":"stdout","output":"52\t        asm(\"waiti 0\");\n","data":null,"type":"output"}
    1: (241667) ->*stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={addr="0x400d1158",func="esp_vApplicationIdleHook",args=[],file="/home/gojimmypi/esp/esp-idf/components/esp32/./freertos_hooks.c",fullname="Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\freertos_hooks.c",line="52"},thread-id="1",stopped-threads="all"
    52          asm("waiti 0");
    1: (241667) <-1028-stack-list-frames 0 1000
    1: (241688) ->1028^done,stack=[frame={level="0",addr="0x400d1158",func="esp_vApplicationIdleHook",file="/home/gojimmypi/esp/esp-idf/components/esp32/./freertos_hooks.c",fullname="Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\freertos_hooks.c",line="52"},frame={level="1",addr="0x4008495d",func="prvIdleTask",file="/home/gojimmypi/esp/esp-idf/components/freertos/./tasks.c",fullname="Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\freertos\\tasks.c",line="3319"}]
    1: (241688) ->(gdb)
    1: (241688) 1028: elapsed time 21
    E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/Pause","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.40306.1","VS.Diagnostics.Debugger.HostVersion":"1.0.30301.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg"},"type":"output"}
    E stopped: {"threadId":-2,"reason":"pause","source":{"name":"freertos_hooks.c","path":"Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\freertos_hooks.c","sourceReference":0},"line":52,"column":1,"text":null,"allThreadsStopped":true,"type":"stopped"}
    C threads: null
    R: {"success":true,"message":null,"request_seq":15,"command":"threads","body":{"threads":[{"id":-2,"name":"Thread #-2"}]},"running":false,"refs":null,"seq":0,"type":"response"}
    C stackTrace: {"threadId":-2,"startFrame":0,"levels":20}
    1: (241694) <-1029-stack-list-arguments 2 0 1
    1: (241698) ->1029^done,stack-args=[frame={level="0",args=[]},frame={level="1",args=[{name="pvParameters",type="void *",value="0x0"}]}]
    1: (241698) ->(gdb)
    1: (241698) 1029: elapsed time 4
    R: {"success":true,"message":null,"request_seq":16,"command":"stackTrace","body":{"stackFrames":[{"id":1000,"source":{"name":"freertos_hooks.c","path":"Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\esp32\\freertos_hooks.c","sourceReference":0},"line":52,"column":1,"name":"esp_vApplicationIdleHook()"},{"id":1001,"source":{"name":"tasks.c","path":"Z:\\home\\gojimmypi\\esp\\esp-idf\\components\\freertos\\tasks.c","sourceReference":0},"line":3319,"column":1,"name":"prvIdleTask(void * pvParameters)"}],"totalFrames":2},"running":false,"refs":null,"seq":0,"type":"response"}
    C scopes: {"frameId":1000}
    1: (241714) <-1030-stack-list-variables 0
    1: (241718) ->1030^done,variables=[{name="doWait"},{name="r"},{name="n"}]
    1: (241718) ->(gdb)
    1: (241718) 1030: elapsed time 4
    1: (241718) <-1031-var-create - * "doWait"
    1: (241728) ->1031^done,name="var4",numchild="0",value="true",type="_Bool",thread-id="1",has_more="0"
    1: (241728) ->(gdb)
    1: (241728) 1031: elapsed time 10
    1: (241728) <-1032-var-create - * "r"
    1: (241738) ->1032^done,name="var5",numchild="0",value="<optimized out>",type="_Bool",thread-id="1",has_more="0"
    1: (241738) ->(gdb)
    1: (241738) 1032: elapsed time 10
    1: (241738) <-1033-var-create - * "n"
    1: (241748) ->1033^done,name="var6",numchild="0",value="8",type="int",thread-id="1",has_more="0"
    1: (241749) ->(gdb)
    1: (241749) 1033: elapsed time 10
    R: {"success":true,"message":null,"request_seq":17,"command":"scopes","body":{"scopes":[{"name":"Locals","variablesReference":1000,"expensive":false}]},"running":false,"refs":null,"seq":0,"type":"response"}
    C variables: {"variablesReference":1000}
    R: {"success":true,"message":null,"request_seq":18,"command":"variables","body":{"variables":[{"name":"doWait","value":"true","type":"_Bool","variablesReference":0,"evaluateName":"doWait"},{"name":"r","value":"<optimized out>","type":"_Bool","variablesReference":0,"evaluateName":"r"},{"name":"n","value":"8","type":"int","variablesReference":0,"evaluateName":"n"}]},"running":false,"refs":null,"seq":0,"type":"response"}
  6. Press a code stepping button, such as Shift-F11.... tada! Single step debugging! step3

I've reproduced this numerous times. Following these instructions allows single-step debugging. Just jumping in with F5 causes the weird GDB error.

So the question is... how can I persuade VSCode to perform these steps automatically? I tried a couple of commands in the launch.json with no luck:

                {
                    "text": "continue"
                }

What are your thoughts on this? Thanks again - I appreciate your help.

edit - p.s. Note that despite the `(11258) ->stopped,reason="breakpoint-hit"` message - to my knowledge, I did not actually set any breakpoints.

*edit - include full log for step 3.

pieandcakes commented 7 years ago

edit - p.s. Note that despite the (11258) ->stopped,reason="breakpoint-hit" message - to my knowledge, I did not actually set any breakpoints.

This is tied to us issuing -break-insert main because we need to configure the environment. We set an initial breakpoint which is tied to the following response:

1: (15817) ->=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x400f4ab0",func="main",file="/home/gojimmypi/esp/hello_world/main/./hello_world_main.c",fullname="Z:\\home\\gojimmypi\\esp\\hello_world\\main\\hello_world_main.c",line="15",thread-groups=["i1"],times="1",original-location="main"}
1: (15819) ->~"\nBreakpoint "
1: (15819) ->~"1, main () at /home/gojimmypi/esp/hello_world/main/./hello_world_main.c:15\n"

We are getting a SIGTRAP which we interpret to an exception that has stopped the process. Unfortunately at that point we think you are in code execution and you stop, so the setup portion is already done and adding another setup command won't fix it.

ivankravets commented 7 years ago

Similar strange warning... No errors...

screen shot 2017-07-20 at 21 00 20

pieandcakes commented 7 years ago

@ivankravets Which version of the extension are you using and which OS and can you enable logging to tell me what its sending?

ivankravets commented 7 years ago

can you enable logging to tell me what its sending?

Could it be linked with "customgdb is not signed" warning?

pieandcakes commented 7 years ago

@ivankravets your gdb normally has to be signed on a Mac to be used for debugging. if you are getting that message, then it looks like it isn't signed. Please sign it and try again.

ivankravets commented 7 years ago

@pieandcakes how we can sign it if it's dynamic binary? Please take a look at PIO Unified Debugger. We don't have here any physical GDB. IDEs communicate with our debugging broker which later decides how to communicate with a hardware device. Yes, we created special "wrapper" around platformio debug --interface=gdb command and called it piodebugdb because VSCode doesn't allow to specify miPath in pair with extra arguments.

See 2 configurations. The first is for Native Debug, which works excellent, 2-nd is for Microsoft's extension.


{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "gdb",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "name": "PlatformIO Debugger",
            "target": "/path/to/firmware.elf",
            "gdbpath": "/dynamic/path/to/piodebuggdb",
            "autorun": [
                "source .pioinit"
            ]
        },
        {
            "type": "cppdbg",
            "request": "launch",
            "name": "PlatformIO Debugger TEST",
            "cwd": "${workspaceRoot}",
            "program": "/path/to/firmware.elf",
            "logging": {
                "moduleLoad": false
            },
            "setupCommands": [
                {
                    "text": "source .pioinit",
                    "description": "PlatformIO Loader"
                }
            ],
            "MIMode": "gdb",
            "miDebuggerPath": "/dynamic/path/to/piodebuggdb"
        }
    ]
}
pieandcakes commented 7 years ago

@ivankravets signing is not a requirement of us, but a requirement of Mac OS. If you are seeing an error related to the binary not being signed, I don't have insight as to how to get around that.

We use "--interpreter=mi" and we pass that argument to gdb/lldb. If you want to pass your own flags, you can wrap your call to the piodebuggdb inside a bash script and pass your own parameters and place that script call in your "miDebuggerPath".

ivankravets commented 7 years ago

Thanks, you can skip all my issues and feedbacks. We will stay with Native Debug which works excellent without any wheels.

P.S: I just wanted to switch our customers to Microsoft official C/C++ extension.

ivankravets commented 7 years ago

If you want to pass your own flags, you can wrap your call to the piodebuggdb inside a bash script and pass your own parameters and place that script call in your "miDebuggerPath".

That is what we did a few months ago. This piodebuggdb is a special hook for VSCode. It wraps http://docs.platformio.org/en/latest/userguide/cmd_debug.html

pieandcakes commented 7 years ago

@ivankravets , @robotdad is one of our Project Managers who works on supporting IoT/Embedded devices. You should probably talk to him about your use case to see what changes are needed to make it work properly if that is the route you would like to go.

ivankravets commented 7 years ago

@pieandcakes I know Marc, thanks!

@robotdad, could ask your team to fix these issues?

  1. https://github.com/Microsoft/vscode-cpptools/issues/815#issuecomment-316805304
  2. https://github.com/Microsoft/vscode-cpptools/issues/763#issuecomment-316802590

Just 2 things and we will switch to your extension from Native Debug:

  1. Launch miPath process using specified cwd.
  2. How to hide this "not signed" warning? PlatformIO is written in pure Python, where piodebuggdb is a binary created by Python's PIP manager.

Thanks!

robotdad commented 7 years ago

Apologies, something was wrong with my notifications here so I missed this thread. Regarding signing, @pieandcakes is right, that is a MacOS requirement.

I'm not sure what to think of the cwd issue yet.

ivankravets commented 7 years ago

@robotdad

Regarding signing, @pieandcakes is right, that is a MacOS requirement.

How could you explain the fact that non-Microsoft extension named "Native Debug" works excellent? The problem is with vscode-cpptools extension, it launches debug session through Apple Script instead of using Node.JS process spawning.

I'm not sure what to think of the cwd issue yet.

We "cwd": "${workspaceRoot}" and "miDebuggerPath": "....". Normally (for Eclipse, even for Native Debug), they change directory to cwd before spawning GDB client.

TuringChenChao commented 6 years ago

Dear @pieandcakes, I meet a problem that I can not stop target when debug Xtensa MCU on VSCode. From the below logs, it seems xt-gdb didn't receive ctrl-c SINGAL.

1: (223) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'

1: (237) LaunchOptions  ExePath='Z:\Larkspur\geneva-dev-maindev-mt2811_sw_integration\out\mt2811a_evb\freertos_create_thread\debug\dsp0_freertos_create_thread.out'

1: (237) LaunchOptions  WorkingDirectory='Z:\Larkspur\geneva-dev-maindev-mt2811_sw_integration\dsp'

1: (237) LaunchOptions  ExeArguments=''

1: (237) LaunchOptions MIMode='gdb'

1: (237) LaunchOptions  MIDebuggerPath='E:\Tensilica\Xplorer7_0_6\XtDevTools\install\tools\RG-2017.7-win32\XtensaTools\bin\xt-gdb.exe'

1: (237) LaunchOptions  WaitDynamicLibLoad='false'

1: (237) LaunchOptions>

1: (237) LaunchOptions    <SetupCommands>

1: (238) LaunchOptions        <Command IgnoreFailures='true' Description='Enable pretty-printing for gdb'>-enable-pretty-printing</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>set substitute-path /proj/mtk60512 Z:</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>set confirm off</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>set width 0</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>set height 0</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>set print ctype-reglayout off</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>set print asm-demangle on</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>interpreter-exec console 'python import thread_aware_rtos'</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>file 'Z:/Larkspur/geneva-dev-maindev-mt2811_sw_integration/out/mt2811a_evb/freertos_create_thread/debug/dsp0_freertos_create_thread.out'</Command>

1: (238) LaunchOptions        <Command IgnoreFailures='false' Description=''>target remote localhost:20000</Command>

1: (238) LaunchOptions    </SetupCommands>

1: (238) LaunchOptions    <LaunchCompleteCommand>None</LaunchCompleteCommand>

1: (238) LaunchOptions</LocalLaunchOptions>

1: (330) Starting: "E:\Tensilica\Xplorer7_0_6\XtDevTools\install\tools\RG-2017.7-win32\XtensaTools\bin\xt-gdb.exe" --interpreter=mi

1: (412) DebuggerPid=13104

1: (1239) ->=thread-group-added,id="i1"

1: (1240) ->~"GNU gdb (GDB) 7.11.1 Xtensa Tools 12.0.7\n"

1: (1240) ->~"Copyright (C) 2016 Free Software Foundation, Inc.\n"

1: (1240) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"

1: (1240) ->~"This GDB was configured as \"--host=i686-pc-mingw32 --target=xtensa-elf\".\nType \"show configuration\" for configuration details."

1: (1240) ->~"\nFor bug reporting instructions, please see:\n"

1: (1240) ->~"<http://www.gnu.org/software/gdb/bugs/>.\n"

1: (1240) ->~"Find the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\n"

1: (1240) ->~"For help, type \"help\".\n"

1: (1240) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"

1: (1240) ->(gdb)

1: (1248) <-1001-gdb-set target-async on

1: (1248) ->1001^done

1: (1248) ->(gdb)

1: (1248) ->&"\n"

1: (1248) ->^done

1: (1248) ->(gdb)

1: (1249) 1001: elapsed time 1

1: (1257) <-1002-enable-pretty-printing

1: (1257) ->1002^done

1: (1257) ->(gdb)

1: (1257) ->&"\n"

1: (1257) ->^done

1: (1257) ->(gdb)

1: (1257) 1002: elapsed time 0

1: (1261) <-1003-interpreter-exec console "set substitute-path /proj/mtk60512 Z:"

1: (1261) ->1003^done

1: (1261) ->(gdb)

1: (1261) ->&"\n"

1: (1261) ->^done

1: (1261) ->(gdb)

1: (1262) 1003: elapsed time 1

1: (1262) <-1004-interpreter-exec console "set confirm off"

1: (1262) ->=cmd-param-changed,param="confirm",value="off"

1: (1262) ->1004^done

1: (1262) ->(gdb)

1: (1262) 1004: elapsed time 0

1: (1262) <-1005-interpreter-exec console "set width 0"

1: (1262) ->&"\n"

1: (1262) ->^done

1: (1262) ->(gdb)

1: (1262) ->=cmd-param-changed,param="width",value="4294967295"

1: (1263) ->1005^done

1: (1263) ->(gdb)

1: (1263) ->&"\n"

1: (1263) ->^done

1: (1263) ->(gdb)

1: (1263) 1005: elapsed time 1

1: (1263) <-1006-interpreter-exec console "set height 0"

1: (1263) ->1006^done

1: (1263) ->(gdb)

1: (1263) 1006: elapsed time 0

1: (1263) <-1007-interpreter-exec console "set print ctype-reglayout off"

1: (1263) ->&"\n"

1: (1263) ->^done

1: (1263) ->(gdb)

1: (1263) ->=cmd-param-changed,param="print ctype-reglayout",value="off"

1: (1263) ->1007^done

1: (1263) ->(gdb)

1: (1263) ->&"\n"

1: (1263) ->^done

1: (1263) ->(gdb)

1: (1263) 1007: elapsed time 0

1: (1263) <-1008-interpreter-exec console "set print asm-demangle on"

1: (1263) ->=cmd-param-changed,param="print asm-demangle",value="on"

1: (1263) ->1008^done

1: (1263) ->(gdb)

1: (1263) ->&"\n"

1: (1263) ->^done

1: (1263) ->(gdb)

1: (1263) 1008: elapsed time 0

1: (1263) <-1009-interpreter-exec console "interpreter-exec console 'python import thread_aware_rtos'"

1: (1305) ->1009^done

1: (1305) ->(gdb)

1: (1305) 1009: elapsed time 42

1: (1305) <-1010-interpreter-exec console "file 'Z:/Larkspur/geneva-dev-maindev-mt2811_sw_integration/out/mt2811a_evb/freertos_create_thread/debug/dsp0_freertos_create_thread.out'"

1: (1305) ->&"\n"

1: (1305) ->^done

1: (1305) ->(gdb)

1: (1339) ->&"warning: Xtensa configuration may be incompatible (configuration ID does not match) for Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\out\\mt2811a_evb\\freertos_create_thread\\debug\\dsp0_freertos_create_thread.out\n"

1: (1417) ->~"Reading symbols from Z:/Larkspur/geneva-dev-maindev-mt2811_sw_integration/out/mt2811a_evb/freertos_create_thread/debug/dsp0_freertos_create_thread.out..."

1: (1458) ->~"done.\n"

1: (1464) ->1010^done

1: (1464) ->(gdb)

1: (1464) 1010: elapsed time 159

1: (1464) <-1011-interpreter-exec console "target remote localhost:20000"

1: (1464) ->&"\n"

1: (1464) ->^done

1: (1464) ->(gdb)

1: (1487) ->~"Remote debugging using localhost:20000\n"

1: (1493) ->&"warning: Current core configuration doesn't match the target:Core ID = 0xC3B3CBFE21C6F6A0, Target ID = 0xC3B3CBFE21C6E91A\n"

1: (1493) ->&"\n"

1: (1494) ->=thread-group-started,id="i1",pid="42000"

1: (1494) ->=thread-created,id="1",group-id="i1"

1: (1508) ->~"0x08134481 in prvIdleTask (pvParameters=0x0) at ../../../../../kernel/rtos/FreeRTOS/Source/tasks.c:2958\n"

1: (1531) ->~"2958\t\t\twhile( uxTasksDeleted > ( UBaseType_t ) 0U )\n"

1: (1533) ->~"0x08134481 in prvIdleTask (pvParameters=0x0) at ../../../../../kernel/rtos/FreeRTOS/Source/tasks.c:2958\n"

1: (1542) ->~"2958\t\t\twhile( uxTasksDeleted > ( UBaseType_t ) 0U )\n"

1: (1545) ->*stopped,frame={addr="0x08134481",func="prvIdleTask",args=[{name="pvParameters",value="0x0"}],file="../../../../../kernel/rtos/FreeRTOS/Source/tasks.c",fullname="Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp\\kernel\\rtos\\FreeRTOS\\Source\\tasks.c",line="2958"},thread-id="1",stopped-threads="all"

1: (1545) ->1011^done

1: (1545) ->(gdb)

1: (1545) ->&"\n"

1: (1545) ->^done

1: (1545) ->(gdb)

1: (1553) 1011: elapsed time 89

1: (1553) <-1012-thread-info 1

1: (1553) <-1013-interpreter-exec console "set pagination off"

1: (1560) ->1012^done,threads=[{id="1",target-id="Thread <main>",frame={level="0",addr="0x08134481",func="prvIdleTask",args=[{name="pvParameters",value="0x0"}],file="../../../../../kernel/rtos/FreeRTOS/Source/tasks.c",fullname="Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp\\kernel\\rtos\\FreeRTOS\\Source\\tasks.c",line="2958"},state="stopped"}]

1: (1560) ->(gdb)

1: (1560) 1012: elapsed time 7

1: (1560) ->&"\n"

1: (1560) ->^done

1: (1560) ->(gdb)

1: (1560) ->=cmd-param-changed,param="pagination",value="off"

1: (1560) ->1013^done

1: (1560) ->(gdb)

1: (1560) ->&"\n"

1: (1560) ->^done

1: (1560) ->(gdb)

E thread: {"reason":"started","threadId":1,"type":"thread"}

1: (1570) 1013: elapsed time 17

1: (1570) <-1014-gdb-set solib-search-path Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\out\\mt2811a_evb\\freertos_create_thread\\debug;

1: (1576) ->1014^done

1: (1576) ->(gdb)

1: (1576) 1014: elapsed time 6

1: (1576) <-1015-environment-cd Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp

1: (1576) ->&"\n"

1: (1576) ->^done

1: (1576) ->(gdb)

1: (1578) ->1015^done

1: (1578) ->(gdb)

1: (1578) 1015: elapsed time 2

1: (1578) ->&"\n"

1: (1578) ->^done

1: (1578) ->(gdb)

1: (1578) <-1016-interpreter-exec console "show configuration"

1: (1578) ->~"This GDB was configured as follows:\n   configure --host=i686-pc-mingw32 --target=xtensa-elf\n"

1: (1578) ->~"             --with-auto-load-dir=$debugdir:$datadir/auto-load\n             --with-auto-load-safe-path=$debugdir:$datadir/auto-load\n"

1: (1578) ->~"             --without-expat\n"

1: (1578) ->~"             --with-gdb-datadir=/build/tree/RG-2017.7_kuma/xttools.build/build/RG-2017.7-win32/XtensaTools/share/gdb (relocatable)\n"

1: (1578) ->~"             --with-jit-reader-dir=/build/tree/RG-2017.7_kuma/xttools.build/build/RG-2017.7-win32/XtensaTools/lib/gdb (relocatable)\n"

1: (1579) ->~"             --without-libunwind-ia64\n"

1: (1579) ->~"             --without-lzma\n"

1: (1579) ->~"             --with-python=C:/usr/xtensa/stools-7.0\n"

1: (1579) ->~"             --without-guile\n"

1: (1579) ->~"             --with-separate-debug-dir=/build/tree/RG-2017.7_kuma/xttools.build/build/RG-2017.7-win32/XtensaTools/lib/debug (relocatable)\n"

1: (1579) ->~"             --without-babeltrace\n"

1: (1579) ->~"\n(\"Relocatable\" means the directory can be moved with the GDB installation\ntree, and GDB will still find it.)\n"

1: (1579) ->1016^done

1: (1579) ->(gdb)

1: (1579) 1016: elapsed time 1

1: (1579) ->&"\n"

1: (1579) ->^done

1: (1579) ->(gdb)

E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/MIEngine/WindowsRuntime","data":{"VS.Diagnostics.Debugger.MIEngine.WindowsRuntime":"MinGW"},"type":"output"}

1: (1583) <-1017-file-exec-and-symbols Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\out\\mt2811a_evb\\freertos_create_thread\\debug\\dsp0_freertos_create_thread.out

1: (1612) ->&"warning: Xtensa configuration may be incompatible (configuration ID does not match) for Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\out\\mt2811a_evb\\freertos_create_thread\\debug\\dsp0_freertos_create_thread.out\n"

1: (1727) ->1017^done

1: (1728) ->(gdb)

1: (1728) 1017: elapsed time 145

1: (1728) ->&"\n"

1: (1728) ->^done

1: (1728) ->(gdb)

1: (1728) <-1018-interpreter-exec console "show architecture"

1: (1728) ->~"The target architecture is set automatically (currently xtensa)\n"

1: (1728) ->1018^done

1: (1728) ->(gdb)

1: (1728) ->&"\n"

1: (1728) ->^done

1: (1728) ->(gdb)

1: (1728) 1018: elapsed time 0

1: (1729) <-1019-break-insert main

1: (1745) ->1019^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x081353c7",func="main",file="../../../../../project/mt2811a_evb/templates/dsp0_freertos_create_thread/src/main.c",fullname="Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp\\project\\mt2811a_evb\\templates\\dsp0_freertos_create_thread\\src\\main.c",line="159",thread-groups=["i1"],times="0",original-location="main"}

1: (1745) ->(gdb)

1: (1745) 1019: elapsed time 16

1: (1745) ->&"\n"

1: (1745) ->^done

1: (1745) ->(gdb)

E output: {"category":"telemetry","output":"VS/Diagnostics/Debugger/Launch","data":{"VS.Diagnostics.Debugger.ImplementationName":"Microsoft.MIDebugEngine","VS.Diagnostics.Debugger.EngineVersion":"14.0.50628.1","VS.Diagnostics.Debugger.HostVersion":"14.0.50628.1","VS.Diagnostics.Debugger.AdapterId":"cppdbg","VS.Diagnostics.Debugger.Launch.Duration":1651,"VS.Diagnostics.Debugger.Launch.IsCoreDump":false,"VS.Diagnostics.Debugger.VisualizerFileUsed":false,"VS.Diagnostics.Debugger.SourceFileMappings":0},"type":"output"}

 R: {"success":true,"message":null,"request_seq":2,"command":"launch","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

E initialized: {"type":"initialized"}

C threads: null

 R: {"success":true,"message":null,"request_seq":3,"command":"threads","body":{"threads":[{"id":1,"name":"Thread #1"}]},"running":false,"refs":null,"seq":0,"type":"response"}

C setFunctionBreakpoints: {"breakpoints":[]}

 R: {"success":true,"message":null,"request_seq":4,"command":"setFunctionBreakpoints","body":{"breakpoints":[]},"running":false,"refs":null,"seq":0,"type":"response"}

C configurationDone: null

 R: {"success":true,"message":null,"request_seq":5,"command":"configurationDone","body":null,"running":false,"refs":null,"seq":0,"type":"response"}

C threads: null

 R: {"success":true,"message":null,"request_seq":6,"command":"threads","body":{"threads":[{"id":1,"name":"Thread #1"}]},"running":false,"refs":null,"seq":0,"type":"response"}

E output: {"category":"stdout","output":"=thread-group-added,id=\"i1\"\nGNU gdb (GDB) 7.11.1 Xtensa Tools 12.0.7\nCopyright (C) 2016 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\nThis GDB was configured as \"--host=i686-pc-mingw32 --target=xtensa-elf\".\nType \"show configuration\" for configuration details.\nFor bug reporting instructions, please see:\n<http://www.gnu.org/software/gdb/bugs/>.\nFind the GDB manual and other documentation resources online at:\n<http://www.gnu.org/software/gdb/documentation/>.\nFor help, type \"help\".\nType \"apropos word\" to search for commands related to \"word\".\nWarning: Debuggee TargetArchitecture not detected, assuming x86_64.\n=cmd-param-changed,param=\"pagination\",value=\"off\"\n","data":null,"type":"output"}

=thread-group-added,id="i1"
GNU gdb (GDB) 7.11.1 Xtensa Tools 12.0.7
Copyright (C) 2016 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=i686-pc-mingw32 --target=xtensa-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".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
1: (1881) <-1020-interpreter-exec console "info sharedlibrary"

1: (1885) ->~"No shared libraries loaded at this time.\n"

1: (1886) ->1020^done

1: (1886) ->(gdb)

1: (1886) ->&"\n"

1: (1886) ->^done

1: (1886) ->(gdb)

1: (1886) 1020: elapsed time 5

E output: {"category":"console","output":"Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.\r\n","data":null,"type":"output"}

Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.

1: (1906) <-1021-thread-info

1: (1924) ->1021^done,threads=[{id="1",target-id="Thread <main>",frame={level="0",addr="0x08134481",func="prvIdleTask",args=[{name="pvParameters",value="0x0"}],file="../../../../../kernel/rtos/FreeRTOS/Source/tasks.c",fullname="Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp\\kernel\\rtos\\FreeRTOS\\Source\\tasks.c",line="2958"},state="stopped"}],current-thread-id="1"

1: (1924) ->(gdb)

1: (1924) 1021: elapsed time 18

1: (1925) ->&"\n"

1: (1925) ->^done

1: (1925) ->(gdb)

1: (1938) <-1022-stack-list-frames 0 1000

1: (1938) ->1022^done,stack=[frame={level="0",addr="0x08134481",func="prvIdleTask",file="../../../../../kernel/rtos/FreeRTOS/Source/tasks.c",fullname="Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp\\kernel\\rtos\\FreeRTOS\\Source\\tasks.c",line="2958"}]

1: (1938) ->(gdb)

1: (1938) ->&"\n"

1: (1938) ->^done

1: (1938) ->(gdb)

1: (1940) 1022: elapsed time 2

1: (1946) <--exec-continue

1: (1948) ->^running

1: (1948) ->*running,thread-id="all"

1: (1948) ->(gdb)

C pause: {"threadId":1}

1: (6676) <-1023-exec-interrupt

But all the sequence can run successfully on the terminal as below:

xt-gdb.exe --xtensa-core=dsp0_core_winabi_xtensac --xtensa-system=E:\\Tensilica\\Xplorer7_0_6\\XtDevTools\\install\\builds\\RG-2017.7-win32\\dsp0_core_winabi_xtensac\\config --xtensa-params= --quiet --nw --interpreter=mi2
=thread-group-added,id="i1"
(gdb)
set substitute-path /proj/mtk60512 Z:
&"set substitute-path /proj/mtk60512 Z:\n"
^done
(gdb)
set confirm off
&"set confirm off\n"
=cmd-param-changed,param="confirm",value="off"
^done
(gdb)
set width 0
&"set width 0\n"
=cmd-param-changed,param="width",value="4294967295"
^done
(gdb)
set height 0
&"set height 0\n"
=cmd-param-changed,param="height",value="4294967295"
^done
(gdb)
set print ctype-reglayout off
&"set print ctype-reglayout off\n"
=cmd-param-changed,param="print ctype-reglayout",value="off"
^done
(gdb)
set print asm-demangle on
&"set print asm-demangle on\n"
=cmd-param-changed,param="print asm-demangle",value="on"
^done
(gdb)
python import thread_aware_rtos
&"python import thread_aware_rtos\n"
^done
(gdb)
file 'Z:/Larkspur/geneva-dev-maindev-mt2811_sw_integration/out/mt2811a_evb/freertos_create_thread/debug/dsp0_freertos_create_thread.out'
&"file 'Z:/Larkspur/geneva-dev-maindev-mt2811_sw_integration/out/mt2811a_evb/freertos_create_thread/debug/dsp0_freertos_create_thread.out'\n"
&"warning: Xtensa configuration may be incompatible (configuration ID does not match) for Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\out\\mt2811a_evb\\freertos_create_thread\\debug\\dsp0_freertos_create_thread.out\n"
~"Reading symbols from Z:/Larkspur/geneva-dev-maindev-mt2811_sw_integration/out/mt2811a_evb/freertos_create_thread/debug/dsp0_freertos_create_thread.out..."
~"done.\n"
^done
(gdb)
target remote localhost:20000
&"target remote localhost:20000\n"
~"Remote debugging using localhost:20000\n"
&"warning: Current core configuration doesn't match the target:Core ID = 0xC3B3CBFE21C6F6A0, Target ID = 0xC3B3CBFE21C6E91A\n"
&"\n"
=thread-group-started,id="i1",pid="42000"
=thread-created,id="1",group-id="i1"
~"0x08134481 in prvIdleTask (pvParameters=0x0) at ../../../../../kernel/rtos/FreeRTOS/Source/tasks.c:2958\n"
~"2958\t\t\twhile( uxTasksDeleted > ( UBaseType_t ) 0U )\n"
*stopped,frame={addr="0x08134481",func="prvIdleTask",args=[{name="pvParameters",value="0x0"}],file="../../../../../kernel/rtos/FreeRTOS/Source/tasks.c",fullname="Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp\\kernel\\rtos\\FreeRTOS\\Source\\tasks.c",line="2958"},thread-id="1",stopped-threads="all"
^done
(gdb)
-exec-continue
^running
*running,thread-id="all"
(gdb)
~"\nProgram"
~" received signal SIGINT, Interrupt.\n"
~"0x08134481 in prvIdleTask (pvParameters=0x0) at ../../../../../kernel/rtos/FreeRTOS/Source/tasks.c:2958\n"
~"2958\t\t\twhile( uxTasksDeleted > ( UBaseType_t ) 0U )\n"
*stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={addr="0x08134481",func="prvIdleTask",args=[{name="pvParameters",value="0x0"}],file="../../../../../kernel/rtos/FreeRTOS/Source/tasks.c",fullname="Z:\\Larkspur\\geneva-dev-maindev-mt2811_sw_integration\\dsp\\kernel\\rtos\\FreeRTOS\\Source\\tasks.c",line="2958"},thread-id="1",stopped-threads="all"
(gdb)
-exec-interrupt
^done
(gdb)

So, I think it is not caused by xt-gdb's MI mode. Could you help me fix this issue or tell me how to do more test?

Thank you!

TuringChenChao commented 6 years ago

Dear @pieandcakes, Add more information: If I add "catch signal SIGTRAP" command in "setupCommands", the F11 is working. But F6 is still not working. Regards, Turing

derasd commented 6 years ago

Hi, I'm using Visual Studio Code Ver. 1.26.1 with PlatformIO 0.17.5 and when I try to debug a esp32doit-devkit with a esp-prog debugger I get the same error as @gojimmypi at one point in this thread.

/builds/idf/crosstool-NG/.build/src/gdb-7.10/gdb/inline-frame.c:171: internal-error: inline_frame_this_id: Assertion !frame_id_eq (*this_id, outer_frame_id)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? 
(y or n) [answered Y; input not from terminal]
undefined

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I tried using the original platformio-debug configuration as well as the native debug configuration suggested by @ivankravets in this thread.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug",
            "executable": "c:/SW/debug_test/.pioenvs/esp32doit-devkit-v1/firmware.elf",
            "toolchainBinDir": "C:/Users/x/.platformio/packages/toolchain-xtensa32/bin",
            "preLaunchTask": "PlatformIO: Pre-Debug",
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug (Skip Pre-Debug)",
            "executable": "c:/SW/debug_test/.pioenvs/esp32doit-devkit-v1/firmware.elf",
            "toolchainBinDir": "C:/Users/x/.platformio/packages/toolchain-xtensa32/bin",
            "internalConsoleOptions": "openOnSessionStart",
        },
        {
            "type": "gdb",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "name": "PlatformIO Debugger",
            "target": "c:/SW/debug_test/.pioenvs/esp32doit-devkit-v1/firmware.elf",
            "gdbpath": "C:/Users/x/.platformio/penv/Scripts/piodebuggdb",
            "autorun": [
                "source .pioinit"
            ]     
        }
    ]
}

but both fail with above error.

I couldn't exactly follow where this error is coming from or if it had been resolved in this thread so I would appreciate some help. Thanks!

derasd commented 6 years ago

As a last possibility I tried @gojimmypi 's side note and disabled RTOS in ESP32.cfg

# Disable RTOS support
set ESP32_RTOS none        

and it seems to work now.

ivankravets commented 6 years ago

@derasd PlatformIO does not use this debugger anymore. We have written our own with advanced features, such as memory and common registers viewers, peripheral registers, disassembly, etc. Our debugger it built-in in our extension https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide

Could you try it?

derasd commented 6 years ago

Well I am using PlatformIO 0.17.5 but debugging failed with above error. Thats why I tried native debugger (and config) which failed as well with the same error. Only disabling RTOS helped (for both). So I would say I am using PlatformIO debugger right now or do I miss something?

ivankravets commented 6 years ago

@derasd Please move your issue to https://community.platformio.org/c/troubleshooting/pio-plus

We've released recently new v1.1.1 version of our IDE. Please update.

Also, this thread could be useful https://community.platformio.org/t/esp32-pio-unified-debugger/4541/

github-actions[bot] commented 3 years ago

This issue has been closed automatically because it's labeled as 'external'.