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
This commit is contained in:
Friedemann Kleint
2011-02-17 13:00:11 +01:00
parent faa4d4fc69
commit 73e9c5790b
9 changed files with 64 additions and 28 deletions

View File

@@ -270,8 +270,8 @@ void BreakHandler::saveBreakpoints()
map.insert(_("threadspec"), data.threadSpec); map.insert(_("threadspec"), data.threadSpec);
if (!data.enabled) if (!data.enabled)
map.insert(_("disabled"), one); map.insert(_("disabled"), one);
if (data.useFullPath) if (data.pathUsage != BreakpointPathUsageEngineDefault)
map.insert(_("usefullpath"), one); map.insert(_("usefullpath"), QString::number(data.pathUsage));
if (data.tracepoint) if (data.tracepoint)
map.insert(_("tracepoint"), one); map.insert(_("tracepoint"), one);
if (!data.module.isEmpty()) if (!data.module.isEmpty())
@@ -320,7 +320,7 @@ void BreakHandler::loadBreakpoints()
data.enabled = !v.toInt(); data.enabled = !v.toInt();
v = map.value(_("usefullpath")); v = map.value(_("usefullpath"));
if (v.isValid()) if (v.isValid())
data.useFullPath = bool(v.toInt()); data.pathUsage = static_cast<BreakpointPathUsage>(v.toInt());
v = map.value(_("tracepoint")); v = map.value(_("tracepoint"));
if (v.isValid()) if (v.isValid())
data.tracepoint = bool(v.toInt()); data.tracepoint = bool(v.toInt());
@@ -585,7 +585,7 @@ void BreakHandler::setter(BreakpointId id, const type &value) \
SETTER(type, getter, setter) SETTER(type, getter, setter)
PROPERTY(bool, useFullPath, setUseFullPath) PROPERTY(BreakpointPathUsage, pathUsage, setPathUsage)
PROPERTY(QString, fileName, setFileName) PROPERTY(QString, fileName, setFileName)
PROPERTY(QString, functionName, setFunctionName) PROPERTY(QString, functionName, setFunctionName)
PROPERTY(BreakpointType, type, setType) PROPERTY(BreakpointType, type, setType)

View File

@@ -106,8 +106,8 @@ public:
// Getter retrieves property value. // Getter retrieves property value.
// Setter sets property value and triggers update if changed. // Setter sets property value and triggers update if changed.
bool useFullPath(BreakpointId id) const; BreakpointPathUsage pathUsage(BreakpointId id) const;
void setUseFullPath(BreakpointId, const bool &on); void setPathUsage(BreakpointId, const BreakpointPathUsage &u);
QByteArray condition(BreakpointId id) const; QByteArray condition(BreakpointId id) const;
void setCondition(BreakpointId, const QByteArray &condition); void setCondition(BreakpointId, const QByteArray &condition);
int ignoreCount(BreakpointId id) const; int ignoreCount(BreakpointId id) const;

View File

@@ -52,7 +52,7 @@ namespace Internal {
*/ */
BreakpointParameters::BreakpointParameters(BreakpointType t) BreakpointParameters::BreakpointParameters(BreakpointType t)
: type(t), enabled(true), useFullPath(false), : type(t), enabled(true), pathUsage(BreakpointPathUsageEngineDefault),
ignoreCount(0), lineNumber(0), address(0), threadSpec(-1), ignoreCount(0), lineNumber(0), address(0), threadSpec(-1),
tracepoint(false) tracepoint(false)
{} {}
@@ -61,7 +61,7 @@ bool BreakpointParameters::equals(const BreakpointParameters &rhs) const
{ {
return type == rhs.type return type == rhs.type
&& enabled == rhs.enabled && enabled == rhs.enabled
&& useFullPath == rhs.useFullPath && pathUsage == rhs.pathUsage
&& fileName == rhs.fileName && fileName == rhs.fileName
&& conditionsMatch(rhs.condition) && conditionsMatch(rhs.condition)
&& ignoreCount == rhs.ignoreCount && ignoreCount == rhs.ignoreCount
@@ -94,7 +94,7 @@ QString BreakpointParameters::toString() const
ts << " LineNumber: " << lineNumber; ts << " LineNumber: " << lineNumber;
ts << " Address: " << address; ts << " Address: " << address;
ts << " FunctionName: " << functionName; ts << " FunctionName: " << functionName;
ts << " UseFullPath: " << useFullPath; ts << " PathUsage: " << pathUsage;
ts << " Tracepoint: " << tracepoint; ts << " Tracepoint: " << tracepoint;
ts << " Module: " << module; ts << " Module: " << module;
ts << " Command: " << command; ts << " Command: " << command;

View File

@@ -76,6 +76,14 @@ enum BreakpointState
BreakpointDead 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 class BreakpointParameters
{ {
public: public:
@@ -93,7 +101,7 @@ public:
BreakpointType type; //!< Type of breakpoint. BreakpointType type; //!< Type of breakpoint.
bool enabled; //!< Should we talk to the debugger engine? 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. QString fileName; //!< Short name of source file.
QByteArray condition; //!< Condition associated with breakpoint. QByteArray condition; //!< Condition associated with breakpoint.
int ignoreCount; //!< Ignore count associated with breakpoint. int ignoreCount; //!< Ignore count associated with breakpoint.

View File

@@ -136,17 +136,10 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelUseFullPath"> <widget class="QLabel" name="labelUseFullPath">
<property name="text"> <property name="text">
<string>&amp;Use full path:</string> <string>Pat&amp;h:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>checkBoxUseFullPath</cstring> <cstring>comboBoxPathUsage</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxUseFullPath">
<property name="text">
<string/>
</property> </property>
</widget> </widget>
</item> </item>
@@ -176,6 +169,25 @@
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="lineEditCommand"/> <widget class="QLineEdit" name="lineEditCommand"/>
</item> </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> </layout>
</item> </item>
<item> <item>
@@ -212,7 +224,7 @@
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="labelThreadSpec"> <widget class="QLabel" name="labelThreadSpec">
<property name="text"> <property name="text">
<string>T&amp;hread specification:</string> <string>&amp;Thread specification:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>lineEditThreadSpec</cstring> <cstring>lineEditThreadSpec</cstring>

View File

@@ -140,6 +140,17 @@ BreakpointDialog::BreakpointDialog(unsigned engineCapabilities, QWidget *parent)
m_ui.labelCommand->setToolTip(commandToolTip); m_ui.labelCommand->setToolTip(commandToolTip);
m_ui.spinBoxIgnoreCount->setMinimum(0); m_ui.spinBoxIgnoreCount->setMinimum(0);
m_ui.spinBoxIgnoreCount->setMaximum(2147483647); 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) void BreakpointDialog::setType(BreakpointType type)
@@ -180,7 +191,7 @@ void BreakpointDialog::setPartsEnabled(unsigned partsMask)
m_ui.labelLineNumber->setEnabled(partsMask & FileAndLinePart); m_ui.labelLineNumber->setEnabled(partsMask & FileAndLinePart);
m_ui.lineEditLineNumber->setEnabled(partsMask & FileAndLinePart); m_ui.lineEditLineNumber->setEnabled(partsMask & FileAndLinePart);
m_ui.labelUseFullPath->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.labelFunction->setEnabled(partsMask & FunctionPart);
m_ui.lineEditFunction->setEnabled(partsMask & FunctionPart); m_ui.lineEditFunction->setEnabled(partsMask & FunctionPart);
@@ -205,7 +216,7 @@ void BreakpointDialog::clearOtherParts(unsigned partsMask)
if (invertedPartsMask & FileAndLinePart) { if (invertedPartsMask & FileAndLinePart) {
m_ui.pathChooserFileName->setPath(QString()); m_ui.pathChooserFileName->setPath(QString());
m_ui.lineEditLineNumber->clear(); m_ui.lineEditLineNumber->clear();
m_ui.checkBoxUseFullPath->setChecked(false); m_ui.comboBoxPathUsage->setCurrentIndex(BreakpointPathUsageEngineDefault);
} }
if (invertedPartsMask & FunctionPart) if (invertedPartsMask & FunctionPart)
@@ -232,7 +243,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data)
if (partsMask & FileAndLinePart) { if (partsMask & FileAndLinePart) {
data->lineNumber = m_ui.lineEditLineNumber->text().toInt(); 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(); data->fileName = m_ui.pathChooserFileName->path();
} }
if (partsMask & FunctionPart) if (partsMask & FunctionPart)
@@ -255,7 +266,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data)
void BreakpointDialog::setParts(unsigned mask, const BreakpointParameters &data) void BreakpointDialog::setParts(unsigned mask, const BreakpointParameters &data)
{ {
m_ui.checkBoxEnabled->setChecked(data.enabled); m_ui.checkBoxEnabled->setChecked(data.enabled);
m_ui.checkBoxUseFullPath->setChecked(data.useFullPath); m_ui.comboBoxPathUsage->setCurrentIndex(data.pathUsage);
m_ui.lineEditCommand->setText(data.command); m_ui.lineEditCommand->setText(data.command);
if (mask & FileAndLinePart) { if (mask & FileAndLinePart) {

View File

@@ -97,7 +97,12 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn,
str << '`'; str << '`';
if (!bp.module.isEmpty()) if (!bp.module.isEmpty())
str << bp.module << '!'; 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; break;
case Watchpoint: case Watchpoint:
str << "rw 1 " << hex << hexPrefixOn << bp.address << hexPrefixOff << dec; str << "rw 1 " << hex << hexPrefixOn << bp.address << hexPrefixOff << dec;

View File

@@ -184,7 +184,7 @@ QDataStream &operator<<(QDataStream &stream, const BreakpointParameters &s)
stream << quint64(s.lineNumber); stream << quint64(s.lineNumber);
stream << quint64(s.address); stream << quint64(s.address);
stream << s.functionName; stream << s.functionName;
stream << s.useFullPath; stream << int(s.pathUsage);
stream << s.tracepoint; stream << s.tracepoint;
stream << s.module; stream << s.module;
stream << s.command; stream << s.command;
@@ -203,7 +203,7 @@ QDataStream &operator>>(QDataStream &stream, BreakpointParameters &s)
stream >> t; s.lineNumber = t; stream >> t; s.lineNumber = t;
stream >> t; s.address = t; stream >> t; s.address = t;
stream >> str; s.functionName = str; stream >> str; s.functionName = str;
stream >> b; s.useFullPath = b; stream >> t; s.pathUsage = static_cast<BreakpointPathUsage>(t);
stream >> b; s.tracepoint = b; stream >> b; s.tracepoint = b;
stream >> str ; s.module = str; stream >> str ; s.module = str;
stream >> str ; s.command = str; stream >> str ; s.command = str;

View File

@@ -2251,7 +2251,7 @@ QByteArray GdbEngine::breakpointLocation(BreakpointId id)
if (data.type == BreakpointByAddress) if (data.type == BreakpointByAddress)
return addressSpec(data.address); return addressSpec(data.address);
const QString fileName = data.useFullPath const QString fileName = data.pathUsage == BreakpointUseFullPath
? data.fileName : breakLocation(data.fileName); ? data.fileName : breakLocation(data.fileName);
// The argument is simply a C-quoted version of the argument to the // The argument is simply a C-quoted version of the argument to the
// non-MI "break" command, including the "original" quoting it wants. // non-MI "break" command, including the "original" quoting it wants.