Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
ksco committed Mar 28, 2024
1 parent 147bbc8 commit 491daa1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions suite/tests/client-interface/stolen-reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ main(int argc, char **argv)

join_thread(thread);

/* TODO i#3544: Add synchall support to RISC-V. */
#ifndef RISCV64
val = get_stolen_reg_val();
if (val != STOLEN_REG_SENTINEL) {
Expand Down
21 changes: 11 additions & 10 deletions suite/tests/client-interface/stolen-reg.dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
/* See stolen-reg.c for the same definition. */
#define BAD_VALUE 0x123

#define STOLEN_REG IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11))

/* We assume the app is single-threaded and don't worry about races. */
static ptr_int_t app_stolen_reg_val;

Expand All @@ -52,19 +54,18 @@ restore_event(void *drcontext, void *tag, dr_mcontext_t *mcontext, bool restore_
* restore event for simplicity.
*/
dr_log(drcontext, DR_LOG_ALL, 2, "Changing the stolen reg value from %ld to %ld\n",
mcontext->IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11)), app_stolen_reg_val);
mcontext->IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11)) = app_stolen_reg_val;
mcontext->STOLEN_REG, app_stolen_reg_val);
mcontext->STOLEN_REG = app_stolen_reg_val;
}

static void
do_flush(app_pc next_pc)
{
dr_fprintf(STDERR, "Performing synchall flush\n");

/* FIXME i#3544: synchall translation path does not work with RISC-V yet. */
/* TODO i#3544: Add synchall support to RISC-V. */
#ifndef RISCV64
if (!dr_flush_region(NULL, ~0UL))
DR_ASSERT(false);
if (!dr_flush_region(NULL, ~0UL)) DR_ASSERT(false);
void *drcontext = dr_get_current_drcontext();
dr_mcontext_t mcontext;
mcontext.size = sizeof(mcontext);
Expand Down Expand Up @@ -99,11 +100,11 @@ read_and_restore_stolen_reg_value()
dr_get_mcontext(drcontext, &mc);

/* The key part of the test: that the modified value shows up here. */
DR_ASSERT(mc.IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11)) == test_value);
DR_ASSERT(mc.STOLEN_REG == test_value);
dr_fprintf(STDERR, "mc->stolen_reg after = " IF_ARM_ELSE("%d", "%ld") "\n",
mc.IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11)));
mc.STOLEN_REG);

mc.IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11)) = orig_value;
mc.STOLEN_REG = orig_value;

dr_set_mcontext(drcontext, &mc);
}
Expand All @@ -124,9 +125,9 @@ change_stolen_reg_value()
mc.flags = DR_MC_ALL;
dr_get_mcontext(drcontext, &mc);

orig_value = mc.IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11));
orig_value = mc.STOLEN_REG;

mc.IF_ARM_ELSE(r10, IF_AARCH64_ELSE(r28, s11)) = test_value;
mc.STOLEN_REG = test_value;

dr_set_mcontext(drcontext, &mc);
}
Expand Down

0 comments on commit 491daa1

Please sign in to comment.