mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
all: Change to use Func::GetName()
This commit is contained in:
parent
71e9c8d436
commit
77b9510c8a
13 changed files with 29 additions and 31 deletions
|
@ -703,7 +703,7 @@ int dbg_handle_debug_input() {
|
||||||
Frame* curr_frame = g_frame_stack.back();
|
Frame* curr_frame = g_frame_stack.back();
|
||||||
const ScriptFunc* func = curr_frame->GetFunction();
|
const ScriptFunc* func = curr_frame->GetFunction();
|
||||||
if ( func )
|
if ( func )
|
||||||
current_module = extract_module_name(func->Name());
|
current_module = extract_module_name(func->GetName().c_str());
|
||||||
else
|
else
|
||||||
current_module = GLOBAL_MODULE_NAME;
|
current_module = GLOBAL_MODULE_NAME;
|
||||||
|
|
||||||
|
|
|
@ -615,7 +615,7 @@ std::string DeltaUnsupportedCreate::Generate(ValTraceMgr* vtm) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTrace::EventTrace(const ScriptFunc* _ev, double _nt, size_t event_num) : ev(_ev), nt(_nt) {
|
EventTrace::EventTrace(const ScriptFunc* _ev, double _nt, size_t event_num) : ev(_ev), nt(_nt) {
|
||||||
auto ev_name = std::regex_replace(ev->Name(), std::regex(":"), "_");
|
auto ev_name = std::regex_replace(ev->GetName(), std::regex(":"), "_");
|
||||||
|
|
||||||
name = ev_name + "_" + std::to_string(event_num) + "__et";
|
name = ev_name + "_" + std::to_string(event_num) + "__et";
|
||||||
}
|
}
|
||||||
|
@ -678,7 +678,7 @@ void EventTrace::Generate(FILE* f, ValTraceMgr& vtm, const DeltaGenVec& dvec, st
|
||||||
if ( ! dvec.empty() )
|
if ( ! dvec.empty() )
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
|
|
||||||
fprintf(f, "\tevent %s(%s);\n\n", ev->Name(), args.c_str());
|
fprintf(f, "\tevent %s(%s);\n\n", ev->GetName().c_str(), args.c_str());
|
||||||
|
|
||||||
if ( successor.empty() ) {
|
if ( successor.empty() ) {
|
||||||
// The following isn't necessary with our current approach
|
// The following isn't necessary with our current approach
|
||||||
|
@ -880,7 +880,7 @@ std::string ValTraceMgr::GenValName(const ValPtr& v) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_FUNC: rep = v->AsFunc()->Name(); break;
|
case TYPE_FUNC: rep = v->AsFunc()->GetName(); break;
|
||||||
|
|
||||||
case TYPE_TIME: {
|
case TYPE_TIME: {
|
||||||
auto tm = v->AsDouble();
|
auto tm = v->AsDouble();
|
||||||
|
@ -1004,11 +1004,11 @@ EventTraceMgr::~EventTraceMgr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
if ( script_events.count(ev->Name()) > 0 )
|
if ( script_events.count(ev->GetName()) > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto nt = run_state::network_time;
|
auto nt = run_state::network_time;
|
||||||
if ( nt == 0.0 || util::streq(ev->Name(), "zeek_init") )
|
if ( nt == 0.0 || ev->GetName() == "zeek_init" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ! vtm.GetBaseTime() )
|
if ( ! vtm.GetBaseTime() )
|
||||||
|
@ -1021,10 +1021,10 @@ void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTraceMgr::EndEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
void EventTraceMgr::EndEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
if ( script_events.count(ev->Name()) > 0 )
|
if ( script_events.count(ev->GetName()) > 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( run_state::network_time > 0.0 && ! util::streq(ev->Name(), "zeek_init") )
|
if ( run_state::network_time > 0.0 && ev->GetName() != "zeek_init" )
|
||||||
vtm.FinishCurrentEvent(args);
|
vtm.FinishCurrentEvent(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4469,7 +4469,7 @@ TraversalCode EventExpr::Traverse(TraversalCallback* cb) const {
|
||||||
// to infinite traversals. We do, however, see if we can
|
// to infinite traversals. We do, however, see if we can
|
||||||
// locate the corresponding identifier, and traverse that.
|
// locate the corresponding identifier, and traverse that.
|
||||||
|
|
||||||
auto& id = lookup_ID(f->Name(), GLOBAL_MODULE_NAME, false, false, false);
|
auto& id = lookup_ID(f->GetName().c_str(), GLOBAL_MODULE_NAME, false, false, false);
|
||||||
|
|
||||||
if ( id ) {
|
if ( id ) {
|
||||||
tc = id->Traverse(cb);
|
tc = id->Traverse(cb);
|
||||||
|
|
|
@ -437,7 +437,7 @@ ValPtr ScriptFunc::Invoke(zeek::Args* args, Frame* parent) const {
|
||||||
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID && ! GetType()->ExpressionlessReturnOkay() &&
|
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID && ! GetType()->ExpressionlessReturnOkay() &&
|
||||||
(flow != FLOW_RETURN /* we fell off the end */ || ! result /* explicit return with no result */) &&
|
(flow != FLOW_RETURN /* we fell off the end */ || ! result /* explicit return with no result */) &&
|
||||||
! f->HasDelayed() )
|
! f->HasDelayed() )
|
||||||
reporter->Warning("non-void function returning without a value: %s", Name());
|
reporter->Warning("non-void function returning without a value: %s", GetName().c_str());
|
||||||
|
|
||||||
if ( result && g_trace_state.DoTrace() ) {
|
if ( result && g_trace_state.DoTrace() ) {
|
||||||
ODesc d;
|
ODesc d;
|
||||||
|
|
|
@ -121,7 +121,7 @@ ScriptProfileMgr::~ScriptProfileMgr() {
|
||||||
auto func = body_to_func[o];
|
auto func = body_to_func[o];
|
||||||
|
|
||||||
if ( func_stats.count(func) == 0 )
|
if ( func_stats.count(func) == 0 )
|
||||||
func_stats[func] = ScriptProfileStats(func->Name());
|
func_stats[func] = ScriptProfileStats(func->GetName());
|
||||||
|
|
||||||
func_stats[func].AddIn(p);
|
func_stats[func].AddIn(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ private:
|
||||||
|
|
||||||
class ScriptProfile : public ScriptProfileStats {
|
class ScriptProfile : public ScriptProfileStats {
|
||||||
public:
|
public:
|
||||||
ScriptProfile(const Func* _func, const detail::StmtPtr& body) : ScriptProfileStats(_func->Name()) {
|
ScriptProfile(const Func* _func, const detail::StmtPtr& body) : ScriptProfileStats(_func->GetName()) {
|
||||||
func = {NewRef{}, const_cast<Func*>(_func)};
|
func = {NewRef{}, const_cast<Func*>(_func)};
|
||||||
is_BiF = body == nullptr;
|
is_BiF = body == nullptr;
|
||||||
|
|
||||||
|
|
|
@ -761,12 +761,10 @@ std::optional<broker::data> val_to_data(const Val* v) {
|
||||||
case TYPE_FILE: return {string(v->AsFile()->Name())};
|
case TYPE_FILE: return {string(v->AsFile()->Name())};
|
||||||
case TYPE_FUNC: {
|
case TYPE_FUNC: {
|
||||||
const Func* f = v->AsFunc();
|
const Func* f = v->AsFunc();
|
||||||
std::string name(f->Name());
|
|
||||||
|
|
||||||
broker::vector rval;
|
broker::vector rval;
|
||||||
rval.emplace_back(name);
|
rval.emplace_back(f->GetName());
|
||||||
|
|
||||||
if ( name.find("lambda_<") == 0 ) {
|
if ( f->GetName().find("lambda_<") == 0 ) {
|
||||||
// Only ScriptFuncs have closures.
|
// Only ScriptFuncs have closures.
|
||||||
if ( auto b = dynamic_cast<const zeek::detail::ScriptFunc*>(f) ) {
|
if ( auto b = dynamic_cast<const zeek::detail::ScriptFunc*>(f) ) {
|
||||||
auto bc = b->SerializeCaptures();
|
auto bc = b->SerializeCaptures();
|
||||||
|
|
|
@ -803,9 +803,9 @@ bool Manager::AutoPublishEvent(string topic, Val* event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto handler = event_registry->Lookup(event_val->Name());
|
auto handler = event_registry->Lookup(event_val->GetName());
|
||||||
if ( ! handler ) {
|
if ( ! handler ) {
|
||||||
Error("Broker::auto_publish failed to lookup event '%s'", event_val->Name());
|
Error("Broker::auto_publish failed to lookup event '%s'", event_val->GetName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,10 +828,10 @@ bool Manager::AutoUnpublishEvent(const string& topic, Val* event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto handler = event_registry->Lookup(event_val->Name());
|
auto handler = event_registry->Lookup(event_val->GetName());
|
||||||
|
|
||||||
if ( ! handler ) {
|
if ( ! handler ) {
|
||||||
Error("Broker::auto_event_stop failed to lookup event '%s'", event_val->Name());
|
Error("Broker::auto_event_stop failed to lookup event '%s'", event_val->GetName().c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,7 +886,7 @@ zeek::RecordValPtr Manager::MakeEvent(ArgsSpan args) {
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
rval->Assign(0, func->Name());
|
rval->Assign(0, func->GetName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,10 @@ file_analysis::Analyzer* DataEvent::Instantiate(RecordValPtr args, file_analysis
|
||||||
EventHandlerPtr stream;
|
EventHandlerPtr stream;
|
||||||
|
|
||||||
if ( chunk_val )
|
if ( chunk_val )
|
||||||
chunk = event_registry->Lookup(chunk_val->AsFunc()->Name());
|
chunk = event_registry->Lookup(chunk_val->AsFunc()->GetName());
|
||||||
|
|
||||||
if ( stream_val )
|
if ( stream_val )
|
||||||
stream = event_registry->Lookup(stream_val->AsFunc()->Name());
|
stream = event_registry->Lookup(stream_val->AsFunc()->GetName());
|
||||||
|
|
||||||
return new DataEvent(std::move(args), file, chunk, stream);
|
return new DataEvent(std::move(args), file, chunk, stream);
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,8 +412,8 @@ bool Manager::CreateEventStream(RecordVal* fval) {
|
||||||
|
|
||||||
stream->num_fields = fieldsV.size();
|
stream->num_fields = fieldsV.size();
|
||||||
stream->fields = fields->Ref()->AsRecordType();
|
stream->fields = fields->Ref()->AsRecordType();
|
||||||
stream->event = event_registry->Lookup(event->Name());
|
stream->event = event_registry->Lookup(event->GetName());
|
||||||
stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr;
|
stream->error_event = error_event ? event_registry->Lookup(error_event->GetName()) : nullptr;
|
||||||
stream->want_record = (want_record->InternalInt() == 1);
|
stream->want_record = (want_record->InternalInt() == 1);
|
||||||
|
|
||||||
assert(stream->reader);
|
assert(stream->reader);
|
||||||
|
@ -679,8 +679,8 @@ bool Manager::CreateTableStream(RecordVal* fval) {
|
||||||
stream->tab = dst.release()->AsTableVal();
|
stream->tab = dst.release()->AsTableVal();
|
||||||
stream->rtype = val.release();
|
stream->rtype = val.release();
|
||||||
stream->itype = idx->Ref()->AsRecordType();
|
stream->itype = idx->Ref()->AsRecordType();
|
||||||
stream->event = event ? event_registry->Lookup(event->Name()) : nullptr;
|
stream->event = event ? event_registry->Lookup(event->GetName()) : nullptr;
|
||||||
stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr;
|
stream->error_event = error_event ? event_registry->Lookup(error_event->GetName()) : nullptr;
|
||||||
stream->currDict = new PDict<InputHash>;
|
stream->currDict = new PDict<InputHash>;
|
||||||
stream->currDict->SetDeleteFunc(input_hash_delete_func);
|
stream->currDict->SetDeleteFunc(input_hash_delete_func);
|
||||||
stream->lastDict = new PDict<InputHash>;
|
stream->lastDict = new PDict<InputHash>;
|
||||||
|
|
|
@ -587,7 +587,7 @@ bool Manager::CreateStream(EnumVal* id, RecordVal* sval) {
|
||||||
streams[idx]->id = id->Ref()->AsEnumVal();
|
streams[idx]->id = id->Ref()->AsEnumVal();
|
||||||
streams[idx]->enabled = true;
|
streams[idx]->enabled = true;
|
||||||
streams[idx]->name = id->GetType()->AsEnumType()->Lookup(idx);
|
streams[idx]->name = id->GetType()->AsEnumType()->Lookup(idx);
|
||||||
streams[idx]->event = event ? event_registry->Lookup(event->Name()) : nullptr;
|
streams[idx]->event = event ? event_registry->Lookup(event->GetName()) : nullptr;
|
||||||
streams[idx]->policy = policy;
|
streams[idx]->policy = policy;
|
||||||
streams[idx]->columns = columns->Ref()->AsRecordType();
|
streams[idx]->columns = columns->Ref()->AsRecordType();
|
||||||
streams[idx]->max_delay_interval = sval->GetField("max_delay_interval")->AsInterval();
|
streams[idx]->max_delay_interval = sval->GetField("max_delay_interval")->AsInterval();
|
||||||
|
@ -1651,7 +1651,7 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
|
||||||
|
|
||||||
if ( f->postprocessor ) {
|
if ( f->postprocessor ) {
|
||||||
delete[] winfo->info->post_proc_func;
|
delete[] winfo->info->post_proc_func;
|
||||||
winfo->info->post_proc_func = util::copy_string(f->postprocessor->Name());
|
winfo->info->post_proc_func = util::copy_string(f->postprocessor->GetName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -784,7 +784,7 @@ void Ascii::RotateLeftoverLogs() {
|
||||||
reporter->Info("Rotated/postprocessed leftover log '%s' -> '%s' ", ll.filename.data(),
|
reporter->Info("Rotated/postprocessed leftover log '%s' -> '%s' ", ll.filename.data(),
|
||||||
rotation_path.data());
|
rotation_path.data());
|
||||||
} catch ( InterpreterException& e ) {
|
} catch ( InterpreterException& e ) {
|
||||||
reporter->Warning("Postprocess function '%s' failed for leftover log '%s'", ppf->Name(),
|
reporter->Warning("Postprocess function '%s' failed for leftover log '%s'", ppf->GetName().c_str(),
|
||||||
ll.filename.data());
|
ll.filename.data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ void HookArgument::Describe(ODesc* d) const {
|
||||||
|
|
||||||
case FUNC:
|
case FUNC:
|
||||||
if ( arg.func )
|
if ( arg.func )
|
||||||
d->Add(arg.func->Name());
|
d->Add(arg.func->GetName());
|
||||||
else
|
else
|
||||||
d->Add("<null>");
|
d->Add("<null>");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue