mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Compare commits
5 commits
e7aad5e3e0
...
65478f8dd0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
65478f8dd0 | ||
![]() |
651ac3cf79 | ||
![]() |
330cb83526 | ||
![]() |
bb73499cf2 | ||
![]() |
d6795320f7 |
6 changed files with 48 additions and 3 deletions
|
@ -60,7 +60,13 @@ public:
|
|||
// Returns previous filename.
|
||||
FILE* SetTraceFile(const char* trace_filename);
|
||||
|
||||
bool DoTrace() const { return dbgtrace; }
|
||||
bool DoTrace() const {
|
||||
#if DEBUG
|
||||
return dbgtrace;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
void TraceOn();
|
||||
void TraceOff();
|
||||
|
||||
|
|
|
@ -339,7 +339,9 @@ ValPtr ScriptFunc::Invoke(zeek::Args* args, Frame* parent) const {
|
|||
f->SetTriggerAssoc(parent->GetTriggerAssoc());
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
g_frame_stack.push_back(f.get()); // used for backtracing
|
||||
#endif
|
||||
const CallExpr* call_expr = parent ? parent->GetCall() : nullptr;
|
||||
call_stack.emplace_back(CallInfo{call_expr, this, *args});
|
||||
|
||||
|
@ -391,7 +393,9 @@ ValPtr ScriptFunc::Invoke(zeek::Args* args, Frame* parent) const {
|
|||
catch ( InterpreterException& e ) {
|
||||
// Already reported, but now determine whether to unwind further.
|
||||
if ( Flavor() == FUNC_FLAVOR_FUNCTION ) {
|
||||
#if DEBUG
|
||||
g_frame_stack.pop_back();
|
||||
#endif
|
||||
call_stack.pop_back();
|
||||
// Result not set b/c exception was thrown
|
||||
throw;
|
||||
|
@ -448,7 +452,9 @@ ValPtr ScriptFunc::Invoke(zeek::Args* args, Frame* parent) const {
|
|||
g_trace_state.LogTrace("Function return: %s\n", d.Description());
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
g_frame_stack.pop_back();
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -445,7 +445,15 @@ Options parse_cmdline(int argc, char** argv) {
|
|||
case 'a': rval.parse_only = true; break;
|
||||
case 'b': rval.bare_mode = true; break;
|
||||
case 'c': rval.unprocessed_output_file = optarg; break;
|
||||
case 'd': rval.debug_scripts = true; break;
|
||||
case 'd':
|
||||
#if DEBUG
|
||||
rval.debug_scripts = true;
|
||||
break;
|
||||
#else
|
||||
fprintf(stderr, "ERROR: Debugger is disabled in non-debug builds\n");
|
||||
exit(1);
|
||||
break;
|
||||
#endif
|
||||
case 'e': rval.script_code_to_exec = optarg; break;
|
||||
case 'f': rval.pcap_filter = optarg; break;
|
||||
case 'h': rval.print_usage = true; break;
|
||||
|
@ -489,7 +497,15 @@ Options parse_cmdline(int argc, char** argv) {
|
|||
rval.pcap_file = optarg;
|
||||
break;
|
||||
case 's': rval.signature_files.emplace_back(optarg); break;
|
||||
case 't': rval.debug_script_tracing_file = optarg; break;
|
||||
case 't':
|
||||
#ifdef DEBUG
|
||||
rval.debug_script_tracing_file = optarg;
|
||||
break;
|
||||
#else
|
||||
fprintf(stderr, "ERROR: Script tracing is disabled in non-debug builds\n");
|
||||
exit(1);
|
||||
break;
|
||||
#endif
|
||||
case 'u': ++rval.analysis_options.usage_issues; break;
|
||||
case 'v': rval.print_version = true; break;
|
||||
case 'V': rval.print_build_info = true; break;
|
||||
|
|
12
src/Stmt.cc
12
src/Stmt.cc
|
@ -147,6 +147,7 @@ const AssertStmt* Stmt::AsAssertStmt() const {
|
|||
}
|
||||
|
||||
bool Stmt::SetLocationInfo(const Location* start, const Location* end) {
|
||||
#if DEBUG
|
||||
if ( ! Obj::SetLocationInfo(start, end) )
|
||||
return false;
|
||||
|
||||
|
@ -177,6 +178,9 @@ bool Stmt::SetLocationInfo(const Location* start, const Location* end) {
|
|||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return Obj::SetLocationInfo(start, end);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Stmt::IsPure() const { return false; }
|
||||
|
@ -436,13 +440,17 @@ ValPtr IfStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) {
|
|||
|
||||
f->SetNextStmt(do_stmt);
|
||||
|
||||
#if DEBUG
|
||||
if ( ! pre_execute_stmt(do_stmt, f) ) { // ### Abort or something
|
||||
}
|
||||
#endif
|
||||
|
||||
auto result = do_stmt->Exec(f, flow);
|
||||
|
||||
#if DEBUG
|
||||
if ( ! post_execute_stmt(do_stmt, f, result.get(), &flow) ) { // ### Abort or something
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1409,13 +1417,17 @@ ValPtr StmtList::Exec(Frame* f, StmtFlowType& flow) {
|
|||
|
||||
f->SetNextStmt(stmt);
|
||||
|
||||
#if DEBUG
|
||||
if ( ! pre_execute_stmt(stmt, f) ) { // ### Abort or something
|
||||
}
|
||||
#endif
|
||||
|
||||
auto result = stmt->Exec(f, flow);
|
||||
|
||||
#if DEBUG
|
||||
if ( ! post_execute_stmt(stmt, f, result.get(), &flow) ) { // ### Abort or something
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( flow != FLOW_NEXT || result || f->HasDelayed() )
|
||||
return result;
|
||||
|
|
|
@ -1105,7 +1105,9 @@ SetupResult setup(int argc, char** argv, Options* zopts) {
|
|||
auto [body, scope] = get_global_stmts();
|
||||
StmtFlowType flow;
|
||||
Frame f(scope->Length(), nullptr, nullptr);
|
||||
#ifdef DEBUG
|
||||
g_frame_stack.push_back(&f);
|
||||
#endif
|
||||
|
||||
try {
|
||||
body->Exec(&f, flow);
|
||||
|
@ -1113,7 +1115,9 @@ SetupResult setup(int argc, char** argv, Options* zopts) {
|
|||
reporter->FatalError("failed to execute script statements at top-level scope");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
g_frame_stack.pop_back();
|
||||
#endif
|
||||
}
|
||||
|
||||
clear_script_analysis();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# @TEST-REQUIRES: have-spicy
|
||||
# @TEST-REQUIRES: test "$($BUILD/zeek-config --build_type)" = "debug"
|
||||
#
|
||||
# @TEST-EXEC: spicyz -d -o text.hlto text.spicy ./text.evt
|
||||
# @TEST-EXEC: zeek -r ${TRACES}/http/post.trace text.hlto %INPUT Spicy::enable_print=T | sort -k 3 >output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue