flag/environment variable for dumping use-defs

This commit is contained in:
Vern Paxson 2021-02-05 22:26:24 -08:00
parent 8a3622a726
commit 12c9b5ede5
3 changed files with 8 additions and 1 deletions

View file

@ -157,6 +157,7 @@ static void set_analysis_option(const char* opt, Options& opts)
if ( util::streq(opt, "help") ) if ( util::streq(opt, "help") )
{ {
fprintf(stderr, "--optimize options:\n"); fprintf(stderr, "--optimize options:\n");
fprintf(stderr, " dump-uds dump use-defs to stdout; implies xform\n");
fprintf(stderr, " dump-xform dump transformed scripts to stdout; implies xform\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");
@ -167,7 +168,9 @@ static void set_analysis_option(const char* opt, Options& opts)
auto& a_o = opts.analysis_options; auto& a_o = opts.analysis_options;
if ( util::streq(opt, "dump-xform") ) if ( util::streq(opt, "dump-uds") )
a_o.activate = a_o.dump_uds = true;
else if ( util::streq(opt, "dump-xform") )
a_o.activate = a_o.dump_xform = true; a_o.activate = a_o.dump_xform = true;
else if ( util::streq(opt, "inline") ) else if ( util::streq(opt, "inline") )
a_o.inliner = true; a_o.inliner = true;

View file

@ -115,6 +115,7 @@ void analyze_scripts()
if ( ! did_init ) if ( ! did_init )
{ {
check_env_opt("ZEEK_DUMP_XFORM", analysis_options.dump_xform); check_env_opt("ZEEK_DUMP_XFORM", analysis_options.dump_xform);
check_env_opt("ZEEK_DUMP_UDS", analysis_options.dump_uds);
check_env_opt("ZEEK_INLINE", analysis_options.inliner); check_env_opt("ZEEK_INLINE", analysis_options.inliner);
check_env_opt("ZEEK_XFORM", analysis_options.activate); check_env_opt("ZEEK_XFORM", analysis_options.activate);

View file

@ -27,6 +27,9 @@ struct AnalyOpt {
// them. Always done if only_func is set. // them. Always done if only_func is set.
bool dump_xform = false; bool dump_xform = false;
// If true, dump out the use-defs for each analyzed function.
bool dump_uds = false;
// If non-nil, then only analyze the given function/event/hook. // If non-nil, then only analyze the given function/event/hook.
std::optional<std::string> only_func; std::optional<std::string> only_func;