From 4b14d961f09019d8ec8d12fb97daf8a840312c32 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 6 May 2024 22:36:56 +0200 Subject: [PATCH] Add LLDB summary for Vector. --- .vscode/settings.json | 1 + extra/natvis.py | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 extra/natvis.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 26010971..a43d1784 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,4 +16,5 @@ "variant": { "statusBarVisibility": "compact" } }, "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json", + "lldb.launch.initCommands": ["command script import ${workspaceRoot}/extra/natvis.py"], } diff --git a/extra/natvis.py b/extra/natvis.py new file mode 100644 index 00000000..3e6b6272 --- /dev/null +++ b/extra/natvis.py @@ -0,0 +1,11 @@ +import lldb + +def VectorSummary(value, dict): + size = value.GetChildMemberWithName('m_size').GetValueAsUnsigned() + capacity = 1 << value.GetChildMemberWithName('m_capacity').GetValueAsUnsigned() + magic = bool(value.GetChildMemberWithName('m_magic').GetValueAsUnsigned()) + return 'size={0}, capacity={1}, magic={2}'.format(size, capacity, magic) + +def __lldb_init_module(debugger, dict): + debugger.HandleCommand('type summary add -w tracy -F natvis.VectorSummary -x ^tracy::Vector<.+>') + debugger.HandleCommand('type category enable tracy')