From f1d160bbf711d4b8659cde503b19f41e1736be6f Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sat, 17 Feb 2024 18:14:34 +0000 Subject: [PATCH 1/2] Fix error when no valid memory reference --- python3/vimspector/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python3/vimspector/variables.py b/python3/vimspector/variables.py index 181fbde9..4aa9262d 100644 --- a/python3/vimspector/variables.py +++ b/python3/vimspector/variables.py @@ -675,7 +675,7 @@ def GetMemoryReference( self ): # Get a memoryReference for use in a ReadMemory request variable, _ = self._GetVariable( None, None ) if variable is None: - return None + return None, None # TODO: Return the connection too! return variable.connection, variable.MemoryReference() From 1f4e2b5e60c9680d550f6de80219a931922354e0 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Thu, 21 Dec 2023 14:21:46 +0000 Subject: [PATCH 2/2] Update codelldb to v1.10.0 and allow local build run --- python3/vimspector/gadgets.py | 14 +++---- .../rust/vimspector_test/.vimspector.json | 17 +++++++- support/test/rust/vimspector_test/src/main.rs | 8 +++- tests/testdata/cpp/simple/.vimspector.json | 12 ++++++ tests/testdata/cpp/simple/Makefile | 2 +- tests/testdata/cpp/simple/buffer.cpp | 40 +++++++++++++++++++ 6 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 tests/testdata/cpp/simple/buffer.cpp diff --git a/python3/vimspector/gadgets.py b/python3/vimspector/gadgets.py index fb0630c5..82b6882c 100644 --- a/python3/vimspector/gadgets.py +++ b/python3/vimspector/gadgets.py @@ -546,12 +546,12 @@ '${version}/${file_name}', }, 'all': { - 'version': 'v1.9.2', + 'version': 'v1.10.0', }, 'macos': { 'file_name': 'codelldb-x86_64-darwin.vsix', 'checksum': - '0b36e91930bca3344cf9b78984ee85ccacc6dc97ab9be5da935d4596f0dba05c', + '91b10d5670a40434c308c09cb511a5b3e096c82b446a0bbbe4224af33204f5cf', 'make_executable': [ 'adapter/codelldb', 'lldb/bin/debugserver', @@ -562,12 +562,12 @@ 'macos_arm64': { 'file_name': 'codelldb-aarch64-darwin.vsix', 'checksum': - '5db25c0b1277795e2196a9118a38e6984b4787ac2c1e3e3adfeefe537296fc51', + '4ab0795a726bc52d6e2fa8ebc610baa3f262ebea89adac478cf4a34c72167a41', }, 'linux': { 'file_name': 'codelldb-x86_64-linux.vsix', 'checksum': - '898bd22b2505b12671fee7d2fe1abb384dc60d13f5fec2b4b650d0dac3f83d75', + 'd12bff19811974e14688e9754d8d7b9a2430868c3bac883d695032a4acd012ca', 'make_executable': [ 'adapter/codelldb', 'lldb/bin/lldb', @@ -578,17 +578,17 @@ 'linux_arm64': { 'file_name': 'codelldb-aarch64-linux.vsix', 'checksum': - '90c23169d5c32b6c3c6c040622f5f181af3e8a0a7d47e01219ce0af4a70aadb4', + '0a81f6617834754537520b7bae2ea9ad50d26b372f8c8bd967dae099e4b27d06', }, 'linux_armv7': { 'file_name': 'codelldb-arm-linux.vsix', 'checksum': - '971a9def71f8093ee63c1944dd69e3fbada97fc2804d312ab22e75f6d7e4e207', + '4bfc5ee753d4359c9ba3cf8fc726f4245a62fd283b718b5120ef1b404baf68c9', }, 'windows': { 'file_name': 'codelldb-x86_64-windows.vsix', 'checksum': - '1c23239941165d051b904a95c0bbf0853d3ff9b9149cdf36c6763fd4937c95f1', + '2f251384e4356edcffe168439714d00de5ca434b263719cbdaf63c9d2f0ffe64', 'make_executable': [] }, 'adapters': { diff --git a/support/test/rust/vimspector_test/.vimspector.json b/support/test/rust/vimspector_test/.vimspector.json index 6918e47f..13ad7499 100644 --- a/support/test/rust/vimspector_test/.vimspector.json +++ b/support/test/rust/vimspector_test/.vimspector.json @@ -1,12 +1,27 @@ { "$schema": "https://puremourning.github.io/vimspector/schema/vimspector.schema.json", + "adapters": { + "CodeLLDB-localbuild": { + "extends": "CodeLLDB", + "command": [ + "$HOME/Development/vimspector/CodeLLDB/build/adapter/codelldb", + "--port", + "${unusedLocalPort}" + ] + } + }, "configurations": { "Run - CodeLLDB": { "adapter": "CodeLLDB", "configuration": { "request": "launch", - "program": "${workspaceRoot}/target/debug/vimspector_test" + "program": "${workspaceRoot}/target/debug/vimspector_test", + "expressions": "native" } + }, + "CodeLLDB-localbuild": { + "extends": "Run - CodeLLDB", + "adapter": "CodeLLDB-localbuild" } } } diff --git a/support/test/rust/vimspector_test/src/main.rs b/support/test/rust/vimspector_test/src/main.rs index f6fc72db..509a6d43 100644 --- a/support/test/rust/vimspector_test/src/main.rs +++ b/support/test/rust/vimspector_test/src/main.rs @@ -1,4 +1,10 @@ +struct Foo { + x: i32, +} + fn main() { let s = "World!"; - println!("Hello, {}!", s); + let f = Foo { x: 42 }; + let g = &f; + println!("Hello, {} {} {}!", s, g.x, f.x); } diff --git a/tests/testdata/cpp/simple/.vimspector.json b/tests/testdata/cpp/simple/.vimspector.json index 6bd10404..3cf58c2d 100644 --- a/tests/testdata/cpp/simple/.vimspector.json +++ b/tests/testdata/cpp/simple/.vimspector.json @@ -104,6 +104,10 @@ "cpp_catch": "" } } + }, + "CodeLLDB-localbuild": { + "extends": "CodeLLDB", + "adapter": "CodeLLDB-localbuild" } }, "adapters": { @@ -124,6 +128,14 @@ "LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY": "YES" }, "name": "lldb" + }, + "CodeLLDB-localbuild": { + "extends": "CodeLLDB", + "command": [ + "$HOME/Development/vimspector/CodeLLDB/build/adapter/codelldb", + "--port", + "${unusedLocalPort}" + ] } } } diff --git a/tests/testdata/cpp/simple/Makefile b/tests/testdata/cpp/simple/Makefile index 548e883b..f918050c 100644 --- a/tests/testdata/cpp/simple/Makefile +++ b/tests/testdata/cpp/simple/Makefile @@ -1,4 +1,4 @@ -TARGETS=simple variables struct printer threads tiny +TARGETS=simple variables struct printer threads tiny buffer CXXFLAGS=-g -O0 -std=c++17 CFLAGS=-g -O0 diff --git a/tests/testdata/cpp/simple/buffer.cpp b/tests/testdata/cpp/simple/buffer.cpp new file mode 100644 index 00000000..a55be93e --- /dev/null +++ b/tests/testdata/cpp/simple/buffer.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +#include + +struct Foo +{ + uint32_t a; + uint64_t b; + float d; +}; + +static void handle_data(const unsigned char* data, size_t length) +{ + if (length < sizeof(Foo)) + return; + + Foo f; + memcpy(&f, data, sizeof(Foo)); + + std::cout << "a: " << f.a << ", b: " << f.b << ", d: " << f.d << std::endl; +} + +int main(int , char**) +{ + unsigned char data[1024]; + Foo f{ 10, 20, 30.7f }; + + memcpy(data + 3, &f, sizeof(Foo)); + + void *ptr = mmap(nullptr, 2048, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + memcpy(ptr, data+3, sizeof(Foo)); + + handle_data((unsigned char*)ptr, sizeof(f)); + munmap(ptr, 2048); + + return 0; +}