void workerThread (State *s) { taskID work; watchList *tasksToNotify, next; bool canQueue; do { task = getWork(dispatch); /* Do stuff */ atomicWrite(status[work] = INPROGRESS); doStuff(work); atomicWrite(status[work] = DONE); /* NOTE : Race condition */ tasksToNotify = getWatches(work); while (tasksToNotify != NULL) { next = tasksToNotify->tail; canQueue = TRUE; foreach (dep in dep[tasksToNotify->id]) { /* OPT : Watch ordering */ if (atomicRead(status[dep]) != DONE) { /* NOTE : Race condition */ if (moveWatch(watch[dep],tasksToNotify)) { canQueue = FALSE; break; } else { /* Have hit the race condition, try the next option */ assert(atomicRead(status[dep]) == DONE); } } } if (canQueue) { /* OPT : Save one work item */ addWork(*dispatch,tasksToNotify->id); deleteWatch(tasksToNotify); } tasksToNotify = next; } } while (1); /* NOTE : some kind of control for thread exit needed */ return; }
DebuggerMainWnd::DebuggerMainWnd() : KXmlGuiWindow(), m_debugger(0), #ifdef GDB_TRANSCRIPT m_transcriptFile(GDB_TRANSCRIPT), #endif m_outputTermCmdStr(defaultTermCmdStr), m_outputTermProc(new QProcess), m_ttyLevel(-1), /* no tty yet */ m_popForeground(false), m_backTimeout(1000), m_tabWidth(0), m_sourceFilter(defaultSourceFilter), m_headerFilter(defaultHeaderFilter), m_animation(0), m_statusActive(i18n("active")) { setDockNestingEnabled(true); m_filesWindow = new WinStack(this); setCentralWidget(m_filesWindow); QDockWidget* dw1 = createDockWidget("Stack", i18n("Stack")); m_btWindow = new QListWidget(dw1); dw1->setWidget(m_btWindow); QDockWidget* dw2 = createDockWidget("Locals", i18n("Locals")); m_localVariables = new ExprWnd(dw2, i18n("Variable")); dw2->setWidget(m_localVariables); QDockWidget* dw3 = createDockWidget("Watches", i18n("Watches")); m_watches = new WatchWindow(dw3); dw3->setWidget(m_watches); QDockWidget* dw4 = createDockWidget("Registers", i18n("Registers")); m_registers = new RegisterView(dw4); dw4->setWidget(m_registers); QDockWidget* dw5 = createDockWidget("Breakpoints", i18n("Breakpoints")); m_bpTable = new BreakpointTable(dw5); dw5->setWidget(m_bpTable); QDockWidget* dw6 = createDockWidget("Output", i18n("Output")); m_ttyWindow = new TTYWindow(dw6); dw6->setWidget(m_ttyWindow); QDockWidget* dw7 = createDockWidget("Threads", i18n("Threads")); m_threads = new ThreadList(dw7); dw7->setWidget(m_threads); QDockWidget* dw8 = createDockWidget("Memory", i18n("Memory")); m_memoryWindow = new MemoryWindow(dw8); dw8->setWidget(m_memoryWindow); m_debugger = new KDebugger(this, m_localVariables, m_watches->watchVariables(), m_btWindow); connect(m_debugger, SIGNAL(updateStatusMessage()), SLOT(slotNewStatusMsg())); connect(m_debugger, SIGNAL(updateUI()), SLOT(updateUI())); connect(m_debugger, SIGNAL(breakpointsChanged()), SLOT(updateLineItems())); connect(m_debugger, SIGNAL(debuggerStarting()), SLOT(slotDebuggerStarting())); m_bpTable->setDebugger(m_debugger); m_memoryWindow->setDebugger(m_debugger); setStandardToolBarMenuEnabled(true); initKAction(); initStatusBar(); connect(m_watches, SIGNAL(addWatch()), SLOT(slotAddWatch())); connect(m_watches, SIGNAL(deleteWatch()), m_debugger, SLOT(slotDeleteWatch())); connect(m_watches, SIGNAL(textDropped(const QString&)), SLOT(slotAddWatch(const QString&))); connect(&m_filesWindow->m_findDlg, SIGNAL(closed()), SLOT(updateUI())); connect(m_filesWindow, SIGNAL(newFileLoaded()), SLOT(slotNewFileLoaded())); connect(m_filesWindow, SIGNAL(toggleBreak(const QString&,int,const DbgAddr&,bool)), this, SLOT(slotToggleBreak(const QString&,int,const DbgAddr&,bool))); connect(m_filesWindow, SIGNAL(enadisBreak(const QString&,int,const DbgAddr&)), this, SLOT(slotEnaDisBreak(const QString&,int,const DbgAddr&))); connect(m_debugger, SIGNAL(activateFileLine(const QString&,int,const DbgAddr&)), m_filesWindow, SLOT(activate(const QString&,int,const DbgAddr&))); connect(m_debugger, SIGNAL(executableUpdated()), m_filesWindow, SLOT(reloadAllFiles())); connect(m_debugger, SIGNAL(updatePC(const QString&,int,const DbgAddr&,int)), m_filesWindow, SLOT(updatePC(const QString&,int,const DbgAddr&,int))); // value popup communication connect(m_filesWindow, SIGNAL(initiateValuePopup(const QString&)), m_debugger, SLOT(slotValuePopup(const QString&))); connect(m_debugger, SIGNAL(valuePopup(const QString&)), m_filesWindow, SLOT(slotShowValueTip(const QString&))); // disassembling connect(m_filesWindow, SIGNAL(disassemble(const QString&, int)), m_debugger, SLOT(slotDisassemble(const QString&, int))); connect(m_debugger, SIGNAL(disassembled(const QString&,int,const std::list<DisassembledCode>&)), m_filesWindow, SLOT(slotDisassembled(const QString&,int,const std::list<DisassembledCode>&))); connect(m_filesWindow, SIGNAL(moveProgramCounter(const QString&,int,const DbgAddr&)), m_debugger, SLOT(setProgramCounter(const QString&,int,const DbgAddr&))); // program stopped connect(m_debugger, SIGNAL(programStopped()), SLOT(slotProgramStopped())); connect(&m_backTimer, SIGNAL(timeout()), SLOT(slotBackTimer())); // tab width connect(this, SIGNAL(setTabWidth(int)), m_filesWindow, SIGNAL(setTabWidth(int))); // connect breakpoint table connect(m_bpTable, SIGNAL(activateFileLine(const QString&,int,const DbgAddr&)), m_filesWindow, SLOT(activate(const QString&,int,const DbgAddr&))); connect(m_debugger, SIGNAL(updateUI()), m_bpTable, SLOT(updateUI())); connect(m_debugger, SIGNAL(breakpointsChanged()), m_bpTable, SLOT(updateBreakList())); connect(m_debugger, SIGNAL(breakpointsChanged()), m_bpTable, SLOT(updateUI())); connect(m_debugger, SIGNAL(registersChanged(const std::list<RegisterInfo>&)), m_registers, SLOT(updateRegisters(const std::list<RegisterInfo>&))); connect(m_debugger, SIGNAL(memoryDumpChanged(const QString&, const std::list<MemoryDump>&)), m_memoryWindow, SLOT(slotNewMemoryDump(const QString&, const std::list<MemoryDump>&))); connect(m_debugger, SIGNAL(saveProgramSpecific(KConfigBase*)), m_memoryWindow, SLOT(saveProgramSpecific(KConfigBase*))); connect(m_debugger, SIGNAL(restoreProgramSpecific(KConfigBase*)), m_memoryWindow, SLOT(restoreProgramSpecific(KConfigBase*))); // thread window connect(m_debugger, SIGNAL(threadsChanged(const std::list<ThreadInfo>&)), m_threads, SLOT(updateThreads(const std::list<ThreadInfo>&))); connect(m_threads, SIGNAL(setThread(int)), m_debugger, SLOT(setThread(int))); // popup menu of the local variables window m_localVariables->setContextMenuPolicy(Qt::CustomContextMenu); connect(m_localVariables, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotLocalsPopup(const QPoint&))); makeDefaultLayout(); setupGUI(KXmlGuiWindow::Default, "kdbgui.rc"); restoreSettings(KGlobal::config()); // The animation button is not part of the restored window state. // We must create it after the toolbar was loaded. initAnimation(); updateUI(); m_bpTable->updateUI(); }