mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Add script-layer call stack to internal errors messages that abort
This commit is contained in:
parent
a7ba44089b
commit
b2560384c4
7 changed files with 66 additions and 12 deletions
26
src/Func.cc
26
src/Func.cc
|
@ -56,6 +56,32 @@ bool did_builtin_init = false;
|
|||
vector<Func*> Func::unique_ids;
|
||||
static const std::pair<bool, Val*> empty_hook_result(false, NULL);
|
||||
|
||||
std::string render_call_stack()
|
||||
{
|
||||
std::string rval;
|
||||
int lvl = 0;
|
||||
|
||||
if ( ! call_stack.empty() )
|
||||
rval += "| ";
|
||||
|
||||
for ( auto it = call_stack.rbegin(); it != call_stack.rend(); ++it )
|
||||
{
|
||||
if ( lvl > 0 )
|
||||
rval += " | ";
|
||||
|
||||
auto& ci = *it;
|
||||
auto loc = ci.call->GetLocationInfo();
|
||||
auto name = ci.func->Name();
|
||||
rval += fmt("#%d %s() at %s:%d", lvl, name, loc->filename, loc->first_line);
|
||||
++lvl;
|
||||
}
|
||||
|
||||
if ( ! call_stack.empty() )
|
||||
rval += " |";
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
Func::Func() : scope(0), type(0)
|
||||
{
|
||||
unique_id = unique_ids.size();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue