From 73e9c5790bcd34b9053e63cf78999ed175e7d33d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Thu, 17 Feb 2011 13:00:11 +0100 Subject: [PATCH] Debugger: Change UseFullPath setting to an enumeration. Introducing EngineDefault such that CDB/LLDB can use full paths by default and gdb can use short paths. Reviewed-by: hjk --- src/plugins/debugger/breakhandler.cpp | 8 ++--- src/plugins/debugger/breakhandler.h | 4 +-- src/plugins/debugger/breakpoint.cpp | 6 ++-- src/plugins/debugger/breakpoint.h | 10 +++++- src/plugins/debugger/breakpoint.ui | 32 ++++++++++++++------ src/plugins/debugger/breakwindow.cpp | 19 +++++++++--- src/plugins/debugger/cdb/cdbparsehelpers.cpp | 7 ++++- src/plugins/debugger/debuggerstreamops.cpp | 4 +-- src/plugins/debugger/gdb/gdbengine.cpp | 2 +- 9 files changed, 64 insertions(+), 28 deletions(-) diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 038bdc16d59..e46c934b711 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -270,8 +270,8 @@ void BreakHandler::saveBreakpoints() map.insert(_("threadspec"), data.threadSpec); if (!data.enabled) map.insert(_("disabled"), one); - if (data.useFullPath) - map.insert(_("usefullpath"), one); + if (data.pathUsage != BreakpointPathUsageEngineDefault) + map.insert(_("usefullpath"), QString::number(data.pathUsage)); if (data.tracepoint) map.insert(_("tracepoint"), one); if (!data.module.isEmpty()) @@ -320,7 +320,7 @@ void BreakHandler::loadBreakpoints() data.enabled = !v.toInt(); v = map.value(_("usefullpath")); if (v.isValid()) - data.useFullPath = bool(v.toInt()); + data.pathUsage = static_cast<BreakpointPathUsage>(v.toInt()); v = map.value(_("tracepoint")); if (v.isValid()) data.tracepoint = bool(v.toInt()); @@ -585,7 +585,7 @@ void BreakHandler::setter(BreakpointId id, const type &value) \ SETTER(type, getter, setter) -PROPERTY(bool, useFullPath, setUseFullPath) +PROPERTY(BreakpointPathUsage, pathUsage, setPathUsage) PROPERTY(QString, fileName, setFileName) PROPERTY(QString, functionName, setFunctionName) PROPERTY(BreakpointType, type, setType) diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h index 34dbd26e97a..4c191953a71 100644 --- a/src/plugins/debugger/breakhandler.h +++ b/src/plugins/debugger/breakhandler.h @@ -106,8 +106,8 @@ public: // Getter retrieves property value. // Setter sets property value and triggers update if changed. - bool useFullPath(BreakpointId id) const; - void setUseFullPath(BreakpointId, const bool &on); + BreakpointPathUsage pathUsage(BreakpointId id) const; + void setPathUsage(BreakpointId, const BreakpointPathUsage &u); QByteArray condition(BreakpointId id) const; void setCondition(BreakpointId, const QByteArray &condition); int ignoreCount(BreakpointId id) const; diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index 06331dc8eef..7dd21a7bc87 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -52,7 +52,7 @@ namespace Internal { */ BreakpointParameters::BreakpointParameters(BreakpointType t) - : type(t), enabled(true), useFullPath(false), + : type(t), enabled(true), pathUsage(BreakpointPathUsageEngineDefault), ignoreCount(0), lineNumber(0), address(0), threadSpec(-1), tracepoint(false) {} @@ -61,7 +61,7 @@ bool BreakpointParameters::equals(const BreakpointParameters &rhs) const { return type == rhs.type && enabled == rhs.enabled - && useFullPath == rhs.useFullPath + && pathUsage == rhs.pathUsage && fileName == rhs.fileName && conditionsMatch(rhs.condition) && ignoreCount == rhs.ignoreCount @@ -94,7 +94,7 @@ QString BreakpointParameters::toString() const ts << " LineNumber: " << lineNumber; ts << " Address: " << address; ts << " FunctionName: " << functionName; - ts << " UseFullPath: " << useFullPath; + ts << " PathUsage: " << pathUsage; ts << " Tracepoint: " << tracepoint; ts << " Module: " << module; ts << " Command: " << command; diff --git a/src/plugins/debugger/breakpoint.h b/src/plugins/debugger/breakpoint.h index a477e90b011..722adbacc50 100644 --- a/src/plugins/debugger/breakpoint.h +++ b/src/plugins/debugger/breakpoint.h @@ -76,6 +76,14 @@ enum BreakpointState BreakpointDead }; +//! \enum Debugger::Internal::BreakpointPathUsage +enum BreakpointPathUsage +{ + BreakpointPathUsageEngineDefault, //!< Default value that suits the engine. + BreakpointUseFullPath, //!< Use full path to avoid ambiguities. Slow with gdb. + BreakpointUseShortPath //!< Use filename only, in case source files are relocated. +}; + class BreakpointParameters { public: @@ -93,7 +101,7 @@ public: BreakpointType type; //!< Type of breakpoint. bool enabled; //!< Should we talk to the debugger engine? - bool useFullPath; //!< Should we use the full path when setting the bp? + BreakpointPathUsage pathUsage; //!< Should we use the full path when setting the bp? QString fileName; //!< Short name of source file. QByteArray condition; //!< Condition associated with breakpoint. int ignoreCount; //!< Ignore count associated with breakpoint. diff --git a/src/plugins/debugger/breakpoint.ui b/src/plugins/debugger/breakpoint.ui index 92dd5295c76..bbda2e2815c 100644 --- a/src/plugins/debugger/breakpoint.ui +++ b/src/plugins/debugger/breakpoint.ui @@ -136,17 +136,10 @@ <item row="1" column="0"> <widget class="QLabel" name="labelUseFullPath"> <property name="text"> - <string>&Use full path:</string> + <string>Pat&h:</string> </property> <property name="buddy"> - <cstring>checkBoxUseFullPath</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QCheckBox" name="checkBoxUseFullPath"> - <property name="text"> - <string/> + <cstring>comboBoxPathUsage</cstring> </property> </widget> </item> @@ -176,6 +169,25 @@ <item row="3" column="1"> <widget class="QLineEdit" name="lineEditCommand"/> </item> + <item row="1" column="1"> + <widget class="QComboBox" name="comboBoxPathUsage"> + <item> + <property name="text"> + <string>Use Engine Default</string> + </property> + </item> + <item> + <property name="text"> + <string>Use Full Path</string> + </property> + </item> + <item> + <property name="text"> + <string>Use File Name</string> + </property> + </item> + </widget> + </item> </layout> </item> <item> @@ -212,7 +224,7 @@ <item row="2" column="0"> <widget class="QLabel" name="labelThreadSpec"> <property name="text"> - <string>T&hread specification:</string> + <string>&Thread specification:</string> </property> <property name="buddy"> <cstring>lineEditThreadSpec</cstring> diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 88d0e99ee59..cf8b2beaa7f 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -140,6 +140,17 @@ BreakpointDialog::BreakpointDialog(unsigned engineCapabilities, QWidget *parent) m_ui.labelCommand->setToolTip(commandToolTip); m_ui.spinBoxIgnoreCount->setMinimum(0); m_ui.spinBoxIgnoreCount->setMaximum(2147483647); + const QString pathToolTip = + tr("<html><head/><body><p>Determines how the path is specified when setting breakpoints:</p><ul>" + "<li><i>Use Engine Default</i>: Preferred setting of the debugger engine.</li>" + "<li><i>Use Full Path</i>: Pass full path, avoiding ambiguities should files of the same " + "name exist in several modules. This is the engine default for CDB and LLDB.</li>" + "<li><i>Use File Name</i>: Pass the file name only. This is useful " + "when using a source tree whose location does not match the one used when building the modules. " + "It is the engine default for gdb as using full paths can be slow with this engine.</li>" + "</ul></body></html>"); + m_ui.labelUseFullPath->setToolTip(pathToolTip); + m_ui.comboBoxPathUsage->setToolTip(pathToolTip); } void BreakpointDialog::setType(BreakpointType type) @@ -180,7 +191,7 @@ void BreakpointDialog::setPartsEnabled(unsigned partsMask) m_ui.labelLineNumber->setEnabled(partsMask & FileAndLinePart); m_ui.lineEditLineNumber->setEnabled(partsMask & FileAndLinePart); m_ui.labelUseFullPath->setEnabled(partsMask & FileAndLinePart); - m_ui.checkBoxUseFullPath->setEnabled(partsMask & FileAndLinePart); + m_ui.comboBoxPathUsage->setEnabled(partsMask & FileAndLinePart); m_ui.labelFunction->setEnabled(partsMask & FunctionPart); m_ui.lineEditFunction->setEnabled(partsMask & FunctionPart); @@ -205,7 +216,7 @@ void BreakpointDialog::clearOtherParts(unsigned partsMask) if (invertedPartsMask & FileAndLinePart) { m_ui.pathChooserFileName->setPath(QString()); m_ui.lineEditLineNumber->clear(); - m_ui.checkBoxUseFullPath->setChecked(false); + m_ui.comboBoxPathUsage->setCurrentIndex(BreakpointPathUsageEngineDefault); } if (invertedPartsMask & FunctionPart) @@ -232,7 +243,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data) if (partsMask & FileAndLinePart) { data->lineNumber = m_ui.lineEditLineNumber->text().toInt(); - data->useFullPath = m_ui.checkBoxUseFullPath->isChecked(); + data->pathUsage = static_cast<BreakpointPathUsage>(m_ui.comboBoxPathUsage->currentIndex()); data->fileName = m_ui.pathChooserFileName->path(); } if (partsMask & FunctionPart) @@ -255,7 +266,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data) void BreakpointDialog::setParts(unsigned mask, const BreakpointParameters &data) { m_ui.checkBoxEnabled->setChecked(data.enabled); - m_ui.checkBoxUseFullPath->setChecked(data.useFullPath); + m_ui.comboBoxPathUsage->setCurrentIndex(data.pathUsage); m_ui.lineEditCommand->setText(data.command); if (mask & FileAndLinePart) { diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index f6236e3d0fa..5e3c7b07399 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -97,7 +97,12 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, str << '`'; if (!bp.module.isEmpty()) str << bp.module << '!'; - str << QDir::toNativeSeparators(bp.fileName) << ':' << bp.lineNumber << '`'; + if (bp.pathUsage == BreakpointUseShortPath) { + str << QFileInfo(bp.fileName).fileName(); + } else { + str << QDir::toNativeSeparators(bp.fileName); + } + str << ':' << bp.lineNumber << '`'; break; case Watchpoint: str << "rw 1 " << hex << hexPrefixOn << bp.address << hexPrefixOff << dec; diff --git a/src/plugins/debugger/debuggerstreamops.cpp b/src/plugins/debugger/debuggerstreamops.cpp index d95f592b882..75cab5badff 100644 --- a/src/plugins/debugger/debuggerstreamops.cpp +++ b/src/plugins/debugger/debuggerstreamops.cpp @@ -184,7 +184,7 @@ QDataStream &operator<<(QDataStream &stream, const BreakpointParameters &s) stream << quint64(s.lineNumber); stream << quint64(s.address); stream << s.functionName; - stream << s.useFullPath; + stream << int(s.pathUsage); stream << s.tracepoint; stream << s.module; stream << s.command; @@ -203,7 +203,7 @@ QDataStream &operator>>(QDataStream &stream, BreakpointParameters &s) stream >> t; s.lineNumber = t; stream >> t; s.address = t; stream >> str; s.functionName = str; - stream >> b; s.useFullPath = b; + stream >> t; s.pathUsage = static_cast<BreakpointPathUsage>(t); stream >> b; s.tracepoint = b; stream >> str ; s.module = str; stream >> str ; s.command = str; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index b95ecb5e2b0..8f3a66cfa4b 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2251,7 +2251,7 @@ QByteArray GdbEngine::breakpointLocation(BreakpointId id) if (data.type == BreakpointByAddress) return addressSpec(data.address); - const QString fileName = data.useFullPath + const QString fileName = data.pathUsage == 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. -- GitLab