code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

Standard output parsing changes lines with `@` (at) symbol in them to "undefined"

Open kmARC opened this issue 1 year ago • 0 comments

When the debugged process tries to print lines with an @ (at) symbol, some parsing mechanism removes it from the debug console output and eventually prints undefined

  • [x] If you are using gdb
    • [x] gdb --version >= 7.7.1
    • [x] it works on the command line with gdb
    • [x] cwd and target are properly set

Screenshot from Debug Console:

Screenshot 2024-06-17 at 15 02 20

Screenshot from terminal gdb:

Screenshot 2024-06-17 at 15 14 35

Reproducible example

Example main.cpp
#include <iostream>

// $ g++ -g main.cpp

int main()
{
    std::cout << "test: FOO@BAR" << std::endl;
    std::cerr << "test: FOO@BAR" << std::endl;
    std::cout << "test: FOO<at>BAR" << std::endl;
    std::cerr << "test: FOO<at>BAR" << std::endl;
}
Example launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "gdb",
            "request": "launch",
            "target": "a.out",
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText"
        }
    ]
}
System details (linux, gdb, code version)

$ gdb --version
GNU gdb (GDB) Rocky Linux 10.2-11.1.el9_3
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ uname -a
Linux <...> 5.10.154-1.base.x86_64 #1 SMP Tue Nov 15 15:31:24 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ code --version
1.90.1
611f9bfce64f25108829dd295f54a6894e87339d
x64

Workaround

I found that removing \@ from src/backend/mi2/mi2.ts#L15 would result in keeping the lines with @ in it, however an undefined output still appear

± git diff
diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts
index e641160..156dc41 100644
--- a/src/backend/mi2/mi2.ts
+++ b/src/backend/mi2/mi2.ts
@@ -12,7 +12,7 @@ export function escape(str: string) {
        return str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
 }
 
-const nonOutput = /^(?:\d*|undefined)[\*\+\=]|[\~\@\&\^]/;
+const nonOutput = /^(?:\d*|undefined)[\*\+\=]|[\~\&\^]/;
 const gdbMatch = /(?:\d*|undefined)\(gdb\)/;
 const numRegex = /\d+/;

kmARC avatar Jun 17 '24 13:06 kmARC