plugin: Add InitPreExecution()

Currently, plugins do not have a way to further inspect or even mutate
script functions after ZAM optimization ran. One use-case here is
zeek-perf-support [1]. This plugin wraps Stmt instances of functions,
events and hooks hooks with a small assembly stub to support JIT map
files [2] and for integration with perf tools.

This change introduces a new InitPreExecution() hook that runs after
ZAM optimization completed, just before the zeek_init() event is enqueued.

Additionally, remove the existing CPP_activation_hook. It doesn't seem
to be used. If it becomes necessary in the future, the new
InitPreExecution() hook can be leveraged instead.

[1] https://github.com/zeek/zeek-perf-support
[2] https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
This commit is contained in:
Arne Welzel 2024-11-18 13:33:29 +01:00
parent 2125a1f558
commit 993cdd03e0
7 changed files with 27 additions and 7 deletions

View file

@ -484,6 +484,14 @@ void Manager::InitPostScript() {
(*i)->InitPostScript();
}
void Manager::InitPreExecution() {
assert(init);
for ( plugin_list::iterator i = Manager::ActivePluginsInternal()->begin();
i != Manager::ActivePluginsInternal()->end(); i++ )
(*i)->InitPreExecution();
}
void Manager::FinishPlugins() {
assert(init);