From cb857b47a27fc20ead792cb2c389636c850f2bd1 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 10 Apr 2013 09:27:07 +0200 Subject: [PATCH] Debugger: Change default gdb engine breakpoint "path usage" to "full" Setting breakpoints by file name and line does not work robustly when using gdb, with neither the full path, nor with just the baseline. Since typically one of the options work, Creator offers a per-breakpoint choice of which approach to use. Traditionally, using the full path broke more often, so the default was "short". Lately (gdb 7.3+) using the full path seems to be more robust, so the default should be changed. Manual overriding to "short" is still possible. Change-Id: I9e857c86a63964bdacf9bebc5444ea752e5974f8 Reviewed-by: hjk Reviewed-by: Friedemann Kleint --- src/plugins/debugger/gdb/gdbengine.cpp | 26 ++++++++++++++++++++++++-- src/plugins/debugger/gdb/gdbengine.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 459d11da3db..2095f8a8642 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2480,6 +2480,8 @@ void GdbEngine::updateResponse(BreakpointResponse &response, const GdbMi &bkpt) } else if (child.hasName("pending")) { // Any content here would be interesting only if we did accept // spontaneously appearing breakpoints (user using gdb commands). + if (file.isEmpty()) + file = child.data(); response.pending = true; } else if (child.hasName("at")) { // Happens with gdb 6.4 symbianelf. @@ -2541,6 +2543,16 @@ QString GdbEngine::breakLocation(const QString &file) const return where; } +BreakpointPathUsage GdbEngine::defaultEngineBreakpointPathUsage() const +{ + // e.g. MinGW gdb 70200 (part of Nokia Qt SDK) + // fails to set breakpoints with absolute paths if + // the source path isn't canonical + if (m_gdbVersion < 70300) + return BreakpointUseShortPath; + return BreakpointUseFullPath; +} + QByteArray GdbEngine::breakpointLocation(BreakpointModelId id) { BreakHandler *handler = breakHandler(); @@ -2560,7 +2572,11 @@ QByteArray GdbEngine::breakpointLocation(BreakpointModelId id) if (data.type == BreakpointByAddress) return addressSpec(data.address); - const QString fileName = data.pathUsage == BreakpointUseFullPath + BreakpointPathUsage usage = data.pathUsage; + if (usage == BreakpointPathUsageEngineDefault) + usage = defaultEngineBreakpointPathUsage(); + + const QString fileName = usage == BreakpointUseFullPath ? data.fileName : breakLocation(data.fileName); // The argument is simply a C-quoted version of the argument to the // non-MI "break" command, including the "original" quoting it wants. @@ -2571,8 +2587,14 @@ QByteArray GdbEngine::breakpointLocation(BreakpointModelId id) QByteArray GdbEngine::breakpointLocation2(BreakpointModelId id) { BreakHandler *handler = breakHandler(); + const BreakpointParameters &data = handler->breakpointData(id); - const QString fileName = data.pathUsage == BreakpointUseFullPath + + BreakpointPathUsage usage = data.pathUsage; + if (usage == BreakpointPathUsageEngineDefault) + usage = defaultEngineBreakpointPathUsage(); + + const QString fileName = usage == BreakpointUseFullPath ? data.fileName : breakLocation(data.fileName); return GdbMi::escapeCString(fileName.toLocal8Bit()) + ':' + QByteArray::number(data.lineNumber); diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 1a4d77c580d..6d50c9f1fd7 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -456,6 +456,7 @@ private: ////////// View & Data Stuff ////////// void handleInfoLine(const GdbResponse &response); void extractDataFromInfoBreak(const QString &output, BreakpointModelId); void updateResponse(BreakpointResponse &response, const GdbMi &bkpt); + BreakpointPathUsage defaultEngineBreakpointPathUsage() const; QByteArray breakpointLocation(BreakpointModelId id); // For gdb/MI. QByteArray breakpointLocation2(BreakpointModelId id); // For gdb/CLI fallback. QString breakLocation(const QString &file) const;