forked from qt-creator/qt-creator
debugger: add more heuristics to find sources
Change-Id: I78a22b885217ed45c97b992e0d70ef3bc19d24f9 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -80,6 +80,7 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDirIterator>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
@@ -1173,7 +1174,6 @@ void GdbEngine::updateAll()
|
|||||||
void GdbEngine::handleQuerySources(const GdbResponse &response)
|
void GdbEngine::handleQuerySources(const GdbResponse &response)
|
||||||
{
|
{
|
||||||
m_sourcesListUpdating = false;
|
m_sourcesListUpdating = false;
|
||||||
m_sourcesListOutdated = false;
|
|
||||||
if (response.resultClass == GdbResultDone) {
|
if (response.resultClass == GdbResultDone) {
|
||||||
QMap<QString, QString> oldShortToFull = m_shortToFullName;
|
QMap<QString, QString> oldShortToFull = m_shortToFullName;
|
||||||
m_shortToFullName.clear();
|
m_shortToFullName.clear();
|
||||||
@@ -1182,16 +1182,17 @@ void GdbEngine::handleQuerySources(const GdbResponse &response)
|
|||||||
// fullname="/data5/dev/ide/main/bin/dumper/dumper.cpp"},
|
// fullname="/data5/dev/ide/main/bin/dumper/dumper.cpp"},
|
||||||
GdbMi files = response.data.findChild("files");
|
GdbMi files = response.data.findChild("files");
|
||||||
foreach (const GdbMi &item, files.children()) {
|
foreach (const GdbMi &item, files.children()) {
|
||||||
GdbMi fullName = item.findChild("fullname");
|
|
||||||
GdbMi fileName = item.findChild("file");
|
GdbMi fileName = item.findChild("file");
|
||||||
|
if (fileName.data().endsWith("<built-in>"))
|
||||||
|
continue;
|
||||||
|
GdbMi fullName = item.findChild("fullname");
|
||||||
QString file = QString::fromLocal8Bit(fileName.data());
|
QString file = QString::fromLocal8Bit(fileName.data());
|
||||||
|
QString full;
|
||||||
if (fullName.isValid()) {
|
if (fullName.isValid()) {
|
||||||
QString full = cleanupFullName(QString::fromLocal8Bit(fullName.data()));
|
full = cleanupFullName(QString::fromLocal8Bit(fullName.data()));
|
||||||
m_shortToFullName[file] = full;
|
|
||||||
m_fullToShortName[full] = file;
|
m_fullToShortName[full] = file;
|
||||||
} else if (fileName.isValid()) {
|
|
||||||
m_shortToFullName[file] = tr("<unknown>");
|
|
||||||
}
|
}
|
||||||
|
m_shortToFullName[file] = full;
|
||||||
}
|
}
|
||||||
if (m_shortToFullName != oldShortToFull)
|
if (m_shortToFullName != oldShortToFull)
|
||||||
sourceFilesHandler()->setSourceFiles(m_shortToFullName);
|
sourceFilesHandler()->setSourceFiles(m_shortToFullName);
|
||||||
@@ -1848,6 +1849,43 @@ QString GdbEngine::cleanupFullName(const QString &fileName)
|
|||||||
cleanFilePath.replace(0, startParameters().remoteMountPoint.length(),
|
cleanFilePath.replace(0, startParameters().remoteMountPoint.length(),
|
||||||
startParameters().localMountDir);
|
startParameters().localMountDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!debuggerCore()->boolSetting(AutoEnrichParameters))
|
||||||
|
return cleanFilePath;
|
||||||
|
|
||||||
|
const QString sysroot = startParameters().sysroot;
|
||||||
|
if (QFileInfo(cleanFilePath).isReadable())
|
||||||
|
return cleanFilePath;
|
||||||
|
if (!sysroot.isEmpty() && fileName.startsWith(QLatin1Char('/'))) {
|
||||||
|
cleanFilePath = sysroot + fileName;
|
||||||
|
if (QFileInfo(cleanFilePath).isReadable())
|
||||||
|
return cleanFilePath;
|
||||||
|
}
|
||||||
|
if (m_baseNameToFullName.isEmpty()) {
|
||||||
|
QString debugSource = sysroot + QLatin1String("/usr/src/debug");
|
||||||
|
if (QFileInfo(debugSource).isDir()) {
|
||||||
|
QDirIterator it(debugSource, QDirIterator::Subdirectories);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
QString name = it.fileName();
|
||||||
|
if (!name.startsWith(QLatin1Char('.'))) {
|
||||||
|
QString path = it.filePath();
|
||||||
|
m_baseNameToFullName.insert(name, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanFilePath.clear();
|
||||||
|
const QString base = QFileInfo(fileName).fileName();
|
||||||
|
|
||||||
|
QMap<QString, QString>::const_iterator jt = m_baseNameToFullName.find(base);
|
||||||
|
while (jt != m_baseNameToFullName.end() && jt.key() == base) {
|
||||||
|
// FIXME: Use some heuristics to find the "best" match.
|
||||||
|
return jt.value();
|
||||||
|
//++jt;
|
||||||
|
}
|
||||||
|
|
||||||
return cleanFilePath;
|
return cleanFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3374,7 +3412,6 @@ void GdbEngine::examineModules()
|
|||||||
void GdbEngine::invalidateSourcesList()
|
void GdbEngine::invalidateSourcesList()
|
||||||
{
|
{
|
||||||
m_modulesListOutdated = true;
|
m_modulesListOutdated = true;
|
||||||
m_sourcesListOutdated = true;
|
|
||||||
m_breakListOutdated = true;
|
m_breakListOutdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -584,9 +584,9 @@ private: ////////// View & Data Stuff //////////
|
|||||||
// awful hack to keep track of used files
|
// awful hack to keep track of used files
|
||||||
QMap<QString, QString> m_shortToFullName;
|
QMap<QString, QString> m_shortToFullName;
|
||||||
QMap<QString, QString> m_fullToShortName;
|
QMap<QString, QString> m_fullToShortName;
|
||||||
|
QMultiMap<QString, QString> m_baseNameToFullName;
|
||||||
|
|
||||||
void invalidateSourcesList();
|
void invalidateSourcesList();
|
||||||
bool m_sourcesListOutdated;
|
|
||||||
bool m_sourcesListUpdating;
|
bool m_sourcesListUpdating;
|
||||||
bool m_breakListOutdated;
|
bool m_breakListOutdated;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user