Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#2039 trace trim, part 6: Enable for AArchXX #5770

Merged
merged 5 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions clients/drcachesim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ else ()
set(os_name "unix")
derekbruening marked this conversation as resolved.
Show resolved Hide resolved
# Ditto.
add_definitions(-DUNIX)
if (LINUX)
add_definitions(-DLINUX)
elseif (APPLE)
add_definitions(-DMACOS)
endif ()
endif ()
# Ditto here, in particular for options.cpp.
if (X86)
if (X64)
add_definitions(-DX86_64)
else ()
add_definitions(-DX86_32)
endif ()
elseif (AARCHXX)
if (X64)
add_definitions(-DARM_64)
else ()
add_definitions(-DARM_32)
endif ()
endif ()

# GCC 6+ has a warning for an ABI change due to a bug introduced in GCC 5:
Expand Down Expand Up @@ -844,6 +863,7 @@ add_executable(drcachesim_ops
set_target_properties(drcachesim_ops PROPERTIES COMPILE_FLAGS "${ORIG_CMAKE_CXX_FLAGS}")
add_win32_flags(drcachesim_ops)
use_DynamoRIO_extension(drcachesim_ops droption)
add_dependencies(drcachesim_ops api_headers)

# We then have to insert it into the doxygen files at build time:
set(srcdoc ${CMAKE_CURRENT_SOURCE_DIR}/docs/drcachesim.dox.in)
Expand Down
5 changes: 3 additions & 2 deletions clients/drcachesim/common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/* shared options for both the frontend and the client */

#include <string>
#include "dr_api.h" // For IF_X86_ELSE.
#include "droption.h"
#include "options.h"

Expand Down Expand Up @@ -288,8 +289,8 @@ droption_t<bytesize_t> op_max_global_trace_refs(
droption_t<bool> op_align_endpoints(
// XXX i#2039,i#5686: Make this true by default (and maybe remove it altogether) once
// robustness issues with drbbdup are fixed (restore state for scatter/gather and
// other libs; yet-undiagnosed other state restore issues).
DROPTION_SCOPE_CLIENT, "align_endpoints", false,
// other libs; yet-undiagnosed other state restore issues) on x86.
DROPTION_SCOPE_CLIENT, "align_endpoints", IF_X86_ELSE(false, true),
"Nop tracing when partially attached or detached",
"When using attach/detach to trace a burst, the attach and detach processes are "
"staggered, with the set of threads producing trace data incrementally growing or "
Expand Down
13 changes: 13 additions & 0 deletions clients/drcachesim/tests/burst_replaceall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
static void *finished;
static constexpr int num_threads = 3;
static void *started[num_threads];
static void *attached;
static void *post_attach[num_threads];
#endif

bool
Expand Down Expand Up @@ -252,6 +254,8 @@ void *
{
uintptr_t i = reinterpret_cast<uintptr_t>(arg);
signal_cond_var(started[i]);
wait_cond_var(attached);
signal_cond_var(post_attach[i]);
wait_cond_var(finished);
return 0;
}
Expand All @@ -273,8 +277,10 @@ main(int argc, const char *argv[])
uintptr_t thread[num_threads];
# endif
finished = create_cond_var();
attached = create_cond_var();
for (uint i = 0; i < num_threads; i++) {
started[i] = create_cond_var();
post_attach[i] = create_cond_var();
# ifdef UNIX
pthread_create(&thread[i], NULL, thread_func, (void *)(uintptr_t)i);
# else
Expand Down Expand Up @@ -308,6 +314,13 @@ main(int argc, const char *argv[])
if (i == iter_start) {
std::cerr << "pre-DR start\n";
dr_app_start();
#ifndef WINDOWS // XXX i#2040: Disabled until Windows static limits are fixed.
// Ensure our threads are actually scheduled during our burst window to avoid
// missing threads from -align_endpoints.
signal_cond_var(attached);
for (uint i = 0; i < num_threads; i++)
wait_cond_var(post_attach[i]);
#endif
}
if (i >= iter_start && i <= iter_stop)
assert(dr_app_running_under_dynamorio());
Expand Down
3 changes: 1 addition & 2 deletions clients/drcachesim/tests/offline-burst_replace.templatex
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ create dir .*
open file .*
open file .*
open file .*
open file .*
derekbruening marked this conversation as resolved.
Show resolved Hide resolved
pre-DR start
pre-DR start.*
0: writing [0-9]+ bytes .*
1: writing [0-9]+ bytes .*
restore the write file function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Total counts:
*[0-9]* total data stores
*[0-9]* total icache flushes
*[0-9]* total dcache flushes
4 total threads
abhinav92003 marked this conversation as resolved.
Show resolved Hide resolved
[1-4] total threads
*[0-9]* total scheduling markers
*[0-9]* total transfer markers
0 total function id markers
Expand Down
2 changes: 2 additions & 0 deletions core/lib/dr_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ DR_API
* - There can only be one far branch (call, jump, or return) in
* a basic block, and it must be the final instruction in the
* block.
* - The AArch64 instruction ISB must be the final instruction in the
* block.
* - The exit control-flow of a block ending in a system call or
* int instruction cannot be changed, nor can instructions be inserted
* after the system call or int instruction itself, unless
Expand Down
2 changes: 1 addition & 1 deletion ext/drbbdup/drbbdup.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ drbbdup_is_special_instr(instr_t *instr)
{
return instr != NULL &&
(instr_is_syscall(instr) || instr_is_cti(instr) || instr_is_ubr(instr) ||
instr_is_interrupt(instr));
instr_is_interrupt(instr) IF_AARCH64(|| instr_get_opcode(instr) == OP_isb));
}

/****************************************************************************
Expand Down