summaryrefslogtreecommitdiff
path: root/src/tools/fuzzing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/fuzzing.h')
-rw-r--r--src/tools/fuzzing.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index f7dd20e76..0a7128e3e 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -197,6 +197,9 @@ public:
}
setupTable();
setupGlobals();
+ if (wasm.features.hasExceptionHandling()) {
+ setupEvents();
+ }
addImportLoggingSupport();
// keep adding functions until we run out of input
while (!finishedInput) {
@@ -397,6 +400,28 @@ private:
}
}
+ void setupEvents() {
+ Index num = upTo(3);
+ for (size_t i = 0; i < num; i++) {
+ // Events should have void return type and at least one param type
+ Type type = pick(i32, i64, f32, f64);
+ std::string sig = std::string("v") + getSig(type);
+ std::vector<Type> params;
+ params.push_back(type);
+ Index numValues = upToSquared(MAX_PARAMS - 1);
+ for (Index i = 0; i < numValues; i++) {
+ type = pick(i32, i64, f32, f64);
+ sig += getSig(type);
+ params.push_back(type);
+ }
+ auto* event = builder.makeEvent(std::string("event$") + std::to_string(i),
+ WASM_EVENT_ATTRIBUTE_EXCEPTION,
+ ensureFunctionType(sig, &wasm)->name,
+ std::move(params));
+ wasm.addEvent(event);
+ }
+ }
+
void finalizeTable() {
wasm.table.initial = wasm.table.segments[0].data.size();
wasm.table.max =