better error reporting when ZAM code calls a function

This commit is contained in:
Vern Paxson 2023-02-09 11:24:35 -08:00
parent 1b6df1a04c
commit 2c9857a618
33 changed files with 38 additions and 52 deletions

@ -1 +1 @@
Subproject commit 1944debe324787866e352f2e4f93acdfd3c6b821 Subproject commit 3b636493c616e77bb8133036eddc911efd0be25a

View file

@ -206,7 +206,9 @@ std::pair<bool, FramePtr> Frame::Unserialize(const broker::vector& data,
const detail::Location* Frame::GetCallLocation() const const detail::Location* Frame::GetCallLocation() const
{ {
return call ? call->GetLocationInfo() : call_loc; // This is currently trivial, but we keep it as an explicit
// method because it can provide flexibility for compiled code.
return call->GetLocationInfo();
} }
void Frame::SetTrigger(trigger::TriggerPtr arg_trigger) void Frame::SetTrigger(trigger::TriggerPtr arg_trigger)

View file

@ -200,7 +200,6 @@ public:
void SetTriggerAssoc(const void* arg_assoc) { assoc = arg_assoc; } void SetTriggerAssoc(const void* arg_assoc) { assoc = arg_assoc; }
const void* GetTriggerAssoc() const { return assoc; } const void* GetTriggerAssoc() const { return assoc; }
void SetCallLoc(const Location* loc) { call_loc = loc; }
const detail::Location* GetCallLocation() const; const detail::Location* GetCallLocation() const;
void SetDelayed() { delayed = true; } void SetDelayed() { delayed = true; }
@ -254,7 +253,6 @@ private:
trigger::TriggerPtr trigger; trigger::TriggerPtr trigger;
const CallExpr* call = nullptr; const CallExpr* call = nullptr;
const void* assoc = nullptr; const void* assoc = nullptr;
const Location* call_loc = nullptr; // only needed if call is nil
}; };
} // namespace detail } // namespace detail

View file

@ -1025,6 +1025,8 @@ const ZAMStmt ZAMCompiler::DoCall(const CallExpr* c, const NameExpr* n)
z.aux->can_change_globals = true; z.aux->can_change_globals = true;
z.call_expr = c;
if ( ! indirect || func_id->IsGlobal() ) if ( ! indirect || func_id->IsGlobal() )
{ {
z.aux->id_val = func_id; z.aux->id_val = func_id;

View file

@ -127,6 +127,10 @@ public:
// Location associated with this instruction, for error reporting. // Location associated with this instruction, for error reporting.
const Location* loc = nullptr; const Location* loc = nullptr;
// Interpreter call expression associated with this instruction,
// for error reporting and stack backtraces.
const CallExpr* call_expr = nullptr;
// Whether v1 represents a frame slot type for which we // Whether v1 represents a frame slot type for which we
// explicitly manage the memory. // explicitly manage the memory.
bool is_managed = false; bool is_managed = false;

View file

@ -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: cat_sep() takes at least 2 arguments, got 1 error in <...>/cat_sep_errors.zeek, line 3: cat_sep() takes at least 2 arguments, got 1 (cat_sep(sep))

View file

@ -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: expected type string for default, got count error in <...>/cat_sep_errors.zeek, line 4: expected type string for default, got count (cat_sep(sep, 1))

View file

@ -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: expected type string for separator, got count error in <...>/cat_sep_errors.zeek, line 4: expected type string for separator, got count (cat_sep(1, default))

View file

@ -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: expected type string for separator, got record error in <...>/cat_sep_errors.zeek, line 3: expected type string for separator, got record (cat_sep(<internal>::#0, default))

View file

@ -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: cat_sep() takes at least 2 arguments, got 0 error in <...>/cat_sep_errors.zeek, line 6: cat_sep() takes at least 2 arguments, got 0 (cat_sep())

View file

@ -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 <...>/to_addr.zeek, line 20: failed converting string to IP address (not an IP) error in <...>/to_addr.zeek, line 7 and <...>/to_addr.zeek, line 20: failed converting string to IP address (to_addr(not an IP) and not an IP)

View file

@ -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 <...>/to_double_from_string.zeek, line 15: bad conversion to double (NotADouble) error in <...>/to_double_from_string.zeek, line 7 and <...>/to_double_from_string.zeek, line 15: bad conversion to double (to_double(NotADouble) and NotADouble)
error in <...>/to_double_from_string.zeek, line 16: bad conversion to double () error in <...>/to_double_from_string.zeek, line 7 and <...>/to_double_from_string.zeek, line 16: bad conversion to double (to_double() and )

View file

@ -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 <...>/to_subnet.zeek, line 10: failed converting string to IP prefix (10.0.0.0) error in <...>/to_subnet.zeek, line 10: failed converting string to IP prefix (to_subnet(10.0.0.0) and 10.0.0.0)
error in <...>/to_subnet.zeek, line 12: failed converting string to IP prefix (10.0.0.0/222) error in <...>/to_subnet.zeek, line 12: failed converting string to IP prefix (to_subnet(10.0.0.0/222) and 10.0.0.0/222)
error in <...>/to_subnet.zeek, line 14: failed converting string to IP prefix (don't work) error in <...>/to_subnet.zeek, line 14: failed converting string to IP prefix (to_subnet(don't work) and don't work)

View file

@ -1,9 +1,9 @@
### 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 <...>/store.zeek, line 780: Failed to attach master store backend_failure: (Broker::__create_master(../fail, Broker::SQLITE, Broker::options.2))
error: Could not create Broker master store '../fail' error in <...>/store.zeek, line 780: Could not create Broker master store '../fail' (Broker::__create_master(../fail, Broker::SQLITE, Broker::options.2))
error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{}) error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{})
error in <...>/store.zeek, line 744: invalid Broker store handle (Broker::__close(Broker::h) and broker::store::{}) error in <...>/store.zeek, line 794: invalid Broker store handle (Broker::__close(Broker::h) and broker::store::{})
error in <...>/store.zeek, line 744: invalid Broker store handle (Broker::__close(Broker::h) and broker::store::{}) error in <...>/store.zeek, line 794: invalid Broker store handle (Broker::__close(Broker::h) and broker::store::{})
error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{}) error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{})
error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{}) error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{})
error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{}) error in <...>/create-failure.zeek, line 49: invalid Broker store handle (Broker::keys(s) and broker::store::{})

View file

@ -1,3 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error: no such event group: my-group
disable non existing event group, F

View file

@ -1,3 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error: no such event group: MyModule
enabling non existing module event group, F

View file

@ -1,3 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error: no such event group: MyModule
disable non existing module event group, F

View file

@ -1,3 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
error: no such event group: my-group
enable non existing event group, F

View file

@ -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: ID 'A' is not an option error in <...>/option-runtime-errors.zeek, line 7: ID 'A' is not an option (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Option::on_change needs function argument; got 'count' for ID 'A' error in <...>/option-runtime-errors.zeek, line 4: Option::on_change needs function argument; got 'count' for ID 'A' (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Third argument of passed function has to be string in Option::on_change for ID 'A'; got 'count' error in <...>/option-runtime-errors.zeek, line 7: Third argument of passed function has to be string in Option::on_change for ID 'A'; got 'count' (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Wrong number of arguments for passed function in Option::on_change for ID 'A'; expected 2 or 3, got 4 error in <...>/option-runtime-errors.zeek, line 7: Wrong number of arguments for passed function in Option::on_change for ID 'A'; expected 2 or 3, got 4 (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Incompatible type for set of ID 'A': got 'string', need 'count' error in <...>/option-runtime-errors.zeek, line 3: Incompatible type for set of ID 'A': got 'string', need 'count' (Option::set(A, hi, ))

View file

@ -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: ID 'A' is not an option error in <...>/option-runtime-errors.zeek, line 3: ID 'A' is not an option (Option::set(A, 6, ))

View file

@ -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: Second argument of passed function has to be count in Option::on_change for ID 'A'; got 'bool' error in <...>/option-runtime-errors.zeek, line 7: Second argument of passed function has to be count in Option::on_change for ID 'A'; got 'bool' (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Wrong number of arguments for passed function in Option::on_change for ID 'A'; expected 2 or 3, got 1 error in <...>/option-runtime-errors.zeek, line 7: Wrong number of arguments for passed function in Option::on_change for ID 'A'; expected 2 or 3, got 1 (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Passed function needs to return type 'count' for ID 'A'; got 'bool' error in <...>/option-runtime-errors.zeek, line 7: Passed function needs to return type 'count' for ID 'A'; got 'bool' (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Option::on_change needs function argument; not hook or event error in <...>/option-runtime-errors.zeek, line 7: Option::on_change needs function argument; not hook or event (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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.
warning in <...>/option-runtime-errors.zeek, line 4: handler for non-existing event cannot be invoked (option_changed) warning in <...>/option-runtime-errors.zeek, line 4: handler for non-existing event cannot be invoked (option_changed)
error: Option::on_change needs function argument; not hook or event error in <...>/option-runtime-errors.zeek, line 7: Option::on_change needs function argument; not hook or event (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Could not find ID named 'A' error in <...>/option-runtime-errors.zeek, line 5: Could not find ID named 'A' (Option::set_change_handler(A, <internal>::#0, 0))

View file

@ -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: Could not find ID named 'B' error in <...>/option-runtime-errors.zeek, line 9: Could not find ID named 'B' (Option::set(B, 6, ))

View file

@ -1,2 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
runtime error: too many arguments for function call

View file

@ -1,6 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
zeek_init() &priority=10
l=a local x=1
zeek_init() &priority=-10
l=a local x=1
l=a local x=1