Skip to content

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

@kmARC

Description

@kmARC

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

  • If you are using gdb
    • gdb --version >= 7.7.1
    • it works on the command line with gdb
    • 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+/;

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