forked from qt-creator/qt-creator
Debugger[CDB]: Do path mapping in both directions.
For breakpoints and reported stacktraces. Make mapping more precise, check for slashes.
This commit is contained in:
@@ -1147,7 +1147,7 @@ void CdbEngine::executeRunToLine(const ContextData &data)
|
|||||||
bp.fileName = data.fileName;
|
bp.fileName = data.fileName;
|
||||||
bp.lineNumber = data.lineNumber;
|
bp.lineNumber = data.lineNumber;
|
||||||
}
|
}
|
||||||
postCommand(cdbAddBreakpointCommand(bp, BreakpointId(-1), true), 0);
|
postCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointId(-1), true), 0);
|
||||||
continueInferior();
|
continueInferior();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1157,7 +1157,7 @@ void CdbEngine::executeRunToFunction(const QString &functionName)
|
|||||||
BreakpointParameters bp(BreakpointByFunction);
|
BreakpointParameters bp(BreakpointByFunction);
|
||||||
bp.functionName = functionName;
|
bp.functionName = functionName;
|
||||||
|
|
||||||
postCommand(cdbAddBreakpointCommand(bp, BreakpointId(-1), true), 0);
|
postCommand(cdbAddBreakpointCommand(bp, m_sourcePathMappings, BreakpointId(-1), true), 0);
|
||||||
continueInferior();
|
continueInferior();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2329,7 +2329,7 @@ void CdbEngine::attemptBreakpointSynchronization()
|
|||||||
}
|
}
|
||||||
switch (handler->state(id)) {
|
switch (handler->state(id)) {
|
||||||
case BreakpointInsertRequested:
|
case BreakpointInsertRequested:
|
||||||
postCommand(cdbAddBreakpointCommand(parameters, id, false), 0);
|
postCommand(cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false), 0);
|
||||||
if (!parameters.enabled)
|
if (!parameters.enabled)
|
||||||
postCommand("bd " + QByteArray::number(id), 0);
|
postCommand("bd " + QByteArray::number(id), 0);
|
||||||
handler->notifyBreakpointInsertProceeding(id);
|
handler->notifyBreakpointInsertProceeding(id);
|
||||||
@@ -2351,7 +2351,7 @@ void CdbEngine::attemptBreakpointSynchronization()
|
|||||||
// Delete and re-add, triggering update
|
// Delete and re-add, triggering update
|
||||||
addedChanged = true;
|
addedChanged = true;
|
||||||
postCommand("bc " + QByteArray::number(id), 0);
|
postCommand("bc " + QByteArray::number(id), 0);
|
||||||
postCommand(cdbAddBreakpointCommand(parameters, id, false), 0);
|
postCommand(cdbAddBreakpointCommand(parameters, m_sourcePathMappings, id, false), 0);
|
||||||
m_pendingBreakpointMap.insert(id, response);
|
m_pendingBreakpointMap.insert(id, response);
|
||||||
}
|
}
|
||||||
handler->notifyBreakpointChangeOk(id);
|
handler->notifyBreakpointChangeOk(id);
|
||||||
@@ -2384,15 +2384,8 @@ CdbEngine::NormalizedSourceFileName CdbEngine::sourceMapNormalizeFileNameFromDeb
|
|||||||
if (debugSourceMapping)
|
if (debugSourceMapping)
|
||||||
qDebug(">sourceMapNormalizeFileNameFromDebugger %s", qPrintable(f));
|
qDebug(">sourceMapNormalizeFileNameFromDebugger %s", qPrintable(f));
|
||||||
// Do we have source path mappings? ->Apply.
|
// Do we have source path mappings? ->Apply.
|
||||||
QString fileName = QDir::toNativeSeparators(f);
|
const QString fileName = cdbSourcePathMapping(QDir::toNativeSeparators(f), m_sourcePathMappings,
|
||||||
if (!m_sourcePathMappings.isEmpty()) {
|
DebuggerToSource);
|
||||||
foreach (const SourcePathMapping &m, m_sourcePathMappings) {
|
|
||||||
if (fileName.startsWith(m.first, Qt::CaseInsensitive)) {
|
|
||||||
fileName.replace(0, m.first.size(), m.second);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Up/lower case normalization according to Windows.
|
// Up/lower case normalization according to Windows.
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString normalized = winNormalizeFileName(fileName);
|
QString normalized = winNormalizeFileName(fileName);
|
||||||
|
@@ -53,8 +53,50 @@
|
|||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// Convert breakpoint in CDB syntax.
|
// Perform mapping on parts of the source tree as reported by/passed to debugger
|
||||||
|
// in case the user has specified such mappings in the global settings.
|
||||||
|
// That is, when debugging an executable built from 'X:\buildsrv\foo.cpp' and using a local
|
||||||
|
// source tree under 'c:\src', the user would specify a mapping 'X:\buildsrv'->'c:\src'
|
||||||
|
// and file names passed to breakpoints and reported stack traces can be converted.
|
||||||
|
QString cdbSourcePathMapping(QString fileName,
|
||||||
|
const QList<QPair<QString, QString> > &sourcePathMapping,
|
||||||
|
SourcePathMode mode)
|
||||||
|
{
|
||||||
|
typedef QPair<QString, QString> SourcePathMapping;
|
||||||
|
|
||||||
|
if (fileName.isEmpty() || sourcePathMapping.isEmpty())
|
||||||
|
return fileName;
|
||||||
|
foreach (const SourcePathMapping &m, sourcePathMapping) {
|
||||||
|
const QString &source = mode == DebuggerToSource ? m.first : m.second;
|
||||||
|
const int sourceSize = source.size();
|
||||||
|
// Map parts of the path and ensure a slash follows.
|
||||||
|
if (fileName.size() > sourceSize && fileName.startsWith(source, Qt::CaseInsensitive)) {
|
||||||
|
const QChar next = fileName.at(sourceSize);
|
||||||
|
if (next == QLatin1Char('\\') || next == QLatin1Char('/')) {
|
||||||
|
const QString &target = mode == DebuggerToSource ? m.second: m.first;
|
||||||
|
fileName.replace(0, sourceSize, target);
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine file name to be used for breakpoints. Convert to native and, unless short path
|
||||||
|
// is set, perform reverse lookup in the source path mappings.
|
||||||
|
static inline QString cdbBreakPointFileName(const BreakpointParameters &bp,
|
||||||
|
const QList<QPair<QString, QString> > &sourcePathMapping)
|
||||||
|
{
|
||||||
|
if (bp.fileName.isEmpty())
|
||||||
|
return bp.fileName;
|
||||||
|
if (bp.pathUsage == BreakpointUseShortPath)
|
||||||
|
return QFileInfo(bp.fileName).fileName();
|
||||||
|
return cdbSourcePathMapping(QDir::toNativeSeparators(bp.fileName), sourcePathMapping, SourceToDebugger);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert breakpoint in CDB syntax. (applying source path mappings using native paths).
|
||||||
QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn,
|
QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn,
|
||||||
|
const QList<QPair<QString, QString> > &sourcePathMapping,
|
||||||
BreakpointId id /* = BreakpointId(-1) */,
|
BreakpointId id /* = BreakpointId(-1) */,
|
||||||
bool oneshot)
|
bool oneshot)
|
||||||
{
|
{
|
||||||
@@ -97,12 +139,7 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn,
|
|||||||
str << '`';
|
str << '`';
|
||||||
if (!bp.module.isEmpty())
|
if (!bp.module.isEmpty())
|
||||||
str << bp.module << '!';
|
str << bp.module << '!';
|
||||||
if (bp.pathUsage == BreakpointUseShortPath) {
|
str << cdbBreakPointFileName(bp, sourcePathMapping) << ':' << bp.lineNumber << '`';
|
||||||
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;
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QVector>
|
#include <QtCore/QVector>
|
||||||
|
#include <QtCore/QPair>
|
||||||
#include <QtCore/QByteArray>
|
#include <QtCore/QByteArray>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -54,8 +55,17 @@ struct ThreadData;
|
|||||||
class Register;
|
class Register;
|
||||||
class GdbMi;
|
class GdbMi;
|
||||||
|
|
||||||
// Convert breakpoint in CDB syntax.
|
// Perform mapping on parts of the source tree as reported by/passed to debugger
|
||||||
QByteArray cdbAddBreakpointCommand(const BreakpointParameters &d, BreakpointId id = BreakpointId(-1), bool oneshot = false);
|
// in case the user has specified such mappings in the global settings.
|
||||||
|
enum SourcePathMode { DebuggerToSource, SourceToDebugger };
|
||||||
|
QString cdbSourcePathMapping(QString fileName,
|
||||||
|
const QList<QPair<QString, QString> > &sourcePathMapping,
|
||||||
|
SourcePathMode mode);
|
||||||
|
|
||||||
|
// Convert breakpoint in CDB syntax (applying source path mappings using native paths).
|
||||||
|
QByteArray cdbAddBreakpointCommand(const BreakpointParameters &d,
|
||||||
|
const QList<QPair<QString, QString> > &sourcePathMapping,
|
||||||
|
BreakpointId id = BreakpointId(-1), bool oneshot = false);
|
||||||
// Parse extension command listing breakpoints.
|
// Parse extension command listing breakpoints.
|
||||||
// Note that not all fields are returned, since file, line, function are encoded
|
// Note that not all fields are returned, since file, line, function are encoded
|
||||||
// in the expression (that is in addition deleted on resolving for a bp-type breakpoint).
|
// in the expression (that is in addition deleted on resolving for a bp-type breakpoint).
|
||||||
|
Reference in New Issue
Block a user