static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs, bool partial) { /* * These on_stack() checks aren't strictly necessary: the unwind code * has already validated the 'regs' pointer. The checks are done for * ordering reasons: if the registers are on the next stack, we don't * want to print them out yet. Otherwise they'll be shown as part of * the wrong stack. Later, when show_trace_log_lvl() switches to the * next stack, this function will be called again with the same regs so * they can be printed in the right context. */ if (!partial && on_stack(info, regs, sizeof(*regs))) { __show_regs(regs, 0); } else if (partial && on_stack(info, (void *)regs + IRET_FRAME_OFFSET, IRET_FRAME_SIZE)) { /* * When an interrupt or exception occurs in entry code, the * full pt_regs might not have been saved yet. In that case * just print the iret frame. */ show_iret_regs(regs); } }
void __unwind_start(struct unwind_state *state, struct task_struct *task, struct pt_regs *regs, unsigned long *first_frame) { unsigned long *bp; memset(state, 0, sizeof(*state)); state->task = task; state->got_irq = (regs); /* Don't even attempt to start from user mode regs: */ if (regs && user_mode(regs)) { state->stack_info.type = STACK_TYPE_UNKNOWN; return; } bp = get_frame_pointer(task, regs); /* Initialize stack info and make sure the frame data is accessible: */ get_stack_info(bp, state->task, &state->stack_info, &state->stack_mask); update_stack_state(state, bp); /* * The caller can provide the address of the first frame directly * (first_frame) or indirectly (regs->sp) to indicate which stack frame * to start unwinding at. Skip ahead until we reach it. */ while (!unwind_done(state) && (!on_stack(&state->stack_info, first_frame, sizeof(long)) || state->bp < first_frame)) unwind_next_frame(state); }
TANGER_LOADSTORE_ATTR uint32_t tanger_stm_load32(tanger_stm_tx_t *tx, uint32_t *addr) { #ifdef STACK_CHECK if (on_stack(addr)) return *addr; #endif /* STACK_CHECK */ return stm_load_u32(TX_PARAM addr); }
TANGER_LOADSTORE_ATTR void tanger_stm_loadregion(tanger_stm_tx_t* tx, uint8_t *src, uintptr_t bytes, uint8_t *dest) { #ifdef STACK_CHECK if (on_stack(src)) memcpy(dest, src, bytes); #endif /* STACK_CHECK */ stm_load_bytes(TX_PARAM src, dest, bytes); }
TANGER_LOADSTORE_ATTR uint8_t tanger_stm_load1(tanger_stm_tx_t *tx, uint8_t *addr) { #ifdef STACK_CHECK /* TODO add unlikely */ if (on_stack(addr)) return *addr; #endif /* STACK_CHECK */ return stm_load_u8(TX_PARAM addr); }
TANGER_LOADSTORE_ATTR void tanger_stm_storeregion(tanger_stm_tx_t* tx, uint8_t *src, uintptr_t bytes, uint8_t *dest) { #ifdef STACK_CHECK if (on_stack(dest)) { memcpy(dest, src, bytes); return; } #endif /* STACK_CHECK */ stm_store_bytes(TX_PARAM src, dest, bytes); }
TANGER_LOADSTORE_ATTR void tanger_stm_store16aligned(tanger_stm_tx_t *tx, uint16_t *addr, uint16_t value) { #ifdef STACK_CHECK if (on_stack(addr)) { *addr = value; return; } #endif /* STACK_CHECK */ stm_store_u16(TX_PARAM addr, value); }
// This GA will use the resource stack for storage if c_heap==false, // Else it will use the C heap. Use clear_and_deallocate to avoid leaks. GenericGrowableArray(int initial_size, int initial_len, bool c_heap) { _len = initial_len; _max = initial_size; assert(_len >= 0 && _len <= _max, "initial_len too big"); _arena = (c_heap ? (Arena*)1 : NULL); set_nesting(); assert(!on_C_heap() || allocated_on_C_heap(), "growable array must be on C heap if elements are"); assert(!on_stack() || (allocated_on_res_area() || allocated_on_stack()), "growable array must be on stack if elements are not on arena and not on C heap"); }
TANGER_LOADSTORE_ATTR uint64_t tanger_stm_load64aligned(tanger_stm_tx_t *tx, uint64_t *addr) { #ifdef STACK_CHECK if (on_stack(addr)) return *addr; #endif /* STACK_CHECK */ #if __WORDSIZE == 64 return (uint64_t)TM_LOAD(TX_PARAM (volatile stm_word_t *)addr); #else return stm_load_u64(TX_PARAM addr); #endif }
TANGER_LOADSTORE_ATTR void tanger_stm_store64aligned(tanger_stm_tx_t *tx, uint64_t *addr, uint64_t value) { #ifdef STACK_CHECK if (on_stack(addr)) { *addr = value; return; } #endif /* STACK_CHECK */ #if __WORD_SIZE == 64 TM_STORE(TX_PARAM (volatile stm_word_t *)addr, (stm_word_t)value); #else stm_store_u64(TX_PARAM addr, value); #endif }
// This GA will use the resource stack for storage if c_heap==false, // Else it will use the C heap. Use clear_and_deallocate to avoid leaks. GenericGrowableArray(int initial_size, int initial_len, bool c_heap, MEMFLAGS flags = mtNone) { _len = initial_len; _max = initial_size; _memflags = flags; // memory type has to be specified for C heap allocation assert(!(c_heap && flags == mtNone), "memory type not specified for C heap object"); assert(_len >= 0 && _len <= _max, "initial_len too big"); _arena = (c_heap ? (Arena*)1 : NULL); set_nesting(); assert(!on_C_heap() || allocated_on_C_heap(), "growable array must be on C heap if elements are"); assert(!on_stack() || (allocated_on_res_area() || allocated_on_stack()), "growable array must be on stack if elements are not on arena and not on C heap"); }
void AccessFlags::print_on(outputStream* st) const { if (is_public ()) st->print("public " ); if (is_private ()) st->print("private " ); if (is_protected ()) st->print("protected " ); if (is_static ()) st->print("static " ); if (is_final ()) st->print("final " ); if (is_synchronized()) st->print("synchronized "); if (is_volatile ()) st->print("volatile " ); if (is_transient ()) st->print("transient " ); if (is_native ()) st->print("native " ); if (is_interface ()) st->print("interface " ); if (is_abstract ()) st->print("abstract " ); if (is_strict ()) st->print("strict " ); if (is_synthetic ()) st->print("synthetic " ); if (is_old ()) st->print("{old} " ); if (is_obsolete ()) st->print("{obsolete} " ); if (on_stack ()) st->print("{on_stack} " ); }
//------------------------------------------------------------------------------------ // Creates and initializes the main window for application //------------------------------------------------------------------------------------ Window::Window(QWidget *parent):QDialog(parent) { //We create an instance of GLWidget component we built in glwidget.h m_glWidget = new GLWidget; //Setup application interface. Creates all the required components and sliders. setupUi(this); //We need to attach our m_glWidget to glWidgetArea //All our drawings will be on glWidgetArea glWidgetArea->setWidget(m_glWidget); stack_size = 0; //Setting up all the SIGNALS and SLOTS doubleSpinBox->setRange(-1000,1000); doubleSpinBox_2->setRange(-1000,1000); doubleSpinBox_3->setRange(-1000,1000); doubleSpinBox_4->setRange(-1000,1000); doubleSpinBox_5->setRange(-1000,1000); doubleSpinBox_6->setRange(-1000,1000); doubleSpinBox_7->setRange(-1000,1000); doubleSpinBox_8->setRange(-1000,1000); doubleSpinBox_9->setRange(-1000,1000); connect(clearButton, SIGNAL(clicked()), m_glWidget, SLOT(ClearInput())); connect(doubleSpinBox, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM11(double))); connect(doubleSpinBox_2, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM12(double))); connect(doubleSpinBox_3, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM13(double))); connect(doubleSpinBox_4, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM21(double))); connect(doubleSpinBox_5, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM22(double))); connect(doubleSpinBox_6, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM23(double))); connect(doubleSpinBox_7, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM31(double))); connect(doubleSpinBox_8, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM32(double))); connect(doubleSpinBox_9, SIGNAL(valueChanged(double)), m_glWidget, SLOT(setM33(double))); connect(btnTransform,SIGNAL(clicked()), m_glWidget, SLOT(transformMatrix())); connect(store, SIGNAL(clicked()), this, SLOT(on_store())); connect(push, SIGNAL(clicked()), this, SLOT(on_push())); connect(pop, SIGNAL(clicked()), this, SLOT(on_pop())); connect(apply, SIGNAL(clicked()), this, SLOT(on_stack())); }
static bool update_stack_state(struct unwind_state *state, void *addr, size_t len) { struct stack_info *info = &state->stack_info; /* * If addr isn't on the current stack, switch to the next one. * * We may have to traverse multiple stacks to deal with the possibility * that 'info->next_sp' could point to an empty stack and 'addr' could * be on a subsequent stack. */ while (!on_stack(info, addr, len)) if (get_stack_info(info->next_sp, state->task, info, &state->stack_mask)) return false; return true; }
void __unwind_start(struct unwind_state *state, struct task_struct *task, struct pt_regs *regs, unsigned long *first_frame) { unsigned long *bp, *frame; size_t len; memset(state, 0, sizeof(*state)); state->task = task; /* don't even attempt to start from user mode regs */ if (regs && user_mode(regs)) { state->stack_info.type = STACK_TYPE_UNKNOWN; return; } /* set up the starting stack frame */ bp = get_frame_pointer(task, regs); regs = decode_frame_pointer(bp); if (regs) { state->regs = regs; frame = (unsigned long *)regs; len = sizeof(*regs); } else { state->bp = bp; frame = bp; len = FRAME_HEADER_SIZE; } /* initialize stack info and make sure the frame data is accessible */ get_stack_info(frame, state->task, &state->stack_info, &state->stack_mask); update_stack_state(state, frame, len); /* * The caller can provide the address of the first frame directly * (first_frame) or indirectly (regs->sp) to indicate which stack frame * to start unwinding at. Skip ahead until we reach it. */ while (!unwind_done(state) && (!on_stack(&state->stack_info, first_frame, sizeof(long)) || state->bp < first_frame)) unwind_next_frame(state); }
void __unwind_start(struct unwind_state *state, struct task_struct *task, struct pt_regs *regs, unsigned long *first_frame) { memset(state, 0, sizeof(*state)); state->task = task; state->sp = first_frame; get_stack_info(first_frame, state->task, &state->stack_info, &state->stack_mask); /* * The caller can provide the address of the first frame directly * (first_frame) or indirectly (regs->sp) to indicate which stack frame * to start unwinding at. Skip ahead until we reach it. */ if (!unwind_done(state) && (!on_stack(&state->stack_info, first_frame, sizeof(long)) || !__kernel_text_address(*first_frame))) unwind_next_frame(state); }
// some uses pass the Thread explicitly for speed (4990299 tuning) void* raw_allocate(Thread* thread, int elementSize) { assert(on_stack(), "fast ResourceObj path only"); return (void*)resource_allocate_bytes(thread, elementSize * _max); }
static bool update_stack_state(struct unwind_state *state, unsigned long *next_bp) { struct stack_info *info = &state->stack_info; enum stack_type prev_type = info->type; struct pt_regs *regs; unsigned long *frame, *prev_frame_end, *addr_p, addr; size_t len; if (state->regs) prev_frame_end = (void *)state->regs + regs_size(state->regs); else prev_frame_end = (void *)state->bp + FRAME_HEADER_SIZE; /* Is the next frame pointer an encoded pointer to pt_regs? */ regs = decode_frame_pointer(next_bp); if (regs) { frame = (unsigned long *)regs; len = regs_size(regs); state->got_irq = true; } else { frame = next_bp; len = FRAME_HEADER_SIZE; } /* * If the next bp isn't on the current stack, switch to the next one. * * We may have to traverse multiple stacks to deal with the possibility * that info->next_sp could point to an empty stack and the next bp * could be on a subsequent stack. */ while (!on_stack(info, frame, len)) if (get_stack_info(info->next_sp, state->task, info, &state->stack_mask)) return false; /* Make sure it only unwinds up and doesn't overlap the prev frame: */ if (state->orig_sp && state->stack_info.type == prev_type && frame < prev_frame_end) return false; /* Move state to the next frame: */ if (regs) { state->regs = regs; state->bp = NULL; } else { state->bp = next_bp; state->regs = NULL; } /* Save the return address: */ if (state->regs && user_mode(state->regs)) state->ip = 0; else { addr_p = unwind_get_return_address_ptr(state); addr = READ_ONCE_TASK_STACK(state->task, *addr_p); state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, addr, addr_p); } /* Save the original stack pointer for unwind_dump(): */ if (!state->orig_sp) state->orig_sp = frame; return true; }
/* * タスク毎の整合性検査 */ static ER bit_task(ID tskid) { TCB *p_tcb; const TINIB *p_tinib; uint_t tstat, tstat_wait, pri; TMEVTB *p_tmevtb; SEMCB *p_semcb; FLGCB *p_flgcb; DTQCB *p_dtqcb; PDQCB *p_pdqcb; MTXCB *p_mtxcb; MPFCB *p_mpfcb; if (!(TMIN_TSKID <= (tskid) && (tskid) <= tmax_tskid)) { return(E_ID); } p_tcb = get_tcb(tskid); p_tinib = p_tcb->p_tinib; tstat = p_tcb->tstat; tstat_wait = (tstat & TS_WAIT_MASK); pri = p_tcb->priority; /* * 初期化ブロックへのポインタの検査 */ if (p_tinib != &(tinib_table[INDEX_TSK(tskid)])) { return(E_SYS_LINENO); } /* * tstatの検査 */ switch (tstat & (TS_RUNNABLE | TS_WAITING | TS_SUSPENDED)) { case TS_DORMANT: if (tstat != TS_DORMANT) { return(E_SYS_LINENO); } break; case TS_RUNNABLE: if (tstat != TS_RUNNABLE) { return(E_SYS_LINENO); } break; case TS_WAITING: case (TS_WAITING | TS_SUSPENDED): if (!(TS_WAIT_DLY <= tstat_wait && tstat_wait <= TS_WAIT_MTX) || tstat_wait == TS_WAIT_MBX) { return(E_SYS_LINENO); } if ((tstat & ~(TS_WAIT_MASK | TS_RUNNABLE | TS_WAITING | TS_SUSPENDED)) != 0U) { return(E_SYS_LINENO); } break; case TS_SUSPENDED: if (tstat != TS_SUSPENDED) { return(E_SYS_LINENO); } break; default: return(E_SYS_LINENO); } /* * actqueの検査 */ if (TSTAT_DORMANT(tstat) && p_tcb->actque) { return(E_SYS_LINENO); } /* * タスク優先度の検査 */ if (pri >= TNUM_TPRI) { return(E_SYS_LINENO); } /* * texptnの検査 */ if (p_tcb->p_tinib->texrtn == NULL && p_tcb->texptn != 0U) { return(E_SYS_LINENO); } /* * 休止状態におけるチェック */ if (TSTAT_DORMANT(tstat)) { if (!(pri == p_tinib->ipriority) && (p_tcb->wupque == false) && (p_tcb->enatex == false) && (p_tcb->texptn == 0U)) { return(E_SYS_LINENO); } } /* * 実行できる状態におけるチェック */ if (TSTAT_RUNNABLE(tstat)) { if (!in_queue(&ready_queue[pri], &(p_tcb->task_queue))) { return(E_SYS_LINENO); } } /* * 待ち状態におけるチェック */ if (TSTAT_WAITING(tstat)) { if (!on_stack(p_tcb->p_winfo, p_tinib)) { return(E_SYS_LINENO); } p_tmevtb = p_tcb->p_winfo->p_tmevtb; if (p_tmevtb != NULL) { if (!on_stack(p_tmevtb, p_tinib)) { return(E_SYS_LINENO); } /* * (*p_tmevtb)の検査(未完成) */ } switch (tstat & TS_WAIT_MASK) { case TS_WAIT_SLP: if (p_tcb->wupque == true) { return(E_SYS_LINENO); } break; case TS_WAIT_DLY: if (p_tmevtb == NULL) { return(E_SYS_LINENO); } break; case TS_WAIT_SEM: p_semcb = ((WINFO_SEM *)(p_tcb->p_winfo))->p_semcb; if (!VALID_SEMCB(p_semcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_semcb->wait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; case TS_WAIT_FLG: p_flgcb = ((WINFO_FLG *)(p_tcb->p_winfo))->p_flgcb; if (!VALID_FLGCB(p_flgcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_flgcb->wait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; case TS_WAIT_SDTQ: p_dtqcb = ((WINFO_DTQ *)(p_tcb->p_winfo))->p_dtqcb; if (!VALID_DTQCB(p_dtqcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_dtqcb->swait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; case TS_WAIT_RDTQ: p_dtqcb = ((WINFO_DTQ *)(p_tcb->p_winfo))->p_dtqcb; if (!VALID_DTQCB(p_dtqcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_dtqcb->rwait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; case TS_WAIT_SPDQ: p_pdqcb = ((WINFO_PDQ *)(p_tcb->p_winfo))->p_pdqcb; if (!VALID_PDQCB(p_pdqcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_pdqcb->swait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; case TS_WAIT_RPDQ: p_pdqcb = ((WINFO_PDQ *)(p_tcb->p_winfo))->p_pdqcb; if (!VALID_PDQCB(p_pdqcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_pdqcb->rwait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; case TS_WAIT_MTX: p_mtxcb = ((WINFO_MTX *)(p_tcb->p_winfo))->p_mtxcb; if (!VALID_MTXCB(p_mtxcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_mtxcb->wait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; case TS_WAIT_MPF: p_mpfcb = ((WINFO_MPF *)(p_tcb->p_winfo))->p_mpfcb; if (!VALID_MPFCB(p_mpfcb)) { return(E_SYS_LINENO); } if (!in_queue(&(p_mpfcb->wait_queue), &(p_tcb->task_queue))) { return(E_SYS_LINENO); } break; } } /* * tskctxbの検査 */ if (!TSTAT_DORMANT(tstat) && p_tcb != p_runtsk) { /* * ターゲット依存の検査 */ #if 0 if (bit_tskctxb(&(p_tcb->tskctxb))) { return(E_SYS_LINENO); } #endif } return(E_OK); }