mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
script_opt/CPP: errors, recursive type fixes, fix embedded comments
better (than nothing) run-time errors for compiled scripts fixes for dealing with recursive types in compiled scripts fix for values in compiled scripts containing embedded comment markers
This commit is contained in:
parent
b7f7d32bf7
commit
c0dd2b4e81
27 changed files with 181 additions and 65 deletions
10
src/Type.h
10
src/Type.h
|
@ -398,6 +398,16 @@ class TableType : public IndexType
|
||||||
public:
|
public:
|
||||||
TableType(TypeListPtr ind, TypePtr yield);
|
TableType(TypeListPtr ind, TypePtr yield);
|
||||||
|
|
||||||
|
// Used by script compilation to update a "stub" table type
|
||||||
|
// (which is specified by using a nil "ind" value in the constructor)
|
||||||
|
// with its actual index & yield - necessary for dealing with
|
||||||
|
// recursive types.
|
||||||
|
void SetIndexAndYield(TypeListPtr ind, TypePtr yield)
|
||||||
|
{
|
||||||
|
ind = std::move(indices);
|
||||||
|
yield_type = std::move(yield);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assesses whether an &expire_func attribute's function type is compatible
|
* Assesses whether an &expire_func attribute's function type is compatible
|
||||||
* with this table type.
|
* with this table type.
|
||||||
|
|
|
@ -178,7 +178,6 @@ public:
|
||||||
|
|
||||||
// The same, for a single attribute.
|
// The same, for a single attribute.
|
||||||
std::shared_ptr<CPP_InitInfo> RegisterAttr(const AttrPtr& attr);
|
std::shared_ptr<CPP_InitInfo> RegisterAttr(const AttrPtr& attr);
|
||||||
int AttrOffset(const AttrPtr& attr) { return GI_Offset(RegisterAttr(attr)); }
|
|
||||||
|
|
||||||
// Returns a mapping of from Attr objects to their associated
|
// Returns a mapping of from Attr objects to their associated
|
||||||
// initialization information. The Attr must have previously
|
// initialization information. The Attr must have previously
|
||||||
|
@ -595,6 +594,10 @@ private:
|
||||||
// Maps function names to priorities, for hooks & event handlers.
|
// Maps function names to priorities, for hooks & event handlers.
|
||||||
std::unordered_map<std::string, int> body_priorities;
|
std::unordered_map<std::string, int> body_priorities;
|
||||||
|
|
||||||
|
// Maps function names to script locations, for better-than-nothing
|
||||||
|
// error reporting.
|
||||||
|
std::unordered_map<std::string, const Location*> body_locs;
|
||||||
|
|
||||||
// Maps function names to events relevant to them.
|
// Maps function names to events relevant to them.
|
||||||
std::unordered_map<std::string, std::vector<std::string>> body_events;
|
std::unordered_map<std::string, std::vector<std::string>> body_events;
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ void CPPCompile::CreateFunction(const FuncTypePtr& ft, const ProfileFunc* pf, co
|
||||||
|
|
||||||
body_hashes[fname] = pf->HashVal();
|
body_hashes[fname] = pf->HashVal();
|
||||||
body_priorities[fname] = priority;
|
body_priorities[fname] = priority;
|
||||||
|
body_locs[fname] = body->GetLocationInfo();
|
||||||
body_names.emplace(body.get(), fname);
|
body_names.emplace(body.get(), fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,13 +137,19 @@ void CPPCompile::DeclareSubclass(const FuncTypePtr& ft, const ProfileFunc* pf, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Emit("%s_cl(const char* name%s) : CPPStmt(name)%s { }", fname, addl_args, inits);
|
const Obj* stmts = pf->ProfiledBody();
|
||||||
|
if ( ! stmts )
|
||||||
|
stmts = pf->ProfiledExpr();
|
||||||
|
|
||||||
|
auto loc = stmts->GetLocationInfo();
|
||||||
|
auto loc_info = string("\"") + loc->filename + "\", " + Fmt(loc->first_line);
|
||||||
|
Emit("%s_cl(const char* name%s) : CPPStmt(name, %s)%s { }", fname, addl_args, loc_info, inits);
|
||||||
|
|
||||||
// An additional constructor just used to generate place-holder
|
// An additional constructor just used to generate place-holder
|
||||||
// instances, due to the mis-design that lambdas are identified
|
// instances, due to the mis-design that lambdas are identified
|
||||||
// by their Func objects rather than their FuncVal objects.
|
// by their Func objects rather than their FuncVal objects.
|
||||||
if ( lambda_ids && lambda_ids->length() > 0 )
|
if ( lambda_ids && lambda_ids->length() > 0 )
|
||||||
Emit("%s_cl(const char* name) : CPPStmt(name) { }", fname);
|
Emit("%s_cl(const char* name) : CPPStmt(name, %s) { }", fname, loc_info);
|
||||||
|
|
||||||
Emit("ValPtr Exec(Frame* f, StmtFlowType& flow) override final");
|
Emit("ValPtr Exec(Frame* f, StmtFlowType& flow) override final");
|
||||||
StartBlock();
|
StartBlock();
|
||||||
|
@ -178,7 +185,8 @@ void CPPCompile::DeclareDynCPPStmt()
|
||||||
Emit("class CPPDynStmt : public CPPStmt");
|
Emit("class CPPDynStmt : public CPPStmt");
|
||||||
Emit("\t{");
|
Emit("\t{");
|
||||||
Emit("public:");
|
Emit("public:");
|
||||||
Emit("\tCPPDynStmt(const char* _name, void* _func, int _type_signature) : CPPStmt(_name), "
|
Emit("\tCPPDynStmt(const char* _name, void* _func, int _type_signature, const char* filename, "
|
||||||
|
"int line_num) : CPPStmt(_name, filename, line_num), "
|
||||||
"func(_func), type_signature(_type_signature) { }");
|
"func(_func), type_signature(_type_signature) { }");
|
||||||
Emit("\tValPtr Exec(Frame* f, StmtFlowType& flow) override final;");
|
Emit("\tValPtr Exec(Frame* f, StmtFlowType& flow) override final;");
|
||||||
Emit("private:");
|
Emit("private:");
|
||||||
|
|
|
@ -274,9 +274,6 @@ shared_ptr<CPP_InitsInfo> CPPCompile::RegisterInitInfo(const char* tag, const ch
|
||||||
|
|
||||||
void CPPCompile::RegisterCompiledBody(const string& f)
|
void CPPCompile::RegisterCompiledBody(const string& f)
|
||||||
{
|
{
|
||||||
auto h = body_hashes[f];
|
|
||||||
auto p = body_priorities[f];
|
|
||||||
|
|
||||||
// Build up an initializer of the events relevant to the function.
|
// Build up an initializer of the events relevant to the function.
|
||||||
string events;
|
string events;
|
||||||
auto be = body_events.find(f);
|
auto be = body_events.find(f);
|
||||||
|
@ -293,8 +290,15 @@ void CPPCompile::RegisterCompiledBody(const string& f)
|
||||||
auto fi = func_index.find(f);
|
auto fi = func_index.find(f);
|
||||||
ASSERT(fi != func_index.end());
|
ASSERT(fi != func_index.end());
|
||||||
auto type_signature = casting_index[fi->second];
|
auto type_signature = casting_index[fi->second];
|
||||||
Emit("\tCPP_RegisterBody(\"%s\", (void*) %s, %s, %s, %s, std::vector<std::string>(%s)),", f, f,
|
|
||||||
Fmt(type_signature), Fmt(p), Fmt(h), events);
|
auto h = body_hashes[f];
|
||||||
|
auto p = body_priorities[f];
|
||||||
|
auto loc = body_locs[f];
|
||||||
|
auto body_info = Fmt(p) + ", " + Fmt(h) + ", \"" + loc->filename + " (C++)\", " +
|
||||||
|
Fmt(loc->first_line);
|
||||||
|
|
||||||
|
Emit("\tCPP_RegisterBody(\"%s\", (void*) %s, %s, %s, std::vector<std::string>(%s)),", f, f,
|
||||||
|
Fmt(type_signature), body_info, events);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPCompile::GenEpilog()
|
void CPPCompile::GenEpilog()
|
||||||
|
@ -368,6 +372,7 @@ void CPPCompile::GenCPPDynStmt()
|
||||||
StartBlock();
|
StartBlock();
|
||||||
|
|
||||||
Emit("flow = FLOW_RETURN;");
|
Emit("flow = FLOW_RETURN;");
|
||||||
|
Emit("f->SetOnlyCall(ce.get());");
|
||||||
|
|
||||||
Emit("switch ( type_signature )");
|
Emit("switch ( type_signature )");
|
||||||
StartBlock();
|
StartBlock();
|
||||||
|
@ -481,7 +486,8 @@ void CPPCompile::GenRegisterBodies()
|
||||||
|
|
||||||
Emit("for ( auto& b : CPP__bodies_to_register )");
|
Emit("for ( auto& b : CPP__bodies_to_register )");
|
||||||
StartBlock();
|
StartBlock();
|
||||||
Emit("auto f = make_intrusive<CPPDynStmt>(b.func_name.c_str(), b.func, b.type_signature);");
|
Emit("auto f = make_intrusive<CPPDynStmt>(b.func_name.c_str(), b.func, b.type_signature, "
|
||||||
|
"b.filename, b.line_num);");
|
||||||
|
|
||||||
auto reg = standalone ? "register_standalone_body" : "register_body";
|
auto reg = standalone ? "register_standalone_body" : "register_body";
|
||||||
Emit("%s__CPP(f, b.priority, b.h, b.events, finish_init__CPP);", reg);
|
Emit("%s__CPP(f, b.priority, b.h, b.events, finish_init__CPP);", reg);
|
||||||
|
|
|
@ -23,6 +23,28 @@ void CPPFunc::Describe(ODesc* d) const
|
||||||
d->Add(name);
|
d->Add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CPPStmt::CPPStmt(const char* _name, const char* filename, int line_num)
|
||||||
|
: Stmt(STMT_CPP), name(_name)
|
||||||
|
{
|
||||||
|
// We build a fake CallExpr node to be used for error-reporting.
|
||||||
|
// It doesn't matter that it matches the actual function/event/hook
|
||||||
|
// type-checking-wise, but it *does* need to type-check.
|
||||||
|
auto no_args = make_intrusive<RecordType>(nullptr);
|
||||||
|
auto no_yield = base_type(TYPE_VOID);
|
||||||
|
auto ft = make_intrusive<FuncType>(no_args, no_yield, FUNC_FLAVOR_FUNCTION);
|
||||||
|
|
||||||
|
vector<StmtPtr> no_bodies;
|
||||||
|
vector<int> no_priorities;
|
||||||
|
|
||||||
|
auto sf = make_intrusive<ScriptFunc>(name, ft, no_bodies, no_priorities);
|
||||||
|
auto fv = make_intrusive<FuncVal>(sf);
|
||||||
|
auto empty_args = make_intrusive<ListExpr>();
|
||||||
|
|
||||||
|
ce = make_intrusive<CallExpr>(make_intrusive<ConstExpr>(fv), empty_args);
|
||||||
|
Location loc(filename, line_num, line_num, 1, 1);
|
||||||
|
ce->SetLocationInfo(&loc);
|
||||||
|
}
|
||||||
|
|
||||||
CPPLambdaFunc::CPPLambdaFunc(string _name, FuncTypePtr ft, CPPStmtPtr _l_body)
|
CPPLambdaFunc::CPPLambdaFunc(string _name, FuncTypePtr ft, CPPStmtPtr _l_body)
|
||||||
: ScriptFunc(move(_name), move(ft), {_l_body}, {0})
|
: ScriptFunc(move(_name), move(ft), {_l_body}, {0})
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
||||||
class CPPStmt : public Stmt
|
class CPPStmt : public Stmt
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPPStmt(const char* _name) : Stmt(STMT_CPP), name(_name) { }
|
CPPStmt(const char* _name, const char* filename, int line_num);
|
||||||
|
|
||||||
const std::string& Name() { return name; }
|
const std::string& Name() { return name; }
|
||||||
|
|
||||||
|
@ -71,6 +71,9 @@ protected:
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
p_hash_type hash = 0ULL;
|
p_hash_type hash = 0ULL;
|
||||||
|
|
||||||
|
// A pseudo AST "call" node, used to support error localization.
|
||||||
|
CallExprPtr ce;
|
||||||
};
|
};
|
||||||
|
|
||||||
using CPPStmtPtr = IntrusivePtr<CPPStmt>;
|
using CPPStmtPtr = IntrusivePtr<CPPStmt>;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// See the file "COPYING" in the main distribution directory for copyright.
|
// See the file "COPYING" in the main distribution directory for copyright.
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include "zeek/Desc.h"
|
#include "zeek/Desc.h"
|
||||||
#include "zeek/RE.h"
|
#include "zeek/RE.h"
|
||||||
#include "zeek/ZeekString.h"
|
#include "zeek/ZeekString.h"
|
||||||
|
@ -95,7 +97,16 @@ void CPP_InitsInfo::BuildCohort(CPPCompile* c, std::vector<std::shared_ptr<CPP_I
|
||||||
vector<string> ivs;
|
vector<string> ivs;
|
||||||
auto o = co->InitObj();
|
auto o = co->InitObj();
|
||||||
if ( o )
|
if ( o )
|
||||||
c->Emit("/* #%s: Initializing %s: */", Fmt(co->Offset()), obj_desc(o));
|
{
|
||||||
|
auto od = obj_desc(o);
|
||||||
|
|
||||||
|
// Escape any embedded comment characters.
|
||||||
|
od = regex_replace(od, std::regex("/\\*"), "<<SLASH-STAR>>");
|
||||||
|
od = regex_replace(od, std::regex("\\*/"), "<<STAR-SLASH>>");
|
||||||
|
|
||||||
|
c->Emit("/* #%s: Initializing %s: */", Fmt(co->Offset()), od);
|
||||||
|
}
|
||||||
|
|
||||||
co->InitializerVals(ivs);
|
co->InitializerVals(ivs);
|
||||||
BuildCohortElement(c, co->InitializerType(), ivs);
|
BuildCohortElement(c, co->InitializerType(), ivs);
|
||||||
++n;
|
++n;
|
||||||
|
@ -286,7 +297,8 @@ AttrInfo::AttrInfo(CPPCompile* _c, const AttrPtr& attr) : CompoundItemInfo(_c)
|
||||||
if ( a_e )
|
if ( a_e )
|
||||||
{
|
{
|
||||||
auto gi = c->RegisterType(a_e->GetType());
|
auto gi = c->RegisterType(a_e->GetType());
|
||||||
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
if ( gi )
|
||||||
|
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
||||||
|
|
||||||
if ( ! CPPCompile::IsSimpleInitExpr(a_e) )
|
if ( ! CPPCompile::IsSimpleInitExpr(a_e) )
|
||||||
{
|
{
|
||||||
|
@ -307,7 +319,7 @@ AttrInfo::AttrInfo(CPPCompile* _c, const AttrPtr& attr) : CompoundItemInfo(_c)
|
||||||
else if ( a_e->Tag() == EXPR_NAME )
|
else if ( a_e->Tag() == EXPR_NAME )
|
||||||
{
|
{
|
||||||
auto g = a_e->AsNameExpr()->Id();
|
auto g = a_e->AsNameExpr()->Id();
|
||||||
auto gi = c->RegisterGlobal(g);
|
gi = c->RegisterGlobal(g);
|
||||||
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
||||||
|
|
||||||
vals.emplace_back(Fmt(static_cast<int>(AE_NAME)));
|
vals.emplace_back(Fmt(static_cast<int>(AE_NAME)));
|
||||||
|
@ -383,7 +395,8 @@ CallExprInitInfo::CallExprInitInfo(CPPCompile* c, ExprPtr _e, string _e_name, st
|
||||||
: CPP_InitInfo(_e), e(move(_e)), e_name(move(_e_name)), wrapper_class(move(_wrapper_class))
|
: CPP_InitInfo(_e), e(move(_e)), e_name(move(_e_name)), wrapper_class(move(_wrapper_class))
|
||||||
{
|
{
|
||||||
auto gi = c->RegisterType(e->GetType());
|
auto gi = c->RegisterType(e->GetType());
|
||||||
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
if ( gi )
|
||||||
|
init_cohort = max(init_cohort, gi->InitCohort() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaRegistrationInfo::LambdaRegistrationInfo(CPPCompile* c, string _name, FuncTypePtr ft,
|
LambdaRegistrationInfo::LambdaRegistrationInfo(CPPCompile* c, string _name, FuncTypePtr ft,
|
||||||
|
@ -477,12 +490,15 @@ void ListTypeInfo::AddInitializerVals(std::vector<std::string>& ivs) const
|
||||||
|
|
||||||
TableTypeInfo::TableTypeInfo(CPPCompile* _c, TypePtr _t) : AbstractTypeInfo(_c, move(_t))
|
TableTypeInfo::TableTypeInfo(CPPCompile* _c, TypePtr _t) : AbstractTypeInfo(_c, move(_t))
|
||||||
{
|
{
|
||||||
|
// Note, we leave init_cohort at 0 because the skeleton of this type
|
||||||
|
// is built in the first cohort.
|
||||||
|
|
||||||
auto tbl = t->AsTableType();
|
auto tbl = t->AsTableType();
|
||||||
|
|
||||||
auto gi = c->RegisterType(tbl->GetIndices());
|
auto gi = c->RegisterType(tbl->GetIndices());
|
||||||
ASSERT(gi);
|
ASSERT(gi);
|
||||||
indices = gi->Offset();
|
indices = gi->Offset();
|
||||||
init_cohort = gi->InitCohort();
|
final_init_cohort = gi->InitCohort();
|
||||||
|
|
||||||
yield = tbl->Yield();
|
yield = tbl->Yield();
|
||||||
|
|
||||||
|
@ -490,7 +506,7 @@ TableTypeInfo::TableTypeInfo(CPPCompile* _c, TypePtr _t) : AbstractTypeInfo(_c,
|
||||||
{
|
{
|
||||||
gi = c->RegisterType(yield);
|
gi = c->RegisterType(yield);
|
||||||
if ( gi )
|
if ( gi )
|
||||||
init_cohort = max(init_cohort, gi->InitCohort());
|
final_init_cohort = max(final_init_cohort, gi->InitCohort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,6 +271,9 @@ void CPP_TypeInits::PreInit(InitsManager* im, int offset, ValElemVec& init_vals)
|
||||||
inits_vec[offset] = get_record_type__CPP(nullptr);
|
inits_vec[offset] = get_record_type__CPP(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if ( tag == TYPE_TABLE )
|
||||||
|
inits_vec[offset] = make_intrusive<TableType>(nullptr, nullptr);
|
||||||
|
|
||||||
// else no pre-initialization needed
|
// else no pre-initialization needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +323,7 @@ void CPP_TypeInits::Generate(InitsManager* im, vector<TypePtr>& ivec, int offset
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case TYPE_TABLE:
|
||||||
t = BuildTableType(im, init_vals);
|
t = BuildTableType(im, init_vals, offset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_FUNC:
|
case TYPE_FUNC:
|
||||||
|
@ -394,13 +397,18 @@ TypePtr CPP_TypeInits::BuildTypeList(InitsManager* im, ValElemVec& init_vals, in
|
||||||
return tl;
|
return tl;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypePtr CPP_TypeInits::BuildTableType(InitsManager* im, ValElemVec& init_vals) const
|
TypePtr CPP_TypeInits::BuildTableType(InitsManager* im, ValElemVec& init_vals, int offset) const
|
||||||
{
|
{
|
||||||
|
auto t = cast_intrusive<TableType>(inits_vec[offset]);
|
||||||
|
ASSERT(t);
|
||||||
|
|
||||||
auto index = cast_intrusive<TypeList>(im->Types(init_vals[1]));
|
auto index = cast_intrusive<TypeList>(im->Types(init_vals[1]));
|
||||||
auto yield_i = init_vals[2];
|
auto yield_i = init_vals[2];
|
||||||
auto yield = yield_i >= 0 ? im->Types(yield_i) : nullptr;
|
auto yield = yield_i >= 0 ? im->Types(yield_i) : nullptr;
|
||||||
|
|
||||||
return make_intrusive<TableType>(index, yield);
|
t->SetIndexAndYield(index, yield);
|
||||||
|
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypePtr CPP_TypeInits::BuildFuncType(InitsManager* im, ValElemVec& init_vals) const
|
TypePtr CPP_TypeInits::BuildFuncType(InitsManager* im, ValElemVec& init_vals) const
|
||||||
|
|
|
@ -307,7 +307,7 @@ protected:
|
||||||
TypePtr BuildTypeType(InitsManager* im, ValElemVec& init_vals) const;
|
TypePtr BuildTypeType(InitsManager* im, ValElemVec& init_vals) const;
|
||||||
TypePtr BuildVectorType(InitsManager* im, ValElemVec& init_vals) const;
|
TypePtr BuildVectorType(InitsManager* im, ValElemVec& init_vals) const;
|
||||||
TypePtr BuildTypeList(InitsManager* im, ValElemVec& init_vals, int offset) const;
|
TypePtr BuildTypeList(InitsManager* im, ValElemVec& init_vals, int offset) const;
|
||||||
TypePtr BuildTableType(InitsManager* im, ValElemVec& init_vals) const;
|
TypePtr BuildTableType(InitsManager* im, ValElemVec& init_vals, int offset) const;
|
||||||
TypePtr BuildFuncType(InitsManager* im, ValElemVec& init_vals) const;
|
TypePtr BuildFuncType(InitsManager* im, ValElemVec& init_vals) const;
|
||||||
TypePtr BuildRecordType(InitsManager* im, ValElemVec& init_vals, int offset) const;
|
TypePtr BuildRecordType(InitsManager* im, ValElemVec& init_vals, int offset) const;
|
||||||
};
|
};
|
||||||
|
@ -556,9 +556,11 @@ protected:
|
||||||
struct CPP_RegisterBody
|
struct CPP_RegisterBody
|
||||||
{
|
{
|
||||||
CPP_RegisterBody(std::string _func_name, void* _func, int _type_signature, int _priority,
|
CPP_RegisterBody(std::string _func_name, void* _func, int _type_signature, int _priority,
|
||||||
p_hash_type _h, std::vector<std::string> _events)
|
p_hash_type _h, const char* _filename, int _line_num,
|
||||||
|
std::vector<std::string> _events)
|
||||||
: func_name(std::move(_func_name)), func(_func), type_signature(_type_signature),
|
: func_name(std::move(_func_name)), func(_func), type_signature(_type_signature),
|
||||||
priority(_priority), h(_h), events(std::move(_events))
|
priority(_priority), h(_h), filename(_filename), line_num(_line_num),
|
||||||
|
events(std::move(_events))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,6 +569,8 @@ struct CPP_RegisterBody
|
||||||
int type_signature;
|
int type_signature;
|
||||||
int priority;
|
int priority;
|
||||||
p_hash_type h;
|
p_hash_type h;
|
||||||
|
const char* filename;
|
||||||
|
int line_num;
|
||||||
std::vector<std::string> events;
|
std::vector<std::string> events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,6 @@ extern ValPtr when_index_slice__CPP(VectorVal* vec, const ListVal* lv);
|
||||||
// but (2) needing to have the address of that vector.
|
// but (2) needing to have the address of that vector.
|
||||||
inline ValPtr invoke__CPP(Func* f, std::vector<ValPtr> args, Frame* frame)
|
inline ValPtr invoke__CPP(Func* f, std::vector<ValPtr> args, Frame* frame)
|
||||||
{
|
{
|
||||||
if ( frame )
|
|
||||||
frame->SetOnlyCall(nullptr);
|
|
||||||
return f->Invoke(&args, frame);
|
return f->Invoke(&args, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,7 @@ void CPPCompile::GenForOverString(const ExprPtr& str, const IDPList* loop_vars)
|
||||||
{
|
{
|
||||||
Emit("auto sval__CPP = %s;", GenExpr(str, GEN_DONT_CARE));
|
Emit("auto sval__CPP = %s;", GenExpr(str, GEN_DONT_CARE));
|
||||||
|
|
||||||
Emit("for ( auto i__CPP = 0u; i__CPP < sval__CPP->Len(); ++i__CPP )");
|
Emit("for ( auto i__CPP = 0; i__CPP < sval__CPP->Len(); ++i__CPP )");
|
||||||
StartBlock();
|
StartBlock();
|
||||||
|
|
||||||
Emit("auto sv__CPP = make_intrusive<StringVal>(1, (const char*) sval__CPP->Bytes() + i__CPP);");
|
Emit("auto sv__CPP = make_intrusive<StringVal>(1, (const char*) sval__CPP->Bytes() + i__CPP);");
|
||||||
|
|
|
@ -15,7 +15,7 @@ The maintenance workflow:
|
||||||
to check in updates to the list of how the compiler currently fares
|
to check in updates to the list of how the compiler currently fares
|
||||||
on various btests (see end of this doc):
|
on various btests (see end of this doc):
|
||||||
|
|
||||||
Tue Feb 14 15:15:27 PST 2023
|
Sun Mar 5 12:02:44 PST 2023
|
||||||
|
|
||||||
2. Make sure the compiler can compile and execute the base scripts:
|
2. Make sure the compiler can compile and execute the base scripts:
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ The maintenance workflow:
|
||||||
"-O gen-C++" can successfully run on the input. Presently, it should
|
"-O gen-C++" can successfully run on the input. Presently, it should
|
||||||
be able to do so for all of them, other than some exceptions noted below.
|
be able to do so for all of them, other than some exceptions noted below.
|
||||||
|
|
||||||
This step is parallelizable, say using xargs -P 10.
|
This step is parallelizable, say using xargs -P 10 -n 1.
|
||||||
|
|
||||||
7. Copy ./src/zeek to ./zeek.HOLD. This is used to speed up recompilation used
|
7. Copy ./src/zeek to ./zeek.HOLD. This is used to speed up recompilation used
|
||||||
in the next step. However, it's also a headache to do development to
|
in the next step. However, it's also a headache to do development to
|
||||||
|
|
6
testing/btest/Baseline.cpp/bifs.find_all/out
Normal file
6
testing/btest/Baseline.cpp/bifs.find_all/out
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
hi
|
||||||
|
es
|
||||||
|
-------------------
|
||||||
|
0
|
||||||
|
0
|
11
testing/btest/Baseline.cpp/bifs.find_all/weird.log
Normal file
11
testing/btest/Baseline.cpp/bifs.find_all/weird.log
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
#separator \x09
|
||||||
|
#set_separator ,
|
||||||
|
#empty_field (empty)
|
||||||
|
#unset_field -
|
||||||
|
#path weird
|
||||||
|
#open XXXX-XX-XX-XX-XX-XX
|
||||||
|
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p name addl notice peer source
|
||||||
|
#types time string addr port addr port string string bool string string
|
||||||
|
XXXXXXXXXX.XXXXXX - - - - - max_find_all_string_length_exceeded <...>/find_all.zeek (C++), line 7: length 14 exceeded 5 F zeek -
|
||||||
|
#close XXXX-XX-XX-XX-XX-XX
|
10
testing/btest/Baseline.cpp/bifs.find_all_ordered/out
Normal file
10
testing/btest/Baseline.cpp/bifs.find_all_ordered/out
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
[this, is, a, test]
|
||||||
|
[one, two, three, four, one, two, three, four]
|
||||||
|
[this, is, a, test, test, test]
|
||||||
|
[]
|
||||||
|
[a, b]
|
||||||
|
[foo]
|
||||||
|
[bar, foo]
|
||||||
|
[]
|
||||||
|
[]
|
11
testing/btest/Baseline.cpp/bifs.find_all_ordered/weird.log
Normal file
11
testing/btest/Baseline.cpp/bifs.find_all_ordered/weird.log
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
#separator \x09
|
||||||
|
#set_separator ,
|
||||||
|
#empty_field (empty)
|
||||||
|
#unset_field -
|
||||||
|
#path weird
|
||||||
|
#open XXXX-XX-XX-XX-XX-XX
|
||||||
|
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p name addl notice peer source
|
||||||
|
#types time string addr port addr port string string bool string string
|
||||||
|
XXXXXXXXXX.XXXXXX - - - - - max_find_all_string_length_exceeded <...>/find_all_ordered.zeek (C++), line 7: length 14 exceeded 5 F zeek -
|
||||||
|
#close XXXX-XX-XX-XX-XX-XX
|
|
@ -1,2 +1,2 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <no location>: failed converting string to IP address (not an IP)
|
error in <...>/to_addr.zeek (C++), line 12: failed converting string to IP address (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_bifs_to_addr_to_addr_zeek__global_stmts__zf() and not an IP)
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <no location>: bad conversion to double (NotADouble)
|
error in <...>/to_double_from_string.zeek (C++), line 12: bad conversion to double (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_bifs_to_double_from_string_to_double_from_string_zeek__global_stmts__zf() and NotADouble)
|
||||||
error in <no location>: bad conversion to double ()
|
error in <...>/to_double_from_string.zeek (C++), line 12: bad conversion to double (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_bifs_to_double_from_string_to_double_from_string_zeek__global_stmts__zf() and )
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error in <no location>: failed converting string to IP prefix (10.0.0.0)
|
error in <...>/to_subnet.zeek (C++), line 6: failed converting string to IP prefix (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_bifs_to_subnet_to_subnet_zeek__global_stmts__zf() and 10.0.0.0)
|
||||||
error in <no location>: failed converting string to IP prefix (10.0.0.0/222)
|
error in <...>/to_subnet.zeek (C++), line 6: failed converting string to IP prefix (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_bifs_to_subnet_to_subnet_zeek__global_stmts__zf() and 10.0.0.0/222)
|
||||||
error in <no location>: failed converting string to IP prefix (don't work)
|
error in <...>/to_subnet.zeek (C++), line 6: failed converting string to IP prefix (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_bifs_to_subnet_to_subnet_zeek__global_stmts__zf() and don't work)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
error: Failed to attach master store backend_failure:
|
error in <...>/create-failure.zeek (C++), line 61: Failed to attach master store backend_failure: (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_broker_store_create_failure_create_failure_zeek__zeek_init__33__zf())
|
||||||
error: Could not create Broker master store '../fail'
|
error in <...>/create-failure.zeek (C++), line 61: Could not create Broker master store '../fail' (Users_vern_warehouse_zeek_zeek_master_02Mar23_testing_btest__tmp_broker_store_create_failure_create_failure_zeek__zeek_init__33__zf())
|
||||||
error in <no location>: invalid Broker store handle (broker::store::{})
|
error in <no location>: invalid Broker store handle (broker::store::{})
|
||||||
error in <no location>: invalid Broker store handle (broker::store::{})
|
error in <no location>: invalid Broker store handle (broker::store::{})
|
||||||
error in <no location>: invalid Broker store handle (broker::store::{})
|
error in <no location>: invalid Broker store handle (broker::store::{})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
reporter_info|init test-info||XXXXXXXXXX.XXXXXX
|
reporter_info|init test-info|<...>/reporter.zeek (C++), line 6|XXXXXXXXXX.XXXXXX
|
||||||
reporter_warning|init test-warning||XXXXXXXXXX.XXXXXX
|
reporter_warning|init test-warning|<...>/reporter.zeek (C++), line 6|XXXXXXXXXX.XXXXXX
|
||||||
reporter_error|init test-error||XXXXXXXXXX.XXXXXX
|
reporter_error|init test-error|<...>/reporter.zeek (C++), line 6|XXXXXXXXXX.XXXXXX
|
||||||
reporter_info|done test-info||XXXXXXXXXX.XXXXXX
|
reporter_info|done test-info|<...>/reporter.zeek (C++), line 13|XXXXXXXXXX.XXXXXX
|
||||||
reporter_warning|done test-warning||XXXXXXXXXX.XXXXXX
|
reporter_warning|done test-warning|<...>/reporter.zeek (C++), line 13|XXXXXXXXXX.XXXXXX
|
||||||
reporter_error|done test-error||XXXXXXXXXX.XXXXXX
|
reporter_error|done test-error|<...>/reporter.zeek (C++), line 13|XXXXXXXXXX.XXXXXX
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
pre test-info
|
<...>/reporter.zeek (C++), line 52: pre test-info
|
||||||
warning: pre test-warning
|
warning in <...>/reporter.zeek (C++), line 52: pre test-warning
|
||||||
error: pre test-error
|
error in <...>/reporter.zeek (C++), line 52: pre test-error
|
||||||
init test-info
|
<...>/reporter.zeek (C++), line 6: init test-info
|
||||||
warning: init test-warning
|
warning in <...>/reporter.zeek (C++), line 6: init test-warning
|
||||||
error: init test-error
|
error in <...>/reporter.zeek (C++), line 6: init test-error
|
||||||
done test-info
|
<...>/reporter.zeek (C++), line 13: done test-info
|
||||||
warning: done test-warning
|
warning in <...>/reporter.zeek (C++), line 13: done test-warning
|
||||||
error: done test-error
|
error in <...>/reporter.zeek (C++), line 13: done test-error
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
Hello, Zeek!
|
<...>/basic-no-errors.test (C++), line 11: Hello, Zeek!
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
#open XXXX-XX-XX-XX-XX-XX
|
#open XXXX-XX-XX-XX-XX-XX
|
||||||
#fields ts level message location
|
#fields ts level message location
|
||||||
#types time enum string string
|
#types time enum string string
|
||||||
XXXXXXXXXX.XXXXXX Reporter::INFO Hello, Zeek! (empty)
|
XXXXXXXXXX.XXXXXX Reporter::INFO Hello, Zeek! <...>/basic-no-errors.test (C++), line 11
|
||||||
#close XXXX-XX-XX-XX-XX-XX
|
#close XXXX-XX-XX-XX-XX-XX
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
runtime error in <...>/queue.zeek, line 152: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>], expression: Queue::ret[Queue::j], call stack:
|
runtime error in <...>/queue.zeek, line 152: vector index assignment failed for invalid type 'myrec', value: [a=T, b=hi, c=<uninitialized>], expression: Queue::ret[Queue::j], call stack:
|
||||||
#0 Queue::get_vector([initialized=T, vals={[2] = test,[3] = [a=T, b=hi, c=<uninitialized>],[5] = 3,[0] = hello,[6] = jkl;,[4] = asdf,[1] = goodbye}, settings=[max_len=<uninitialized>], top=7, bottom=0, size=0], [hello, goodbye, test])
|
#0 Queue::get_vector([initialized=T, vals={[2] = test,[3] = [a=T, b=hi, c=<uninitialized>],[5] = 3,[0] = hello,[6] = jkl;,[4] = asdf,[1] = goodbye}, settings=[max_len=<uninitialized>], top=7, bottom=0, size=0], [hello, goodbye, test]) at <...>/index-assignment-invalid.zeek (C++):32
|
||||||
#1 zeek_init()
|
#1 zeek_init()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
Reporter::Hook - Exercise Reporter Hook (dynamic, version 1.0.0)
|
Reporter::Hook - Exercise Reporter Hook (dynamic, version 1.0.0)
|
||||||
Implements Reporter (priority 0)
|
Implements Reporter (priority 0)
|
||||||
|
|
||||||
| Hook Some Info
|
| Hook Some Info <...>/reporter-hook.zeek (C++), line 15
|
||||||
| Hook error An Error
|
| Hook error An Error <...>/reporter-hook.zeek (C++), line 15
|
||||||
| Hook error An Error that does not show up in the log
|
| Hook error An Error that does not show up in the log <...>/reporter-hook.zeek (C++), line 15
|
||||||
| Hook runtime error in compiled code field value missing
|
| Hook runtime error in compiled code field value missing
|
||||||
| Hook warning A warning
|
| Hook warning A warning <...>/reporter-hook.zeek (C++), line 15
|
||||||
Some Info
|
<...>/reporter-hook.zeek (C++), line 15: Some Info
|
||||||
error: An Error
|
error in <...>/reporter-hook.zeek (C++), line 15: An Error
|
||||||
error: An Error that does not show up in the log
|
error in <...>/reporter-hook.zeek (C++), line 15: An Error that does not show up in the log
|
||||||
runtime error in compiled code: field value missing
|
runtime error in compiled code: field value missing
|
||||||
warning: A warning
|
warning in <...>/reporter-hook.zeek (C++), line 15: A warning
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#open XXXX-XX-XX-XX-XX-XX
|
#open XXXX-XX-XX-XX-XX-XX
|
||||||
#fields ts level message location
|
#fields ts level message location
|
||||||
#types time enum string string
|
#types time enum string string
|
||||||
XXXXXXXXXX.XXXXXX Reporter::INFO Some Info (empty)
|
XXXXXXXXXX.XXXXXX Reporter::INFO Some Info <...>/reporter-hook.zeek (C++), line 15
|
||||||
XXXXXXXXXX.XXXXXX Reporter::WARNING A warning (empty)
|
XXXXXXXXXX.XXXXXX Reporter::WARNING A warning <...>/reporter-hook.zeek (C++), line 15
|
||||||
XXXXXXXXXX.XXXXXX Reporter::ERROR An Error (empty)
|
XXXXXXXXXX.XXXXXX Reporter::ERROR An Error <...>/reporter-hook.zeek (C++), line 15
|
||||||
XXXXXXXXXX.XXXXXX Reporter::ERROR field value missing (empty)
|
XXXXXXXXXX.XXXXXX Reporter::ERROR field value missing (empty)
|
||||||
#close XXXX-XX-XX-XX-XX-XX
|
#close XXXX-XX-XX-XX-XX-XX
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue