void sigtrap_handler(int signal, siginfo_t *info, os_context_t *context) { unsigned int trap; if (single_stepping) { restore_breakpoint_from_single_step(context); return; } /* This is just for info in case the monitor wants to print an * approximation. */ current_control_stack_pointer = (lispobj *)*os_context_sp_addr(context); #ifdef LISP_FEATURE_SUNOS /* For some reason the breakpoints that :ENCAPSULATE NIL tracing sets up * cause a trace trap (i.e. processor single-stepping trap) on the following * instruction on Solaris 10/x86. -- JES, 2006-04-07 */ if (info->si_code == TRAP_TRACE) { lose("foo"); return; } #endif /* On entry %eip points just after the INT3 byte and aims at the * 'kind' value (eg trap_Cerror). For error-trap and Cerror-trap a * number of bytes will follow, the first is the length of the byte * arguments to follow. */ trap = *(unsigned char *)(*os_context_pc_addr(context)); handle_trap(context, trap); }
static void sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context) { unsigned int code = *((unsigned char *)(4+*os_context_pc_addr(context))); u32 trap_instruction = *((u32 *)*os_context_pc_addr(context)); int condition_bits = (trap_instruction >> 28) & 0x0f; /* Make sure that we're looking at an SWI instruction or that one * undefined instruction that the kernel recognizes as an explicit * trap. */ if ((condition_bits == 15) || (((trap_instruction & 0x0f000000) != 0x0f000000) && (trap_instruction != 0xe7f001f0))) { lose("Unrecognized trap instruction %08lx in sigtrap_handler()", trap_instruction); } if (trap_instruction == 0xe7f001f0) { handle_trap(context, code); } else { arch_clear_pseudo_atomic_interrupted(context); arch_skip_instruction(context); interrupt_handle_pending(context); } }
void userspace(union uml_pt_regs *regs) { int err, status, op, pid = userspace_pid[0]; int local_using_sysemu; /*To prevent races if using_sysemu changes under us.*/ while(1){ restore_registers(pid, regs); /* Now we set local_using_sysemu to be used for one loop */ local_using_sysemu = get_using_sysemu(); op = SELECT_PTRACE_OPERATION(local_using_sysemu, singlestepping(NULL)); err = ptrace(op, pid, 0, 0); if(err) panic("userspace - could not resume userspace process, " "pid=%d, ptrace operation = %d, errno = %d\n", op, errno); CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); if(err < 0) panic("userspace - waitpid failed, errno = %d\n", errno); regs->skas.is_user = 1; save_registers(pid, regs); UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */ if(WIFSTOPPED(status)){ switch(WSTOPSIG(status)){ case SIGSEGV: handle_segv(pid, regs); break; case SIGTRAP + 0x80: handle_trap(pid, regs, local_using_sysemu); break; case SIGTRAP: relay_signal(SIGTRAP, regs); break; case SIGIO: case SIGVTALRM: case SIGILL: case SIGBUS: case SIGFPE: case SIGWINCH: user_signal(WSTOPSIG(status), regs, pid); break; default: printk("userspace - child stopped with signal " "%d\n", WSTOPSIG(status)); } interrupt_end(); /* Avoid -ERESTARTSYS handling in host */ PT_SYSCALL_NR(regs->skas.regs) = -1; } } }
void userspace(union uml_pt_regs *regs) { int err, status, op, pid = userspace_pid[0]; restore_registers(regs); err = ptrace(PTRACE_SYSCALL, pid, 0, 0); if(err) panic("userspace - PTRACE_SYSCALL failed, errno = %d\n", errno); while(1){ CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); if(err < 0) panic("userspace - waitpid failed, errno = %d\n", errno); regs->skas.is_user = 1; save_registers(regs); if(WIFSTOPPED(status)){ switch(WSTOPSIG(status)){ case SIGSEGV: handle_segv(pid); break; case SIGTRAP: handle_trap(pid, regs); break; case SIGIO: case SIGVTALRM: case SIGILL: case SIGBUS: case SIGFPE: case SIGWINCH: user_signal(WSTOPSIG(status), regs); break; default: printk("userspace - child stopped with signal " "%d\n", WSTOPSIG(status)); } interrupt_end(); } restore_registers(regs); op = singlestepping_skas() ? PTRACE_SINGLESTEP : PTRACE_SYSCALL; err = ptrace(op, pid, 0, 0); if(err) panic("userspace - PTRACE_SYSCALL failed, " "errno = %d\n", errno); } }
static void sigtrap_handler(int signal, siginfo_t *siginfo, os_context_t *context) { unsigned int code = *((unsigned char *)(4+*os_context_pc_addr(context))); u32 trap_instruction = *((u32 *)*os_context_pc_addr(context)); if (trap_instruction != 0xe7f001f0) { lose("Unrecognized trap instruction %08lx in sigtrap_handler()", trap_instruction); } if (code == trap_PendingInterrupt) { arch_skip_instruction(context); } handle_trap(context, code); }
void sigtrap_handler(int signal, siginfo_t *info, os_context_t *context) { unsigned int trap; if (single_stepping) { restore_breakpoint_from_single_step(context); return; } /* This is just for info in case the monitor wants to print an * approximation. */ access_control_stack_pointer(arch_os_get_current_thread()) = (lispobj *)*os_context_sp_addr(context); /* On entry %eip points just after the INT3 byte and aims at the * 'kind' value (eg trap_Cerror). For error-trap and Cerror-trap a * number of bytes will follow, the first is the length of the byte * arguments to follow. */ trap = *(unsigned char *)(*os_context_pc_addr(context)); handle_trap(context, trap); }
sai_status_t processEvent(swss::ConsumerTable &consumer) { std::lock_guard<std::mutex> lock(g_mutex); SWSS_LOG_ENTER(); swss::KeyOpFieldsValuesTuple kco; consumer.pop(kco); const std::string &key = kfvKey(kco); const std::string &op = kfvOp(kco); std::string str_object_type = key.substr(0, key.find(":")); std::string str_object_id = key.substr(key.find(":")+1); SWSS_LOG_INFO("key: %s op: %s", key.c_str(), op.c_str()); sai_common_api_t api = SAI_COMMON_API_MAX; if (op == "create") api = SAI_COMMON_API_CREATE; else if (op == "remove") api = SAI_COMMON_API_REMOVE; else if (op == "set") api = SAI_COMMON_API_SET; else if (op == "get") api = SAI_COMMON_API_GET; else { if (op != "delget") SWSS_LOG_ERROR("api %s is not implemented", op.c_str()); return SAI_STATUS_NOT_SUPPORTED; } std::stringstream ss; int index = 0; sai_object_type_t object_type; sai_deserialize_primitive(str_object_type, index, object_type); if (object_type >= SAI_OBJECT_TYPE_MAX) { SWSS_LOG_ERROR("undefined object type %d", object_type); return SAI_STATUS_NOT_SUPPORTED; } const std::vector<swss::FieldValueTuple> &values = kfvFieldsValues(kco); SaiAttributeList list(object_type, values, false); if (api != SAI_COMMON_API_GET) translate_vid_to_rid_list(object_type, list.get_attr_count(), list.get_attr_list()); sai_attribute_t *attr_list = list.get_attr_list(); uint32_t attr_count = list.get_attr_count(); sai_status_t status; switch (object_type) { case SAI_OBJECT_TYPE_FDB: status = handle_fdb(str_object_id, api, attr_count, attr_list); break; case SAI_OBJECT_TYPE_SWITCH: status = handle_switch(str_object_id, api, attr_count, attr_list); break; case SAI_OBJECT_TYPE_NEIGHBOR: status = handle_neighbor(str_object_id, api, attr_count, attr_list); break; case SAI_OBJECT_TYPE_ROUTE: status = handle_route(str_object_id, api, attr_count, attr_list); break; case SAI_OBJECT_TYPE_VLAN: status = handle_vlan(str_object_id, api, attr_count, attr_list); break; case SAI_OBJECT_TYPE_TRAP: status = handle_trap(str_object_id, api, attr_count, attr_list); break; default: status = handle_generic(object_type, str_object_id, api, attr_count, attr_list); break; } if (api == SAI_COMMON_API_GET) { internal_syncd_get_send(object_type, status, attr_count, attr_list); } else if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("failed to execute api: %s: %d", op.c_str(), status); exit(EXIT_FAILURE); } return status; }
void i860_cpu_device::run_cycle() { CLEAR_FLOW(); m_dim_cc_valid = false; m_flow &= ~DIM_OP; UINT64 insn64 = ifetch64(m_pc); if(!(m_pc & 4)) { UINT32 savepc = m_pc; #if ENABLE_DEBUGGER if(m_single_stepping) debugger(0,0); #endif UINT32 insnLow = insn64; if(insnLow == INSN_FNOP_DIM) { if(m_dim) m_flow |= DIM_OP; else m_flow &= ~DIM_OP; } else if((insnLow & INSN_MASK_DIM) == INSN_FP_DIM) m_flow |= DIM_OP; decode_exec(insnLow); if (PENDING_TRAP()) { handle_trap(savepc); goto done; } else if(GET_PC_UPDATED()) { goto done; } else { // If the PC wasn't updated by a control flow instruction, just bump to next sequential instruction. m_pc += 4; CLEAR_FLOW(); } } if(m_pc & 4) { UINT32 savepc = m_pc; #if ENABLE_DEBUGGER if(m_single_stepping && !(m_dim)) debugger(0,0); #endif UINT32 insnHigh= insn64 >> 32; decode_exec(insnHigh); // only check for external interrupts // - on high-word (speedup) // - not DIM (safety :-) // - when no other traps are pending if(!(m_dim) && !(PENDING_TRAP())) { if(m_flow & EXT_INTR) { m_flow &= ~EXT_INTR; gen_interrupt(); } else clr_interrupt(); } if (PENDING_TRAP()) { handle_trap(savepc); } else if (GET_PC_UPDATED()) { goto done; } else { // If the PC wasn't updated by a control flow instruction, just bump to next sequential instruction. m_pc += 4; } }
void userspace(union uml_pt_regs *regs) { int err, status, op, pt_syscall_parm, pid = userspace_pid[0]; int local_using_sysemu; /*To prevent races if using_sysemu changes under us.*/ restore_registers(regs); local_using_sysemu = get_using_sysemu(); pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL; err = ptrace(pt_syscall_parm, pid, 0, 0); if(err) panic("userspace - PTRACE_%s failed, errno = %d\n", local_using_sysemu ? "SYSEMU" : "SYSCALL", errno); while(1){ CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); if(err < 0) panic("userspace - waitpid failed, errno = %d\n", errno); regs->skas.is_user = 1; save_registers(regs); if(WIFSTOPPED(status)){ switch(WSTOPSIG(status)){ case SIGSEGV: handle_segv(pid); break; case SIGTRAP: handle_trap(pid, regs, local_using_sysemu); break; case SIGIO: case SIGVTALRM: case SIGILL: case SIGBUS: case SIGFPE: case SIGWINCH: user_signal(WSTOPSIG(status), regs); break; default: printk("userspace - child stopped with signal " "%d\n", WSTOPSIG(status)); } interrupt_end(); } restore_registers(regs); /*Now we ended the syscall, so re-read local_using_sysemu.*/ local_using_sysemu = get_using_sysemu(); pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL; op = singlestepping(NULL) ? PTRACE_SINGLESTEP : pt_syscall_parm; err = ptrace(op, pid, 0, 0); if(err) panic("userspace - PTRACE_%s failed, " "errno = %d\n", local_using_sysemu ? "SYSEMU" : "SYSCALL", errno); } }