microsoft / microsoft/vscode-cpptools
Natvis: Size specifier for array-like structures is not working
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
Environment
- OS and version: Linux
- VS Code: 1.85.2
- C/C++ extension: 1.18.5
- OS and version of remote machine (if applicable): RHEL 7.6
- GDB / LLDB version: 10.2
Bug Summary and Steps to Reproduce
Bug Summary:
In my natvis file, I am trying to create a visualizer for GCC's std::string_view, and I am using a method similar to how MSVC displays their std::string_view. It looks like so:
<Type Name="std::string_view">
<AlternativeType Name="std::basic_string_view<*,*>" />
<DisplayString>{_M_str,[_M_len]na}</DisplayString>
<StringView>_M_str,[_M_len]na</StringView>
<Expand>
<Item Name="[size]" ExcludeView="simple">_M_len</Item>
<ArrayItems ExcludeView="simple">
<Size>_M_len</Size>
<ValuePointer>_M_str</ValuePointer>
</ArrayItems>
</Expand>
</Type>
During debugging, the DisplayString just reports "-var-create: unable to create variable object".
If I remove the size specifier, it works, but this isn't correct because a std::string_view doesn't necessarily need to be a null-terminated string.
Steps to reproduce:
- Start a remote debugging session to a linux server (haven't tried this with running directly on my linux machine)
- Use a custom natvis file with the above
std::string_viewvisualizer - Create a c++ program that uses
std::string_view - Start a debugging session of a c++ application
- Try to visualize the
std::string_viewand see the "-var-create" option
Debugger Configurations
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach MyProgram",
"type": "cppdbg",
"request": "attach",
"program": "/path/to/my/program",
"visualizerFile": "${workspaceFolder}/stl.natvis",
"showDisplayString": true,
"miDebuggerPath": "/usr/local/bin/gdb",
"MIMode": "gdb"
}
]
}
Debugger Logs
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (31423) <-2235-var-create - * \"((lPattern)._M_str),[((lPattern)._M_len)]na\"\n"},"seq":10547}
1: (31423) <-2235-var-create - * "((lPattern)._M_str),[((lPattern)._M_len)]na"
--> R (variables-33): {"type":"response","request_seq":33,"success":true,"command":"variables","body":{"variables":[{"name":"lPattern","value":"-var-create: unable to create variable object","type":"std::string_view","evaluateName":"lPattern","variablesReference":1002},{"name":"lTagName","value":"0x7fffffff8130 \"\"","type":"std::string","evaluateName":"lTagName","variablesReference":1003},{"name":"lStatus","value":"0","type":"int","evaluateName":"lStatus","variablesReference":0,"memoryReference":"0x0000000000000000"},{"name":"lWaveAll","value":"false","type":"bool","evaluateName":"lWaveAll","variablesReference":0},{"name":"lTagFound","value":"false","type":"bool","evaluateName":"lTagFound","variablesReference":0},{"name":"lInsertPoint","value":"false","type":"bool","evaluateName":"lInsertPoint","variablesReference":0},{"name":"lTagCount","value":"1","type":"int","evaluateName":"lTagCount","variablesReference":0,"memoryReference":"0x0000000000000001"},{"name":"lRecursive","value":"0","type":"int","evaluateName":"lRecursive","variablesReference":0,"memoryReference":"0x0000000000000000"},{"name":"lDepth","value":"-1","type":"int","evaluateName":"lDepth","variablesReference":0},{"name":"lLimit","value":"5000","type":"int","evaluateName":"lLimit","variablesReference":0,"memoryReference":"0x0000000000001388"},{"name":"lCount","value":"false","type":"bool","evaluateName":"lCount","variablesReference":0},{"name":"lIsExtId","value":"false","type":"bool","evaluateName":"lIsExtId","variablesReference":0},{"name":"xPattern","value":"-var-create: unable to create variable object","type":"std::string_view","evaluateName":"xPattern","variablesReference":1004},{"name":"xOptions","value":"-var-create: unable to create variable object","type":"std::string_view","evaluateName":"xOptions","variablesReference":1005},{"name":"xFlush","value":"0","type":"int","evaluateName":"xFlush","variablesReference":0,"memoryReference":"0x0000000000000000"},{"name":"xRequest","value":"{...}","type":"const wave::AddWaveReq &","evaluateName":"xRequest","variablesReference":1006}]},"seq":10587}
Other Extensions
No response
Additional Information
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il file natvis personalizzato e l’espressione ArrayItems Size mostrata nel report, quindi riproduci il malfunzionamento usando la configurazione GDB remoto e il log del debugger forniti. Traccia il modo in cui l’estensione C++ gestisce lo specificatore di dimensione natvis per la visualizzazione di string_view; il lavoro è completato quando il visualizzatore viene creato correttamente e visualizza i caratteri delimitati senza l’errore var-create.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, vscode
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100