OSDN Git Service

track shared library events even on gdb < 7
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Tue, 10 Nov 2009 11:40:23 +0000 (12:40 +0100)
committercon <qtc-committer@nokia.com>
Tue, 10 Nov 2009 13:01:19 +0000 (14:01 +0100)
this is to update breakpoint, source and module lists automatically.

also remove the now pointless -break-list on every stop.

Reviewed-by: hjk
(cherry picked from commit cb4b13914826f3e508428a3b91fb8238514de54e)

src/plugins/debugger/gdb/gdbengine.cpp

index ccdad00..fd18c57 100644 (file)
@@ -1153,6 +1153,33 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
     }
     setState(InferiorStopped);
 
+    // Due to LD_PRELOADing the dumpers, these events can occur even before
+    // reaching the entry point. So handle it before the entry point hacks below.
+    if (reason.isEmpty() && m_gdbVersion < 70000 && !m_isMacGdb) {
+        // On Linux it reports "Stopped due to shared library event\n", but
+        // on Windows it simply forgets about it. Thus, we identify the response
+        // based on it having no frame information.
+        if (!data.findChild("frame").isValid()) {
+            m_modulesListOutdated = m_sourcesListOutdated = true;
+            // Each stop causes a roundtrip and button flicker, so prevent
+            // a flood of useless stops. Will be automatically re-enabled.
+            postCommand(_("set stop-on-solib-events 0"));
+#if 0
+            // The related code (handleAqcuiredInferior()) is disabled as well.
+            if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) {
+                QString dataStr = _(data.toString());
+                debugMessage(_("SHARED LIBRARY EVENT: ") + dataStr);
+                QString pat = theDebuggerStringSetting(SelectedPluginBreakpointsPattern);
+                debugMessage(_("PATTERN: ") + pat);
+                postCommand(_("sharedlibrary ") + pat);
+                showStatusMessage(tr("Loading %1...").arg(dataStr));
+            }
+#endif
+            continueInferiorInternal();
+            return;
+        }
+    }
+
 #ifdef Q_OS_LINUX
     if (!m_entryPoint.isEmpty()) {
         GdbMi frameData = data.findChild("frame");
@@ -1178,27 +1205,6 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
     }
 #endif
 
-#if 0
-    // The related code (handleAqcuiredInferior()) is disabled as well.
-    // When re-enabling, try something to avoid spurious source list updates
-    // due to unrelated no-reason stops.
-    const QByteArray &msg = data.findChild("consolestreamoutput").data();
-    if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) {
-        m_modulesListOutdated = m_sourcesListOutdated = true;
-        if (theDebuggerBoolSetting(SelectedPluginBreakpoints)) {
-            QString dataStr = _(data.toString());
-            debugMessage(_("SHARED LIBRARY EVENT: ") + dataStr);
-            QString pat = theDebuggerStringSetting(SelectedPluginBreakpointsPattern);
-            debugMessage(_("PATTERN: ") + pat);
-            postCommand(_("sharedlibrary ") + pat);
-            continueInferiorInternal();
-            showStatusMessage(tr("Loading %1...").arg(dataStr));
-            return;
-        }
-        // fall through
-    }
-#endif
-
     // seen on XP after removing a breakpoint while running
     //  >945*stopped,reason="signal-received",signal-name="SIGTRAP",
     //  signal-meaning="Trace/breakpoint trap",thread-id="2",
@@ -1269,11 +1275,6 @@ void GdbEngine::handleStop1(const GdbMi &data)
     if (m_sourcesListOutdated)
         reloadSourceFilesInternal(); // This needs to be done before fullName() may need it
 
-    // Older gdb versions do not produce "library loaded" messages
-    // so the breakpoint update is not triggered.
-    if (m_gdbVersion < 70000 && !m_isMacGdb)
-        postCommand(_("-break-list"), CB(handleBreakList));
-
     QByteArray reason = data.findChild("reason").data();
     if (reason == "breakpoint-hit") {
         showStatusMessage(tr("Stopped at breakpoint."));
@@ -2249,6 +2250,8 @@ void GdbEngine::reloadModulesInternal()
 {
     m_modulesListOutdated = false;
     postCommand(_("info shared"), NeedsStop, CB(handleModulesList));
+    if (m_gdbVersion < 70000 && !m_isMacGdb)
+        postCommand(_("set stop-on-solib-events 1"));
 }
 
 void GdbEngine::handleModulesList(const GdbResponse &response)
@@ -2317,6 +2320,8 @@ void GdbEngine::reloadSourceFilesInternal()
     m_sourcesListOutdated = false;
     postCommand(_("-file-list-exec-source-files"), NeedsStop, CB(handleQuerySources));
     postCommand(_("-break-list"), CB(handleBreakList));
+    if (m_gdbVersion < 70000 && !m_isMacGdb)
+        postCommand(_("set stop-on-solib-events 1"));
 }