.natvis not supported base class members by lldb on mac
Type: Debugger
When I use .natvis file for data visualizer in VSCode, we got the following error:
error: error: no member named 'Base' in 'Object'\nerror: expected expression\nerror: 2 errors parsing expression\n
And we have found 2 issues during debug data visuallize:
.natvisdoes not support base class members for derive classestd::string / std::vectorcould not be customized by.natvisfile
Describe the bug
- OS and Version: macOS Mojave (version: 10.14.5)
- VS Code Version: Version 1.35.1 (1.35.1)
- GCC Version: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
- lldb Version: lldb-1001.0.13.3
- C/C++ Extension Version: Version 1.35.1 (1.35.1)
- Other extensions you installed (and if the issue persists after disabling them):
code --install-extension adashen.vscode-tomcat
code --install-extension blzjns.vscode-raml
code --install-extension cschlosser.doxdocgen
code --install-extension cssho.vscode-svgviewer
code --install-extension dbaeumer.jshint
code --install-extension dbaeumer.vscode-eslint
code --install-extension DotJoshJohnson.xml
code --install-extension eamodio.gitlens
code --install-extension EditorConfig.EditorConfig
code --install-extension eg2.tslint
code --install-extension eriklynd.json-tools
code --install-extension fuchsia-authors.language-fidl
code --install-extension Gruntfuggly.todo-tree
code --install-extension jebbs.plantuml
code --install-extension momoto.binary-viewer
code --install-extension ms-python.python
code --install-extension ms-vscode.cpptools
code --install-extension ms-vscode.vscode-typescript-tslint-plugin
code --install-extension msjsdiag.debugger-for-chrome
code --install-extension naumovs.node-modules-resolve
code --install-extension redhat.java
code --install-extension shd101wyy.markdown-preview-enhanced
code --install-extension slevesque.vscode-hexdump
code --install-extension twxs.cmake
code --install-extension vscjava.vscode-java-debug
code --install-extension vscjava.vscode-java-dependency
code --install-extension vscjava.vscode-java-pack
code --install-extension vscjava.vscode-java-test
code --install-extension vscjava.vscode-maven
code --install-extension vscode-icons-team.vscode-icons
code --install-extension wayou.vscode-todo-highlight
code --install-extension xabikos.JavaScriptSnippets
code --install-extension xaver.clang-format
- A clear and concise description of what the bug is.
To Reproduce

-
base (Base class)
var
baseworks file. -
obj (Object class) NOK
Class
Objectderived from classBase. ButBasemembers does not support forObjectfor.natvisdata visuallizer.error: error: no member named 'Base' in 'Object'\nerror: expected expression\nerror: 2 errors parsing expression\n -
welcome (std::string) Could not be customized by .natvis file
-
vecInt (std::vector) Could not be customized by .natvis file
Additional context
- Source Code
#include <iostream>
#include <string>
#include <vector>
class Base {
public:
int32_t a;
int32_t b;
};
class Object : public Base {
public:
int32_t c;
};
int main() {
Base base;
base.a = 10;
base.b = 20;
Object obj;
obj.b = 100;
obj.c = 200;
obj.a = 500;
std::string welcome = "hello, world!";
std::vector<uint32_t> vecInt;
vecInt.push_back(100);
vecInt.push_back(200);
vecInt.push_back(300);
vecInt.push_back(400);
std::cout << welcome << "\n------- Done -------\n";
return 0;
}
- launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/visualData",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"logging": {
"exceptions": true,
"programOutput": true,
"moduleLoad": true,
"engineLogging": false,
"trace": false,
"traceResponse": false
},
"visualizerFile": "${workspaceRoot}/.vscode/debug-data-visualizer.natvis",
"showDisplayString": true
}
]
}
- debug-data-visualizer.natvis
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="std::vector<*>">
<DisplayString>{{ this={_Myfirst} (vector) }}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple">_Mylast - _Myfirst</Item>
<Item Name="[capacity]" ExcludeView="simple">_Myend - _Myfirst</Item>
<ArrayItems>
<Size>_Mylast - _Myfirst</Size>
<ValuePointer>_Myfirst</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="std::string<*>">
<DisplayString>{{ this={_Myfirst} (string)}}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple">_Mylast - _Myfirst</Item>
<Item Name="[capacity]" ExcludeView="simple">_Myend - _Myfirst</Item>
<ArrayItems>
<Size>_Mylast - _Myfirst</Size>
<ValuePointer>_Myfirst</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="std::string">
<DisplayString>{{ this={_Myfirst} (string)}}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple">_Mylast - _Myfirst</Item>
<Item Name="[capacity]" ExcludeView="simple">_Myend - _Myfirst</Item>
<ArrayItems>
<Size>_Mylast - _Myfirst</Size>
<ValuePointer>_Myfirst</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="Base">
<DisplayString>{{ a={a} b={b} }}</DisplayString>
</Type>
<Type Name="Object">
<DisplayString>{{ c={c} }}</DisplayString>
<Expand>
<Item Name="Base [Base]">(Base*)this,nd</Item>
</Expand>
</Type>
<!-- https://docs.microsoft.com/zh-cn/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2015 -->
</AutoVisualizer>
This issue has been closed automatically because it has not had recent activity.