mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
fdr_confirm_compile: clean up debugging code
This commit is contained in:
parent
37e7c96424
commit
d626cb68e0
@ -221,55 +221,61 @@ getFDRConfirm(const vector<hwlmLiteral> &lits, bool applyOneCharOpt,
|
|||||||
#ifdef FDR_CONFIRM_DUMP
|
#ifdef FDR_CONFIRM_DUMP
|
||||||
// print out the literals reversed - makes it easier to line up analyses
|
// print out the literals reversed - makes it easier to line up analyses
|
||||||
// that are end-offset based
|
// that are end-offset based
|
||||||
for (map<u32, vector<LiteralIndex> >::iterator i = res2lits.begin(),
|
for (const auto &m : res2lits) {
|
||||||
e = res2lits.end(); i != e; ++i) {
|
const u32 &hash = m.first;
|
||||||
u32 hash = i->first;
|
const vector<LiteralIndex> &vlidx = m.second;
|
||||||
vector<LiteralIndex> & vlidx = i->second;
|
if (vlidx.size() <= 1) {
|
||||||
if (vlidx.size() > 1) {
|
continue;
|
||||||
|
}
|
||||||
printf("%x -> %zu literals\n", hash, vlidx.size());
|
printf("%x -> %zu literals\n", hash, vlidx.size());
|
||||||
u32 min_len = lits[vlidx.front()].s.size();
|
size_t min_len = lits[vlidx.front()].s.size();
|
||||||
|
|
||||||
vector<set<u8>> vsl; // contains the set of chars at each location
|
vector<set<u8>> vsl; // contains the set of chars at each location
|
||||||
// reversed from the end
|
// reversed from the end
|
||||||
vsl.resize(1024);
|
|
||||||
u32 total_string_size = 0;
|
for (const auto &litIdx : vlidx) {
|
||||||
for (vector<LiteralIndex>::iterator i2 = vlidx.begin(),
|
const auto &lit = lits[litIdx];
|
||||||
e2 = vlidx.end(); i2 != e2; ++i2) {
|
if (lit.s.size() > vsl.size()) {
|
||||||
LiteralIndex litIdx = *i2;
|
vsl.resize(lit.s.size());
|
||||||
total_string_size += lits[litIdx].s.size();
|
|
||||||
for (u32 j = lits[litIdx].s.size(); j != 0 ; j--) {
|
|
||||||
vsl[lits[litIdx].s.size()-j].insert(lits[litIdx].s.c_str()[j - 1]);
|
|
||||||
}
|
}
|
||||||
min_len = MIN(min_len, lits[litIdx].s.size());
|
for (size_t j = lit.s.size(); j != 0; j--) {
|
||||||
|
vsl[lit.s.size() - j].insert(lit.s[j - 1]);
|
||||||
|
}
|
||||||
|
min_len = min(min_len, lit.s.size());
|
||||||
}
|
}
|
||||||
printf("common ");
|
printf("common ");
|
||||||
for (u32 j = 0; j < min_len; j++) {
|
for (size_t j = 0; j < min_len; j++) {
|
||||||
if (vsl[j].size() == 1) {
|
if (vsl[j].size() == 1) {
|
||||||
printf("%02x", (u32)*vsl[j].begin());
|
printf("%02x", *vsl[j].begin());
|
||||||
} else {
|
} else {
|
||||||
printf("__");
|
printf("__");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (vector<LiteralIndex>::iterator i2 = vlidx.begin(),
|
for (const auto &litIdx : vlidx) {
|
||||||
e2 = vlidx.end(); i2 != e2; ++i2) {
|
const auto &lit = lits[litIdx];
|
||||||
LiteralIndex litIdx = *i2;
|
printf("%8x %c", lit.id, lit.nocase ? '!' : ' ');
|
||||||
printf("%8x %c", lits[litIdx].id, lits[litIdx].nocase ? '!' : ' ');
|
for (size_t j = lit.s.size(); j != 0; j--) {
|
||||||
for (u32 j = lits[litIdx].s.size(); j != 0 ; j--) {
|
size_t dist_from_end = lit.s.size() - j;
|
||||||
u32 dist_from_end = lits[litIdx].s.size() - j;
|
|
||||||
if (dist_from_end < min_len && vsl[dist_from_end].size() == 1) {
|
if (dist_from_end < min_len && vsl[dist_from_end].size() == 1) {
|
||||||
printf("__");
|
printf("__");
|
||||||
} else {
|
} else {
|
||||||
printf("%02x", (u32)lits[litIdx].s.c_str()[j-1]);
|
printf("%02x", lit.s[j - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
u32 total_compares = 0;
|
size_t total_compares = 0;
|
||||||
for (u32 j = 0; j < 1024; j++) { // naughty
|
for (const auto &v : vsl) {
|
||||||
total_compares += vsl[j].size();
|
total_compares += v.size();
|
||||||
}
|
}
|
||||||
printf("Total compare load: %d Total string size: %d\n\n", total_compares, total_string_size);
|
size_t total_string_size = 0;
|
||||||
|
for (const auto &litIdx : vlidx) {
|
||||||
|
const auto &lit = lits[litIdx];
|
||||||
|
total_string_size += lit.s.size();
|
||||||
}
|
}
|
||||||
|
printf("Total compare load: %zu Total string size: %zu\n\n",
|
||||||
|
total_compares, total_string_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user