mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 03:34:25 +03:00
remove start argument in literal matcher callbacks
This commit is contained in:
committed by
Matthew Barr
parent
482e1ef931
commit
ebb1b0006b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -178,13 +178,11 @@ void roseBlockEodExec(const struct RoseEngine *t, u64a offset,
|
||||
assert(!scratch->tctxt.filledDelayedSlots);
|
||||
|
||||
const u64a som = 0;
|
||||
const size_t match_len = 0;
|
||||
const u8 flags = ROSE_PROG_FLAG_SKIP_MPV_CATCHUP;
|
||||
|
||||
// Note: we ignore the result, as this is the last thing to ever happen on
|
||||
// a scan.
|
||||
roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, match_len,
|
||||
flags);
|
||||
roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -51,13 +51,12 @@ static really_inline
|
||||
int roseNfaRunProgram(const struct RoseEngine *rose, struct hs_scratch *scratch,
|
||||
u64a som, u64a offset, ReportID id, const char from_mpv) {
|
||||
const u32 program = id;
|
||||
const size_t match_len = 0; // Unused in this path.
|
||||
u8 flags = ROSE_PROG_FLAG_IN_CATCHUP;
|
||||
if (from_mpv) {
|
||||
flags |= ROSE_PROG_FLAG_FROM_MPV;
|
||||
}
|
||||
|
||||
roseRunProgram(rose, scratch, program, som, offset, match_len, flags);
|
||||
roseRunProgram(rose, scratch, program, som, offset, flags);
|
||||
|
||||
return can_stop_matching(scratch) ? MO_HALT_MATCHING : MO_CONTINUE_MATCHING;
|
||||
}
|
||||
|
@@ -66,8 +66,7 @@ void printMatch(const struct core_info *ci, u64a start, u64a end) {
|
||||
}
|
||||
#endif
|
||||
|
||||
hwlmcb_rv_t roseDelayRebuildCallback(size_t start, size_t end, u32 id,
|
||||
void *ctx) {
|
||||
hwlmcb_rv_t roseDelayRebuildCallback(size_t end, u32 id, void *ctx) {
|
||||
struct hs_scratch *scratch = ctx;
|
||||
struct RoseContext *tctx = &scratch->tctxt;
|
||||
struct core_info *ci = &scratch->core_info;
|
||||
@@ -77,9 +76,9 @@ hwlmcb_rv_t roseDelayRebuildCallback(size_t start, size_t end, u32 id,
|
||||
u64a real_end = ci->buf_offset - rb_len + end + 1; // index after last byte
|
||||
|
||||
#ifdef DEBUG
|
||||
DEBUG_PRINTF("REBUILD MATCH id=%u offsets=[%llu,%llu]: ", id,
|
||||
start + ci->buf_offset - rb_len, real_end);
|
||||
printMatch(ci, start + ci->buf_offset - rb_len, real_end);
|
||||
DEBUG_PRINTF("REBUILD MATCH id=%u end offset@%llu]: ", id, real_end);
|
||||
u64a start = real_end < 8 ? 1 : real_end - 7;
|
||||
printMatch(ci, start, real_end);
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
@@ -87,10 +86,9 @@ hwlmcb_rv_t roseDelayRebuildCallback(size_t start, size_t end, u32 id,
|
||||
|
||||
assert(id && id < t->size); // id is a program offset
|
||||
const u64a som = 0;
|
||||
const size_t match_len = end - start + 1;
|
||||
const u8 flags = 0;
|
||||
UNUSED hwlmcb_rv_t rv =
|
||||
roseRunProgram(t, scratch, id, som, real_end, match_len, flags);
|
||||
roseRunProgram(t, scratch, id, som, real_end, flags);
|
||||
assert(rv != HWLM_TERMINATE_MATCHING);
|
||||
|
||||
/* we are just repopulating the delay queue, groups should be
|
||||
@@ -200,8 +198,6 @@ int roseAnchoredCallback(u64a start, u64a end, u32 id, void *ctx) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
||||
const size_t match_len = 0;
|
||||
|
||||
/* delayed literals need to be delivered before real literals; however
|
||||
* delayed literals only come from the floating table so if we are going
|
||||
* to deliver a literal here it must be too early for a delayed literal */
|
||||
@@ -216,8 +212,8 @@ int roseAnchoredCallback(u64a start, u64a end, u32 id, void *ctx) {
|
||||
|
||||
// Note that the "id" we have been handed is the program offset.
|
||||
const u8 flags = ROSE_PROG_FLAG_IN_ANCHORED;
|
||||
if (roseRunProgram(t, scratch, id, start, real_end, match_len,
|
||||
flags) == HWLM_TERMINATE_MATCHING) {
|
||||
if (roseRunProgram(t, scratch, id, start, real_end, flags)
|
||||
== HWLM_TERMINATE_MATCHING) {
|
||||
assert(can_stop_matching(scratch));
|
||||
DEBUG_PRINTF("caller requested termination\n");
|
||||
return MO_HALT_MATCHING;
|
||||
@@ -237,12 +233,12 @@ int roseAnchoredCallback(u64a start, u64a end, u32 id, void *ctx) {
|
||||
static really_inline
|
||||
hwlmcb_rv_t roseProcessMatchInline(const struct RoseEngine *t,
|
||||
struct hs_scratch *scratch, u64a end,
|
||||
size_t match_len, u32 id) {
|
||||
u32 id) {
|
||||
DEBUG_PRINTF("id=%u\n", id);
|
||||
assert(id && id < t->size); // id is an offset into bytecode
|
||||
const u64a som = 0;
|
||||
const u8 flags = 0;
|
||||
return roseRunProgram_i(t, scratch, id, som, end, match_len, flags);
|
||||
return roseRunProgram_i(t, scratch, id, som, end, flags);
|
||||
}
|
||||
|
||||
static rose_inline
|
||||
@@ -274,7 +270,7 @@ hwlmcb_rv_t playDelaySlot(const struct RoseEngine *t,
|
||||
const u64a som = 0;
|
||||
const u8 flags = 0;
|
||||
hwlmcb_rv_t rv = roseRunProgram(t, scratch, programs[it], som, offset,
|
||||
0, flags);
|
||||
flags);
|
||||
DEBUG_PRINTF("DONE groups=0x%016llx\n", tctxt->groups);
|
||||
|
||||
/* delayed literals can't safely set groups.
|
||||
@@ -311,7 +307,7 @@ hwlmcb_rv_t flushAnchoredLiteralAtLoc(const struct RoseEngine *t,
|
||||
const u64a som = 0;
|
||||
const u8 flags = 0;
|
||||
hwlmcb_rv_t rv = roseRunProgram(t, scratch, programs[it], som, curr_loc,
|
||||
0, flags);
|
||||
flags);
|
||||
DEBUG_PRINTF("DONE groups=0x%016llx\n", tctxt->groups);
|
||||
|
||||
/* anchored literals can't safely set groups.
|
||||
@@ -476,7 +472,7 @@ anchored_leftovers:;
|
||||
}
|
||||
|
||||
static really_inline
|
||||
hwlmcb_rv_t roseCallback_i(size_t start, size_t end, u32 id, void *ctxt) {
|
||||
hwlmcb_rv_t roseCallback_i(size_t end, u32 id, void *ctxt) {
|
||||
struct hs_scratch *scratch = ctxt;
|
||||
struct RoseContext *tctx = &scratch->tctxt;
|
||||
const struct RoseEngine *t = scratch->core_info.rose;
|
||||
@@ -484,9 +480,9 @@ hwlmcb_rv_t roseCallback_i(size_t start, size_t end, u32 id, void *ctxt) {
|
||||
u64a real_end = end + tctx->lit_offset_adjust;
|
||||
|
||||
#if defined(DEBUG)
|
||||
DEBUG_PRINTF("MATCH id=%u offsets=[%llu,%llu]: ", id,
|
||||
start + tctx->lit_offset_adjust, real_end);
|
||||
printMatch(&scratch->core_info, start + tctx->lit_offset_adjust, real_end);
|
||||
DEBUG_PRINTF("MATCH id=%u end offset@%llu: ", id, real_end);
|
||||
u64a start = real_end < 8 ? 1 : real_end - 7;
|
||||
printMatch(&scratch->core_info, start, real_end);
|
||||
printf("\n");
|
||||
#endif
|
||||
DEBUG_PRINTF("last end %llu\n", tctx->lastEndOffset);
|
||||
@@ -510,8 +506,7 @@ hwlmcb_rv_t roseCallback_i(size_t start, size_t end, u32 id, void *ctxt) {
|
||||
return HWLM_TERMINATE_MATCHING;
|
||||
}
|
||||
|
||||
size_t match_len = end - start + 1;
|
||||
rv = roseProcessMatchInline(t, scratch, real_end, match_len, id);
|
||||
rv = roseProcessMatchInline(t, scratch, real_end, id);
|
||||
|
||||
DEBUG_PRINTF("DONE groups=0x%016llx\n", tctx->groups);
|
||||
|
||||
@@ -524,15 +519,15 @@ hwlmcb_rv_t roseCallback_i(size_t start, size_t end, u32 id, void *ctxt) {
|
||||
return HWLM_TERMINATE_MATCHING;
|
||||
}
|
||||
|
||||
hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *ctxt) {
|
||||
return roseCallback_i(start, end, id, ctxt);
|
||||
hwlmcb_rv_t roseCallback(size_t end, u32 id, void *ctxt) {
|
||||
return roseCallback_i(end, id, ctxt);
|
||||
}
|
||||
|
||||
hwlmcb_rv_t roseFloatingCallback(size_t start, size_t end, u32 id, void *ctxt) {
|
||||
hwlmcb_rv_t roseFloatingCallback(size_t end, u32 id, void *ctxt) {
|
||||
struct hs_scratch *scratch = ctxt;
|
||||
const struct RoseEngine *t = scratch->core_info.rose;
|
||||
|
||||
return roseCallback_i(start, end, id, ctxt) & t->floating_group_mask;
|
||||
return roseCallback_i(end, id, ctxt) & t->floating_group_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -567,10 +562,9 @@ int roseRunBoundaryProgram(const struct RoseEngine *rose, u32 program,
|
||||
scratch->tctxt.minMatchOffset = stream_offset;
|
||||
|
||||
const u64a som = 0;
|
||||
const size_t match_len = 0;
|
||||
const u8 flags = 0;
|
||||
hwlmcb_rv_t rv = roseRunProgram(rose, scratch, program, som, stream_offset,
|
||||
match_len, flags);
|
||||
flags);
|
||||
if (rv == HWLM_TERMINATE_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
@@ -588,10 +582,9 @@ int roseReportAdaptor(u64a start, u64a end, ReportID id, void *context) {
|
||||
|
||||
// Our match ID is the program offset.
|
||||
const u32 program = id;
|
||||
const size_t match_len = 0; // Unused in this path.
|
||||
const u8 flags = ROSE_PROG_FLAG_SKIP_MPV_CATCHUP;
|
||||
hwlmcb_rv_t rv =
|
||||
roseRunProgram(rose, scratch, program, start, end, match_len, flags);
|
||||
roseRunProgram(rose, scratch, program, start, end, flags);
|
||||
if (rv == HWLM_TERMINATE_MATCHING) {
|
||||
return MO_HALT_MATCHING;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -52,10 +52,9 @@ int roseNfaAdaptor(u64a start, u64a end, ReportID id, void *context);
|
||||
|
||||
/* Callbacks, defined in match.c */
|
||||
|
||||
hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *ctx);
|
||||
hwlmcb_rv_t roseFloatingCallback(size_t start, size_t end, u32 id, void *ctx);
|
||||
hwlmcb_rv_t roseDelayRebuildCallback(size_t start, size_t end, u32 id,
|
||||
void *ctx);
|
||||
hwlmcb_rv_t roseCallback(size_t end, u32 id, void *ctx);
|
||||
hwlmcb_rv_t roseFloatingCallback(size_t end, u32 id, void *ctx);
|
||||
hwlmcb_rv_t roseDelayRebuildCallback(size_t end, u32 id, void *ctx);
|
||||
int roseAnchoredCallback(u64a start, u64a end, u32 id, void *ctx);
|
||||
|
||||
/* Common code, used all over Rose runtime */
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -43,8 +43,6 @@ int roseNfaEarliestSom(u64a start, UNUSED u64a end, UNUSED ReportID id,
|
||||
|
||||
hwlmcb_rv_t roseRunProgram(const struct RoseEngine *t,
|
||||
struct hs_scratch *scratch, u32 programOffset,
|
||||
u64a som, u64a end, size_t match_len,
|
||||
u8 prog_flags) {
|
||||
return roseRunProgram_i(t, scratch, programOffset, som, end, match_len,
|
||||
prog_flags);
|
||||
u64a som, u64a end, u8 prog_flags) {
|
||||
return roseRunProgram_i(t, scratch, programOffset, som, end, prog_flags);
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@
|
||||
|
||||
hwlmcb_rv_t roseRunProgram(const struct RoseEngine *t,
|
||||
struct hs_scratch *scratch, u32 programOffset,
|
||||
u64a som, u64a end, size_t match_len, u8 prog_flags);
|
||||
u64a som, u64a end, u8 prog_flags);
|
||||
|
||||
/* Inline implementation follows. */
|
||||
|
||||
@@ -1838,8 +1838,7 @@ void updateSeqPoint(struct RoseContext *tctxt, u64a offset,
|
||||
static rose_inline
|
||||
hwlmcb_rv_t roseRunProgram_i(const struct RoseEngine *t,
|
||||
struct hs_scratch *scratch, u32 programOffset,
|
||||
u64a som, u64a end, UNUSED size_t match_len,
|
||||
u8 prog_flags) {
|
||||
u64a som, u64a end, u8 prog_flags) {
|
||||
DEBUG_PRINTF("program=%u, offsets [%llu,%llu], flags=%u\n", programOffset,
|
||||
som, end, prog_flags);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
* Copyright (c) 2015-2017, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -46,7 +46,7 @@ void roseStreamExec(const struct RoseEngine *t, struct hs_scratch *scratch);
|
||||
void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
|
||||
struct hs_scratch *scratch);
|
||||
|
||||
hwlmcb_rv_t roseCallback(size_t start, size_t end, u32 id, void *context);
|
||||
hwlmcb_rv_t roseCallback(size_t end, u32 id, void *context);
|
||||
|
||||
int roseReportAdaptor(u64a start, u64a end, ReportID id, void *context);
|
||||
|
||||
|
@@ -742,11 +742,9 @@ void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
|
||||
assert(!scratch->tctxt.filledDelayedSlots);
|
||||
|
||||
const u64a som = 0;
|
||||
const size_t match_len = 0;
|
||||
const u8 flags = ROSE_PROG_FLAG_SKIP_MPV_CATCHUP;
|
||||
|
||||
// Note: we ignore the result, as this is the last thing to ever happen on
|
||||
// a scan.
|
||||
roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, match_len,
|
||||
flags);
|
||||
roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, flags);
|
||||
}
|
||||
|
Reference in New Issue
Block a user