diff --git a/CHANGES b/CHANGES index f83ae6405f..f2264a16f4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,23 @@ +7.1.0-dev.716 | 2024-12-09 12:15:46 -0700 + + * BTest baseline updates for compile-to-C++ (Vern Paxson, Corelight) + + * mark ZAM regression BTests as not suitable for compile-to-C++ (Vern Paxson, Corelight) + + * fix for -O gen-C++ maintenance helper to skip BTest intermediary files (Vern Paxson, Corelight) + + * introduced simplified initialization for non-standalone -O gen-C++ code (Vern Paxson, Corelight) + tied -O gen-standalone-C++ to use of --optimize-files + + * streamline generated -O C++ code by relying on per-function profiles rather than aggregate profile (Vern Paxson, Corelight) + + * when reporting available/unavailble C++ script bodies, flag those that are skipped (Vern Paxson, Corelight) + + * modified AST profiling to mark (and fully skip) non-optimizable functions (Vern Paxson, Corelight) + + * modified merge_types() to skip work if given identical types, which (Vern Paxson, Corelight) + also preserves type names (useful for -O gen-C++) + 7.1.0-dev.707 | 2024-12-09 12:08:21 -0700 * Move python signatures to a separate file (Tim Wojtulewicz, Corelight) diff --git a/VERSION b/VERSION index f70d157b1e..1757809c63 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.1.0-dev.707 +7.1.0-dev.716 diff --git a/src/Type.cc b/src/Type.cc index 4b6d78a066..e32a4565bb 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -2376,6 +2376,9 @@ TypeListPtr merge_list_types(const Type* t1, const Type* t2) { } TypePtr merge_types(const TypePtr& arg_t1, const TypePtr& arg_t2) { + if ( arg_t1 == arg_t2 ) + return arg_t1; + auto t1 = arg_t1.get(); auto t2 = arg_t2.get(); // t1 = flatten_type(t1); diff --git a/src/script_opt/CPP/Driver.cc b/src/script_opt/CPP/Driver.cc index b6dc561853..c96a8012cf 100644 --- a/src/script_opt/CPP/Driver.cc +++ b/src/script_opt/CPP/Driver.cc @@ -29,6 +29,7 @@ CPPCompile::CPPCompile(vector& _funcs, std::shared_ptr _ CPPCompile::~CPPCompile() { fclose(write_file); } void CPPCompile::Compile(bool report_uncompilable) { + unordered_set rep_types; unordered_set filenames_reported_as_skipped; bool had_to_skip = false; @@ -63,6 +64,24 @@ void CPPCompile::Compile(bool report_uncompilable) { continue; } + auto pf = func.Profile(); + total_hash = merge_p_hashes(total_hash, pf->HashVal()); + + for ( auto t : pf->UnorderedTypes() ) + rep_types.insert(pfs->TypeRep(t)); + + auto& pf_all_gl = pf->AllGlobals(); + all_accessed_globals.insert(pf_all_gl.begin(), pf_all_gl.end()); + + auto& pf_gl = pf->Globals(); + accessed_globals.insert(pf_gl.begin(), pf_gl.end()); + + auto& pf_events = pf->Events(); + accessed_events.insert(pf_events.begin(), pf_events.end()); + + auto& pf_lambdas = pf->Lambdas(); + accessed_lambdas.insert(pf_lambdas.begin(), pf_lambdas.end()); + if ( is_lambda(f) || is_when_lambda(f) ) { // We deal with these separately. func.SetSkip(true); @@ -85,35 +104,35 @@ void CPPCompile::Compile(bool report_uncompilable) { } } - if ( standalone && had_to_skip ) - reporter->FatalError("aborting standalone compilation to C++ due to having to skip some functions"); - // Generate a hash unique for this compilation. for ( const auto& func : funcs ) if ( ! func.ShouldSkip() ) total_hash = merge_p_hashes(total_hash, func.Profile()->HashVal()); + if ( standalone && had_to_skip ) + reporter->FatalError("aborting standalone compilation to C++ due to having to skip some functions"); + auto t = util::current_time(); total_hash = merge_p_hashes(total_hash, hash{}(t)); GenProlog(); // Track all of the types we'll be using. - for ( const auto& t : pfs->RepTypes() ) { + for ( const auto& t : rep_types ) { TypePtr tp{NewRef{}, (Type*)(t)}; types.AddKey(tp, pfs->HashType(t)); } NL(); - for ( auto& g : pfs->AllGlobals() ) + for ( auto& g : all_accessed_globals ) CreateGlobal(g); - for ( const auto& e : pfs->Events() ) + for ( const auto& e : accessed_events ) if ( AddGlobal(e, "gl") ) Emit("EventHandlerPtr %s_ev;", globals[string(e)]); - for ( const auto& t : pfs->RepTypes() ) { + for ( const auto& t : rep_types ) { ASSERT(types.HasKey(t)); TypePtr tp{NewRef{}, (Type*)(t)}; RegisterType(tp); @@ -131,7 +150,7 @@ void CPPCompile::Compile(bool report_uncompilable) { // be identical. In that case, we don't want to generate the lambda // twice, but we do want to map the second one to the same body name. unordered_map lambda_ASTs; - for ( const auto& l : pfs->Lambdas() ) { + for ( const auto& l : accessed_lambdas ) { const auto& n = l->Name(); const auto body = l->Ingredients()->Body().get(); if ( lambda_ASTs.count(n) > 0 ) @@ -151,7 +170,7 @@ void CPPCompile::Compile(bool report_uncompilable) { CompileFunc(func); lambda_ASTs.clear(); - for ( const auto& l : pfs->Lambdas() ) { + for ( const auto& l : accessed_lambdas ) { const auto& n = l->Name(); if ( lambda_ASTs.count(n) > 0 ) continue; diff --git a/src/script_opt/CPP/Driver.h b/src/script_opt/CPP/Driver.h index e2a097ed2e..f4f8e123d8 100644 --- a/src/script_opt/CPP/Driver.h +++ b/src/script_opt/CPP/Driver.h @@ -60,6 +60,11 @@ void GenFinishInit(); // Generate the function that registers compiled script bodies. void GenRegisterBodies(); +public: +// Whether we're generating "standalone" code. +bool TargetingStandalone() const { return standalone; } + +private: // True if the given function (plus body and profile) is one that should be // compiled. If non-nil, sets reason to the the reason why, if there's a // fundamental problem. If however the function should be skipped for other diff --git a/src/script_opt/CPP/Exprs.cc b/src/script_opt/CPP/Exprs.cc index 482b04f61f..ddef91b5a8 100644 --- a/src/script_opt/CPP/Exprs.cc +++ b/src/script_opt/CPP/Exprs.cc @@ -308,9 +308,8 @@ string CPPCompile::GenCallExpr(const CallExpr* c, GenType gt, bool top_level) { if ( pfs->BiFGlobals().count(f_id) == 0 ) gen += +"->AsFunc()"; - else if ( pfs->Globals().count(f_id) > 0 ) - // The BiF version has an extra "_", per - // AddBiF(..., true). + else if ( accessed_globals.count(f_id) > 0 ) + // The BiF version has an extra "_", per AddBiF(..., true). gen = globals[string(id_name) + "_"]; } diff --git a/src/script_opt/CPP/Inits.cc b/src/script_opt/CPP/Inits.cc index 0906d1c55b..54b40b161c 100644 --- a/src/script_opt/CPP/Inits.cc +++ b/src/script_opt/CPP/Inits.cc @@ -104,11 +104,18 @@ void CPPCompile::InitializeFieldMappings() { StartBlock(); + string type_arg, attrs_arg; + if ( ! standalone ) + type_arg = attrs_arg = "DO_NOT_CONSTRUCT_VALUE_MARKER"; + for ( const auto& mapping : field_decls ) { auto rt_arg = Fmt(mapping.first); auto td = mapping.second; - auto type_arg = Fmt(TypeOffset(td->type)); - auto attrs_arg = Fmt(AttributesOffset(td->attrs)); + + if ( standalone ) { + type_arg = Fmt(TypeOffset(td->type)); + attrs_arg = Fmt(AttributesOffset(td->attrs)); + } Emit("CPP_FieldMapping(%s, \"%s\", %s, %s),", rt_arg, td->id, type_arg, attrs_arg); } @@ -121,8 +128,10 @@ void CPPCompile::InitializeEnumMappings() { StartBlock(); + auto create_if_missing = standalone ? "true" : "false"; + for ( const auto& mapping : enum_names ) - Emit("CPP_EnumMapping(%s, \"%s\"),", Fmt(mapping.first), mapping.second); + Emit("CPP_EnumMapping(%s, \"%s\", %s),", Fmt(mapping.first), mapping.second, create_if_missing); EndBlock(true); } @@ -178,9 +187,15 @@ void CPPCompile::InitializeGlobals() { Emit("Frame* f__CPP = nullptr;"); NL(); + auto& ofiles = analysis_options.only_files; + for ( const auto& ginit : IDOptInfo::GetGlobalInitExprs() ) { auto g = ginit.Id(); - if ( pfs->Globals().count(g) == 0 ) + + if ( ! ofiles.empty() && ! obj_matches_opt_files(g) ) + continue; + + if ( accessed_globals.count(g) == 0 ) continue; auto ic = ginit.IC(); diff --git a/src/script_opt/CPP/InitsInfo.cc b/src/script_opt/CPP/InitsInfo.cc index 6006b7bda0..ba8e3cd674 100644 --- a/src/script_opt/CPP/InitsInfo.cc +++ b/src/script_opt/CPP/InitsInfo.cc @@ -355,10 +355,18 @@ AttrsInfo::AttrsInfo(CPPCompile* _c, const AttributesPtr& _attrs) : CompoundItem } } -GlobalInitInfo::GlobalInitInfo(CPPCompile* c, const ID* g, string _CPP_name) +GlobalLookupInitInfo::GlobalLookupInitInfo(CPPCompile* c, const ID* g, string _CPP_name) : CPP_InitInfo(g), CPP_name(std::move(_CPP_name)) { Zeek_name = g->Name(); +} +void GlobalLookupInitInfo::InitializerVals(std::vector& ivs) const { + ivs.push_back(CPP_name); + ivs.push_back(string("\"") + Zeek_name + "\""); +} + +GlobalInitInfo::GlobalInitInfo(CPPCompile* c, const ID* g, string _CPP_name) + : GlobalLookupInitInfo(c, g, std::move(_CPP_name)) { auto& gt = g->GetType(); auto gi = c->RegisterType(gt); init_cohort = max(init_cohort, gi->InitCohort() + 1); @@ -375,7 +383,7 @@ GlobalInitInfo::GlobalInitInfo(CPPCompile* c, const ID* g, string _CPP_name) exported = g->IsExport(); val = ValElem(c, nullptr); // empty because we initialize dynamically - if ( gt->Tag() == TYPE_FUNC && ! g->GetVal() ) + if ( gt->Tag() == TYPE_FUNC && (! g->GetVal() || g->GetVal()->AsFunc()->GetKind() == Func::BUILTIN_FUNC) ) // Remember this peculiarity so we can recreate it for // error-behavior-compatibility. func_with_no_val = true; @@ -549,7 +557,7 @@ RecordTypeInfo::RecordTypeInfo(CPPCompile* _c, TypePtr _t) : AbstractTypeInfo(_c field_types.push_back(r_i->type); - if ( r_i->attrs ) { + if ( c->TargetingStandalone() && r_i->attrs ) { gi = c->RegisterAttributes(r_i->attrs); final_init_cohort = max(final_init_cohort, gi->InitCohort() + 1); field_attrs.push_back(gi->Offset()); @@ -576,6 +584,13 @@ void RecordTypeInfo::AddInitializerVals(std::vector& ivs) const { } } +NamedTypeInfo::NamedTypeInfo(CPPCompile* _c, TypePtr _t) : AbstractTypeInfo(_c, std::move(_t)) {} + +void NamedTypeInfo::AddInitializerVals(std::vector& ivs) const { + ivs.emplace_back(Fmt(NAMED_TYPE_MARKER)); + ivs.emplace_back(Fmt(c->TrackString(t->GetName()))); +} + void IndicesManager::Generate(CPPCompile* c) { c->Emit("int CPP__Indices__init[] ="); c->StartBlock(); diff --git a/src/script_opt/CPP/InitsInfo.h b/src/script_opt/CPP/InitsInfo.h index a9ae9ed37b..3432871d67 100644 --- a/src/script_opt/CPP/InitsInfo.h +++ b/src/script_opt/CPP/InitsInfo.h @@ -478,8 +478,22 @@ public: AttrsInfo(CPPCompile* c, const AttributesPtr& attrs); }; -// Information for initialization a Zeek global. -class GlobalInitInfo : public CPP_InitInfo { +// A lightweight initializer for a Zeek global that will look it up at +// initialization time but not create it if missing. +class GlobalLookupInitInfo : public CPP_InitInfo { +public: + GlobalLookupInitInfo(CPPCompile* c, const ID* g, std::string CPP_name); + + std::string InitializerType() const override { return "CPP_GlobalLookupInit"; } + void InitializerVals(std::vector& ivs) const override; + +protected: + std::string Zeek_name; + std::string CPP_name; +}; + +// Information for initializing a Zeek global. +class GlobalInitInfo : public GlobalLookupInitInfo { public: GlobalInitInfo(CPPCompile* c, const ID* g, std::string CPP_name); @@ -639,6 +653,14 @@ private: std::vector field_attrs; }; +// Class for initializing a named Zeek type that should be present at startup. +class NamedTypeInfo : public AbstractTypeInfo { +public: + NamedTypeInfo(CPPCompile* c, TypePtr _t); + + void AddInitializerVals(std::vector& ivs) const override; +}; + // Much of the table-driven initialization is based on vectors of indices, // which we represent as vectors of int's, where each int is used to index a // global C++ vector. This class manages such vectors. In particular, it diff --git a/src/script_opt/CPP/README.md b/src/script_opt/CPP/README.md index 4b3ed6b10f..ba95fc6980 100644 --- a/src/script_opt/CPP/README.md +++ b/src/script_opt/CPP/README.md @@ -90,7 +90,7 @@ and also any compiled-to-C++ bodies present in the `zeek` binary that The above workflows require the subsequent `zeek` execution to include the `target.zeek` script. You can avoid this by replacing the first step with: -1. `./src/zeek -O gen-standalone-C++ target.zeek >target-stand-in.zeek` +1. `./src/zeek -O gen-standalone-C++ --optimize-files=target.zeek target.zeek >target-stand-in.zeek` (and then building as in the 2nd step above). This option prints to _stdout_ a @@ -100,13 +100,9 @@ without needing to include `target.zeek` in the invocation (nor the `-O use-C++` option). After loading the stand-in script, you can still access types and functions declared in `target.zeek`. -Note: the implementation differences between `gen-C++` and `gen-standalone-C++` -wound up being modest enough that it might make sense to just always provide -the latter functionality, which it turns out does not introduce any -additional constraints compared to the current `gen-C++` functionality. -On the other hand, it's possible (not yet established) that code created -using `gen-C++` can be made to compile significantly faster than -standalone code. +Note: `gen-standalone-C++` _must_ be used with `--optimize-files`, as the +compiler needs the latter to determine which global declarations the +standalone code needs to initialize. There are additional workflows relating to running the test suite: see `src/script_opt/CPP/maint/README`. diff --git a/src/script_opt/CPP/RuntimeInits.cc b/src/script_opt/CPP/RuntimeInits.cc index d8b73626c5..2918a8b30a 100644 --- a/src/script_opt/CPP/RuntimeInits.cc +++ b/src/script_opt/CPP/RuntimeInits.cc @@ -235,7 +235,7 @@ void CPP_TypeInits::PreInit(InitsManager* im, int offset, ValElemVec& init_vals) if ( tag == TYPE_LIST ) inits_vec[offset] = make_intrusive(); - else if ( tag == TYPE_RECORD ) { + else if ( tag == TYPE_RECORD && init_vals[1] != NAMED_TYPE_MARKER ) { auto name = im->Strings(init_vals[1]); if ( name[0] ) inits_vec[offset] = get_record_type__CPP(name); @@ -243,7 +243,7 @@ void CPP_TypeInits::PreInit(InitsManager* im, int offset, ValElemVec& init_vals) inits_vec[offset] = get_record_type__CPP(nullptr); } - else if ( tag == TYPE_TABLE ) + else if ( tag == TYPE_TABLE && init_vals[1] != NAMED_TYPE_MARKER ) inits_vec[offset] = make_intrusive(); // else no pre-initialization needed @@ -251,6 +251,13 @@ void CPP_TypeInits::PreInit(InitsManager* im, int offset, ValElemVec& init_vals) void CPP_TypeInits::Generate(InitsManager* im, vector& ivec, int offset, ValElemVec& init_vals) const { auto tag = static_cast(init_vals[0]); + + if ( init_vals.size() > 1 && init_vals[1] == NAMED_TYPE_MARKER ) { + auto name = im->Strings(init_vals[2]); + ivec[offset] = find_global__CPP(name)->GetType(); + return; + } + TypePtr t; switch ( tag ) { case TYPE_ADDR: @@ -406,6 +413,11 @@ int CPP_FieldMapping::ComputeOffset(InitsManager* im) const { auto fm_offset = r->FieldOffset(field_name.c_str()); if ( fm_offset < 0 ) { // field does not exist, create it + if ( field_type == DO_NOT_CONSTRUCT_VALUE_MARKER ) { + reporter->CPPRuntimeError("record field \"%s\" missing in %s", field_name.c_str(), obj_desc(r).c_str()); + exit(1); + } + fm_offset = r->NumFields(); auto id = util::copy_string(field_name.c_str(), field_name.size()); @@ -429,6 +441,11 @@ int CPP_EnumMapping::ComputeOffset(InitsManager* im) const { auto em_offset = e->Lookup(e_name); if ( em_offset < 0 ) { // enum constant does not exist, create it + if ( ! construct_if_missing ) { + reporter->CPPRuntimeError("enum element \"%s\" missing in %s", e_name.c_str(), obj_desc(e).c_str()); + exit(1); + } + em_offset = e->Names().size(); if ( e->Lookup(em_offset) ) reporter->InternalError("enum inconsistency while initializing compiled scripts"); @@ -438,6 +455,10 @@ int CPP_EnumMapping::ComputeOffset(InitsManager* im) const { return em_offset; } +void CPP_GlobalLookupInit::Generate(InitsManager* im, std::vector& /* inits_vec */, int /* offset */) const { + global = find_global__CPP(name); +} + void CPP_GlobalInit::Generate(InitsManager* im, std::vector& /* inits_vec */, int /* offset */) const { auto& t = im->Types(type); global = lookup_global__CPP(name, t, exported); diff --git a/src/script_opt/CPP/RuntimeInits.h b/src/script_opt/CPP/RuntimeInits.h index 268d2ca250..ddd8cf578e 100644 --- a/src/script_opt/CPP/RuntimeInits.h +++ b/src/script_opt/CPP/RuntimeInits.h @@ -41,6 +41,14 @@ extern std::vector>> generate_indices_set(int* init #define END_OF_VEC_VEC -100 #define END_OF_VEC_VEC_VEC -200 +// A marker value for "named" types (those that are simply looked up by +// name at initialization time). +#define NAMED_TYPE_MARKER -300 + +// A marker value indicating values that should not be constructed if not +// already present. +#define DO_NOT_CONSTRUCT_VALUE_MARKER -400 + // An abstract helper class used to access elements of an initialization vector. // We need the abstraction because InitsManager below needs to be able to refer // to any of a range of templated classes. @@ -369,8 +377,19 @@ public: } }; -// Class for initializing a Zeek global. These don't go into an initialization +// Classes for initializing Zeek globals. These don't go into an initialization // vector, so we use void* as the underlying type. +class CPP_GlobalLookupInit : public CPP_Init { +public: + CPP_GlobalLookupInit(IDPtr& _global, const char* _name) : CPP_Init(), global(_global), name(_name) {} + + void Generate(InitsManager* im, std::vector& /* inits_vec */, int /* offset */) const override; + +protected: + IDPtr& global; + const char* name; +}; + class CPP_GlobalInit : public CPP_Init { public: CPP_GlobalInit(IDPtr& _global, const char* _name, int _type, int _attrs, int _val, bool _exported, @@ -463,8 +482,12 @@ public: private: int rec; // index to retrieve the record's type std::string field_name; // which field this offset pertains to - int field_type; // the field's type, in case we have to construct it - int field_attrs; // the same for the field's attributes + + // The field's type, in case we have to construct it. If + // DO_NOT_CONSTRUCT_VALUE_MARKER then it's instead an error + // if missing. + int field_type; + int field_attrs; // the same for the field's attributes }; // Constructs at run-time a mapping between abstract enum values used when @@ -473,13 +496,15 @@ private: // the enum). class CPP_EnumMapping { public: - CPP_EnumMapping(int _e_type, std::string _e_name) : e_type(_e_type), e_name(std::move(_e_name)) {} + CPP_EnumMapping(int _e_type, std::string _e_name, bool _construct_if_missing) + : e_type(_e_type), e_name(std::move(_e_name)), construct_if_missing(_construct_if_missing) {} int ComputeOffset(InitsManager* im) const; private: - int e_type; // index to EnumType - std::string e_name; // which enum constant for that type + int e_type; // index to EnumType + std::string e_name; // which enum constant for that type + bool construct_if_missing; // if true, construct constant if not present }; // Looks up a BiF of the given name, making it available to compiled diff --git a/src/script_opt/CPP/Types.cc b/src/script_opt/CPP/Types.cc index f97987a9e9..59aab07a04 100644 --- a/src/script_opt/CPP/Types.cc +++ b/src/script_opt/CPP/Types.cc @@ -191,41 +191,45 @@ shared_ptr CPPCompile::RegisterType(const TypePtr& tp) { shared_ptr gi; - switch ( t->Tag() ) { - case TYPE_ADDR: - case TYPE_ANY: - case TYPE_BOOL: - case TYPE_COUNT: - case TYPE_DOUBLE: - case TYPE_ERROR: - case TYPE_INT: - case TYPE_INTERVAL: - case TYPE_PATTERN: - case TYPE_PORT: - case TYPE_STRING: - case TYPE_TIME: - case TYPE_VOID: - case TYPE_SUBNET: - case TYPE_FILE: gi = make_shared(this, tp); break; + if ( standalone || t->GetName().empty() ) { + switch ( t->Tag() ) { + case TYPE_ADDR: + case TYPE_ANY: + case TYPE_BOOL: + case TYPE_COUNT: + case TYPE_DOUBLE: + case TYPE_ERROR: + case TYPE_INT: + case TYPE_INTERVAL: + case TYPE_PATTERN: + case TYPE_PORT: + case TYPE_STRING: + case TYPE_TIME: + case TYPE_VOID: + case TYPE_SUBNET: + case TYPE_FILE: gi = make_shared(this, tp); break; - case TYPE_ENUM: gi = make_shared(this, tp); break; + case TYPE_ENUM: gi = make_shared(this, tp); break; - case TYPE_OPAQUE: gi = make_shared(this, tp); break; + case TYPE_OPAQUE: gi = make_shared(this, tp); break; - case TYPE_TYPE: gi = make_shared(this, tp); break; + case TYPE_TYPE: gi = make_shared(this, tp); break; - case TYPE_VECTOR: gi = make_shared(this, tp); break; + case TYPE_VECTOR: gi = make_shared(this, tp); break; - case TYPE_LIST: gi = make_shared(this, tp); break; + case TYPE_LIST: gi = make_shared(this, tp); break; - case TYPE_TABLE: gi = make_shared(this, tp); break; + case TYPE_TABLE: gi = make_shared(this, tp); break; - case TYPE_RECORD: gi = make_shared(this, tp); break; + case TYPE_RECORD: gi = make_shared(this, tp); break; - case TYPE_FUNC: gi = make_shared(this, tp); break; + case TYPE_FUNC: gi = make_shared(this, tp); break; - default: reporter->InternalError("bad type in CPPCompile::RegisterType"); + default: reporter->InternalError("bad type in CPPCompile::RegisterType"); + } } + else + gi = make_shared(this, tp); type_info->AddInstance(gi); processed_types[t] = gi; diff --git a/src/script_opt/CPP/Vars.cc b/src/script_opt/CPP/Vars.cc index 38ec046aa9..34a037c056 100644 --- a/src/script_opt/CPP/Vars.cc +++ b/src/script_opt/CPP/Vars.cc @@ -11,7 +11,7 @@ void CPPCompile::CreateGlobal(const ID* g) { auto gn = string(g->Name()); bool is_bif = pfs->BiFGlobals().count(g) > 0; - if ( pfs->Globals().count(g) == 0 ) { + if ( accessed_globals.count(g) == 0 ) { // Only used in the context of calls. If it's compilable, // then we'll call it directly. if ( compilable_funcs.count(gn) > 0 ) { @@ -28,11 +28,16 @@ void CPPCompile::CreateGlobal(const ID* g) { if ( AddGlobal(gn, "gl") ) { // We'll be creating this global. Emit("IDPtr %s;", globals[gn]); - if ( pfs->Events().count(gn) > 0 ) + if ( accessed_events.count(gn) > 0 ) // This is an event that's also used as a variable. Emit("EventHandlerPtr %s_ev;", globals[gn]); - auto gi = make_shared(this, g, globals[gn]); + shared_ptr gi; + if ( standalone ) + gi = make_shared(this, g, globals[gn]); + else + gi = make_shared(this, g, globals[gn]); + global_id_info->AddInstance(gi); global_gis[g] = gi; } @@ -64,7 +69,12 @@ std::shared_ptr CPPCompile::RegisterGlobal(const ID* g) { return gg->second; } - auto gi = make_shared(this, g, globals[gn]); + shared_ptr gi; + if ( standalone ) + gi = make_shared(this, g, globals[gn]); + else + gi = make_shared(this, g, globals[gn]); + global_id_info->AddInstance(gi); global_gis[g] = gi; diff --git a/src/script_opt/CPP/Vars.h b/src/script_opt/CPP/Vars.h index cfbeb2db3c..8a0d9dac81 100644 --- a/src/script_opt/CPP/Vars.h +++ b/src/script_opt/CPP/Vars.h @@ -53,6 +53,19 @@ std::string Canonicalize(const std::string& name) const; // be a EXPR_NAME). std::string GlobalName(const ExprPtr& e) { return globals[e->AsNameExpr()->Id()->Name()]; } +// Globals that are used (appear in the profiles) of the bodies we're +// compiling. Includes globals just used as functions to call. +std::unordered_set all_accessed_globals; + +// Same, but just the globals used in contexts beyond function calls. +std::unordered_set accessed_globals; + +// Lambdas that are accessed. +std::unordered_set accessed_lambdas; + +// Events that are accessed. +std::unordered_set accessed_events; + // Maps global names (not identifiers) to the names we use for them. std::unordered_map globals; diff --git a/src/script_opt/CPP/maint/find-test-files.sh b/src/script_opt/CPP/maint/find-test-files.sh index 642b438d31..bf848db4ec 100755 --- a/src/script_opt/CPP/maint/find-test-files.sh +++ b/src/script_opt/CPP/maint/find-test-files.sh @@ -1,6 +1,7 @@ #! /bin/sh find ../testing/btest -type f | + grep -v '\.tmp/' | xargs grep -E -l '@TEST' | xargs grep -E -l '^[ ]*(event|print)' | xargs grep -E -c 'REQUIRES.*CPP.*((!=.*1)|(==.*0))' | diff --git a/src/script_opt/ProfileFunc.cc b/src/script_opt/ProfileFunc.cc index c489921f46..dbccc7f778 100644 --- a/src/script_opt/ProfileFunc.cc +++ b/src/script_opt/ProfileFunc.cc @@ -578,6 +578,8 @@ ProfileFuncs::ProfileFuncs(std::vector& funcs, is_compilable_pred pred if ( ! pred || (*pred)(pf.get(), nullptr) ) MergeInProfile(pf.get()); + else if ( pred ) + f.SetSkip(true); // Track the profile even if we're not compiling the function, since // the AST optimizer will still need it to reason about function-call diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index b1f56d99c0..b69a61b6fc 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -109,13 +109,25 @@ bool should_analyze(const ScriptFuncPtr& f, const StmtPtr& body) { if ( ofiles.empty() && ofuncs.empty() ) return true; + if ( obj_matches_opt_files(body.get()) ) + return true; + const auto& fun = f->GetName(); for ( auto& o : ofuncs ) if ( std::regex_match(fun, o) ) return true; - auto fin = util::detail::normalize_path(body->GetLocationInfo()->filename); + return false; +} + +bool obj_matches_opt_files(const Obj* obj) { + auto& ofiles = analysis_options.only_files; + + if ( ofiles.empty() ) + return false; + + auto fin = util::detail::normalize_path(obj->GetLocationInfo()->filename); for ( auto& o : ofiles ) if ( std::regex_match(fin, o) ) @@ -287,8 +299,12 @@ static void init_options() { check_env_opt("ZEEK_USE_CPP", analysis_options.use_CPP); check_env_opt("ZEEK_ALLOW_COND", analysis_options.allow_cond); - if ( analysis_options.gen_standalone_CPP ) + if ( analysis_options.gen_standalone_CPP ) { + if ( analysis_options.only_files.empty() ) + reporter->FatalError("-O gen-standalone-C++ requires use of --optimize-files"); + analysis_options.gen_CPP = true; + } if ( analysis_options.gen_CPP ) generating_CPP = true; @@ -368,6 +384,12 @@ static void report_CPP() { for ( auto& f : funcs ) { const auto& name = f.Func()->GetName(); + + if ( f.ShouldSkip() ) { + printf("script function %s: SKIP\n", name.c_str()); + continue; + } + auto hash = f.Profile()->HashVal(); bool have = compiled_scripts.count(hash) > 0; @@ -399,6 +421,9 @@ static void use_CPP() { auto pfs = std::make_unique(funcs, is_CPP_compilable, true, false); for ( auto& f : funcs ) { + if ( f.ShouldSkip() ) + continue; + auto hash = f.Profile()->HashVal(); auto s = compiled_scripts.find(hash); diff --git a/src/script_opt/ScriptOpt.h b/src/script_opt/ScriptOpt.h index 70eed83dbe..4890987aec 100644 --- a/src/script_opt/ScriptOpt.h +++ b/src/script_opt/ScriptOpt.h @@ -253,6 +253,10 @@ extern void add_file_analysis_pattern(AnalyOpt& opts, const char* pat); // it should be skipped. extern bool should_analyze(const ScriptFuncPtr& f, const StmtPtr& body); +// True if the given object's location matches one specified by +// --optimize-files=... +extern bool obj_matches_opt_files(const Obj* obj); + // Analyze all of the parsed scripts collectively for usage issues (unless // suppressed by the flag) and optimization. extern void analyze_scripts(bool no_unused_warnings); diff --git a/testing/btest/Baseline.cpp/bifs.disable_analyzer-early/out b/testing/btest/Baseline.cpp/bifs.disable_analyzer-early/out index b72c958aef..5741db6901 100644 --- a/testing/btest/Baseline.cpp/bifs.disable_analyzer-early/out +++ b/testing/btest/Baseline.cpp/bifs.disable_analyzer-early/out @@ -3,5 +3,5 @@ proto confirm, AllAnalyzers::ANALYZER_ANALYZER_HTTP T http_request, GET, /style/enhanced.css total http messages, { -[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp]] = 1 +[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp, proto=6]] = 1 } diff --git a/testing/btest/Baseline.cpp/bifs.disable_analyzer-hook/out b/testing/btest/Baseline.cpp/bifs.disable_analyzer-hook/out index c72bc161e8..750269ab42 100644 --- a/testing/btest/Baseline.cpp/bifs.disable_analyzer-hook/out +++ b/testing/btest/Baseline.cpp/bifs.disable_analyzer-hook/out @@ -1,16 +1,16 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. proto confirm, AllAnalyzers::ANALYZER_ANALYZER_HTTP http_request, GET, /style/enhanced.css -preventing disable_analyzer, [orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp], AllAnalyzers::ANALYZER_ANALYZER_HTTP, 3, 1 +preventing disable_analyzer, [orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_HTTP, 3, 1 F http_reply, 200 http_request, GET, /script/urchin.js -preventing disable_analyzer, [orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp], AllAnalyzers::ANALYZER_ANALYZER_HTTP, 3, 3 +preventing disable_analyzer, [orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_HTTP, 3, 3 F http_reply, 200 http_request, GET, /images/template/screen/bullet_utility.png -allowing disable_analyzer, [orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp], AllAnalyzers::ANALYZER_ANALYZER_HTTP, 3, 5 +allowing disable_analyzer, [orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_HTTP, 3, 5 T total http messages, { -[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp]] = 5 +[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp, proto=6]] = 5 } diff --git a/testing/btest/Baseline.cpp/bifs.disable_analyzer/out b/testing/btest/Baseline.cpp/bifs.disable_analyzer/out index 2a4cdae144..6c14045611 100644 --- a/testing/btest/Baseline.cpp/bifs.disable_analyzer/out +++ b/testing/btest/Baseline.cpp/bifs.disable_analyzer/out @@ -3,5 +3,5 @@ proto confirm, AllAnalyzers::ANALYZER_ANALYZER_HTTP http_request, GET, /style/enhanced.css T total http messages, { -[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp]] = 1 +[[orig_h=192.168.1.104, orig_p=1673/tcp, resp_h=63.245.209.11, resp_p=80/tcp, proto=6]] = 1 } diff --git a/testing/btest/Baseline.cpp/bifs.type_aliases/out b/testing/btest/Baseline.cpp/bifs.type_aliases/out deleted file mode 100644 index dab1c31ead..0000000000 --- a/testing/btest/Baseline.cpp/bifs.type_aliases/out +++ /dev/null @@ -1,22 +0,0 @@ -### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -type aliases for 'RED enum val': ColorAlias Color -type aliases for 'Color enum type': ColorAlias Color -type aliases for 'MyRec val': MyRec MyRecAlias -type aliases for 'MyRecAlias val': MyRec MyRecAlias -type aliases for 'MyRec type': MyRec MyRecAlias -type aliases for 'MyRecalias type': MyRec MyRecAlias -type aliases for 'MyString val': it's just a 'string' -type aliases for 'MyString type': MyString AnotherString -type aliases for 'MyOtherString type': MyOtherString -type aliases for 'AnotherString type': MyString AnotherString -type aliases for 'string literal value': it's just a 'string' -type aliases for 'count literal value': it's just a 'count' -type aliases for 'MyTable value': it's just a 'table[count] of string' -type aliases for 'MyTable2 value': it's just a 'table[count] of string' -type aliases for 'MyTable3 value': it's just a 'table[count] of string' -type aliases for 'MyTable4 value': it's just a 'table[count] of string' -type aliases for 'MyTable type': MyTable2 MyTable3 MyTable MyTable4 -type aliases for 'MyTable2 type': MyTable2 MyTable3 MyTable MyTable4 -type aliases for 'MyTable3 type': MyTable2 MyTable3 MyTable MyTable4 -type aliases for 'MyTable4 type': MyTable2 MyTable3 MyTable MyTable4 -type aliases for 'table value': it's just a 'table[count] of string' diff --git a/testing/btest/Baseline.cpp/cluster.generic.errors/.stderr b/testing/btest/Baseline.cpp/cluster.generic.errors/.stderr new file mode 100644 index 0000000000..8e82f08d99 --- /dev/null +++ b/testing/btest/Baseline.cpp/cluster.generic.errors/.stderr @@ -0,0 +1,15 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +error in <...>/errors.zeek (C++), line 16: no event arguments given (<___>testing_btest__tmp_cluster_generic_errors_errors_zeek__zeek_init__36__zf: function() : void()) +error in <...>/errors.zeek (C++), line 16: not enough arguments (<___>testing_btest__tmp_cluster_generic_errors_errors_zeek__zeek_init__36__zf: function() : void()) +error in <...>/errors.zeek (C++), line 16: bad number of arguments for ping1: got 0, expect 2 +error in <...>/errors.zeek (C++), line 16: bad number of arguments for ping1: got 0, expect 2 +error in <...>/errors.zeek (C++), line 16: bad number of arguments for ping1: got 1, expect 2 +error in <...>/errors.zeek (C++), line 16: bad number of arguments for ping1: got 1, expect 2 +error in <...>/errors.zeek (C++), line 16: bad number of arguments for ping1: got 3, expect 2 +error in <...>/errors.zeek (C++), line 16: bad number of arguments for ping1: got 3, expect 2 +error in <...>/errors.zeek (C++), line 37: event parameter #2 type mismatch, got count, expecting string +error in <...>/errors.zeek (C++), line 37: event parameter #2 type mismatch, got count, expecting string +error in <...>/errors.zeek (C++), line 37: unexpected function type for hook1: hook +error in <...>/errors.zeek (C++), line 37: unexpected function type for hook1: hook +error in <...>/errors.zeek (C++), line 37: expected function or record as first argument, got count (<___>testing_btest__tmp_cluster_generic_errors_errors_zeek__zeek_init__37__zf: function() : void()) +error in <...>/errors.zeek (C++), line 37: got non-event type 'count' (<___>testing_btest__tmp_cluster_generic_errors_errors_zeek__zeek_init__37__zf: function() : void()) diff --git a/testing/btest/Baseline.cpp/cluster.generic.errors/.stdout b/testing/btest/Baseline.cpp/cluster.generic.errors/.stdout new file mode 100644 index 0000000000..ee431b2959 --- /dev/null +++ b/testing/btest/Baseline.cpp/cluster.generic.errors/.stdout @@ -0,0 +1,10 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +wrong number of args +r1, [ev=, args=[]] +r2, [ev=, args=[]] +r3, [ev=, args=[]] +r4, [ev=, args=[]] +wrong types +r1, [ev=, args=[]] +r2, [ev=, args=[]] +r3, [ev=, args=[]] diff --git a/testing/btest/Baseline.cpp/cluster.generic.make_event/.stderr b/testing/btest/Baseline.cpp/cluster.generic.make_event/.stderr new file mode 100644 index 0000000000..9e77528b32 --- /dev/null +++ b/testing/btest/Baseline.cpp/cluster.generic.make_event/.stderr @@ -0,0 +1,7 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +error in <...>/make_event.zeek (C++), line 30: not enough arguments (<___>testing_btest__tmp_cluster_generic_make_event_make_event_zeek__zeek_init__39__zf: function() : void()) +error in <...>/make_event.zeek (C++), line 35: got non-event type 'string' (<___>testing_btest__tmp_cluster_generic_make_event_make_event_zeek__zeek_init__40__zf: function() : void()) +error in <...>/make_event.zeek (C++), line 40: unexpected function type for test_fun: function +error in <...>/make_event.zeek (C++), line 45: unexpected function type for test_hook: hook +error in <...>/make_event.zeek (C++), line 50: bad number of arguments for test_event2: got 0, expect 1 +error in <...>/make_event.zeek (C++), line 55: bad number of arguments for test_event2: got 2, expect 1 diff --git a/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info-ftp/.stdout b/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info-ftp/.stdout index 1e4f9aa98a..a901d6fb47 100644 --- a/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info-ftp/.stdout +++ b/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info-ftp/.stdout @@ -1,3 +1,3 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -analyzer_confirmation_info, AllAnalyzers::ANALYZER_ANALYZER_FTP, [orig_h=2001:470:1f05:17a6:d69a:20ff:fefd:6b88, orig_p=24316/tcp, resp_h=2001:6a8:a40::21, resp_p=21/tcp], 3 -analyzer_violation_info, AllAnalyzers::ANALYZER_ANALYZER_FTP, non-numeric reply code, [orig_h=2001:470:1f05:17a6:d69a:20ff:fefd:6b88, orig_p=24316/tcp, resp_h=2001:6a8:a40::21, resp_p=21/tcp], 3, SSH-2.0-mod_sftp/0.9.7 +analyzer_confirmation_info, AllAnalyzers::ANALYZER_ANALYZER_FTP, [orig_h=2001:470:1f05:17a6:d69a:20ff:fefd:6b88, orig_p=24316/tcp, resp_h=2001:6a8:a40::21, resp_p=21/tcp, proto=6], 3 +analyzer_violation_info, AllAnalyzers::ANALYZER_ANALYZER_FTP, non-numeric reply code, [orig_h=2001:470:1f05:17a6:d69a:20ff:fefd:6b88, orig_p=24316/tcp, resp_h=2001:6a8:a40::21, resp_p=21/tcp, proto=6], 3, SSH-2.0-mod_sftp/0.9.7 diff --git a/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info/.stdout b/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info/.stdout index af8800750d..16b47e8b21 100644 --- a/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info/.stdout +++ b/testing/btest/Baseline.cpp/core.analyzer-confirmation-violation-info/.stdout @@ -1,3 +1,3 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -analyzer_confirmation_info, AllAnalyzers::ANALYZER_ANALYZER_SSL, [orig_h=1.1.1.1, orig_p=20394/tcp, resp_h=2.2.2.2, resp_p=443/tcp], 3 -analyzer_violation_info, AllAnalyzers::ANALYZER_ANALYZER_SSL, Invalid version late in TLS connection. Packet reported version: 0, [orig_h=1.1.1.1, orig_p=20394/tcp, resp_h=2.2.2.2, resp_p=443/tcp], 3 +analyzer_confirmation_info, AllAnalyzers::ANALYZER_ANALYZER_SSL, [orig_h=1.1.1.1, orig_p=20394/tcp, resp_h=2.2.2.2, resp_p=443/tcp, proto=6], 3 +analyzer_violation_info, AllAnalyzers::ANALYZER_ANALYZER_SSL, Invalid version late in TLS connection. Packet reported version: 0, [orig_h=1.1.1.1, orig_p=20394/tcp, resp_h=2.2.2.2, resp_p=443/tcp, proto=6], 3 diff --git a/testing/btest/Baseline.cpp/core.expr-exception/output b/testing/btest/Baseline.cpp/core.expr-exception/output index 9ea22c91da..7c9dccba13 100644 --- a/testing/btest/Baseline.cpp/core.expr-exception/output +++ b/testing/btest/Baseline.cpp/core.expr-exception/output @@ -1,19 +1,19 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. ftp field missing -[orig_h=141.142.220.118, orig_p=48649/tcp, resp_h=208.80.152.118, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=48649/tcp, resp_h=208.80.152.118, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.118, orig_p=49997/tcp, resp_h=208.80.152.3, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=49997/tcp, resp_h=208.80.152.3, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.118, orig_p=49996/tcp, resp_h=208.80.152.3, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=49996/tcp, resp_h=208.80.152.3, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.118, orig_p=49998/tcp, resp_h=208.80.152.3, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=49998/tcp, resp_h=208.80.152.3, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.118, orig_p=50000/tcp, resp_h=208.80.152.3, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=50000/tcp, resp_h=208.80.152.3, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.118, orig_p=49999/tcp, resp_h=208.80.152.3, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=49999/tcp, resp_h=208.80.152.3, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.118, orig_p=50001/tcp, resp_h=208.80.152.3, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=50001/tcp, resp_h=208.80.152.3, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.118, orig_p=35642/tcp, resp_h=208.80.152.2, resp_p=80/tcp] +[orig_h=141.142.220.118, orig_p=35642/tcp, resp_h=208.80.152.2, resp_p=80/tcp, proto=6] ftp field missing -[orig_h=141.142.220.235, orig_p=6705/tcp, resp_h=173.192.163.128, resp_p=80/tcp] +[orig_h=141.142.220.235, orig_p=6705/tcp, resp_h=173.192.163.128, resp_p=80/tcp, proto=6] diff --git a/testing/btest/Baseline.cpp/language.expire-expr-error/output b/testing/btest/Baseline.cpp/language.expire-expr-error/output index 0220c1a064..1f379ec328 100644 --- a/testing/btest/Baseline.cpp/language.expire-expr-error/output +++ b/testing/btest/Baseline.cpp/language.expire-expr-error/output @@ -1,3 +1,3 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -runtime error in compiled code: no such index -received termination signal +event(), [] +event(s:string), [abc] diff --git a/testing/btest/Baseline.cpp/language.expire-func-undef/output b/testing/btest/Baseline.cpp/language.expire-func-undef/output deleted file mode 100644 index 4e0530b87c..0000000000 --- a/testing/btest/Baseline.cpp/language.expire-func-undef/output +++ /dev/null @@ -1,21 +0,0 @@ -### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -1299470395.000000 expression error in : value used but not set (segfault::scan_summary) -1299470405.000000 expression error in : value used but not set (segfault::scan_summary) -1299473995.000000 expression error in : value used but not set (segfault::scan_summary) -1299474005.000000 expression error in : value used but not set (segfault::scan_summary) -1299477595.000000 expression error in : value used but not set (segfault::scan_summary) -1299477605.000000 expression error in : value used but not set (segfault::scan_summary) -1299481195.000000 expression error in : value used but not set (segfault::scan_summary) -1299481205.000000 expression error in : value used but not set (segfault::scan_summary) -1299484795.000000 expression error in : value used but not set (segfault::scan_summary) -1299484805.000000 expression error in : value used but not set (segfault::scan_summary) -1299488395.000000 expression error in : value used but not set (segfault::scan_summary) -1299488405.000000 expression error in : value used but not set (segfault::scan_summary) -1299491995.000000 expression error in : value used but not set (segfault::scan_summary) -1299492005.000000 expression error in : value used but not set (segfault::scan_summary) -1299495595.000000 expression error in : value used but not set (segfault::scan_summary) -1299495605.000000 expression error in : value used but not set (segfault::scan_summary) -1299499195.000000 expression error in : value used but not set (segfault::scan_summary) -1299499205.000000 expression error in : value used but not set (segfault::scan_summary) -1299502795.000000 expression error in : value used but not set (segfault::scan_summary) -orig: 10.0.0.2: peers: {\x0a\x0910.0.0.3\x0a} diff --git a/testing/btest/Baseline.cpp/scripts.base.protocols.ssl.prevent-disable-analyzer/.stdout b/testing/btest/Baseline.cpp/scripts.base.protocols.ssl.prevent-disable-analyzer/.stdout index 229c675729..f66615e9e9 100644 --- a/testing/btest/Baseline.cpp/scripts.base.protocols.ssl.prevent-disable-analyzer/.stdout +++ b/testing/btest/Baseline.cpp/scripts.base.protocols.ssl.prevent-disable-analyzer/.stdout @@ -1,11 +1,11 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -analyzer_confirmation, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 -encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], T, 22, 32, 1 -established, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp] -disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 -preventing disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 -encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], F, 22, 32, 2 -encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], T, 23, 31, 3 -encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], T, 23, 17, 4 -disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 -allowing disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 +analyzer_confirmation, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 +encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], T, 22, 32, 1 +established, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6] +disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 +preventing disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 +encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], F, 22, 32, 2 +encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], T, 23, 31, 3 +encrypted_data, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], T, 23, 17, 4 +disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 +allowing disabling_analyzer, [orig_h=10.0.0.80, orig_p=56637/tcp, resp_h=68.233.76.12, resp_p=443/tcp, proto=6], AllAnalyzers::ANALYZER_ANALYZER_SSL, 3 diff --git a/testing/btest/opt/regress-any-leak.zeek b/testing/btest/opt/regress-any-leak.zeek index 118356aa07..d049672caf 100644 --- a/testing/btest/opt/regress-any-leak.zeek +++ b/testing/btest/opt/regress-any-leak.zeek @@ -1,4 +1,5 @@ # @TEST-DOC: Regression test for leak when mixing "any" types (affected both ZAM and non-ZAM) +# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1" # @TEST-EXEC: zeek -b -O ZAM %INPUT >output # @TEST-EXEC: btest-diff output diff --git a/testing/btest/opt/regress-any.zeek b/testing/btest/opt/regress-any.zeek index 98c4116392..0514cbac1d 100644 --- a/testing/btest/opt/regress-any.zeek +++ b/testing/btest/opt/regress-any.zeek @@ -1,4 +1,5 @@ # @TEST-DOC: Regression test for reassigning an "any" field +# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1" # @TEST-EXEC: zeek -b -O ZAM %INPUT >output # @TEST-EXEC: btest-diff output diff --git a/testing/btest/opt/regress-vector-mismatch.zeek b/testing/btest/opt/regress-vector-mismatch.zeek index e07411750d..48a15f96ac 100644 --- a/testing/btest/opt/regress-vector-mismatch.zeek +++ b/testing/btest/opt/regress-vector-mismatch.zeek @@ -1,4 +1,5 @@ # @TEST-DOC: Regression test for coercing vectors-of-any +# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1" # @TEST-EXEC: zeek -b -O ZAM %INPUT >output # @TEST-EXEC: btest-diff output