diff --git a/parser/libapparmor_re/apparmor_re.h b/parser/libapparmor_re/apparmor_re.h index 0a3aa7031..f21621795 100644 --- a/parser/libapparmor_re/apparmor_re.h +++ b/parser/libapparmor_re/apparmor_re.h @@ -30,6 +30,7 @@ typedef enum dfaflags { DFA_CONTROL_REMOVE_UNREACHABLE = 1 << 7, DFA_CONTROL_TRANS_HIGH = 1 << 8, + DFA_DUMP_MIN_PARTS = 1 << 13, DFA_DUMP_UNIQ_PERMS = 1 << 14, DFA_DUMP_MIN_UNIQ_PERMS = 1 << 15, DFA_DUMP_TREE_STATS = 1 << 16, diff --git a/parser/libapparmor_re/hfa.cc b/parser/libapparmor_re/hfa.cc index 40bf6e1c5..147021467 100644 --- a/parser/libapparmor_re/hfa.cc +++ b/parser/libapparmor_re/hfa.cc @@ -477,10 +477,14 @@ void DFA::minimize(dfaflags_t flags) * to states within the same partitions, however this can slow * down compressed dfa compression as there are more states, */ + if (flags & DFA_DUMP_MIN_PARTS) + cerr << "Partitions after minimization\n"; for (list::iterator p = partitions.begin(); p != partitions.end(); p++) { /* representative state for this partition */ State *rep = *((*p)->begin()); + if (flags & DFA_DUMP_MIN_PARTS) + cerr << *rep << " : "; /* update representative state's transitions */ if (rep->cases.otherwise) { @@ -498,6 +502,8 @@ void DFA::minimize(dfaflags_t flags) * and accumulate permissions */ for (Partition::iterator i = ++(*p)->begin(); i != (*p)->end(); i++) { //cerr << " " << (*i)->label; + if (flags & DFA_DUMP_MIN_PARTS) + cerr << **i << ", "; (*i)->label = -1; rep->accept |= (*i)->accept; rep->audit |= (*i)->audit; @@ -506,6 +512,8 @@ void DFA::minimize(dfaflags_t flags) final_accept++; //if ((*p)->size() > 1) //cerr << "\n"; + if (flags & DFA_DUMP_MIN_PARTS) + cerr << "\n"; } if (flags & DFA_DUMP_STATS) cerr << "\033[2KMinimized dfa: final partitions " diff --git a/parser/parser_main.c b/parser/parser_main.c index 1151219ec..e65e8ae2a 100644 --- a/parser/parser_main.c +++ b/parser/parser_main.c @@ -216,6 +216,8 @@ optflag_table_t dumpflag_table[] = { DFA_DUMP_UNIQ_PERMS }, { 1, "dfa-minimize-uniq-perms", "Dump unique perms post minimization", DFA_DUMP_MIN_UNIQ_PERMS }, + { 1, "dfa-minimize-partitions", "Dump dfa minimization partitions", + DFA_DUMP_MIN_PARTS }, { 1, "compress-progress", "Dump progress of compression", DFA_DUMP_TRANS_PROGRESS | DFA_DUMP_TRANS_STATS }, { 1, "compress-stats", "Dump stats on compression",