static char * haiku_pid_to_str (ptid_t ptid) { static char buffer[B_OS_NAME_LENGTH + 64 + 64]; team_info teamInfo; thread_info threadInfo; status_t error; // get the team info for the target team error = get_team_info(ptid_get_pid(ptid), &teamInfo); if (error != B_OK) { sprintf(buffer, "invalid team ID %d", ptid_get_pid(ptid)); return buffer; } // get the thread info for the target thread error = get_thread_info(ptid_get_tid(ptid), &threadInfo); if (error != B_OK) { sprintf(buffer, "team %.*s (%ld) invalid thread ID %ld", (int)sizeof(teamInfo.args), teamInfo.args, teamInfo.team, ptid_get_tid(ptid)); return buffer; } sprintf(buffer, "team %.*s (%ld) thread %s (%ld)", (int)sizeof(teamInfo.args), teamInfo.args, teamInfo.team, threadInfo.name, threadInfo.thread); return buffer; }
status_t Team::Init(team_id teamID, port_id debuggerPort) { // get team info team_info teamInfo; status_t error = get_team_info(teamID, &teamInfo); if (error != B_OK) return error; fID = teamID; fArgs = teamInfo.args; // install ourselves as the team debugger fNubPort = install_team_debugger(teamID, debuggerPort); if (fNubPort < 0) { fprintf(stderr, "%s: Failed to install as debugger for team %ld: " "%s\n", kCommandName, teamID, strerror(fNubPort)); return fNubPort; } // init debug context error = init_debug_context(&fDebugContext, teamID, fNubPort); if (error != B_OK) { fprintf(stderr, "%s: Failed to init debug context for team %ld: " "%s\n", kCommandName, teamID, strerror(error)); return error; } // set team debugging flags int32 teamDebugFlags = B_TEAM_DEBUG_THREADS | B_TEAM_DEBUG_TEAM_CREATION | B_TEAM_DEBUG_IMAGES; set_team_debugging_flags(fNubPort, teamDebugFlags); return B_OK; }
static void list_areas_for_id(team_id id) { int32 cookie = 0; team_info teamInfo; area_info areaInfo; if (id != 1 && get_team_info(id, &teamInfo) == B_BAD_TEAM_ID) { printf("\nteam %ld unknown\n", id); return; } else if (id == 1) strcpy(teamInfo.args, "KERNEL SPACE"); printf("\n%s (team %ld)\n", teamInfo.args, id); printf(" ID name address size alloc. #-cow #-in #-out\n"); printf("------------------------------------------------------------------------------------\n"); while (get_next_area_info(id, &cookie, &areaInfo) == B_OK) { printf("%5ld %32s %08lx %8lx %8lx %5ld %5ld %5ld\n", areaInfo.area, areaInfo.name, // (addr_t)areaInfo.address, (uint32)areaInfo.address, areaInfo.size, areaInfo.ram_size, areaInfo.copy_count, areaInfo.in_count, areaInfo.out_count); } }
void MemoryBarMenuItem::BarUpdate() { area_info areaInfo; ssize_t cookie = 0; int64 lram_size = 0; int64 lwram_size = 0; bool exists = false; while (get_next_area_info(fTeamID, &cookie, &areaInfo) == B_OK) { exists = true; lram_size += areaInfo.ram_size; // TODO: this won't work this way anymore under Haiku! // int zone = (int (areaInfo.address) & 0xf0000000) >> 24; if ((areaInfo.protection & B_WRITE_AREA) != 0) lwram_size += areaInfo.ram_size; // && (zone & 0xf0) != 0xA0 // Exclude media buffers // && (fTeamID != gAppServerTeamID || zone != 0x90)) // Exclude app_server side of bitmaps } if (!exists) { team_info info; exists = get_team_info(fTeamID, &info) == B_OK; } if (exists) { fWriteMemory = lwram_size / 1024; fAllMemory = lram_size / 1024; DrawBar(false); } else fWriteMemory = -1; }
int main(int argc, char **argv) { team_info tinfo; int32 cookie = 0; int32 i; system_info sysinfo; // show up some stats first... get_system_info(&sysinfo); printf("sem: total: %5" B_PRIu32 ", used: %5" B_PRIu32 ", left: %5" B_PRIu32 "\n\n", sysinfo.max_sems, sysinfo.used_sems, sysinfo.max_sems - sysinfo.used_sems); if (argc == 1) { while (get_next_team_info( &cookie, &tinfo) == B_OK) list_sems(&tinfo); return 0; } for (i = 1; i < argc; i++) { if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { fprintf(stderr, "Usage: %s [-s semid] [teamid]\n", argv[0]); fputs(" List the semaphores allocated by the specified\n", stderr); fputs(" team, or all teams if none is specified.\n", stderr); fputs("\n", stderr); fputs(" The -s option displays the sem_info data for a\n", stderr); fputs(" specified semaphore.\n", stderr); return 0; } else if (strcmp(argv[i], "-s") == 0) { if (argc < i + 2) printf("-s used without associated sem id\n"); else { sem_id id = atoi(argv[i + 1]); sem_info info; if (get_sem_info(id, &info) == B_OK) { print_header(NULL); print_sem_info(&info); } else printf("semaphore %" B_PRId32 " unknown\n\n", id); i++; } } else { team_id team; team = atoi(argv[i]); if (get_team_info(team, &tinfo) == B_OK) list_sems(&tinfo); else printf("team %" B_PRId32 " unknown\n\n", team); } } return 0; }
/*! Returns the ID of the supplied team's main thread. \param team The team. \return - The thread ID of the supplied team's main thread - \c B_BAD_TEAM_ID: The supplied team ID does not identify a running team. - another error code */ thread_id main_thread_for(team_id team) { // Under Haiku the team ID is equal to it's main thread ID. We just get // a team info to verify the existence of the team. team_info info; status_t error = get_team_info(team, &info); return error == B_OK ? team : error; }
status_t LocalDebuggerInterface::GetTeamInfo(TeamInfo& info) { team_info teamInfo; status_t result = get_team_info(fTeamID, &teamInfo); if (result != B_OK) return result; info.SetTo(fTeamID, teamInfo); return B_OK; }
static status_t signal_pusher(void* data) { team_info teamInfo; get_team_info(B_CURRENT_TEAM, &teamInfo); thread_id mainThread = teamInfo.team; while (true) { send_signal(mainThread, SIGUSR1); snooze(1000); } return B_OK; }
TeamsWindow::TeamsWindow(SettingsManager* settingsManager) : BWindow(BRect(100, 100, 500, 250), "Teams", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), fTargetHostInterface(NULL), fTeamsListView(NULL), fAttachTeamButton(NULL), fCreateTeamButton(NULL), fLoadCoreButton(NULL), fConnectionField(NULL), fCoreSelectionPanel(NULL), fSettingsManager(settingsManager), fListeners() { team_info info; get_team_info(B_CURRENT_TEAM, &info); fCurrentTeam = info.team; }
//------------------------------------------------------------------------------ std::string TInstantiateObjectTester::GetLocalSignature() { BRoster Roster; app_info ai; team_id team; // Get the team_id of this app thread_id tid = find_thread(NULL); thread_info ti; status_t err = get_thread_info(tid, &ti); if (err) { FORMAT_AND_THROW(" failed to get thread_info: ", err); } // Get the app_info via the team_id team = ti.team; team_info info; err = get_team_info(team, &info); if (err) { FORMAT_AND_THROW(" failed to get team_info: ", err); } team = info.team; // It seems that this call to GetRunningAppInfo() is not working because we // don't have an instance of BApplication somewhere -- the roster, therefore, // doesn't know about us. err = Roster.GetRunningAppInfo(team, &ai); if (err) { FORMAT_AND_THROW(" failed to get app_info: ", err); } // Return the signature from the app_info return ai.signature; }
/** * Creates the default logger instance for a VBox process. * * @returns Pointer to the logger instance. */ RTDECL(PRTLOGGER) RTLogDefaultInit(void) { /* * Initialize the default logger instance. * Take care to do this once and not recursively. */ static volatile uint32_t fInitializing = 0; PRTLOGGER pLogger; int rc; if (g_pLogger || !ASMAtomicCmpXchgU32(&fInitializing, 1, 0)) return g_pLogger; #ifdef IN_RING3 /* * Assert the group definitions. */ #define ASSERT_LOG_GROUP(grp) ASSERT_LOG_GROUP2(LOG_GROUP_##grp, #grp) #define ASSERT_LOG_GROUP2(def, str) \ do { if (strcmp(g_apszGroups[def], str)) {printf("%s='%s' expects '%s'\n", #def, g_apszGroups[def], str); RTAssertDoPanic(); } } while (0) ASSERT_LOG_GROUP(DEFAULT); ASSERT_LOG_GROUP(AUDIO_MIXER); ASSERT_LOG_GROUP(AUDIO_MIXER_BUFFER); ASSERT_LOG_GROUP(CFGM); ASSERT_LOG_GROUP(CPUM); ASSERT_LOG_GROUP(CSAM); ASSERT_LOG_GROUP(DBGC); ASSERT_LOG_GROUP(DBGF); ASSERT_LOG_GROUP(DBGF_INFO); ASSERT_LOG_GROUP(DEV); ASSERT_LOG_GROUP(DEV_AC97); ASSERT_LOG_GROUP(DEV_ACPI); ASSERT_LOG_GROUP(DEV_APIC); ASSERT_LOG_GROUP(DEV_FDC); ASSERT_LOG_GROUP(DEV_HDA); ASSERT_LOG_GROUP(DEV_HDA_CODEC); ASSERT_LOG_GROUP(DEV_HPET); ASSERT_LOG_GROUP(DEV_IDE); ASSERT_LOG_GROUP(DEV_KBD); ASSERT_LOG_GROUP(DEV_LPC); ASSERT_LOG_GROUP(DEV_NE2000); ASSERT_LOG_GROUP(DEV_PC); ASSERT_LOG_GROUP(DEV_PC_ARCH); ASSERT_LOG_GROUP(DEV_PC_BIOS); ASSERT_LOG_GROUP(DEV_PCI); ASSERT_LOG_GROUP(DEV_PCNET); ASSERT_LOG_GROUP(DEV_PIC); ASSERT_LOG_GROUP(DEV_PIT); ASSERT_LOG_GROUP(DEV_RTC); ASSERT_LOG_GROUP(DEV_SB16); ASSERT_LOG_GROUP(DEV_SERIAL); ASSERT_LOG_GROUP(DEV_SMC); ASSERT_LOG_GROUP(DEV_VGA); ASSERT_LOG_GROUP(DEV_VMM); ASSERT_LOG_GROUP(DEV_VMM_STDERR); ASSERT_LOG_GROUP(DIS); ASSERT_LOG_GROUP(DRV); ASSERT_LOG_GROUP(DRV_ACPI); ASSERT_LOG_GROUP(DRV_AUDIO); ASSERT_LOG_GROUP(DRV_BLOCK); ASSERT_LOG_GROUP(DRV_FLOPPY); ASSERT_LOG_GROUP(DRV_HOST_AUDIO); ASSERT_LOG_GROUP(DRV_HOST_DVD); ASSERT_LOG_GROUP(DRV_HOST_FLOPPY); ASSERT_LOG_GROUP(DRV_ISO); ASSERT_LOG_GROUP(DRV_KBD_QUEUE); ASSERT_LOG_GROUP(DRV_MOUSE_QUEUE); ASSERT_LOG_GROUP(DRV_NAT); ASSERT_LOG_GROUP(DRV_RAW_IMAGE); ASSERT_LOG_GROUP(DRV_TUN); ASSERT_LOG_GROUP(DRV_USBPROXY); ASSERT_LOG_GROUP(DRV_VBOXHDD); ASSERT_LOG_GROUP(DRV_VRDE_AUDIO); ASSERT_LOG_GROUP(DRV_VSWITCH); ASSERT_LOG_GROUP(DRV_VUSB); ASSERT_LOG_GROUP(EM); ASSERT_LOG_GROUP(GUI); ASSERT_LOG_GROUP(HGCM); ASSERT_LOG_GROUP(HM); ASSERT_LOG_GROUP(IOM); ASSERT_LOG_GROUP(LWIP); ASSERT_LOG_GROUP(MAIN); ASSERT_LOG_GROUP(MM); ASSERT_LOG_GROUP(MM_HEAP); ASSERT_LOG_GROUP(MM_HYPER); ASSERT_LOG_GROUP(MM_HYPER_HEAP); ASSERT_LOG_GROUP(MM_PHYS); ASSERT_LOG_GROUP(MM_POOL); ASSERT_LOG_GROUP(NAT_SERVICE); ASSERT_LOG_GROUP(NET_SERVICE); ASSERT_LOG_GROUP(PATM); ASSERT_LOG_GROUP(PDM); ASSERT_LOG_GROUP(PDM_DEVICE); ASSERT_LOG_GROUP(PDM_DRIVER); ASSERT_LOG_GROUP(PDM_LDR); ASSERT_LOG_GROUP(PDM_QUEUE); ASSERT_LOG_GROUP(PGM); ASSERT_LOG_GROUP(PGM_POOL); ASSERT_LOG_GROUP(REM); ASSERT_LOG_GROUP(REM_DISAS); ASSERT_LOG_GROUP(REM_HANDLER); ASSERT_LOG_GROUP(REM_IOPORT); ASSERT_LOG_GROUP(REM_MMIO); ASSERT_LOG_GROUP(REM_PRINTF); ASSERT_LOG_GROUP(REM_RUN); ASSERT_LOG_GROUP(SELM); ASSERT_LOG_GROUP(SSM); ASSERT_LOG_GROUP(STAM); ASSERT_LOG_GROUP(SUP); ASSERT_LOG_GROUP(TM); ASSERT_LOG_GROUP(TRPM); ASSERT_LOG_GROUP(VM); ASSERT_LOG_GROUP(VMM); ASSERT_LOG_GROUP(VRDP); #undef ASSERT_LOG_GROUP #undef ASSERT_LOG_GROUP2 #endif /* IN_RING3 */ /* * Create the default logging instance. */ #ifdef IN_RING3 # ifndef IN_GUEST char szExecName[RTPATH_MAX]; if (!RTProcGetExecutablePath(szExecName, sizeof(szExecName))) strcpy(szExecName, "VBox"); RTTIMESPEC TimeSpec; RTTIME Time; RTTimeExplode(&Time, RTTimeNow(&TimeSpec)); rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0], RTLOGDEST_FILE, "./%04d-%02d-%02d-%02d-%02d-%02d.%03d-%s-%d.log", Time.i32Year, Time.u8Month, Time.u8MonthDay, Time.u8Hour, Time.u8Minute, Time.u8Second, Time.u32Nanosecond / 10000000, RTPathFilename(szExecName), RTProcSelf()); if (RT_SUCCESS(rc)) { /* * Write a log header. */ char szBuf[RTPATH_MAX]; RTTimeSpecToString(&TimeSpec, szBuf, sizeof(szBuf)); RTLogLoggerEx(pLogger, 0, ~0U, "Log created: %s\n", szBuf); RTLogLoggerEx(pLogger, 0, ~0U, "Executable: %s\n", szExecName); /* executable and arguments - tricky and all platform specific. */ # if defined(RT_OS_WINDOWS) RTLogLoggerEx(pLogger, 0, ~0U, "Commandline: %ls\n", GetCommandLineW()); # elif defined(RT_OS_SOLARIS) psinfo_t psi; char szArgFileBuf[80]; RTStrPrintf(szArgFileBuf, sizeof(szArgFileBuf), "/proc/%ld/psinfo", (long)getpid()); FILE* pFile = fopen(szArgFileBuf, "rb"); if (pFile) { if (fread(&psi, sizeof(psi), 1, pFile) == 1) { # if 0 /* 100% safe:*/ RTLogLoggerEx(pLogger, 0, ~0U, "Args: %s\n", psi.pr_psargs); # else /* probably safe: */ const char * const *argv = (const char * const *)psi.pr_argv; for (int iArg = 0; iArg < psi.pr_argc; iArg++) RTLogLoggerEx(pLogger, 0, ~0U, "Arg[%d]: %s\n", iArg, argv[iArg]); # endif } fclose(pFile); } # elif defined(RT_OS_LINUX) FILE *pFile = fopen("/proc/self/cmdline", "r"); if (pFile) { /* braindead */ unsigned iArg = 0; int ch; bool fNew = true; while (!feof(pFile) && (ch = fgetc(pFile)) != EOF) { if (fNew) { RTLogLoggerEx(pLogger, 0, ~0U, "Arg[%u]: ", iArg++); fNew = false; } if (ch) RTLogLoggerEx(pLogger, 0, ~0U, "%c", ch); else { RTLogLoggerEx(pLogger, 0, ~0U, "\n"); fNew = true; } } if (!fNew) RTLogLoggerEx(pLogger, 0, ~0U, "\n"); fclose(pFile); } # elif defined(RT_OS_HAIKU) team_info info; if (get_team_info(0, &info) == B_OK) { /* there is an info.argc, but no way to know arg boundaries */ RTLogLoggerEx(pLogger, 0, ~0U, "Commandline: %.64s\n", info.args); } # elif defined(RT_OS_FREEBSD) /* Retrieve the required length first */ int aiName[4]; aiName[0] = CTL_KERN; aiName[1] = KERN_PROC; aiName[2] = KERN_PROC_ARGS; /* Introduced in FreeBSD 4.0 */ aiName[3] = getpid(); size_t cchArgs = 0; int rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), NULL, &cchArgs, NULL, 0); if (cchArgs > 0) { char *pszArgFileBuf = (char *)RTMemAllocZ(cchArgs + 1 /* Safety */); if (pszArgFileBuf) { /* Retrieve the argument list */ rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), pszArgFileBuf, &cchArgs, NULL, 0); if (!rcBSD) { unsigned iArg = 0; size_t off = 0; while (off < cchArgs) { size_t cchArg = strlen(&pszArgFileBuf[off]); RTLogLoggerEx(pLogger, 0, ~0U, "Arg[%u]: %s\n", iArg, &pszArgFileBuf[off]); /* advance */ off += cchArg + 1; iArg++; } } RTMemFree(pszArgFileBuf); } } # elif defined(RT_OS_OS2) || defined(RT_OS_DARWIN) /* commandline? */ # else # error needs porting. # endif } # else /* IN_GUEST */ /* The user destination is backdoor logging. */ rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0], RTLOGDEST_USER, "VBox.log"); # endif /* IN_GUEST */ #else /* IN_RING0 */ /* Some platforms has trouble allocating memory with interrupts and/or preemption disabled. Check and fail before we panic. */ # if defined(RT_OS_DARWIN) if ( !ASMIntAreEnabled() || !RTThreadPreemptIsEnabled(NIL_RTTHREAD)) return NULL; # endif # ifndef IN_GUEST rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0], RTLOGDEST_FILE, "VBox-ring0.log"); # else /* IN_GUEST */ rc = RTLogCreate(&pLogger, 0, NULL, "VBOX_LOG", RT_ELEMENTS(g_apszGroups), &g_apszGroups[0], RTLOGDEST_USER, "VBox-ring0.log"); # endif /* IN_GUEST */ if (RT_SUCCESS(rc)) { /* * This is where you set your ring-0 logging preferences. * * On platforms which don't differ between debugger and kernel * log printing, STDOUT is gonna be a stub and the DEBUGGER * destination is the one doing all the work. On platforms * that do differ (like Darwin), STDOUT is the kernel log. */ # if defined(DEBUG_bird) /*RTLogGroupSettings(pLogger, "all=~0 -default.l6.l5.l4.l3");*/ RTLogFlags(pLogger, "enabled unbuffered pid tid"); # ifndef IN_GUEST pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT; # endif # endif # if defined(DEBUG_sandervl) && !defined(IN_GUEST) RTLogGroupSettings(pLogger, "+all"); RTLogFlags(pLogger, "enabled unbuffered"); pLogger->fDestFlags |= RTLOGDEST_DEBUGGER; # endif # if defined(DEBUG_ramshankar) /* Guest ring-0 as well */ RTLogGroupSettings(pLogger, "+all.e.l.f"); RTLogFlags(pLogger, "enabled unbuffered"); pLogger->fDestFlags |= RTLOGDEST_DEBUGGER; # endif # if defined(DEBUG_aleksey) /* Guest ring-0 as well */ //RTLogGroupSettings(pLogger, "net_flt_drv.e.l.f.l3.l4.l5 +net_adp_drv.e.l.f.l3.l4.l5"); RTLogGroupSettings(pLogger, "net_flt_drv.e.l.f.l3.l4.l5.l6"); RTLogFlags(pLogger, "enabled unbuffered"); pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT; # endif # if defined(DEBUG_andy) /* Guest ring-0 as well */ RTLogGroupSettings(pLogger, "+all.e.l.f"); RTLogFlags(pLogger, "enabled unbuffered pid tid"); pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT; # endif # if defined(DEBUG_misha) /* Guest ring-0 as well */ RTLogFlags(pLogger, "enabled unbuffered"); pLogger->fDestFlags |= RTLOGDEST_DEBUGGER; # endif # if defined(DEBUG_michael) && defined(IN_GUEST) RTLogGroupSettings(pLogger, "+vga.e.l.f"); RTLogFlags(pLogger, "enabled unbuffered"); pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT; # endif # if 0 /* vboxdrv logging - ATTENTION: this is what we're referring to guys! Change to '# if 1'. */ RTLogGroupSettings(pLogger, "all=~0 -default.l6.l5.l4.l3"); RTLogFlags(pLogger, "enabled unbuffered tid"); pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT; # endif } #endif /* IN_RING0 */ return g_pLogger = RT_SUCCESS(rc) ? pLogger : NULL; }
void MemoryBarMenu::Pulse() { system_info sinfo; get_system_info(&sinfo); int committedMemory = int(sinfo.used_pages * B_PAGE_SIZE / 1024); int cachedMemory = int(sinfo.cached_pages * B_PAGE_SIZE / 1024); Window()->BeginViewTransaction(); // create the list of items to remove, for their team is gone. Update the old teams. int lastRecycle = 0; int firstRecycle = 0; int k; MemoryBarMenuItem* item; int total = 0; for (k = 1; (item = (MemoryBarMenuItem*)ItemAt(k)) != NULL; k++) { int m = item->UpdateSituation(committedMemory); if (m < 0) { if (lastRecycle == fRecycleCount) { fRecycleCount += EXTRA; fRecycleList = (MRecycleItem*)realloc(fRecycleList, sizeof(MRecycleItem) * fRecycleCount); } fRecycleList[lastRecycle].index = k; fRecycleList[lastRecycle++].item = item; } else { if (lastRecycle > 0) { RemoveItems(fRecycleList[0].index, lastRecycle, true); k -= lastRecycle; lastRecycle = 0; } total += m; } } // Look new teams that have appeared. Create an item for them, or recycle from the list. int32 cookie = 0; info_pack infos; item = NULL; while (get_next_team_info(&cookie, &infos.team_info) == B_OK) { int j = 0; while (j < fTeamCount && infos.team_info.team != fTeamList[j]) { j++; } if (infos.team_info.team != fTeamList[j]) { // new team team_info info; j = 0; while (j < fTeamCount && fTeamList[j] != -1) { if (get_team_info(fTeamList[j], &info) != B_OK) fTeamList[j] = -1; else j++; } if (j == fTeamCount) { fTeamCount += 10; fTeamList = (team_id*)realloc(fTeamList, sizeof(team_id) * fTeamCount); } fTeamList[j] = infos.team_info.team; if (!get_team_name_and_icon(infos, true)) { // the team is already gone! delete infos.team_icon; fTeamList[j] = -1; } else { if (!item && firstRecycle < lastRecycle) item = fRecycleList[firstRecycle++].item; if (item) item->Reset(infos.team_name, infos.team_info.team, infos.team_icon, true); else { AddItem(item = new MemoryBarMenuItem(infos.team_name, infos.team_info.team, infos.team_icon, true, NULL)); } int m = item->UpdateSituation(committedMemory); if (m >= 0) { total += m; item = NULL; } else fTeamList[j] = -1; } } } if (item) { RemoveItem(item); delete item; } // Delete the items that haven't been recycled. if (firstRecycle < lastRecycle) { RemoveItems(IndexOf(fRecycleList[firstRecycle].item), lastRecycle - firstRecycle, true); } fLastTotalTime = system_time(); KernelMemoryBarMenuItem *kernelItem; if ((kernelItem = (KernelMemoryBarMenuItem*)ItemAt(0)) != NULL) kernelItem->UpdateSituation(committedMemory, cachedMemory); Window()->EndViewTransaction(); Window()->Flush(); }
void ProcessController::MessageReceived(BMessage *message) { team_id team; thread_id thread; BAlert *alert; char question[1000]; switch (message->what) { case 'Puls': Update (); DoDraw (false); break; case 'QtTm': if (message->FindInt32("team", &team) == B_OK) { resume_thread(spawn_thread(thread_quit_application, B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY, (void*) team)); } break; case 'KlTm': if (message->FindInt32("team", &team) == B_OK) { info_pack infos; if (get_team_info(team, &infos.team_info) == B_OK) { get_team_name_and_icon(infos); snprintf(question, sizeof(question), B_TRANSLATE("Do you really want to kill the team \"%s\"?"), infos.team_name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Yes, kill this team!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); if (alert->Go()) kill_team(team); } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This team is already gone"B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } } break; case 'KlTh': if (message->FindInt32("thread", &thread) == B_OK) { thread_info thinfo; if (get_thread_info(thread, &thinfo) == B_OK) { #if DEBUG_THREADS snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do " "with the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"), B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); #define KILL 2 #else snprintf(question, sizeof(question), B_TRANSLATE("Are you sure you want " "to kill the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); #define KILL 1 #endif alert->SetShortcut(0, B_ESCAPE); int r = alert->Go(); if (r == KILL) kill_thread(thread); #if DEBUG_THREADS else if (r == 1) { Tdebug_thead_param* param = new Tdebug_thead_param; param->thread = thread; if (thinfo.state == B_THREAD_WAITING) param->sem = thinfo.sem; else param->sem = -1; param->totalTime = thinfo.user_time+thinfo.kernel_time; resume_thread(spawn_thread(thread_debug_thread, B_TRANSLATE("Debug thread"), B_NORMAL_PRIORITY, param)); } #endif } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This thread is already gone"B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } } break; case 'PrTh': if (message->FindInt32("thread", &thread) == B_OK) { long new_priority; if (message->FindInt32("priority", &new_priority) == B_OK) set_thread_priority(thread, new_priority); } break; case 'Trac': launch(kTrackerSig, "/boot/system/Tracker"); break; case 'Dbar': launch(kDeskbarSig, "/boot/system/Deskbar"); break; case 'Term': launch(kTerminalSig, "/boot/system/apps/Terminal"); break; case 'AlDb': { if (!be_roster->IsRunning(kDeskbarSig)) launch(kDeskbarSig, "/boot/system/Deskbar"); BDeskbar deskbar; if (gInDeskbar || deskbar.HasItem (kDeskbarItemName)) deskbar.RemoveItem (kDeskbarItemName); else move_to_deskbar(deskbar); break; } case 'CPU ': { int32 cpu; if (message->FindInt32 ("cpu", &cpu) == B_OK) { bool last = true; for (int p = 0; p < gCPUcount; p++) { if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } } if (last) { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This is the last active processor...\n" "You can't turn it off!"), B_TRANSLATE("That's no Fun!"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } else _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } case B_ABOUT_REQUESTED: AboutRequested(); break; default: BView::MessageReceived(message); } }
status_t thread_debug_thread(void *arg) { Tdebug_thead_param* param = (Tdebug_thead_param*) arg; #ifdef __HAIKU__ debug_thread(param->thread); #else // !__HAIKU__ thread_info thinfo; get_thread_info(param->thread, &thinfo); char text[4096]; sprintf(text, "db %d", int(param->thread)); system(text); if (param->sem >= 0 && thinfo.state == B_THREAD_WAITING && param->sem == thinfo.sem) { snooze(1000000); get_thread_info(param->thread, &thinfo); if (thinfo.state == B_THREAD_WAITING && param->sem == thinfo.sem && param->totalTime == thinfo.user_time + thinfo.kernel_time) { // the thread has been waiting for this semaphore since the before // the alert, not doing anything... Let's push it out of there! sem_info sinfo; thread_info thinfo; info_pack infos; if (get_sem_info(param->sem, &sinfo) == B_OK && get_thread_info(param->thread, &thinfo) == B_OK && get_team_info(thinfo.team, &infos.team_info) == B_OK) { sprintf (text, "This thread is waiting for the " "semaphore called \"%s\". As long as it waits for this " "semaphore, you won't be able to debug that thread.\n", sinfo.name); if (sinfo.team == thinfo.team) strcat(text, "This semaphore belongs to the " "thread's team.\n\nShould I release this semaphore?\n"); else { get_team_name_and_icon(infos); char moreText[1024]; sprintf(moreText, "\nWARNING! This semaphore " "belongs to the team \"%s\"!\n\nShould I release this " "semaphore anyway?\n", infos.team_name); strcat(text, moreText); } BAlert* alert = new BAlert("", text, "Cancel", "Release", NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); if (alert->Go()) { get_thread_info (param->thread, &thinfo); if (thinfo.state == B_THREAD_WAITING && param->sem == thinfo.sem && param->totalTime == thinfo.user_time + thinfo.kernel_time) release_sem(param->sem); else { alert = new BAlert("", "The semaphore wasn't released, " "because it wasn't necessary anymore!", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } } } } #endif // !__HAIKU__ delete param; return B_OK; }
void ProcessController::MessageReceived(BMessage *message) { team_id team; thread_id thread; BAlert *alert; char question[1000]; switch (message->what) { case 'Puls': Update (); DoDraw (false); break; case 'QtTm': if (message->FindInt32("team", &team) == B_OK) { resume_thread(spawn_thread(thread_quit_application, B_TRANSLATE("Quit application"), B_NORMAL_PRIORITY, (void*)(addr_t)team)); } break; case 'KlTm': if (message->FindInt32("team", &team) == B_OK) { info_pack infos; if (get_team_info(team, &infos.team_info) == B_OK) { get_team_name_and_icon(infos); snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do with the team \"%s\"?"), infos.team_name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this team!"), B_TRANSLATE("Kill this team!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); int result = alert->Go(); switch (result) { case 1: _HandleDebugRequest(team, -1); break; case 2: kill_team(team); break; default: break; } } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This team is already gone" B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } break; case 'KlTh': if (message->FindInt32("thread", &thread) == B_OK) { thread_info thinfo; if (get_thread_info(thread, &thinfo) == B_OK) { #if DEBUG_THREADS snprintf(question, sizeof(question), B_TRANSLATE("What do you want to do " "with the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Debug this thread!"), B_TRANSLATE("Kill this thread!"), B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); #define KILL 2 #else snprintf(question, sizeof(question), B_TRANSLATE("Are you sure you want " "to kill the thread \"%s\"?"), thinfo.name); alert = new BAlert(B_TRANSLATE("Please confirm"), question, B_TRANSLATE("Cancel"), B_TRANSLATE("Kill this thread!"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); #define KILL 1 #endif alert->SetShortcut(0, B_ESCAPE); int r = alert->Go(); if (r == KILL) kill_thread(thread); #if DEBUG_THREADS else if (r == 1) _HandleDebugRequest(thinfo.team, thinfo.thread); #endif } else { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This thread is already gone" B_UTF8_ELLIPSIS), B_TRANSLATE("Ok!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } break; case 'PrTh': if (message->FindInt32("thread", &thread) == B_OK) { int32 new_priority; if (message->FindInt32("priority", &new_priority) == B_OK) set_thread_priority(thread, new_priority); } break; case 'Trac': { BPath trackerPath; if (find_directory(B_SYSTEM_DIRECTORY, &trackerPath) == B_OK && trackerPath.Append("Tracker") == B_OK) { launch(kTrackerSig, trackerPath.Path()); } break; } case 'Dbar': { BPath deskbarPath; if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK && deskbarPath.Append("Deskbar") == B_OK) { launch(kDeskbarSig, deskbarPath.Path()); } break; } case 'Term': { BPath terminalPath; if (find_directory(B_SYSTEM_APPS_DIRECTORY, &terminalPath) == B_OK && terminalPath.Append("Terminal") == B_OK) { launch(kTerminalSig, terminalPath.Path()); } break; } case 'AlDb': { if (!be_roster->IsRunning(kDeskbarSig)) { BPath deskbarPath; if (find_directory(B_SYSTEM_DIRECTORY, &deskbarPath) == B_OK && deskbarPath.Append("Deskbar") == B_OK) { launch(kDeskbarSig, deskbarPath.Path()); } } BDeskbar deskbar; if (gInDeskbar || deskbar.HasItem (kDeskbarItemName)) deskbar.RemoveItem (kDeskbarItemName); else move_to_deskbar(deskbar); break; } case 'CPU ': { uint32 cpu; if (message->FindInt32("cpu", (int32*)&cpu) == B_OK) { bool last = true; for (unsigned int p = 0; p < gCPUcount; p++) { if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } } if (last) { alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("This is the last active processor...\n" "You can't turn it off!"), B_TRANSLATE("That's no Fun!"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } else _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } case 'Schd': { int32 mode; if (message->FindInt32 ("mode", &mode) == B_OK) set_scheduler_mode(mode); break; } case B_ABOUT_REQUESTED: AboutRequested(); break; default: BView::MessageReceived(message); } }
void FilePermissionsView::ModelChanged(Model* model) { fModel = model; bool hideCheckBoxes = false; uid_t nodeOwner = 0; gid_t nodeGroup = 0; mode_t perms = 0; if (fModel != NULL) { BNode node(fModel->EntryRef()); if (node.InitCheck() == B_OK) { if (fReadUserCheckBox->IsHidden()) { fReadUserCheckBox->Show(); fReadGroupCheckBox->Show(); fReadOtherCheckBox->Show(); fWriteUserCheckBox->Show(); fWriteGroupCheckBox->Show(); fWriteOtherCheckBox->Show(); fExecuteUserCheckBox->Show(); fExecuteGroupCheckBox->Show(); fExecuteOtherCheckBox->Show(); } if (node.GetPermissions(&perms) == B_OK) { fReadUserCheckBox->SetValue((int32)(perms & S_IRUSR)); fReadGroupCheckBox->SetValue((int32)(perms & S_IRGRP)); fReadOtherCheckBox->SetValue((int32)(perms & S_IROTH)); fWriteUserCheckBox->SetValue((int32)(perms & S_IWUSR)); fWriteGroupCheckBox->SetValue((int32)(perms & S_IWGRP)); fWriteOtherCheckBox->SetValue((int32)(perms & S_IWOTH)); fExecuteUserCheckBox->SetValue((int32)(perms & S_IXUSR)); fExecuteGroupCheckBox->SetValue((int32)(perms & S_IXGRP)); fExecuteOtherCheckBox->SetValue((int32)(perms & S_IXOTH)); } else hideCheckBoxes = true; if (node.GetOwner(&nodeOwner) == B_OK) { BString user; if (nodeOwner == 0) if (getenv("USER") != NULL) user << getenv("USER"); else user << "root"; else user << nodeOwner; fOwnerTextControl->SetText(user.String()); } else fOwnerTextControl->SetText(B_TRANSLATE("Unknown")); if (node.GetGroup(&nodeGroup) == B_OK) { BString group; if (nodeGroup == 0) if (getenv("GROUP") != NULL) group << getenv("GROUP"); else group << "0"; else group << nodeGroup; fGroupTextControl->SetText(group.String()); } else fGroupTextControl->SetText(B_TRANSLATE("Unknown")); // Unless we're root, only allow the owner to transfer the // ownership, i.e. disable text controls if uid:s doesn't match: thread_id thisThread = find_thread(NULL); thread_info threadInfo; get_thread_info(thisThread, &threadInfo); team_info teamInfo; get_team_info(threadInfo.team, &teamInfo); if (teamInfo.uid != 0 && nodeOwner != teamInfo.uid) { fOwnerTextControl->SetEnabled(false); fGroupTextControl->SetEnabled(false); } else { fOwnerTextControl->SetEnabled(true); fGroupTextControl->SetEnabled(true); } } else hideCheckBoxes = true; } else hideCheckBoxes = true; if (hideCheckBoxes) { fReadUserCheckBox->Hide(); fReadGroupCheckBox->Hide(); fReadOtherCheckBox->Hide(); fWriteUserCheckBox->Hide(); fWriteGroupCheckBox->Hide(); fWriteOtherCheckBox->Hide(); fExecuteUserCheckBox->Hide(); fExecuteGroupCheckBox->Hide(); fExecuteOtherCheckBox->Hide(); } }
status_t TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain) { bool targetIsLocal = true; // TODO: Support non-local targets! // the first thing we want to do when running PostMessage(MSG_LOAD_SETTINGS); fTeamID = teamID; // create debugger interface fDebuggerInterface = new(std::nothrow) DebuggerInterface(fTeamID); if (fDebuggerInterface == NULL) return B_NO_MEMORY; status_t error = fDebuggerInterface->Init(); if (error != B_OK) return error; // create file manager fFileManager = new(std::nothrow) FileManager; if (fFileManager == NULL) return B_NO_MEMORY; error = fFileManager->Init(targetIsLocal); if (error != B_OK) return error; // create team debug info TeamDebugInfo* teamDebugInfo = new(std::nothrow) TeamDebugInfo( fDebuggerInterface, fDebuggerInterface->GetArchitecture(), fFileManager); if (teamDebugInfo == NULL) return B_NO_MEMORY; BReference<TeamDebugInfo> teamDebugInfoReference(teamDebugInfo); error = teamDebugInfo->Init(); if (error != B_OK) return error; // check whether the team exists at all // TODO: That should be done in the debugger interface! team_info teamInfo; error = get_team_info(fTeamID, &teamInfo); if (error != B_OK) return error; // create a team object fTeam = new(std::nothrow) ::Team(fTeamID, fDebuggerInterface, fDebuggerInterface->GetArchitecture(), teamDebugInfo, teamDebugInfo); if (fTeam == NULL) return B_NO_MEMORY; error = fTeam->Init(); if (error != B_OK) return error; fTeam->SetName(teamInfo.args); // TODO: Set a better name! fTeam->AddListener(this); // init thread handler table error = fThreadHandlers.Init(); if (error != B_OK) return error; // create image handler table fImageHandlers = new(std::nothrow) ImageHandlerTable; if (fImageHandlers == NULL) return B_NO_MEMORY; error = fImageHandlers->Init(); if (error != B_OK) return error; // create our worker fWorker = new(std::nothrow) Worker; if (fWorker == NULL) return B_NO_MEMORY; error = fWorker->Init(); if (error != B_OK) return error; // create the breakpoint manager fBreakpointManager = new(std::nothrow) BreakpointManager(fTeam, fDebuggerInterface); if (fBreakpointManager == NULL) return B_NO_MEMORY; error = fBreakpointManager->Init(); if (error != B_OK) return error; // create the memory block manager fMemoryBlockManager = new(std::nothrow) TeamMemoryBlockManager(); if (fMemoryBlockManager == NULL) return B_NO_MEMORY; error = fMemoryBlockManager->Init(); if (error != B_OK) return error; // set team debugging flags fDebuggerInterface->SetTeamDebuggingFlags( B_TEAM_DEBUG_THREADS | B_TEAM_DEBUG_IMAGES); // get the initial state of the team AutoLocker< ::Team> teamLocker(fTeam); ThreadHandler* mainThreadHandler = NULL; { BObjectList<ThreadInfo> threadInfos(20, true); status_t error = fDebuggerInterface->GetThreadInfos(threadInfos); for (int32 i = 0; ThreadInfo* info = threadInfos.ItemAt(i); i++) { ::Thread* thread; error = fTeam->AddThread(*info, &thread); if (error != B_OK) return error; ThreadHandler* handler = new(std::nothrow) ThreadHandler(thread, fWorker, fDebuggerInterface, fBreakpointManager); if (handler == NULL) return B_NO_MEMORY; fThreadHandlers.Insert(handler); if (thread->IsMainThread()) mainThreadHandler = handler; handler->Init(); } } Image* appImage = NULL; { BObjectList<ImageInfo> imageInfos(20, true); status_t error = fDebuggerInterface->GetImageInfos(imageInfos); for (int32 i = 0; ImageInfo* info = imageInfos.ItemAt(i); i++) { Image* image; error = _AddImage(*info, &image); if (error != B_OK) return error; if (image->Type() == B_APP_IMAGE) appImage = image; ImageDebugInfoRequested(image); } } // create the debug event listener char buffer[128]; snprintf(buffer, sizeof(buffer), "team %ld debug listener", fTeamID); fDebugEventListener = spawn_thread(_DebugEventListenerEntry, buffer, B_NORMAL_PRIORITY, this); if (fDebugEventListener < 0) return fDebugEventListener; resume_thread(fDebugEventListener); // run looper thread_id looperThread = Run(); if (looperThread < 0) return looperThread; // init the UI error = fUserInterface->Init(fTeam, this); if (error != B_OK) { ERROR("Error: Failed to init the UI: %s\n", strerror(error)); return error; } // if requested, stop the given thread if (threadID >= 0) { if (stopInMain) { SymbolInfo symbolInfo; if (appImage != NULL && mainThreadHandler != NULL && fDebuggerInterface->GetSymbolInfo( fTeam->ID(), appImage->ID(), "main", B_SYMBOL_TYPE_TEXT, symbolInfo) == B_OK) { mainThreadHandler->SetBreakpointAndRun(symbolInfo.Address()); } } else { debug_thread(threadID); // TODO: Superfluous, if the thread is already stopped. } } fListener->TeamDebuggerStarted(this); return B_OK; }
void DeskbarView::MessageReceived(BMessage *message) { // message->PrintToStream(); switch (message->what) { case 'LIVE': { ticks++; Invalidate(); team_info teamInfo; status_t error = get_team_info(team, &teamInfo); if (error != B_OK && id>0) { BDeskbar deskbar; deskbar.RemoveItem(id); } else { BMessage *mes=new BMessage(*message); mes->AddRect("rect",ConvertToScreen(Bounds())); ReplyMessenger.SendMessage(mes); } break; } case B_SET_PROPERTY: { switch( message->FindInt32("what2") ) { case 'TTIP': { const char *tip=NULL; status_t res = message->FindString("tooltip",&tip); if(!tip || res!=B_OK) tip = applicationName.String(); if(strlen(tip)==0) tip = applicationName.String(); if(strlen(tip)!=0) SetToolTip(tip); break; } case 'BITS': { BBitmap *oldicon=icon; icon=NULL; delete oldicon; BMessage bits; message->FindMessage("icon", &bits); icon = new BBitmap(&bits); bits.MakeEmpty(); Invalidate(); break; } case '_ID_': { message->FindInt32("ReplicantID",&id); break; } case 'MSGR': { ssize_t numBytes; const char *name=NULL; message->FindMessenger("messenger", &ReplyMessenger); message->FindData("qtrayobject",B_ANY_TYPE,&traysysobject,&numBytes); if(message->FindString("application_name",&name)==B_OK) applicationName.SetTo(name); break; } } } break; default: BView::MessageReceived(message); break; } }
static void haiku_init_child_debugging (thread_id threadID, bool debugThread) { thread_info threadInfo; status_t result; port_id nubPort; // get a thread info result = get_thread_info(threadID, &threadInfo); if (result != B_OK) error("Thread with ID %ld not found: %s", threadID, strerror(result)); // init our team debug structure sTeamDebugInfo.team = threadInfo.team; sTeamDebugInfo.debugger_port = -1; sTeamDebugInfo.context.nub_port = -1; sTeamDebugInfo.context.reply_port = -1; sTeamDebugInfo.threads = NULL; sTeamDebugInfo.events.head = NULL; sTeamDebugInfo.events.tail = NULL; // create the debugger port sTeamDebugInfo.debugger_port = create_port(10, "gdb debug"); if (sTeamDebugInfo.debugger_port < 0) { error("Failed to create debugger port: %s", strerror(sTeamDebugInfo.debugger_port)); } // install ourselves as the team debugger nubPort = install_team_debugger(sTeamDebugInfo.team, sTeamDebugInfo.debugger_port); if (nubPort < 0) { error("Failed to install ourselves as debugger for team %ld: %s", sTeamDebugInfo.team, strerror(nubPort)); } // get the nub thread { team_info teamInfo; result = get_team_info(sTeamDebugInfo.team, &teamInfo); if (result != B_OK) { error("Failed to get info for team %ld: %s\n", sTeamDebugInfo.team, strerror(result)); } sTeamDebugInfo.nub_thread = teamInfo.debugger_nub_thread; } // init the debug context result = init_debug_context(&sTeamDebugInfo.context, sTeamDebugInfo.team, nubPort); if (result != B_OK) { error("Failed to init debug context for team %ld: %s\n", sTeamDebugInfo.team, strerror(result)); } // start debugging the thread if (debugThread) { result = debug_thread(threadID); if (result != B_OK) { error("Failed to start debugging thread %ld: %s", threadID, strerror(result)); } } // set the team debug flags { debug_nub_set_team_flags message; message.flags = B_TEAM_DEBUG_SIGNALS /*| B_TEAM_DEBUG_PRE_SYSCALL | B_TEAM_DEBUG_POST_SYSCALL*/ | B_TEAM_DEBUG_TEAM_CREATION | B_TEAM_DEBUG_THREADS | B_TEAM_DEBUG_IMAGES; // TODO: We probably don't need all events haiku_send_debugger_message(&sTeamDebugInfo, B_DEBUG_MESSAGE_SET_TEAM_FLAGS, &message, sizeof(message), NULL, 0); } // the fun can start: push the target and init the rest push_target(sHaikuTarget); haiku_init_thread_list(&sTeamDebugInfo); haiku_init_image_list(&sTeamDebugInfo); disable_breakpoints_in_shlibs (1); // child_clear_solibs (); // TODO: Implement? Do we need this? clear_proceed_status (); init_wait_for_inferior (); target_terminal_init (); target_terminal_inferior (); }