mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-07-13 05:54:43 +03:00
rose: dump leftfix/suffix queue indices
This commit is contained in:
parent
6d87533ef0
commit
9b7eca5400
@ -1102,7 +1102,7 @@ void setLeftNfaProperties(NFA &n, const left_id &left) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
bool buildLeftfixes(const RoseBuildImpl &tbi, build_context &bc,
|
bool buildLeftfixes(RoseBuildImpl &tbi, build_context &bc,
|
||||||
QueueIndexFactory &qif, set<u32> *no_retrigger_queues,
|
QueueIndexFactory &qif, set<u32> *no_retrigger_queues,
|
||||||
bool do_prefix) {
|
bool do_prefix) {
|
||||||
const RoseGraph &g = tbi.g;
|
const RoseGraph &g = tbi.g;
|
||||||
@ -1174,6 +1174,7 @@ bool buildLeftfixes(const RoseBuildImpl &tbi, build_context &bc,
|
|||||||
setLeftNfaProperties(*nfa, leftfix);
|
setLeftNfaProperties(*nfa, leftfix);
|
||||||
|
|
||||||
qi = qif.get_queue();
|
qi = qif.get_queue();
|
||||||
|
tbi.leftfix_queue_map.emplace(leftfix, qi);
|
||||||
nfa->queueIndex = qi;
|
nfa->queueIndex = qi;
|
||||||
|
|
||||||
if (!is_prefix && !leftfix.haig() && leftfix.graph() &&
|
if (!is_prefix && !leftfix.haig() && leftfix.graph() &&
|
||||||
@ -1458,6 +1459,7 @@ void assignSuffixQueues(RoseBuildImpl &build, build_context &bc) {
|
|||||||
u32 queue = build.qif.get_queue();
|
u32 queue = build.qif.get_queue();
|
||||||
DEBUG_PRINTF("assigning %p to queue %u\n", s.graph(), queue);
|
DEBUG_PRINTF("assigning %p to queue %u\n", s.graph(), queue);
|
||||||
bc.suffixes.emplace(s, queue);
|
bc.suffixes.emplace(s, queue);
|
||||||
|
build.suffix_queue_map.emplace(s, queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +30,13 @@
|
|||||||
|
|
||||||
#include "rose_build_dump.h"
|
#include "rose_build_dump.h"
|
||||||
|
|
||||||
#include "hwlm/hwlm_build.h"
|
|
||||||
#include "rose_build_impl.h"
|
#include "rose_build_impl.h"
|
||||||
#include "rose_build_matchers.h"
|
#include "rose_build_matchers.h"
|
||||||
#include "rose/rose_dump.h"
|
#include "rose/rose_dump.h"
|
||||||
#include "rose_internal.h"
|
#include "rose_internal.h"
|
||||||
#include "ue2common.h"
|
#include "ue2common.h"
|
||||||
|
#include "hwlm/hwlm_build.h"
|
||||||
|
#include "nfa/castlecompile.h"
|
||||||
#include "nfa/nfa_internal.h"
|
#include "nfa/nfa_internal.h"
|
||||||
#include "nfagraph/ng_dump.h"
|
#include "nfagraph/ng_dump.h"
|
||||||
#include "som/slot_manager_dump.h"
|
#include "som/slot_manager_dump.h"
|
||||||
@ -64,22 +65,40 @@ static
|
|||||||
string to_string(nfa_kind k) {
|
string to_string(nfa_kind k) {
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case NFA_PREFIX:
|
case NFA_PREFIX:
|
||||||
return "p";
|
return "PREFIX";
|
||||||
case NFA_INFIX:
|
case NFA_INFIX:
|
||||||
return "i";
|
return "INFIX";
|
||||||
case NFA_SUFFIX:
|
case NFA_SUFFIX:
|
||||||
return "s";
|
return "SUFFIX";
|
||||||
case NFA_OUTFIX:
|
case NFA_OUTFIX:
|
||||||
return "o";
|
return "OUTFIX";
|
||||||
case NFA_REV_PREFIX:
|
case NFA_REV_PREFIX:
|
||||||
return "r";
|
return "REV_PREFIX";
|
||||||
case NFA_OUTFIX_RAW:
|
case NFA_OUTFIX_RAW:
|
||||||
return "O";
|
return "OUTFIX_RAW";
|
||||||
}
|
}
|
||||||
assert(0);
|
assert(0);
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** \brief Return the kind of a left_id or a suffix_id. */
|
||||||
|
template<class Graph>
|
||||||
|
string render_kind(const Graph &g) {
|
||||||
|
if (g.graph()) {
|
||||||
|
return to_string(g.graph()->kind);
|
||||||
|
}
|
||||||
|
if (g.dfa()) {
|
||||||
|
return to_string(g.dfa()->kind);
|
||||||
|
}
|
||||||
|
if (g.haig()) {
|
||||||
|
return to_string(g.haig()->kind);
|
||||||
|
}
|
||||||
|
if (g.castle()) {
|
||||||
|
return to_string(g.castle()->kind);
|
||||||
|
}
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class RoseGraphWriter {
|
class RoseGraphWriter {
|
||||||
@ -130,22 +149,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g[v].suffix) {
|
if (g[v].suffix) {
|
||||||
os << "\\nSUFFIX (TOP " << g[v].suffix.top;
|
suffix_id suff(g[v].suffix);
|
||||||
// Can't dump the queue number, but we can identify the suffix.
|
os << "\\n" << render_kind(suff) << " (top " << g[v].suffix.top;
|
||||||
if (g[v].suffix.graph) {
|
auto it = build.suffix_queue_map.find(suff);
|
||||||
os << ", graph=" << g[v].suffix.graph.get() << " "
|
if (it != end(build.suffix_queue_map)) {
|
||||||
<< to_string(g[v].suffix.graph->kind);
|
os << ", queue " << it->second;
|
||||||
}
|
}
|
||||||
if (g[v].suffix.castle) {
|
|
||||||
os << ", castle=" << g[v].suffix.castle.get();
|
|
||||||
}
|
|
||||||
if (g[v].suffix.rdfa) {
|
|
||||||
os << ", dfa=" << g[v].suffix.rdfa.get();
|
|
||||||
}
|
|
||||||
if (g[v].suffix.haig) {
|
|
||||||
os << ", haig=" << g[v].suffix.haig.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
os << ")";
|
os << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,15 +163,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g[v].left) {
|
if (g[v].left) {
|
||||||
const char *roseKind =
|
left_id left(g[v].left);
|
||||||
build.isRootSuccessor(v) ? "PREFIX" : "INFIX";
|
os << "\\n" << render_kind(left) << " (queue ";
|
||||||
os << "\\nROSE " << roseKind;
|
auto it = build.leftfix_queue_map.find(left);
|
||||||
os << " (";
|
if (it != end(build.leftfix_queue_map)) {
|
||||||
os << "report " << g[v].left.leftfix_report << ")";
|
os << it->second;
|
||||||
|
} else {
|
||||||
if (g[v].left.graph) {
|
os << "??";
|
||||||
os << " " << to_string(g[v].left.graph->kind);
|
|
||||||
}
|
}
|
||||||
|
os << ", report " << g[v].left.leftfix_report << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "\"";
|
os << "\"";
|
||||||
|
@ -541,6 +541,12 @@ public:
|
|||||||
|
|
||||||
u32 ematcher_region_size; /**< number of bytes the eod table runs over */
|
u32 ematcher_region_size; /**< number of bytes the eod table runs over */
|
||||||
|
|
||||||
|
/** \brief Mapping from leftfix to queue ID (used in dump code). */
|
||||||
|
unordered_map<left_id, u32> leftfix_queue_map;
|
||||||
|
|
||||||
|
/** \brief Mapping from suffix to queue ID (used in dump code). */
|
||||||
|
unordered_map<suffix_id, u32> suffix_queue_map;
|
||||||
|
|
||||||
/** \brief Mapping from anchored literal ID to the original literal suffix
|
/** \brief Mapping from anchored literal ID to the original literal suffix
|
||||||
* present when the literal was added to the literal matcher. Used for
|
* present when the literal was added to the literal matcher. Used for
|
||||||
* overlap calculation in history assignment. */
|
* overlap calculation in history assignment. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user