| 1 | //\r |
| 2 | // brkWin.cpp - Breakpoints\r |
| 3 | //\r |
| 4 | // by Jean-Paul Mari\r |
| 5 | //\r |
| 6 | // JPM = Jean-Paul Mari <djipi.mari@gmail.com>\r |
| 7 | //\r |
| 8 | // Who When What\r |
| 9 | // --- ---------- -----------------------------------------------------------\r |
| 10 | // JPM 30/08/2017 Created this file\r |
| 11 | //\r |
| 12 | \r |
| 13 | // STILL TO DO:\r |
| 14 | //\r |
| 15 | \r |
| 16 | #include "debugger/brkWin.h"\r |
| 17 | //#include "memory.h"\r |
| 18 | #include "debugger/DBGManager.h"\r |
| 19 | \r |
| 20 | \r |
| 21 | //\r |
| 22 | BrkWindow::BrkWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),\r |
| 23 | layout(new QVBoxLayout), text(new QTextBrowser),\r |
| 24 | // layout(new QVBoxLayout), text(new QLabel),\r |
| 25 | // refresh(new QPushButton(tr("Refresh"))),\r |
| 26 | address(new QLineEdit)\r |
| 27 | // go(new QPushButton(tr("Go"))),\r |
| 28 | // memBase(0),\r |
| 29 | // NbWatch(0),\r |
| 30 | // PtrWatchInfo(NULL)\r |
| 31 | {\r |
| 32 | setWindowTitle(tr("Breakpoints window"));\r |
| 33 | \r |
| 34 | #if 0\r |
| 35 | // address->setInputMask("hhhhhh");\r |
| 36 | // QHBoxLayout * hbox1 = new QHBoxLayout;\r |
| 37 | // hbox1->addWidget(refresh);\r |
| 38 | // hbox1->addWidget(address);\r |
| 39 | // hbox1->addWidget(go);\r |
| 40 | \r |
| 41 | // Need to set the size as well...\r |
| 42 | // resize(560, 480);\r |
| 43 | \r |
| 44 | QFont fixedFont("Lucida Console", 8, QFont::Normal);\r |
| 45 | // QFont fixedFont("", 8, QFont::Normal);\r |
| 46 | fixedFont.setStyleHint(QFont::TypeWriter);\r |
| 47 | text->setFont(fixedFont);\r |
| 48 | //// layout->setSizeConstraint(QLayout::SetFixedSize);\r |
| 49 | setLayout(layout);\r |
| 50 | \r |
| 51 | layout->addWidget(text);\r |
| 52 | // layout->addWidget(refresh);\r |
| 53 | // layout->addLayout(hbox1);\r |
| 54 | \r |
| 55 | // connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));\r |
| 56 | // connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));\r |
| 57 | #endif\r |
| 58 | }\r |
| 59 | \r |
| 60 | \r |
| 61 | //\r |
| 62 | BrkWindow::~BrkWindow(void)\r |
| 63 | {\r |
| 64 | #if 0\r |
| 65 | NbWatch = 0;\r |
| 66 | free(PtrWatchInfo);\r |
| 67 | #endif\r |
| 68 | }\r |
| 69 | \r |
| 70 | \r |
| 71 | //\r |
| 72 | void BrkWindow::RefreshContents(void)\r |
| 73 | {\r |
| 74 | #if 0\r |
| 75 | char string[1024];\r |
| 76 | // char buf[64];\r |
| 77 | QString WatchAll;\r |
| 78 | \r |
| 79 | if (isVisible())\r |
| 80 | {\r |
| 81 | if (!NbWatch)\r |
| 82 | {\r |
| 83 | if (NbWatch = DBGManager_GetNbGlobalVariables())\r |
| 84 | {\r |
| 85 | PtrWatchInfo = (WatchInfo *)calloc(NbWatch, sizeof(WatchInfo));\r |
| 86 | #ifdef _MSC_VER\r |
| 87 | #pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!")\r |
| 88 | #else\r |
| 89 | #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!"\r |
| 90 | #endif // _MSC_VER\r |
| 91 | \r |
| 92 | for (uint32_t i = 0; i < NbWatch; i++)\r |
| 93 | {\r |
| 94 | PtrWatchInfo[i].PtrVariableName = DBGManager_GetGlobalVariableName(i + 1);\r |
| 95 | PtrWatchInfo[i].addr = DBGManager_GetExternalVariableAdr(i + 1);\r |
| 96 | PtrWatchInfo[i].TypeTag = DBGManager_GetExternalVariableTypeTag(i + 1);\r |
| 97 | if (!strlen(PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetGlobalVariableTypeName(i + 1)))\r |
| 98 | {\r |
| 99 | PtrWatchInfo[i].PtrVariableBaseTypeName = (char *)"<font color='#ff0000'>N/A</font>";\r |
| 100 | }\r |
| 101 | }\r |
| 102 | }\r |
| 103 | }\r |
| 104 | \r |
| 105 | for (uint32_t i = 0; i < NbWatch; i++)\r |
| 106 | {\r |
| 107 | if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName)\r |
| 108 | {\r |
| 109 | sprintf(string, "%i : %s | %s | 0x%06X | %s", (i + 1), PtrWatchInfo[i].PtrVariableBaseTypeName, PtrWatchInfo[i].PtrVariableName, PtrWatchInfo[i].addr, (PtrWatchInfo[i].TypeTag & 0x8) ? "" : DBGManager_GetExternalVariableValue(i + 1));\r |
| 110 | WatchAll += QString(string);\r |
| 111 | sprintf(string, "<br>");\r |
| 112 | WatchAll += QString(string);\r |
| 113 | }\r |
| 114 | }\r |
| 115 | \r |
| 116 | text->clear();\r |
| 117 | text->setText(WatchAll);\r |
| 118 | }\r |
| 119 | #endif\r |
| 120 | }\r |
| 121 | \r |
| 122 | \r |
| 123 | //\r |
| 124 | void BrkWindow::keyPressEvent(QKeyEvent * e)\r |
| 125 | {\r |
| 126 | if (e->key() == Qt::Key_Escape)\r |
| 127 | {\r |
| 128 | hide();\r |
| 129 | }\r |
| 130 | else\r |
| 131 | {\r |
| 132 | if (e->key() == Qt::Key_PageUp)\r |
| 133 | {\r |
| 134 | #if 0\r |
| 135 | memBase -= 480;\r |
| 136 | \r |
| 137 | if (memBase < 0)\r |
| 138 | memBase = 0;\r |
| 139 | \r |
| 140 | RefreshContents();\r |
| 141 | #endif\r |
| 142 | }\r |
| 143 | else\r |
| 144 | {\r |
| 145 | if (e->key() == Qt::Key_PageDown)\r |
| 146 | {\r |
| 147 | #if 0\r |
| 148 | memBase += 480;\r |
| 149 | \r |
| 150 | if (memBase > (0x200000 - 480))\r |
| 151 | memBase = 0x200000 - 480;\r |
| 152 | \r |
| 153 | RefreshContents();\r |
| 154 | #endif\r |
| 155 | }\r |
| 156 | else\r |
| 157 | {\r |
| 158 | if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)\r |
| 159 | {\r |
| 160 | #if 0\r |
| 161 | memBase -= 16;\r |
| 162 | \r |
| 163 | if (memBase < 0)\r |
| 164 | memBase = 0;\r |
| 165 | \r |
| 166 | RefreshContents();\r |
| 167 | #endif\r |
| 168 | }\r |
| 169 | else\r |
| 170 | {\r |
| 171 | if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)\r |
| 172 | {\r |
| 173 | #if 0\r |
| 174 | memBase += 16;\r |
| 175 | \r |
| 176 | if (memBase > (0x200000 - 480))\r |
| 177 | memBase = 0x200000 - 480;\r |
| 178 | \r |
| 179 | RefreshContents();\r |
| 180 | #endif\r |
| 181 | }\r |
| 182 | else\r |
| 183 | {\r |
| 184 | if (e->key() == Qt::Key_Return)\r |
| 185 | {\r |
| 186 | GoToAddress();\r |
| 187 | }\r |
| 188 | }\r |
| 189 | }\r |
| 190 | }\r |
| 191 | }\r |
| 192 | }\r |
| 193 | }\r |
| 194 | \r |
| 195 | \r |
| 196 | //\r |
| 197 | void BrkWindow::RefreshBrkList(size_t Address)\r |
| 198 | {\r |
| 199 | }\r |
| 200 | \r |
| 201 | \r |
| 202 | // Go to the requested address\r |
| 203 | // Address can be an hexa, decimal or a symbol name\r |
| 204 | void BrkWindow::GoToAddress(void)\r |
| 205 | {\r |
| 206 | size_t Address;\r |
| 207 | bool ok;\r |
| 208 | QString newAddress;\r |
| 209 | \r |
| 210 | newAddress = address->text();\r |
| 211 | \r |
| 212 | if ((newAddress.at(0) == QChar('0')) && (newAddress.at(1) == QChar('x')))\r |
| 213 | {\r |
| 214 | Address = newAddress.toUInt(&ok, 16);\r |
| 215 | }\r |
| 216 | else\r |
| 217 | {\r |
| 218 | if (!(Address = DBGManager_GetAdrFromSymbolName(newAddress.toLatin1().data())))\r |
| 219 | {\r |
| 220 | Address = newAddress.toUInt(&ok, 10);\r |
| 221 | }\r |
| 222 | }\r |
| 223 | \r |
| 224 | RefreshBrkList(Address);\r |
| 225 | }\r |
| 226 | \r |