简体   繁体   English

使用LLDB检查VSCode中的C ++ std :: set

[英]inspect C++ std::set in VSCode with LLDB

This is a VSCode specific question. 这是VSCode的特定问题。

Asking here since the VSCode repo points to asking question on SO. 自VSCode回购以来,在这里提出问题就指向了SO的问题。

I'm using VSCode on Mac OS, with LLDB . 在Mac OS和LLDB上使用VSCode

I'm trying to figure out how to inspect a std::set . 我试图弄清楚如何检查 std::set

I can't find any doc on this; 我找不到任何相关文档; I found some ways to do it with GDB using macros ( https://sourceware.org/ml/gdb/2008-02/msg00064/stl-views.gdb ) 我发现了一些使用宏通过GDB做到这一点的方法( https://sourceware.org/ml/gdb/2008-02/msg00064/stl-views.gdb

but I can't get GDB to work with VS Code (used the WebFreak Native Debug extension but on run I just get "running executable" and nothing happening, no error, no log, so I gave up on that) 但是我无法让GDB与VS Code一起使用(使用了WebFreak本机调试扩展,但是在运行时,我只是获得了“正在运行的可执行文件”,没有任何反应,没有错误,没有日志,因此我放弃了)

LLDB has worked good for me so far (using -DDEBUG=2 flags to get symbols working right), but I see nothing when trying to open a set in the variables frame. 到目前为止,LLDB对我来说一直很好(使用-DDEBUG=2标志使符号正常工作),但是在variables框架中尝试打开set时,我什么也看不到。

I only get the number of items in it. 我只得到其中的物品数量。

Is there similar macros as the GDB ones to inspect sets in LLDB? 是否有与GDB类似的宏来检查LLDB中的集? Or is there some other way? 还是有其他方法?

Thanks 谢谢

lldb uses "data formatters" to pretty print objects. lldb使用“数据格式化程序”来漂亮地打印对象。 See: 看到:

http://lldb.llvm.org/varformats.html http://lldb.llvm.org/varformats.html

for more details. 更多细节。

lldb has built-in data formatters for std::set from the clang standard libraries. lldb具有来自clang标准库的std :: set内置数据格式化程序。 If VSCode uses that version of the C++ standard library then the data formatters should fire automatically. 如果VSCode使用该版本的C ++标准库,则数据格式化程序应自动触发。 If VSCode gives you access to the lldb command line, you can check the std::set data formatter thusly: 如果VSCode允许您访问lldb命令行,则可以这样检查std :: set数据格式化程序:

(lldb) fr v my_set
(std::__1::set<int, std::__1::less<int>, std::__1::allocator<int> >) my_set = size=3 {
  [0] = 100
  [1] = 200
  [2] = 300
}

If you see the elements broken out then the data formatters are working (and you can use the console to view them.) If they use a different version of the STL, then the link above will get you started writing data formatters for their object layout. 如果看到元素破裂,则数据格式化程序正在运行(并且您可以使用控制台来查看它们。)如果它们使用其他版本的STL,则上面的链接将使您开始为其对象布局编写数据格式化程序。 。

The data formatters also hook into the API's lldb provides to inspect values, but it may be that VSCode is using lldb's emulation of gdb's "Machine Interface" layer, in which case it won't be able to access the data formatter results. 数据格式化程序还连接到API的lldb提供来检查值,但是VSCode可能正在使用lldb对gdb的“机器接口”层的仿真,在这种情况下,它将无法访问数据格式化程序的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM