Skip to content

Commit

Permalink
Merge branch 'master' into i7046-add-load-program-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankyluk authored Dec 5, 2024
2 parents 41c7bf2 + 100cac0 commit 903c18e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 6 deletions.
44 changes: 44 additions & 0 deletions clients/drcachesim/tests/invariant_checker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "../tools/invariant_checker.h"
#include "../common/memref.h"
#include "memref_gen.h"
#include "trace_entry.h"

#ifdef LINUX
# include "../../core/unix/include/syscall_target.h"
#endif
Expand Down Expand Up @@ -3572,6 +3574,48 @@ bool
check_regdeps(void)
{
std::cerr << "Testing regdeps traces\n";

// Incorrect: OFFLINE_FILE_TYPE_ARCH_AARCH64 not allowed.
{
std::vector<memref_t> memrefs = {
gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE,
OFFLINE_FILE_TYPE_ARCH_REGDEPS | OFFLINE_FILE_TYPE_ARCH_AARCH64),
gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64),
gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096),
gen_marker(TID_A, TRACE_MARKER_TYPE_CPU_ID, INVALID_CPU_MARKER_VALUE),
gen_instr(TID_A),
gen_exit(TID_A),
};
if (!run_checker(memrefs, true,
{ "OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have other"
"OFFLINE_FILE_TYPE_ARCH_*",
/*tid=*/TID_A,
/*ref_ordinal=*/1, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/0 },
"Failed to catch non-allowed OFFLINE_FILE_TYPE_ARCH_AARCH64"))
return false;
}

// Incorrect: TRACE_MARKER_TYPE_CPU_ID with value other than -1 not allowed.
{
std::vector<memref_t> memrefs = {
gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE, OFFLINE_FILE_TYPE_ARCH_REGDEPS),
gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64),
gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096),
gen_marker(TID_A, TRACE_MARKER_TYPE_CPU_ID, 1),
gen_instr(TID_A),
gen_exit(TID_A),
};
if (!run_checker(memrefs, true,
{ "OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have a valid "
"TRACE_MARKER_TYPE_CPU_ID",
/*tid=*/TID_A,
/*ref_ordinal=*/4, /*last_timestamp=*/0,
/*instrs_since_last_timestamp=*/0 },
"Failed to catch non-allowed TRACE_MARKER_TYPE_CPU_ID marker"))
return false;
}

// Incorrect: TRACE_MARKER_TYPE_SYSCALL_IDX not allowed.
{
std::vector<memref_t> memrefs = {
Expand Down
20 changes: 20 additions & 0 deletions clients/drcachesim/tools/invariant_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,26 @@ invariant_checker_t::check_regdeps_invariants(per_shard_t *shard, const memref_t
// Check markers.
if (memref.marker.type == TRACE_TYPE_MARKER) {
switch (memref.marker.marker_type) {
case TRACE_MARKER_TYPE_FILETYPE:
report_if_false(
shard,
static_cast<offline_file_type_t>(memref.marker.marker_value) ==
shard->file_type_,
"TRACE_MARKER_TYPE_FILETYPE and shard file type are not the same");
// Check that the file type does not contain any architecture specific
// information except OFFLINE_FILE_TYPE_ARCH_REGDEPS.
report_if_false(
shard,
!TESTANY(OFFLINE_FILE_TYPE_ARCH_ALL & ~OFFLINE_FILE_TYPE_ARCH_REGDEPS,
shard->file_type_),
"OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have other"
"OFFLINE_FILE_TYPE_ARCH_*");
break;
case TRACE_MARKER_TYPE_CPU_ID:
report_if_false(shard, memref.marker.marker_value == INVALID_CPU_MARKER_VALUE,
"OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have a valid "
"TRACE_MARKER_TYPE_CPU_ID");
break;
case TRACE_MARKER_TYPE_SYSCALL_IDX:
report_if_false(shard, false,
"OFFLINE_FILE_TYPE_ARCH_REGDEPS traces cannot have "
Expand Down
16 changes: 10 additions & 6 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4839,12 +4839,14 @@ if (BUILD_CLIENTS)
# Generate an OFFLINE_FILE_TYPE_ARCH_REGDEPS trace by running record_filter
# with -filter_encodings2regdeps to change instruction encodings,
# -filter_keep_func_ids 4294967498 (which is SYS_futex, associated to the only
# TRACE_MARKER_TYPE_FUNC_ markers we want to keep), and
# TRACE_MARKER_TYPE_FUNC_ markers we want to keep),
# -filter_marker_types 19,25,27,28,30 (which correspond to
# TRACE_MARKER_TYPE_SYSCALL_IDX, TRACE_MARKER_TYPE_SYSCALL,
# TRACE_MARKER_TYPE_SYSCALL_TRACE_START, TRACE_MARKER_TYPE_SYSCALL_TRACE_END,
# TRACE_MARKER_TYPE_SYSCALL_FAILED).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${ci_shared_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30@-filter_keep_func_ids@4294967498"
# TRACE_MARKER_TYPE_SYSCALL_FAILED), and -filter_modify_marker_value 3,-1
# (which changes the value of TRACE_MARKER_TYPE_CPU_ID == 3 to
# INVALID_CPU_MARKER_VALUE == (uintptr_t)-1).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${ci_shared_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30@-filter_keep_func_ids@4294967498@-filter_modify_marker_value@3,-1"
# We run the invariant_checker analyzer on the REGDEPS filtered trace.
# We expect no invariant errors.
"invariant_checker")
Expand All @@ -4857,12 +4859,14 @@ if (BUILD_CLIENTS)
# Generate an OFFLINE_FILE_TYPE_ARCH_REGDEPS trace by running record_filter
# with -filter_encodings2regdeps to change instruction encodings,
# -filter_keep_func_ids 4294967498 (which is SYS_futex, associated to the only
# TRACE_MARKER_TYPE_FUNC_ markers we want to keep), and
# TRACE_MARKER_TYPE_FUNC_ markers we want to keep),
# -filter_marker_types 19,25,27,28,30 (which correspond to
# TRACE_MARKER_TYPE_SYSCALL_IDX, TRACE_MARKER_TYPE_SYSCALL,
# TRACE_MARKER_TYPE_SYSCALL_TRACE_START, TRACE_MARKER_TYPE_SYSCALL_TRACE_END,
# TRACE_MARKER_TYPE_SYSCALL_FAILED).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${kernel_xfer_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30@-filter_keep_func_ids@4294967498"
# TRACE_MARKER_TYPE_SYSCALL_FAILED), and -filter_modify_marker_value 3,-1
# (which changes the value of TRACE_MARKER_TYPE_CPU_ID == 3 to
# INVALID_CPU_MARKER_VALUE == (uintptr_t)-1).
"${drcachesim_path}@-simulator_type@record_filter@-filter_encodings2regdeps@-indir@${testname}.${kernel_xfer_app}.*.dir/trace@-outdir@${testname}.filtered.dir@-filter_marker_types@19,25,27,28,30@-filter_keep_func_ids@4294967498@-filter_modify_marker_value@3,-1"
# We run the invariant_checker analyzer on the REGDEPS filtered trace.
# We expect no invariant errors.
"invariant_checker")
Expand Down

0 comments on commit 903c18e

Please sign in to comment.