Move all debugger code into the zeek::detail namespace

This commit is contained in:
Tim Wojtulewicz 2020-07-16 10:56:15 -07:00
parent 834b76f94f
commit 35c61697d9
17 changed files with 525 additions and 419 deletions

View file

@ -15,6 +15,8 @@
using namespace std;
namespace zeek::detail {
Brofiler::Brofiler()
: ignoring(0), delim('\t')
{
@ -154,3 +156,5 @@ bool Brofiler::WriteStats()
fclose(f);
return true;
}
} // namespace zeek::detail

View file

@ -8,6 +8,8 @@
#include "util.h"
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
namespace zeek::detail {
/**
* A simple class for managing stats of Bro script coverage across Bro runs.
*/
@ -83,3 +85,8 @@ private:
};
extern Brofiler brofiler;
} // namespace zeek::detail
using Brofiler [[deprecated("Remove in v4.1. Use zeek::detail::Brofiler.")]] = zeek::detail::Brofiler;
extern zeek::detail::Brofiler& brofiler [[deprecated("Remove in v4.1. Use zeek::detail::brofiler.")]];

View file

@ -19,6 +19,8 @@
#include "Reporter.h"
#include "module_util.h"
namespace zeek::detail {
// BreakpointTimer used for time-based breakpoints
class BreakpointTimer final : public Timer {
public:
@ -121,13 +123,13 @@ void DbgBreakpoint::RemoveFromStmt()
bool DbgBreakpoint::SetLocation(ParseLocationRec plr, std::string_view loc_str)
{
if ( plr.type == plrUnknown )
if ( plr.type == PLR_UNKNOWN )
{
debug_msg("Breakpoint specifier invalid or operation canceled.\n");
return false;
}
if ( plr.type == plrFileAndLine )
if ( plr.type == PLR_FILE_AND_LINE )
{
kind = BP_LINE;
source_filename = plr.filename;
@ -146,7 +148,7 @@ bool DbgBreakpoint::SetLocation(ParseLocationRec plr, std::string_view loc_str)
debug_msg("Breakpoint %d set at %s\n", GetID(), Description());
}
else if ( plr.type == plrFunction )
else if ( plr.type == PLR_FUNCTION )
{
std::string loc_s(loc_str);
kind = BP_FUNC;
@ -211,7 +213,7 @@ bool DbgBreakpoint::Reset()
case BP_FUNC:
case BP_STMT:
case BP_LINE:
plr.type = plrFunction;
plr.type = PLR_FUNCTION;
//### How to deal with wildcards?
//### perhaps save user choices?--tough...
break;
@ -240,7 +242,7 @@ BreakCode DbgBreakpoint::HasHit()
if ( temporary )
{
SetEnable(false);
return bcHitAndDelete;
return BC_HIT_AND_DELETE;
}
if ( condition.size() )
@ -254,7 +256,7 @@ BreakCode DbgBreakpoint::HasHit()
condition.c_str());
SetCondition("");
PrintHitMsg();
return bcHit;
return BC_HIT;
}
if ( ! zeek::IsIntegral(yes->GetType()->Tag()) &&
@ -262,13 +264,13 @@ BreakCode DbgBreakpoint::HasHit()
{
PrintHitMsg();
debug_msg("Breakpoint condition should return an integral type");
return bcHitAndDelete;
return BC_HIT_AND_DELETE;
}
yes->CoerceToInt();
if ( yes->IsZero() )
{
return bcNoHit;
return BC_NO_HIT;
}
}
@ -279,26 +281,26 @@ BreakCode DbgBreakpoint::HasHit()
{
hit_count = 0;
PrintHitMsg();
return bcHit;
return BC_HIT;
}
return bcNoHit;
return BC_NO_HIT;
}
PrintHitMsg();
return bcHit;
return BC_HIT;
}
BreakCode DbgBreakpoint::ShouldBreak(zeek::detail::Stmt* s)
{
if ( ! IsEnabled() )
return bcNoHit;
return BC_NO_HIT;
switch ( kind ) {
case BP_STMT:
case BP_FUNC:
if ( at_stmt != s )
return bcNoHit;
return BC_NO_HIT;
break;
case BP_LINE:
@ -330,10 +332,10 @@ BreakCode DbgBreakpoint::ShouldBreak(double t)
reporter->InternalError("Calling ShouldBreak(time) on a non-time breakpoint");
if ( t < at_time )
return bcNoHit;
return BC_NO_HIT;
if ( ! IsEnabled() )
return bcNoHit;
return BC_NO_HIT;
BreakCode code = HasHit();
if ( code )
@ -371,3 +373,5 @@ void DbgBreakpoint::PrintHitMsg()
reporter->InternalError("Missed a case in DbgBreakpoint::PrintHitMsg\n");
}
}
} // namespace zeek::detail

View file

@ -5,11 +5,12 @@
#include <string>
#include "util.h"
struct ParseLocationRec;
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(ParseLocationRec, zeek::detail);
enum BreakCode { bcNoHit, bcHit, bcHitAndDelete };
namespace zeek::detail {
enum BreakCode { BC_NO_HIT, BC_HIT, BC_HIT_AND_DELETE };
class DbgBreakpoint {
enum Kind { BP_STMT = 0, BP_FUNC, BP_LINE, BP_TIME };
@ -81,3 +82,15 @@ protected:
std::string condition; // condition to evaluate; nil for none
};
} // namespace zeek::detail
using DbgBreakPoint [[deprecated("Remove in v4.1. Use zeek::detail::DbgBreakpoint.")]] = zeek::detail::DbgBreakpoint;
using BreakCode [[deprecated("Remove in v4.1. Use zeek::detail::BreakCode.")]] = zeek::detail::BreakCode;
[[deprecated("Remove in v4.1. Use zeek::detail::BC_NO_HIT.")]]
constexpr auto bcNoHit = zeek::detail::BC_NO_HIT;
[[deprecated("Remove in v4.1. Use zeek::detail::BC_HIT.")]]
constexpr auto bcHit = zeek::detail::BC_HIT;
[[deprecated("Remove in v4.1. Use zeek::detail::BC_HIT_AND_DELETE.")]]
constexpr auto bcHitAndDelete = zeek::detail::BC_HIT_AND_DELETE;

View file

@ -2,7 +2,9 @@
#pragma once
class Expr;
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
namespace zeek::detail {
// Automatic displays: display these at each stoppage.
class DbgDisplay {
@ -23,3 +25,7 @@ protected:
bool enabled;
Expr* expression;
};
} // namespace zeek::detail
using DbgDisplay [[deprecated("Remove in v4.1. Use zeek::detail::DbgDisplay.")]] = zeek::detail::DbgDisplay;

View file

@ -7,16 +7,12 @@
#include "Reporter.h"
// Support classes
DbgWatch::DbgWatch(zeek::Obj* var_to_watch)
zeek::detail::DbgWatch::DbgWatch(zeek::Obj* var_to_watch)
{
reporter->InternalError("DbgWatch unimplemented");
}
DbgWatch::DbgWatch(zeek::detail::Expr* expr_to_watch)
zeek::detail::DbgWatch::DbgWatch(zeek::detail::Expr* expr_to_watch)
{
reporter->InternalError("DbgWatch unimplemented");
}
DbgWatch::~DbgWatch()
{
}

View file

@ -8,13 +8,19 @@ ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
namespace zeek { class Obj; }
using BroObj [[deprecated("Remove in v4.1. Use zeek:Obj instead.")]] = zeek::Obj;
namespace zeek::detail {
class DbgWatch {
public:
explicit DbgWatch(zeek::Obj* var_to_watch);
explicit DbgWatch(zeek::detail::Expr* expr_to_watch);
~DbgWatch();
~DbgWatch() = default;
protected:
zeek::Obj* var;
zeek::detail::Expr* expr;
};
} // namespace zeek::detail
using DbgWatch [[deprecated("Remove in v4.1. Using zeek::detail::DbgWatch.")]] = zeek::detail::DbgWatch;

View file

@ -35,10 +35,17 @@ using namespace std;
#include <readline/history.h>
#endif
bool g_policy_debug = false;
DebuggerState g_debugger_state;
TraceState g_trace_state;
std::map<string, Filemap*> g_dbgfilemaps;
bool zeek::detail::g_policy_debug = false;
bool& g_policy_debug = zeek::detail::g_policy_debug;
zeek::detail::DebuggerState zeek::detail::g_debugger_state;
zeek::detail::DebuggerState& g_debugger_state = zeek::detail::g_debugger_state;
zeek::detail::TraceState zeek::detail::g_trace_state;
zeek::detail::TraceState& g_trace_state = zeek::detail::g_trace_state;
std::map<string, zeek::detail::Filemap*> zeek::detail::g_dbgfilemaps;
std::map<string, zeek::detail::Filemap*>& g_dbgfilemaps = zeek::detail::g_dbgfilemaps;
// These variables are used only to decide whether or not to print the
// current context; you don't want to do it after a step or next
@ -46,6 +53,24 @@ std::map<string, Filemap*> g_dbgfilemaps;
static bool step_or_next_pending = false;
static zeek::detail::Frame* last_frame;
// The following values are needed by parse.y.
// Evaluates the given expression in the context of the currently selected
// frame. Returns the resulting value, or nil if none (or there was an error).
zeek::detail::Expr* g_curr_debug_expr = nullptr;
const char* g_curr_debug_error = nullptr;
bool in_debug = false;
// ### fix this hardwired access to external variables etc.
struct yy_buffer_state;
typedef struct yy_buffer_state* YY_BUFFER_STATE;
YY_BUFFER_STATE bro_scan_string(const char*);
extern YYLTYPE yylloc; // holds start line and column of token
extern int line_number;
extern const char* filename;
namespace zeek::detail {
DebuggerState::DebuggerState()
{
next_bp_id = next_watch_id = next_display_id = 1;
@ -195,7 +220,7 @@ void get_first_statement(zeek::detail::Stmt* list, zeek::detail::Stmt*& first, z
}
static void parse_function_name(vector<ParseLocationRec>& result,
ParseLocationRec& plr, const string& s)
ParseLocationRec& plr, const string& s)
{ // function name
const auto& id = zeek::detail::lookup_ID(s.c_str(), zeek::detail::current_module.c_str());
@ -203,21 +228,21 @@ static void parse_function_name(vector<ParseLocationRec>& result,
{
string fullname = make_full_var_name(zeek::detail::current_module.c_str(), s.c_str());
debug_msg("Function %s not defined.\n", fullname.c_str());
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return;
}
if ( ! id->GetType()->AsFuncType() )
{
debug_msg("Function %s not declared.\n", id->Name());
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return;
}
if ( ! id->HasVal() )
{
debug_msg("Function %s declared but not defined.\n", id->Name());
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return;
}
@ -227,7 +252,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
if ( bodies.size() == 0 )
{
debug_msg("Function %s is a built-in function\n", id->Name());
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return;
}
@ -256,7 +281,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
char charinput[256];
if ( ! fgets(charinput, sizeof(charinput) - 1, stdin) )
{
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return;
}
@ -270,7 +295,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
if ( input == "n" )
{
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return;
}
@ -283,7 +308,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
}
}
plr.type = plrFunction;
plr.type = PLR_FUNCTION;
// Find first atomic (non-STMT_LIST) statement
zeek::detail::Stmt* first;
@ -311,7 +336,7 @@ static void parse_function_name(vector<ParseLocationRec>& result,
if ( ! first )
continue;
plr.type = plrFunction;
plr.type = PLR_FUNCTION;
plr.stmt = first;
plr.filename = stmt_loc.filename;
plr.line = stmt_loc.last_line;
@ -326,7 +351,7 @@ vector<ParseLocationRec> parse_location_string(const string& s)
result.push_back(ParseLocationRec());
ParseLocationRec& plr = result[0];
// If plrFileAndLine, set this to the filename you want; for
// If PLR_FILE_AND_LINE, set this to the filename you want; for
// memory management reasons, the real filename is set when looking
// up the line number to find the corresponding statement.
std::string loc_filename;
@ -334,7 +359,7 @@ vector<ParseLocationRec> parse_location_string(const string& s)
if ( sscanf(s.c_str(), "%d", &plr.line) )
{ // just a line number (implicitly referring to the current file)
loc_filename = g_debugger_state.last_loc.filename;
plr.type = plrFileAndLine;
plr.type = PLR_FILE_AND_LINE;
}
else
@ -350,23 +375,23 @@ vector<ParseLocationRec> parse_location_string(const string& s)
string line_string = s.substr(pos_colon + 1, s.length() - pos_colon);
if ( ! sscanf(line_string.c_str(), "%d", &plr.line) )
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
string path(find_script_file(filename, bro_path()));
if ( path.empty() )
{
debug_msg("No such policy file: %s.\n", filename.c_str());
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return result;
}
loc_filename = path;
plr.type = plrFileAndLine;
plr.type = PLR_FILE_AND_LINE;
}
}
if ( plr.type == plrFileAndLine )
if ( plr.type == PLR_FILE_AND_LINE )
{
auto iter = g_dbgfilemaps.find(loc_filename);
if ( iter == g_dbgfilemaps.end() )
@ -376,7 +401,7 @@ vector<ParseLocationRec> parse_location_string(const string& s)
if ( plr.line > how_many_lines_in(loc_filename.data()) )
{
debug_msg("No line %d in %s.\n", plr.line, loc_filename.data());
plr.type = plrUnknown;
plr.type = PLR_UNKNOWN;
return result;
}
@ -634,7 +659,7 @@ static int dbg_dispatch_cmd(DebugCmd cmd_code, const vector<string>& args)
{
switch ( cmd_code ) {
case dcHelp:
dbg_cmd_help(cmd_code, args);
zeek::detail::dbg_cmd_help(cmd_code, args);
break;
case dcQuit:
@ -664,11 +689,11 @@ static int dbg_dispatch_cmd(DebugCmd cmd_code, const vector<string>& args)
break;
case dcBreak:
dbg_cmd_break(cmd_code, args);
zeek::detail::dbg_cmd_break(cmd_code, args);
break;
case dcBreakCondition:
dbg_cmd_break_condition(cmd_code, args);
zeek::detail::dbg_cmd_break_condition(cmd_code, args);
break;
case dcDeleteBreak:
@ -676,26 +701,26 @@ static int dbg_dispatch_cmd(DebugCmd cmd_code, const vector<string>& args)
case dcDisableBreak:
case dcEnableBreak:
case dcIgnoreBreak:
dbg_cmd_break_set_state(cmd_code, args);
zeek::detail::dbg_cmd_break_set_state(cmd_code, args);
break;
case dcPrint:
dbg_cmd_print(cmd_code, args);
zeek::detail::dbg_cmd_print(cmd_code, args);
break;
case dcBacktrace:
return dbg_cmd_backtrace(cmd_code, args);
return zeek::detail::dbg_cmd_backtrace(cmd_code, args);
case dcFrame:
case dcUp:
case dcDown:
return dbg_cmd_frame(cmd_code, args);
return zeek::detail::dbg_cmd_frame(cmd_code, args);
case dcInfo:
return dbg_cmd_info(cmd_code, args);
return zeek::detail::dbg_cmd_info(cmd_code, args);
case dcList:
return dbg_cmd_list(cmd_code, args);
return zeek::detail::dbg_cmd_list(cmd_code, args);
case dcDisplay:
case dcUndisplay:
@ -703,7 +728,7 @@ static int dbg_dispatch_cmd(DebugCmd cmd_code, const vector<string>& args)
break;
case dcTrace:
return dbg_cmd_trace(cmd_code, args);
return zeek::detail::dbg_cmd_trace(cmd_code, args);
default:
debug_msg("INTERNAL ERROR: "
@ -932,22 +957,6 @@ bool post_execute_stmt(zeek::detail::Stmt* stmt, zeek::detail::Frame* f, zeek::V
return true;
}
// Evaluates the given expression in the context of the currently selected
// frame. Returns the resulting value, or nil if none (or there was an error).
zeek::detail::Expr* g_curr_debug_expr = nullptr;
const char* g_curr_debug_error = nullptr;
bool in_debug = false;
// ### fix this hardwired access to external variables etc.
struct yy_buffer_state;
typedef struct yy_buffer_state* YY_BUFFER_STATE;
YY_BUFFER_STATE bro_scan_string(const char*);
extern YYLTYPE yylloc; // holds start line and column of token
extern int line_number;
extern const char* filename;
zeek::ValPtr dbg_eval_expr(const char* expr)
{
// Push the current frame's associated scope.
@ -1011,3 +1020,5 @@ zeek::ValPtr dbg_eval_expr(const char* expr)
return result;
}
} // namespace zeek::detail

View file

@ -14,15 +14,22 @@
ZEEK_FORWARD_DECLARE_NAMESPACED(Frame, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
ZEEK_FORWARD_DECLARE_NAMESPACED(DbgBreakpoint, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(DbgWatch, zeek::detail);
ZEEK_FORWARD_DECLARE_NAMESPACED(DbgDisplay, zeek::detail);
namespace zeek {
template <class T> class IntrusivePtr;
using ValPtr = zeek::IntrusivePtr<Val>;
}
extern std::string current_module;
namespace detail {
// This needs to be defined before we do the includes that come after it.
enum ParseLocationRecType { plrUnknown, plrFileAndLine, plrFunction };
struct ParseLocationRec {
enum ParseLocationRecType { PLR_UNKNOWN, PLR_FILE_AND_LINE, PLR_FUNCTION };
class ParseLocationRec {
public:
ParseLocationRecType type;
int32_t line;
zeek::detail::Stmt* stmt;
@ -30,19 +37,10 @@ struct ParseLocationRec {
};
class StmtLocMapping;
typedef zeek::PQueue<StmtLocMapping> Filemap; // mapping for a single file
using Filemap = zeek::PQueue<StmtLocMapping>; // mapping for a single file
class DbgBreakpoint;
class DbgWatch;
class DbgDisplay;
class StmtHashFn;
typedef std::map<int, DbgBreakpoint*> BPIDMapType;
typedef std::multimap<const zeek::detail::Stmt*, DbgBreakpoint*> BPMapType;
namespace zeek {
extern std::string current_module;
}
using BPIDMapType = std::map<int, zeek::detail::DbgBreakpoint*>;
using BPMapType = std::multimap<const zeek::detail::Stmt*, zeek::detail::DbgBreakpoint*>;
class TraceState {
public:
@ -92,8 +90,8 @@ public:
zeek::detail::Location last_loc; // used by 'list'; the last location listed
BPIDMapType breakpoints; // BPID -> Breakpoint
std::vector<DbgWatch*> watches;
std::vector<DbgDisplay*> displays;
std::vector<zeek::detail::DbgWatch*> watches;
std::vector<zeek::detail::DbgDisplay*> displays;
BPMapType breakpoint_map; // maps Stmt -> Breakpoints on it
protected:
@ -122,7 +120,6 @@ protected:
zeek::detail::Stmt* stmt;
};
extern bool g_policy_debug; // enable debugging facility
extern DebuggerState g_debugger_state;
@ -183,3 +180,36 @@ extern std::map<std::string, Filemap*> g_dbgfilemaps; // filename => filemap
// Perhaps add a code/priority argument to do selective output.
int debug_msg(const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
} // namespace zeek::detail
} // namespace zeek
constexpr auto plrUnknown [[deprecated("Remove in v4.1. Use zeek::detail::PLR_UNKNOWN.")]] = zeek::detail::PLR_UNKNOWN;
constexpr auto plrFileAndLine [[deprecated("Remove in v4.1. Use zeek::detail::PLR_FILE_AND_LINE.")]] = zeek::detail::PLR_FILE_AND_LINE;
constexpr auto plrFunction [[deprecated("Remove in v4.1. Use zeek::detail::PLR_FUNCTION.")]] = zeek::detail::PLR_FUNCTION;
using ParseLocationRec [[deprecated("Remove in v4.1. Use zeek::detail::ParseLocationRec.")]] = zeek::detail::ParseLocationRec;
using Filemap [[deprecated("Remove in v4.1. Use zeek::detail::Filemap.")]] = zeek::detail::Filemap;
using BPIDMapType [[deprecated("Remove in v4.1. Use zeek::detail::BPIDMapType.")]] = zeek::detail::BPIDMapType;
using BPMapType [[deprecated("Remove in v4.1. Use zeek::detail::BPMapType.")]] = zeek::detail::BPMapType;
using TraceState [[deprecated("Remove in v4.1. Use zeek::detail::TraceState.")]] = zeek::detail::TraceState;
using DebuggerState [[deprecated("Remove in v4.1. Use zeek::detail::DebuggerState.")]] = zeek::detail::DebuggerState;
using StmtLocMapping [[deprecated("Remove in v4.1. Use zeek::detail::StmtLocMapping.")]] = zeek::detail::StmtLocMapping;
constexpr auto parse_location_string [[deprecated("Remove in v4.1. Use zeek::detail::parse_location_string.")]] = zeek::detail::parse_location_string;
constexpr auto pre_execute_stmt [[deprecated("Remove in v4.1. Use zeek::detail::pre_execute_stmt.")]] = zeek::detail::pre_execute_stmt;
constexpr auto post_execute_stmt [[deprecated("Remove in v4.1. Use zeek::detail::post_execute_stmt.")]] = zeek::detail::post_execute_stmt;
constexpr auto dbg_init_debugger [[deprecated("Remove in v4.1. Use zeek::detail::dbg_init_debugger.")]] = zeek::detail::dbg_init_debugger;
constexpr auto dbg_shutdown_debugger [[deprecated("Remove in v4.1. Use zeek::detail::dbg_shutdown_debugger.")]] = zeek::detail::dbg_shutdown_debugger;
constexpr auto dbg_handle_debug_input [[deprecated("Remove in v4.1. Use zeek::detail::dbg_handle_debug_input.")]] = zeek::detail::dbg_handle_debug_input;
constexpr auto dbg_execute_command [[deprecated("Remove in v4.1. Use zeek::detail::dbg_execute_command.")]] = zeek::detail::dbg_execute_command;
constexpr auto dbg_eval_expr [[deprecated("Remove in v4.1. Use zeek::detail::dbg_eval_expr.")]] = zeek::detail::dbg_eval_expr;
constexpr auto dbg_read_internal_state [[deprecated("Remove in v4.1. Use zeek::detail::dbg_read_internal_state.")]] = zeek::detail::dbg_read_internal_state;
constexpr auto get_context_description [[deprecated("Remove in v4.1. Use zeek::detail::get_context_description.")]] = zeek::detail::get_context_description;
constexpr auto debug_msg [[deprecated("Remove in v4.1. Use zeek::detail::debug_msg.")]] = zeek::detail::debug_msg;
extern bool& g_policy_debug [[deprecated("Remove in v4.1. Use zeek::detail:g_policy_debug")]];
extern zeek::detail::DebuggerState& g_debugger_state [[deprecated("Remove in v4.1. Use zeek::detail:g_debugger_state")]];
extern std::string& current_module [[deprecated("Remove in v4.1. Use zeek::current_module.")]];
extern zeek::detail::TraceState& g_trace_state [[deprecated("Remove in v4.1. Use zeek::detail::g_trace_state.")]];
extern zeek::detail::Frame*& g_dbg_locals [[deprecated("Remove in v4.1. Use zeek::detail::g_dbg_locals.")]];
extern std::map<std::string, zeek::detail::Filemap*>& g_dbgfilemaps [[deprecated("Remove in v4.1. Use zeek::detail::g_dbgfilemaps.")]];

View file

@ -1,284 +1,282 @@
//
// This file was automatically generated from ./DebugCmdInfoConstants.in
// This file was automatically generated from DebugCmdInfoConstants.in
// DO NOT EDIT.
//
#include "util.h"
void init_global_dbg_constants () {
void zeek::detail::init_global_dbg_constants () {
{
DebugCmdInfo* info;
const char * const names[] = {
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = { };
};
info = new zeek::detail::DebugCmdInfo(dcInvalid, names, 0, false, "This function should not be called",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcInvalid, names, 0, false, "This function should not be called",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"help"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"help"
};
info = new zeek::detail::DebugCmdInfo(dcHelp, names, 1, false, "Get help with debugger commands",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcHelp, names, 1, false, "Get help with debugger commands",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"quit"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"quit"
};
info = new zeek::detail::DebugCmdInfo(dcQuit, names, 1, false, "Exit Zeek",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcQuit, names, 1, false, "Exit Zeek",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"next"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"next"
};
info = new zeek::detail::DebugCmdInfo(dcNext, names, 1, true, "Step to the following statement, skipping function calls",
true);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcNext, names, 1, true, "Step to the following statement, skipping function calls",
true);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"step",
"s"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"step",
"s"
};
info = new zeek::detail::DebugCmdInfo(dcStep, names, 2, true, "Step to following statements, stepping in to function calls",
true);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcStep, names, 2, true, "Step to following statements, stepping in to function calls",
true);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"continue",
"c"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"continue",
"c"
};
info = new zeek::detail::DebugCmdInfo(dcContinue, names, 2, true, "Resume execution of the policy script",
true);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcContinue, names, 2, true, "Resume execution of the policy script",
true);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"finish"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"finish"
};
info = new zeek::detail::DebugCmdInfo(dcFinish, names, 1, true, "Run until the currently-executing function completes",
true);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcFinish, names, 1, true, "Run until the currently-executing function completes",
true);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"break",
"b"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"break",
"b"
};
info = new zeek::detail::DebugCmdInfo(dcBreak, names, 2, false, "Set a breakpoint",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcBreak, names, 2, false, "Set a breakpoint",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"cond"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"cond"
};
info = new zeek::detail::DebugCmdInfo(dcBreakCondition, names, 1, false, "",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcBreakCondition, names, 1, false, "",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"delete",
"d"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"delete",
"d"
};
info = new zeek::detail::DebugCmdInfo(dcDeleteBreak, names, 2, false, "Delete the specified breakpoints; delete all if no arguments",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcDeleteBreak, names, 2, false, "Delete the specified breakpoints; delete all if no arguments",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"clear"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"clear"
};
info = new zeek::detail::DebugCmdInfo(dcClearBreak, names, 1, false, "",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcClearBreak, names, 1, false, "",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"disable",
"dis"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"disable",
"dis"
};
info = new zeek::detail::DebugCmdInfo(dcDisableBreak, names, 2, false, "",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcDisableBreak, names, 2, false, "",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"enable"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"enable"
};
info = new zeek::detail::DebugCmdInfo(dcEnableBreak, names, 1, false, "",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcEnableBreak, names, 1, false, "",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"ignore"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"ignore"
};
info = new zeek::detail::DebugCmdInfo(dcIgnoreBreak, names, 1, false, "",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcIgnoreBreak, names, 1, false, "",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"print",
"p",
"set"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"print",
"p",
"set"
};
info = new zeek::detail::DebugCmdInfo(dcPrint, names, 3, false, "Evaluate an expression and print the result (also aliased as 'set')",
true);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcPrint, names, 3, false, "Evaluate an expression and print the result (also aliased as 'set')",
true);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"backtrace",
"bt",
"where"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"backtrace",
"bt",
"where"
};
info = new zeek::detail::DebugCmdInfo(dcBacktrace, names, 3, false, "Print a stack trace (with +- N argument, inner/outer N frames only)",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcBacktrace, names, 3, false, "Print a stack trace (with +- N argument, inner/outer N frames only)",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"frame"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"frame"
};
info = new zeek::detail::DebugCmdInfo(dcFrame, names, 1, false, "Select frame number N",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcFrame, names, 1, false, "Select frame number N",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"up"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"up"
};
info = new zeek::detail::DebugCmdInfo(dcUp, names, 1, false, "Select the stack frame one level up",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcUp, names, 1, false, "Select the stack frame one level up",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"down"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"down"
};
info = new zeek::detail::DebugCmdInfo(dcDown, names, 1, false, "Select the stack frame one level down",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcDown, names, 1, false, "Select the stack frame one level down",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"info"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"info"
};
info = new zeek::detail::DebugCmdInfo(dcInfo, names, 1, false, "Get information about the debugging environment",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcInfo, names, 1, false, "Get information about the debugging environment",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"list",
"l"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"list",
"l"
};
info = new zeek::detail::DebugCmdInfo(dcList, names, 2, false, "Print source lines surrounding specified context",
true);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcList, names, 2, false, "Print source lines surrounding specified context",
true);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"display"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"display"
};
info = new zeek::detail::DebugCmdInfo(dcDisplay, names, 1, false, "",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcDisplay, names, 1, false, "",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"undisplay"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"undisplay"
};
info = new zeek::detail::DebugCmdInfo(dcUndisplay, names, 1, false, "",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
info = new DebugCmdInfo (dcUndisplay, names, 1, false, "",
false);
g_DebugCmdInfos.push_back(info);
}
{
zeek::detail::DebugCmdInfo* info;
const char * const names[] = {
"trace"
};
{
DebugCmdInfo* info;
const char * const names[] = {
"trace"
};
info = new DebugCmdInfo (dcTrace, names, 1, false, "Turn on or off execution tracing (with no arguments, prints current state.)",
false);
g_DebugCmdInfos.push_back(info);
}
info = new zeek::detail::DebugCmdInfo(dcTrace, names, 1, false, "Turn on or off execution tracing (with no arguments, prints current state.)",
false);
zeek::detail::g_DebugCmdInfos.push_back(info);
}
}

View file

@ -53,7 +53,7 @@ static void lookup_global_symbols_regex(const string& orig_regex, vector<zeek::d
regex_t re;
if ( regcomp(&re, regex.c_str(), REG_EXTENDED|REG_NOSUB) )
{
debug_msg("Invalid regular expression: %s\n", regex.c_str());
zeek::detail::debug_msg("Invalid regular expression: %s\n", regex.c_str());
return;
}
@ -80,14 +80,14 @@ static void choose_global_symbols_regex(const string& regex, vector<zeek::detail
while ( true )
{
debug_msg("There were multiple matches, please choose:\n");
zeek::detail::debug_msg("There were multiple matches, please choose:\n");
for ( size_t i = 0; i < choices.size(); i++ )
debug_msg("[%lu] %s\n", i+1, choices[i]->Name());
zeek::detail::debug_msg("[%lu] %s\n", i+1, choices[i]->Name());
debug_msg("[a] All of the above\n");
debug_msg("[n] None of the above\n");
debug_msg("Enter your choice: ");
zeek::detail::debug_msg("[a] All of the above\n");
zeek::detail::debug_msg("[n] None of the above\n");
zeek::detail::debug_msg("Enter your choice: ");
char charinput[256];
if ( ! fgets(charinput, sizeof(charinput) - 1, stdin) )
@ -123,7 +123,10 @@ static void choose_global_symbols_regex(const string& regex, vector<zeek::detail
// DebugCmdInfo implementation
//
zeek::PQueue<DebugCmdInfo> g_DebugCmdInfos;
zeek::PQueue<zeek::detail::DebugCmdInfo> zeek::detail::g_DebugCmdInfos;
zeek::PQueue<zeek::detail::DebugCmdInfo>& g_DebugCmdInfos = zeek::detail::g_DebugCmdInfos;
namespace zeek::detail {
DebugCmdInfo::DebugCmdInfo(const DebugCmdInfo& info)
: cmd(info.cmd), helpstring(nullptr)
@ -663,7 +666,7 @@ int dbg_cmd_list(DebugCmd cmd, const vector<string>& args)
{
vector<ParseLocationRec> plrs = parse_location_string(args[0]);
ParseLocationRec plr = plrs[0];
if ( plr.type == plrUnknown )
if ( plr.type == PLR_UNKNOWN )
{
debug_msg("Invalid location specifier\n");
return false;
@ -722,3 +725,5 @@ int dbg_cmd_trace(DebugCmd cmd, const vector<string>& args)
debug_msg("Invalid argument");
return 0;
}
} // namespace zeek::detail

View file

@ -10,6 +10,8 @@
#include "Queue.h"
#include "DebugCmdConstants.h"
namespace zeek::detail {
class DebugCmdInfo {
public:
DebugCmdInfo(const DebugCmdInfo& info);
@ -74,3 +76,23 @@ DbgCmdFn dbg_cmd_print;
DbgCmdFn dbg_cmd_info;
DbgCmdFn dbg_cmd_list;
DbgCmdFn dbg_cmd_trace;
} // namespace zeek::detail
using DebugCmdInfo [[deprecated("Remove in v4.1. Use zeek::detail::DebugCmdInfo.")]] = zeek::detail::DebugCmdInfo;
constexpr auto init_global_dbg_constants [[deprecated("Remove in v4.1. Use zeek::detail::init_global_dbg_constants.")]] = zeek::detail::init_global_dbg_constants;
constexpr auto get_debug_cmd_info [[deprecated("Remove in v4.1. Use zeek::detail::get_debug_cmd_info.")]] = zeek::detail::get_debug_cmd_info;
constexpr auto find_all_matching_cmds [[deprecated("Remove in v4.1. Use zeek::detail::find_all_matching_cmds.")]] = zeek::detail::find_all_matching_cmds;
constexpr auto dbg_cmd_backtrace [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_backtrace")]] = zeek::detail::dbg_cmd_backtrace;
constexpr auto dbg_cmd_frame [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_frame")]] = zeek::detail::dbg_cmd_frame;
constexpr auto dbg_cmd_help [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_help")]] = zeek::detail::dbg_cmd_help;
constexpr auto dbg_cmd_break [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_break")]] = zeek::detail::dbg_cmd_break;
constexpr auto dbg_cmd_break_condition [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_break_condition")]] = zeek::detail::dbg_cmd_break_condition;
constexpr auto dbg_cmd_break_set_state [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_break_set_state")]] = zeek::detail::dbg_cmd_break_set_state;
constexpr auto dbg_cmd_print [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_print")]] = zeek::detail::dbg_cmd_print;
constexpr auto dbg_cmd_info [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_info")]] = zeek::detail::dbg_cmd_info;
constexpr auto dbg_cmd_list [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_list")]] = zeek::detail::dbg_cmd_list;
constexpr auto dbg_cmd_trace [[deprecated("Remove in v4.1. Use zeek::detail::dbg_cmd_trace")]] = zeek::detail::dbg_cmd_trace;
extern zeek::PQueue<zeek::detail::DebugCmdInfo>& g_DebugCmdInfos [[deprecated("Remove in v4.1. Use zeek::detail::g_DebugCmdInfos.")]];

View file

@ -37,7 +37,7 @@ int how_many_lines_in(const char* policy_filename)
FILE* throwaway = fopen(policy_filename, "r");
if ( ! throwaway )
{
debug_msg("No such policy file: %s.\n", policy_filename);
zeek::detail::debug_msg("No such policy file: %s.\n", policy_filename);
return -1;
}
@ -51,7 +51,7 @@ int how_many_lines_in(const char* policy_filename)
match = policy_files.find(policy_filename);
if ( match == policy_files.end() )
{
debug_msg("Policy file %s was not loaded.\n", policy_filename);
zeek::detail::debug_msg("Policy file %s was not loaded.\n", policy_filename);
return -1;
}
}
@ -69,14 +69,14 @@ bool LoadPolicyFileText(const char* policy_filename)
if ( ! f )
{
debug_msg("No such policy file: %s.\n", policy_filename);
zeek::detail::debug_msg("No such policy file: %s.\n", policy_filename);
return false;
}
PolicyFile* pf = new PolicyFile;
if ( policy_files.find(policy_filename) != policy_files.end() )
debug_msg("Policy file %s already loaded\n", policy_filename);
zeek::detail::debug_msg("Policy file %s already loaded\n", policy_filename);
policy_files.insert(PolicyFileMap::value_type(policy_filename, pf));
@ -129,7 +129,7 @@ bool PrintLines(const char* policy_filename, unsigned int start_line,
FILE* throwaway = fopen(policy_filename, "r");
if ( ! throwaway )
{
debug_msg("No such policy file: %s.\n", policy_filename);
zeek::detail::debug_msg("No such policy file: %s.\n", policy_filename);
return false;
}
@ -143,7 +143,7 @@ bool PrintLines(const char* policy_filename, unsigned int start_line,
match = policy_files.find(policy_filename);
if ( match == policy_files.end() )
{
debug_msg("Policy file %s was not loaded.\n", policy_filename);
zeek::detail::debug_msg("Policy file %s was not loaded.\n", policy_filename);
return false;
}
}
@ -155,7 +155,7 @@ bool PrintLines(const char* policy_filename, unsigned int start_line,
if ( start_line > pf->lines.size() )
{
debug_msg("Line number %d out of range; %s has %d lines\n",
zeek::detail::debug_msg("Line number %d out of range; %s has %d lines\n",
start_line, policy_filename, int(pf->lines.size()));
return false;
}
@ -166,10 +166,10 @@ bool PrintLines(const char* policy_filename, unsigned int start_line,
for ( unsigned int i = 0; i < how_many_lines; ++i )
{
if ( show_numbers )
debug_msg("%d\t", i + start_line);
zeek::detail::debug_msg("%d\t", i + start_line);
const char* line = pf->lines[start_line + i - 1];
debug_msg("%s\n", line);
zeek::detail::debug_msg("%s\n", line);
}
return true;

View file

@ -25,13 +25,13 @@ import sys
inputfile = sys.argv[1]
init_tmpl = '''
{
DebugCmdInfo* info;
%(name_init)s
info = new DebugCmdInfo (%(cmd)s, names, %(num_names)s, %(resume)s, "%(help)s",
%(repeatable)s);
g_DebugCmdInfos.push_back(info);
}
\t{
\t\tzeek::detail::DebugCmdInfo* info;
\t\t%(name_init)s
\t\tinfo = new zeek::detail::DebugCmdInfo(%(cmd)s, names, %(num_names)s, %(resume)s, "%(help)s",
\t\t %(repeatable)s);
\t\tzeek::detail::g_DebugCmdInfos.push_back(info);
\t}
'''
enum_str = '''
@ -49,13 +49,16 @@ init_str = '''
//
#include "util.h"
void init_global_dbg_constants () {
void zeek::detail::init_global_dbg_constants () {
''' % inputfile
def outputrecord():
global init_str, enum_str
dbginfo["name_init"] = "const char * const names[] = {\n\t%s\n };\n" % ",\n\t".join(dbginfo["names"])
if dbginfo["names"]:
dbginfo["name_init"] = "const char * const names[] = {\n\t\t\t%s\n\t\t};\n" % ",\n\t\t\t".join(dbginfo["names"])
else:
dbginfo["name_init"] = "const char * const names[] = { };\n"
dbginfo["num_names"] = len(dbginfo["names"])
@ -102,8 +105,8 @@ for line in inputf:
# output the last record
outputrecord()
init_str += " \n}\n"
enum_str += " dcLast\n};\n"
init_str += "\t\n}\n"
enum_str += "\tdcLast\n};\n"
debugcmds = open("DebugCmdConstants.h", "w")
debugcmds.write(enum_str)

View file

@ -1416,7 +1416,7 @@ stmt:
zeek::detail::set_location(@1, @4);
$$ = $3;
if ( $2 )
brofiler.DecIgnoreDepth();
zeek::detail::brofiler.DecIgnoreDepth();
}
| TOK_PRINT expr_list ';' opt_no_test
@ -1424,7 +1424,7 @@ stmt:
zeek::detail::set_location(@1, @3);
$$ = new zeek::detail::PrintStmt(zeek::IntrusivePtr{zeek::AdoptRef{}, $2});
if ( ! $4 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_EVENT event ';' opt_no_test
@ -1432,7 +1432,7 @@ stmt:
zeek::detail::set_location(@1, @3);
$$ = new zeek::detail::EventStmt({zeek::AdoptRef{}, $2});
if ( ! $4 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_IF '(' expr ')' stmt
@ -1468,7 +1468,7 @@ stmt:
zeek::detail::set_location(@1, @2);
$$ = new zeek::detail::NextStmt;
if ( ! $3 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_BREAK ';' opt_no_test
@ -1476,7 +1476,7 @@ stmt:
zeek::detail::set_location(@1, @2);
$$ = new zeek::detail::BreakStmt;
if ( ! $3 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_FALLTHROUGH ';' opt_no_test
@ -1484,7 +1484,7 @@ stmt:
zeek::detail::set_location(@1, @2);
$$ = new zeek::detail::FallthroughStmt;
if ( ! $3 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_RETURN ';' opt_no_test
@ -1492,7 +1492,7 @@ stmt:
zeek::detail::set_location(@1, @2);
$$ = new zeek::detail::ReturnStmt(0);
if ( ! $3 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_RETURN expr ';' opt_no_test
@ -1500,7 +1500,7 @@ stmt:
zeek::detail::set_location(@1, @2);
$$ = new zeek::detail::ReturnStmt({zeek::AdoptRef{}, $2});
if ( ! $4 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_ADD expr ';' opt_no_test
@ -1508,7 +1508,7 @@ stmt:
zeek::detail::set_location(@1, @3);
$$ = new zeek::detail::AddStmt({zeek::AdoptRef{}, $2});
if ( ! $4 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_DELETE expr ';' opt_no_test
@ -1516,7 +1516,7 @@ stmt:
zeek::detail::set_location(@1, @3);
$$ = new zeek::detail::DelStmt({zeek::AdoptRef{}, $2});
if ( ! $4 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_LOCAL local_id opt_type init_class opt_init opt_attr ';' opt_no_test
@ -1527,7 +1527,7 @@ stmt:
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
VAR_REGULAR).release();
if ( ! $8 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_CONST local_id opt_type init_class opt_init opt_attr ';' opt_no_test
@ -1538,7 +1538,7 @@ stmt:
std::unique_ptr<std::vector<zeek::detail::AttrPtr>>{$6},
VAR_CONST).release();
if ( ! $8 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| TOK_WHEN '(' expr ')' stmt
@ -1554,7 +1554,7 @@ stmt:
$$ = new zeek::detail::WhenStmt({zeek::AdoptRef{}, $3}, {zeek::AdoptRef{}, $5},
{zeek::AdoptRef{}, $10}, {zeek::AdoptRef{}, $7}, false);
if ( $9 )
brofiler.DecIgnoreDepth();
zeek::detail::brofiler.DecIgnoreDepth();
}
@ -1571,7 +1571,7 @@ stmt:
$$ = new zeek::detail::WhenStmt({zeek::AdoptRef{}, $4}, {zeek::AdoptRef{}, $6},
{zeek::AdoptRef{}, $11}, {zeek::AdoptRef{}, $8}, true);
if ( $10 )
brofiler.DecIgnoreDepth();
zeek::detail::brofiler.DecIgnoreDepth();
}
| index_slice '=' expr ';' opt_no_test
@ -1581,7 +1581,7 @@ stmt:
{zeek::AdoptRef{}, $3}, in_init));
if ( ! $5 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| expr ';' opt_no_test
@ -1589,7 +1589,7 @@ stmt:
zeek::detail::set_location(@1, @2);
$$ = new zeek::detail::ExprStmt({zeek::AdoptRef{}, $1});
if ( ! $3 )
brofiler.AddStmt($$);
zeek::detail::brofiler.AddStmt($$);
}
| ';'
@ -1881,7 +1881,7 @@ opt_no_test:
opt_no_test_block:
TOK_NO_TEST
{ $$ = true; brofiler.IncIgnoreDepth(); }
{ $$ = true; zeek::detail::brofiler.IncIgnoreDepth(); }
|
{ $$ = false; }

View file

@ -602,10 +602,10 @@ static int load_files(const char* orig_file)
f = stdin;
file_path = canonical_stdin_path;
if ( g_policy_debug )
if ( zeek::detail::g_policy_debug )
{
debug_msg("Warning: can't use debugger while reading policy from stdin; turning off debugging.\n");
g_policy_debug = false;
zeek::detail::debug_msg("Warning: can't use debugger while reading policy from stdin; turning off debugging.\n");
zeek::detail::g_policy_debug = false;
}
}
@ -635,12 +635,12 @@ static int load_files(const char* orig_file)
files_scanned.push_back(std::move(sf));
if ( g_policy_debug && ! file_path.empty() )
if ( zeek::detail::g_policy_debug && ! file_path.empty() )
{
// Add the filename to the file mapping table (Debug.h).
Filemap* map = new Filemap;
zeek::detail::Filemap* map = new zeek::detail::Filemap;
HashKey* key = new HashKey(file_path.c_str());
g_dbgfilemaps.emplace(file_path, map);
zeek::detail::g_dbgfilemaps.emplace(file_path, map);
LoadPolicyFileText(file_path.c_str());
}

View file

@ -67,7 +67,8 @@ extern "C" {
#define DOCTEST_CONFIG_IMPLEMENT
#include "3rdparty/doctest.h"
Brofiler brofiler;
zeek::detail::Brofiler zeek::detail::brofiler;
zeek::detail::Brofiler& brofiler = zeek::detail::brofiler;
#ifndef HAVE_STRSEP
extern "C" {
@ -272,7 +273,7 @@ void terminate_bro()
// the termination process.
file_mgr->Terminate();
brofiler.WriteStats();
zeek::detail::brofiler.WriteStats();
if ( zeek_done )
mgr.Enqueue(zeek_done, zeek::Args{});
@ -424,7 +425,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
if ( zeek::Supervisor::ThisNode() )
zeek::Supervisor::ThisNode()->Init(&options);
brofiler.ReadStats();
zeek::detail::brofiler.ReadStats();
auto dns_type = options.dns_mode;