From 09eba1d5c20f978e81e6424371331d261ea37df7 Mon Sep 17 00:00:00 2001 From: Alwin Joshy Date: Mon, 15 Jan 2024 17:11:10 +1100 Subject: [PATCH] improved --- .../src/arch/arm/tests/breakpoints.c | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/apps/sel4test-tests/src/arch/arm/tests/breakpoints.c b/apps/sel4test-tests/src/arch/arm/tests/breakpoints.c index 6e15a005..d4c9f42d 100644 --- a/apps/sel4test-tests/src/arch/arm/tests/breakpoints.c +++ b/apps/sel4test-tests/src/arch/arm/tests/breakpoints.c @@ -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; @@ -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(); }