mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00
address some holes in script coverage
This commit is contained in:
parent
2bb4e696e1
commit
ca32cab6cb
3 changed files with 16 additions and 10 deletions
|
@ -127,27 +127,27 @@ bool ScriptCoverageManager::WriteStats()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( list<Stmt*>::const_iterator it = stmts.begin(); it != stmts.end(); ++it )
|
for ( auto s : stmts )
|
||||||
{
|
{
|
||||||
ODesc location_info;
|
ODesc location_info;
|
||||||
(*it)->GetLocationInfo()->Describe(&location_info);
|
s->GetLocationInfo()->Describe(&location_info);
|
||||||
ODesc desc_info;
|
ODesc desc_info;
|
||||||
(*it)->Describe(&desc_info);
|
s->Describe(&desc_info);
|
||||||
string desc(desc_info.Description());
|
string desc(desc_info.Description());
|
||||||
canonicalize_desc cd{delim};
|
canonicalize_desc cd{delim};
|
||||||
for_each(desc.begin(), desc.end(), cd);
|
for_each(desc.begin(), desc.end(), cd);
|
||||||
pair<string, string> location_desc(location_info.Description(), desc);
|
pair<string, string> location_desc(location_info.Description(), desc);
|
||||||
if ( usage_map.find(location_desc) != usage_map.end() )
|
if ( usage_map.find(location_desc) != usage_map.end() )
|
||||||
usage_map[location_desc] += (*it)->GetAccessCount();
|
usage_map[location_desc] += s->GetAccessCount();
|
||||||
else
|
else
|
||||||
usage_map[location_desc] = (*it)->GetAccessCount();
|
usage_map[location_desc] = s->GetAccessCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
map<pair<string, string>, uint64_t>::const_iterator it;
|
map<pair<string, string>, uint64_t>::const_iterator it;
|
||||||
for ( it = usage_map.begin(); it != usage_map.end(); ++it )
|
for ( auto& um : usage_map )
|
||||||
{
|
{
|
||||||
fprintf(f, "%" PRIu64 "%c%s%c%s\n", it->second, delim, it->first.first.c_str(), delim,
|
fprintf(f, "%" PRIu64 "%c%s%c%s\n", um.second, delim, um.first.first.c_str(), delim,
|
||||||
it->first.second.c_str());
|
um.first.second.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
|
@ -258,7 +258,7 @@ ExprListStmt::~ExprListStmt() = default;
|
||||||
|
|
||||||
ValPtr ExprListStmt::Exec(Frame* f, StmtFlowType& flow)
|
ValPtr ExprListStmt::Exec(Frame* f, StmtFlowType& flow)
|
||||||
{
|
{
|
||||||
last_access = run_state::network_time;
|
RegisterAccess();
|
||||||
flow = FLOW_NEXT;
|
flow = FLOW_NEXT;
|
||||||
|
|
||||||
auto vals = eval_list(f, l.get());
|
auto vals = eval_list(f, l.get());
|
||||||
|
@ -325,7 +325,6 @@ static void print_log(const std::vector<ValPtr>& vals)
|
||||||
|
|
||||||
ValPtr PrintStmt::DoExec(std::vector<ValPtr> vals, StmtFlowType& /* flow */)
|
ValPtr PrintStmt::DoExec(std::vector<ValPtr> vals, StmtFlowType& /* flow */)
|
||||||
{
|
{
|
||||||
RegisterAccess();
|
|
||||||
do_print_stmt(vals);
|
do_print_stmt(vals);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1665,28 +1665,33 @@ stmt:
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, make_intrusive<NullStmt>());
|
$$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, make_intrusive<NullStmt>());
|
||||||
|
script_coverage_mgr.AddStmt($$);
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_IF '(' expr ')' stmt TOK_ELSE stmt
|
| TOK_IF '(' expr ')' stmt TOK_ELSE stmt
|
||||||
{
|
{
|
||||||
set_location(@1, @4);
|
set_location(@1, @4);
|
||||||
$$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, {AdoptRef{}, $7});
|
$$ = new IfStmt({AdoptRef{}, $3}, {AdoptRef{}, $5}, {AdoptRef{}, $7});
|
||||||
|
script_coverage_mgr.AddStmt($$);
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_SWITCH expr '{' case_list '}'
|
| TOK_SWITCH expr '{' case_list '}'
|
||||||
{
|
{
|
||||||
set_location(@1, @2);
|
set_location(@1, @2);
|
||||||
$$ = new SwitchStmt({AdoptRef{}, $2}, $4);
|
$$ = new SwitchStmt({AdoptRef{}, $2}, $4);
|
||||||
|
script_coverage_mgr.AddStmt($$);
|
||||||
}
|
}
|
||||||
|
|
||||||
| for_head stmt
|
| for_head stmt
|
||||||
{
|
{
|
||||||
$1->AsForStmt()->AddBody({AdoptRef{}, $2});
|
$1->AsForStmt()->AddBody({AdoptRef{}, $2});
|
||||||
|
script_coverage_mgr.AddStmt($1);
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_WHILE '(' expr ')' stmt
|
| TOK_WHILE '(' expr ')' stmt
|
||||||
{
|
{
|
||||||
$$ = new WhileStmt({AdoptRef{}, $3}, {AdoptRef{}, $5});
|
$$ = new WhileStmt({AdoptRef{}, $3}, {AdoptRef{}, $5});
|
||||||
|
script_coverage_mgr.AddStmt($$);
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_NEXT ';' opt_no_test
|
| TOK_NEXT ';' opt_no_test
|
||||||
|
@ -1762,6 +1767,7 @@ stmt:
|
||||||
| when_clause
|
| when_clause
|
||||||
{
|
{
|
||||||
$$ = new WhenStmt($1);
|
$$ = new WhenStmt($1);
|
||||||
|
script_coverage_mgr.AddStmt($$);
|
||||||
}
|
}
|
||||||
|
|
||||||
| index_slice '=' expr ';' opt_no_test
|
| index_slice '=' expr ';' opt_no_test
|
||||||
|
@ -1786,6 +1792,7 @@ stmt:
|
||||||
{
|
{
|
||||||
set_location(@1, @1);
|
set_location(@1, @1);
|
||||||
$$ = new NullStmt;
|
$$ = new NullStmt;
|
||||||
|
script_coverage_mgr.AddStmt($$);
|
||||||
}
|
}
|
||||||
|
|
||||||
| conditional
|
| conditional
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue