From 53dc4ef0844cd56da96db103c0b51048db844817 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Mon, 13 Jun 2011 19:50:11 -0500 Subject: [PATCH 1/5] Change bro doc mode to write out docs immediately after parsing. Originally docs were written right after parsing, but it changed to after the bro_init event happens when I was experimenting with auto-documenting logging streams by querying the LogMgr after bro_init. That experiment dead-ended, and that location is bad for other reasons: the doc framework may try to access BroObj's that have already been freed. --- src/main.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main.cc b/src/main.cc index 70a1d8e4e9..37acbdeaeb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -740,6 +740,20 @@ int main(int argc, char** argv) } #endif + if ( generate_documentation ) + { + std::list::iterator it; + + for ( it = docs_generated.begin(); it != docs_generated.end(); ++it ) + (*it)->WriteDocFile(); + + for ( it = docs_generated.begin(); it != docs_generated.end(); ++it ) + delete *it; + + terminate_bro(); + return 0; + } + if ( nerr > 0 ) { delete dns_mgr; @@ -975,20 +989,6 @@ int main(int argc, char** argv) mgr.Drain(); - if ( generate_documentation ) - { - std::list::iterator it; - - for ( it = docs_generated.begin(); it != docs_generated.end(); ++it ) - (*it)->WriteDocFile(); - - for ( it = docs_generated.begin(); it != docs_generated.end(); ++it ) - delete *it; - - terminate_bro(); - return 0; - } - have_pending_timers = ! reading_traces && timer_mgr->Size() > 0; if ( io_sources.Size() > 0 || have_pending_timers ) From e00e29273a12f295fd7d6ec660ad86f6c6fb713c Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Tue, 14 Jun 2011 21:16:01 -0700 Subject: [PATCH 2/5] Updating submodule(s). --- aux/bro-aux | 2 +- aux/btest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aux/bro-aux b/aux/bro-aux index 14a7cfe4ea..1a610bced1 160000 --- a/aux/bro-aux +++ b/aux/bro-aux @@ -1 +1 @@ -Subproject commit 14a7cfe4ea2ff6c7f5301dcb81a869adcd6e9834 +Subproject commit 1a610bced1c83644a5bfaeb6e98cf75380fe61a1 diff --git a/aux/btest b/aux/btest index f096c0e408..a9aeb2e1a8 160000 --- a/aux/btest +++ b/aux/btest @@ -1 +1 @@ -Subproject commit f096c0e4088f2d92743e0c28077f086dff216cce +Subproject commit a9aeb2e1a8434c583c75f5941b58dc69a7517444 From b7e5d4169e7b76d6ce5c625495d28ef5337725a9 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 15 Jun 2011 12:33:35 -0500 Subject: [PATCH 3/5] Fix (py)broccoli unit tests being skipped on Mac. --- testing/btest/istate/broccoli.bro | 2 +- testing/btest/istate/pybroccoli.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/btest/istate/broccoli.bro b/testing/btest/istate/broccoli.bro index ed6a9eee6a..7f97f40585 100644 --- a/testing/btest/istate/broccoli.bro +++ b/testing/btest/istate/broccoli.bro @@ -1,5 +1,5 @@ # @TEST-REQUIRES: grep -vq '#define BROv6' $BUILD/config.h -# @TEST-REQUIRES: test -e $BUILD/aux/broccoli/src/libbroccoli.so +# @TEST-REQUIRES: test -e $BUILD/aux/broccoli/src/libbroccoli.so || test -e $BUILD/aux/broccoli/src/libbroccoli.dylib # # @TEST-EXEC: btest-bg-run bro bro %INPUT $DIST/aux/broccoli/test/broping-record.bro # @TEST-EXEC: btest-bg-run broccoli $BUILD/aux/broccoli/test/broping -r -c 3 127.0.0.1 diff --git a/testing/btest/istate/pybroccoli.py b/testing/btest/istate/pybroccoli.py index 52aba6dfa1..b7fb53a955 100644 --- a/testing/btest/istate/pybroccoli.py +++ b/testing/btest/istate/pybroccoli.py @@ -1,5 +1,5 @@ # @TEST-REQUIRES: grep -vq '#define BROv6' $BUILD/config.h -# @TEST-REQUIRES: test -e $BUILD/aux/broccoli/src/libbroccoli.so +# @TEST-REQUIRES: test -e $BUILD/aux/broccoli/src/libbroccoli.so || test -e $BUILD/aux/broccoli/src/libbroccoli.dylib # @TEST-REQUIRES: test -e $BUILD/aux/broccoli/bindings/broccoli-python/_broccoli_intern.so # # @TEST-EXEC: btest-bg-run bro bro %INPUT $DIST/aux/broccoli/bindings/broccoli-python/tests/test.bro From 4f6690776c28f47a6e7df6cec9c1693c4bd90749 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 15 Jun 2011 12:41:48 -0500 Subject: [PATCH 4/5] Update pybroccoli test. This corresponds to changes in the broccoli-python repository's commit 5b843ecc02a5d04b281409a05cee3a947665cfd2 --- testing/btest/Baseline/istate.pybroccoli/bro..stdout | 1 + 1 file changed, 1 insertion(+) diff --git a/testing/btest/Baseline/istate.pybroccoli/bro..stdout b/testing/btest/Baseline/istate.pybroccoli/bro..stdout index 6b74681745..f8c0c63c45 100644 --- a/testing/btest/Baseline/istate.pybroccoli/bro..stdout +++ b/testing/btest/Baseline/istate.pybroccoli/bro..stdout @@ -11,4 +11,5 @@ Servus 0.0 192.168.0.0/16 ==== record +[a=42, b=6.6.7.7] 42, 6.6.7.7 From 303dba6372739d7cae4a51e71a07e607c595afc6 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 15 Jun 2011 13:56:37 -0500 Subject: [PATCH 5/5] Coerce event handler record arguments to correct record type. This lets events be sent to bro that contain record arguments that don't have to fill in all &optional record fields. This corresponds to broccoli-python tests that were updated in commit 8b87d8f61ef89162019cd4acc01be93700b0c588 --- src/EventHandler.cc | 25 +++++++++++++++++++ .../Baseline/istate.pybroccoli/bro..stdout | 4 +++ 2 files changed, 29 insertions(+) diff --git a/src/EventHandler.cc b/src/EventHandler.cc index 9cc5306c9c..ef0c9fc63c 100644 --- a/src/EventHandler.cc +++ b/src/EventHandler.cc @@ -69,7 +69,32 @@ void EventHandler::Call(val_list* vl, bool no_remote) } if ( local ) + { + if ( FType() ) + { + const type_list* arg_types = type->ArgTypes()->Types(); + loop_over_list(*vl, i) + { + Val* v = (*vl)[i]; + BroType* va_t = v->Type(); + BroType* ar_t = (*arg_types)[i]; + if ( va_t->Tag() == TYPE_RECORD && ar_t->Tag() == TYPE_RECORD ) + { + if ( ! same_type(va_t, ar_t) ) + { + Val* nv; + nv = v->AsRecordVal()->CoerceTo(ar_t->AsRecordType()); + if ( nv ) + { + vl->replace(i, nv); + Unref(v); + } + } + } + } + } Unref(local->Call(vl)); + } else { loop_over_list(*vl, i) diff --git a/testing/btest/Baseline/istate.pybroccoli/bro..stdout b/testing/btest/Baseline/istate.pybroccoli/bro..stdout index f8c0c63c45..9eec3a4550 100644 --- a/testing/btest/Baseline/istate.pybroccoli/bro..stdout +++ b/testing/btest/Baseline/istate.pybroccoli/bro..stdout @@ -13,3 +13,7 @@ Servus ==== record [a=42, b=6.6.7.7] 42, 6.6.7.7 +==== coerced record +[a=13, b=, c=helloworld] +13 +helloworld