Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
proper and verbose wasm module error printing (#175)
Browse files Browse the repository at this point in the history
* proper and verbose wasm module error printing

* more verbose proxywasm

* pw fixes
  • Loading branch information
bonifaido committed Mar 1, 2024
1 parent 7c28a23 commit 42a982e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
4 changes: 2 additions & 2 deletions device_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ wasm_vm_result load_module(const char *name, const char *code, unsigned length,
result = init_opa_for(vm, module);
if (result.err)
{
pr_crit("could not init opa module # err[%s]", result.err);
pr_crit("could not init opa module # err[%s: %s]", result.err, wasm_vm_last_error(module));
wasm_vm_unlock(vm);
return result;
}
Expand All @@ -180,7 +180,7 @@ wasm_vm_result load_module(const char *name, const char *code, unsigned length,
result = init_proxywasm_for(vm, module);
if (result.err)
{
pr_crit("could not init proxywasm module # err[%s]", result.err);
pr_crit("could not init proxywasm module # err[%s: %s]", result.err, wasm_vm_last_error(module));
wasm_vm_unlock(vm);
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion opa.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ opa_socket_context this_cpu_opa_socket_eval(const char *input)
result = opa_eval(opa, inputAddr, inputLen, opa->dataValueAddr, heapAddr);
if (result.err)
{
pr_crit("opa eval error # name[%s] err[%s]", opa->eval->module->name, result.err);
pr_crit("opa eval error # name[%s] err[%s: %s]", opa->eval->module->name, result.err, wasm_vm_last_error(opa->eval->module));
goto cleanup;
}

Expand Down
41 changes: 22 additions & 19 deletions proxywasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@
#define hash_for_each_possible(name, obj, member, key, bits) \
hlist_for_each_entry(obj, &name[hash_min(key, bits)], member)

#define FOR_ALL_FILTERS(CALL) \
wasm_vm_result result; \
proxywasm_filter *f; \
for (f = p->filters; f != NULL; f = f->next) \
{ \
pr_info("camblet: calling %s " #CALL, f->name); \
result = CALL; \
if (result.err != NULL) \
{ \
pr_err("camblet: calling %s " #CALL " error: %s\n", f->name, result.err); \
return result; \
} \
pr_info("camblet: result of calling %s " #CALL ": %d", f->name, result.data->i32); \
} \
#define FOR_ALL_FILTERS(CALL) \
wasm_vm_result result; \
proxywasm_filter *f; \
for (f = p->filters; f != NULL; f = f->next) \
{ \
pr_info("camblet: calling %s " #CALL, f->name); \
result = CALL; \
if (result.err != NULL) \
{ \
pr_err("camblet: calling %s " #CALL " # err[%s: %s]", f->name, \
result.err, \
wasm_vm_last_error(f->proxy_on_vm_start->module)); \
return result; \
} \
pr_info("camblet: result of calling %s " #CALL ": %d", f->name, \
result.data->i32); \
} \
return result;

typedef struct property_h_node
Expand Down Expand Up @@ -464,15 +467,15 @@ wasm_vm_result init_proxywasm_for(wasm_vm *vm, wasm_vm_module *module)
result = wasm_vm_call_direct(vm, filter->proxy_on_context_create, proxywasm->root_context->id, 0);
if (result.err)
{
pr_crit("proxy_on_context_create for module %s failed: %s -> %s", module->name, result.err, wasm_vm_last_error(module));
pr_crit("proxy_on_context_create for module %s failed # err[%s: %s]", module->name, result.err, wasm_vm_last_error(module));
kfree(proxywasm);
return result;
}

result = wasm_vm_call_direct(vm, filter->proxy_on_vm_start, proxywasm->root_context->id, 0);
if (result.err)
{
pr_crit("proxy_on_vm_start for module %s failed: %s", module->name, result.err);
pr_crit("proxy_on_vm_start for module %s failed # err[%s: %s]", module->name, result.err, wasm_vm_last_error(module));
kfree(proxywasm);
return result;
}
Expand All @@ -482,7 +485,7 @@ wasm_vm_result init_proxywasm_for(wasm_vm *vm, wasm_vm_module *module)
result = wasm_vm_call_direct(vm, filter->proxy_on_configure, proxywasm->root_context->id, plugin_configuration_size);
if (result.err)
{
pr_crit("proxy_on_configure for module %s failed: %s", module->name, result.err);
pr_crit("proxy_on_configure for module %s failed # err[%s: %s]", module->name, result.err, wasm_vm_last_error(module));
kfree(proxywasm);
return result;
}
Expand Down Expand Up @@ -520,13 +523,13 @@ wasm_vm_result proxywasm_destroy_context(proxywasm *p)
result = wasm_vm_call_direct(p->vm, f->proxy_on_done, p->current_context->id);
if (result.err != NULL)
{
pr_err("camblet: calling %s.proxy_on_done errored %s", f->name, result.err);
pr_err("camblet: calling %s.proxy_on_done errored # err[%s: %s]", f->name, result.err, wasm_vm_last_error(f->proxy_on_done->module));
}

result = wasm_vm_call_direct(p->vm, f->proxy_on_delete, p->current_context->id);
if (result.err != NULL)
{
pr_err("camblet: calling %s.proxy_on_delete errored %s", f->name, result.err);
pr_err("camblet: calling %s.proxy_on_delete errored # err[%s: %s]", f->name, result.err, wasm_vm_last_error(f->proxy_on_delete->module));
}
}

Expand Down

0 comments on commit 42a982e

Please sign in to comment.