Commit 84a535ba authored by hjk's avatar hjk Committed by hjk
Browse files

debugger: hack to specify sysroot in generic remote linux

Change-Id: I9657f71246df4742329a0b4f27bf08f146e9632a
Reviewed-on: http://codereview.qt-project.org/5534

Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 9cc47518
......@@ -1014,6 +1014,9 @@ public slots:
DebuggerToolTipManager *toolTipManager() const { return m_toolTipManager; }
virtual QSharedPointer<GlobalDebuggerOptions> globalDebuggerOptions() const { return m_globalDebuggerOptions; }
// FIXME: Remove.
void maybeEnrichParameters(DebuggerStartParameters *sp);
public:
DebuggerMainWindow *m_mainWindow;
DebuggerRunControlFactory *m_debuggerRunControlFactory;
......@@ -1189,14 +1192,21 @@ static QString msgParameterMissing(const QString &a)
return DebuggerPlugin::tr("Option '%1' is missing the parameter.").arg(a);
}
static void maybeEnrichParameters(DebuggerStartParameters *sp)
void DebuggerPluginPrivate::maybeEnrichParameters(DebuggerStartParameters *sp)
{
if (!theDebuggerCore->boolSetting(AutoEnrichParameters))
if (!boolSetting(AutoEnrichParameters))
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())
sp->debugInfoLocation = sp->sysroot + "/usr/lib/debug";
if (sp->debugSourceLocation.isEmpty()) {
if (false && sp->debugSourceLocation.isEmpty()) {
QString base = sp->sysroot + "/usr/src/debug/";
sp->debugSourceLocation.append(base + "qt5base/src/corelib");
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 + "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,
......@@ -1486,7 +1500,6 @@ void DebuggerPluginPrivate::attachExternalApplication()
sp.startMode = AttachExternal;
sp.toolChainAbi = dlg.abi();
sp.debuggerCommand = dlg.debuggerCommand();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1498,7 +1511,6 @@ void DebuggerPluginPrivate::attachExternalApplication(ProjectExplorer::RunContro
sp.displayName = tr("Debugger attached to %1").arg(rc->displayName());
sp.startMode = AttachExternal;
sp.toolChainAbi = rc->abi();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1530,7 +1542,6 @@ void DebuggerPluginPrivate::attachCore()
sp.toolChainAbi = dlg.abi();
sp.sysroot = dlg.sysroot();
sp.overrideStartScript = dlg.overrideStartScript();
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1545,7 +1556,6 @@ void DebuggerPluginPrivate::attachRemote(const QString &spec)
sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel);
sp.startMode = AttachToRemoteServer;
sp.toolChainAbi = anyAbiOfBinary(sp.executable);
maybeEnrichParameters(&sp);
if (DebuggerRunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1643,7 +1653,6 @@ void DebuggerPluginPrivate::startRemoteApplication()
sp.startMode = StartRemote;
if (!queryRemoteParameters(sp, true))
return;
maybeEnrichParameters(&sp);
if (RunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1656,7 +1665,6 @@ void DebuggerPluginPrivate::attachRemoteApplication()
sp.startMode = AttachToRemoteServer;
sp.useServerStartScript = false;
sp.serverStartScript.clear();
maybeEnrichParameters(&sp);
if (RunControl *rc = createDebugger(sp))
startDebugger(rc);
}
......@@ -1926,8 +1934,10 @@ void DebuggerPluginPrivate::requestMark(ITextEditor *editor, int lineNumber)
}
DebuggerRunControl *DebuggerPluginPrivate::createDebugger
(const DebuggerStartParameters &sp, RunConfiguration *rc)
(const DebuggerStartParameters &sp0, RunConfiguration *rc)
{
DebuggerStartParameters sp = sp0;
maybeEnrichParameters(&sp);
return m_debuggerRunControlFactory->create(sp, rc);
}
......@@ -2525,12 +2535,14 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
str << "Start parameters: '" << sp.displayName << "' mode: " << sp.startMode
<< "\nABI: " << sp.toolChainAbi.toString() << '\n';
if (!sp.executable.isEmpty()) {
str << "Executable: " << QDir::toNativeSeparators(sp.executable) << ' ' << sp.processArgs;
str << "Executable: " << QDir::toNativeSeparators(sp.executable)
<< ' ' << sp.processArgs;
if (sp.useTerminal)
str << " [terminal]";
str << '\n';
if (!sp.workingDirectory.isEmpty())
str << "Directory: " << QDir::toNativeSeparators(sp.workingDirectory) << '\n';
str << "Directory: " << QDir::toNativeSeparators(sp.workingDirectory)
<< '\n';
if (sp.executableUid) {
str << "UID: 0x";
str.setIntegerBase(16);
......@@ -2547,36 +2559,38 @@ static QString formatStartParameters(DebuggerStartParameters &sp)
if (!sp.projectSourceDirectory.isEmpty()) {
str << "Project: " << QDir::toNativeSeparators(sp.projectSourceDirectory);
if (!sp.projectBuildDirectory.isEmpty())
str << " (built: " << QDir::toNativeSeparators(sp.projectBuildDirectory) << ')';
str << " (built: " << QDir::toNativeSeparators(sp.projectBuildDirectory)
<< ')';
str << '\n';
}
if (!sp.qtInstallPath.isEmpty())
str << "Qt: " << QDir::toNativeSeparators(sp.qtInstallPath) << '\n';
if (!sp.qmlServerAddress.isEmpty())
str << "QML server: " << sp.qmlServerAddress << ':' << sp.qmlServerPort << '\n';
str << "QML server: " << sp.qmlServerAddress << ':'
<< sp.qmlServerPort << '\n';
if (!sp.remoteChannel.isEmpty()) {
str << "Remote: " << sp.remoteChannel << ", " << sp.remoteArchitecture << '\n';
str << "Remote: " << sp.remoteChannel << ", "
<< sp.remoteArchitecture << '\n';
if (!sp.remoteDumperLib.isEmpty())
str << "Remote dumpers: " << sp.remoteDumperLib << '\n';
if (!sp.remoteSourcesDir.isEmpty())
str << "Remote sources: " << sp.remoteSourcesDir << '\n';
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())
str << "Gnu target: " << sp.gnuTarget << '\n';
if (!sp.sysroot.isEmpty())
str << "Sysroot: " << sp.sysroot << '\n';
if (!sp.symbolFileName.isEmpty())
str << "Symbol file: " << sp.symbolFileName << '\n';
str << "Sysroot: " << sp.sysroot << '\n';
str << "Solib Search Path: " << sp.solibSearchPath << '\n';
str << "Debug Source Loaction: " << sp.debugSourceLocation.join(":") << '\n';
str << "Symbol file: " << sp.symbolFileName << '\n';
if (sp.useServerStartScript)
str << "Using server start script: " << sp.serverStartScript;
if (!sp.dumperLibrary.isEmpty()) {
str << "Dumper libraries: " << QDir::toNativeSeparators(sp.dumperLibrary);
foreach (const QString &dl, sp.dumperLibraryLocations)
str << ' ' << QDir::toNativeSeparators(dl);
str << '\n';
}
str << "Dumper libraries: " << QDir::toNativeSeparators(sp.dumperLibrary);
foreach (const QString &dl, sp.dumperLibraryLocations)
str << ' ' << QDir::toNativeSeparators(dl);
str << '\n';
return rc;
}
......@@ -2636,17 +2650,17 @@ QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType
switch (et) {
case CdbEngineType:
searchAbis.clear();
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMsvc2010Flavor,
abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMsvc2008Flavor,
abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMsvc2005Flavor,
abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(),
Abi::WindowsMsvc2010Flavor, abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(),
Abi::WindowsMsvc2008Flavor, abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(),
Abi::WindowsMsvc2005Flavor, abi.binaryFormat(), abi.wordWidth()));
break;
case GdbEngineType:
searchAbis.clear();
searchAbis.push_back(Abi(abi.architecture(), abi.os(), Abi::WindowsMSysFlavor,
abi.binaryFormat(), abi.wordWidth()));
searchAbis.push_back(Abi(abi.architecture(), abi.os(),
Abi::WindowsMSysFlavor, abi.binaryFormat(), abi.wordWidth()));
break;
default:
break;
......@@ -2657,7 +2671,8 @@ QString DebuggerPluginPrivate::debuggerForAbi(const Abi &abi, DebuggerEngineType
<< searchAbis.front().toString() << et;
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
for (int i = toolchains.size() - 1; i >= 0; i--) {
const QString debugger = toolchains.at(i)->debuggerCommand();
......
......@@ -108,8 +108,9 @@ public:
bool useServerStartScript;
QString serverStartScript;
QString sysroot;
QString debugInfoLocation;
QStringList debugSourceLocation;
QString debugInfoLocation; // Gdb "set-debug-file-directory".
QString solibSearchPath; // Gdb "set solib-search-path".
QStringList debugSourceLocation; // Gdb "directory"
QByteArray remoteDumperLib;
QByteArray remoteSourcesDir;
QString remoteMountPoint;
......
......@@ -4763,8 +4763,11 @@ void GdbEngine::setupInferior()
const QByteArray debugInfoLocation = sp.debugInfoLocation.toLocal8Bit();
if (!debugInfoLocation.isEmpty())
postCommand("set debug-file-directory " + debugInfoLocation);
// Spaces just will not work.
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();
}
......
......@@ -169,10 +169,8 @@ void RemoteGdbServerAdapter::setupInferior()
fileName = fi.absoluteFilePath();
}
const QByteArray sysroot = sp.sysroot.toLocal8Bit();
const QByteArray debugInfoLocation = sp.debugInfoLocation.toLocal8Bit();
const QByteArray remoteArch = sp.remoteArchitecture.toLatin1();
const QByteArray gnuTarget = sp.gnuTarget.toLatin1();
const QByteArray solibPath = QFileInfo(sp.dumperLibrary).path().toLocal8Bit();
const QString args = sp.processArgs;
if (!remoteArch.isEmpty())
......@@ -181,12 +179,6 @@ void RemoteGdbServerAdapter::setupInferior()
m_engine->postCommand("set gnutarget " + gnuTarget);
if (!sysroot.isEmpty())
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())
m_engine->postCommand("-exec-arguments " + args.toLocal8Bit());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment