microsoft / microsoft/vscode-cpptools

How to let VS CODE print std::string of libc++?

Open
#12,324 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger help wanted Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: windows 10
  • VS Code Version: 1.89.1
  • C/C++ Extension Version: libc++
  • If using SSH remote, specify OS of remote machine: 5.10.16.3-microsoft-standard-WSL2
Bug Summary and Steps to Reproduce

I use libc++ as following:
https://libcxx.llvm.org/UsingLibcxx.html#gdb-pretty-printers-for-libc

GDB Pretty printers for libc++
GDB does not support pretty-printing of libc++ symbols by default. However, libc++ does provide pretty-printers itself. Those can be used as:

$ gdb -ex "source /utils/gdb/libcxx/printers.py"
-ex "python register_libcxx_printer_loader()"

then I can print string or vector in linux in gdb, and I can print it ok aslo in vsocde in debuger console as following:

-exec p request_body
$1 = (const std::__1::string &) @0x7ffff3eebc48: ""

But I put the mouse on the variable of the code, and the original data will still be displayed.

std::__1::__basic_string_common (base):
std::__1::__basic_string_common
npos:
18446744073709551615
__short_mask:
128
__long_mask:
9223372036854775808
_r

Configuration and Logs
launch.json is here
    "version": "0.2.0",
    "configurations": [
        {
            ...
            "request": "launch",
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb",  
            "setupCommands": [
                {
                    "description": "",
                    "text": "source xxx/libc++/trunk/utils/gdb/libcxx/printers.py",
                    "ignoreFailures": true
                },
                {
                    "description": "",
                    "text": "python register_libcxx_printer_loader()",
                    "ignoreFailures": true
                },
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the launch.json setupCommands and the libcxx/printers.py configuration described in the issue. Compare the working GDB debug-console output with the variable hover display in VS Code. Done means determining why the hover still exposes libc++ internals and documenting or correcting the relevant behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.