Skip to content

probe-rs gdb server -> cortex-debug (with defmt/rtt), no rtt output #1136

Description

@mfp20

Describe the bug

I'm not sure it is a bug. There's no RTT output option in VSCode OUTPUT window.

I also had to override the launch commands as in this other issue but in this way I can attach to a running firmware, but cannot upload the new firmware to the device before attaching, not in a single command/click.

To Reproduce

  1. run probe-rs to hook the usb device to a gdb server stub probe-rs gdb --chip rp2040 --protocol swd --speed 20000
  2. configure the RTT for defmt (ie: use the advanced decoder seen in other issues and convert from js to ts)
  3. run the launch.json configuration shown in the pasted debug console output below

Expected behavior

When I run the same Debug-Cortex configuration with OpenOCD instead of probe-rs, I've an RTT output to select in order to see the defmt messages in the running code. It should pop up for this probe-rs based configuration as well, as the rttConfig configuration block is pasted from the other openocd-based configuration and the js script is exactly the same file used by the openocd-based configuration.

Environment (please complete the following information):

  • Cortex-Debug 1.12.1 git(652d042)
  • Windows 11
  • GNU gdb (Arm GNU Toolchain 14.2.Rel1 (Build arm-14.52)) 15.2.90.20241130-git

Attach text from Debug Console

Cortex-Debug: VSCode debugger extension version 1.12.1 git(652d042). Usage info: https://github.com/Marus/cortex-debug#usage
"configuration": {
    "type": "cortex-debug",
    "request": "launch",
    "name": "Cortex-Debug with probe-rs",
    "showDevDebugOutput": "raw",
    "cwd": "C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template",
    "executable": "C:/Users/user/dev/repo-pico-rust/knurling-app-template/target/thumbv6m-none-eabi/debug/count",
    "servertype": "external",
    "gdbTarget": "[::1]:1337",
    "overrideLaunchCommands": [
        "interpreter-exec console \"monitor reset halt\"",
        "-enable-pretty-printing"
    ],
    "rttConfig": {
        "enabled": true,
        "address": "auto",
        "clearSearch": false,
        "decoders": [
            {
                "type": "advanced",
                "decoder": "C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template/.vscode/rtt-defmt.js",
                "config": {
                    "executable": "C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template/target/thumbv6m-none-eabi/debug/count"
                },
                "label": "RTT",
                "port": 0,
                "ports": [
                    0
                ]
            }
        ]
    },
    "__configurationTarget": 6,
    "gdbServerConsolePort": 55878,
    "pvtAvoidPorts": [],
    "chainedConfigurations": {
        "enabled": false
    },
    "debuggerArgs": [],
    "swoConfig": {
        "enabled": false,
        "decoders": [],
        "cpuFrequency": 0,
        "swoFrequency": 0,
        "source": "probe"
    },
    "graphConfig": [],
    "preLaunchCommands": [],
    "postLaunchCommands": [],
    "preAttachCommands": [],
    "postAttachCommands": [],
    "preRestartCommands": [],
    "postRestartCommands": [],
    "preResetCommands": [],
    "postResetCommands": [],
    "toolchainPath": "C:\\Users\\user\\dev\\repo-pico-rust\\arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi\\bin",
    "toolchainPrefix": "arm-none-eabi",
    "gdbPath": "C:\\Users\\user\\dev\\repo-pico-rust\\arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi\\bin\\arm-none-eabi-gdb.exe",
    "extensionPath": "c:/Users/user/.vscode/extensions/marus25.cortex-debug-1.12.1",
    "registerUseNaturalFormat": true,
    "variableUseNaturalFormat": true,
    "pvtVersion": "1.12.1",
    "__sessionId": "0dea14ec-38d1-4f7d-a520-cbe6dff3b039",
    "pvtShowDevDebugOutput": "raw"
}
Reading symbols from C:/Users/user/dev/repo-pico-rust/arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi/bin/arm-none-eabi-objdump.exe --syms -C -h -w C:/Users/user/dev/repo-pico-rust/knurling-app-template/target/thumbv6m-none-eabi/debug/count
Reading symbols from c:/users/user/dev/repo-pico-rust/arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi/bin/arm-none-eabi-nm.exe --defined-only -S -l -C -p C:/Users/user/dev/repo-pico-rust/knurling-app-template/target/thumbv6m-none-eabi/debug/count
Launching GDB: "C:\\Users\\user\\dev\\repo-pico-rust\\arm-gnu-toolchain-14.2.rel1-mingw-w64-x86_64-arm-none-eabi\\bin\\arm-none-eabi-gdb.exe" -q --interpreter=mi2
1-gdb-version
Finished reading symbols from objdump: Time: 14 ms
-> =thread-group-added,id="i1"
-> ~"GNU gdb (Arm GNU Toolchain 14.2.Rel1 (Build arm-14.52)) 15.2.90.20241130-git\n"
-> ~"Copyright (C) 2024 Free Software Foundation, Inc.\n"
-> ~"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."
-> ~"\nType \"show copying\" and \"show warranty\" for details.\n"
-> ~"This GDB was configured as \"--host=x86_64-w64-mingw32 --target=arm-none-eabi\".\n"
-> ~"Type \"show configuration\" for configuration details.\n"
-> ~"For bug reporting instructions, please see:\n"
-> ~"<https://bugs.linaro.org/>.\n"
-> ~"Find the GDB manual and other documentation resources online at:\n    <"
-> ~"http://www.gnu.org/software/gdb/documentation/>.\n\n"
-> ~"For help, type \"help\".\n"
-> ~"Type \"apropos word\" to search for commands related to \"word\".\n"
-> 1^done
2-gdb-set mi-async on
-> 2^done
3-interpreter-exec console "set print demangle on"
Finished reading symbols from nm: Time: 38 ms
-> 3^done
4-interpreter-exec console "set print asm-demangle on"
-> =cmd-param-changed,param="print asm-demangle",value="on"
-> 4^done
5-enable-pretty-printing
-> 5^done
6-interpreter-exec console "source c:/Users/user/.vscode/extensions/marus25.cortex-debug-1.12.1/support/gdbsupport.init"
-> 6^done
7-interpreter-exec console "source c:/Users/user/.vscode/extensions/marus25.cortex-debug-1.12.1/support/gdb-swo.init"
-> =cmd-param-changed,param="language",value="c"
-> =cmd-param-changed,param="language",value="auto"
-> 7^done
8-interpreter-exec console "set output-radix 0xa"
-> ~"Output radix now set to decimal 10, hex a, octal 12.\n"
Output radix now set to decimal 10, hex a, octal 12.
-> 8^done
9-interpreter-exec console "set input-radix 0xa"
-> ~"Input radix now set to decimal 10, hex a, octal 12.\n"
Input radix now set to decimal 10, hex a, octal 12.
-> 9^done
10-file-exec-and-symbols "C:/Users/user/dev/repo-pico-rust/knurling-app-template/target/thumbv6m-none-eabi/debug/count"
-> 10^done
11-target-select extended-remote [::1]:1337
-> =thread-group-started,id="i1",pid="1"
-> =thread-created,id="1",group-id="i1"
-> =thread-created,id="2",group-id="i1"
-> ~"0x000000ee in ?? ()\n"
0x000000ee in ?? ()
-> *stopped,frame={addr="0x000000ee",func="??",args=[],arch="armv6s-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
Program stopped, probably due to a reset and/or halt issued by debugger
-> &"warning: could not convert 'main' from the host encoding (CP1252) to UTF-32.\nThis normally should not happen, please file a bug report."
warning: could not convert 'main' from the host encoding (CP1252) to UTF-32.
This normally should not happen, please file a bug report.
-> &"\n"

-> 11^connected
12-interpreter-exec console "interpreter-exec console \"monitor reset halt\""
-> @"Resetting and halting target\n"
Resetting and halting target
-> @"Target halted\n"
Target halted
-> 12^done
13-enable-pretty-printing
-> 13^done
14-break-insert "c:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs:42"
-> ~"Note: automatically using hardware breakpoints for read-only addresses.\n"
Note: automatically using hardware breakpoints for read-only addresses.
-> 14^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x1000038e",func="count::__cortex_m_rt_main",file="src\\bin/count.rs",fullname="C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs",line="42",thread-groups=["i1"],times="0",original-location="c:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs:42"}
Returning dummy thread-id to workaround VSCode issue with pause button not working
Returning dummy stack frame to workaround VSCode issue with pause button not working: {"threadId":1,"startFrame":0,"levels":20}
15-exec-continue --all
-> 15^running
-> *running,thread-id="all"
mi2.status = running
-> =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x1000038e",func="count::__cortex_m_rt_main",file="src\\bin/count.rs",fullname="C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs",line="42",thread-groups=["i1"],times="1",original-location="c:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs:42"}
-> ~"\n"

-> ~"Thread 1 hit Breakpoint 1, count::__cortex_m_rt_main () at src\\bin/count.rs:42\n"
Thread 1 hit Breakpoint 1, count::__cortex_m_rt_main () at src\bin/count.rs:42
-> ~"42\t        defmt::println!(\"{}\", count);\n"
42	        defmt::println!("{}", count);
-> *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x1000038e",func="count::__cortex_m_rt_main",args=[],file="src\\bin/count.rs",fullname="C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs",line="42",arch="armv6s-m"},thread-id="1",stopped-threads="all"
mi2.status = stopped
16-thread-list-ids
-> 16^done,thread-ids={thread-id="1",thread-id="2"},current-thread-id="1",number-of-threads="2"
17-thread-info 1
-> 17^done,threads=[{id="1",target-id="Thread 1.1",details="core0",frame={level="0",addr="0x1000038e",func="count::__cortex_m_rt_main",args=[],file="src\\bin/count.rs",fullname="C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs",line="42",arch="armv6s-m"},state="stopped"}]
18-thread-info 2
-> 18^done,threads=[{id="2",target-id="Thread 1.2",details="core1",frame={level="0",addr="0x00000178",func="??",args=[],arch="armv6s-m"},state="stopped"}]
19-stack-list-frames --thread 1 0 19
-> 19^done,stack=[frame={level="0",addr="0x1000038e",func="count::__cortex_m_rt_main",file="src\\bin/count.rs",fullname="C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs",line="42",arch="armv6s-m"},frame={level="1",addr="0x100002d8",func="count::__cortex_m_rt_main_trampoline",file="src\\bin/count.rs",fullname="C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs",line="10",arch="armv6s-m"}]
20-stack-info-frame --thread 1 --frame 0
-> 20^done,frame={level="0",addr="0x1000038e",func="count::__cortex_m_rt_main",file="src\\bin/count.rs",fullname="C:\\Users\\user\\dev\\repo-pico-rust\\knurling-app-template\\src\\bin\\count.rs",line="42",arch="armv6s-m"}
21-stack-list-variables --thread 1 --frame 0 --simple-values
-> 21^done,variables=[{name="arg0",type="*mut i32",value="0x2003fb70"},{name="count",type="i32",value="0"},{name="delay",type="cortex_m::delay::Delay"},{name="clocks",type="rp2040_hal::clocks::ClocksManager"},{name="wd",type="rp2040_hal::watchdog::Watchdog"}]
22-var-create --thread 1 --frame 0 var_arg0_4096 @ "arg0"
-> 22^done,name="var_arg0_4096",numchild="1",value="0x2003fb70",type="*mut i32",has_more="0"
23-var-create --thread 1 --frame 0 var_count_4096 @ "count"
-> 23^done,name="var_count_4096",numchild="0",value="0",type="i32",has_more="0"
24-var-create --thread 1 --frame 0 var_delay_4096 @ "delay"
-> 24^done,name="var_delay_4096",numchild="2",value="{...}",type="cortex_m::delay::Delay",has_more="0"
25-var-create --thread 1 --frame 0 var_clocks_4096 @ "clocks"
-> 25^done,name="var_clocks_4096",numchild="11",value="{...}",type="rp2040_hal::clocks::ClocksManager",has_more="0"
26-var-create --thread 1 --frame 0 var_wd_4096 @ "wd"
-> 26^done,name="var_wd_4096",numchild="2",value="{...}",type="rp2040_hal::watchdog::Watchdog",has_more="0"

Additional context

Everything else seems to work: I can see 2 call stacks, one per core, and I can set breakpoints and see the execution to stop at the given point. I didn't test much but it seems fine. I'm more worried about having a smooth workflow.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions