From 0939a7f77f06e6206c9a4eeb665d7cd5dd7118d1 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Thu, 12 Nov 2009 14:49:54 +0100
Subject: [PATCH] don't track shared library events on gdb < 7, after all.

The problem is that the shlib events disturb bounded execution requests
and there is no way to recover from this - the debugger will effectively
turn "step over" into "continue". this is nicely explained in
http://vladimir_prus.blogspot.com/2007/12/debugger-stories-pending-breakpoints.html
---
 src/plugins/debugger/gdb/gdbengine.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 9b2aa9e15d9..0d95b216dea 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -1153,6 +1153,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
     }
     setState(InferiorStopped);
 
+#if 0 // See http://vladimir_prus.blogspot.com/2007/12/debugger-stories-pending-breakpoints.html
     // 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) {
@@ -1179,6 +1180,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
             return;
         }
     }
+#endif
 
 #ifdef Q_OS_LINUX
     if (!m_entryPoint.isEmpty()) {
@@ -1272,6 +1274,12 @@ 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 && !m_sourcesListUpdating
+        && manager()->breakHandler()->size() > 0)
+        postCommand(_("-break-list"), CB(handleBreakList));
+
     QByteArray reason = data.findChild("reason").data();
     if (reason == "breakpoint-hit") {
         showStatusMessage(tr("Stopped at breakpoint."));
@@ -2247,8 +2255,10 @@ void GdbEngine::reloadModulesInternal()
 {
     m_modulesListOutdated = false;
     postCommand(_("info shared"), NeedsStop, CB(handleModulesList));
+#if 0
     if (m_gdbVersion < 70000 && !m_isMacGdb)
         postCommand(_("set stop-on-solib-events 1"));
+#endif
 }
 
 void GdbEngine::handleModulesList(const GdbResponse &response)
@@ -2317,8 +2327,10 @@ void GdbEngine::reloadSourceFilesInternal()
     m_sourcesListOutdated = false;
     postCommand(_("-file-list-exec-source-files"), NeedsStop, CB(handleQuerySources));
     postCommand(_("-break-list"), CB(handleBreakList));
+#if 0
     if (m_gdbVersion < 70000 && !m_isMacGdb)
         postCommand(_("set stop-on-solib-events 1"));
+#endif
 }
 
 
-- 
GitLab