debugger: hack to specify sysroot in generic remote linux

Change-Id: I9657f71246df4742329a0b4f27bf08f146e9632a
Reviewed-on: http://codereview.qt-project.org/5534
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2011-09-26 12:38:17 +02:00
committed by hjk
parent 9cc4751857
commit 84a535bae7
4 changed files with 58 additions and 47 deletions

View File

@@ -1014,6 +1014,9 @@ public slots:
DebuggerToolTipManager *toolTipManager() const { return m_toolTipManager; } DebuggerToolTipManager *toolTipManager() const { return m_toolTipManager; }
virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; } virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; }
// FIXME: Remove.
void maybeEnrichParameters(DebuggerStartParameters *sp);
public: public:
DebuggerMainWindow *m_mainWindow; DebuggerMainWindow *m_mainWindow;
DebuggerRunControlFactory *m_debuggerRunControlFactory; DebuggerRunControlFactory *m_debuggerRunControlFactory;
@@ -1189,14 +1192,21 @@ static QString msgParameterMissing(const QString &a)
return DebuggerPlugin::tr("Option '%1' is missing the parameter.").arg(a); return DebuggerPlugin::tr("Option '%1' is missing the parameter.").arg(a);
} }
void DebuggerPluginPrivate::maybeEnrichParameters(DebuggerStartParameters *sp)
static void maybeEnrichParameters(DebuggerStartParameters *sp)
{ {
if (!theDebuggerCore->boolSetting(AutoEnrichParameters)) if (!boolSetting(AutoEnrichParameters))
return; return;
if (sp->sysroot.isEmpty() && (sp->startMode == AttachToRemoteServer
|| sp->startMode == StartRemote)) {
// FIXME: Get from BaseQtVersion
sp->sysroot = QString::fromLocal8Bit(qgetenv("QTC_DEBUGGER_SYSROOT"));
//if (sp->sysroot.isEmpty())
// sp->sysroot = debuggerCore()->configValue(_("LastSysroot")).toString();
showMessage("### USING FAKE SYSROOT ###" + sp->sysroot.toLocal8Bit(), LogWarning);
}
if (sp->debugInfoLocation.isEmpty()) if (sp->debugInfoLocation.isEmpty())
sp->debugInfoLocation = sp->sysroot + "/usr/lib/debug"; sp->debugInfoLocation = sp->sysroot + "/usr/lib/debug";
if (sp->debugSourceLocation.isEmpty()) { if (false && sp->debugSourceLocation.isEmpty()) {
QString base = sp->sysroot + "/usr/src/debug/"; QString base = sp->sysroot + "/usr/src/debug/";
sp->debugSourceLocation.append(base + "qt5base/src/corelib"); sp->debugSourceLocation.append(base + "qt5base/src/corelib");
sp->debugSourceLocation.append(base + "qt5base/src/gui"); sp->debugSourceLocation.append(base + "qt5base/src/gui");
@@ -1204,6 +1214,10 @@ static void maybeEnrichParameters(DebuggerStartParameters *sp)
sp->debugSourceLocation.append(base + "qt5base/src/v8"); sp->debugSourceLocation.append(base + "qt5base/src/v8");
sp->debugSourceLocation.append(base + "qtdeclarative/src/declarative/qml"); sp->debugSourceLocation.append(base + "qtdeclarative/src/declarative/qml");
} }
//if (sp->solibSearchPath.isEmpty()) {
// sp->solibSearchPath = sp->sysroot + "/usr/lib/debug";
// // was: QFileInfo(sp.dumperLibrary).path().toLocal8Bit();
//}
} }
bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
@@ -1486,7 +1500,6 @@ void DebuggerPluginPrivate::attachExternalApplication()
sp.startMode = AttachExternal; sp.startMode = AttachExternal;
sp.toolChainAbi = dlg.abi(); sp.toolChainAbi = dlg.abi();
sp.debuggerCommand = dlg.debuggerCommand(); sp.debuggerCommand = dlg.debuggerCommand();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
} }
@@ -1498,7 +1511,6 @@ void DebuggerPluginPrivate::attachExternalApplication(ProjectExplorer::RunContro
sp.displayName = tr("Debugger attached to %1").arg(rc->displayName()); sp.displayName = tr("Debugger attached to %1").arg(rc->displayName());
sp.startMode = AttachExternal; sp.startMode = AttachExternal;
sp.toolChainAbi = rc->abi(); sp.toolChainAbi = rc->abi();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
} }
@@ -1530,7 +1542,6 @@ void DebuggerPluginPrivate::attachCore()
sp.toolChainAbi = dlg.abi(); sp.toolChainAbi = dlg.abi();
sp.sysroot = dlg.sysroot(); sp.sysroot = dlg.sysroot();
sp.overrideStartScript = dlg.overrideStartScript(); sp.overrideStartScript = dlg.overrideStartScript();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
} }
@@ -1545,7 +1556,6 @@ void DebuggerPluginPrivate::attachRemote(const QString &spec)
sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel); sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel);
sp.startMode = AttachToRemoteServer; sp.startMode = AttachToRemoteServer;
sp.toolChainAbi = anyAbiOfBinary(sp.executable); sp.toolChainAbi = anyAbiOfBinary(sp.executable);
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp)) if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
} }
@@ -1643,7 +1653,6 @@ void DebuggerPluginPrivate::startRemoteApplication()
sp.startMode = StartRemote; sp.startMode = StartRemote;
if (!queryRemoteParameters(sp, true)) if (!queryRemoteParameters(sp, true))
return; return;
maybeEnrichParameters(&sp);
if (RunControl *rc = createDebugger(sp)) if (RunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
} }
@@ -1656,7 +1665,6 @@ void DebuggerPluginPrivate::attachRemoteApplication()
sp.startMode = AttachToRemoteServer; sp.startMode = AttachToRemoteServer;
sp.useServerStartScript = false; sp.useServerStartScript = false;
sp.serverStartScript.clear(); sp.serverStartScript.clear();
maybeEnrichParameters(&sp);
if (RunControl *rc = createDebugger(sp)) if (RunControl *rc = createDebugger(sp))
startDebugger(rc); startDebugger(rc);
} }
@@ -1926,8 +1934,10 @@ void DebuggerPluginPrivate::requestMark(ITextEditor *editor, int lineNumber)
} }
DebuggerRunControl *DebuggerPluginPrivate::createDebugger DebuggerRunControl *DebuggerPluginPrivate::createDebugger
(const DebuggerStartParameters &sp, RunConfiguration *rc) (const DebuggerStartParameters &sp0, RunConfiguration *rc)
{ {
DebuggerStartParameters sp = sp0;
maybeEnrichParameters(&sp);
return m_debuggerRunControlFactory->create(sp, rc); return m_debuggerRunControlFactory->create(sp, rc);
} }
@@ -2525,12 +2535,14 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
str << "Start parameters: '" << sp.displayName << "' mode: " << sp.startMode str << "Start parameters: '" << sp.displayName << "' mode: " << sp.startMode
<< "\nABI: " << sp.toolChainAbi.toString() << '\n'; << "\nABI: " << sp.toolChainAbi.toString() << '\n';
if (!sp.executable.isEmpty()) { if (!sp.executable.isEmpty()) {
str << "Executable: " << QDir::toNativeSeparators(sp.executable) << ' ' << sp.processArgs; str << "Executable: " << QDir::toNativeSeparators(sp.executable)
<< ' ' << sp.processArgs;
if (sp.useTerminal) if (sp.useTerminal)
str << " [terminal]"; str << " [terminal]";
str << '\n'; str << '\n';
if (!sp.workingDirectory.isEmpty()) if (!sp.workingDirectory.isEmpty())
str << "Directory: " << QDir::toNativeSeparators(sp.workingDirectory) << '\n'; str << "Directory: " << QDir::toNativeSeparators(sp.workingDirectory)
<< '\n';
if (sp.executableUid) { if (sp.executableUid) {
str << "UID: 0x"; str << "UID: 0x";
str.setIntegerBase(16); str.setIntegerBase(16);
@@ -2547,36 +2559,38 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
if (!sp.projectSourceDirectory.isEmpty()) { if (!sp.projectSourceDirectory.isEmpty()) {
str << "Project: " << QDir::toNativeSeparators(sp.projectSourceDirectory); str << "Project: " << QDir::toNativeSeparators(sp.projectSourceDirectory);
if (!sp.projectBuildDirectory.isEmpty()) if (!sp.projectBuildDirectory.isEmpty())
str << " (built: " << QDir::toNativeSeparators(sp.projectBuildDirectory) << ')'; str << " (built: " << QDir::toNativeSeparators(sp.projectBuildDirectory)
<< ')';
str << '\n'; str << '\n';
} }
if (!sp.qtInstallPath.isEmpty()) if (!sp.qtInstallPath.isEmpty())
str << "Qt: " << QDir::toNativeSeparators(sp.qtInstallPath) << '\n'; str << "Qt: " << QDir::toNativeSeparators(sp.qtInstallPath) << '\n';
if (!sp.qmlServerAddress.isEmpty()) if (!sp.qmlServerAddress.isEmpty())
str << "QML server: " << sp.qmlServerAddress << ':' << sp.qmlServerPort << '\n'; str << "QML server: " << sp.qmlServerAddress << ':'
<< sp.qmlServerPort << '\n';
if (!sp.remoteChannel.isEmpty()) { if (!sp.remoteChannel.isEmpty()) {
str << "Remote: " << sp.remoteChannel << ", " << sp.remoteArchitecture << '\n'; str << "Remote: " << sp.remoteChannel << ", "
<< sp.remoteArchitecture << '\n';
if (!sp.remoteDumperLib.isEmpty()) if (!sp.remoteDumperLib.isEmpty())
str << "Remote dumpers: " << sp.remoteDumperLib << '\n'; str << "Remote dumpers: " << sp.remoteDumperLib << '\n';
if (!sp.remoteSourcesDir.isEmpty()) if (!sp.remoteSourcesDir.isEmpty())
str << "Remote sources: " << sp.remoteSourcesDir << '\n'; str << "Remote sources: " << sp.remoteSourcesDir << '\n';
if (!sp.remoteMountPoint.isEmpty()) if (!sp.remoteMountPoint.isEmpty())
str << "Remote mount point: " << sp.remoteMountPoint << " Local: " << sp.localMountDir << '\n'; str << "Remote mount point: " << sp.remoteMountPoint
<< " Local: " << sp.localMountDir << '\n';
} }
if (!sp.gnuTarget.isEmpty()) if (!sp.gnuTarget.isEmpty())
str << "Gnu target: " << sp.gnuTarget << '\n'; str << "Gnu target: " << sp.gnuTarget << '\n';
if (!sp.sysroot.isEmpty())
str << "Sysroot: " << sp.sysroot << '\n'; str << "Sysroot: " << sp.sysroot << '\n';
if (!sp.symbolFileName.isEmpty()) str << "Solib Search Path: " << sp.solibSearchPath << '\n';
str << "Debug Source Loaction: " << sp.debugSourceLocation.join(":") << '\n';
str << "Symbol file: " << sp.symbolFileName << '\n'; str << "Symbol file: " << sp.symbolFileName << '\n';
if (sp.useServerStartScript) if (sp.useServerStartScript)
str << "Using server start script: " << sp.serverStartScript; str << "Using server start script: " << sp.serverStartScript;
if (!sp.dumperLibrary.isEmpty()) {
str << "Dumper libraries: " << QDir::toNativeSeparators(sp.dumperLibrary); str << "Dumper libraries: " << QDir::toNativeSeparators(sp.dumperLibrary);
foreach (const QString &dl, sp.dumperLibraryLocations) foreach (const QString &dl, sp.dumperLibraryLocations)
str << ' ' << QDir::toNativeSeparators(dl); str << ' ' << QDir::toNativeSeparators(dl);
str << '\n'; str << '\n';
}
return rc; return rc;
} }
@@ -2636,17 +2650,17 @@ QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType
switch (et) { switch (et) {
case CdbEngineType: case CdbEngineType:
searchAbis.clear(); searchAbis.clear();
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMsvc2010Flavor, searchAbis.push_back(Abi(abi.architecture(), abi.os(),
abi.binaryFormat(), abi.wordWidth())); Abi::WindowsMsvc2010Flavor, abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMsvc2008Flavor, searchAbis.push_back(Abi(abi.architecture(), abi.os(),
abi.binaryFormat(), abi.wordWidth())); Abi::WindowsMsvc2008Flavor, abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMsvc2005Flavor, searchAbis.push_back(Abi(abi.architecture(), abi.os(),
abi.binaryFormat(), abi.wordWidth())); Abi::WindowsMsvc2005Flavor, abi.binaryFormat(), abi.wordWidth()));
break; break;
case GdbEngineType: case GdbEngineType:
searchAbis.clear(); searchAbis.clear();
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMSysFlavor, searchAbis.push_back(Abi(abi.architecture(), abi.os(),
abi.binaryFormat(), abi.wordWidth())); Abi::WindowsMSysFlavor, abi.binaryFormat(), abi.wordWidth()));
break; break;
default: default:
break; break;
@@ -2657,7 +2671,8 @@ QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType
<< searchAbis.front().toString() << et; << searchAbis.front().toString() << et;
foreach (const Abi &searchAbi, searchAbis) { foreach (const Abi &searchAbi, searchAbis) {
const QList<ToolChain *> toolchains = ToolChainManager::instance()->findToolChains(searchAbi); const QList<ToolChain *> toolchains =
ToolChainManager::instance()->findToolChains(searchAbi);
// Find manually configured ones first // Find manually configured ones first
for (int i = toolchains.size() - 1; i >= 0; i--) { for (int i = toolchains.size() - 1; i >= 0; i--) {
const QString debugger = toolchains.at(i)->debuggerCommand(); const QString debugger = toolchains.at(i)->debuggerCommand();

View File

@@ -108,8 +108,9 @@ public:
bool useServerStartScript; bool useServerStartScript;
QString serverStartScript; QString serverStartScript;
QString sysroot; QString sysroot;
QString debugInfoLocation; QString debugInfoLocation; // Gdb "set-debug-file-directory".
QStringList debugSourceLocation; QString solibSearchPath; // Gdb "set solib-search-path".
QStringList debugSourceLocation; // Gdb "directory"
QByteArray remoteDumperLib; QByteArray remoteDumperLib;
QByteArray remoteSourcesDir; QByteArray remoteSourcesDir;
QString remoteMountPoint; QString remoteMountPoint;

View File

@@ -4763,8 +4763,11 @@ void GdbEngine::setupInferior()
const QByteArray debugInfoLocation = sp.debugInfoLocation.toLocal8Bit(); const QByteArray debugInfoLocation = sp.debugInfoLocation.toLocal8Bit();
if (!debugInfoLocation.isEmpty()) if (!debugInfoLocation.isEmpty())
postCommand("set debug-file-directory " + debugInfoLocation); postCommand("set debug-file-directory " + debugInfoLocation);
// Spaces just will not work.
foreach (const QString &src, sp.debugSourceLocation) foreach (const QString &src, sp.debugSourceLocation)
postCommand("directory " + src.toLocal8Bit()); postCommand("directory " + src.toLocal8Bit());
if (!sp.solibSearchPath.isEmpty())
postCommand("set solib-search-path " + sp.solibSearchPath.toLocal8Bit());
m_gdbAdapter->setupInferior(); m_gdbAdapter->setupInferior();
} }

View File

@@ -169,10 +169,8 @@ void RemoteGdbServerAdapter::setupInferior()
fileName = fi.absoluteFilePath(); fileName = fi.absoluteFilePath();
} }
const QByteArray sysroot = sp.sysroot.toLocal8Bit(); const QByteArray sysroot = sp.sysroot.toLocal8Bit();
const QByteArray debugInfoLocation = sp.debugInfoLocation.toLocal8Bit();
const QByteArray remoteArch = sp.remoteArchitecture.toLatin1(); const QByteArray remoteArch = sp.remoteArchitecture.toLatin1();
const QByteArray gnuTarget = sp.gnuTarget.toLatin1(); const QByteArray gnuTarget = sp.gnuTarget.toLatin1();
const QByteArray solibPath = QFileInfo(sp.dumperLibrary).path().toLocal8Bit();
const QString args = sp.processArgs; const QString args = sp.processArgs;
if (!remoteArch.isEmpty()) if (!remoteArch.isEmpty())
@@ -181,12 +179,6 @@ void RemoteGdbServerAdapter::setupInferior()
m_engine->postCommand("set gnutarget " + gnuTarget); m_engine->postCommand("set gnutarget " + gnuTarget);
if (!sysroot.isEmpty()) if (!sysroot.isEmpty())
m_engine->postCommand("set sysroot " + sysroot); m_engine->postCommand("set sysroot " + sysroot);
if (!debugInfoLocation.isEmpty())
m_engine->postCommand("set debug-file-directory " + debugInfoLocation);
foreach (const QString &src, sp.debugSourceLocation)
m_engine->postCommand("directory " + src.toLocal8Bit());
if (!solibPath.isEmpty())
m_engine->postCommand("set solib-search-path " + solibPath);
if (!args.isEmpty()) if (!args.isEmpty())
m_engine->postCommand("-exec-arguments " + args.toLocal8Bit()); m_engine->postCommand("-exec-arguments " + args.toLocal8Bit());