eclipse-cdt-cloud / cdt-gdb-adapter

CDT GDB Debug Adapter
Eclipse Public License 2.0
30 stars 40 forks source link

On Windows, "\r\n" sends an extra new line #317

Closed XingMicrochip closed 10 months ago

XingMicrochip commented 10 months ago

Hi @jonahgraham,

When we debug on Windows through the IDE using the adapter, we see an extra new line if we send a \r\n character to the UART. This only happens on Windows, but not Linux. If we send \n, then it works on both Windows and Linux (there's no extra new line). We suspect it's an issue with the adapter because \r\n works fine if we debug through the command line (using a manual flow) without the adapter. Do you by any chance know why this happens and if it's an issue with the adapter?

Relevant part of the application code:

UART_polled_tx_string(&g_core_uart_0, "CoreTimer timer interrupt.\r\n");

Windows IDE debug console:

CoreTimer timer interrupt.

CoreTimer timer interrupt.

CoreTimer timer interrupt.

CoreTimer timer interrupt.

CoreTimer timer interrupt.

Linux IDE debug console (also the expected output):

CoreTimer timer interrupt.
CoreTimer timer interrupt.
CoreTimer timer interrupt.
CoreTimer timer interrupt.
CoreTimer timer interrupt.
jonahgraham commented 10 months ago

@XingMicrochip can you look at what @AdhamRagabMCHP did in https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/pull/280 as it seems to have been trying to solve the opposite issue of missing newline. It certainly sounds like something the adapter does.

XingMicrochip commented 10 months ago

It seems @AdhamRagabMCHP faced the same issue here: https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/pull/280#issuecomment-1630899743. My debug log looks like this on Windows, which I think causes the extra new line issue (on Linux there's no extra \r):

[14:32:05.909 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"Socket","output":"CoreTimer timer interrupt.\r\r\n"}}
[14:32:06.552 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"Socket","output":"CoreTimer timer interrupt.\r\r\n"}}
[14:32:07.161 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"Socket","output":"CoreTimer timer interrupt.\r\r\n"}}
[14:32:07.747 UTC] To client: {"seq":0,"type":"event","event":"output","body":{"category":"Socket","output":"CoreTimer timer interrupt.\r\r\n"}}

He avoided this issue by changing the test in this commit: https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/pull/280/commits/f87a505f749bd9b2c12339df5de811d2690a0228 to send \n in the application. But the old test sending \r\n is our currently application code - on Windows, it sends \r\n. I guess I will need to modify the adapter to support this case.

Do you have a better solution for this?

XingMicrochip commented 10 months ago

Do you know where the code parses "CoreTimer timer interrupt.\r\n" into "CoreTimer timer interrupt.\r\r\n"? This behavior doesn't look correct.

jonahgraham commented 10 months ago

I don't know without debugging it, sorry. I'm not likely to have time to look at it closer this week, but perhaps on Monday we can try some pair programming if you haven't identified it by then.

XingMicrochip commented 10 months ago

I think I found a bug with parsing UART output. I'll put up a PR once fixed.

jonahgraham commented 10 months ago

Fixed by #318

jonahgraham commented 10 months ago

@XingMicrochip v0.0.108 should be published to open vsx overnight