mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
Further polishing and cleanup in preparation for merge.
This commit is contained in:
parent
aeb8e71e8c
commit
9616cd8e61
15 changed files with 79 additions and 60 deletions
|
@ -1,7 +1,6 @@
|
||||||
project(Bro C CXX)
|
project(Bro C CXX)
|
||||||
|
|
||||||
# When changing the minimum version here, also adapt
|
# When changing the minimum version here, also adapt
|
||||||
# cmake/BroPluginDynamic and
|
|
||||||
# aux/bro-aux/plugin-support/skeleton/CMakeLists.txt
|
# aux/bro-aux/plugin-support/skeleton/CMakeLists.txt
|
||||||
cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)
|
cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)
|
||||||
|
|
||||||
|
|
|
@ -247,10 +247,11 @@ in its search path ``BRO_PLUGIN_PATH``. However, in bare mode (``bro
|
||||||
-b``), no dynamic plugins will be activated by default; instead the
|
-b``), no dynamic plugins will be activated by default; instead the
|
||||||
user can selectively enable individual plugins in scriptland using the
|
user can selectively enable individual plugins in scriptland using the
|
||||||
``@load-plugin <qualified-plugin-name>`` directive (e.g.,
|
``@load-plugin <qualified-plugin-name>`` directive (e.g.,
|
||||||
``@load-plugin Demo::Rot13``). Alternatively, one can also set the
|
``@load-plugin Demo::Rot13``). Alternatively, one can activate a
|
||||||
environment variable ``BRO_PLUGIN_ACTIVATE`` to a list of
|
plugin from the command-line by specifying its full name
|
||||||
comma(!)-separated names of plugins to unconditionally activate, even
|
(``Demo::Rot13``), or set the environment variable
|
||||||
in bare mode.
|
``BRO_PLUGIN_ACTIVATE`` to a list of comma(!)-separated names of
|
||||||
|
plugins to unconditionally activate, even in bare mode.
|
||||||
|
|
||||||
``bro -N`` shows activated plugins separately from found but not yet
|
``bro -N`` shows activated plugins separately from found but not yet
|
||||||
activated plugins. Note that plugins compiled statically into Bro are
|
activated plugins. Note that plugins compiled statically into Bro are
|
||||||
|
@ -323,6 +324,11 @@ Packet Dumpers
|
||||||
|
|
||||||
Not yet available as plugins.
|
Not yet available as plugins.
|
||||||
|
|
||||||
|
Hooks
|
||||||
|
=====
|
||||||
|
|
||||||
|
TODO.
|
||||||
|
|
||||||
Testing Plugins
|
Testing Plugins
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
@ -398,9 +404,20 @@ Run the test-suite::
|
||||||
Debugging Plugins
|
Debugging Plugins
|
||||||
=================
|
=================
|
||||||
|
|
||||||
..todo::
|
Plugins can use Bro's standard debug logger by using the
|
||||||
|
``PLUGIN_DBG_LOG(<plugin>, <args>)`` macro (defined in
|
||||||
|
``DebugLogger.h``), where ``<plugin>`` is the ``Plugin`` instance and
|
||||||
|
``<args>`` are printf-style arguments, just as with Bro's standard
|
||||||
|
debuggging macros.
|
||||||
|
|
||||||
|
At runtime, one then activates a plugin's debugging output with ``-B
|
||||||
|
plugin-<name>``, where ``<name>`` is the name of the plugin as
|
||||||
|
returned by its ``Configure()`` method, yet with the
|
||||||
|
namespace-separator ``::`` replaced with a simple dash. Example: If
|
||||||
|
the plugin is called ``Bro::Demo``, use ``-B plugin-Bro-Dome``. As
|
||||||
|
usual, the debugging output will be recorded to ``debug.log`` if Bro's
|
||||||
|
compiled in debug mode.
|
||||||
|
|
||||||
Document.
|
|
||||||
|
|
||||||
Documenting Plugins
|
Documenting Plugins
|
||||||
===================
|
===================
|
||||||
|
|
|
@ -426,6 +426,6 @@ add_dependencies(bro bif_loader_plugins)
|
||||||
# Install *.bif.bro.
|
# Install *.bif.bro.
|
||||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/scripts/base/bif DESTINATION ${BRO_SCRIPT_INSTALL_PATH}/base)
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/scripts/base/bif DESTINATION ${BRO_SCRIPT_INSTALL_PATH}/base)
|
||||||
|
|
||||||
# Make clean removes the bif and plugin directories.
|
# Make clean removes the bif directory.
|
||||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/scripts/base/bif)
|
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/scripts/base/bif)
|
||||||
|
|
||||||
|
|
23
src/Func.cc
23
src/Func.cc
|
@ -277,17 +277,11 @@ int BroFunc::IsPure() const
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Val* BroFunc::Call(val_list* args, Frame* parent) const
|
Val* BroFunc::HandlePluginResult(Val* plugin_resul, tval_list* args)
|
||||||
{
|
{
|
||||||
#ifdef PROFILE_BRO_FUNCTIONS
|
// Helper function factoring out this code from BroFunc:Call() for better
|
||||||
DEBUG_MSG("Function: %s\n", id->Name());
|
// readability.
|
||||||
#endif
|
|
||||||
|
|
||||||
Val* plugin_result = PLUGIN_HOOK_WITH_RESULT(HOOK_CALL_FUNCTION, HookCallFunction(this, args), 0);
|
|
||||||
|
|
||||||
if ( plugin_result )
|
|
||||||
{
|
|
||||||
// TODO: We should factor this out into its own method.
|
|
||||||
switch ( Flavor() ) {
|
switch ( Flavor() ) {
|
||||||
case FUNC_FLAVOR_EVENT:
|
case FUNC_FLAVOR_EVENT:
|
||||||
Unref(plugin_result);
|
Unref(plugin_result);
|
||||||
|
@ -326,6 +320,17 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
||||||
return plugin_result;
|
return plugin_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Val* BroFunc::Call(val_list* args, Frame* parent) const
|
||||||
|
{
|
||||||
|
#ifdef PROFILE_BRO_FUNCTIONS
|
||||||
|
DEBUG_MSG("Function: %s\n", id->Name());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Val* plugin_result = PLUGIN_HOOK_WITH_RESULT(HOOK_CALL_FUNCTION, HookCallFunction(this, args), 0);
|
||||||
|
|
||||||
|
if ( plugin_result )
|
||||||
|
return HandlePluginResult(plugin_result, args);
|
||||||
|
|
||||||
if ( bodies.empty() )
|
if ( bodies.empty() )
|
||||||
{
|
{
|
||||||
// Can only happen for events and hooks.
|
// Can only happen for events and hooks.
|
||||||
|
|
|
@ -100,6 +100,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
BroFunc() : Func(BRO_FUNC) {}
|
BroFunc() : Func(BRO_FUNC) {}
|
||||||
Stmt* AddInits(Stmt* body, id_list* inits);
|
Stmt* AddInits(Stmt* body, id_list* inits);
|
||||||
|
Val* HandlePluginResult(Val* plugin_result, val_list* args);
|
||||||
|
|
||||||
DECLARE_SERIAL(BroFunc);
|
DECLARE_SERIAL(BroFunc);
|
||||||
|
|
||||||
|
|
|
@ -94,9 +94,7 @@ int BroObj::suppress_errors = 0;
|
||||||
BroObj::~BroObj()
|
BroObj::~BroObj()
|
||||||
{
|
{
|
||||||
if ( notify_plugins )
|
if ( notify_plugins )
|
||||||
{
|
|
||||||
PLUGIN_HOOK_VOID(HOOK_BRO_OBJ_DTOR, HookBroObjDtor(this));
|
PLUGIN_HOOK_VOID(HOOK_BRO_OBJ_DTOR, HookBroObjDtor(this));
|
||||||
}
|
|
||||||
|
|
||||||
delete location;
|
delete location;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace plugin {
|
||||||
* @param method_call The \a Manager method corresponding to the hook.
|
* @param method_call The \a Manager method corresponding to the hook.
|
||||||
*/
|
*/
|
||||||
#define PLUGIN_HOOK_VOID(hook, method_call) \
|
#define PLUGIN_HOOK_VOID(hook, method_call) \
|
||||||
if ( plugin_mgr->HavePluginForHook(plugin::hook) ) plugin_mgr->method_call;
|
{ if ( plugin_mgr->HavePluginForHook(plugin::hook) ) plugin_mgr->method_call; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro to trigger hooks that return a result.
|
* Macro to trigger hooks that return a result.
|
||||||
|
|
|
@ -1626,7 +1626,6 @@ void get_memory_usage(unsigned int* total, unsigned int* malloced)
|
||||||
unsigned int ret_total;
|
unsigned int ret_total;
|
||||||
|
|
||||||
#ifdef HAVE_MALLINFO
|
#ifdef HAVE_MALLINFO
|
||||||
// For memory, getrusage() gives bogus results on Linux. Grmpf.
|
|
||||||
struct mallinfo mi = mallinfo();
|
struct mallinfo mi = mallinfo();
|
||||||
|
|
||||||
if ( malloced )
|
if ( malloced )
|
||||||
|
@ -1637,7 +1636,7 @@ void get_memory_usage(unsigned int* total, unsigned int* malloced)
|
||||||
struct rusage r;
|
struct rusage r;
|
||||||
getrusage(RUSAGE_SELF, &r);
|
getrusage(RUSAGE_SELF, &r);
|
||||||
|
|
||||||
// At least on FreeBSD it's in KB.
|
// In KB.
|
||||||
ret_total = r.ru_maxrss * 1024;
|
ret_total = r.ru_maxrss * 1024;
|
||||||
|
|
||||||
if ( total )
|
if ( total )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue