void GpsimProcessor::executeNext() { if ( !m_bIsRunning ) return; if ( !m_bCanExecuteNextCycle ) { m_bCanExecuteNextCycle = true; return; } unsigned long long beforeExecuteCount = get_cycles().get(); if(get_bp().have_interrupt()) { m_pPicProcessor->interrupt(); } else { m_pPicProcessor->step_one(false); // Don't know what the false is for; gpsim ignores its value anyway // Some instructions take more than one cycle to execute, so ignore next cycle if this was the case if ( (get_cycles().get() - beforeExecuteCount) > 1 ) m_bCanExecuteNextCycle = false; } currentDebugger()->checkForBreak(); // Let's also update the values of RegisterInfo every 25 milliseconds if ( (beforeExecuteCount % 10000) == 0 ) registerMemory()->update(); }
std::string body_part_name_accusative( body_part bp, int number ) { const auto &bdy = get_bp( bp ); return npgettext( "bodypart_accusative", bdy.name.c_str(), bdy.name_multiple.c_str(), number ); }
void save(size_t sz) { m_sz = sz; stack_frame* frame; void* st = 0; exlib::Thread_base* fb = exlib::Thread_base::current(); if (fb) st = (void*)fb->stackguard(); get_bp(frame); frame = frame->next->next; m_frame_count = 0; while (frame && m_frame_count < (int32_t)ARRAYSIZE(m_frames)) { m_frames[m_frame_count++] = frame->ret; stack_frame* frame1 = frame->next; if (frame1 < frame || (((intptr_t)frame1 & stack_align_mask) != 0) || (st && frame1 >= st) || frame1->ret == 0) break; frame = frame1; } }
void dump_stack(void) { unsigned long bp = 0; unsigned long stack; #ifdef CONFIG_FRAME_POINTER if (!bp) get_bp(bp); #endif printk("Pid: %d, comm: %.20s %s %s %.*s\n", current->pid, current->comm, print_tainted(), init_utsname()->release, (int)strcspn(init_utsname()->version, " "), init_utsname()->version); show_trace(NULL, NULL, &stack, bp); }
void dump_trace(struct task_struct *task, struct pt_regs *regs, unsigned long *stack, unsigned long bp, const struct stacktrace_ops *ops, void *data) { int graph = 0; if (!task) task = current; if (!stack) { unsigned long dummy; stack = &dummy; if (task && task != current) stack = (unsigned long *)task->thread.sp; } #ifdef CONFIG_FRAME_POINTER if (!bp) { if (task == current) { /* Grab bp right from our regs */ get_bp(bp); } else { /* bp is the last reg pushed by switch_to */ bp = *(unsigned long *) task->thread.sp; } } #endif for (;;) { struct thread_info *context; context = (struct thread_info *) ((unsigned long)stack & (~(THREAD_SIZE - 1))); bp = print_context_stack(context, stack, bp, ops, data, NULL, &graph); stack = (unsigned long *)context->previous_esp; if (!stack) break; if (ops->stack(data, "IRQ") < 0) break; touch_nmi_watchdog(); } }
void util_stacktrace(void) { #if USE_SYSDEBUG reg_t bp, pc, hbp; bp= get_bp(); while(bp) { pc= ((reg_t *)bp)[1]; hbp= ((reg_t *)bp)[0]; printf("0x%lx ", (unsigned long) pc); if (hbp != 0 && hbp <= bp) { printf("0x%lx ", (unsigned long) -1); break; } bp= hbp; } printf("\n"); #endif /* USE_SYSDEBUG */ }
void body_part_struct::check() const { const auto &under_token = get_bp( token ); if( this != &under_token ) { debugmsg( "Body part %s has duplicate token %d, mapped to %s", id.c_str(), token, under_token.id.c_str() ); } if( !id.is_null() && main_part.is_null() ) { debugmsg( "Body part %s has unset main part", id.c_str() ); } if( !id.is_null() && opposite_part.is_null() ) { debugmsg( "Body part %s has unset opposite part", id.c_str() ); } if( !main_part.is_valid() ) { debugmsg( "Body part %s has invalid main part %s.", id.c_str(), main_part.c_str() ); } if( !opposite_part.is_valid() ) { debugmsg( "Body part %s has invalid opposite part %s.", id.c_str(), opposite_part.c_str() ); } }
void dump_trace(struct task_struct *task, struct pt_regs *regs, unsigned long *stack, unsigned long bp, const struct stacktrace_ops *ops, void *data) { const unsigned cpu = get_cpu(); unsigned long *irq_stack_end = (unsigned long *)per_cpu(irq_stack_ptr, cpu); unsigned used = 0; struct thread_info *tinfo; int graph = 0; if (!task) task = current; if (!stack) { unsigned long dummy; stack = &dummy; if (task && task != current) stack = (unsigned long *)task->thread.sp; } #ifdef CONFIG_FRAME_POINTER if (!bp) { if (task == current) { /* Grab bp right from our regs */ get_bp(bp); } else { /* bp is the last reg pushed by switch_to */ bp = *(unsigned long *) task->thread.sp; } } #endif /* * Print function call entries in all stacks, starting at the * current stack address. If the stacks consist of nested * exceptions */ tinfo = task_thread_info(task); for (;;) { char *id; unsigned long *estack_end; estack_end = in_exception_stack(cpu, (unsigned long)stack, &used, &id); if (estack_end) { if (ops->stack(data, id) < 0) break; bp = ops->walk_stack(tinfo, stack, bp, ops, data, estack_end, &graph); ops->stack(data, "<EOE>"); /* * We link to the next stack via the * second-to-last pointer (index -2 to end) in the * exception stack: */ stack = (unsigned long *) estack_end[-2]; continue; } if (irq_stack_end) { unsigned long *irq_stack; irq_stack = irq_stack_end - (IRQ_STACK_SIZE - 64) / sizeof(*irq_stack); if (in_irq_stack(stack, irq_stack, irq_stack_end)) { if (ops->stack(data, "IRQ") < 0) break; bp = ops->walk_stack(tinfo, stack, bp, ops, data, irq_stack_end, &graph); /* * We link to the next stack (which would be * the process stack normally) the last * pointer (index -1 to end) in the IRQ stack: */ stack = (unsigned long *) (irq_stack_end[-1]); bp = fixup_bp_irq_link(bp, stack, irq_stack, irq_stack_end); irq_stack_end = NULL; ops->stack(data, "EOI"); continue; } } break; } /* * This handles the process stack: */ bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph); put_cpu(); }
void _SE3(uintptr_t xax, uintptr_t xbx, uintptr_t xcx, uintptr_t xdx, uintptr_t xsi, uintptr_t xdi) { UNUSED(xdx); switch (xax) { case SE_EENTER: uintptr_t xip; void * enclave_base_addr; se_pt_regs_t* p_pt_regs; tcs_t* tcs; tcs_sim_t* tcs_sim; ssa_gpr_t* p_ssa_gpr; secs_t* secs; CEnclaveMngr* mngr; CEnclaveSim* ce; // xbx contains the address of a TCS tcs = reinterpret_cast<tcs_t*>(xbx); // Is TCS pointer page-aligned? GP_ON_EENTER(!IS_PAGE_ALIGNED(tcs)); mngr = CEnclaveMngr::get_instance(); assert(mngr != NULL); // Is it really a TCS? ce = mngr->get_enclave(tcs); GP_ON_EENTER(ce == NULL); GP_ON_EENTER(!ce->is_tcs_page(tcs)); // Check the EntryReason tcs_sim = reinterpret_cast<tcs_sim_t *>(tcs->reserved); GP_ON_EENTER(tcs_sim->tcs_state != TCS_STATE_INACTIVE); GP_ON_EENTER(tcs->cssa >= tcs->nssa); secs = ce->get_secs(); enclave_base_addr = secs->base; p_ssa_gpr = reinterpret_cast<ssa_gpr_t*>(reinterpret_cast<uintptr_t>(enclave_base_addr) + static_cast<size_t>(tcs->ossa) + secs->ssa_frame_size * SE_PAGE_SIZE - sizeof(ssa_gpr_t)); tcs_sim->saved_aep = xcx; p_pt_regs = reinterpret_cast<se_pt_regs_t*>(get_bp()); p_ssa_gpr->REG(bp_u) = p_pt_regs->xbp; p_ssa_gpr->REG(sp_u) = reinterpret_cast<uintptr_t>(p_pt_regs + 1); xcx = p_pt_regs->xip; xip = reinterpret_cast<uintptr_t>(enclave_base_addr); GP_ON_EENTER(xip == 0); //set the _tls_array to point to the self_addr of TLS section inside the enclave GP_ON_EENTER(td_mngr_set_td(enclave_base_addr, tcs) == false); // Destination depends on STATE xip += (uintptr_t)tcs->oentry; tcs_sim->tcs_state = TCS_STATE_ACTIVE; // Link the TCS to the thread GP_ON_EENTER((secs->attributes.flags & SGX_FLAGS_INITTED) == 0); // Replace the return address on the stack with the enclave entry, // so that when we return from this function, we'll enter the enclave. enclu_regs_t regs; regs.xax = tcs->cssa; regs.xbx = reinterpret_cast<uintptr_t>(tcs); regs.xcx = xcx; regs.xdx = 0; regs.xsi = xsi; regs.xdi = xdi; regs.xbp = p_ssa_gpr->REG(bp_u); regs.xsp = p_ssa_gpr->REG(sp_u); regs.xip = xip; load_regs(®s); // Returning from this function enters the enclave return; default: // There's only 1 ring 3 instruction outside the enclave: EENTER. GP(); } }
std::string get_body_part_id( body_part bp ) { return get_bp( bp ).legacy_id; }
body_part opposite_body_part( body_part bp ) { return get_bp( bp ).opposite_part->token; }
body_part mutate_to_main_part( body_part bp ) { return get_bp( bp ).main_part->token; }
std::string encumb_text( body_part bp ) { const std::string &txt = get_bp( bp ).encumb_text; return !txt.empty() ? _( txt.c_str() ) : txt; }
std::string body_part_hp_bar_ui_text( body_part bp ) { return _( get_bp( bp ).hp_bar_ui_text.c_str() ); }
std::string body_part_name_as_heading( body_part bp, int number ) { const auto &bdy = get_bp( bp ); return ngettext( bdy.name_as_heading_singular.c_str(), bdy.name_as_heading_multiple.c_str(), number ); }
void save(size_t sz) { void* bp; get_bp(bp); save(sz, bp); }