OSDN Git Service

debugger: simplify attach-to-{external,core} code
authorhjk <qtc-committer@nokia.com>
Tue, 31 May 2011 08:27:32 +0000 (10:27 +0200)
committerhjk <qthjk@ovi.com>
Tue, 31 May 2011 11:34:53 +0000 (13:34 +0200)
Change-Id: Ia1af4b48d32b2de4c5f320ba7b8ab4594eb0e56d
Reviewed-on: http://codereview.qt.nokia.com/252
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: hjk <qthjk@ovi.com>
src/plugins/debugger/debuggerplugin.cpp

index aecdd66..30904e6 100644 (file)
@@ -689,16 +689,8 @@ public slots:
     void startRemoteEngine();
     void attachExternalApplication();
     Q_SLOT void attachExternalApplication(ProjectExplorer::RunControl *rc);
-    void attachExternalApplication(qint64 pid, const QString &binary,
-                                   const ProjectExplorer::Abi &abi,
-                                   const QString &debuggerCommand);
     void runScheduled();
     void attachCore();
-    void attachCore(const QString &core, const QString &exeFileName,
-                    const ProjectExplorer::Abi &abi = ProjectExplorer::Abi(),
-                    const QString &sysroot = QString(),
-                    const QString &overrideStartScript = QString(),
-                    const QString &debuggerCommand = QString());
     void attachRemote(const QString &spec);
 
     void enableReverseDebuggingTriggered(const QVariant &value);
@@ -1412,26 +1404,21 @@ void DebuggerPluginPrivate::attachExternalApplication()
     if (dlg.exec() != QDialog::Accepted)
         return;
 
-    setConfigValue(_("LastAttachExternalAbiIndex"), QVariant(dlg.abiIndex()));
-    attachExternalApplication(dlg.attachPID(), dlg.executable(), dlg.abi(), dlg.debuggerCommand());
-}
-
-void DebuggerPluginPrivate::attachExternalApplication(qint64 pid, const QString &binary,
-                                                      const ProjectExplorer::Abi &abi,
-                                                      const QString &debuggerCommand)
-{
-    if (pid == 0) {
+    if (dlg.attachPID() == 0) {
         QMessageBox::warning(mainWindow(), tr("Warning"),
-            tr("Cannot attach to PID 0"));
+            tr("Cannot attach to process with PID 0"));
         return;
     }
+
+    setConfigValue(_("LastAttachExternalAbiIndex"), QVariant(dlg.abiIndex()));
+
     DebuggerStartParameters sp;
-    sp.attachPID = pid;
-    sp.displayName = tr("Process %1").arg(pid);
-    sp.executable = binary;
+    sp.attachPID = dlg.attachPID();
+    sp.displayName = tr("Process %1").arg(dlg.attachPID());
+    sp.executable = dlg.executable();
     sp.startMode = AttachExternal;
-    sp.toolChainAbi = abi.isValid() ? abi : abiOfBinary(sp.executable);
-    sp.debuggerCommand = debuggerCommand;
+    sp.toolChainAbi = dlg.abi();
+    sp.debuggerCommand = dlg.debuggerCommand();
     if (DebuggerRunControl *rc = createDebugger(sp))
         startDebugger(rc);
 }
@@ -1465,26 +1452,16 @@ void DebuggerPluginPrivate::attachCore()
     setConfigValue(_("LastExternalCoreAbiIndex"), QVariant(dlg.abiIndex()));
     setConfigValue(_("LastSysroot"), dlg.sysroot());
     setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript());
-    attachCore(dlg.coreFile(), dlg.executableFile(), dlg.abi(),
-               dlg.sysroot(), dlg.overrideStartScript());
-}
 
-void DebuggerPluginPrivate::attachCore(const QString &core,
-                                       const QString &exe,
-                                       const ProjectExplorer::Abi &abi,
-                                       const QString &sysroot,
-                                       const QString &overrideStartScript,
-                                       const QString &debuggerCommand)
-{
     DebuggerStartParameters sp;
-    sp.executable = exe;
-    sp.coreFile = core;
-    sp.displayName = tr("Core file \"%1\"").arg(core);
+    sp.executable = dlg.executableFile();
+    sp.coreFile = dlg.coreFile();
+    sp.displayName = tr("Core file \"%1\"").arg(dlg.coreFile());
     sp.startMode = AttachCore;
-    sp.debuggerCommand = debuggerCommand;
-    sp.toolChainAbi = abi.isValid() ? abi : abiOfBinary(sp.coreFile);
-    sp.sysroot = sysroot;
-    sp.overrideStartScript = overrideStartScript;
+    sp.debuggerCommand = dlg.debuggerCommand();
+    sp.toolChainAbi = dlg.abi();
+    sp.sysroot = dlg.sysroot();
+    sp.overrideStartScript = dlg.overrideStartScript();
     if (DebuggerRunControl *rc = createDebugger(sp))
         startDebugger(rc);
 }