Giter Club home page Giter Club logo

Comments (5)

tsondergaard avatar tsondergaard commented on June 26, 2024

The debugger logs provided above are accidentally using an overridden gdb:

$ ll ~/.local/bin/gdb
lrwxrwxrwx 1 ts ts 39 Feb 25 18:58 /home/ts/.local/bin/gdb -> /opt/rh/gcc-toolset-13/root/usr/bin/gdb

But behaviour is the same with RHEL 9.4 stock /usr/bin/gdb (GNU gdb (GDB) Red Hat Enterprise Linux 10.2-13.el9)

from vscode-cpptools.

tsondergaard avatar tsondergaard commented on June 26, 2024

I can reproduce the behaviour with /usr/bin/gdb on the command line using --interpreter=mi using this string of commands:

  • -gdb-set target-async on
  • -file-exec-and-symbols /bin/echo
  • -exec-arguments foo;bar
  • -exec-run

As can be seen the inferior outputs only foo, not foo;bar:

$ /usr/bin/gdb --interpreter=mi -nx -q
=thread-group-added,id="i1"
(gdb)
-gdb-set target-async on
^done
(gdb)
-file-exec-and-symbols /bin/echo
^done
(gdb)
-exec-arguments foo;bar
^done
(gdb)
-exec-run
=thread-group-started,id="i1",pid="23252"
=thread-created,id="1",group-id="i1"
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007ffff7fc9090",to="0x00007ffff7feeb43"}]
^running
*running,thread-id="all"
(gdb)
=library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007ffff7dd4700",to="0x00007ffff7f4740d"}]
~"[Thread debugging using libthread_db enabled]\n"
~"Using host libthread_db library \"/lib64/libthread_db.so.1\".\n"
foo
~"[Inferior 1 (process 23252) exited normally]\n"
=thread-exited,id="1",group-id="i1"
=thread-group-exited,id="i1",exit-code="0"
*stopped,reason="exited-normally"

If I change -exec-arguments foo;bar to -exec-arguments "foo;bar" then /bin/echo outputs foo;bar.

from vscode-cpptools.

tsondergaard avatar tsondergaard commented on June 26, 2024

Hm, I can see with execsnoop that gdb actually uses bash to launch the executable:

$ sudo -E /usr/share/bcc/tools/execsnoop |grep foo
bash             3880    3853      0 /bin/bash -c exec /usr/bin/echo foo;bar
echo             3880    3853      0 /usr/bin/echo foo

This also happens when I just run gdb --args /bin/echo "foo;bar", but here I can see in the execsnoop output that the semicolon gets escaped:

$ sudo -E /usr/share/bcc/tools/execsnoop |grep foo
gdb              5952    16623     0 /usr/bin/gdb --args /bin/echo foo;bar
bash             5974    5952      0 /bin/bash -c exec /usr/bin/echo foo\;bar
echo             5974    5952      0 /usr/bin/echo foo;bar

I also checked qt-creator version 12.0.1 and it has the same behaviour as Visual Studio Code, i.e. the same bug. Now I'm uncertain if this is an issue in Visual Studio Code or gdb.

from vscode-cpptools.

tsondergaard avatar tsondergaard commented on June 26, 2024

I can disable gdb's use of a shell with set startup-with-shell off or equivalently in gdb MI lingo -gdb-set startup-with-shell off. Doing this fixes the reported issue.

This means this is not a vscode or vscode-cpptools problem as adding "setupCommands": [ { "text": "-gdb-set startup-with-shell off" }] allows this to be done. Here is the full working configuration:

      {
        "name": "example",
        "type": "cppdbg",
        "request": "launch",
        "program": "/bin/echo",
        "args": [
             "foo;bar"
        ],
        "cwd": "${workspaceFolder}",
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [ { "text": "-gdb-set startup-with-shell off" }]
      }

from vscode-cpptools.

tsondergaard avatar tsondergaard commented on June 26, 2024

Not a vscode-cpptools problem. Closing issue.

from vscode-cpptools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.