diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index cc1b5e45fef92162eb328379397e9d53bb0eb46c..c1a3b2d7672af0ec22a18e96076d217e43645024 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -1362,6 +1362,10 @@ void DebuggerEngine::setState(DebuggerState state, bool forced) if (!forced && !isAllowedTransition(oldState, state)) qDebug() << "UNEXPECTED STATE TRANSITION: " << msg; + const bool running = d->m_state == InferiorRunOk; + if (running) + threadsHandler()->notifyRunning(); + showMessage(msg, LogDebug); plugin()->updateState(this); } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 1db8857ab97ac9d6183f344802ffb3b5b2f7e86f..654d7071d78880cb8d1cc9c62ecc01397e8ccf4d 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -51,10 +51,11 @@ #include "threadswindow.h" #include "watchwindow.h" -#include "watchutils.h" #include "breakhandler.h" -#include "snapshothandler.h" #include "sessionengine.h" +#include "snapshothandler.h" +#include "threadshandler.h" +#include "watchutils.h" #ifdef Q_OS_WIN # include "shared/peutils.h" @@ -2136,6 +2137,9 @@ void DebuggerPluginPrivate::setInitialState() void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) { + //m_threadBox->setModel(engine->threadsModel()); + //m_threadBox->setModel(engine->threadsModel()); + m_threadBox->setCurrentIndex(engine->threadsHandler()->currentThread()); m_watchersWindow->setVisible( m_watchersWindow->model()->rowCount(QModelIndex()) > 0); m_returnWindow->setVisible( @@ -2192,16 +2196,11 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) || m_state == InferiorUnrunnable; const bool running = m_state == InferiorRunOk; -// FIXME ABC -// if (running) -// threadsHandler()->notifyRunning(); const bool stopped = m_state == InferiorStopOk; if (stopped) QApplication::alert(mainWindow(), 3000); - //qDebug() << "FLAGS: " << stoppable << running << stopped; - m_actions.watchAction1->setEnabled(true); m_actions.watchAction2->setEnabled(true); m_actions.breakAction->setEnabled(true); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index c222351100c1dd60123feaffbadda19621803e68..197b7db047cdc4b6f90df213902447f8b9cebf7d 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2913,8 +2913,10 @@ void GdbEngine::handleThreadInfo(const GdbResponse &response) threads.append(thread); } threadsHandler()->setThreads(threads); - const int currentThreadId = response.data.findChild("current-thread-id").data().toInt(); + const int currentThreadId = + response.data.findChild("current-thread-id").data().toInt(); threadsHandler()->setCurrentThreadId(currentThreadId); + plugin()->updateState(this); // Adjust Threads combobox. } else { // Fall back for older versions: Try to get at least a list // of running threads. diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index 8eedbbf60e08771f1841b58c2c6e18893715fa0e..9092e099a4ae9d1a8f16328eac667806398a886e 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -32,6 +32,7 @@ #include "debuggerconstants.h" #include "debuggerengine.h" +#include <QtCore/QDebug> #include <QtCore/QTextStream> namespace Debugger { @@ -59,21 +60,6 @@ void ThreadData::notifyRunning() lineNumber = -1; } - -int id; -QString targetId; -QString core; - -// State information when stopped -void notifyRunning(); // Clear state information - -int frameLevel; -quint64 address; -QString function; -QString fileName; -QString state; -int lineNumber; - static inline QString threadToolTip(const ThreadData &thread) { const char tableRowStartC[] = "<tr><td>"; @@ -94,7 +80,7 @@ static inline QString threadToolTip(const ThreadData &thread) str << tableRowStartC << ThreadsHandler::tr("Core:") << tableRowSeparatorC << thread.core << tableRowEndC; - if (thread.address) { + if (thread.address) { str << tableRowStartC << ThreadsHandler::tr("Stopped at:") << tableRowSeparatorC; if (!thread.function.isEmpty()) @@ -166,7 +152,8 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const } case Qt::ToolTipRole: return threadToolTip(thread); - case Qt::DecorationRole: // Return icon that indicates whether this is the active stack frame + case Qt::DecorationRole: + // Return icon that indicates whether this is the active stack frame if (index.column() == 0) return (index.row() == m_currentIndex) ? m_positionIcon : m_emptyIcon; break; @@ -256,8 +243,8 @@ void ThreadsHandler::setThreads(const Threads &threads) { m_threads = threads; if (m_currentIndex >= m_threads.size()) - m_currentIndex = m_threads.size() - 1; - reset(); + m_currentIndex = -1; + layoutChanged(); } Threads ThreadsHandler::threads() const @@ -269,7 +256,7 @@ void ThreadsHandler::removeAll() { m_threads.clear(); m_currentIndex = 0; - reset(); + layoutChanged(); } void ThreadsHandler::notifyRunning() diff --git a/src/plugins/debugger/threadshandler.h b/src/plugins/debugger/threadshandler.h index eaed8e1f3394fc8a349d019cb4d36791a59a9d67..c237c1ccd561fe6a28660d034231dd4274fcf92c 100644 --- a/src/plugins/debugger/threadshandler.h +++ b/src/plugins/debugger/threadshandler.h @@ -96,9 +96,10 @@ class ThreadsHandler : public QAbstractTableModel public: explicit ThreadsHandler(DebuggerEngine *engine); + int currentThread() const { return m_currentIndex; } + void setCurrentThread(int index); int currentThreadId() const; void setCurrentThreadId(int id); - void setCurrentThread(int index); int indexOf(int threadId) const; void selectThread(int index); diff --git a/tests/manual/gdbdebugger/simple/app.cpp b/tests/manual/gdbdebugger/simple/app.cpp index 939f34a4887de094dc861a68bea4deb3f26b57a7..1a4675d8247123982bf849e67e4a49a227c1b10c 100644 --- a/tests/manual/gdbdebugger/simple/app.cpp +++ b/tests/manual/gdbdebugger/simple/app.cpp @@ -1347,6 +1347,9 @@ public: //sleep(1); std::cerr << m_id; } + if (m_id == 2) { + ++j; + } std::cerr << j; } @@ -1937,7 +1940,7 @@ int main(int argc, char *argv[]) # endif testQStringList(); testStruct(); - // testQThread(); + //testQThread(); testQVariant1(); testQVariant2(); testQVariant3();