Commit 8a7518ccae6254d2f60f96c43df338d23f3acc67
- Diff rendering mode:
- inline
- side by side
|   | |||
| 1720 | 1720 | } | |
| 1721 | 1721 | } | |
| 1722 | 1722 | ||
| 1723 | #ifdef Q_OS_WIN | ||
| 1724 | |||
| 1725 | // Prepend environment of the Symbian Gdb by Cygwin '/bin' | ||
| 1726 | static void setGdbCygwinEnvironment(const QString &cygwin, QProcess *process) | ||
| 1727 | { | ||
| 1728 | if (cygwin.isEmpty() || !QFileInfo(cygwin).isDir()) | ||
| 1729 | return; | ||
| 1730 | const QString cygwinBinPath = QDir::toNativeSeparators(cygwin) + QLatin1String("\\bin"); | ||
| 1731 | QStringList env = process->environment(); | ||
| 1732 | if (env.isEmpty()) | ||
| 1733 | env = QProcess::systemEnvironment(); | ||
| 1734 | const QRegExp pathPattern(QLatin1String("^PATH=.*"), Qt::CaseInsensitive); | ||
| 1735 | const int index = env.indexOf(pathPattern); | ||
| 1736 | if (index == -1) | ||
| 1737 | return; | ||
| 1738 | QString pathValue = env.at(index).mid(5); | ||
| 1739 | if (pathValue.startsWith(cygwinBinPath)) | ||
| 1740 | return; | ||
| 1741 | env[index] = QLatin1String("PATH=") + cygwinBinPath + QLatin1Char(';'); | ||
| 1742 | process->setEnvironment(env); | ||
| 1743 | } | ||
| 1744 | #endif | ||
| 1745 | |||
| 1746 | 1723 | void TrkGdbAdapter::startGdb() | |
| 1747 | 1724 | { | |
| 1748 | 1725 | QTC_ASSERT(state() == AdapterStarting, qDebug() << state()); | |
| … | … | ||
| 1749 | 1749 | gdbArgs.append(QLatin1String("--nx")); // Do not read .gdbinit file | |
| 1750 | 1750 | gdbArgs.append(QLatin1String("-i")); | |
| 1751 | 1751 | gdbArgs.append(QLatin1String("mi")); | |
| 1752 | #ifdef Q_OS_WIN | ||
| 1753 | setGdbCygwinEnvironment(m_options->cygwin, &m_gdbProc); | ||
| 1754 | #endif | ||
| 1755 | 1752 | m_gdbProc.start(m_options->gdb, gdbArgs); | |
| 1756 | 1753 | } | |
| 1757 | 1754 |
|   | |||
| 54 | 54 | static const char *blueToothDeviceKeyC = "BlueToothDevice"; | |
| 55 | 55 | static const char *blueToothDeviceDefaultC = "/dev/rfcomm0"; | |
| 56 | 56 | static const char *gdbKeyC = "gdb"; | |
| 57 | static const char *cygwinKeyC = "Cygwin"; | ||
| 58 | 57 | ||
| 59 | static inline QString cygwinDefault() | ||
| 60 | { | ||
| 61 | #ifdef Q_OS_WIN | ||
| 62 | // Some smartness to check for Cygwin | ||
| 63 | static bool firstTime = true; | ||
| 64 | static QString rc = QLatin1String("C:/cygwin"); | ||
| 65 | if (firstTime) { | ||
| 66 | if (!QFileInfo(rc).isDir()) | ||
| 67 | rc.clear(); | ||
| 68 | firstTime = false; | ||
| 69 | } | ||
| 70 | return rc; | ||
| 71 | #else | ||
| 72 | return QString(); | ||
| 73 | #endif | ||
| 74 | } | ||
| 75 | |||
| 76 | 58 | namespace Debugger { | |
| 77 | 59 | namespace Internal { | |
| 78 | 60 | ||
| … | … | ||
| 62 | 62 | mode(modeDefault), | |
| 63 | 63 | serialPort(QLatin1String(serialPortDefaultC)), | |
| 64 | 64 | blueToothDevice(QLatin1String(blueToothDeviceDefaultC)), | |
| 65 | gdb(QLatin1String(gdbDefaultC)), | ||
| 66 | cygwin(cygwinDefault()) | ||
| 65 | gdb(QLatin1String(gdbDefaultC)) | ||
| 67 | 66 | { | |
| 68 | 67 | } | |
| 69 | 68 | ||
| … | … | ||
| 72 | 72 | mode = s->value(keyRoot + QLatin1String(modeKeyC), modeDefault).toInt(); | |
| 73 | 73 | serialPort = s->value(keyRoot + QLatin1String(serialPortKeyC), QLatin1String(serialPortDefaultC)).toString(); | |
| 74 | 74 | gdb = s->value(keyRoot + QLatin1String(gdbKeyC),QLatin1String(gdbDefaultC)).toString(); | |
| 75 | cygwin = s->value(keyRoot + QLatin1String(cygwinKeyC), cygwinDefault()).toString(); | ||
| 76 | 75 | blueToothDevice = s->value(keyRoot + QLatin1String(blueToothDeviceKeyC), QLatin1String(blueToothDeviceDefaultC)).toString(); | |
| 77 | 76 | } | |
| 78 | 77 | ||
| … | … | ||
| 82 | 82 | s->setValue(QLatin1String(serialPortKeyC), serialPort); | |
| 83 | 83 | s->setValue(QLatin1String(blueToothDeviceKeyC), blueToothDevice); | |
| 84 | 84 | s->setValue(QLatin1String(gdbKeyC), gdb); | |
| 85 | s->setValue(QLatin1String(cygwinKeyC), cygwin); | ||
| 86 | 85 | s->endGroup(); | |
| 87 | 86 | } | |
| 88 | 87 | ||
| … | … | ||
| 96 | 96 | *errorMessage = QCoreApplication::translate("TrkOptions", "The Symbian gdb executable '%1' could not be found in the search path.").arg(gdb); | |
| 97 | 97 | return false; | |
| 98 | 98 | } | |
| 99 | if (!cygwin.isEmpty() && !QFileInfo(cygwin).isDir()) { | ||
| 100 | *errorMessage = QCoreApplication::translate("TrkOptions", "The Cygwin directory '%1' does not exist.").arg(cygwin); | ||
| 101 | return false; | ||
| 102 | } | ||
| 103 | 99 | return true; | |
| 104 | 100 | } | |
| 105 | 101 | ||
| … | … | ||
| 104 | 104 | return mode == o.mode | |
| 105 | 105 | && serialPort == o.serialPort | |
| 106 | 106 | && blueToothDevice == o.blueToothDevice | |
| 107 | && gdb == o.gdb | ||
| 108 | && cygwin == o.cygwin; | ||
| 107 | && gdb == o.gdb; | ||
| 109 | 108 | } | |
| 110 | 109 | ||
| 111 | 110 | QStringList TrkOptions::serialPorts() |
|   | |||
| 40 | 40 | namespace Internal { | |
| 41 | 41 | ||
| 42 | 42 | /* Parameter to be used for debugging S60 via TRK. | |
| 43 | * GDB is a Symbian-ARM Gdb. It is Cygwin-built on Windows; the cygwin | ||
| 44 | * location 'x/bin' will prepended to the execution path. | ||
| 43 | * GDB is a Symbian-ARM Gdb. | ||
| 45 | 44 | * Communication happens either via BlueTooth (Linux only) or | |
| 46 | 45 | * serial ports. */ | |
| 47 | 46 | ||
| … | … | ||
| 63 | 63 | QString serialPort; | |
| 64 | 64 | QString blueToothDevice; | |
| 65 | 65 | QString gdb; | |
| 66 | QString cygwin; // ignored on Linux | ||
| 67 | 66 | }; | |
| 68 | 67 | ||
| 69 | 68 | inline bool operator==(const TrkOptions &o1, const TrkOptions &o2) |
|   | |||
| 41 | 41 | { | |
| 42 | 42 | ui->setupUi(this); | |
| 43 | 43 | ui->gdbChooser->setExpectedKind(Utils::PathChooser::Command); | |
| 44 | ui->cygwinChooser->setExpectedKind(Utils::PathChooser::Directory); | ||
| 45 | 44 | ui->blueToothComboBox->addItems(TrkOptions::blueToothDevices()); | |
| 46 | 45 | ui->serialComboBox->addItems(TrkOptions::serialPorts()); | |
| 47 | 46 | connect(ui->commComboBox, SIGNAL(currentIndexChanged(int)), ui->commStackedWidget, SLOT(setCurrentIndex(int))); | |
| 48 | 47 | // No bluetooth on Windows yet... | |
| 49 | 48 | #ifdef Q_OS_WIN | |
| 50 | ui->commComboBox->setEnabled(false); | ||
| 51 | #else | ||
| 52 | ui->cygwinChooser->setVisible(false); | ||
| 53 | ui->cygwinLabel->setVisible(false); | ||
| 49 | ui->commGroupBox->setVisible(false); | ||
| 54 | 50 | #endif | |
| 55 | 51 | } | |
| 56 | 52 | ||
| … | … | ||
| 74 | 74 | const int serialPortIndex = qMax(0, ui->serialComboBox->findText(o.serialPort)); | |
| 75 | 75 | ui->serialComboBox->setCurrentIndex(serialPortIndex); | |
| 76 | 76 | ui->gdbChooser->setPath(o.gdb); | |
| 77 | ui->cygwinChooser->setPath(o.cygwin); | ||
| 78 | 77 | const int blueToothIndex = qMax(0, ui->blueToothComboBox->findText(o.blueToothDevice)); | |
| 79 | 78 | ui->blueToothComboBox->setCurrentIndex(blueToothIndex); | |
| 80 | 79 | } | |
| … | … | ||
| 83 | 83 | TrkOptions rc; | |
| 84 | 84 | rc.mode = ui->commComboBox->currentIndex(); | |
| 85 | 85 | rc.gdb = ui->gdbChooser->path(); | |
| 86 | rc.cygwin = ui->cygwinChooser->path(); | ||
| 87 | 86 | rc.blueToothDevice = ui->blueToothComboBox->currentText(); | |
| 88 | 87 | rc.serialPort = ui->serialComboBox->currentText(); | |
| 89 | 88 | return rc; |
|   | |||
| 20 | 20 | <string>Gdb</string> | |
| 21 | 21 | </property> | |
| 22 | 22 | <layout class="QFormLayout" name="formLayout"> | |
| 23 | <property name="fieldGrowthPolicy"> | ||
| 24 | <enum>QFormLayout::AllNonFixedFieldsGrow</enum> | ||
| 25 | </property> | ||
| 23 | 26 | <item row="0" column="0"> | |
| 24 | 27 | <widget class="QLabel" name="gdbLabel"> | |
| 25 | 28 | <property name="text"> | |
| … | … | ||
| 32 | 32 | </item> | |
| 33 | 33 | <item row="0" column="1"> | |
| 34 | 34 | <widget class="Utils::PathChooser" name="gdbChooser" native="true"/> | |
| 35 | </item> | ||
| 36 | <item row="1" column="0"> | ||
| 37 | <widget class="QLabel" name="cygwinLabel"> | ||
| 38 | <property name="text"> | ||
| 39 | <string>Cygwin location:</string> | ||
| 40 | </property> | ||
| 41 | </widget> | ||
| 42 | </item> | ||
| 43 | <item row="1" column="1"> | ||
| 44 | <widget class="Utils::PathChooser" name="cygwinChooser" native="true"/> | ||
| 45 | 35 | </item> | |
| 46 | 36 | </layout> | |
| 47 | 37 | </widget> |

