Skip to content

Commit

Permalink
improved
Browse files Browse the repository at this point in the history
  • Loading branch information
alwin-joshy committed Jan 15, 2024
1 parent 0e95e54 commit 09eba1d
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions apps/sel4test-tests/src/arch/arm/tests/breakpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
#include "../../../test.h"
#include "../../../tests/breakpoints.h"

static int faulter(seL4_Word arg0, seL4_Word arg1, seL4_Word arg2, seL4_Word arg3) {
static int faulter_main(seL4_Word arg0, seL4_Word arg1, seL4_Word arg2, seL4_Word arg3) {
TEST_SINGLE_STEP_ASM();
/* NOTHING BELOW SHOULD EVER BE REACHED */
int *ptr = NULL;
*ptr = 0xBEEF;
return 0;
}

static int single_step_handler(seL4_Word _fault_ep_cspath, seL4_Word faulter_tcb, seL4_Word a2, seL4_Word a3) {
static int handler_main(seL4_Word faulter_tcb, seL4_Word a1, seL4_Word a2, seL4_Word a3) {
seL4_Word sender_badge;
seL4_MessageInfo_t tag;
seL4_Word label;
Expand Down Expand Up @@ -56,48 +57,44 @@ static int single_step_handler(seL4_Word _fault_ep_cspath, seL4_Word faulter_tcb
fault_data.vaddr2 = seL4_GetMR(seL4_DebugException_TriggerAddress);
fault_data.bp_num = seL4_GetMR(seL4_DebugException_BreakpointNumber);

switch (label) {
case seL4_Fault_DebugException:
return 0;
default:
if (label == seL4_Fault_DebugException &&
fault_data.reason == seL4_SingleStep &&
fault_data.vaddr == (seL4_Word) &TEST_SS_LABEL_TWO) {

return 0;
} else {
ZF_LOGE("Fault of type %zd received. Vaddr 0x%zx\n", label, fault_data.vaddr);
fault_data.bp_num = 0;
return -1;
}
}

static void setup_ss_handler_thread_for_test(struct env *env, helper_thread_t *handler_thread, seL4_CPtr faulter_tcb) {
create_helper_thread(env, handler_thread);
NAME_THREAD(get_helper_tcb(handler_thread), "Handler");
set_helper_priority(env, handler_thread, BREAKPOINT_TEST_HANDLER_PRIO);
start_helper(env, handler_thread, &single_step_handler, (seL4_Word)&fault_ep_cspath, faulter_tcb, 0, 0);
}

static int test_single_step_one(struct env *env) {
int error, result;
helper_thread_t faulter_thread, handler_thread;
test_eq(setup_caps_for_test(env), 0);

create_helper_thread(env, &handler_thread);
set_helper_priority(env, &handler_thread, BREAKPOINT_TEST_HANDLER_PRIO);

error = setup_faulter_thread_for_test(env, &faulter_thread);
test_eq(error, seL4_NoError);

setup_ss_handler_thread_for_test(env, &handler_thread, get_helper_tcb(&faulter_thread));

/* We want it to run until the first label */
error = seL4_TCB_SetBreakpoint(get_helper_tcb(&faulter_thread), 0, (seL4_Word) &TEST_SS_LABEL_ONE,
seL4_InstructionBreakpoint, 0, seL4_BreakOnRead);
test_eq(error, seL4_NoError);
start_helper(env, &faulter_thread, &faulter, 0, 0, 0, 0);

start_helper(env, &handler_thread, &handler_main, get_helper_tcb(&faulter_thread), 0, 0, 0);
start_helper(env, &faulter_thread, &faulter_main, 0, 0, 0, 0);

result = wait_for_helper(&handler_thread);

cleanup_helper(env, &faulter_thread);
cleanup_helper(env, &handler_thread);

/* Ensure the fault address is the address of the function */
/* Ensure the test was a success */
test_eq(result, 0);
test_eq(fault_data.reason, (seL4_Word)seL4_SingleStep);
test_eq(fault_data.vaddr,
(seL4_Word) & (TEST_SS_LABEL_TWO));

return sel4test_get_result();
}
Expand Down

0 comments on commit 09eba1d

Please sign in to comment.