1

I'm trying to remote debug a c++ app from a VM ubuntu 16.04 amd64 host to a debian armbian target of cubietruck board (ARM® Cortex™-A7 Dual-Core) via vs code.
I have follwed this guide https://medium.com/@spe_/debugging-c-c-programs-remotely-using-visual-studio-code-and-gdbserver-559d3434fb78 with the only addition of the field

"setupCommands": [
          {
              "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true
          }
      ],

so the whole launch.json has become

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "C++ Launch",
        "type": "cppdbg",
        "request": "launch",
        "miDebuggerPath": "/home/user/ARM/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb",
        "setupCommands": [
          {
              "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true
          }
      ],
        "program": "/home/user/myproject/bin/app",
        "miDebuggerServerAddress": "localhost:9091",
        "args": [],
        "stopAtEntry": false,
        "cwd": "/home/user/myproject",
        "environment": [],
        "externalConsole": true,
        "linux": {
          "MIMode": "gdb"
        },
        "osx": {
          "MIMode": "gdb"
        },
        "windows": {
          "MIMode": "gdb"
        }
      }
    ]
  }

in launch.json file so as to support pretty printer.
In the host I'm using the linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf gdb while the gdb in arm board has the native 8.0.1 gdb.
Everything works fine except from the pretty printer since the strings are not shown correctly. Whenever I hover over a string the fields npos and _M_dataplus pop up and one should open the _M_dataplus filed to see the actual string.
In host the linaro gdb supports pretty-printer since the command info pretty-printer gives the output :

builtin  
mpx_bound128 

However when I give the same command in target gdb 8.0.1, I get:

Undefined info command: "pretty-printer".  Try "help info".

I also created a .gdbinit file in my host home folder that contains the enable pretty-printer command. I saw in the debug console that it was executed successfully but the result was erroneous as well.
Since I am pretty novice in remote debugging, what should I do to get the pretty-printer working. Should I install pretty-printer in the remote board as well or am I doing something else wrong?

dk13
  • 1,461
  • 4
  • 20
  • 47

1 Answers1

0

1.make sure your bin is NOT built with -static-libstdc++

2.if you have to use -static-libstdc++, please add the following in your ~/.gdbinit:

python sys.path.append('/usr/share/gdb/python')  <--provided by gdb `show configuration: --with-gdb-datadir=`
python sys.path.append("/usr/share/gcc-8/python/")  <--corresponding to your gcc version
source /usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25-gdb.py  <--this script is for std::string/list/map/etc pretty-printing.

3.edit your launch.json:

"setupCommands": [
  { "text": "-interpreter-exec console \"set sysroot /\"", "ignoreFailures": true },
  { "text": "-enable-pretty-printing", "ignoreFailures": true },
],

This is what I did to resolve the same issue occured to me. Hope this would resolve your issue.

ref1: http://tomszilagyi.github.io/2018/03/Remote-gdb-with-stl-pp

ref2: http://transit.iut2.upmf-grenoble.fr/doc/gdb-doc/html/gdb/Writing-a-Pretty_002dPrinter.html

ref3: Import Error: No module name libstdcxx

Charles
  • 115
  • 1
  • 8