[apparmor] [PATCH 08/11] Update dfa stats output
John Johansen
john.johansen at canonical.com
Tue Oct 19 01:20:40 BST 2010
Update state progress/stats output to dump the number of accepting
states/partitions occur in the minimized dfa.
---
parser/libapparmor_re/regexp.y | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/parser/libapparmor_re/regexp.y b/parser/libapparmor_re/regexp.y
index 49d9f37..88c08bd 100644
--- a/parser/libapparmor_re/regexp.y
+++ b/parser/libapparmor_re/regexp.y
@@ -1712,6 +1712,7 @@ void DFA::minimize(dfaflags_t flags)
* minimization.
*/
int accept_count = 0;
+ int final_accept = 0;
for (Partition::iterator i = states.begin(); i != states.end(); i++) {
uint64_t perm_hash = 0;
if (flags & DFA_CONTROL_MINIMIZE_HASH_PERMS) {
@@ -1743,7 +1744,7 @@ void DFA::minimize(dfaflags_t flags)
if ((flags & DFA_DUMP_PROGRESS) &&
(partitions.size() % 1000 == 0))
- cerr << "\033[2KMinimize dfa: partitions " << partitions.size() << "\tinit " << partitions.size() << "\t(accept " << accept_count << ")\r";
+ cerr << "\033[2KMinimize dfa: partitions " << partitions.size() << "\tinit " << partitions.size() << " (accept " << accept_count << ")\r";
}
/* perm_map is no longer needed so free the memory it is using.
@@ -1753,7 +1754,7 @@ void DFA::minimize(dfaflags_t flags)
int init_count = partitions.size();
if (flags & DFA_DUMP_PROGRESS)
- cerr << "\033[2KMinimize dfa: partitions " << partitions.size() << "\tinit " << init_count << "\t(accept " << accept_count << ")\r";
+ cerr << "\033[2KMinimize dfa: partitions " << partitions.size() << "\tinit " << init_count << " (accept " << accept_count << ")\r";
/* Now do repartitioning until each partition contains the set of
* states that are the same. This will happen when the partition
@@ -1796,15 +1797,15 @@ void DFA::minimize(dfaflags_t flags)
}
if ((flags & DFA_DUMP_PROGRESS) &&
(partitions.size() % 100 == 0))
- cerr << "\033[2KMinimize dfa: partitions " << partitions.size() << "\tinit " << init_count << "\t(accept " << accept_count << ")\r";
+ cerr << "\033[2KMinimize dfa: partitions " << partitions.size() << "\tinit " << init_count << " (accept " << accept_count << ")\r";
}
} while(new_part_count);
- if (flags & DFA_DUMP_STATS)
- cerr << "\033[2KMinimized dfa: partitions " << partitions.size() << "\tinit " << init_count << "\t(accept " << accept_count << ")\n";
+ if (partitions.size() == states.size()) {
+ if (flags & DFA_DUMP_STATS)
+ cerr << "\033[2KDfa minimization no states removed: partitions " << partitions.size() << "\tinit " << init_count << " (accept " << accept_count << ")\n";
- if (partitions.size() == states.size()) {
goto out;
}
@@ -1840,9 +1841,15 @@ void DFA::minimize(dfaflags_t flags)
rep->accept |= (*i)->accept;
rep->audit |= (*i)->audit;
}
+ if (rep->accept || rep->audit)
+ final_accept++;
//if ((*p)->size() > 1)
//cerr << "\n";
}
+ if (flags & DFA_DUMP_STATS)
+ cerr << "\033[2KMinimized dfa: final partitions " << partitions.size() << " (accept " << final_accept << ")" << "\tinit " << init_count << " (accept " << accept_count << ")\n";
+
+
/* make sure nonmatching and start state are up to date with the
* mappings */
--
1.7.1
More information about the AppArmor
mailing list