espressif / vscode-esp-idf-extension

Visual Studio Code extension for ESP-IDF projects
Apache License 2.0
1.02k stars 297 forks source link

Launch & debug silently breaks when launch.json has trailing comma (VSC-1449) #1259

Closed gudvinr closed 4 weeks ago

gudvinr commented 1 month ago

OS

Windows

Operating System version

Arch Linux

Visual Studio Code version

1.91.1

ESP-IDF version

5.2.2

Python version

3.12

Doctor command output

ESP-IDF Extension for Visual Studio Code report ``` ---------------------------------------------- ESP-IDF Extension for Visual Studio Code report --------------------------------------------- OS linux x64 6.9.10-arch1-1 System environment variable IDF_PYTHON_ENV_PATH undefined System environment variable PATH /.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/tools/go/bin:/tools/flutter/bin:/tools/android/cmdline-tools/latest/bin:/tools/android/platform-tools:/tools/android/build-tools/35.0.0 System environment variable PYTHON undefined Visual Studio Code version 1.91.1 Visual Studio Code language en Visual Studio Code shell /usr/bin/bash ESP-IDF Extension version 1.8.0 Workspace folder /prog/personal/esp-rt ---------------------------------------------------- Extension configuration settings ------------------------------------------------------ ESP-ADF Path (idf.espAdfPath) ${env:ADF_PATH} ESP-IDF Path (idf.espIdfPath) /tools/esp/v5.2.2/esp-idf ESP-MDF Path (idf.espMdfPath) ${env:MDF_PATH} ESP-Matter Path (idf.espMatterPath) ${env:ESP_MATTER_PATH} ESP-HomeKit-SDK Path (idf.espHomeKitSdkPath) ${env:HOMEKIT_PATH} Custom extra paths (idf.customExtraPaths) /tools/esp/tools/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin:/tools/esp/tools/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin:/tools/esp/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin:/tools/esp/tools/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin:/tools/esp/tools/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/tools/esp/tools/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin:/tools/esp/tools/tools/esp-rom-elfs/20230320 Custom extra vars (idf.customExtraVars) OPENOCD_SCRIPTS: /tools/esp/tools/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts ESP_ROM_ELF_DIR: /tools/esp/tools/tools/esp-rom-elfs/20230320/ Virtual env Python Path (idf.pythonBinPath) /tools/esp/tools/python_env/idf5.2_py3.12_env/bin/python Serial port (idf.port) /dev/ttyACM0 OpenOCD Configs (idf.openOcdConfigs) board/esp32s3-builtin.cfg ESP-IDF Tools Path (idf.toolsPath) /tools/esp/tools Git Path (idf.gitPath) /usr/bin/git Notification Mode (idf.notificationMode) All -------------------------------------------------------- Configurations access ------------------------------------------------------------- Access to ESP-ADF Path (idf.espAdfPath) false Access to ESP-IDF Path (idf.espIdfPath) true Access to ESP-MDF Path (idf.espMdfPath) false Access to ESP-Matter Path (idf.espMatterPath) false Access to ESP-HomeKit Path (idf.espHomeKitSdkPath) false Access to ESP-IDF Custom extra paths Access to /tools/esp/tools/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin: true Access to /tools/esp/tools/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin: true Access to /tools/esp/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin: true Access to /tools/esp/tools/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin: true Access to /tools/esp/tools/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin: true Access to /tools/esp/tools/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin: true Access to /tools/esp/tools/tools/esp-rom-elfs/20230320: true Access to Virtual env Python Path (idf.pythonBinPath) true Access to CMake in environment PATH true Access to Ninja in environment PATH true Access to ESP-IDF Tools Path (idf.toolsPath) true -------------------------------------------------------- Configurations has spaces ------------------------------------------------------------- Spaces in system environment Path false Spaces in ESP-ADF Path (idf.espAdfPath) false Spaces in ESP-IDF Path (idf.espIdfPath) false Spaces in ESP-MDF Path (idf.espMdfPath) false Spaces in ESP-Matter Path (idf.espMatterPath) false Spaces in ESP-HomeKit-SDK Path (idf.espHomeKitSdkPath) false Spaces in ESP-IDF Custom extra paths Spaces in /tools/esp/tools/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin: false Spaces in /tools/esp/tools/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin: false Spaces in /tools/esp/tools/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin: false Spaces in /tools/esp/tools/tools/riscv32-esp-elf/esp-13.2.0_20230928/riscv32-esp-elf/bin: false Spaces in /tools/esp/tools/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin: false Spaces in /tools/esp/tools/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin: false Spaces in /tools/esp/tools/tools/esp-rom-elfs/20230320: false Spaces in Virtual env Python Path (idf.pythonBinPath) false Spaces in ESP-IDF Tools Path (idf.toolsPath) false ----------------------------------------------------------- Executables Versions ----------------------------------------------------------- Git version 2.45.2 ESP-IDF version 5.2.2 Python version 3.12.4 Python's pip version 24.0 -------------------------------------------------- Project configuration settings ---------------------------------------------------------- -------------------------------------------------- Python packages in idf.pythonBinPath ---------------------------------------------------- bitarray version: 2.9.2 bitstring version: 4.2.3 CacheControl version: 0.14.0 certifi version: 2024.6.2 cffi version: 1.16.0 charset-normalizer version: 3.3.2 click version: 8.0.4 colorama version: 0.4.6 construct version: 2.10.70 contextlib2 version: 21.6.0 cryptography version: 41.0.7 ecdsa version: 0.19.0 esp-coredump version: 1.11.0 esp-debug-backend version: 1.0.3 esp-idf-kconfig version: 1.4.2 esp-idf-monitor version: 1.4.0 esp-idf-panic-decoder version: 1.1.0 esp-idf-size version: 1.4.0 esptool version: 4.7.0 filelock version: 3.14.0 freertos-gdb version: 1.0.3 idf-component-manager version: 1.5.2 idna version: 3.7 intelhex version: 2.3.0 kconfiglib version: 14.1.0 markdown-it-py version: 3.0.0 mdurl version: 0.1.2 msgpack version: 1.0.8 packaging version: 24.0 pip version: 24.0 pyclang version: 0.4.2 pycparser version: 2.22 pyelftools version: 0.31 pygdbmi version: 0.9.0.2 Pygments version: 2.18.0 pyparsing version: 3.1.2 pyserial version: 3.5 PyYAML version: 6.0.1 reedsolo version: 1.7.0 requests version: 2.32.3 requests-file version: 1.5.1 requests-toolbelt version: 1.0.0 rich version: 13.7.1 schema version: 0.7.7 setuptools version: 70.0.0 six version: 1.16.0 tqdm version: 4.66.4 urllib3 version: 1.26.18 ---------------------------------------------------- Check ESP-IDF python requirements.txt ------------------------------------------------- Check ESP-IDF Python packages Python requirements are satisfied. ---------------------------------------------------- Check ESP-IDF debug adapter requirements.txt ------------------------------------------ Check Debug AdapterPython packages Python requirements are satisfied. ---------------------------------------------------- Visual Studio Code launch.json -------------------------------------------------------- { "version": "0.2.0", "configurations": [ { "type": "gdbtarget", "request": "attach", "name": "Eclipse CDT GDB Adapter", "initCommands": [ "set remote hardware-watchpoint-limit {IDF_TARGET_CPU_WATCHPOINT_NUM}", "mon reset halt", "maintenance flush register-cache" ], } ] } ---------------------------------------------------- Visual Studio Code c_cpp_properties.json ---------------------------------------------- { "configurations": [ { "name": "ESP-IDF (S3)", "compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc", "compileCommands": "${config:idf.buildPath}/compile_commands.json", "includePath": [ "${workspaceFolder}/**", "${config:idf.espIdfPath}/components/**", ], "browse": { "path": [ "${workspaceFolder}", "${config:idf.espIdfPath}/components", ], "limitSymbolsToIncludedHeaders": true } } ], "version": 4 } -------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------- Logfile ----------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------- ```

Extension

No response

Description

After using workaround I noticed that launching debugger from status bar doesn't work anymore.

I am not entirely sure but this could be caused by this because JSON.Parse doesn't support trailing commas.
These are part of JSON5 that is supported by vscode itself I believe.

If you insert "initCommands": [], right before }, you will get an error.

If that is the case, I think it can be mitigated by getting launch config directly from getConfiguration("launch", ...) or by fixing json/parser to make it compliant.

Debug Message

[error] SyntaxError: /home/gudvin/prog/personal/esp-rt/.vscode/launch.json: Expected double-quoted property name in JSON at position 333 (line 13 column 5)
    at JSON.parse (<anonymous>)
    at <HOMEPATH>/.vscode-oss/extensions/espressif.esp-idf-extension-1.8.0/dist/extension.js:2:701202
    at <HOMEPATH>/.vscode-oss/extensions/espressif.esp-idf-extension-1.8.0/dist/extension.js:2:648451
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)

I have checked existing issues, online documentation and the Troubleshooting Guide

brianignacio5 commented 1 month ago

I've made these changes in #1261

You can try these changes using this vsix installer to see if it works for you. Same for avoid breakpoint at app_main

gudvinr commented 1 month ago

I don't see an error in Extension Host log with that installer.