mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/awelzel/plugin-init-pre-execution'
* origin/topic/awelzel/plugin-init-pre-execution: plugin: Add InitPreExecution()
This commit is contained in:
commit
94ffcd6535
10 changed files with 52 additions and 8 deletions
20
CHANGES
20
CHANGES
|
@ -1,3 +1,23 @@
|
|||
7.1.0-dev.590 | 2024-11-21 14:40:53 +0100
|
||||
|
||||
* plugin: Add InitPreExecution() (Arne Welzel, Corelight)
|
||||
|
||||
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
|
||||
|
||||
7.1.0-dev.588 | 2024-11-21 10:22:21 +0100
|
||||
|
||||
* Bump zeekjs to v0.14.0 (Arne Welzel, Corelight)
|
||||
|
|
4
NEWS
4
NEWS
|
@ -77,6 +77,10 @@ New Functionality
|
|||
|
||||
event signature_match(state: signature_state, msg: string, data: string, end_of_match: count);
|
||||
|
||||
* A we plugin hook ``InitPreExecution()`` has been added to allow introspection
|
||||
of Zeek's AST after ZAM optimizations ran. This hook executes right before
|
||||
the ``zeek_init()`` event is enqueued.
|
||||
|
||||
Changed Functionality
|
||||
---------------------
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
7.1.0-dev.588
|
||||
7.1.0-dev.590
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -122,6 +122,13 @@ public:
|
|||
*/
|
||||
void InitPostScript();
|
||||
|
||||
/**
|
||||
* Fourth-stage initialization of the manager. This is called just before
|
||||
* enqueuing zeek_init(), after script analysis and optimization completed.
|
||||
* It forwards to the corresponding Plugin methods.
|
||||
*/
|
||||
void InitPreExecution();
|
||||
|
||||
/**
|
||||
* Finalizes all plugins at termination time. This forwards to the
|
||||
* corresponding Plugin \a Done() methods.
|
||||
|
|
|
@ -249,6 +249,8 @@ void Plugin::InitPreScript() {}
|
|||
|
||||
void Plugin::InitPostScript() {}
|
||||
|
||||
void Plugin::InitPreExecution() {}
|
||||
|
||||
Plugin::bif_item_list Plugin::BifItems() const { return bif_items; }
|
||||
|
||||
void Plugin::Done() {
|
||||
|
|
|
@ -748,6 +748,14 @@ protected:
|
|||
*/
|
||||
virtual void InitPostScript();
|
||||
|
||||
/**
|
||||
* Third-stage initialization of the plugin called just before enqueueing
|
||||
* zeek_init(), after script analysis and optimization completed.
|
||||
* This can be overridden by derived classes; they must however call the
|
||||
* parent's implementation.
|
||||
*/
|
||||
virtual void InitPreExecution();
|
||||
|
||||
/**
|
||||
* Finalizer method that derived classes can override for performing
|
||||
* custom tasks at shutdown. This can be overridden by derived
|
||||
|
|
|
@ -26,7 +26,6 @@ AnalyOpt analysis_options;
|
|||
std::unordered_set<const Func*> non_recursive_funcs;
|
||||
|
||||
void (*CPP_init_hook)() = nullptr;
|
||||
void (*CPP_activation_hook)() = nullptr;
|
||||
|
||||
// Tracks all of the loaded functions (including event handlers and hooks).
|
||||
static std::vector<FuncInfo> funcs;
|
||||
|
|
|
@ -271,8 +271,4 @@ extern bool IsZAM_BuiltInCond(const CallExpr* c);
|
|||
// to a non-empty value.
|
||||
extern void (*CPP_init_hook)();
|
||||
|
||||
// Used for "standalone" C++-compiled scripts to complete their activation;
|
||||
// called after parsing and BiF initialization, but before zeek_init.
|
||||
extern void (*CPP_activation_hook)();
|
||||
|
||||
} // namespace zeek::detail
|
||||
|
|
|
@ -992,8 +992,8 @@ SetupResult setup(int argc, char** argv, Options* zopts) {
|
|||
// we don't have any other source for it.
|
||||
run_state::detail::update_network_time(util::current_time());
|
||||
|
||||
if ( CPP_activation_hook )
|
||||
(*CPP_activation_hook)();
|
||||
// Plugin pre-execution hook.
|
||||
plugin_mgr->InitPreExecution();
|
||||
|
||||
if ( zeek_init )
|
||||
event_mgr.Enqueue(zeek_init, Args{});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue