📄 db_eros.cxx
字号:
if (cc->processFlags & PF_DDBTRAP) { cc->processFlags &= ~PF_DDBTRAP; db_printf("Exception traps for context 0x%08x (OID 0x%08x%08x) disabled\n", cc, (uint32_t) (cc->procRoot->ob.oid >> 32), (uint32_t) (cc->procRoot->ob.oid)); } else { cc->processFlags |= PF_DDBTRAP; db_printf("Exception traps for context 0x%08x (OID 0x%08x%08x) enabled\n", cc, (uint32_t) (cc->procRoot->ob.oid >> 32), (uint32_t) (cc->procRoot->ob.oid)); /* Once set, this is forever: */ ddb_inv_flags |= DDB_INV_pflag; }}voiddb_eros_mesg_keyerr_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (ddb_inv_flags & DDB_INV_keyerr) { ddb_inv_flags &= ~DDB_INV_keyerr; db_printf("ddb will NOT stop on key errors\n"); } else { ddb_inv_flags |= DDB_INV_keyerr; db_printf("ddb will stop on key errors\n"); }}voiddb_eros_mesg_keeper_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (ddb_inv_flags & DDB_INV_keeper) { ddb_inv_flags &= ~DDB_INV_keeper; db_printf("ddb will NOT stop on keeper invocations\n"); } else { ddb_inv_flags |= DDB_INV_keeper; db_printf("ddb will stop on keeper invocations\n"); }}voiddb_eros_mesg_show_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ db_printf("Stopping on"); if(ddb_segwalk_debug) db_printf(" segwalk"); if (ddb_thread_uqueue_debug) db_printf(" uqueue"); if (ddb_uyield_debug) db_printf(" uyield"); if (ddb_inv_flags & DDB_INV_gate) db_printf(" gate"); if (ddb_inv_flags & DDB_INV_keeper) db_printf(" keeper"); if (ddb_inv_flags & DDB_INV_keyerr) db_printf(" keyerr"); if (ddb_inv_flags & DDB_INV_all) db_printf(" allinv"); if (ddb_inv_flags & DDB_INV_return) db_printf(" return"); if (ddb_inv_flags & DDB_INV_pflag) db_printf(" processFlags"); db_printf("\n");}voiddb_ctxt_print_cmd(db_expr_t addr, int have_addr, db_expr_t /* count */, char * /* modif */){ Process *cc = have_addr ? (Process *) addr : (Process*) Thread::CurContext(); db_eros_print_context(cc);}voiddb_user_single_step_cmd(db_expr_t addr, int have_addr, db_expr_t /* count */, char * /* modif */){ Process *cc = have_addr ? (Process *) addr : (Process*) Thread::CurContext(); cc->SetInstrSingleStep(); { extern void db_continue_cmd(db_expr_t, int, db_expr_t, char*); db_continue_cmd(0, 0, 0, ""); }}voiddb_print_reserve(CpuReserve *r){ int index = -1; if ((uint32_t)r > (uint32_t) CpuReserve::CpuReserveTable) index = r - CpuReserve::CpuReserveTable; if (index >= MAX_CPU_RESERVE) index = -1; db_printf("[%3d] (0x%08x) period 0x%08x%08x duration 0x%08x%08x\n" " quanta 0x%08x%08x normPrio %d rsrvPrio %d\n" " residQ 0x%08x%08x residD 0x%08x%08x expired? %c\n", index, r, (uint32_t) (r->period >> 32), (uint32_t) (r->period), (uint32_t) (r->duration >> 32), (uint32_t) (r->duration), (uint32_t) (r->quanta >> 32), (uint32_t) (r->quanta), r->normPrio, r->rsrvPrio, (uint32_t) (r->residQuanta >> 32), (uint32_t) (r->residQuanta), (uint32_t) (r->residDuration >> 32), (uint32_t) (r->residDuration), r->expired ? 'y' : 'n');} voiddb_show_reserves_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ for (uint32_t i = 0; i < MAX_CPU_RESERVE; i++) { CpuReserve& r = CpuReserve::CpuReserveTable[i]; if (r.threadChain.next == 0) continue; db_print_reserve(&r); }}voiddb_show_kreserves_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ db_print_reserve(&CpuReserve::KernIdleCpuReserve); db_print_reserve(&CpuReserve::KernThreadCpuReserve);}voiddb_rsrv_print_cmd(db_expr_t addr, int have_addr, db_expr_t /* count */, char * /* modif */){ CpuReserve *pCpuReserve = CpuReserve::Current; if (have_addr) pCpuReserve = (CpuReserve *) addr; if (pCpuReserve) db_print_reserve(pCpuReserve); else db_error("no current reserve\n");}voiddb_rsrvchain_print_cmd(db_expr_t addr, int have_addr, db_expr_t /* count */, char * /* modif */){ CpuReserve *pCpuReserve = CpuReserve::Current; if (have_addr) pCpuReserve = (CpuReserve *) addr; db_print_reserve(pCpuReserve); Link* tlnk = pCpuReserve->threadChain.next; while (tlnk) { Thread *t = Thread::ThreadFromCpuReserveLinkage(tlnk); db_eros_print_thread(t); tlnk = tlnk->next; }}voiddb_ctxt_kr_print_cmd(db_expr_t addr, int have_addr, db_expr_t /* count */, char * /* modif */){ Process *cc = have_addr ? (Process *) addr : (Process*) Thread::CurContext(); db_eros_print_context_keyring(cc);}voiddb_ctxt_keys_print_cmd(db_expr_t addr, int have_addr, db_expr_t /* count */, char * /* modif */){ Process *cc = have_addr ? (Process *) addr : (Process*) Thread::CurContext(); db_eros_print_context_keyregs(cc);}voiddb_thread_print_cmd(db_expr_t addr, int have_addr, db_expr_t /* count */, char * /* modif */){ Thread *t = Thread::Current(); const char * cur_str = "current "; if (have_addr) { t = (Thread *) addr; cur_str=""; } if (t) { if (t->context && t->IsUser()) ((Process*) t->context)->SyncThread(); db_eros_print_thread(t); db_printf("%sthread 0x%08x (%s) ctxt 0x%08x (%s) rsrv=0x%08x\n", cur_str, t, Thread::stateNames[t->state], t->context, (t->IsKernel() ? "kernel" : "user"), t->cpuReserve); db_printf(" (0x%08x): ", &t->processKey); db_eros_print_key(t->processKey); } else db_printf("No current thread.\n");}voiddb_inv_print_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (inv.IsActive() == false) { db_printf("No active invocation\n"); return; } uint32_t invType = inv.invType; if (invType >= 3) invType = 3; static char invTypeName[] = { 'R', 'C', 'S', '?' }; if (inv.key) { db_printf("Invoked key 0x%08x ity=%c ikt=%d kd=%d st=%d inv count=%U\n" " OC=0x%08x (%d) nextPC=0x%08x\n", inv.key, invTypeName[invType], inv.keyType, inv.key->GetType(), inv.key->keyData, KernStats.nInvoke, inv.entry.code, inv.entry.code, inv.nextPC); db_printf("(0x%08x): ", inv.key); db_eros_print_key(*inv.key); } else db_printf("Invoked key not yet determined\n");}voiddb_entry_print_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (inv.IsActive() == false) db_printf("WARNING: no active invocation\n"); db_printf("Entry: 0x%08x, data 0x%08x len %d invocation %U\n", inv.entry.code, inv.entry.data, inv.entry.len, (uint32_t) KernStats.nInvoke); for (int i = 0; i < 4; i++) { if (inv.entry.key[i]) { db_printf("%d: (0x%08x): ", i, inv.entry.key[i]); db_eros_print_key(*inv.entry.key[i]); } } db_printf("w0: 0x%08x w1: 0x%08x w2: 0x%08x w3: 0x%08x\n", inv.entry.code, inv.entry.w1, inv.entry.w2, inv.entry.w3); db_printf(" str: "); db_eros_print_string(inv.entry.data, inv.entry.len);}voiddb_exit_print_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (inv.IsActive() == false) db_printf("WARNING: No active invocation\n"); db_printf("Exit: 0x%08x, data 0x%08x len %d valid len %d invocation %u\n", inv.exit.code, inv.exit.data, inv.exit.len, inv.validLen, (uint32_t) KernStats.nInvoke); for (int i = 0; i < 4; i++) { if (inv.exit.pKey[i]) { db_printf("%d: (0x%08x): ", i, inv.exit.pKey[i]); db_eros_print_key(*inv.exit.pKey[i]); } } db_printf("w0: 0x%08x w1: 0x%08x w2: 0x%08x w3: 0x%08x\n", inv.exit.code, inv.exit.w1, inv.exit.w2, inv.exit.w3);}voiddb_invokee_print_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (inv.IsActive() == false) { if (inv.invokee) db_printf("WARNING! Out-of-date invokee!\n"); else { db_printf("No active invocation\n"); return; } } db_eros_print_context(inv.invokee);}voiddb_invokee_kr_print_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (inv.IsActive() == false) { db_printf("No active invocation\n"); return; } Process *cc; if ( inv.key && inv.key->IsGateKey() ) { cc = inv.key->gk.pContext; } else if (inv.entry.key[3] && inv.entry.key[3]->IsGateKey() ) { cc = inv.entry.key[3]->gk.pContext; } else cc = 0; db_eros_print_context_keyring(cc);}voiddb_invokee_keys_print_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ if (inv.IsActive() == false) { db_printf("No active invocation\n"); return; } Process *cc; if ( inv.key && inv.key->IsGateKey() ) { cc = inv.key->gk.pContext; } else if (inv.entry.key[3] && inv.entry.key[3]->IsGateKey() ) { cc = inv.entry.key[3]->gk.pContext; } else cc = 0; db_eros_print_context_keyregs(cc);}voiddb_show_uthread_cmd(db_expr_t /* addr */, int /* have_addr */, db_expr_t /* count */, char * /* modif */){ for (uint32_t i = 0; i < KTUNE_NTHREAD; i++) { Thread *t = &Thread::ThreadTable[i]; if (t->state != Thread::Free) db_eros_print_thread(t); }}voiddb_reboot_cmd(db_expr_t, int, db_expr_t, char*){ Machine::HardReset();}/* This is quite tricky. Basically, we are trying to find the most * expensive 10 procedures in the kernel. The problem is that we * don't really want to sort the symbol table to do it. */extern "C" { extern void etext(); extern void start();#ifdef OPTION_KERN_PROFILE extern uint32_t *KernelProfileTable;#endif}#ifdef OPTION_KERN_STATS#define DB64(x) ((uint32_t)(x>>32)), (uint32_t)(x)voiddb_kstat_show_cmd(db_expr_t, int, db_expr_t, char*){ db_printf("nDepend 0x%08x%08x " "nDepMerge 0x%08x%08x\n" "nDepInval 0x%08x%08x " "nDepZap 0x%08x%08x\n" "nInvoke 0x%08x%08x " "nInvKpr 0x%08x%08x\n" "nPfTraps 0x%08x%08x " "nPfAccess 0x%08x%08x\n" "nWalkSeg 0x%08x%08x " "nWalkLoop 0x%08x%08x\n" "nKeyPrep 0x%08x%08d " "nInter 0x%08x%08d\n" "nGateJmp 0x%08x%08x " "nInvRetry 0x%08x%08x\n" "nRetag 0x%08x%08x\n ", DB64(KernStats.nDepend), DB64(KernStats.nDepMerge), DB64(KernStats.nDepInval), DB64(KernStats.nDepZap), DB64(KernStats.nInvoke), DB64(KernStats.nInvKpr), DB64(KernStats.nPfTraps), DB64(KernStats.nPfAccess), DB64(KernStats.nWalkSeg), DB64(KernStats.nWalkLoop), DB64(KernStats.nKeyPrep), DB64(KernStats.nInter), DB64(KernStats.nGateJmp), DB64(KernStats.nInvRetry), DB64(KernStats.nRetag) );}#ifdef FAST_IPC_STATSextern "C" { extern uint32_t nFastIpcPath; extern uint32_t nFastIpcFast; extern uint32_t nFastIpcRedSeg; extern uint32_t nFastIpcString; extern uint32_t nFastIpcSmallString; extern uint32_t nFastIpcLargeString; extern uint32_t nFastIpcNoString; extern uint32_t nFastIpcRcvPf; extern uint32_t nFastIpcEnd; extern uint32_t nFastIpcOK; extern uint32_t nFastIpcPrepared;} voiddb_kstat_fast_cmd(db_expr_t, int, db_expr_t, char*){ db_printf("nFastIpcPath 0x%08x " "nFastIpcFast 0x%08x\n" "nFastIpcRedSeg 0x%08x " "nFastIpcString 0x%08x\n" "nFastIpcSmallString 0x%08x " "nFastIpcLargeString 0x%08x\n" "nFastIpcNoString 0x%08x " "nFastIpcRcvPf 0x%08x\n" "nFastIpcEnd 0x%08x " "nFastIpcOK 0x%08x\n" "nFastIpcPrepared 0x%08x\n" , nFastIpcPath, nFastIpcFast, nFastIpcRedSeg, nFastIpcString, nFastIpcSmallString, nFastIpcLargeString, nFastIpcNoString, nFastIpcRcvPf, nFastIpcEnd, nFastIpcOK, nFastIpcPrepared );}#endif /* FAST_IPC_STATS */voiddb_kstat_clear_cmd(db_expr_t, int, db_expr_t, char*){ bzero(&KernStats, sizeof(KernStats));#ifdef OPTION_KERN_TIMING_STATS Invocation::ZeroStats();#endif}#ifdef OPTION_KERN_TIMING_STATSvoiddb_kstat_ipc_cmd(db_expr_t, int, db_expr_t, char*){ for (int i = 0; i < KT_NUM_KEYTYPE; i++) { if (Invocation::KeyHandlerCounts[i][IT_Call] || Invocation::KeyHandlerCounts[i][IT_Reply] || Invocation::KeyHandlerCounts[i][IT_Send]) { db_printf("kt%02d: C [%8U] %13U cy R [%8U] %13U cy\n", i, Invocation::KeyHandlerCounts[i][IT_Call], Invocation::KeyHandlerCycles[i][IT_Call], Invocation::KeyHandlerCounts[i][IT_Reply], Invocation::KeyHandlerCycles[i][IT_Reply]); db_printf(" S [%8U] %13U cy\n", Invocation::KeyHandlerCounts[i][IT_Send], Invocation::KeyHandlerCycles[i][IT_Send]); } }}#endif /* OPTION_KERN_TIMING_STATS */#endif /* OPTION_KERN_STATS */#ifdef OPTION_KERN_PROFILEtypedef int (*qsortfn)(...); intddb_CompareFunsByAddr(FuncSym *sn0, FuncSym*sn1){ if (sn0->address < sn1->address) return -1; if (sn0->address == sn1->address) return 0; return 1;}intddb_CompareLinesByAddr(LineSym *sn0, LineSym*sn1){ if (sn0->address < sn1->address) return -1; if (sn0->address == sn1->address) return 0; return 1;}/* Note - higher sorts first: */intddb_CompareFunsByCount(FuncSym *sn0, FuncSym*sn1){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -