zeek/src/ScriptCoverageManager.h
Josh Soref cd201aa24e Spelling src
These are non-functional changes.

* accounting
* activation
* actual
* added
* addresult
* aggregable
* aligned
* alternatively
* ambiguous
* analysis
* analyzer
* anticlimactic
* apparently
* application
* appropriate
* arithmetic
* assignment
* assigns
* associated
* authentication
* authoritative
* barrier
* boundary
* broccoli
* buffering
* caching
* called
* canonicalized
* capturing
* certificates
* ciphersuite
* columns
* communication
* comparison
* comparisons
* compilation
* component
* concatenating
* concatenation
* connection
* convenience
* correctly
* corresponding
* could
* counting
* data
* declared
* decryption
* defining
* dependent
* deprecated
* detached
* dictionary
* directional
* directly
* directory
* discarding
* disconnecting
* distinguishes
* documentation
* elsewhere
* emitted
* empty
* endianness
* endpoint
* enumerator
* essentially
* evaluated
* everything
* exactly
* execute
* explicit
* expressions
* facilitates
* fiddling
* filesystem
* flag
* flagged
* for
* fragments
* guarantee
* guaranteed
* happen
* happening
* hemisphere
* identifier
* identifies
* identify
* implementation
* implemented
* implementing
* including
* inconsistency
* indeterminate
* indices
* individual
* information
* initial
* initialization
* initialize
* initialized
* initializes
* instantiate
* instantiated
* instantiates
* interface
* internal
* interpreted
* interpreter
* into
* it
* iterators
* length
* likely
* log
* longer
* mainly
* mark
* maximum
* message
* minimum
* module
* must
* name
* namespace
* necessary
* nonexistent
* not
* notifications
* notifier
* number
* objects
* occurred
* operations
* original
* otherwise
* output
* overridden
* override
* overriding
* overwriting
* ownership
* parameters
* particular
* payload
* persistent
* potential
* precision
* preexisting
* preservation
* preserved
* primarily
* probably
* procedure
* proceed
* process
* processed
* processes
* processing
* propagate
* propagated
* prototype
* provides
* publishing
* purposes
* queue
* reached
* reason
* reassem
* reassemble
* reassembler
* recommend
* record
* reduction
* reference
* regularly
* representation
* request
* reserved
* retrieve
* returning
* separate
* should
* shouldn't
* significant
* signing
* simplified
* simultaneously
* single
* somebody
* sources
* specific
* specification
* specified
* specifies
* specify
* statement
* subdirectories
* succeeded
* successful
* successfully
* supplied
* synchronization
* tag
* temporarily
* terminating
* that
* the
* transmitted
* true
* truncated
* try
* understand
* unescaped
* unforwarding
* unknown
* unknowndata
* unspecified
* update
* usually
* which
* wildcard

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-11-09 12:08:15 -05:00

95 lines
2.2 KiB
C++

#pragma once
#include <list>
#include <map>
#include <string>
#include <utility>
#include "zeek/util.h"
namespace zeek::detail
{
class Stmt;
/**
* A simple class for managing stats of Zeek script coverage across Zeek runs.
*/
class ScriptCoverageManager
{
public:
ScriptCoverageManager();
virtual ~ScriptCoverageManager();
/**
* Imports Zeek script Stmt usage information from file pointed to by
* environment variable ZEEK_PROFILER_FILE.
*
* @return: true if usage info was read, otherwise false.
*/
bool ReadStats();
/**
* Combines usage stats from current run with any read from ReadStats(),
* then writes information to file pointed to by environment variable
* ZEEK_PROFILER_FILE. If the value of that env. variable ends with
* ".XXXXXX" (exactly 6 X's), then it is first passed through mkstemp
* to get a unique file.
*
* @return: true when usage info is written, otherwise false.
*/
bool WriteStats();
void SetDelim(char d) { delim = d; }
void IncIgnoreDepth() { ignoring++; }
void DecIgnoreDepth() { ignoring--; }
void AddStmt(Stmt* s);
private:
/**
* The current, global ScriptCoverageManager instance creates this list at parse-time.
*/
std::list<Stmt*> stmts;
/**
* Indicates whether new statements will not be considered as part of
* coverage statistics because it was marked with the @no-test tag.
*/
uint32_t ignoring;
/**
* The character to use to delimit ScriptCoverageManager output files. Default is '\t'.
*/
char delim;
/**
* This maps Stmt location-desc pairs to the total number of times that
* Stmt has been executed. The map can be initialized from a file at
* startup time and modified at shutdown time before writing back
* to a file.
*/
std::map<std::pair<std::string, std::string>, uint64_t> usage_map;
/**
* A canonicalization routine for Stmt descriptions containing characters
* that don't agree with the output format of ScriptCoverageManager.
*/
struct canonicalize_desc
{
char delim;
void operator()(char& c)
{
if ( c == '\n' )
c = ' ';
if ( c == delim )
c = ' ';
}
};
};
extern ScriptCoverageManager script_coverage_mgr;
} // namespace zeek::detail