mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
94
src/Debug.h
94
src/Debug.h
|
@ -2,16 +2,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
|
||||
#include "zeek/Obj.h"
|
||||
#include "zeek/StmtEnums.h"
|
||||
#include "zeek/util.h"
|
||||
|
||||
namespace zeek {
|
||||
namespace zeek
|
||||
{
|
||||
|
||||
class Val;
|
||||
template <class T> class IntrusivePtr;
|
||||
|
@ -19,7 +20,8 @@ using ValPtr = zeek::IntrusivePtr<Val>;
|
|||
|
||||
extern std::string current_module;
|
||||
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class Frame;
|
||||
class Stmt;
|
||||
|
@ -28,14 +30,20 @@ class DbgWatch;
|
|||
class DbgDisplay;
|
||||
|
||||
// This needs to be defined before we do the includes that come after it.
|
||||
enum ParseLocationRecType { PLR_UNKNOWN, PLR_FILE_AND_LINE, PLR_FUNCTION };
|
||||
class ParseLocationRec {
|
||||
enum ParseLocationRecType
|
||||
{
|
||||
PLR_UNKNOWN,
|
||||
PLR_FILE_AND_LINE,
|
||||
PLR_FUNCTION
|
||||
};
|
||||
class ParseLocationRec
|
||||
{
|
||||
public:
|
||||
ParseLocationRecType type;
|
||||
int32_t line;
|
||||
Stmt* stmt;
|
||||
const char* filename;
|
||||
};
|
||||
};
|
||||
|
||||
class StmtLocMapping;
|
||||
using Filemap = std::deque<StmtLocMapping*>; // mapping for a single file
|
||||
|
@ -43,34 +51,41 @@ using Filemap = std::deque<StmtLocMapping*>; // mapping for a single file
|
|||
using BPIDMapType = std::map<int, DbgBreakpoint*>;
|
||||
using BPMapType = std::multimap<const Stmt*, DbgBreakpoint*>;
|
||||
|
||||
class TraceState {
|
||||
class TraceState
|
||||
{
|
||||
public:
|
||||
TraceState() { dbgtrace = false; trace_file = stderr; }
|
||||
TraceState()
|
||||
{
|
||||
dbgtrace = false;
|
||||
trace_file = stderr;
|
||||
}
|
||||
|
||||
// Returns previous filename.
|
||||
FILE* SetTraceFile(const char* trace_filename);
|
||||
|
||||
bool DoTrace() const { return dbgtrace; }
|
||||
bool DoTrace() const { return dbgtrace; }
|
||||
void TraceOn();
|
||||
void TraceOff();
|
||||
|
||||
int LogTrace(const char* fmt, ...) __attribute__((format(printf, 2, 3)));;
|
||||
int LogTrace(const char* fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
;
|
||||
|
||||
protected:
|
||||
bool dbgtrace; // print an execution trace
|
||||
bool dbgtrace; // print an execution trace
|
||||
FILE* trace_file;
|
||||
};
|
||||
};
|
||||
|
||||
extern TraceState g_trace_state;
|
||||
|
||||
class DebuggerState {
|
||||
class DebuggerState
|
||||
{
|
||||
public:
|
||||
DebuggerState();
|
||||
~DebuggerState();
|
||||
|
||||
int NextBPID() { return next_bp_id++; }
|
||||
int NextWatchID() { return next_watch_id++; }
|
||||
int NextDisplayID() { return next_display_id++; }
|
||||
int NextBPID() { return next_bp_id++; }
|
||||
int NextWatchID() { return next_watch_id++; }
|
||||
int NextDisplayID() { return next_display_id++; }
|
||||
|
||||
bool BreakBeforeNextStmt() { return break_before_next_stmt; }
|
||||
void BreakBeforeNextStmt(bool dobrk) { break_before_next_stmt = dobrk; }
|
||||
|
@ -78,7 +93,6 @@ public:
|
|||
bool BreakFromSignal() { return break_from_signal; }
|
||||
void BreakFromSignal(bool dobrk) { break_from_signal = dobrk; }
|
||||
|
||||
|
||||
// Temporary state: vanishes when execution resumes.
|
||||
|
||||
//### Umesh, why do these all need to be public? -- Vern
|
||||
|
@ -86,42 +100,47 @@ public:
|
|||
// Which frame we're looking at; 0 = the innermost frame.
|
||||
int curr_frame_idx;
|
||||
|
||||
bool already_did_list; // did we already do a 'list' command?
|
||||
bool already_did_list; // did we already do a 'list' command?
|
||||
|
||||
Location last_loc; // used by 'list'; the last location listed
|
||||
Location last_loc; // used by 'list'; the last location listed
|
||||
|
||||
BPIDMapType breakpoints; // BPID -> Breakpoint
|
||||
BPIDMapType breakpoints; // BPID -> Breakpoint
|
||||
std::vector<DbgWatch*> watches;
|
||||
std::vector<DbgDisplay*> displays;
|
||||
BPMapType breakpoint_map; // maps Stmt -> Breakpoints on it
|
||||
BPMapType breakpoint_map; // maps Stmt -> Breakpoints on it
|
||||
|
||||
protected:
|
||||
bool break_before_next_stmt; // trap into debugger (used for "step")
|
||||
bool break_from_signal; // was break caused by a signal?
|
||||
bool break_before_next_stmt; // trap into debugger (used for "step")
|
||||
bool break_from_signal; // was break caused by a signal?
|
||||
|
||||
int next_bp_id, next_watch_id, next_display_id;
|
||||
|
||||
private:
|
||||
Frame* dbg_locals; // unused
|
||||
};
|
||||
};
|
||||
|
||||
// Source line -> statement mapping.
|
||||
// (obj -> source line mapping available in object itself)
|
||||
class StmtLocMapping {
|
||||
class StmtLocMapping
|
||||
{
|
||||
public:
|
||||
StmtLocMapping() { }
|
||||
StmtLocMapping(const Location* l, Stmt* s) { loc = *l; stmt = s; }
|
||||
StmtLocMapping() { }
|
||||
StmtLocMapping(const Location* l, Stmt* s)
|
||||
{
|
||||
loc = *l;
|
||||
stmt = s;
|
||||
}
|
||||
|
||||
bool StartsAfter(const StmtLocMapping* m2);
|
||||
const Location& Loc() const { return loc; }
|
||||
Stmt* Statement() const { return stmt; }
|
||||
const Location& Loc() const { return loc; }
|
||||
Stmt* Statement() const { return stmt; }
|
||||
|
||||
protected:
|
||||
Location loc;
|
||||
Stmt* stmt;
|
||||
};
|
||||
};
|
||||
|
||||
extern bool g_policy_debug; // enable debugging facility
|
||||
extern bool g_policy_debug; // enable debugging facility
|
||||
extern DebuggerState g_debugger_state;
|
||||
|
||||
//
|
||||
|
@ -144,7 +163,6 @@ std::vector<ParseLocationRec> parse_location_string(const std::string& s);
|
|||
//
|
||||
// Also add some hooks for UI? -- See GDB
|
||||
|
||||
|
||||
// Debugging hooks.
|
||||
|
||||
// Return true to continue execution, false to abort.
|
||||
|
@ -158,7 +176,7 @@ int dbg_init_debugger(const char* cmdfile = nullptr);
|
|||
int dbg_shutdown_debugger();
|
||||
|
||||
// Returns 1 if successful, 0 otherwise.
|
||||
int dbg_handle_debug_input(); // read a line and then have it executed
|
||||
int dbg_handle_debug_input(); // read a line and then have it executed
|
||||
|
||||
// Returns > 0 if execution should be resumed, 0 if another debug command
|
||||
// should be read, or < 0 if there was an error.
|
||||
|
@ -170,12 +188,12 @@ ValPtr dbg_eval_expr(const char* expr);
|
|||
// Get line that looks like "In FnFoo(arg = val) at File:Line".
|
||||
std::string get_context_description(const Stmt* stmt, const Frame* frame);
|
||||
|
||||
extern Frame* g_dbg_locals; // variables created within debugger context
|
||||
extern Frame* g_dbg_locals; // variables created within debugger context
|
||||
|
||||
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)));
|
||||
int debug_msg(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
} // namespace detail
|
||||
} // namespace zeek
|
||||
} // namespace detail
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue