Skip to content

pio debug --interface=gdb --interpreter=mi2 generates malformed GDB-MI messages #4959

Open
@HanyzPAPU

Description

@HanyzPAPU

What kind of issue is this?

  • PlatformIO Core.

Configuration

Operating system:
Windows

Edition Windows 11 Pro
Version 23H2
OS build 22631.3880

PlatformIO Version (platformio --version):

PlatformIO Core, version 6.1.15

Description of problem

When running pio debug --interface=gdb --interpreter=mi2 -x .pioinit the program sometimes sends malformed output records.

For example: @"P"(gdb) or @"S"(gdb). As per GDB-MI specification, there should be a new line between the @"P" and (gdb).

Steps to Reproduce

  1. Create a new nrf52840_dk arduino project with j-link debug probe
  2. pio debug --interface=gdb --interpreter=mi2 -x .pioinit

Actual Results

\n""@"EGGER J-Link GDB Server V7.88k Command Line Version
\n"arget endian:                 little0kHzxAA@"ly-device nRF52840_xxAA -port 2"@"331
\n"onnecting to J-Link...
\n""@"-Link is connected.
\n"eature(s): RDI, FlashBP, FlashDL, JFlash, GDBiled Oct 30 2023 12:13:06
\n"arget voltage: 3.30 Vtage...
\n"onnecting to target...port 2331
\nWaiting for GDB connection..."=thread-group-added,id="i1"
~"Reading symbols from C:\\Users\\jan.papesch\\CLionProjects\\untitled8\\.pio\\build\\nrf52840_dk\\firmware.elf..."
~"done.\n"
~"PlatformIO Unified Debugger -> https://bit.ly/pio-debug\n"
~"PlatformIO: debug_tool = jlink\n"
~"PlatformIO: Initializing remote target...\n"
\n""@"onnected to 127.0.0.1
\n""@"DB client (conn. 876) requested target.xml from GDB Server
=thread-group-started,id="i1",pid="42000"
=thread-created,id="1",group-id="i1"
\n"ead register 'xpsr' (4 bytes) from hardware: 0x03000001Fes) f"@"rom hardware: 0x00000000
\n""@"ead 4 bytes @ address 0xFFFFFFFE (Data = 0xFFFF00"@"00)
\n""@"ead 2 bytes @ address 0xFFFFFFFE (Data = 0x0000)
~"0xfffffffe in ?? ()\n"
*stopped,frame={addr="0xfffffffe",func="??",args=[]},thread-id="1",stopped-threads="all"
\n""@"eceived monitor command: clrbp
\n""@"eceived monitor command: speed auto
\n""@"elect auto target interface speed (2000 kHz)
@"Select auto target interface speed (2000 kHz)\r\n"
\n""@"eceived monitor command: reset
\n""@"esetting target
@"Resetting target\r\n"
\n"..Target halted (PC = 0xFFFFFFFE)
\n""@"ownloading 2468 bytes @ address 0x00000000
+download,{section=".text",section-size="2468",total-size="62058"}
@"D"+download,{section=".text",section-sent="2468",section-size="2468",total-sent="2468",total-size="62058"}
\n"wnloading 8 bytes @ address 0x000009A4
\n"ownloading 108 bytes @ address 0x000009AC
+download,{section=".ARM.exidx",section-size="8",total-size="62058"}
+download,{section=".data",section-size="108",total-size="62058"}
\n""@"riting register 'pc' = 0x000002E4
\n"ead 2 bytes @ address 0x000002E4 "@"(Data = 0x4906)906)
\n"eading 64 bytes @ address 0x00000700
\n"ead 2 bytes @ address 0x0000072A (Data = 0xF000)
=breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000072a",func="main()",file="C:\\Users\\jan.papesch\\.platformio\\packages\\framework-arduinonordicnrf5\\cores\\nRF5\\main.cpp",fullname="C:\\Users\\jan.papesch\\.platformio\\packages\\framework-arduinonordicnrf5\\cores\\nRF5\\main.cpp",line="29",thread-groups=["i1"],times="0",original-location="main"}
~"PlatformIO: Initialization completed\n"
(gdb)
~"PlatformIO: Resume the execution to `debug_init_break = tbreak main`\n"
~"PlatformIO: More configuration options -> https://bit.ly/pio-debug\n"
0^running
*running,thread-id="all"
(gdb)
\n""@"etting breakpoint @ address 0x0000072A, Kind = 2, Type = "@"THUMB, BPHandle = 0x0"@"001
\n""@"tarting target CPU...

Expected Results

At line @"D"+download,{section=".text",section-sent="2468",section-size="2468",total-sent="2468",total-size="62058"}
there should be newline after @"D", so:

@"D"
+download,{section=".text",section-sent="2468",section-size="2468",total-sent="2468",total-size="62058"}

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:nrf52840_dk]
platform = nordicnrf52
board = nrf52840_dk
framework = arduino

Source file to reproduce issue:

#include <Arduino.h>

void setup() {
    // PIN_BUTTON1 is LED1
    pinMode(PIN_BUTTON1, OUTPUT);
}

void loop() {
    digitalWrite(PIN_BUTTON1, HIGH);
    delay(500);
    digitalWrite(PIN_BUTTON1, LOW);
    delay(500);
}

Additional info

GDB MI spec

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions