Skip to content

Commit

Permalink
Merge branch 'master' into i7113-decode-cache-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav92003 authored Dec 14, 2024
2 parents 1e810b5 + 1f67ae1 commit 1fc4c04
Show file tree
Hide file tree
Showing 56 changed files with 8,573 additions and 3,061 deletions.
31 changes: 27 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,16 @@ if (TARGET_ARCH MATCHES "^arm64" OR TARGET_ARCH MATCHES "^aarch64")
set(AARCH64 1)
set(X64 1)
message(STATUS "Building for AArch64")
if (ANDROID)
set(ANDROID64 1)
endif ()
elseif (TARGET_ARCH MATCHES "^arm")
set(ARM 1) # This means AArch32.
set(X64 OFF)
message(STATUS "Building for ARM")
if (ANDROID)
set(ANDROID32 1)
endif ()
elseif (TARGET_ARCH MATCHES "^riscv64")
set(RISCV64 1)
set(X64 1)
Expand Down Expand Up @@ -692,6 +698,7 @@ if (UNIX)
endif (NOT CMAKE_COMPILER_IS_GNUCC)

check_if_linker_is_gnu_gold(LINKER_IS_GNU_GOLD)
check_if_linker_is_llvm_lld(LINKER_IS_LLVM_LLD)

# FIXME i#2949: static 32-bit release-build linking with gcc 7.3.1 fails when
# static C++ clients like drmemtrace or drmemtrace_raw2trace are linked in.
Expand Down Expand Up @@ -821,6 +828,7 @@ if (UNIX)
# (see i#1034 where this caused problems in the past).
set(BASE_CFLAGS "${BASE_CFLAGS} -funsigned-char")
# Ubuntu defaults to -fstack-protector these days, which depends on app TLS.
CHECK_C_COMPILER_FLAG("-no-pie" no_pie_avail)
CHECK_C_COMPILER_FLAG("-fno-stack-protector" no_stack_protector_avail)
if (no_stack_protector_avail)
set(BASE_CFLAGS "${BASE_CFLAGS} -fno-stack-protector")
Expand Down Expand Up @@ -875,14 +883,14 @@ if (UNIX)
endif ()
# there's no cmake warning control so we hardcode it
set(WARN "-Wall -Werror -Wwrite-strings -Wvla")
CHECK_C_COMPILER_FLAG("-Wno-unused-but-set-variable" nounused_avail)
if (nounused_avail)
set(WARN "${WARN} -Wno-unused-but-set-variable")
endif (nounused_avail)
if (NOT CMAKE_COMPILER_IS_CLANG)
# Old gcc's ignore unknown -W flags, but -Wall -Werror causes clang to
# complain that it doesn't recognize it.
# Actually this is not true: gcc 4.1.2 aborts on unknown -W so we check
CHECK_C_COMPILER_FLAG("-Wno-unused-but-set-variable" nounused_avail)
if (nounused_avail)
set(WARN "${WARN} -Wno-unused-but-set-variable")
endif (nounused_avail)
# XXX i#3792: DynamoRIO manages '\0' termination and error states itself in
# too many places. In order to activate this warning, this code needs to get
# re-factored for no good reason.
Expand All @@ -908,6 +916,21 @@ if (UNIX)
set(WARN "${WARN} -Wno-dangling-pointer")
endif ()
else (NOT CMAKE_COMPILER_IS_CLANG)
# Clang emits this warning when a function is used without a defined
# prototype, however clang can't find function prototpes in #define macros.
# If function prototypes are moved out of #define macros then this warning
# can be re-enabled.
CHECK_C_COMPILER_FLAG("-Wno-deprecated-non-prototype" nodeprecated_prototype_avail)
if (nodeprecated_prototype_avail)
set(WARN "${WARN} -Wno-deprecated-non-prototype")
endif (nodeprecated_prototype_avail)
# Clang emits this warning due to the assembly shared between arm and
# aarch64 in os.c not specifying register widths. If the shared code is
# split into arm and aarch64 versions, then this warning can be re-enabled.
CHECK_C_COMPILER_FLAG("-Wno-asm-operand-widths" noasm_operand_widths)
if (noasm_operand_widths)
set(WARN "${WARN} -Wno-asm-operand-widths")
endif (noasm_operand_widths)
# clang turns off color when it's writing to a pipe, but the user may still
# wish to force color if it eventually goes to a terminal.
option(CLANG_COLOR_DIAGNOSTICS "force colored clang diagnostics" OFF)
Expand Down
2 changes: 2 additions & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ Further non-compatibility-affecting changes include:
- Added the AArch64 FPMR register as DR_REG_FPMR.
- Added OPSZ_addr which chooses the appropriate operand size on X86 from 2/4/8 based
on the 32/64 bit mode and the presence or absence of the address size prefix.
- Fixed the order of operands for the vpexpandd/vpexpandq opcodes (previously the
source and destination operands were reversed).

**************************************************
<hr>
Expand Down
6 changes: 6 additions & 0 deletions clients/drcachesim/tests/invariant_checker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2825,15 +2825,21 @@ check_read_write_records_match_operands()
{
instr_t *clflush = INSTR_CREATE_clflush(
GLOBAL_DCONTEXT, OPND_CREATE_MEM_clflush(REG1, REG_NULL, 0, 0));
instr_t *clflushopt = INSTR_CREATE_clflushopt(
GLOBAL_DCONTEXT, OPND_CREATE_MEM_clflush(REG1, REG_NULL, 0, 0));
instrlist_t *ilist = instrlist_create(GLOBAL_DCONTEXT);
instrlist_append(ilist, clflush);
instrlist_append(ilist, clflushopt);
static constexpr addr_t BASE_ADDR = 0xeba4ad4;
std::vector<memref_with_IR_t> memref_setup = {
{ gen_marker(TID_A, TRACE_MARKER_TYPE_FILETYPE, OFFLINE_FILE_TYPE_ENCODINGS),
nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, 64), nullptr },
{ gen_marker(TID_A, TRACE_MARKER_TYPE_PAGE_SIZE, 4096), nullptr },
{ gen_instr(TID_A), clflush },
{ gen_addr(TID_A, /*type=*/TRACE_TYPE_DATA_FLUSH, /*addr=*/0, /*size=*/0),
nullptr },
{ gen_instr(TID_A), clflushopt },
{ gen_addr(TID_A, /*type=*/TRACE_TYPE_DATA_FLUSH, /*addr=*/0, /*size=*/0),
nullptr },
{ gen_exit(TID_A), nullptr },
Expand Down
10 changes: 5 additions & 5 deletions clients/drcachesim/tracer/instru.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2016-2023 Google, Inc. All rights reserved.
* Copyright (c) 2016-2024 Google, Inc. All rights reserved.
* **********************************************************/

/*
Expand Down Expand Up @@ -224,7 +224,7 @@ instru_t::instr_is_flush(instr_t *instr)
{
// Assuming we won't see any privileged instructions.
#ifdef X86
if (instr_get_opcode(instr) == OP_clflush)
if (instr_get_opcode(instr) == OP_clflush || instr_get_opcode(instr) == OP_clflushopt)
return true;
#endif
#ifdef AARCH64
Expand All @@ -239,9 +239,9 @@ instru_t::instr_to_flush_type(instr_t *instr)
{
DR_ASSERT(instr_is_flush(instr));
#ifdef X86
// XXX: OP_clflush invalidates all levels of the processor cache
// hierarchy (data and instruction)
if (instr_get_opcode(instr) == OP_clflush)
// XXX: OP_clflush* invalidates all levels of the processor cache
// hierarchy (data and instruction).
if (instr_get_opcode(instr) == OP_clflush || instr_get_opcode(instr) == OP_clflushopt)
return TRACE_TYPE_DATA_FLUSH;
#endif
#ifdef AARCH64
Expand Down
9 changes: 1 addition & 8 deletions clients/drcachesim/tracer/instru.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,14 @@
#include "dr_allocator.h"
#include "dr_api.h"
#include "drvector.h"
#include "raw2trace_shared.h"
#include "trace_entry.h"

namespace dynamorio {
namespace drmemtrace {

#define MINSERT instrlist_meta_preinsert

// Versioning for our drmodtrack custom module fields.
#define CUSTOM_MODULE_VERSION 1

// A std::unordered_set, even using dr_allocator_t, raises transparency risks when
// statically linked on Windows (from lock functions and other non-allocator
// resources). We thus create our own resource-isolated class to track GPR register
Expand Down Expand Up @@ -499,11 +497,6 @@ class offline_instru_t : public instru_t {
label_marks_elidable(instr_t *instr, DR_PARAM_OUT int *opnd_index,
DR_PARAM_OUT int *memopnd_index, DR_PARAM_OUT bool *is_write,
DR_PARAM_OUT bool *needs_base);
static int
print_module_data_fields(char *dst, size_t max_len, const void *custom_data,
size_t custom_size,
int (*user_print_cb)(void *data, char *dst, size_t max_len),
void *user_cb_data);

private:
struct custom_module_data_t {
Expand Down
26 changes: 1 addition & 25 deletions clients/drcachesim/tracer/instru_offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "drreg.h"
#include "drutil.h"
#include "drvector.h"
#include "raw2trace_shared.h"
#include "trace_entry.h"
#include "utils.h"
#include "instru.h"
Expand Down Expand Up @@ -186,31 +187,6 @@ offline_instru_t::load_custom_module_data(module_data_t *module, int seg_idx)
return nullptr;
}

int
offline_instru_t::print_module_data_fields(
char *dst, size_t max_len, const void *custom_data, size_t custom_size,
int (*user_print_cb)(void *data, char *dst, size_t max_len), void *user_cb_data)
{
char *cur = dst;
int len = dr_snprintf(dst, max_len, "v#%d,%zu,", CUSTOM_MODULE_VERSION, custom_size);
if (len < 0)
return -1;
cur += len;
if (cur - dst + custom_size > max_len)
return -1;
if (custom_size > 0) {
memcpy(cur, custom_data, custom_size);
cur += custom_size;
}
if (user_print_cb != nullptr) {
int res = (*user_print_cb)(user_cb_data, cur, max_len - (cur - dst));
if (res == -1)
return -1;
cur += res;
}
return (int)(cur - dst);
}

int
offline_instru_t::print_custom_module_data(void *data, char *dst, size_t max_len)
{
Expand Down
Loading

0 comments on commit 1fc4c04

Please sign in to comment.