2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 18:17:09 +00:00

Add debugging dump for DFA partition minimization

Allow dumping out which states where dropped during partition minimization
and which state became the partitions representative state.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
John Johansen 2011-05-20 09:26:44 -07:00
parent 414e5bf560
commit 627638a6cf
3 changed files with 11 additions and 0 deletions

View File

@ -30,6 +30,7 @@ typedef enum dfaflags {
DFA_CONTROL_REMOVE_UNREACHABLE = 1 << 7, DFA_CONTROL_REMOVE_UNREACHABLE = 1 << 7,
DFA_CONTROL_TRANS_HIGH = 1 << 8, DFA_CONTROL_TRANS_HIGH = 1 << 8,
DFA_DUMP_MIN_PARTS = 1 << 13,
DFA_DUMP_UNIQ_PERMS = 1 << 14, DFA_DUMP_UNIQ_PERMS = 1 << 14,
DFA_DUMP_MIN_UNIQ_PERMS = 1 << 15, DFA_DUMP_MIN_UNIQ_PERMS = 1 << 15,
DFA_DUMP_TREE_STATS = 1 << 16, DFA_DUMP_TREE_STATS = 1 << 16,

View File

@ -477,10 +477,14 @@ void DFA::minimize(dfaflags_t flags)
* to states within the same partitions, however this can slow * to states within the same partitions, however this can slow
* down compressed dfa compression as there are more states, * down compressed dfa compression as there are more states,
*/ */
if (flags & DFA_DUMP_MIN_PARTS)
cerr << "Partitions after minimization\n";
for (list<Partition *>::iterator p = partitions.begin(); for (list<Partition *>::iterator p = partitions.begin();
p != partitions.end(); p++) { p != partitions.end(); p++) {
/* representative state for this partition */ /* representative state for this partition */
State *rep = *((*p)->begin()); State *rep = *((*p)->begin());
if (flags & DFA_DUMP_MIN_PARTS)
cerr << *rep << " : ";
/* update representative state's transitions */ /* update representative state's transitions */
if (rep->cases.otherwise) { if (rep->cases.otherwise) {
@ -498,6 +502,8 @@ void DFA::minimize(dfaflags_t flags)
* and accumulate permissions */ * and accumulate permissions */
for (Partition::iterator i = ++(*p)->begin(); i != (*p)->end(); i++) { for (Partition::iterator i = ++(*p)->begin(); i != (*p)->end(); i++) {
//cerr << " " << (*i)->label; //cerr << " " << (*i)->label;
if (flags & DFA_DUMP_MIN_PARTS)
cerr << **i << ", ";
(*i)->label = -1; (*i)->label = -1;
rep->accept |= (*i)->accept; rep->accept |= (*i)->accept;
rep->audit |= (*i)->audit; rep->audit |= (*i)->audit;
@ -506,6 +512,8 @@ void DFA::minimize(dfaflags_t flags)
final_accept++; final_accept++;
//if ((*p)->size() > 1) //if ((*p)->size() > 1)
//cerr << "\n"; //cerr << "\n";
if (flags & DFA_DUMP_MIN_PARTS)
cerr << "\n";
} }
if (flags & DFA_DUMP_STATS) if (flags & DFA_DUMP_STATS)
cerr << "\033[2KMinimized dfa: final partitions " cerr << "\033[2KMinimized dfa: final partitions "

View File

@ -216,6 +216,8 @@ optflag_table_t dumpflag_table[] = {
DFA_DUMP_UNIQ_PERMS }, DFA_DUMP_UNIQ_PERMS },
{ 1, "dfa-minimize-uniq-perms", "Dump unique perms post minimization", { 1, "dfa-minimize-uniq-perms", "Dump unique perms post minimization",
DFA_DUMP_MIN_UNIQ_PERMS }, DFA_DUMP_MIN_UNIQ_PERMS },
{ 1, "dfa-minimize-partitions", "Dump dfa minimization partitions",
DFA_DUMP_MIN_PARTS },
{ 1, "compress-progress", "Dump progress of compression", { 1, "compress-progress", "Dump progress of compression",
DFA_DUMP_TRANS_PROGRESS | DFA_DUMP_TRANS_STATS }, DFA_DUMP_TRANS_PROGRESS | DFA_DUMP_TRANS_STATS },
{ 1, "compress-stats", "Dump stats on compression", { 1, "compress-stats", "Dump stats on compression",