mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
new function for getting the location, if any, associated with the current call
This commit is contained in:
parent
8fb30f1d62
commit
8f2637decb
6 changed files with 14 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -194,7 +194,7 @@ T& require_data_type(broker::data& d, zeek::TypeTag tag, zeek::detail::Frame* f)
|
|||
{
|
||||
auto ptr = caf::get_if<T>(&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));
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue