diff --git a/src/Frame.cc b/src/Frame.cc index c58d830d89..dd6e391adb 100644 --- a/src/Frame.cc +++ b/src/Frame.cc @@ -616,6 +616,11 @@ void Frame::CaptureClosure(Frame* c, IDPList arg_outer_ids) // if (c) closure = c->SelectiveClone(outer_ids); } +const detail::Location* Frame::GetCallLocation() const + { + return call ? call->GetLocationInfo() : nullptr; + } + void Frame::SetTrigger(trigger::TriggerPtr arg_trigger) { trigger = std::move(arg_trigger); diff --git a/src/Frame.h b/src/Frame.h index 36d775ef9f..4188dded27 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -262,6 +262,7 @@ public: void SetCall(const CallExpr* arg_call) { call = arg_call; } void ClearCall() { call = nullptr; } const CallExpr* GetCall() const { return call; } + const detail::Location* GetCallLocation() const; void SetDelayed() { delayed = true; } bool HasDelayed() const { return delayed; } diff --git a/src/broker/Data.cc b/src/broker/Data.cc index a54e30287c..2af93460bd 100644 --- a/src/broker/Data.cc +++ b/src/broker/Data.cc @@ -1177,7 +1177,7 @@ broker::data& opaque_field_to_data(RecordVal* v, zeek::detail::Frame* f) const auto& d = v->GetField(0); if ( ! d ) - reporter->RuntimeError(f->GetCall()->GetLocationInfo(), + reporter->RuntimeError(f->GetCallLocation(), "Broker::Data's opaque field is not set"); // RuntimeError throws an exception which causes this line to never exceute. diff --git a/src/broker/Data.h b/src/broker/Data.h index a3db6c1514..feb58e3806 100644 --- a/src/broker/Data.h +++ b/src/broker/Data.h @@ -194,7 +194,7 @@ T& require_data_type(broker::data& d, zeek::TypeTag tag, zeek::detail::Frame* f) { auto ptr = caf::get_if(&d); if ( ! ptr ) - zeek::reporter->RuntimeError(f->GetCall()->GetLocationInfo(), + zeek::reporter->RuntimeError(f->GetCallLocation(), "data is of type '%s' not of type '%s'", caf::visit(type_name_getter{tag}, d), zeek::type_name(tag)); diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index 3d682ea4ab..0ce23d9508 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -74,7 +74,7 @@ int Manager::script_scope = 0; struct scoped_reporter_location { scoped_reporter_location(zeek::detail::Frame* frame) { - reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->PushLocation(frame->GetCallLocation()); } ~scoped_reporter_location() diff --git a/src/reporter.bif b/src/reporter.bif index 950b58f846..523195debb 100644 --- a/src/reporter.bif +++ b/src/reporter.bif @@ -22,7 +22,7 @@ module Reporter; ## .. zeek:see:: reporter_info function Reporter::info%(msg: string%): bool %{ - reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->PushLocation(frame->GetCallLocation()); reporter->Info("%s", msg->CheckString()); reporter->PopLocation(); return zeek::val_mgr->True(); @@ -37,7 +37,7 @@ function Reporter::info%(msg: string%): bool ## .. zeek:see:: reporter_warning function Reporter::warning%(msg: string%): bool %{ - reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->PushLocation(frame->GetCallLocation()); reporter->Warning("%s", msg->CheckString()); reporter->PopLocation(); return zeek::val_mgr->True(); @@ -53,7 +53,7 @@ function Reporter::warning%(msg: string%): bool ## .. zeek:see:: reporter_error function Reporter::error%(msg: string%): bool %{ - reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->PushLocation(frame->GetCallLocation()); reporter->Error("%s", msg->CheckString()); reporter->PopLocation(); return zeek::val_mgr->True(); @@ -66,7 +66,7 @@ function Reporter::error%(msg: string%): bool ## Returns: Always true. function Reporter::fatal%(msg: string%): bool %{ - reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->PushLocation(frame->GetCallLocation()); reporter->FatalError("%s", msg->CheckString()); reporter->PopLocation(); return zeek::val_mgr->True(); @@ -80,7 +80,7 @@ function Reporter::fatal%(msg: string%): bool ## Returns: Always true. function Reporter::fatal_error_with_core%(msg: string%): bool %{ - reporter->PushLocation(frame->GetCall()->GetLocationInfo()); + reporter->PushLocation(frame->GetCallLocation()); reporter->FatalErrorWithCore("%s", msg->CheckString()); reporter->PopLocation(); return zeek::val_mgr->True();