| 109 | } |
| 110 | |
| 111 | void MainWindow::debugImportFile(const QString &file) { |
| 112 | if (file.isEmpty()) { |
| 113 | return; |
| 114 | } |
| 115 | int i; |
| 116 | |
| 117 | // check the debug file version |
| 118 | QSettings info(file, QSettings::IniFormat); |
| 119 | if (info.value(QStringLiteral("version")) != VERSION_DBG) { |
| 120 | error: |
| 121 | QMessageBox *warn = new QMessageBox; |
| 122 | warn->setWindowTitle(tr("Invalid Configuration")); |
| 123 | warn->setText(tr("The debugging configuration is incompatible with CEmu")); |
| 124 | warn->setWindowModality(Qt::ApplicationModal); |
| 125 | warn->setAttribute(Qt::WA_DeleteOnClose); |
| 126 | warn->show(); |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | // load the breakpoint information |
| 131 | QStringList breakLabel = info.value(QStringLiteral("breakpoints/label")).toStringList(); |
| 132 | QStringList breakAddr = info.value(QStringLiteral("breakpoints/address")).toStringList(); |
| 133 | QStringList breakSet = info.value(QStringLiteral("breakpoints/enable")).toStringList(); |
| 134 | if ((breakLabel.size() + breakAddr.size() + breakSet.size()) / 3 != breakLabel.size()) { |
| 135 | goto error; |
| 136 | } |
| 137 | for (i = 0; i < breakLabel.size(); i++) { |
| 138 | breakAdd(breakLabel.at(i), static_cast<uint32_t>(hex2int(breakAddr.at(i))), breakSet.at(i) == TXT_YES, false, false); |
| 139 | } |
| 140 | |
| 141 | // load the watchpoint information |
| 142 | QStringList watchLabel = info.value(QStringLiteral("watchpoints/label")).toStringList(); |
| 143 | QStringList watchLow = info.value(QStringLiteral("watchpoints/low")).toStringList(); |
| 144 | QStringList watchHigh = info.value(QStringLiteral("watchpoints/high")).toStringList(); |
| 145 | QStringList watchR = info.value(QStringLiteral("watchpoints/read")).toStringList(); |
| 146 | QStringList watchW = info.value(QStringLiteral("watchpoints/write")).toStringList(); |
| 147 | if ((watchLabel.size() + watchLow.size() + watchHigh.size() + watchR.size() + watchW.size()) / 5 != watchLabel.size()) { |
| 148 | goto error; |
| 149 | } |
| 150 | for (i = 0; i < watchLabel.size(); i++) { |
| 151 | int mask = (watchR.at(i) == TXT_YES ? DBG_MASK_READ : DBG_MASK_NONE) | |
| 152 | (watchW.at(i) == TXT_YES ? DBG_MASK_WRITE : DBG_MASK_NONE); |
| 153 | watchAdd(watchLabel.at(i), static_cast<uint32_t>(hex2int(watchLow.at(i))), |
| 154 | static_cast<uint32_t>(hex2int(watchHigh.at(i))), mask, false, false); |
| 155 | } |
| 156 | |
| 157 | // load the port monitor information |
| 158 | QStringList portAddr = info.value(QStringLiteral("portmonitor/address")).toStringList(); |
| 159 | QStringList portR = info.value(QStringLiteral("portmonitor/read")).toStringList(); |
| 160 | QStringList portW = info.value(QStringLiteral("portmonitor/write")).toStringList(); |
| 161 | QStringList portF = info.value(QStringLiteral("portmonitor/freeze")).toStringList(); |
| 162 | if ((portAddr.size() + portR.size() + portW.size() + portF.size()) / 4 != portAddr.size()) { |
| 163 | goto error; |
| 164 | } |
| 165 | for (i = 0; i < portAddr.size(); i++) { |
| 166 | int mask = (portR.at(i) == TXT_YES ? DBG_MASK_PORT_READ : DBG_MASK_NONE) | |
| 167 | (portW.at(i) == TXT_YES ? DBG_MASK_PORT_WRITE : DBG_MASK_NONE) | |
| 168 | (portF.at(i) == TXT_YES ? DBG_MASK_PORT_FREEZE : DBG_MASK_NONE); |