[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevelop/4.4] debuggers/gdb: Add Thread and Frame Information on Execution
From:       David_E._Narváez <david.narvaez () computer ! org>
Date:       2012-09-01 4:30:13
Message-ID: 20120901043013.4B168A6094 () git ! kde ! org
[Download RAW message or body]

Git commit cc8c9466675fcd022f45f81be97872a8527bb8d9 by David E. Narváez.
Committed on 01/09/2012 at 06:26.
Pushed by narvaez into branch '4.4'.

Add Thread and Frame Information on Execution

Moved the code that adds frame and thread information when not present
in the command already from the queueCmd method to the executeCmd
method and added some info at the debug strings to make clear that the
queued command will be modified upon execution. This is needed in order
to be able to queue commands whose information depend on previous
commands in the same queue.

CCBUG: 301287
REVIEW: 105210

M  +24   -9    debuggers/gdb/debugsession.cpp
M  +32   -3    debuggers/gdb/unittests/gdbtest.cpp
M  +1    -0    debuggers/gdb/unittests/gdbtest.h

http://commits.kde.org/kdevelop/cc8c9466675fcd022f45f81be97872a8527bb8d9

diff --git a/debuggers/gdb/debugsession.cpp b/debuggers/gdb/debugsession.cpp
index ed3598e..90aec94 100644
--- a/debuggers/gdb/debugsession.cpp
+++ b/debuggers/gdb/debugsession.cpp
@@ -555,6 +555,10 @@ void DebugSession::queueCmd(GDBCommand *cmd, QueuePosition \
queue_where)  if (stateReloadInProgress_)
         cmd->setStateReloading(true);
 
+    commandQueue_->enqueue(cmd, queue_where);
+
+    kDebug(9012) << "QUEUE: " << cmd->initialString() << (stateReloadInProgress_ ? \
"(state reloading)" : ""); +
     bool varCommandWithContext= (cmd->type() >= GDBMI::VarAssign
                                  && cmd->type() <= GDBMI::VarUpdate
                                  && cmd->type() != GDBMI::VarDelete);
@@ -564,20 +568,13 @@ void DebugSession::queueCmd(GDBCommand *cmd, QueuePosition \
queue_where)  
     if (varCommandWithContext || stackCommandWithContext)
     {
-        // Most var commands should be executed in the context
-        // of the selected thread and frame.
         if (cmd->thread() == -1)
-            cmd->setThread(frameStackModel()->currentThread());
+            kDebug(9012) << "\t--thread will be added on execution";
 
         if (cmd->frame() == -1)
-            cmd->setFrame(frameStackModel()->currentFrame());
+            kDebug(9012) << "\t--frame will be added on execution";
     }
 
-    commandQueue_->enqueue(cmd, queue_where);
-
-    kDebug(9012) << "QUEUE: " << cmd->initialString()
-                  << (stateReloadInProgress_ ? "(state reloading)" : "");
-
     setStateOn(s_dbgBusy);
     raiseEvent(debugger_busy);
 
@@ -595,6 +592,24 @@ bool DebugSession::executeCmd()
     if (!currentCmd)
         return false;
 
+    bool varCommandWithContext= (currentCmd->type() >= GDBMI::VarAssign
+                                 && currentCmd->type() <= GDBMI::VarUpdate
+                                 && currentCmd->type() != GDBMI::VarDelete);
+
+    bool stackCommandWithContext = (currentCmd->type() >= GDBMI::StackInfoDepth
+                                    && currentCmd->type() <= \
GDBMI::StackListLocals); +
+    if (varCommandWithContext || stackCommandWithContext)
+    {
+        // Most var commands should be executed in the context
+        // of the selected thread and frame.
+        if (currentCmd->thread() == -1)
+            currentCmd->setThread(frameStackModel()->currentThread());
+
+        if (currentCmd->frame() == -1)
+            currentCmd->setFrame(frameStackModel()->currentFrame());
+    }
+
     QString commandText = currentCmd->cmdToSend();
     bool bad_command = false;
     QString message;
diff --git a/debuggers/gdb/unittests/gdbtest.cpp \
b/debuggers/gdb/unittests/gdbtest.cpp index fc59b7b..de091b9 100644
--- a/debuggers/gdb/unittests/gdbtest.cpp
+++ b/debuggers/gdb/unittests/gdbtest.cpp
@@ -123,15 +123,22 @@ class TestFrameStackModel : public KDevelop::GdbFrameStackModel
 {
 public:
     
-    TestFrameStackModel(DebugSession* session) 
-    : GdbFrameStackModel(session), fetchFramesCalled(0) {}
-    
+    TestFrameStackModel(DebugSession* session)
+        : GdbFrameStackModel(session), fetchFramesCalled(0), fetchThreadsCalled(0) \
{} +
     int fetchFramesCalled;
+    int fetchThreadsCalled;
     virtual void fetchFrames(int threadNumber, int from, int to)
     {
         fetchFramesCalled++;
         GdbFrameStackModel::fetchFrames(threadNumber, from, to);
     }
+
+    virtual void fetchThreads()
+    {
+        fetchThreadsCalled++;
+        GdbFrameStackModel::fetchThreads();
+    }
 };
 
 class TestDebugSession : public DebugSession
@@ -1566,6 +1573,27 @@ void GdbTest::testCatchpoint()
 
 }
 
+void GdbTest::testThreadAndFrameInfo()
+{
+    TestDebugSession *session = new TestDebugSession;
+    TestLaunchConfiguration cfg(findExecutable("debugeethreads"));
+    QString fileName = findSourceFile("debugeethreads.cpp");
+    QSignalSpy outputSpy(session, SIGNAL(gdbUserCommandStdout(QString)));
+
+    breakpoints()->addCodeBreakpoint(fileName, 38);
+    QVERIFY(session->startProgram(&cfg));
+    session->frameStackModel()->fetchThreads();
+    session->addCommand(new UserCommand(GDBMI::StackListLocals, \
QLatin1String("0"))); +    WAIT_FOR_STATE(session, DebugSession::PausedState);
+    QTest::qWait(1000);
+
+    QVERIFY(outputSpy.count() == 2);
+    QVERIFY(outputSpy.last().at(0).toString().contains(QLatin1String("--thread \
1"))); +
+    session->run();
+    WAIT_FOR_STATE(session, DebugSession::EndedState);
+}
+
 void GdbTest::parseBug304730()
 {
     FileSymbol file;
@@ -1652,3 +1680,4 @@ QTEST_KDEMAIN(GDBDebugger::GdbTest, GUI)
 
 #include "gdbtest.moc"
 #include "moc_gdbtest.cpp"
+
diff --git a/debuggers/gdb/unittests/gdbtest.h b/debuggers/gdb/unittests/gdbtest.h
index a027327..930c74a 100644
--- a/debuggers/gdb/unittests/gdbtest.h
+++ b/debuggers/gdb/unittests/gdbtest.h
@@ -82,6 +82,7 @@ private Q_SLOTS:
     void testBreakpointWithSpaceInPath();
     void testBreakpointDisabledOnStart();
     void testCatchpoint();
+    void testThreadAndFrameInfo();
     void parseBug304730();
     void testMultipleLocationsBreakpoint();
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic