1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @LICENSE(DATA61_BSD) 11 */ 12 13#include <sel4/sel4.h> 14#include <sel4debug/register_dump.h> 15 16#include <stdbool.h> 17#include <stdio.h> 18#include <utils/zf_log.h> 19 20void sel4debug_dump_registers(seL4_CPtr tcb) 21{ 22 sel4debug_dump_registers_prefix(tcb, ""); 23} 24 25void sel4debug_dump_registers_prefix(seL4_CPtr tcb, char *prefix) 26{ 27 seL4_UserContext context; 28 int error; 29 const int num_regs = sizeof(context) / sizeof(seL4_Word); 30 31 error = seL4_TCB_ReadRegisters(tcb, false, 0, num_regs, &context); 32 if (error) { 33 ZF_LOGE("Failed to read registers for tcb 0x%lx, error %d", (long) tcb, error); 34 return; 35 } 36 37 printf("%sRegister dump:\n", prefix); 38 for (int i = 0; i < num_regs; i++) { 39 printf("%s%s\t:0x%lx\n", prefix, register_names[i], (long) ((seL4_Word * )&context)[i]); 40 } 41} 42