【问题标题】:Pretty-printer is not working when remote debugging an arm board via vs code通过 vs code 远程调试 arm 板时 Pretty-printer 不工作
【发布时间】:2018-12-07 17:08:28
【问题描述】:

我正在尝试通过 vs 代码从 VM ubuntu 16.04 amd64 主机远程调试 c++ 应用程序到 cubietruck 板(ARM® Cortex™-A7 双核)的 debian armbian 目标。
我已经按照这个指南https://medium.com/@spe_/debugging-c-c-programs-remotely-using-visual-studio-code-and-gdbserver-559d3434fb78 只添加了字段

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

所以整个launch.json变成了

{
    "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"
        }
      }
    ]
  }

在launch.json文件中以支持漂亮的打印机。
在主机中,我使用的是 linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf gdb,而 arm 板中的 gdb 具有本机 8.0.1 gdb。
一切正常,除了漂亮的打印机,因为字符串显示不正确。每当我将鼠标悬停在字符串上时,都会弹出 npos 和 _M_dataplus 字段,并且应该打开 _M_dataplus 字段以查看实际字符串。
在主机中,linaro gdb 支持漂亮的打印机,因为命令 info pretty-printer 给出了输出:

builtin  
mpx_bound128 

但是,当我在目标 gdb 8.0.1 中给出相同的命令时,我得到:

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

我还在我的主机主文件夹中创建了一个 .gdbinit 文件,其中包含 enable pretty-printer 命令。我在调试控制台中看到它执行成功,但结果也是错误的。
由于我是远程调试的新手,我应该怎么做才能让漂亮的打印机正常工作。我应该在远程板上也安装漂亮的打印机还是我做错了什么?

【问题讨论】:

    标签: c++ visual-studio-code arm gdb remote-debugging


    【解决方案1】:

    1.确保您的垃圾箱不是使用-static-libstdc++

    构建的

    2.如果你必须使用-static-libstdc++,请在你的~/.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.编辑你的launch.json:

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

    这是我为解决发生在我身上的同样问题所做的。希望这能解决您的问题。

    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

    【讨论】:

      猜你喜欢
      • 2021-04-25
      • 2016-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-22
      • 2017-07-20
      • 2021-03-17
      相关资源
      最近更新 更多