diff --git a/examples/examplevm/examplevm.c b/examples/examplevm/examplevm.c index 1ed8dd9..b1b4d57 100644 --- a/examples/examplevm/examplevm.c +++ b/examples/examplevm/examplevm.c @@ -9,6 +9,8 @@ struct examplevm { struct evmc_instance instance; int verbose; + evmc_trace_callback trace_callback; + struct evmc_tracer_context* tracer_context; }; static void destroy(struct evmc_instance* evm) @@ -113,6 +115,15 @@ static struct evmc_result execute(struct evmc_instance* instance, return ret; } +static void set_tracer(struct evmc_instance* instance, + evmc_trace_callback callback, + struct evmc_tracer_context* context) +{ + struct examplevm* vm = (struct examplevm*)instance; + vm->trace_callback = callback; + vm->tracer_context = context; +} + struct evmc_instance* evmc_create_examplevm() { struct evmc_instance init = { @@ -122,6 +133,7 @@ struct evmc_instance* evmc_create_examplevm() .destroy = destroy, .execute = execute, .set_option = set_option, + .set_tracer = set_tracer, }; struct examplevm* vm = calloc(1, sizeof(struct examplevm)); struct evmc_instance* interface = &vm->instance; diff --git a/test/vmtester/tests.cpp b/test/vmtester/tests.cpp index 744c97b..cf01963 100644 --- a/test/vmtester/tests.cpp +++ b/test/vmtester/tests.cpp @@ -59,4 +59,13 @@ TEST_F(evmc_vm_test, version) { ASSERT_NE(vm->version, nullptr); EXPECT_GT(std::strlen(vm->version), 0) << "VM name cannot be empty"; -} \ No newline at end of file +} + +TEST_F(evmc_vm_test, set_tracer) +{ + static constexpr auto tracer_callback = [](evmc_tracer_context*, int, size_t, evmc_status_code, + int64_t, size_t, const evmc_uint256be*, size_t, + size_t, size_t, const uint8_t*) noexcept {}; + ASSERT_NE(vm->set_tracer, nullptr); + vm->set_tracer(vm, tracer_callback, nullptr); +}