pyocd / pyOCD

Open source Python library for programming and debugging Arm Cortex-M microcontrollers
https://pyocd.io
Apache License 2.0
1.13k stars 484 forks source link

Debugging Zephyr app on reel board with GDB TUI see some python error. #1324

Open smrtos opened 2 years ago

smrtos commented 2 years ago

Host environment:

Steps:

And btw it seems this very python exception will break the Native Debug extension for the Visual Studio Code. See below:

image

And if I attempt to input some gdb command in the Visual Studio Code DEBUG CONSOLE, it shows below error:

image

flit commented 2 years ago

Hi @smrtos! I also use both GDB Dashboard for command line debugging, and VSCode for GUI debugging.

The ValueError: max() arg is an empty sequence exception you see is a bug in GDB Dashboard. It's not completely happy with the Cortex-M architecture.

I'm not sure where the "Exception has occurred" error comes from. I don't think that's a result of the GDB Dashboard error, since that's a Python exception (and you can see Dashboard continues to print the rest of the dashboard sections). This error is probably related to the Native Debug extension not being meant for embedded debugging.

So basically, the Native Debug extension should not be used with Cortex-M debugging. Please use the cortex-debug extension instead. It works well with pyocd.

Here's an example cortex-debug launch configuration I use for debugging DAPLink.

{
    "name": "DAPLink lpc55s69_bl",
    "executable": "${workspaceRoot}/projectfiles/make_gcc_arm/lpc55s69_bl/build/lpc55s69_bl.elf",
    "cwd": "${workspaceRoot}",
    "request": "launch",
    "type": "cortex-debug",
    "servertype": "pyocd",
    "serverpath": "${workspaceRoot}/venv/mac39/bin/pyocd",
    "targetId": "lpc55s69",
    "serverArgs": [
        "--uid=L02932983A",
        "--core=0",
    ],
    "svdFile": "/xxx/_cmsis_packs/NXP.LPC55S69_DFP.12.3.0/LPC55S69_cm33_core0.xml",
    "showDevDebugOutput": false,
    "gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.07/bin/arm-none-eabi-gdb-py",
},

Notes:

(I plan on adding a full guide to debugging with VSCode+cortex-debug to the pyocd docs soon.)

smrtos commented 2 years ago

Thanks @flit I will try the Cortex Debug extension. I remember I also tried disabling the Native Debug extension but the "Exception has occurred" still showed up. I will double check on that and provide further details.

smrtos commented 2 years ago

@flit Thanks for the recommendation. I just tried it. It seems impossible to configure the port for the gdb client to connect to. The maintainer doesn't consider that to be a proper way I guess. Check here: https://github.com/Marus/cortex-debug/issues/117

flit commented 2 years ago

Hmmm, that's a bit frustrating indeed.