From 0677022f69771b68ab4d7ff3898c17cda12210e8 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 20 Mar 2024 10:56:57 +0100 Subject: [PATCH 01/31] Add dummy primitive --- src/Primitives/emulated.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index 28548ae0..81ab3a43 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -26,8 +26,8 @@ #include "../WARDuino/CallbackHandler.h" #include "primitives.h" -#define NUM_PRIMITIVES 0 -#define NUM_PRIMITIVES_ARDUINO 29 +#define NUM_PRIMITIVES 30 +#define NUM_PRIMITIVES_ARDUINO 0 #define ALL_PRIMITIVES (NUM_PRIMITIVES + NUM_PRIMITIVES_ARDUINO) @@ -244,6 +244,18 @@ def_prim(abort, NoneToNoneU32) { return false; } +def_prim(dummy, twoToOneU32) { + uint32_t a = arg1.uint32; + uint32_t b = arg0.uint32; + StackValue val = {I32, {42}}; + for (int i = 0; a + i < b; i += 4) { + m->warduino->interpreter->store(m, I32, a + i, val); + } + pop_args(2); + pushUInt32(b - a); + return true; +} + def_prim(millis, NoneToOneU64) { struct timeval tv {}; gettimeofday(&tv, nullptr); @@ -514,6 +526,8 @@ def_prim(chip_ledc_attach_pin, twoToNoneU32) { void install_primitives() { dbg_info("INSTALLING PRIMITIVES\n"); dbg_info("INSTALLING FAKE ARDUINO\n"); + install_primitive(dummy); + install_primitive(abort); install_primitive(millis); install_primitive(micros); From 322708e9da9e754af35c617a3f0d077a3c628c22 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 20 Mar 2024 11:33:00 +0100 Subject: [PATCH 02/31] =?UTF-8?q?=E2=9C=85=20Add=20unit=20test=20for=20dum?= =?UTF-8?q?my=20primitive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/latch/examples/dummy.wast | 28 ++++++++++++++++++++++++++++ tests/latch/src/primitives.test.ts | 30 ++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/latch/examples/dummy.wast diff --git a/tests/latch/examples/dummy.wast b/tests/latch/examples/dummy.wast new file mode 100644 index 00000000..ce91e63e --- /dev/null +++ b/tests/latch/examples/dummy.wast @@ -0,0 +1,28 @@ + +(module + ;; Type declarations + (type $int32->int32->int32 (func (param i32 i32) (result i32))) + (type $int32->int32 (func (param i32) (result i32))) + (type $int32->void (func (param i32))) + (type $void->void (func)) + + ;; Imports from the WARDuino VM + (import "env" "dummy" (func $env.dummy (type $int32->int32->int32))) + (import "env" "print_int" (func $env.print_int (type $int32->void))) + + ;; Memory + (memory 1) + + ;; Main function + (func $main (export "main") (type $void->void) + (call $env.dummy (i32.const 32) (i32.const 64)) + (drop) + (call $env.print_int (i32.load (i32.const 32))) + ) + + (func $dummy (export "dummy") (type $int32->int32->int32) + (call $env.dummy (local.get 0) (local.get 1))) + + (func $load (export "load") (type $int32->int32) + (i32.load (local.get 0))) +) diff --git a/tests/latch/src/primitives.test.ts b/tests/latch/src/primitives.test.ts index be1a4ad8..2024d298 100644 --- a/tests/latch/src/primitives.test.ts +++ b/tests/latch/src/primitives.test.ts @@ -8,17 +8,43 @@ import { Message, TestScenario, WASM, - awaitBreakpoint, PureAction, OutputStyle, Suite, Assertable, assertable + awaitBreakpoint, PureAction, OutputStyle, Suite, Assertable, assertable, invoke, returns } from 'latch'; import * as mqtt from 'mqtt'; import Type = WASM.Type; import {Breakpoint} from "latch/dist/types/debug/Breakpoint"; +const examples = `${__dirname}/../examples`; + const framework = Framework.getImplementation(); framework.style(OutputStyle.github); // TODO disclaimer: file is currently disabled until latch supports AS compilation +const dummy: Suite = framework.suite('Integration tests: dummy primitives'); + +dummy.testee('emulator [:8520]', new EmulatorSpecification(8520)); + +const dummyScenario: TestScenario = { + title: 'Test dummy primitives', + program: `${examples}/dummy.wast`, + steps: [{ + title: 'Check: dummy value', + instruction: invoke('dummy', [WASM.i32(32), WASM.i32(64)]), + expected: returns(WASM.i32(32)) + }, { + title: 'Check: value at 32', + instruction: invoke('load', [WASM.i32(32)]), + expected: returns(WASM.i32(42)) + }, { + title: 'Check: value at 48', + instruction: invoke('load', [WASM.i32(48)]), + expected: returns(WASM.i32(42)) + }] +}; + +dummy.test(dummyScenario); + const basic: Suite = framework.suite('Integration tests: basic primitives'); basic.testee('emulator [:8520]', new EmulatorSpecification(8520)); @@ -165,4 +191,4 @@ export function listen(topic: string): PureAction { comms.test(scenario); -framework.run([]); +framework.run([dummy]); From db61df746f73a3c2781d729cdcc1b7b2d0bc894a Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 26 Mar 2024 10:31:22 +0100 Subject: [PATCH 03/31] Implement store proxy --- src/Debug/debugger.cpp | 17 +++++++++++++++++ src/Debug/debugger.h | 2 +- src/Interpreter/proxied.cpp | 14 ++++++++++++++ src/Interpreter/proxied.h | 1 + src/Utils/util.cpp | 2 +- 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/Interpreter/proxied.cpp create mode 100644 src/Interpreter/proxied.h diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index fbd77bd1..cb0ece31 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -15,6 +15,7 @@ #include "../Utils//util.h" #include "../Utils/macros.h" #include "../WARDuino/CallbackHandler.h" +#include "../Interpreter/proxied.h" // Debugger @@ -362,6 +363,10 @@ bool Debugger::checkDebugMessages(Module *m, RunningState *program_state) { this->removeOverride(m, interruptData + 1); free(interruptData); break; + case interruptStore: + this->receiveStore(m, interruptData + 1); + free(interruptData); + break; default: // handle later this->channel->write("COULD not parse interrupt data!\n"); @@ -1413,6 +1418,8 @@ uintptr_t Debugger::readPointer(uint8_t **data) { void Debugger::proxify() { WARDuino::instance()->program_state = PROXYhalt; + delete WARDuino::instance()->interpreter; + WARDuino::instance()->interpreter = new Proxied(); this->proxy = new Proxy(); // TODO delete } @@ -1500,6 +1507,16 @@ void Debugger::updateCallbackmapping(Module *m, const char *interruptData) { } } +void Debugger::receiveStore(Module *m, uint8_t *interruptData) { + uint8_t type = *interruptData; + uint8_t *pos = interruptData + 1; + uint32_t addr = read_LEB_32(&pos); + auto *sval = (StackValue *)malloc(sizeof(struct StackValue)); + deserialiseStackValue(pos, true, sval); + m->warduino->interpreter->store(m, type, addr, *sval); + free(sval); +} + // Stop the debugger void Debugger::stop() { if (this->channel != nullptr) { diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index 98f28e48..49575f71 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -212,7 +212,7 @@ class Debugger { static void updateCallbackmapping(Module *m, const char *interruptData); - bool operation(Module *m, operation op); + void receiveStore(Module *m, uint8_t *interruptData); public: // Public fields diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp new file mode 100644 index 00000000..43c97b2d --- /dev/null +++ b/src/Interpreter/proxied.cpp @@ -0,0 +1,14 @@ +#include "./wasm.h" +#include "../Debug/debugger.h" + +bool Proxied::store(Module *m, uint8_t type, uint32_t addr, StackValue &sval) { + // TODO send back to debugger + uint8_t *buf = calloc(sizeof(uint8_t), 20); + uint32_t size = write_LEB_32(addr, *buf, 20); + uint8_t *msg = calloc(sizeof(uint8_t), size + 3); + msg[0] = interruptStore; + msg[1] = 0; + memcpy(msg + 2, sval.value, 4); + msg[19] = '\0'; + m->warduino->debugger->channel->write(msg); +} diff --git a/src/Interpreter/proxied.h b/src/Interpreter/proxied.h new file mode 100644 index 00000000..522eb474 --- /dev/null +++ b/src/Interpreter/proxied.h @@ -0,0 +1 @@ +class Proxied : public Interpreter {}; \ No newline at end of file diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index 7455bb3f..9e0195f0 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -39,7 +39,7 @@ StackValue *readArgs(Type function, uint8_t *data) { return args; } -// Little endian base (LED128) +// Little endian base (LEB128) uint64_t read_LEB_(uint8_t **pos, uint32_t maxbits, bool sign) { uint64_t result = 0; From 1a936ffc4a2e870ed4f16ca7e1027271972b1b10 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 26 Mar 2024 16:42:36 +0100 Subject: [PATCH 04/31] Fix proxy store prototype for emulator --- CMakeLists.txt | 1 + src/Debug/debugger.cpp | 7 ++- src/Interpreter/interpreter.cpp | 4 -- src/Interpreter/interpreter.h | 3 +- src/Interpreter/proxied.cpp | 27 +++++++----- src/Interpreter/proxied.h | 6 ++- src/Utils/util.cpp | 75 +++++++++++++++++++++++++++++++++ src/Utils/util.h | 22 ++++++++++ 8 files changed, 125 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65e6facb..f75130ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ if (BUILD_EMULATOR) src/Primitives/emulated.cpp src/Interpreter/instructions.cpp src/Interpreter/interpreter.cpp + src/Interpreter/proxied.cpp src/Memory/mem.cpp src/Utils/util.cpp src/Utils/util_arduino.cpp diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index cb0ece31..634637e7 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -10,12 +10,12 @@ #include "../../lib/json/single_include/nlohmann/json.hpp" #endif +#include "../Interpreter/proxied.h" #include "../Memory/mem.h" #include "../Primitives/primitives.h" #include "../Utils//util.h" #include "../Utils/macros.h" #include "../WARDuino/CallbackHandler.h" -#include "../Interpreter/proxied.h" // Debugger @@ -1508,12 +1508,11 @@ void Debugger::updateCallbackmapping(Module *m, const char *interruptData) { } void Debugger::receiveStore(Module *m, uint8_t *interruptData) { - uint8_t type = *interruptData; - uint8_t *pos = interruptData + 1; + uint8_t *pos = interruptData; uint32_t addr = read_LEB_32(&pos); auto *sval = (StackValue *)malloc(sizeof(struct StackValue)); deserialiseStackValue(pos, true, sval); - m->warduino->interpreter->store(m, type, addr, *sval); + m->warduino->interpreter->store(m, sval->value_type, addr, *sval); free(sval); } diff --git a/src/Interpreter/interpreter.cpp b/src/Interpreter/interpreter.cpp index 5e6d6b18..d83fb12d 100644 --- a/src/Interpreter/interpreter.cpp +++ b/src/Interpreter/interpreter.cpp @@ -113,10 +113,6 @@ uint32_t STORE_SIZE[] = {4, 8, 4, 8, 1, 2, 1, 2, 4}; bool Interpreter::store(Module *m, uint8_t type, uint32_t addr, StackValue &sval) { - if (m->warduino->debugger->isProxy()) { - return m->warduino->debugger; - } - uint8_t *maddr, *mem_end; uint32_t size = STORE_SIZE[abs(type - I32)]; bool overflow = false; diff --git a/src/Interpreter/interpreter.h b/src/Interpreter/interpreter.h index d11260d3..4761a037 100644 --- a/src/Interpreter/interpreter.h +++ b/src/Interpreter/interpreter.h @@ -48,7 +48,8 @@ class Interpreter { /* Stateful operations * ************************************************************************/ - bool store(Module *m, uint8_t type, uint32_t addr, StackValue &sval); + virtual bool store(Module *m, uint8_t type, uint32_t addr, + StackValue &sval); bool load(Module *m, uint8_t type, uint32_t addr, uint32_t offset); diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp index 43c97b2d..f768de54 100644 --- a/src/Interpreter/proxied.cpp +++ b/src/Interpreter/proxied.cpp @@ -1,14 +1,21 @@ -#include "./wasm.h" +#include "./proxied.h" + #include "../Debug/debugger.h" +#include "../Utils//util.h" + +void send_leb(Channel *channel, uint32_t value, const char *end = "") { + uint8_t *buffer = write_LEB(value); + uint32_t size = size_leb(value); + for (int i = 0; i < size; ++i) { + channel->write("%" PRIx8 "%s", buffer[i], end); + } + free(buffer); +} bool Proxied::store(Module *m, uint8_t type, uint32_t addr, StackValue &sval) { - // TODO send back to debugger - uint8_t *buf = calloc(sizeof(uint8_t), 20); - uint32_t size = write_LEB_32(addr, *buf, 20); - uint8_t *msg = calloc(sizeof(uint8_t), size + 3); - msg[0] = interruptStore; - msg[1] = 0; - memcpy(msg + 2, sval.value, 4); - msg[19] = '\0'; - m->warduino->debugger->channel->write(msg); + m->warduino->debugger->channel->write("%" PRIx8, interruptStore); + send_leb(m->warduino->debugger->channel, addr); + send_leb(m->warduino->debugger->channel, 0); + send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n"); + return true; } diff --git a/src/Interpreter/proxied.h b/src/Interpreter/proxied.h index 522eb474..779547c2 100644 --- a/src/Interpreter/proxied.h +++ b/src/Interpreter/proxied.h @@ -1 +1,5 @@ -class Proxied : public Interpreter {}; \ No newline at end of file +class Proxied : public Interpreter { + public: + bool store(Module *m, uint8_t type, uint32_t addr, + StackValue &sval) override; +}; \ No newline at end of file diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index 9e0195f0..16f4b85a 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -41,6 +41,81 @@ StackValue *readArgs(Type function, uint8_t *data) { // Little endian base (LEB128) +uint64_t size_leb(uint64_t val) { + uint64_t count = 0; + do { + val >>= 7; + count++; + } while (val != 0); + return count; +} + +uint32_t write_LEB_(uint8_t *dest, uint64_t val) { + uint32_t count = 0; + + do { + uint8_t byte = val & 0x7f; + val >>= 7; + + if (val != 0) byte |= 0x80; + + dest[count++] = byte; + } while (val != 0); + + return count; +} + +uint8_t *write_LEB(uint32_t value) { + uint8_t *buffer = + static_cast(calloc(sizeof(uint8_t), size_leb(value))); + write_LEB_(buffer, value); + return buffer; +} + +uint32_t write_LEB_signed(uint8_t *dest, uint64_t val, uint64_t bits) { + uint32_t count = 0; + + do { + uint8_t byte = val & 0x7f; + val >>= 7; + + if (static_cast(val) < 0) { + val |= UINT64_MAX << (bits - 7); // sign extend + } + + if ((val == 0 && static_cast(byte) >= 0) || + (val == -1 && static_cast(byte) < 0)) { + break; + } + byte |= 0x80; + + dest[count++] = byte; + } while (val != 0); + + return count; +} + +uint64_t write_LEB_(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, + bool sign) { + if (size_leb(value) > size) { + return 0; + } + + if (sign) { + return write_LEB_(buff, value); + } else { + return write_LEB_signed(buff, value, bits); + } +} + +uint64_t write_LEB_32(uint32_t value, uint8_t *buff, uint32_t size) { + return write_LEB_(value, buff, size, 32, false); +} + +uint64_t write_LEB_32_signed(uint32_t value, uint8_t *buff, uint32_t size) { + return write_LEB_(value, buff, size, 32, true); +} + uint64_t read_LEB_(uint8_t **pos, uint32_t maxbits, bool sign) { uint64_t result = 0; uint32_t shift = 0; diff --git a/src/Utils/util.h b/src/Utils/util.h index b5717be0..a31e849c 100644 --- a/src/Utils/util.h +++ b/src/Utils/util.h @@ -17,6 +17,28 @@ */ StackValue *readArgs(Type function, uint8_t *data); +uint64_t size_leb(uint64_t val); + +uint8_t *write_LEB(uint32_t value); + +/** + * Write a Little endian base value. + * see: https://en.wikipedia.org/wiki/LEB128 + * + * @param value The value to write. + * @param buff The buffer to write to. + * @param size The size of the buffer. + * @param bits The size of the value type (I32, I64) + * @param sign Whether the value should be sign-extended. + * @return The number of bytes written. + */ +uint64_t write_LEB_(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, + bool sign); + +uint64_t write_LEB_32(uint32_t value, uint8_t *buff, uint32_t size); + +uint64_t write_LEB_32_signed(uint32_t value, uint8_t *buff, uint32_t size); + /** * Read a Little endian base value of 32 bits * see: https://en.wikipedia.org/wiki/LEB128 From 95eaed22c9f76962d959b16fb76d1f8384ad8ab3 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 3 Apr 2024 11:45:10 +0200 Subject: [PATCH 05/31] Fix compilation + store format --- src/Interpreter/proxied.cpp | 4 ++-- src/Interpreter/proxied.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp index f768de54..db61d416 100644 --- a/src/Interpreter/proxied.cpp +++ b/src/Interpreter/proxied.cpp @@ -7,13 +7,13 @@ void send_leb(Channel *channel, uint32_t value, const char *end = "") { uint8_t *buffer = write_LEB(value); uint32_t size = size_leb(value); for (int i = 0; i < size; ++i) { - channel->write("%" PRIx8 "%s", buffer[i], end); + channel->write("%02" PRIx8 "%s", buffer[i], end); } free(buffer); } bool Proxied::store(Module *m, uint8_t type, uint32_t addr, StackValue &sval) { - m->warduino->debugger->channel->write("%" PRIx8, interruptStore); + m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); send_leb(m->warduino->debugger->channel, addr); send_leb(m->warduino->debugger->channel, 0); send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n"); diff --git a/src/Interpreter/proxied.h b/src/Interpreter/proxied.h index 779547c2..dccdb5bc 100644 --- a/src/Interpreter/proxied.h +++ b/src/Interpreter/proxied.h @@ -1,3 +1,4 @@ +#include "./interpreter.h" class Proxied : public Interpreter { public: bool store(Module *m, uint8_t type, uint32_t addr, From 3f840b9f4c1da13a394e3e3ad6c55dce90fba3f8 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 3 Apr 2024 11:49:13 +0200 Subject: [PATCH 06/31] Make `Supervisor` inherit from `Debugger` --- src/Debug/debugger.h | 3 ++- src/Edward/proxy_supervisor.cpp | 37 +++++++-------------------------- src/Edward/proxy_supervisor.h | 4 ++-- 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index 49575f71..cf46db6c 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -12,7 +12,6 @@ #include #include "../Edward/proxy.h" -#include "../Edward/proxy_supervisor.h" #include "../Threading/warduino-thread.h" #include "../Utils/sockets.h" @@ -109,6 +108,8 @@ enum class SnapshotPolicy : int { // points where primitives are used. }; +class ProxySupervisor; + class Debugger { private: std::deque debugMessages = {}; diff --git a/src/Edward/proxy_supervisor.cpp b/src/Edward/proxy_supervisor.cpp index 511efca9..472bc6d5 100644 --- a/src/Edward/proxy_supervisor.cpp +++ b/src/Edward/proxy_supervisor.cpp @@ -53,9 +53,8 @@ Event *parseJSON(char *buff) { return new Event(*parsed.find("topic"), payload); } -ProxySupervisor::ProxySupervisor(Channel *duplex, warduino::mutex *mutex) { +ProxySupervisor::ProxySupervisor(Channel *duplex, warduino::mutex *mutex) : Debugger(duplex) { debug("Starting supervisor.\n"); - this->channel = duplex; this->mutex = mutex; this->thread = warduino::thread(runSupervisor, this); this->proxyResult = nullptr; @@ -70,39 +69,21 @@ bool isReply(nlohmann::basic_json<> parsed) { } void ProxySupervisor::listenToSocket() { - char _char; - uint32_t buf_idx = 0; - const uint32_t start_size = 1024; - uint32_t current_size = start_size; - char *buffer = (char *)malloc(start_size); + uint8_t message[1024] = {0}; ssize_t readAmount; this->channel->open(); dbg_info("Proxy supervisor listening to remote device...\n"); while (continuing(this->mutex)) { - readAmount = this->channel->read(&_char, 1); + readAmount = this->channel->read(message, 1024); if (readAmount == -1) { printf("Proxy supervisor shutting down.\n"); exit(-1); } if (readAmount > 0) { - // increase buffer size if needed - if (current_size <= (buf_idx + 1)) { - char *new_buff = (char *)malloc(current_size + start_size); - memcpy((void *)new_buff, (void *)buffer, current_size); - free(buffer); - buffer = new_buff; - current_size += start_size; - printf("increasing PushClient's buffer size to %" PRId32 "\n", - current_size); - } - buffer[buf_idx++] = _char; - // manual null-termination is needed because parseJSON does not use - // first len argument - buffer[buf_idx] = '\0'; try { - nlohmann::basic_json<> parsed = nlohmann::json::parse(buffer); + nlohmann::basic_json<> parsed = nlohmann::json::parse(message); debug("parseJSON: %s\n", parsed.dump().c_str()); if (isEvent(parsed)) { @@ -115,13 +96,9 @@ void ProxySupervisor::listenToSocket() { this->hasReplied = true; this->proxyResult = parsed; } - - buf_idx = 0; } catch (const nlohmann::detail::parse_error &e) { - if (_char == '\n') { - // discard buffer - buf_idx = 0; - } + printf("Non RFC call: %s", message); + WARDuino::instance()->handleInterrupt(readAmount, message); } } } @@ -276,7 +253,7 @@ bool ProxySupervisor::call(RFC *callee) { char cmdBuffer[10] = ""; int cmdBufferLen = 0; sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping, &cmdBufferLen); - WARDuino::instance()->debugger->supervisor->send(cmdBuffer, cmdBufferLen); + this->send(cmdBuffer, cmdBufferLen); this->deserializeRFCResult(callee); return true; } diff --git a/src/Edward/proxy_supervisor.h b/src/Edward/proxy_supervisor.h index 40b0bb55..4988db00 100644 --- a/src/Edward/proxy_supervisor.h +++ b/src/Edward/proxy_supervisor.h @@ -6,6 +6,7 @@ #include #include +#include "../Debug/debugger.h" #include "../Threading/warduino-thread.h" #include "../Utils/sockets.h" #include "RFC.h" @@ -16,9 +17,8 @@ #endif #include "sys/types.h" -class ProxySupervisor { +class ProxySupervisor : public Debugger { private: - Channel *channel; warduino::mutex *mutex; std::set *proxied = new std::set(); From 62cdd68261a04abfcd6fbcb570cfe657feaba28a Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 26 Nov 2024 13:45:03 +0100 Subject: [PATCH 07/31] =?UTF-8?q?=F0=9F=A7=B0=20Fix=20compile=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Interpreter/interpreter.cpp | 2 ++ src/Interpreter/interpreter.h | 1 + src/Interpreter/proxied.cpp | 4 ++-- src/Utils/util.cpp | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Interpreter/interpreter.cpp b/src/Interpreter/interpreter.cpp index d83fb12d..be7eb1b2 100644 --- a/src/Interpreter/interpreter.cpp +++ b/src/Interpreter/interpreter.cpp @@ -470,3 +470,5 @@ void Interpreter::report_overflow([[maybe_unused]] Module *m, m->memory.bytes + m->memory.pages * (uint32_t)PAGE_SIZE, maddr); sprintf(exception, "out of bounds memory access"); } + +Interpreter::~Interpreter() {} diff --git a/src/Interpreter/interpreter.h b/src/Interpreter/interpreter.h index 4761a037..10d9a04c 100644 --- a/src/Interpreter/interpreter.h +++ b/src/Interpreter/interpreter.h @@ -55,6 +55,7 @@ class Interpreter { static void report_overflow(Module *m, uint8_t *maddr); + virtual ~Interpreter(); protected: private: }; diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp index db61d416..af76c3c0 100644 --- a/src/Interpreter/proxied.cpp +++ b/src/Interpreter/proxied.cpp @@ -6,13 +6,13 @@ void send_leb(Channel *channel, uint32_t value, const char *end = "") { uint8_t *buffer = write_LEB(value); uint32_t size = size_leb(value); - for (int i = 0; i < size; ++i) { + for (uint32_t i = 0; i < size; ++i) { channel->write("%02" PRIx8 "%s", buffer[i], end); } free(buffer); } -bool Proxied::store(Module *m, uint8_t type, uint32_t addr, StackValue &sval) { +bool Proxied::store(Module *m, [[maybe_unused]] uint8_t type, uint32_t addr, StackValue &sval) { m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); send_leb(m->warduino->debugger->channel, addr); send_leb(m->warduino->debugger->channel, 0); diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index 16f4b85a..3fa3ea5e 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -84,7 +84,7 @@ uint32_t write_LEB_signed(uint8_t *dest, uint64_t val, uint64_t bits) { } if ((val == 0 && static_cast(byte) >= 0) || - (val == -1 && static_cast(byte) < 0)) { + (val == static_cast(-1) && static_cast(byte) < 0)) { break; } byte |= 0x80; From 75d2e08f68e21f3865d70e8e42e3e2dfd81d14b7 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 3 Apr 2024 11:52:32 +0200 Subject: [PATCH 08/31] Check debug messages during blocking RFC call Adds `module *m` to RFC --- src/Debug/debugger.cpp | 2 +- src/Edward/RFC.cpp | 4 ++-- src/Edward/RFC.h | 5 ++++- src/Edward/proxy_supervisor.cpp | 6 ++++-- src/Edward/proxy_supervisor.h | 2 +- src/Interpreter/instructions.cpp | 4 ++-- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index 634637e7..6f9740c6 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -1438,7 +1438,7 @@ void Debugger::handleProxyCall(Module *m, RunningState *, StackValue *args = Proxy::readRFCArgs(func, data); dbg_trace("Enqueuing callee %" PRIu32 "\n", func->fidx); - auto *rfc = new RFC(fidx, func->type, args); + auto *rfc = new RFC(m, fidx, func->type, args); this->proxy->pushRFC(m, rfc); } diff --git a/src/Edward/RFC.cpp b/src/Edward/RFC.cpp index 8bcf131e..5e8e63ec 100644 --- a/src/Edward/RFC.cpp +++ b/src/Edward/RFC.cpp @@ -1,4 +1,4 @@ #include "RFC.h" -RFC::RFC(uint32_t id, Type *t_type, StackValue *t_args) - : fidx(id), args(t_args), type(t_type) {} +RFC::RFC(Module *m, uint32_t id, Type *t_type, StackValue *t_args) + : m(m), fidx(id), args(t_args), type(t_type) {} diff --git a/src/Edward/RFC.h b/src/Edward/RFC.h index 2ed7b9c8..6b03d2d2 100644 --- a/src/Edward/RFC.h +++ b/src/Edward/RFC.h @@ -1,6 +1,8 @@ #pragma once #include + +#include "../WARDuino/internals.h" struct StackValue; struct Type; @@ -11,6 +13,7 @@ struct SerializeData { class RFC { public: + Module *m; const uint32_t fidx; StackValue *args; const Type *type; @@ -20,5 +23,5 @@ class RFC { char *exception; uint16_t exception_size; - RFC(uint32_t id, Type *t_type, StackValue *t_args = nullptr); + RFC(Module *m, uint32_t id, Type *t_type, StackValue *t_args = nullptr); }; diff --git a/src/Edward/proxy_supervisor.cpp b/src/Edward/proxy_supervisor.cpp index 472bc6d5..3d591a06 100644 --- a/src/Edward/proxy_supervisor.cpp +++ b/src/Edward/proxy_supervisor.cpp @@ -110,8 +110,10 @@ bool ProxySupervisor::send( return n == size; } -nlohmann::basic_json<> ProxySupervisor::readReply() { - while (!this->hasReplied); +nlohmann::basic_json<> ProxySupervisor::readReply(RFC *rfc) { + while (!this->hasReplied) { + WARDuino::instance()->debugger->checkDebugMessages(rfc->m, &WARDuino::instance()->program_state); + } WARDuino::instance()->debugger->channel->write("read reply: succeeded\n"); this->hasReplied = false; return this->proxyResult; diff --git a/src/Edward/proxy_supervisor.h b/src/Edward/proxy_supervisor.h index 4988db00..dd7ba502 100644 --- a/src/Edward/proxy_supervisor.h +++ b/src/Edward/proxy_supervisor.h @@ -36,7 +36,7 @@ class ProxySupervisor : public Debugger { void listenToSocket(); bool send(void *t_buffer, int t_size); - nlohmann::basic_json<> readReply(); + nlohmann::basic_json<> readReply(RFC *rfc); bool call(RFC *callee); diff --git a/src/Interpreter/instructions.cpp b/src/Interpreter/instructions.cpp index 0e4ceb3c..429c1f09 100644 --- a/src/Interpreter/instructions.cpp +++ b/src/Interpreter/instructions.cpp @@ -17,9 +17,9 @@ bool proxy_call(Module *m, uint32_t fidx) { if (type->param_count > 0) { m->sp -= type->param_count; StackValue *args = &m->stack[m->sp + 1]; - rfc = new RFC(fidx, type, args); + rfc = new RFC(m, fidx, type, args); } else { - rfc = new RFC(fidx, type); + rfc = new RFC(m, fidx, type); } if (!supervisor->call(rfc)) { From 49f0696bb46e36ad86cd83e18687ea416c34cfa6 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 26 Nov 2024 13:47:38 +0100 Subject: [PATCH 09/31] =?UTF-8?q?=F0=9F=8E=A8=20Clang=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Edward/proxy_supervisor.cpp | 6 ++++-- src/Interpreter/interpreter.h | 1 + src/Interpreter/proxied.cpp | 3 ++- src/Utils/util.cpp | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Edward/proxy_supervisor.cpp b/src/Edward/proxy_supervisor.cpp index 3d591a06..c16a8915 100644 --- a/src/Edward/proxy_supervisor.cpp +++ b/src/Edward/proxy_supervisor.cpp @@ -53,7 +53,8 @@ Event *parseJSON(char *buff) { return new Event(*parsed.find("topic"), payload); } -ProxySupervisor::ProxySupervisor(Channel *duplex, warduino::mutex *mutex) : Debugger(duplex) { +ProxySupervisor::ProxySupervisor(Channel *duplex, warduino::mutex *mutex) + : Debugger(duplex) { debug("Starting supervisor.\n"); this->mutex = mutex; this->thread = warduino::thread(runSupervisor, this); @@ -112,7 +113,8 @@ bool ProxySupervisor::send( nlohmann::basic_json<> ProxySupervisor::readReply(RFC *rfc) { while (!this->hasReplied) { - WARDuino::instance()->debugger->checkDebugMessages(rfc->m, &WARDuino::instance()->program_state); + WARDuino::instance()->debugger->checkDebugMessages( + rfc->m, &WARDuino::instance()->program_state); } WARDuino::instance()->debugger->channel->write("read reply: succeeded\n"); this->hasReplied = false; diff --git a/src/Interpreter/interpreter.h b/src/Interpreter/interpreter.h index 10d9a04c..5c93376b 100644 --- a/src/Interpreter/interpreter.h +++ b/src/Interpreter/interpreter.h @@ -56,6 +56,7 @@ class Interpreter { static void report_overflow(Module *m, uint8_t *maddr); virtual ~Interpreter(); + protected: private: }; diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp index af76c3c0..28778922 100644 --- a/src/Interpreter/proxied.cpp +++ b/src/Interpreter/proxied.cpp @@ -12,7 +12,8 @@ void send_leb(Channel *channel, uint32_t value, const char *end = "") { free(buffer); } -bool Proxied::store(Module *m, [[maybe_unused]] uint8_t type, uint32_t addr, StackValue &sval) { +bool Proxied::store(Module *m, [[maybe_unused]] uint8_t type, uint32_t addr, + StackValue &sval) { m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); send_leb(m->warduino->debugger->channel, addr); send_leb(m->warduino->debugger->channel, 0); diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index 3fa3ea5e..7800fcad 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -84,7 +84,8 @@ uint32_t write_LEB_signed(uint8_t *dest, uint64_t val, uint64_t bits) { } if ((val == 0 && static_cast(byte) >= 0) || - (val == static_cast(-1) && static_cast(byte) < 0)) { + (val == static_cast(-1) && + static_cast(byte) < 0)) { break; } byte |= 0x80; From cc7e442ede176ca4add0b9d3ef3cf0f5c94d120d Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 3 Apr 2024 12:06:02 +0200 Subject: [PATCH 10/31] Add missing virtual destructor --- src/Interpreter/interpreter.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Interpreter/interpreter.h b/src/Interpreter/interpreter.h index 5c93376b..616aa2cf 100644 --- a/src/Interpreter/interpreter.h +++ b/src/Interpreter/interpreter.h @@ -6,6 +6,8 @@ class Interpreter { public: + virtual ~Interpreter(); + /** * Push a new frame on to the call stack * @param m module From cdb85cc999bacfe68c97b93bea51c1fe06ddf329 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 3 Apr 2024 12:17:41 +0200 Subject: [PATCH 11/31] Fix ESP IDF compilation --- platforms/ESP-IDF/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/platforms/ESP-IDF/CMakeLists.txt b/platforms/ESP-IDF/CMakeLists.txt index 12abbd25..fed06de8 100644 --- a/platforms/ESP-IDF/CMakeLists.txt +++ b/platforms/ESP-IDF/CMakeLists.txt @@ -2,6 +2,7 @@ set(SOURCE_FILES ../../src/Debug/debugger.cpp ../../src/Interpreter/instructions.cpp ../../src/Interpreter/interpreter.cpp + ../../src/Interpreter/proxied.cpp ../../src/Memory/mem.cpp ../../src/Primitives/idf.cpp ../../src/Edward/proxy.cpp From 0a97f0daba1874f92aabbde77a35187ae2702582 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Wed, 3 Apr 2024 14:37:11 +0200 Subject: [PATCH 12/31] Fix internal tests compilation --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f75130ba..2ca6b712 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,7 @@ if (BUILD_UNITTEST) src/Primitives/emulated.cpp src/Interpreter/instructions.cpp src/Interpreter/interpreter.cpp + src/Interpreter/proxied.cpp src/Memory/mem.cpp src/Utils/util.cpp src/Utils/util_arduino.cpp From dcd932c4a1a901bdc7d8962f84639a1ce402349b Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 26 Nov 2024 14:15:10 +0100 Subject: [PATCH 13/31] Fix compilation --- src/Edward/proxy_supervisor.cpp | 2 +- src/Interpreter/interpreter.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Edward/proxy_supervisor.cpp b/src/Edward/proxy_supervisor.cpp index c16a8915..c8140304 100644 --- a/src/Edward/proxy_supervisor.cpp +++ b/src/Edward/proxy_supervisor.cpp @@ -199,7 +199,7 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) { } void ProxySupervisor::deserializeRFCResult(RFC *rfc) { - nlohmann::basic_json<> call_result = this->readReply(); // blocking + nlohmann::basic_json<> call_result = this->readReply(rfc); // blocking rfc->success = *call_result.find("success"); if (rfc->type->result_count == 0) { diff --git a/src/Interpreter/interpreter.h b/src/Interpreter/interpreter.h index 616aa2cf..9d5acc57 100644 --- a/src/Interpreter/interpreter.h +++ b/src/Interpreter/interpreter.h @@ -57,8 +57,6 @@ class Interpreter { static void report_overflow(Module *m, uint8_t *maddr); - virtual ~Interpreter(); - protected: private: }; From 557b9c58993408b4249ce99ae3e074b92b217857 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 26 Nov 2024 14:52:00 +0100 Subject: [PATCH 14/31] =?UTF-8?q?=E2=9C=85=20Add=20first=20unit=20test=20f?= =?UTF-8?q?or=20out-of-place?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/latch/src/debugger.test.ts | 57 ++++++++++++++++++++++++++++-- tests/latch/src/primitives.test.ts | 4 +-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/tests/latch/src/debugger.test.ts b/tests/latch/src/debugger.test.ts index f4df2146..28485b91 100644 --- a/tests/latch/src/debugger.test.ts +++ b/tests/latch/src/debugger.test.ts @@ -18,7 +18,6 @@ import { export const EMULATOR: string = process.env.EMULATOR ?? `${require('os').homedir()}/Arduino/libraries/WARDuino/build-emu/wdcli`; - const EXAMPLES: string = `${__dirname}/../examples/`; /** @@ -312,7 +311,6 @@ const stepOverTest: TestScenario = { integration.test(stepOverTest); -// EDWARD tests with mock proxy const dumpEventsTest: TestScenario = { title: 'Test DUMPEvents', @@ -332,4 +330,57 @@ const dumpEventsTest: TestScenario = { integration.test(dumpEventsTest); -framework.run([integration]); +// EDWARD tests + +const oop = framework.suite('Test Out-of-place primitives'); + +oop.testee('supervisor[:8100] - proxy[:8150]', new OutofPlaceSpecification(8100, 8150)); + +oop.test({ + title: `Test store primitive`, + program: 'test/dummy.wast', + dependencies: [], + steps: [ + { + title: '[supervisor] CHECK: execution at start of main', + instruction: {kind: Kind.Request, value: dump}, + expected: [{'pc': {kind: 'primitive', value: 129} as Expected}] + }, + + { + title: '[proxy] CHECK: execution at start of main', + instruction: {kind: Kind.Request, value: dump}, + expected: [{'pc': {kind: 'primitive', value: 129} as Expected}], + target: Target.proxy + }, + + new Invoker('load', [WASM.i32(32)], WASM.i32(0), Target.proxy), + + { + title: '[supervisor] Send STEP command', + instruction: {kind: Kind.Request, value: step} + }, + + { + title: '[supervisor] Send STEP command', + instruction: {kind: Kind.Request, value: step} + }, + + { + title: '[supervisor] Send STEP command', + instruction: {kind: Kind.Request, value: step} + }, + + { + title: '[supervisor] CHECK: execution took three steps', + instruction: {kind: Kind.Request, value: dump}, + expected: [{'pc': {kind: 'primitive', value: 136} as Expected}] + }, + + new Invoker('load', [WASM.i32(32)], WASM.i32(42), Target.proxy), + + new Invoker('load', [WASM.i32(32)], WASM.i32(42), Target.supervisor) + ] +}); + +framework.run([integration,oop]); diff --git a/tests/latch/src/primitives.test.ts b/tests/latch/src/primitives.test.ts index 2024d298..892e041a 100644 --- a/tests/latch/src/primitives.test.ts +++ b/tests/latch/src/primitives.test.ts @@ -19,8 +19,6 @@ const examples = `${__dirname}/../examples`; const framework = Framework.getImplementation(); framework.style(OutputStyle.github); -// TODO disclaimer: file is currently disabled until latch supports AS compilation - const dummy: Suite = framework.suite('Integration tests: dummy primitives'); dummy.testee('emulator [:8520]', new EmulatorSpecification(8520)); @@ -45,6 +43,8 @@ const dummyScenario: TestScenario = { dummy.test(dummyScenario); +// TODO disclaimer: rest of the file is currently disabled until latch supports AS compilation + const basic: Suite = framework.suite('Integration tests: basic primitives'); basic.testee('emulator [:8520]', new EmulatorSpecification(8520)); From 6c4a9a601afdf7b395f003a642992071f1041501 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Mon, 2 Dec 2024 15:03:58 +0100 Subject: [PATCH 15/31] Fix local save in proxied store --- src/Interpreter/proxied.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp index 28778922..dc2df906 100644 --- a/src/Interpreter/proxied.cpp +++ b/src/Interpreter/proxied.cpp @@ -14,6 +14,7 @@ void send_leb(Channel *channel, uint32_t value, const char *end = "") { bool Proxied::store(Module *m, [[maybe_unused]] uint8_t type, uint32_t addr, StackValue &sval) { + Interpreter::store(m, type, addr, sval); m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); send_leb(m->warduino->debugger->channel, addr); send_leb(m->warduino->debugger->channel, 0); From d0370e63feb604d6271fddc751a69d03042235e5 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Mon, 2 Dec 2024 16:16:57 +0100 Subject: [PATCH 16/31] Fix compilation & `isProxied` implementation --- src/Debug/debugger.cpp | 8 ++++---- src/Debug/debugger.h | 7 +++---- src/Interpreter/instructions.cpp | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index 6f9740c6..cce65287 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -454,12 +454,12 @@ void Debugger::handleInterruptRUN(const Module *m, *program_state = WARDUINOrun; } -void Debugger::handleSTEP(const Module *m, RunningState *program_state) { +void Debugger::handleSTEP(Module *m, RunningState *program_state) { *program_state = WARDUINOstep; this->skipBreakpoint = m->pc_ptr; } -void Debugger::handleSTEPOver(const Module *m, RunningState *program_state) { +void Debugger::handleSTEPOver(Module *m, RunningState *program_state) { this->skipBreakpoint = m->pc_ptr; uint8_t const opcode = *m->pc_ptr; if (opcode == 0x10) { // step over direct call @@ -1458,8 +1458,8 @@ void Debugger::sendProxyCallResult(Module *m) const { bool Debugger::isProxy() const { return this->proxy != nullptr; } -bool Debugger::isProxied(const uint32_t fidx) const { - return this->supervisor != nullptr && this->supervisor->isProxied(fidx); +bool Debugger::isProxied(Module *m, const uint32_t fidx) const { + return this->supervisor != nullptr && fidx < m->import_count; } void Debugger::handleMonitorProxies(const Module *m, diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index cf46db6c..cf6d29cd 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -98,7 +98,6 @@ enum InterruptTypes { // Operations interruptStore = 0xa0, - interruptStored = 0xa1, }; enum class SnapshotPolicy : int { @@ -160,9 +159,9 @@ class Debugger { void handleInterruptRUN(const Module *m, RunningState *program_state); - void handleSTEP(const Module *m, RunningState *program_state); + void handleSTEP(Module *m, RunningState *program_state); - void handleSTEPOver(const Module *m, RunningState *program_state); + void handleSTEPOver(Module *m, RunningState *program_state); void handleInterruptBP(Module *m, uint8_t *interruptData); @@ -284,7 +283,7 @@ class Debugger { bool isProxy() const; - bool isProxied(uint32_t fidx) const; + bool isProxied(Module *m, uint32_t fidx) const; void startProxySupervisor(Channel *socket); diff --git a/src/Interpreter/instructions.cpp b/src/Interpreter/instructions.cpp index 429c1f09..543c8c5c 100644 --- a/src/Interpreter/instructions.cpp +++ b/src/Interpreter/instructions.cpp @@ -282,7 +282,7 @@ bool i_instr_return(Module *m) { bool i_instr_call(Module *m) { uint32_t fidx = read_LEB_32(&m->pc_ptr); - if (m->warduino->debugger->isProxied(fidx)) { + if (m->warduino->debugger->isProxied(m, fidx)) { return proxy_call(m, fidx); } From f03f5f26ea8445971c5b46ba2f4f82e362de1631 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Mon, 2 Dec 2024 16:33:50 +0100 Subject: [PATCH 17/31] =?UTF-8?q?fixup!=20=E2=9C=85=20Add=20first=20unit?= =?UTF-8?q?=20test=20for=20out-of-place?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/latch/package-lock.json | 1309 ------------------------------ tests/latch/package.json | 28 +- tests/latch/src/debugger.test.ts | 31 +- 3 files changed, 19 insertions(+), 1349 deletions(-) delete mode 100644 tests/latch/package-lock.json diff --git a/tests/latch/package-lock.json b/tests/latch/package-lock.json deleted file mode 100644 index 707ca38d..00000000 --- a/tests/latch/package-lock.json +++ /dev/null @@ -1,1309 +0,0 @@ -{ - "name": "warduino-testsuite", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "warduino-testsuite", - "version": "1.0.0", - "devDependencies": { - "latch": "file:./latch-0.3.0.tgz", - "mqtt": "^4.3.7", - "serialport": "^10.4.0", - "typescript": "^4.5.5" - } - }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "node_modules/@serialport/binding-mock": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/@serialport/binding-mock/-/binding-mock-10.2.2.tgz", - "integrity": "sha512-HAFzGhk9OuFMpuor7aT5G1ChPgn5qSsklTFOTUX72Rl6p0xwcSVsRtG/xaGp6bxpN7fI9D/S8THLBWbBgS6ldw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@serialport/bindings-interface": "^1.2.1", - "debug": "^4.3.3" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/@serialport/bindings-cpp": { - "version": "10.8.0", - "resolved": "https://registry.npmjs.org/@serialport/bindings-cpp/-/bindings-cpp-10.8.0.tgz", - "integrity": "sha512-OMQNJz5kJblbmZN5UgJXLwi2XNtVLxSKmq5VyWuXQVsUIJD4l9UGHnLPqM5LD9u3HPZgDI5w7iYN7gxkQNZJUw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "@serialport/bindings-interface": "1.2.2", - "@serialport/parser-readline": "^10.2.1", - "debug": "^4.3.2", - "node-addon-api": "^5.0.0", - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">=12.17.0 <13.0 || >=14.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/bindings-interface": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@serialport/bindings-interface/-/bindings-interface-1.2.2.tgz", - "integrity": "sha512-CJaUd5bLvtM9c5dmO9rPBHPXTa9R2UwpkJ0wdh9JCYcbrPWsKz+ErvR0hBLeo7NPeiFdjFO4sonRljiw4d2XiA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.22 || ^14.13 || >=16" - } - }, - "node_modules/@serialport/parser-byte-length": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-byte-length/-/parser-byte-length-10.5.0.tgz", - "integrity": "sha512-eHhr4lHKboq1OagyaXAqkemQ1XyoqbLQC8XJbvccm95o476TmEdW5d7AElwZV28kWprPW68ZXdGF2VXCkJgS2w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-cctalk": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-cctalk/-/parser-cctalk-10.5.0.tgz", - "integrity": "sha512-Iwsdr03xmCKAiibLSr7b3w6ZUTBNiS+PwbDQXdKU/clutXjuoex83XvsOtYVcNZmwJlVNhAUbkG+FJzWwIa4DA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-delimiter": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-delimiter/-/parser-delimiter-10.5.0.tgz", - "integrity": "sha512-/uR/yT3jmrcwnl2FJU/2ySvwgo5+XpksDUR4NF/nwTS5i3CcuKS+FKi/tLzy1k8F+rCx5JzpiK+koqPqOUWArA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-inter-byte-timeout": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-inter-byte-timeout/-/parser-inter-byte-timeout-10.5.0.tgz", - "integrity": "sha512-WPvVlSx98HmmUF9jjK6y9mMp3Wnv6JQA0cUxLeZBgS74TibOuYG3fuUxUWGJALgAXotOYMxfXSezJ/vSnQrkhQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-packet-length": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-packet-length/-/parser-packet-length-10.5.0.tgz", - "integrity": "sha512-jkpC/8w4/gUBRa2Teyn7URv1D7T//0lGj27/4u9AojpDVXsR6dtdcTG7b7dNirXDlOrSLvvN7aS5/GNaRlEByw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/@serialport/parser-readline": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-readline/-/parser-readline-10.5.0.tgz", - "integrity": "sha512-0aXJknodcl94W9zSjvU+sLdXiyEG2rqjQmvBWZCr8wJZjWEtv3RgrnYiWq4i2OTOyC8C/oPK8ZjpBjQptRsoJQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@serialport/parser-delimiter": "10.5.0" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-ready": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-ready/-/parser-ready-10.5.0.tgz", - "integrity": "sha512-QIf65LTvUoxqWWHBpgYOL+soldLIIyD1bwuWelukem2yDZVWwEjR288cLQ558BgYxH4U+jLAQahhqoyN1I7BaA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-regex": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-regex/-/parser-regex-10.5.0.tgz", - "integrity": "sha512-9jnr9+PCxRoLjtGs7uxwsFqvho+rxuJlW6ZWSB7oqfzshEZWXtTJgJRgac/RuLft4hRlrmRz5XU40i3uoL4HKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-slip-encoder": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-slip-encoder/-/parser-slip-encoder-10.5.0.tgz", - "integrity": "sha512-wP8m+uXQdkWSa//3n+VvfjLthlabwd9NiG6kegf0fYweLWio8j4pJRL7t9eTh2Lbc7zdxuO0r8ducFzO0m8CQw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/parser-spacepacket": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/parser-spacepacket/-/parser-spacepacket-10.5.0.tgz", - "integrity": "sha512-BEZ/HAEMwOd8xfuJSeI/823IR/jtnThovh7ils90rXD4DPL1ZmrP4abAIEktwe42RobZjIPfA4PaVfyO0Fjfhg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@serialport/stream": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/@serialport/stream/-/stream-10.5.0.tgz", - "integrity": "sha512-gbcUdvq9Kyv2HsnywS7QjnEB28g+6OGB5Z8TLP7X+UPpoMIWoUsoQIq5Kt0ZTgMoWn3JGM2lqwTsSHF+1qhniA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@serialport/bindings-interface": "1.2.2", - "debug": "^4.3.2" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "22.5.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", - "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "undici-types": "~6.19.2" - } - }, - "node_modules/acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", - "dev": true, - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", - "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, - "license": "MIT" - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/cli-cursor": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", - "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", - "dev": true, - "license": "MIT", - "dependencies": { - "restore-cursor": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-spinners": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", - "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/commist": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/commist/-/commist-1.1.0.tgz", - "integrity": "sha512-rraC8NXWOEjhADbZe9QBNzLAN5Q3fsTPQtBV+fEVj6xKIgDgNiEVE6ZNfHpZOqfQ21YUzfVNUXLOEZquYvQPPg==", - "dev": true, - "license": "MIT", - "dependencies": { - "leven": "^2.1.0", - "minimist": "^1.1.0" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, - "license": "MIT" - }, - "node_modules/concat-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", - "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", - "dev": true, - "engines": [ - "node >= 6.0" - ], - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.0.2", - "typedarray": "^0.0.6" - } - }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/duplexify": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz", - "integrity": "sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==", - "dev": true, - "license": "MIT", - "dependencies": { - "end-of-stream": "^1.4.1", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1", - "stream-shift": "^1.0.2" - } - }, - "node_modules/emoji-regex": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", - "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", - "dev": true, - "license": "MIT" - }, - "node_modules/end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "once": "^1.4.0" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true, - "license": "ISC" - }, - "node_modules/get-east-asian-width": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.2.0.tgz", - "integrity": "sha512-2nk+7SIVb14QrgXFHcm84tD4bKQz0RxPuMT8Ag5KPOq7J5fEmAg0UbXdTOSHqNuHSU28k55qnceesxXRZGzKWA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/help-me": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/help-me/-/help-me-3.0.0.tgz", - "integrity": "sha512-hx73jClhyk910sidBB7ERlnhMlFsJJIBqSVMFDwPN8o2v9nmp5KgLq1Xz1Bf1fCMMZ6mPrX159iG0VLy/fPMtQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "glob": "^7.1.6", - "readable-stream": "^3.6.0" - } - }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", - "dev": true, - "license": "ISC", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/is-interactive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", - "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-unicode-supported": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", - "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/js-sdsl": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", - "integrity": "sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==", - "dev": true, - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, - "node_modules/latch": { - "version": "0.3.0", - "resolved": "file:latch-0.3.0.tgz", - "integrity": "sha512-4ZVbuSUb5lmSvcNWfGDnxrOUoFq7uTL62CvfglTunjPig5r5f0daTWd76CwdylxQobInUH3RVXSx8qIZ1HjTmA==", - "dev": true, - "dependencies": { - "ansi-colors": "^4.1.3", - "ieee754": "^1.2.1", - "ora": "^8.0.1", - "source-map": "^0.7.4", - "ts-node": "^10.5.0" - }, - "bin": { - "latch": "npx ts-node" - } - }, - "node_modules/leven": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", - "integrity": "sha512-nvVPLpIHUxCUoRLrFqTgSxXJ614d8AgQoWl7zPe/2VadE8+1dpU3LBhowRuBAcuwruWtOdD8oYC9jDNJjXDPyA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/log-symbols": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", - "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^5.3.0", - "is-unicode-supported": "^1.3.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/log-symbols/node_modules/is-unicode-supported": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", - "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, - "node_modules/mimic-function": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", - "integrity": "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/mqtt": { - "version": "4.3.8", - "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.3.8.tgz", - "integrity": "sha512-2xT75uYa0kiPEF/PE0VPdavmEkoBzMT/UL9moid0rAvlCtV48qBwxD62m7Ld/4j8tSkIO1E/iqRl/S72SEOhOw==", - "dev": true, - "license": "MIT", - "dependencies": { - "commist": "^1.0.0", - "concat-stream": "^2.0.0", - "debug": "^4.1.1", - "duplexify": "^4.1.1", - "help-me": "^3.0.0", - "inherits": "^2.0.3", - "lru-cache": "^6.0.0", - "minimist": "^1.2.5", - "mqtt-packet": "^6.8.0", - "number-allocator": "^1.0.9", - "pump": "^3.0.0", - "readable-stream": "^3.6.0", - "reinterval": "^1.1.0", - "rfdc": "^1.3.0", - "split2": "^3.1.0", - "ws": "^7.5.5", - "xtend": "^4.0.2" - }, - "bin": { - "mqtt": "bin/mqtt.js", - "mqtt_pub": "bin/pub.js", - "mqtt_sub": "bin/sub.js" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/mqtt-packet": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/mqtt-packet/-/mqtt-packet-6.10.0.tgz", - "integrity": "sha512-ja8+mFKIHdB1Tpl6vac+sktqy3gA8t9Mduom1BA75cI+R9AHnZOiaBQwpGiWnaVJLDGRdNhQmFaAqd7tkKSMGA==", - "dev": true, - "license": "MIT", - "dependencies": { - "bl": "^4.0.2", - "debug": "^4.1.1", - "process-nextick-args": "^2.0.1" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/node-addon-api": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", - "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==", - "dev": true, - "license": "MIT" - }, - "node_modules/node-gyp-build": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.2.tgz", - "integrity": "sha512-IRUxE4BVsHWXkV/SFOut4qTlagw2aM8T5/vnTsmrHJvVoKueJHRc/JaFND7QDDc61kLYUJ6qlZM3sqTSyx2dTw==", - "dev": true, - "license": "MIT", - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, - "node_modules/number-allocator": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/number-allocator/-/number-allocator-1.0.14.tgz", - "integrity": "sha512-OrL44UTVAvkKdOdRQZIJpLkAdjXGTRda052sN4sO77bKEzYYqWKMBjQvrJFzqygI99gL6Z4u2xctPW1tB8ErvA==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.3.1", - "js-sdsl": "4.3.0" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/onetime": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", - "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-function": "^5.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/ora/-/ora-8.1.0.tgz", - "integrity": "sha512-GQEkNkH/GHOhPFXcqZs3IDahXEQcQxsSjEkK4KvEEST4t7eNzoMjxTzef+EZ+JluDEV+Raoi3WQ2CflnRdSVnQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^5.3.0", - "cli-cursor": "^5.0.0", - "cli-spinners": "^2.9.2", - "is-interactive": "^2.0.0", - "is-unicode-supported": "^2.0.0", - "log-symbols": "^6.0.0", - "stdin-discarder": "^0.2.2", - "string-width": "^7.2.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true, - "license": "MIT" - }, - "node_modules/pump": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", - "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", - "dev": true, - "license": "MIT", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/reinterval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/reinterval/-/reinterval-1.1.0.tgz", - "integrity": "sha512-QIRet3SYrGp0HUHO88jVskiG6seqUGC5iAG7AwI/BV4ypGcuqk9Du6YQBUOUqm9c8pw1eyLoIaONifRua1lsEQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/restore-cursor": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", - "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", - "dev": true, - "license": "MIT", - "dependencies": { - "onetime": "^7.0.0", - "signal-exit": "^4.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/rfdc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz", - "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", - "dev": true, - "license": "MIT" - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/serialport": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/serialport/-/serialport-10.5.0.tgz", - "integrity": "sha512-7OYLDsu5i6bbv3lU81pGy076xe0JwpK6b49G6RjNvGibstUqQkI+I3/X491yBGtf4gaqUdOgoU1/5KZ/XxL4dw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@serialport/binding-mock": "10.2.2", - "@serialport/bindings-cpp": "10.8.0", - "@serialport/parser-byte-length": "10.5.0", - "@serialport/parser-cctalk": "10.5.0", - "@serialport/parser-delimiter": "10.5.0", - "@serialport/parser-inter-byte-timeout": "10.5.0", - "@serialport/parser-packet-length": "10.5.0", - "@serialport/parser-readline": "10.5.0", - "@serialport/parser-ready": "10.5.0", - "@serialport/parser-regex": "10.5.0", - "@serialport/parser-slip-encoder": "10.5.0", - "@serialport/parser-spacepacket": "10.5.0", - "@serialport/stream": "10.5.0", - "debug": "^4.3.3" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/serialport/donate" - } - }, - "node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/source-map": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", - "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">= 8" - } - }, - "node_modules/split2": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", - "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", - "dev": true, - "license": "ISC", - "dependencies": { - "readable-stream": "^3.0.0" - } - }, - "node_modules/stdin-discarder": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.2.2.tgz", - "integrity": "sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/stream-shift": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", - "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/string-width": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", - "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^10.3.0", - "get-east-asian-width": "^1.0.0", - "strip-ansi": "^7.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", - "dev": true, - "license": "MIT" - }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true, - "license": "MIT" - }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, - "license": "MIT" - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/ws": { - "version": "7.5.10", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", - "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/xtend": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", - "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4" - } - }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "license": "ISC" - }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - } - } -} diff --git a/tests/latch/package.json b/tests/latch/package.json index a1fd84ae..4b8ee549 100644 --- a/tests/latch/package.json +++ b/tests/latch/package.json @@ -1,16 +1,16 @@ { - "name": "warduino-testsuite", - "version": "1.0.0", - "scripts": { - "debugtest": "npx ts-node ./src/debugger.test.ts", - "primtest": "npx ts-node ./src/primitives.test.ts", - "spectest": "npx ts-node ./src/spec.test.ts", - "comptest": "npx ts-node ./src/comp.test.ts" - }, - "devDependencies": { - "latch": "file:./latch-0.3.1.tgz", - "mqtt": "^4.3.7", - "serialport": "^10.4.0", - "typescript": "^4.5.5" - } + "name": "warduino-testsuite", + "version": "1.0.0", + "scripts": { + "debugtest": "npx ts-node ./src/debugger.test.ts", + "primtest": "npx ts-node ./src/primitives.test.ts", + "spectest": "npx ts-node ./src/spec.test.ts", + "comptest": "npx ts-node ./src/comp.test.ts" + }, + "devDependencies": { + "latch": "file:./latch-0.3.1.tgz", + "mqtt": "^4.3.7", + "serialport": "^10.4.0", + "typescript": "^4.5.5" + } } diff --git a/tests/latch/src/debugger.test.ts b/tests/latch/src/debugger.test.ts index 28485b91..b80d9f43 100644 --- a/tests/latch/src/debugger.test.ts +++ b/tests/latch/src/debugger.test.ts @@ -13,8 +13,10 @@ import { Message, OutputStyle, Step, Suite, TestScenario, - Breakpoint + Breakpoint, OutofPlaceSpecification, Target, WASM, Invoker } from 'latch'; +import dump = Message.dump; +import step = Message.step; export const EMULATOR: string = process.env.EMULATOR ?? `${require('os').homedir()}/Arduino/libraries/WARDuino/build-emu/wdcli`; @@ -180,30 +182,7 @@ integration.test(dumpFullTest); // Test *run* command -const running: Step[] = [DUMP, { - title: 'Send RUN command', - instruction: {kind: Kind.Request, value: Message.run}, -}, { - title: 'CHECK: execution continues', - instruction: {kind: Kind.Request, value: Message.dump}, - expected: [{ - 'pc': {kind: 'description', value: Description.defined} as Expected - }, { - 'pc': {kind: 'behaviour', value: Behaviour.changed} as Expected - }] -}]; - -integration.test({ - title: 'Test RUN blink', - program: `${EXAMPLES}blink.wast`, - steps: running -}); - -integration.test({ - title: 'Test RUN button', - program: `${EXAMPLES}button.wast`, - steps: running -}); +// todo // Test *pause* command @@ -338,7 +317,7 @@ oop.testee('supervisor[:8100] - proxy[:8150]', new OutofPlaceSpecification(8100, oop.test({ title: `Test store primitive`, - program: 'test/dummy.wast', + program: `${EXAMPLES}dummy.wast`, dependencies: [], steps: [ { From 8429745194e552ebd308f8198b1d9e09cd4d3b31 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 3 Dec 2024 13:31:46 +0100 Subject: [PATCH 18/31] Increase timeout --- tests/latch/src/debugger.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/latch/src/debugger.test.ts b/tests/latch/src/debugger.test.ts index b80d9f43..2eb49b58 100644 --- a/tests/latch/src/debugger.test.ts +++ b/tests/latch/src/debugger.test.ts @@ -31,8 +31,8 @@ framework.style(OutputStyle.github); const integration: Suite = framework.suite('Integration tests: Debugger'); // must be called first -integration.testee('emulator [:8500]', new EmulatorSpecification(8500)); -//integration.testee('esp wrover', new ArduinoSpecification('/dev/ttyUSB0', 'esp32:esp32:esp32wrover'), new HybridScheduler(), {timeout: 0}); +integration.testee('emulator [:8500]', new EmulatorSpecification(8500), {timeout: 4000}); +//integration.testee('esp wrover', new ArduinoSpecification('/dev/ttyUSB0', 'esp32:esp32:esp32wrover'), {timeout: 0}); const expectDUMP: Expectation[] = [ {'pc': {kind: 'description', value: Description.defined} as Expected}, @@ -313,7 +313,7 @@ integration.test(dumpEventsTest); const oop = framework.suite('Test Out-of-place primitives'); -oop.testee('supervisor[:8100] - proxy[:8150]', new OutofPlaceSpecification(8100, 8150)); +oop.testee('supervisor[:8100] - proxy[:8150]', new OutofPlaceSpecification(8100, 8150), {timeout: 4000}); oop.test({ title: `Test store primitive`, @@ -362,4 +362,5 @@ oop.test({ ] }); -framework.run([integration,oop]); +framework.run([integration,oop]).then(() => process.exit(0)); + From 4afbfd1a3e30d23a9547842803eab8a9aa9cc624 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 3 Dec 2024 13:46:36 +0100 Subject: [PATCH 19/31] fixup! Increase timeout --- tests/latch/src/debugger.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/latch/src/debugger.test.ts b/tests/latch/src/debugger.test.ts index 2eb49b58..ead2c8c7 100644 --- a/tests/latch/src/debugger.test.ts +++ b/tests/latch/src/debugger.test.ts @@ -313,7 +313,7 @@ integration.test(dumpEventsTest); const oop = framework.suite('Test Out-of-place primitives'); -oop.testee('supervisor[:8100] - proxy[:8150]', new OutofPlaceSpecification(8100, 8150), {timeout: 4000}); +oop.testee('supervisor[:8100] - proxy[:8150]', new OutofPlaceSpecification(8100, 8150), {timeout: 20000}); oop.test({ title: `Test store primitive`, From dfd05c336bbdce567cd197af7e81462e7ca9fd52 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Thu, 6 Feb 2025 16:06:53 +0100 Subject: [PATCH 20/31] Refactor Edward -> Oop --- src/{Edward => Oop}/RFC.cpp | 0 src/{Edward => Oop}/RFC.h | 0 src/{Edward => Oop}/proxy.cpp | 0 src/{Edward => Oop}/proxy.h | 0 src/{Edward => Oop}/proxy_supervisor.cpp | 0 src/{Edward => Oop}/proxy_supervisor.h | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename src/{Edward => Oop}/RFC.cpp (100%) rename src/{Edward => Oop}/RFC.h (100%) rename src/{Edward => Oop}/proxy.cpp (100%) rename src/{Edward => Oop}/proxy.h (100%) rename src/{Edward => Oop}/proxy_supervisor.cpp (100%) rename src/{Edward => Oop}/proxy_supervisor.h (100%) diff --git a/src/Edward/RFC.cpp b/src/Oop/RFC.cpp similarity index 100% rename from src/Edward/RFC.cpp rename to src/Oop/RFC.cpp diff --git a/src/Edward/RFC.h b/src/Oop/RFC.h similarity index 100% rename from src/Edward/RFC.h rename to src/Oop/RFC.h diff --git a/src/Edward/proxy.cpp b/src/Oop/proxy.cpp similarity index 100% rename from src/Edward/proxy.cpp rename to src/Oop/proxy.cpp diff --git a/src/Edward/proxy.h b/src/Oop/proxy.h similarity index 100% rename from src/Edward/proxy.h rename to src/Oop/proxy.h diff --git a/src/Edward/proxy_supervisor.cpp b/src/Oop/proxy_supervisor.cpp similarity index 100% rename from src/Edward/proxy_supervisor.cpp rename to src/Oop/proxy_supervisor.cpp diff --git a/src/Edward/proxy_supervisor.h b/src/Oop/proxy_supervisor.h similarity index 100% rename from src/Edward/proxy_supervisor.h rename to src/Oop/proxy_supervisor.h From b2309c3b6a070e8a24abba9df03a3b59cfe3f88e Mon Sep 17 00:00:00 2001 From: tolauwae Date: Fri, 7 Feb 2025 05:48:10 +0100 Subject: [PATCH 21/31] fixup! Refactor Edward -> Oop --- CMakeLists.txt | 12 ++++++------ platforms/ESP-IDF/CMakeLists.txt | 6 +++--- platforms/Zephyr/CMakeLists.txt | 6 +++--- src/Debug/debugger.h | 2 +- src/WARDuino.h | 2 +- tutorials/assemblyscript/main/CMakeLists.txt | 6 +++--- tutorials/wat/main/CMakeLists.txt | 6 +++--- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ca6b712..32041e6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,9 +53,9 @@ if (BUILD_EMULATOR) src/Utils/macros.cpp src/Utils/sockets.cpp src/Debug/debugger.cpp - src/Edward/proxy.cpp - src/Edward/proxy_supervisor.cpp - src/Edward/RFC.cpp + src/Oop/proxy.cpp + src/Oop/proxy_supervisor.cpp + src/Oop/RFC.cpp ) add_definitions(-DINFO=0) @@ -95,9 +95,9 @@ if (BUILD_UNITTEST) src/Utils/macros.cpp src/Utils/sockets.cpp src/Debug/debugger.cpp - src/Edward/proxy.cpp - src/Edward/proxy_supervisor.cpp - src/Edward/RFC.cpp + src/Oop/proxy.cpp + src/Oop/proxy_supervisor.cpp + src/Oop/RFC.cpp ) # Set default compile flags for GCC diff --git a/platforms/ESP-IDF/CMakeLists.txt b/platforms/ESP-IDF/CMakeLists.txt index fed06de8..73a54e36 100644 --- a/platforms/ESP-IDF/CMakeLists.txt +++ b/platforms/ESP-IDF/CMakeLists.txt @@ -5,9 +5,9 @@ set(SOURCE_FILES ../../src/Interpreter/proxied.cpp ../../src/Memory/mem.cpp ../../src/Primitives/idf.cpp - ../../src/Edward/proxy.cpp - ../../src/Edward/proxy_supervisor.cpp - ../../src/Edward/RFC.cpp + ../../src/Oop/proxy.cpp + ../../src/Oop/proxy_supervisor.cpp + ../../src/Oop/RFC.cpp ../../src/Utils/macros.cpp ../../src/Utils/sockets.cpp ../../src/Utils/util.cpp diff --git a/platforms/Zephyr/CMakeLists.txt b/platforms/Zephyr/CMakeLists.txt index 0ed056c0..0bd989a1 100644 --- a/platforms/Zephyr/CMakeLists.txt +++ b/platforms/Zephyr/CMakeLists.txt @@ -25,9 +25,9 @@ target_sources(app PRIVATE ../../src/Utils/macros.cpp ../../src/Utils/sockets.cpp ../../src/Debug/debugger.cpp - ../../src/Edward/proxy.cpp - ../../src/Edward/proxy_supervisor.cpp - ../../src/Edward/RFC.cpp + ../../src/Oop/proxy.cpp + ../../src/Oop/proxy_supervisor.cpp + ../../src/Oop/RFC.cpp upload.h ) diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index cf6d29cd..e50c7269 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -11,7 +11,7 @@ #include #include -#include "../Edward/proxy.h" +#include "../Oop/proxy.h" #include "../Threading/warduino-thread.h" #include "../Utils/sockets.h" diff --git a/src/WARDuino.h b/src/WARDuino.h index 8d04d160..b876ad4b 100644 --- a/src/WARDuino.h +++ b/src/WARDuino.h @@ -9,7 +9,7 @@ #include #include "Debug/debugger.h" -#include "Edward/proxy_supervisor.h" +#include "Oop/proxy_supervisor.h" #include "Interpreter/interpreter.h" #include "WARDuino/internals.h" diff --git a/tutorials/assemblyscript/main/CMakeLists.txt b/tutorials/assemblyscript/main/CMakeLists.txt index 6cd29af4..3989adc9 100644 --- a/tutorials/assemblyscript/main/CMakeLists.txt +++ b/tutorials/assemblyscript/main/CMakeLists.txt @@ -4,9 +4,9 @@ set(SOURCE_FILES ../../../src/Utils/util_arduino.cpp ../../../src/Utils/sockets.cpp ../../../src/Debug/debugger.cpp - ../../../src/Edward/proxy.cpp - ../../../src/Edward/proxy_supervisor.cpp - ../../../src/Edward/RFC.cpp + ../../../src/Oop/proxy.cpp + ../../../src/Oop/proxy_supervisor.cpp + ../../../src/Oop/RFC.cpp ../../../src/Utils/macros.cpp ../../../src/WARDuino/WARDuino.cpp ../../../src/Primitives/emulated.cpp diff --git a/tutorials/wat/main/CMakeLists.txt b/tutorials/wat/main/CMakeLists.txt index 8a775fb6..51664b3f 100644 --- a/tutorials/wat/main/CMakeLists.txt +++ b/tutorials/wat/main/CMakeLists.txt @@ -3,9 +3,9 @@ set(SOURCE_FILES ../../../src/Interpreter/instructions.cpp ../../../src/Memory/mem.cpp ../../../src/Primitives/idf.cpp - ../../../src/Edward/proxy.cpp - ../../../src/Edward/proxy_supervisor.cpp - ../../../src/Edward/RFC.cpp + ../../../src/Oop/proxy.cpp + ../../../src/Oop/proxy_supervisor.cpp + ../../../src/Oop/RFC.cpp ../../../src/Utils/macros.cpp ../../../src/Utils/sockets.cpp ../../../src/Utils/util.cpp From 972197e14bf886fb54a59650bae96834079ad059 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sun, 9 Feb 2025 08:04:08 +0100 Subject: [PATCH 22/31] Add transfer debug operation --- src/Debug/debugger.cpp | 30 ++++++++++++++++++++++++++++++ src/Debug/debugger.h | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index cce65287..dec615bd 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -312,6 +312,11 @@ bool Debugger::checkDebugMessages(Module *m, RunningState *program_state) { this->channel->write("%s!\n", receivingData ? "ack" : "done"); } break; + case interruptTransfer: + this->transfer(m, interruptData); + free(interruptData); + this->channel->write("Transferred!\n"); + break; case interruptProxyCall: { this->handleProxyCall(m, program_state, interruptData + 1); free(interruptData); @@ -1120,6 +1125,31 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) { debug("done with first msg\n"); } +void load(uint8_t *bytes, Module* m) { + auto start = read_B32(&bytes); + auto limit = read_B32(&bytes); + auto total_bytes = limit - start + 1; + memcpy(m->memory.bytes + start, bytes, total_bytes); +} + +void Debugger::transfer(Module *m, uint8_t *interruptData) { + uint8_t *cursor = nullptr; + uint8_t *end = nullptr; + cursor = interruptData + 1; // skip interruptLoadSnapshot + uint32_t len = read_B32(&cursor); + end = cursor + len; + + while (cursor < end) { + switch (*cursor++) { + case memoryState: + load(cursor, m); + default: { + debug("do nothing\n"); + } + } + } +} + bool Debugger::saveState(Module *m, uint8_t *interruptData) { uint8_t *program_state = nullptr; uint8_t *end_state = nullptr; diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index e50c7269..56f69c7b 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -76,6 +76,9 @@ enum InterruptTypes { // Remote REPL interruptINVOKE = 0x40, + // Stateful out-of-place + interruptTransfer = 0x52, + // Pull Debugging interruptSnapshot = 0x60, interruptSetSnapshotPolicy = 0x61, @@ -208,6 +211,8 @@ class Debugger { bool saveState(Module *m, uint8_t *interruptData); + void transfer(Module *m, uint8_t *interruptData); + static uintptr_t readPointer(uint8_t **data); static void updateCallbackmapping(Module *m, const char *interruptData); From b42ae4b4ae5a91d7555669a5dd3398f8e94520c3 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sun, 9 Feb 2025 13:37:16 +0100 Subject: [PATCH 23/31] Fix load for transfer operation --- src/Debug/debugger.cpp | 12 ++++++------ src/Debug/debugger.h | 2 ++ src/Utils/util.cpp | 7 +++++++ src/Utils/util.h | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index dec615bd..d9d3a9a5 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -1125,18 +1125,18 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) { debug("done with first msg\n"); } -void load(uint8_t *bytes, Module* m) { - auto start = read_B32(&bytes); - auto limit = read_B32(&bytes); +void Debugger::load(uint8_t *bytes, Module* m) { + auto start = read_B8(&bytes); + auto limit = read_B8(&bytes); auto total_bytes = limit - start + 1; + this->channel->write("loading into %u - %u \n", start, limit); memcpy(m->memory.bytes + start, bytes, total_bytes); } void Debugger::transfer(Module *m, uint8_t *interruptData) { - uint8_t *cursor = nullptr; + uint8_t *cursor = interruptData; uint8_t *end = nullptr; - cursor = interruptData + 1; // skip interruptLoadSnapshot - uint32_t len = read_B32(&cursor); + uint16_t len = read_B16(&cursor); end = cursor + len; while (cursor < end) { diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index 56f69c7b..63a2a2ed 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -211,6 +211,8 @@ class Debugger { bool saveState(Module *m, uint8_t *interruptData); + void load(uint8_t *bytes, Module* m); + void transfer(Module *m, uint8_t *interruptData); static uintptr_t readPointer(uint8_t **data); diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index 7800fcad..c7f52dca 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -347,6 +347,13 @@ uint16_t read_B16(uint8_t **bytes) { return n; } +uint8_t read_B8(uint8_t **bytes) { + uint8_t *b = *bytes; + uint8_t n = b[0]; + *bytes += 1; + return n; +} + int read_B32_signed(uint8_t **bytes) { uint8_t *b = *bytes; int n = (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3]; diff --git a/src/Utils/util.h b/src/Utils/util.h index a31e849c..2d303044 100644 --- a/src/Utils/util.h +++ b/src/Utils/util.h @@ -121,6 +121,7 @@ double wa_fmin(double a, double b); // legacy util functions (todo remove) uint32_t read_B32(uint8_t **bytes); uint16_t read_B16(uint8_t **bytes); +uint8_t read_B8(uint8_t **bytes); int read_B32_signed(uint8_t **bytes); uint32_t read_L32(uint8_t **bytes); void chars_as_hexa(unsigned char *dest, unsigned char *source, From 7d57709ed6141e15e6717bb6397b1aa1d4706a1a Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sun, 9 Feb 2025 21:27:55 +0100 Subject: [PATCH 24/31] Add transfer to RFC call --- CMakeLists.txt | 2 ++ src/Oop/RFC.cpp | 14 ++++++++++++++ src/Oop/RFC.h | 4 +++- src/Oop/proxy_supervisor.cpp | 9 ++++++++- src/Primitives/emulated.cpp | 31 +++++++++++++++++++++++++++++-- src/Primitives/primitives.h | 2 ++ src/WARDuino.h | 4 +++- 7 files changed, 61 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32041e6a..eb7f02a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ if (BUILD_EMULATOR) src/Oop/proxy.cpp src/Oop/proxy_supervisor.cpp src/Oop/RFC.cpp + src/Oop/stateful.cpp ) add_definitions(-DINFO=0) @@ -98,6 +99,7 @@ if (BUILD_UNITTEST) src/Oop/proxy.cpp src/Oop/proxy_supervisor.cpp src/Oop/RFC.cpp + src/Oop/stateful.cpp ) # Set default compile flags for GCC diff --git a/src/Oop/RFC.cpp b/src/Oop/RFC.cpp index 5e8e63ec..612471a4 100644 --- a/src/Oop/RFC.cpp +++ b/src/Oop/RFC.cpp @@ -1,4 +1,18 @@ #include "RFC.h" +#include +#include + RFC::RFC(Module *m, uint32_t id, Type *t_type, StackValue *t_args) : m(m), fidx(id), args(t_args), type(t_type) {} + +SerializeData *merge(SerializeData a, SerializeData b) { + auto data = new SerializeData; + data->size = a.size + b.size + 2; + data->raw = (unsigned char *)calloc(sizeof(char), data->size); + std::memcpy(data->raw, a.raw, a.size); + *(data->raw + a.size) = '\n'; + std::memcpy(data->raw + a.size + 1, b.raw, b.size); + *(data->raw + a.size + b.size + 1) = '\n'; + return data; +} diff --git a/src/Oop/RFC.h b/src/Oop/RFC.h index 6b03d2d2..43c14717 100644 --- a/src/Oop/RFC.h +++ b/src/Oop/RFC.h @@ -7,10 +7,12 @@ struct StackValue; struct Type; struct SerializeData { - const unsigned char *raw; + unsigned char *raw; uint32_t size; }; +SerializeData *merge(SerializeData a, SerializeData b); + class RFC { public: Module *m; diff --git a/src/Oop/proxy_supervisor.cpp b/src/Oop/proxy_supervisor.cpp index c8140304..9d6ac42f 100644 --- a/src/Oop/proxy_supervisor.cpp +++ b/src/Oop/proxy_supervisor.cpp @@ -12,6 +12,7 @@ #include "../../lib/json/single_include/nlohmann/json.hpp" #endif +#include "../Primitives/primitives.h" #include "../Utils/macros.h" #include "../Utils/util.h" #include "../WARDuino/CallbackHandler.h" @@ -195,7 +196,13 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) { auto *ser = new SerializeData; ser->size = hexa_size + 1; ser->raw = hexa; - return ser; + + auto *transfer = get_transfer(callee->m, callee->fidx); + auto *message = merge(*transfer, *ser); + + delete ser; + free(transfer); + return message; } void ProxySupervisor::deserializeRFCResult(RFC *rfc) { diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index 81ab3a43..ad4841fb 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -21,6 +21,7 @@ #include #include "../Memory/mem.h" +#include "../Oop/stateful.h" #include "../Utils/macros.h" #include "../Utils/util.h" #include "../WARDuino/CallbackHandler.h" @@ -46,6 +47,7 @@ double sensor_emu = 0; if (prim_index < ALL_PRIMITIVES) { \ PrimitiveEntry *p = &primitives[prim_index++]; \ p->name = #prim_name; \ + p->index = prim_index - 1; \ p->f = &(prim_name); \ p->f_reverse = nullptr; \ p->f_serialize_state = nullptr; \ @@ -73,6 +75,9 @@ double sensor_emu = 0; void function_name##_serialize( \ std::vector &external_state) +#define def_prim_transfer(function_name) \ + SerializeData &function_name##_transfer([[maybe_unused]] Module *m) + // TODO: use fp #define pop_args(n) m->sp -= n #define get_arg(m, arg) m->stack[(m)->sp - (arg)].value @@ -256,8 +261,14 @@ def_prim(dummy, twoToOneU32) { return true; } +def_prim_transfer(dummy) { + uint32_t start = arg1.uint32; + uint32_t end = arg0.uint32; + return sync_memory(m, start, end); +} + def_prim(millis, NoneToOneU64) { - struct timeval tv {}; + struct timeval tv{}; gettimeofday(&tv, nullptr); unsigned long millis = 1000 * tv.tv_sec + tv.tv_usec; pushUInt64(millis); @@ -265,7 +276,7 @@ def_prim(millis, NoneToOneU64) { } def_prim(micros, NoneToOneU64) { - struct timeval tv {}; + struct timeval tv{}; gettimeofday(&tv, nullptr); unsigned long micros = 1000000 * tv.tv_sec + tv.tv_usec; pushUInt64(micros); @@ -646,4 +657,20 @@ std::vector get_io_state(Module *) { return ioState; } +SerializeData *get_transfer(Module *m, uint32_t index) { + SerializeData *nil = new SerializeData; + nil->raw = nullptr; + nil->size = 0; + for (auto &primitive : primitives) { + if (index == primitive.index) { + if (primitive.f_transfer) { + return primitive.f_transfer(m); + } else { + return nil; + } + } + } + return nil; +} + #endif // ARDUINO diff --git a/src/Primitives/primitives.h b/src/Primitives/primitives.h index 0a9509e9..2ead1d8a 100644 --- a/src/Primitives/primitives.h +++ b/src/Primitives/primitives.h @@ -81,4 +81,6 @@ void invoke_primitive(Module *m, const std::string &function_name, Ts... args) { primitive(m); } +SerializeData *get_transfer(Module *m, uint32_t index); + #endif diff --git a/src/WARDuino.h b/src/WARDuino.h index b876ad4b..465b846a 100644 --- a/src/WARDuino.h +++ b/src/WARDuino.h @@ -9,8 +9,8 @@ #include #include "Debug/debugger.h" -#include "Oop/proxy_supervisor.h" #include "Interpreter/interpreter.h" +#include "Oop/proxy_supervisor.h" #include "WARDuino/internals.h" // Constants @@ -71,9 +71,11 @@ struct IOStateElement { typedef struct PrimitiveEntry { const char *name; + uint32_t index; Primitive f; void (*f_reverse)(Module *m, std::vector); void (*f_serialize_state)(std::vector &); + SerializeData *(*f_transfer)(Module *m); Type t; } PrimitiveEntry; From 3f6d3a5a574e165dcd6da8d7b6586ae801d4b137 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sun, 2 Mar 2025 14:46:29 +0100 Subject: [PATCH 25/31] fixup! Add transfer to RFC call --- src/Debug/debugger.cpp | 5 +++- src/Debug/debugger.h | 2 +- src/Interpreter/proxied.cpp | 8 +++--- src/Oop/RFC.cpp | 51 ++++++++++++++++++++++++++++++----- src/Oop/RFC.h | 6 +++-- src/Oop/proxy_supervisor.cpp | 16 ++++++----- src/Oop/stateful.cpp | 22 +++++++++++++++ src/Oop/stateful.h | 5 ++++ src/Primitives/emulated.cpp | 52 ++++++++++++++++++++++-------------- src/Utils/macros.h | 12 ++++++--- src/Utils/sockets.cpp | 4 +-- src/Utils/util.cpp | 2 +- src/WARDuino.h | 4 +-- 13 files changed, 139 insertions(+), 50 deletions(-) create mode 100644 src/Oop/stateful.cpp create mode 100644 src/Oop/stateful.h diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index d9d3a9a5..bd8cb19f 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -180,6 +180,7 @@ bool Debugger::checkDebugMessages(Module *m, RunningState *program_state) { debug("received interrupt %x\n", *interruptData); fflush(stdout); + printf("Interrupt: %x\n", *interruptData); this->channel->write("Interrupt: %x\n", *interruptData); long start = 0, size = 0; @@ -1125,7 +1126,7 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) { debug("done with first msg\n"); } -void Debugger::load(uint8_t *bytes, Module* m) { +void Debugger::load(uint8_t *bytes, Module *m) { auto start = read_B8(&bytes); auto limit = read_B8(&bytes); auto total_bytes = limit - start + 1; @@ -1451,6 +1452,7 @@ void Debugger::proxify() { delete WARDuino::instance()->interpreter; WARDuino::instance()->interpreter = new Proxied(); this->proxy = new Proxy(); // TODO delete + this->channel->write("PROXIED!\n"); } void Debugger::handleProxyCall(Module *m, RunningState *, @@ -1691,6 +1693,7 @@ void Debugger::notifyCompleteStep(Module *m) const { m->warduino->debugger->checkpoint(m); } this->channel->write("STEP!\n"); + printf("STEP!\n"); } Debugger::~Debugger() { diff --git a/src/Debug/debugger.h b/src/Debug/debugger.h index 63a2a2ed..3cc79ab3 100644 --- a/src/Debug/debugger.h +++ b/src/Debug/debugger.h @@ -211,7 +211,7 @@ class Debugger { bool saveState(Module *m, uint8_t *interruptData); - void load(uint8_t *bytes, Module* m); + void load(uint8_t *bytes, Module *m); void transfer(Module *m, uint8_t *interruptData); diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp index dc2df906..34bd3cdb 100644 --- a/src/Interpreter/proxied.cpp +++ b/src/Interpreter/proxied.cpp @@ -15,9 +15,9 @@ void send_leb(Channel *channel, uint32_t value, const char *end = "") { bool Proxied::store(Module *m, [[maybe_unused]] uint8_t type, uint32_t addr, StackValue &sval) { Interpreter::store(m, type, addr, sval); - m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); - send_leb(m->warduino->debugger->channel, addr); - send_leb(m->warduino->debugger->channel, 0); - send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n"); +// m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); +// send_leb(m->warduino->debugger->channel, addr); +// send_leb(m->warduino->debugger->channel, 0); +// send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n"); return true; } diff --git a/src/Oop/RFC.cpp b/src/Oop/RFC.cpp index 612471a4..02bfa844 100644 --- a/src/Oop/RFC.cpp +++ b/src/Oop/RFC.cpp @@ -6,13 +6,50 @@ RFC::RFC(Module *m, uint32_t id, Type *t_type, StackValue *t_args) : m(m), fidx(id), args(t_args), type(t_type) {} -SerializeData *merge(SerializeData a, SerializeData b) { - auto data = new SerializeData; - data->size = a.size + b.size + 2; - data->raw = (unsigned char *)calloc(sizeof(char), data->size); +SerializeData *merge(SerializeData a, SerializeData b, bool divide) { + auto *data = new SerializeData; + auto padding = divide ? 2 : 1; + data->size = a.size + b.size + padding; +// size_t lengte = a.size + b.size + padding; + data->raw = new unsigned char[data->size]; //(unsigned char *)calloc(data->size, sizeof(char)); + if (divide) { + *(data->raw + a.size) = '\n'; + *(data->raw + a.size + b.size + 1) = '\n'; + padding = 1; + } else { + padding = 0; + } std::memcpy(data->raw, a.raw, a.size); - *(data->raw + a.size) = '\n'; - std::memcpy(data->raw + a.size + 1, b.raw, b.size); - *(data->raw + a.size + b.size + 1) = '\n'; + std::memcpy(data->raw + a.size + padding, b.raw, b.size); return data; } + +struct SerializeData* mergeSerializeData(struct SerializeData data1, struct SerializeData data2, bool divide) { + // Allocate memory for the result struct + struct SerializeData *result = + static_cast(malloc(sizeof(struct SerializeData))); + if (result == NULL) { + return NULL; // Memory allocation failure + } + + uint32_t extra = divide ? 1 : 0; + result->size = data1.size + data2.size + extra; + result->raw = static_cast(malloc(result->size)); + if (result->raw == NULL) { + free(result); + return NULL; // Memory allocation failure + } + + // Copy the first data block + memcpy(result->raw, data1.raw, data1.size); + + // Optionally add a newline character + if (divide) { + result->raw[data1.size] = '\n'; + } + + // Copy the second data block after the newline (if inserted) + memcpy(result->raw + data1.size + extra, data2.raw, data2.size); + + return result; +} \ No newline at end of file diff --git a/src/Oop/RFC.h b/src/Oop/RFC.h index 43c14717..e2fded42 100644 --- a/src/Oop/RFC.h +++ b/src/Oop/RFC.h @@ -11,9 +11,11 @@ struct SerializeData { uint32_t size; }; -SerializeData *merge(SerializeData a, SerializeData b); +SerializeData *merge(SerializeData a, SerializeData b, bool divide=true); -class RFC { +struct SerializeData *mergeSerializeData(struct SerializeData data1, struct SerializeData data2, bool divide=true); + + class RFC { public: Module *m; const uint32_t fidx; diff --git a/src/Oop/proxy_supervisor.cpp b/src/Oop/proxy_supervisor.cpp index 9d6ac42f..83be9019 100644 --- a/src/Oop/proxy_supervisor.cpp +++ b/src/Oop/proxy_supervisor.cpp @@ -86,7 +86,7 @@ void ProxySupervisor::listenToSocket() { if (readAmount > 0) { try { nlohmann::basic_json<> parsed = nlohmann::json::parse(message); - debug("parseJSON: %s\n", parsed.dump().c_str()); + printf("parseJSON: %s\n", parsed.dump().c_str()); if (isEvent(parsed)) { CallbackHandler::push_event(new Event( @@ -100,6 +100,7 @@ void ProxySupervisor::listenToSocket() { } } catch (const nlohmann::detail::parse_error &e) { printf("Non RFC call: %s", message); + printf("error: %s", e.what()); WARDuino::instance()->handleInterrupt(readAmount, message); } } @@ -118,6 +119,7 @@ nlohmann::basic_json<> ProxySupervisor::readReply(RFC *rfc) { rfc->m, &WARDuino::instance()->program_state); } WARDuino::instance()->debugger->channel->write("read reply: succeeded\n"); + printf("read reply: succeeded\n"); this->hasReplied = false; return this->proxyResult; } @@ -193,14 +195,13 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) { hexa[hexa_size + 1] = '\0'; // TODO remove zero termination and +2 above delete[] buffer; - auto *ser = new SerializeData; - ser->size = hexa_size + 1; - ser->raw = hexa; + auto *message = new SerializeData; + message->size = hexa_size + 1; + message->raw = hexa; auto *transfer = get_transfer(callee->m, callee->fidx); - auto *message = merge(*transfer, *ser); + this->send(transfer->raw, transfer->size); - delete ser; free(transfer); return message; } @@ -248,8 +249,10 @@ void ProxySupervisor::deserializeRFCResult(RFC *rfc) { } bool ProxySupervisor::call(RFC *callee) { + printf("serializing RFC\n"); struct SerializeData *rfc_request = this->serializeRFC(callee); + printf("sending to proxy: %s ...", static_cast((void *)rfc_request->raw)); bool sent = this->send((void *)rfc_request->raw, rfc_request->size); if (!sent) { callee->success = false; @@ -266,6 +269,7 @@ bool ProxySupervisor::call(RFC *callee) { sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping, &cmdBufferLen); this->send(cmdBuffer, cmdBufferLen); this->deserializeRFCResult(callee); + printf("end of supervisor::call(rfc)\n"); return true; } diff --git a/src/Oop/stateful.cpp b/src/Oop/stateful.cpp new file mode 100644 index 00000000..731d3c84 --- /dev/null +++ b/src/Oop/stateful.cpp @@ -0,0 +1,22 @@ +#include "stateful.h" + +#include "../Utils/util.h" + +SerializeData &sync_memory(Module *m, uint32_t start, uint32_t end) { + uint8_t len = end - start; + + auto message = new SerializeData; + message->size = len + 2; + auto *buffer = (unsigned char *)calloc(sizeof(char), message->size); + + *buffer = start; + *(buffer + 1) = end; + std::memcpy(buffer + 2, m->bytes + start, len); + + auto *hexa = + new unsigned char[message->size]; //+2 for '\n' and '0' termination + chars_as_hexa(hexa, buffer, message->size); + message->raw = hexa; + free(buffer); + return *message; +} \ No newline at end of file diff --git a/src/Oop/stateful.h b/src/Oop/stateful.h new file mode 100644 index 00000000..a8c38aa7 --- /dev/null +++ b/src/Oop/stateful.h @@ -0,0 +1,5 @@ +#pragma once + +#include "../WARDuino.h" + +SerializeData &sync_memory(Module *m, uint32_t start, uint32_t end); diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index ad4841fb..449fe818 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -40,20 +40,22 @@ double sensor_emu = 0; /* Private macros to install a primitive */ -#define install_primitive(prim_name) \ - { \ +#define install_primitive(prim_name) \ + { \ dbg_info("installing primitive number: %d of %d with name: %s\n", \ - prim_index + 1, ALL_PRIMITIVES, #prim_name); \ - if (prim_index < ALL_PRIMITIVES) { \ - PrimitiveEntry *p = &primitives[prim_index++]; \ - p->name = #prim_name; \ - p->index = prim_index - 1; \ - p->f = &(prim_name); \ - p->f_reverse = nullptr; \ - p->f_serialize_state = nullptr; \ - } else { \ - FATAL("prim_index out of bounds"); \ - } \ + prim_index + 1, ALL_PRIMITIVES, #prim_name); \ + if (prim_index < ALL_PRIMITIVES) { \ + PrimitiveEntry *p = &primitives[prim_index++]; \ + p->name = #prim_name; \ + p->t = &(prim_name##_type); \ + p->index = prim_index - 1; \ + p->f = &(prim_name); \ + p->f_reverse = nullptr; \ + p->f_serialize_state = nullptr; \ + p->f_transfer = nullptr; \ + } else { \ + FATAL("prim_index out of bounds"); \ + } \ } #define install_primitive_reverse(prim_name) \ @@ -63,6 +65,12 @@ double sensor_emu = 0; p->f_serialize_state = &(prim_name##_serialize); \ } +#define install_primitive_transfer(prim_name) \ + { \ + PrimitiveEntry *p = &primitives[prim_index - 1]; \ + p->f_transfer = &(prim_name##_transfer); \ + } + #define def_prim(function_name, type) \ Type function_name##_type = type; \ bool function_name([[maybe_unused]] Module *m) @@ -538,6 +546,7 @@ void install_primitives() { dbg_info("INSTALLING PRIMITIVES\n"); dbg_info("INSTALLING FAKE ARDUINO\n"); install_primitive(dummy); + install_primitive_transfer(dummy); install_primitive(abort); install_primitive(millis); @@ -659,16 +668,19 @@ std::vector get_io_state(Module *) { SerializeData *get_transfer(Module *m, uint32_t index) { SerializeData *nil = new SerializeData; + SerializeData header = {.raw = (unsigned char *)"52", .size = 2}; nil->raw = nullptr; nil->size = 0; - for (auto &primitive : primitives) { - if (index == primitive.index) { - if (primitive.f_transfer) { - return primitive.f_transfer(m); - } else { - return nil; - } + if (index < ALL_PRIMITIVES) { + auto &primitive = primitives[index]; + printf("transfering for %s", primitive.name); + if (primitive.f_transfer) { + m->sp += primitive.t->param_count; + SerializeData &payload = primitive.f_transfer(m); + m->sp -= primitive.t->param_count; + nil = merge(header, payload, false); } + return nil; } return nil; } diff --git a/src/Utils/macros.h b/src/Utils/macros.h index 015f9b98..4b765f0d 100644 --- a/src/Utils/macros.h +++ b/src/Utils/macros.h @@ -81,8 +81,10 @@ void end(); #endif #if INFO -#define dbg_info(...) \ - { printf(__VA_ARGS__); } +#define dbg_info(...) \ + { \ + printf(__VA_ARGS__); \ + } #else #define dbg_info(...) ; #endif @@ -98,8 +100,10 @@ void end(); #endif #if WARN -#define dbg_warn(...) \ - { printf(__VA_ARGS__); } +#define dbg_warn(...) \ + { \ + printf(__VA_ARGS__); \ + } #else #define dbg_warn(...) ; #endif diff --git a/src/Utils/sockets.cpp b/src/Utils/sockets.cpp index c5dab7d2..c672c7fd 100644 --- a/src/Utils/sockets.cpp +++ b/src/Utils/sockets.cpp @@ -43,7 +43,7 @@ void bindSocketToAddress(int socket_fd, struct sockaddr_in address) { } struct sockaddr_in createAddress(int port) { - struct sockaddr_in address {}; + struct sockaddr_in address{}; address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons(port); @@ -167,7 +167,7 @@ ssize_t WebSocket::read(void *out, size_t size) { } void sendAlarm() { - struct sigaction sact {}; + struct sigaction sact{}; sigemptyset(&sact.sa_mask); sact.sa_flags = 0; sigaction(SIGALRM, &sact, nullptr); diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index c7f52dca..dab6962c 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -125,7 +125,7 @@ uint64_t read_LEB_(uint8_t **pos, uint32_t maxbits, bool sign) { uint64_t byte; while (true) { - byte = (uint64_t) * *pos; + byte = (uint64_t)**pos; *pos += 1; result |= ((byte & 0x7fu) << shift); shift += 7; diff --git a/src/WARDuino.h b/src/WARDuino.h index 465b846a..540ec693 100644 --- a/src/WARDuino.h +++ b/src/WARDuino.h @@ -75,8 +75,8 @@ typedef struct PrimitiveEntry { Primitive f; void (*f_reverse)(Module *m, std::vector); void (*f_serialize_state)(std::vector &); - SerializeData *(*f_transfer)(Module *m); - Type t; + SerializeData &(*f_transfer)(Module *m); + Type *t; } PrimitiveEntry; class WARDuino { From cda76db45e315d181756ee9f80db03362b686950 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sun, 2 Mar 2025 20:07:56 +0100 Subject: [PATCH 26/31] Fix transfer --- src/Debug/debugger.cpp | 2 +- src/Oop/RFC.cpp | 4 ++-- src/Oop/RFC.h | 2 +- src/Oop/proxy_supervisor.cpp | 8 +++----- src/Oop/stateful.cpp | 19 +++++-------------- src/Oop/stateful.h | 2 +- src/Primitives/emulated.cpp | 22 ++++++++++++---------- src/Primitives/primitives.h | 2 +- src/Utils/util.cpp | 18 ++++++++++++++---- src/Utils/util.h | 9 ++++++--- src/WARDuino.h | 2 +- 11 files changed, 47 insertions(+), 43 deletions(-) diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index bd8cb19f..324eea30 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -1137,7 +1137,7 @@ void Debugger::load(uint8_t *bytes, Module *m) { void Debugger::transfer(Module *m, uint8_t *interruptData) { uint8_t *cursor = interruptData; uint8_t *end = nullptr; - uint16_t len = read_B16(&cursor); + uint16_t len = read_B16(&(++cursor)); end = cursor + len; while (cursor < end) { diff --git a/src/Oop/RFC.cpp b/src/Oop/RFC.cpp index 02bfa844..9c13f07a 100644 --- a/src/Oop/RFC.cpp +++ b/src/Oop/RFC.cpp @@ -11,7 +11,7 @@ SerializeData *merge(SerializeData a, SerializeData b, bool divide) { auto padding = divide ? 2 : 1; data->size = a.size + b.size + padding; // size_t lengte = a.size + b.size + padding; - data->raw = new unsigned char[data->size]; //(unsigned char *)calloc(data->size, sizeof(char)); + data->raw = new char[data->size]; //(unsigned char *)calloc(data->size, sizeof(char)); if (divide) { *(data->raw + a.size) = '\n'; *(data->raw + a.size + b.size + 1) = '\n'; @@ -34,7 +34,7 @@ struct SerializeData* mergeSerializeData(struct SerializeData data1, struct Seri uint32_t extra = divide ? 1 : 0; result->size = data1.size + data2.size + extra; - result->raw = static_cast(malloc(result->size)); + result->raw = static_cast(malloc(result->size)); if (result->raw == NULL) { free(result); return NULL; // Memory allocation failure diff --git a/src/Oop/RFC.h b/src/Oop/RFC.h index e2fded42..2b217466 100644 --- a/src/Oop/RFC.h +++ b/src/Oop/RFC.h @@ -7,7 +7,7 @@ struct StackValue; struct Type; struct SerializeData { - unsigned char *raw; + char *raw; uint32_t size; }; diff --git a/src/Oop/proxy_supervisor.cpp b/src/Oop/proxy_supervisor.cpp index 83be9019..86e6ef28 100644 --- a/src/Oop/proxy_supervisor.cpp +++ b/src/Oop/proxy_supervisor.cpp @@ -189,7 +189,7 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) { // array as hexa const uint32_t hexa_size = serializationSize * 2; auto *hexa = - new unsigned char[hexa_size + 2]; //+2 for '\n' and '0' termination + new char[hexa_size + 2]; //+2 for '\n' and '0' termination chars_as_hexa(hexa, buffer, serializationSize); hexa[hexa_size] = '\n'; hexa[hexa_size + 1] = '\0'; // TODO remove zero termination and +2 above @@ -199,10 +199,8 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) { message->size = hexa_size + 1; message->raw = hexa; - auto *transfer = get_transfer(callee->m, callee->fidx); - this->send(transfer->raw, transfer->size); - - free(transfer); + auto transfer = get_transfer(callee->m, callee->fidx); + this->channel->write(transfer.c_str()); return message; } diff --git a/src/Oop/stateful.cpp b/src/Oop/stateful.cpp index 731d3c84..d4b8134b 100644 --- a/src/Oop/stateful.cpp +++ b/src/Oop/stateful.cpp @@ -2,21 +2,12 @@ #include "../Utils/util.h" -SerializeData &sync_memory(Module *m, uint32_t start, uint32_t end) { +char *sync_memory(Module *m, uint32_t start, uint32_t end) { uint8_t len = end - start; + auto *buffer = (char *)calloc(sizeof(char), (2 * len) + 8); - auto message = new SerializeData; - message->size = len + 2; - auto *buffer = (unsigned char *)calloc(sizeof(char), message->size); + sprintf(buffer, "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, memoryState, start, end); + slebf(buffer + 6, m->bytes + start, len, "\n"); - *buffer = start; - *(buffer + 1) = end; - std::memcpy(buffer + 2, m->bytes + start, len); - - auto *hexa = - new unsigned char[message->size]; //+2 for '\n' and '0' termination - chars_as_hexa(hexa, buffer, message->size); - message->raw = hexa; - free(buffer); - return *message; + return buffer; } \ No newline at end of file diff --git a/src/Oop/stateful.h b/src/Oop/stateful.h index a8c38aa7..5642d196 100644 --- a/src/Oop/stateful.h +++ b/src/Oop/stateful.h @@ -2,4 +2,4 @@ #include "../WARDuino.h" -SerializeData &sync_memory(Module *m, uint32_t start, uint32_t end); +char *sync_memory(Module *m, uint32_t start, uint32_t end); diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index 449fe818..c1ea8619 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -84,7 +84,7 @@ double sensor_emu = 0; std::vector &external_state) #define def_prim_transfer(function_name) \ - SerializeData &function_name##_transfer([[maybe_unused]] Module *m) + char *function_name##_transfer([[maybe_unused]] Module *m) // TODO: use fp #define pop_args(n) m->sp -= n @@ -666,23 +666,25 @@ std::vector get_io_state(Module *) { return ioState; } -SerializeData *get_transfer(Module *m, uint32_t index) { - SerializeData *nil = new SerializeData; - SerializeData header = {.raw = (unsigned char *)"52", .size = 2}; - nil->raw = nullptr; - nil->size = 0; +std::string get_transfer(Module *m, uint32_t index) { + std::stringstream transfer; + auto *buffer = new char[6]; + sprintf(buffer, "%02" PRIx8 "00%02" PRIx8, interruptTransfer, 1); + transfer << std::string(buffer); + delete[] buffer; + if (index < ALL_PRIMITIVES) { auto &primitive = primitives[index]; printf("transfering for %s", primitive.name); if (primitive.f_transfer) { m->sp += primitive.t->param_count; - SerializeData &payload = primitive.f_transfer(m); + auto data = primitive.f_transfer(m); + transfer << std::string(data); + free(data); m->sp -= primitive.t->param_count; - nil = merge(header, payload, false); } - return nil; } - return nil; + return transfer.str(); } #endif // ARDUINO diff --git a/src/Primitives/primitives.h b/src/Primitives/primitives.h index 2ead1d8a..d772d1fb 100644 --- a/src/Primitives/primitives.h +++ b/src/Primitives/primitives.h @@ -81,6 +81,6 @@ void invoke_primitive(Module *m, const std::string &function_name, Ts... args) { primitive(m); } -SerializeData *get_transfer(Module *m, uint32_t index); +std::string get_transfer(Module *m, uint32_t index); #endif diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index dab6962c..e6a51913 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -96,7 +96,7 @@ uint32_t write_LEB_signed(uint8_t *dest, uint64_t val, uint64_t bits) { return count; } -uint64_t write_LEB_(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, +uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, bool sign) { if (size_leb(value) > size) { return 0; @@ -110,11 +110,11 @@ uint64_t write_LEB_(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, } uint64_t write_LEB_32(uint32_t value, uint8_t *buff, uint32_t size) { - return write_LEB_(value, buff, size, 32, false); + return write_LEB_s(value, buff, size, 32, false); } uint64_t write_LEB_32_signed(uint32_t value, uint8_t *buff, uint32_t size) { - return write_LEB_(value, buff, size, 32, true); + return write_LEB_s(value, buff, size, 32, true); } uint64_t read_LEB_(uint8_t **pos, uint32_t maxbits, bool sign) { @@ -369,7 +369,17 @@ uint32_t read_L32(uint8_t **bytes) { return n; } // TODO replace with read_LEB_32? If keep Big endian use memcpy? -void chars_as_hexa(unsigned char *dest, unsigned char *source, +int slebf(char *dest, uint8_t *source, const int size, const char *end) { + char *cursor = dest; + for (int i = 0; i < size; i++) { + sprintf(cursor, "%02" PRIx8, source[i]); + cursor += 2; + } + sprintf(cursor, "%s", end); + return size; +} + +void chars_as_hexa(char *dest, unsigned char *source, uint32_t len_source) { for (uint32_t i = 0; i < len_source; i++) { unsigned c = source[i] >> 4; diff --git a/src/Utils/util.h b/src/Utils/util.h index 2d303044..401d98d6 100644 --- a/src/Utils/util.h +++ b/src/Utils/util.h @@ -21,6 +21,10 @@ uint64_t size_leb(uint64_t val); uint8_t *write_LEB(uint32_t value); +int slebf(char *dest, uint8_t *source, const int size, const char *end = ""); + +uint32_t write_LEB_(uint8_t *dest, uint64_t val); + /** * Write a Little endian base value. * see: https://en.wikipedia.org/wiki/LEB128 @@ -32,7 +36,7 @@ uint8_t *write_LEB(uint32_t value); * @param sign Whether the value should be sign-extended. * @return The number of bytes written. */ -uint64_t write_LEB_(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, +uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, bool sign); uint64_t write_LEB_32(uint32_t value, uint8_t *buff, uint32_t size); @@ -124,8 +128,7 @@ uint16_t read_B16(uint8_t **bytes); uint8_t read_B8(uint8_t **bytes); int read_B32_signed(uint8_t **bytes); uint32_t read_L32(uint8_t **bytes); -void chars_as_hexa(unsigned char *dest, unsigned char *source, - uint32_t len_source); +void chars_as_hexa(char *dest, unsigned char *source, uint32_t len_source); unsigned short int sizeof_valuetype(uint32_t); diff --git a/src/WARDuino.h b/src/WARDuino.h index 540ec693..c5570a91 100644 --- a/src/WARDuino.h +++ b/src/WARDuino.h @@ -75,7 +75,7 @@ typedef struct PrimitiveEntry { Primitive f; void (*f_reverse)(Module *m, std::vector); void (*f_serialize_state)(std::vector &); - SerializeData &(*f_transfer)(Module *m); + char *(*f_transfer)(Module *m); Type *t; } PrimitiveEntry; From 729fd29015c4ae5deeb0aa593486e4a691a79d3e Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sun, 2 Mar 2025 21:26:23 +0100 Subject: [PATCH 27/31] Split in forward and backward --- src/Oop/proxy.cpp | 8 ++++++++ src/Oop/proxy_supervisor.cpp | 11 ++++++----- src/Oop/stateful.cpp | 1 + src/Primitives/primitives.h | 4 +++- src/WARDuino.h | 3 ++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Oop/proxy.cpp b/src/Oop/proxy.cpp index df3b4005..59bfefb3 100644 --- a/src/Oop/proxy.cpp +++ b/src/Oop/proxy.cpp @@ -7,6 +7,7 @@ #include #include "../Interpreter/instructions.h" +#include "../Primitives/primitives.h" #include "../Utils/macros.h" #include "../Utils/util.h" @@ -51,6 +52,13 @@ RFC *Proxy::topRFC() { return this->calls->top(); } void Proxy::returnResult(Module *m) { RFC *rfc = this->calls->top(); + // first transfer state + auto transfer = get_forward(m, rfc->fidx); + WARDuino::instance()->debugger->channel->write(transfer.c_str()); + printf("send transfer\n"); + + // return result + // remove call from lifo queue this->calls->pop(); diff --git a/src/Oop/proxy_supervisor.cpp b/src/Oop/proxy_supervisor.cpp index 86e6ef28..36692e9a 100644 --- a/src/Oop/proxy_supervisor.cpp +++ b/src/Oop/proxy_supervisor.cpp @@ -199,8 +199,9 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) { message->size = hexa_size + 1; message->raw = hexa; - auto transfer = get_transfer(callee->m, callee->fidx); + auto transfer = get_backward(callee->m, callee->fidx); this->channel->write(transfer.c_str()); + return message; } @@ -262,10 +263,10 @@ bool ProxySupervisor::call(RFC *callee) { } // Fetch new callback mapping // convert message to hex TODO: move to proxyserver - char cmdBuffer[10] = ""; - int cmdBufferLen = 0; - sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping, &cmdBufferLen); - this->send(cmdBuffer, cmdBufferLen); +// char cmdBuffer[10] = ""; +// int cmdBufferLen = 0; +// sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping, &cmdBufferLen); +// this->send(cmdBuffer, cmdBufferLen); this->deserializeRFCResult(callee); printf("end of supervisor::call(rfc)\n"); return true; diff --git a/src/Oop/stateful.cpp b/src/Oop/stateful.cpp index d4b8134b..724f476e 100644 --- a/src/Oop/stateful.cpp +++ b/src/Oop/stateful.cpp @@ -9,5 +9,6 @@ char *sync_memory(Module *m, uint32_t start, uint32_t end) { sprintf(buffer, "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, memoryState, start, end); slebf(buffer + 6, m->bytes + start, len, "\n"); + printf("syncing memory\n"); return buffer; } \ No newline at end of file diff --git a/src/Primitives/primitives.h b/src/Primitives/primitives.h index d772d1fb..3d934fe9 100644 --- a/src/Primitives/primitives.h +++ b/src/Primitives/primitives.h @@ -81,6 +81,8 @@ void invoke_primitive(Module *m, const std::string &function_name, Ts... args) { primitive(m); } -std::string get_transfer(Module *m, uint32_t index); +std::string get_forward(Module *m, uint32_t index); + +std::string get_backward(Module *m, uint32_t index); #endif diff --git a/src/WARDuino.h b/src/WARDuino.h index c5570a91..39bf0d99 100644 --- a/src/WARDuino.h +++ b/src/WARDuino.h @@ -75,7 +75,8 @@ typedef struct PrimitiveEntry { Primitive f; void (*f_reverse)(Module *m, std::vector); void (*f_serialize_state)(std::vector &); - char *(*f_transfer)(Module *m); + char *(*f_forward)(Module *m); + char *(*f_backward)(Module *m); Type *t; } PrimitiveEntry; From 225e6e7538aae5f9b79d8d16654b76d32cef4958 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sun, 2 Mar 2025 23:32:56 +0100 Subject: [PATCH 28/31] fixup! Split in forward and backward --- src/Oop/proxy.cpp | 6 ++-- src/Primitives/emulated.cpp | 58 ++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/Oop/proxy.cpp b/src/Oop/proxy.cpp index 59bfefb3..b3551137 100644 --- a/src/Oop/proxy.cpp +++ b/src/Oop/proxy.cpp @@ -64,20 +64,20 @@ void Proxy::returnResult(Module *m) { if (!rfc->success) { // TODO exception msg - WARDuino::instance()->debugger->channel->write(R"({"success":false})"); + WARDuino::instance()->debugger->channel->write("{\"success\":false}\n"); return; } if (rfc->type->result_count == 0) { // reading result from stack - WARDuino::instance()->debugger->channel->write(R"({"success":true})"); + WARDuino::instance()->debugger->channel->write("{\"success\":true}\n"); return; } // send the result to the client rfc->result = &m->stack[m->sp]; char *val = printValue(rfc->result); - WARDuino::instance()->debugger->channel->write(R"({"success":true,%s})", + WARDuino::instance()->debugger->channel->write("{\"success\":true,%s}\n", val); free(val); } diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index c1ea8619..1af515bf 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -52,7 +52,8 @@ double sensor_emu = 0; p->f = &(prim_name); \ p->f_reverse = nullptr; \ p->f_serialize_state = nullptr; \ - p->f_transfer = nullptr; \ + p->f_backward = nullptr; \ + p->f_forward = nullptr; \ } else { \ FATAL("prim_index out of bounds"); \ } \ @@ -65,10 +66,16 @@ double sensor_emu = 0; p->f_serialize_state = &(prim_name##_serialize); \ } -#define install_primitive_transfer(prim_name) \ +#define install_primitive_backward(prim_name) \ { \ PrimitiveEntry *p = &primitives[prim_index - 1]; \ - p->f_transfer = &(prim_name##_transfer); \ + p->f_backward = &(prim_name##_backward); \ + } + +#define install_primitive_forward(prim_name) \ + { \ + PrimitiveEntry *p = &primitives[prim_index - 1]; \ + p->f_forward = &(prim_name##_forward); \ } #define def_prim(function_name, type) \ @@ -83,8 +90,11 @@ double sensor_emu = 0; void function_name##_serialize( \ std::vector &external_state) -#define def_prim_transfer(function_name) \ - char *function_name##_transfer([[maybe_unused]] Module *m) +#define def_prim_backward(function_name) \ + char *function_name##_backward([[maybe_unused]] Module *m) + +#define def_prim_forward(function_name) \ + char *function_name##_forward([[maybe_unused]] Module *m) // TODO: use fp #define pop_args(n) m->sp -= n @@ -258,6 +268,7 @@ def_prim(abort, NoneToNoneU32) { } def_prim(dummy, twoToOneU32) { + printf("dummy \n"); uint32_t a = arg1.uint32; uint32_t b = arg0.uint32; StackValue val = {I32, {42}}; @@ -269,7 +280,8 @@ def_prim(dummy, twoToOneU32) { return true; } -def_prim_transfer(dummy) { +def_prim_forward(dummy) { + printf("giving transfer \n"); uint32_t start = arg1.uint32; uint32_t end = arg0.uint32; return sync_memory(m, start, end); @@ -546,7 +558,7 @@ void install_primitives() { dbg_info("INSTALLING PRIMITIVES\n"); dbg_info("INSTALLING FAKE ARDUINO\n"); install_primitive(dummy); - install_primitive_transfer(dummy); + install_primitive_forward(dummy); install_primitive(abort); install_primitive(millis); @@ -666,7 +678,7 @@ std::vector get_io_state(Module *) { return ioState; } -std::string get_transfer(Module *m, uint32_t index) { +std::string get_backward(Module *m, uint32_t index) { std::stringstream transfer; auto *buffer = new char[6]; sprintf(buffer, "%02" PRIx8 "00%02" PRIx8, interruptTransfer, 1); @@ -676,9 +688,9 @@ std::string get_transfer(Module *m, uint32_t index) { if (index < ALL_PRIMITIVES) { auto &primitive = primitives[index]; printf("transfering for %s", primitive.name); - if (primitive.f_transfer) { + if (primitive.f_backward) { m->sp += primitive.t->param_count; - auto data = primitive.f_transfer(m); + auto data = primitive.f_backward(m); transfer << std::string(data); free(data); m->sp -= primitive.t->param_count; @@ -687,4 +699,30 @@ std::string get_transfer(Module *m, uint32_t index) { return transfer.str(); } +// todo eliminate duplicate code +// fix length at start of 52 message +// send nothing if length is 0 + +std::string get_forward(Module *m, uint32_t index) { + std::stringstream transfer; + auto *buffer = new char[6]; + sprintf(buffer, "%02" PRIx8 "00%02" PRIx8, interruptTransfer, 1); + transfer << std::string(buffer); + delete[] buffer; + + if (index < ALL_PRIMITIVES) { + auto &primitive = primitives[index]; + printf("transfering for %s", primitive.name); + if (primitive.f_forward) { + m->sp++; + auto data = primitive.f_forward(m); + transfer << std::string(data); + free(data); + m->sp--; + } + } + printf("transfer built\n"); + return transfer.str(); +} + #endif // ARDUINO From fe012826aa454f0d8be374293b39a02b9b86336e Mon Sep 17 00:00:00 2001 From: tolauwae Date: Mon, 3 Mar 2025 07:23:16 +0100 Subject: [PATCH 29/31] Fix do forward in proxy --- src/Debug/debugger.cpp | 4 +++- src/Oop/proxy.cpp | 13 ++++++------- src/Oop/stateful.cpp | 4 ++-- src/Primitives/emulated.cpp | 37 +++++++++++++++++++++---------------- src/Primitives/primitives.h | 2 +- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/Debug/debugger.cpp b/src/Debug/debugger.cpp index 324eea30..79f5bd65 100644 --- a/src/Debug/debugger.cpp +++ b/src/Debug/debugger.cpp @@ -1452,7 +1452,9 @@ void Debugger::proxify() { delete WARDuino::instance()->interpreter; WARDuino::instance()->interpreter = new Proxied(); this->proxy = new Proxy(); // TODO delete - this->channel->write("PROXIED!\n"); + if (this->channel) { + this->channel->write("PROXIED!\n"); + } } void Debugger::handleProxyCall(Module *m, RunningState *, diff --git a/src/Oop/proxy.cpp b/src/Oop/proxy.cpp index b3551137..81434569 100644 --- a/src/Oop/proxy.cpp +++ b/src/Oop/proxy.cpp @@ -31,8 +31,12 @@ void Proxy::pushRFC(Module *m, RFC *rfc) { this->setupCalleeArgs(m, rfc); if (rfc->fidx < m->import_count) { - // execute primitives directly - ((Primitive)m->functions[rfc->fidx].func_ptr)(m); + // try with forward state transfer + if (!do_forward(m, rfc->fidx)) { + // on fail: execute primitives directly + ((Primitive)m->functions[rfc->fidx].func_ptr)(m); + } + // send result directly m->warduino->program_state = PROXYhalt; m->warduino->debugger->sendProxyCallResult(m); @@ -52,11 +56,6 @@ RFC *Proxy::topRFC() { return this->calls->top(); } void Proxy::returnResult(Module *m) { RFC *rfc = this->calls->top(); - // first transfer state - auto transfer = get_forward(m, rfc->fidx); - WARDuino::instance()->debugger->channel->write(transfer.c_str()); - printf("send transfer\n"); - // return result // remove call from lifo queue diff --git a/src/Oop/stateful.cpp b/src/Oop/stateful.cpp index 724f476e..8cc2dfab 100644 --- a/src/Oop/stateful.cpp +++ b/src/Oop/stateful.cpp @@ -7,8 +7,8 @@ char *sync_memory(Module *m, uint32_t start, uint32_t end) { auto *buffer = (char *)calloc(sizeof(char), (2 * len) + 8); sprintf(buffer, "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, memoryState, start, end); - slebf(buffer + 6, m->bytes + start, len, "\n"); + auto target = m->memory.bytes + start; + slebf(buffer + 6, target, len, "\n"); - printf("syncing memory\n"); return buffer; } \ No newline at end of file diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index 1af515bf..2fbaf1ff 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -281,10 +281,20 @@ def_prim(dummy, twoToOneU32) { } def_prim_forward(dummy) { - printf("giving transfer \n"); - uint32_t start = arg1.uint32; - uint32_t end = arg0.uint32; - return sync_memory(m, start, end); + printf("dummy \n"); + uint32_t a = arg1.uint32; + uint32_t b = arg0.uint32; + StackValue val = {I32, {42}}; + for (int i = 0; a + i < b; i += 4) { + m->warduino->interpreter->store(m, I32, a + i, val); + } + + printf("transfering state changes\n"); + auto transfer = sync_memory(m, a, b); + + pop_args(2); + pushUInt32(b - a); + return transfer; } def_prim(millis, NoneToOneU64) { @@ -703,26 +713,21 @@ std::string get_backward(Module *m, uint32_t index) { // fix length at start of 52 message // send nothing if length is 0 -std::string get_forward(Module *m, uint32_t index) { - std::stringstream transfer; - auto *buffer = new char[6]; - sprintf(buffer, "%02" PRIx8 "00%02" PRIx8, interruptTransfer, 1); - transfer << std::string(buffer); - delete[] buffer; - +bool do_forward(Module *m, uint32_t index) { if (index < ALL_PRIMITIVES) { auto &primitive = primitives[index]; printf("transfering for %s", primitive.name); if (primitive.f_forward) { - m->sp++; auto data = primitive.f_forward(m); - transfer << std::string(data); + printf("transfer built\n"); + WARDuino::instance()->debugger->channel->write("%02" PRIx8 "00%02" PRIx8 "%s", interruptTransfer, 1, data); free(data); - m->sp--; } + } else { + return false; } - printf("transfer built\n"); - return transfer.str(); + + return true; } #endif // ARDUINO diff --git a/src/Primitives/primitives.h b/src/Primitives/primitives.h index 3d934fe9..2cf47179 100644 --- a/src/Primitives/primitives.h +++ b/src/Primitives/primitives.h @@ -81,7 +81,7 @@ void invoke_primitive(Module *m, const std::string &function_name, Ts... args) { primitive(m); } -std::string get_forward(Module *m, uint32_t index); +bool do_forward(Module *m, uint32_t index); std::string get_backward(Module *m, uint32_t index); From 78345837d6d0aaa8af60559136d6bb8c6492444e Mon Sep 17 00:00:00 2001 From: tolauwae Date: Mon, 3 Mar 2025 08:04:57 +0100 Subject: [PATCH 30/31] Fix get backward --- src/Primitives/emulated.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index 2fbaf1ff..83ed2fc7 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -692,7 +692,6 @@ std::string get_backward(Module *m, uint32_t index) { std::stringstream transfer; auto *buffer = new char[6]; sprintf(buffer, "%02" PRIx8 "00%02" PRIx8, interruptTransfer, 1); - transfer << std::string(buffer); delete[] buffer; if (index < ALL_PRIMITIVES) { @@ -701,6 +700,7 @@ std::string get_backward(Module *m, uint32_t index) { if (primitive.f_backward) { m->sp += primitive.t->param_count; auto data = primitive.f_backward(m); + transfer << std::string(buffer); transfer << std::string(data); free(data); m->sp -= primitive.t->param_count; From 89e7aa0768919d39285bb62cf169f20762065b3c Mon Sep 17 00:00:00 2001 From: tolauwae Date: Mon, 3 Mar 2025 08:11:51 +0100 Subject: [PATCH 31/31] Clang format --- src/Interpreter/proxied.cpp | 8 +++--- src/Oop/RFC.cpp | 13 +++++---- src/Oop/RFC.h | 8 +++--- src/Oop/proxy_supervisor.cpp | 12 ++++----- src/Oop/stateful.cpp | 3 ++- src/Primitives/emulated.cpp | 51 ++++++++++++++++++------------------ src/Utils/util.cpp | 9 +++---- src/Utils/util.h | 4 +-- 8 files changed, 56 insertions(+), 52 deletions(-) diff --git a/src/Interpreter/proxied.cpp b/src/Interpreter/proxied.cpp index 34bd3cdb..189bc889 100644 --- a/src/Interpreter/proxied.cpp +++ b/src/Interpreter/proxied.cpp @@ -15,9 +15,9 @@ void send_leb(Channel *channel, uint32_t value, const char *end = "") { bool Proxied::store(Module *m, [[maybe_unused]] uint8_t type, uint32_t addr, StackValue &sval) { Interpreter::store(m, type, addr, sval); -// m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); -// send_leb(m->warduino->debugger->channel, addr); -// send_leb(m->warduino->debugger->channel, 0); -// send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n"); + // m->warduino->debugger->channel->write("%02" PRIx8, interruptStore); + // send_leb(m->warduino->debugger->channel, addr); + // send_leb(m->warduino->debugger->channel, 0); + // send_leb(m->warduino->debugger->channel, sval.value.uint32, "\n"); return true; } diff --git a/src/Oop/RFC.cpp b/src/Oop/RFC.cpp index 9c13f07a..ac93e9c1 100644 --- a/src/Oop/RFC.cpp +++ b/src/Oop/RFC.cpp @@ -10,8 +10,9 @@ SerializeData *merge(SerializeData a, SerializeData b, bool divide) { auto *data = new SerializeData; auto padding = divide ? 2 : 1; data->size = a.size + b.size + padding; -// size_t lengte = a.size + b.size + padding; - data->raw = new char[data->size]; //(unsigned char *)calloc(data->size, sizeof(char)); + // size_t lengte = a.size + b.size + padding; + data->raw = new char[data->size]; //(unsigned char *)calloc(data->size, + //sizeof(char)); if (divide) { *(data->raw + a.size) = '\n'; *(data->raw + a.size + b.size + 1) = '\n'; @@ -24,12 +25,14 @@ SerializeData *merge(SerializeData a, SerializeData b, bool divide) { return data; } -struct SerializeData* mergeSerializeData(struct SerializeData data1, struct SerializeData data2, bool divide) { +struct SerializeData *mergeSerializeData(struct SerializeData data1, + struct SerializeData data2, + bool divide) { // Allocate memory for the result struct struct SerializeData *result = static_cast(malloc(sizeof(struct SerializeData))); if (result == NULL) { - return NULL; // Memory allocation failure + return NULL; // Memory allocation failure } uint32_t extra = divide ? 1 : 0; @@ -37,7 +40,7 @@ struct SerializeData* mergeSerializeData(struct SerializeData data1, struct Seri result->raw = static_cast(malloc(result->size)); if (result->raw == NULL) { free(result); - return NULL; // Memory allocation failure + return NULL; // Memory allocation failure } // Copy the first data block diff --git a/src/Oop/RFC.h b/src/Oop/RFC.h index 2b217466..39d40013 100644 --- a/src/Oop/RFC.h +++ b/src/Oop/RFC.h @@ -11,11 +11,13 @@ struct SerializeData { uint32_t size; }; -SerializeData *merge(SerializeData a, SerializeData b, bool divide=true); +SerializeData *merge(SerializeData a, SerializeData b, bool divide = true); -struct SerializeData *mergeSerializeData(struct SerializeData data1, struct SerializeData data2, bool divide=true); +struct SerializeData *mergeSerializeData(struct SerializeData data1, + struct SerializeData data2, + bool divide = true); - class RFC { +class RFC { public: Module *m; const uint32_t fidx; diff --git a/src/Oop/proxy_supervisor.cpp b/src/Oop/proxy_supervisor.cpp index 36692e9a..e11b05e9 100644 --- a/src/Oop/proxy_supervisor.cpp +++ b/src/Oop/proxy_supervisor.cpp @@ -188,8 +188,7 @@ struct SerializeData *ProxySupervisor::serializeRFC(RFC *callee) { // array as hexa const uint32_t hexa_size = serializationSize * 2; - auto *hexa = - new char[hexa_size + 2]; //+2 for '\n' and '0' termination + auto *hexa = new char[hexa_size + 2]; //+2 for '\n' and '0' termination chars_as_hexa(hexa, buffer, serializationSize); hexa[hexa_size] = '\n'; hexa[hexa_size + 1] = '\0'; // TODO remove zero termination and +2 above @@ -251,7 +250,6 @@ bool ProxySupervisor::call(RFC *callee) { printf("serializing RFC\n"); struct SerializeData *rfc_request = this->serializeRFC(callee); - printf("sending to proxy: %s ...", static_cast((void *)rfc_request->raw)); bool sent = this->send((void *)rfc_request->raw, rfc_request->size); if (!sent) { callee->success = false; @@ -263,10 +261,10 @@ bool ProxySupervisor::call(RFC *callee) { } // Fetch new callback mapping // convert message to hex TODO: move to proxyserver -// char cmdBuffer[10] = ""; -// int cmdBufferLen = 0; -// sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping, &cmdBufferLen); -// this->send(cmdBuffer, cmdBufferLen); + // char cmdBuffer[10] = ""; + // int cmdBufferLen = 0; + // sprintf(cmdBuffer, "%x\n%n", interruptDUMPCallbackmapping, + // &cmdBufferLen); this->send(cmdBuffer, cmdBufferLen); this->deserializeRFCResult(callee); printf("end of supervisor::call(rfc)\n"); return true; diff --git a/src/Oop/stateful.cpp b/src/Oop/stateful.cpp index 8cc2dfab..e8e9814f 100644 --- a/src/Oop/stateful.cpp +++ b/src/Oop/stateful.cpp @@ -6,7 +6,8 @@ char *sync_memory(Module *m, uint32_t start, uint32_t end) { uint8_t len = end - start; auto *buffer = (char *)calloc(sizeof(char), (2 * len) + 8); - sprintf(buffer, "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, memoryState, start, end); + sprintf(buffer, "%02" PRIx8 "%02" PRIx8 "%02" PRIx8, memoryState, start, + end); auto target = m->memory.bytes + start; slebf(buffer + 6, target, len, "\n"); diff --git a/src/Primitives/emulated.cpp b/src/Primitives/emulated.cpp index 83ed2fc7..911a7ea9 100644 --- a/src/Primitives/emulated.cpp +++ b/src/Primitives/emulated.cpp @@ -40,23 +40,23 @@ double sensor_emu = 0; /* Private macros to install a primitive */ -#define install_primitive(prim_name) \ - { \ +#define install_primitive(prim_name) \ + { \ dbg_info("installing primitive number: %d of %d with name: %s\n", \ - prim_index + 1, ALL_PRIMITIVES, #prim_name); \ - if (prim_index < ALL_PRIMITIVES) { \ - PrimitiveEntry *p = &primitives[prim_index++]; \ - p->name = #prim_name; \ - p->t = &(prim_name##_type); \ - p->index = prim_index - 1; \ - p->f = &(prim_name); \ - p->f_reverse = nullptr; \ - p->f_serialize_state = nullptr; \ - p->f_backward = nullptr; \ - p->f_forward = nullptr; \ - } else { \ - FATAL("prim_index out of bounds"); \ - } \ + prim_index + 1, ALL_PRIMITIVES, #prim_name); \ + if (prim_index < ALL_PRIMITIVES) { \ + PrimitiveEntry *p = &primitives[prim_index++]; \ + p->name = #prim_name; \ + p->t = &(prim_name##_type); \ + p->index = prim_index - 1; \ + p->f = &(prim_name); \ + p->f_reverse = nullptr; \ + p->f_serialize_state = nullptr; \ + p->f_backward = nullptr; \ + p->f_forward = nullptr; \ + } else { \ + FATAL("prim_index out of bounds"); \ + } \ } #define install_primitive_reverse(prim_name) \ @@ -66,16 +66,16 @@ double sensor_emu = 0; p->f_serialize_state = &(prim_name##_serialize); \ } -#define install_primitive_backward(prim_name) \ - { \ - PrimitiveEntry *p = &primitives[prim_index - 1]; \ - p->f_backward = &(prim_name##_backward); \ +#define install_primitive_backward(prim_name) \ + { \ + PrimitiveEntry *p = &primitives[prim_index - 1]; \ + p->f_backward = &(prim_name##_backward); \ } -#define install_primitive_forward(prim_name) \ - { \ - PrimitiveEntry *p = &primitives[prim_index - 1]; \ - p->f_forward = &(prim_name##_forward); \ +#define install_primitive_forward(prim_name) \ + { \ + PrimitiveEntry *p = &primitives[prim_index - 1]; \ + p->f_forward = &(prim_name##_forward); \ } #define def_prim(function_name, type) \ @@ -720,7 +720,8 @@ bool do_forward(Module *m, uint32_t index) { if (primitive.f_forward) { auto data = primitive.f_forward(m); printf("transfer built\n"); - WARDuino::instance()->debugger->channel->write("%02" PRIx8 "00%02" PRIx8 "%s", interruptTransfer, 1, data); + WARDuino::instance()->debugger->channel->write( + "%02" PRIx8 "00%02" PRIx8 "%s", interruptTransfer, 1, data); free(data); } } else { diff --git a/src/Utils/util.cpp b/src/Utils/util.cpp index e6a51913..e6ab9e63 100644 --- a/src/Utils/util.cpp +++ b/src/Utils/util.cpp @@ -96,8 +96,8 @@ uint32_t write_LEB_signed(uint8_t *dest, uint64_t val, uint64_t bits) { return count; } -uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, - bool sign) { +uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, + uint32_t bits, bool sign) { if (size_leb(value) > size) { return 0; } @@ -369,7 +369,7 @@ uint32_t read_L32(uint8_t **bytes) { return n; } // TODO replace with read_LEB_32? If keep Big endian use memcpy? -int slebf(char *dest, uint8_t *source, const int size, const char *end) { +int slebf(char *dest, uint8_t *source, const int size, const char *end) { char *cursor = dest; for (int i = 0; i < size; i++) { sprintf(cursor, "%02" PRIx8, source[i]); @@ -379,8 +379,7 @@ int slebf(char *dest, uint8_t *source, const int size, const char *end) { return size; } -void chars_as_hexa(char *dest, unsigned char *source, - uint32_t len_source) { +void chars_as_hexa(char *dest, unsigned char *source, uint32_t len_source) { for (uint32_t i = 0; i < len_source; i++) { unsigned c = source[i] >> 4; unsigned c2 = source[i] & 0xF; diff --git a/src/Utils/util.h b/src/Utils/util.h index 401d98d6..11059ebb 100644 --- a/src/Utils/util.h +++ b/src/Utils/util.h @@ -36,8 +36,8 @@ uint32_t write_LEB_(uint8_t *dest, uint64_t val); * @param sign Whether the value should be sign-extended. * @return The number of bytes written. */ -uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, uint32_t bits, - bool sign); +uint64_t write_LEB_s(uint64_t value, uint8_t *buff, uint32_t size, + uint32_t bits, bool sign); uint64_t write_LEB_32(uint32_t value, uint8_t *buff, uint32_t size);