mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
options relating to script transformation: activation, dumping, selecting only a single function (for debugging)
This commit is contained in:
parent
8f001062bf
commit
77e9610086
2 changed files with 35 additions and 5 deletions
|
@ -106,6 +106,7 @@ void usage(const char* prog, int code)
|
||||||
fprintf(stderr, " -I|--print-id <ID name> | print out given ID\n");
|
fprintf(stderr, " -I|--print-id <ID name> | print out given ID\n");
|
||||||
fprintf(stderr, " -N|--print-plugins | print available plugins and exit (-NN for verbose)\n");
|
fprintf(stderr, " -N|--print-plugins | print available plugins and exit (-NN for verbose)\n");
|
||||||
fprintf(stderr, " -O|--optimize[=<option>] | enable script optimization (use -O help for options)\n");
|
fprintf(stderr, " -O|--optimize[=<option>] | enable script optimization (use -O help for options)\n");
|
||||||
|
fprintf(stderr, " -o|--optimize-only=<func> | enable script optimization only for the given function\n");
|
||||||
fprintf(stderr, " -P|--prime-dns | prime DNS\n");
|
fprintf(stderr, " -P|--prime-dns | prime DNS\n");
|
||||||
fprintf(stderr, " -Q|--time | print execution time summary to stderr\n");
|
fprintf(stderr, " -Q|--time | print execution time summary to stderr\n");
|
||||||
fprintf(stderr, " -S|--debug-rules | enable rule debugging\n");
|
fprintf(stderr, " -S|--debug-rules | enable rule debugging\n");
|
||||||
|
@ -145,20 +146,34 @@ void usage(const char* prog, int code)
|
||||||
|
|
||||||
static void set_analysis_option(const char* opt, Options& opts)
|
static void set_analysis_option(const char* opt, Options& opts)
|
||||||
{
|
{
|
||||||
|
if ( ! opt || util::streq(opt, "all") )
|
||||||
|
{
|
||||||
|
opts.analysis_options.inliner = true;
|
||||||
|
opts.analysis_options.activate = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( util::streq(opt, "help") )
|
if ( util::streq(opt, "help") )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "--optimize options:\n");
|
fprintf(stderr, "--optimize options:\n");
|
||||||
|
fprintf(stderr, " dump-xform dump transformed scripts to stdout; implies xform\n");
|
||||||
fprintf(stderr, " help print this list\n");
|
fprintf(stderr, " help print this list\n");
|
||||||
fprintf(stderr, " inline inline function calls\n");
|
fprintf(stderr, " inline inline function calls\n");
|
||||||
fprintf(stderr, " recursive report on recursive functions and exit\n");
|
fprintf(stderr, " recursive report on recursive functions and exit\n");
|
||||||
|
fprintf(stderr, " xform tranform scripts to \"reduced\" form\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( util::streq(opt, "inline") )
|
auto& a_o = opts.analysis_options;
|
||||||
opts.analysis_options.inliner = true;
|
|
||||||
|
if ( util::streq(opt, "dump-xform") )
|
||||||
|
a_o.activate = a_o.dump_xform = true;
|
||||||
|
else if ( util::streq(opt, "inline") )
|
||||||
|
a_o.inliner = true;
|
||||||
else if ( util::streq(opt, "recursive") )
|
else if ( util::streq(opt, "recursive") )
|
||||||
opts.analysis_options.inliner =
|
a_o.inliner = a_o.report_recursive = true;
|
||||||
opts.analysis_options.report_recursive = true;
|
else if ( util::streq(opt, "xform") )
|
||||||
|
a_o.activate = true;
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -279,6 +294,7 @@ Options parse_cmdline(int argc, char** argv)
|
||||||
{"save-seeds", required_argument, nullptr, 'H'},
|
{"save-seeds", required_argument, nullptr, 'H'},
|
||||||
{"print-plugins", no_argument, nullptr, 'N'},
|
{"print-plugins", no_argument, nullptr, 'N'},
|
||||||
{"optimize", required_argument, nullptr, 'O'},
|
{"optimize", required_argument, nullptr, 'O'},
|
||||||
|
{"optimize-only", required_argument, nullptr, 'o'},
|
||||||
{"prime-dns", no_argument, nullptr, 'P'},
|
{"prime-dns", no_argument, nullptr, 'P'},
|
||||||
{"time", no_argument, nullptr, 'Q'},
|
{"time", no_argument, nullptr, 'Q'},
|
||||||
{"debug-rules", no_argument, nullptr, 'S'},
|
{"debug-rules", no_argument, nullptr, 'S'},
|
||||||
|
@ -306,7 +322,7 @@ Options parse_cmdline(int argc, char** argv)
|
||||||
};
|
};
|
||||||
|
|
||||||
char opts[256];
|
char opts[256];
|
||||||
util::safe_strncpy(opts, "B:e:f:G:H:I:i:j::n:O:p:r:s:T:t:U:w:X:CDFNPQSWabdhv",
|
util::safe_strncpy(opts, "B:e:f:G:H:I:i:j::n:O:o:p:r:s:T:t:U:w:X:CDFNPQSWabdhv",
|
||||||
sizeof(opts));
|
sizeof(opts));
|
||||||
|
|
||||||
#ifdef USE_PERFTOOLS_DEBUG
|
#ifdef USE_PERFTOOLS_DEBUG
|
||||||
|
@ -431,6 +447,9 @@ Options parse_cmdline(int argc, char** argv)
|
||||||
case 'O':
|
case 'O':
|
||||||
set_analysis_option(optarg, rval);
|
set_analysis_option(optarg, rval);
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
rval.analysis_options.only_func = util::copy_string(optarg);
|
||||||
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
if ( rval.dns_mode != detail::DNS_DEFAULT )
|
if ( rval.dns_mode != detail::DNS_DEFAULT )
|
||||||
usage(zargs[0], 1);
|
usage(zargs[0], 1);
|
||||||
|
|
|
@ -16,6 +16,17 @@ namespace zeek::detail {
|
||||||
// Flags controlling what sorts of analysis to do.
|
// Flags controlling what sorts of analysis to do.
|
||||||
|
|
||||||
struct AnalyOpt {
|
struct AnalyOpt {
|
||||||
|
// Whether to analyze scripts.
|
||||||
|
bool activate = false;
|
||||||
|
|
||||||
|
// If true, dump out transformed code: the results of reducing
|
||||||
|
// interpreted scripts, and, if optimize is set, of then optimizing
|
||||||
|
// them. Always done if only_func is set.
|
||||||
|
bool dump_xform = false;
|
||||||
|
|
||||||
|
// If non-nil, then only analyze the given function/event/hook.
|
||||||
|
const char* only_func = nullptr;
|
||||||
|
|
||||||
// If true, do global inlining.
|
// If true, do global inlining.
|
||||||
bool inliner = false;
|
bool inliner = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue