| 1 | // |
| 2 | // allwatch.cpp - All Watch |
| 3 | // |
| 4 | // by Jean-Paul Mari |
| 5 | // |
| 6 | // JPM = Jean-Paul Mari <djipi.mari@gmail.com> |
| 7 | // |
| 8 | // Who When What |
| 9 | // --- ---------- ----------------------------------------------------------- |
| 10 | // JPM 12/07/2017 Created this file |
| 11 | // |
| 12 | |
| 13 | // STILL TO DO: |
| 14 | // |
| 15 | |
| 16 | #include "debugger\allwatchbrowser.h" |
| 17 | #include "memory.h" |
| 18 | #include "debugger\DBGManager.h" |
| 19 | |
| 20 | |
| 21 | AllWatchBrowserWindow::AllWatchBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog), |
| 22 | layout(new QVBoxLayout), text(new QTextBrowser), |
| 23 | // layout(new QVBoxLayout), text(new QLabel), |
| 24 | // refresh(new QPushButton(tr("Refresh"))), |
| 25 | // address(new QLineEdit), |
| 26 | // go(new QPushButton(tr("Go"))), |
| 27 | // memBase(0), |
| 28 | NbWatch(0), |
| 29 | PtrWatchInfo(NULL) |
| 30 | { |
| 31 | setWindowTitle(tr("All Watch")); |
| 32 | |
| 33 | // address->setInputMask("hhhhhh"); |
| 34 | // QHBoxLayout * hbox1 = new QHBoxLayout; |
| 35 | // hbox1->addWidget(refresh); |
| 36 | // hbox1->addWidget(address); |
| 37 | // hbox1->addWidget(go); |
| 38 | |
| 39 | // Need to set the size as well... |
| 40 | // resize(560, 480); |
| 41 | |
| 42 | QFont fixedFont("Lucida Console", 8, QFont::Normal); |
| 43 | // QFont fixedFont("", 8, QFont::Normal); |
| 44 | fixedFont.setStyleHint(QFont::TypeWriter); |
| 45 | text->setFont(fixedFont); |
| 46 | //// layout->setSizeConstraint(QLayout::SetFixedSize); |
| 47 | setLayout(layout); |
| 48 | |
| 49 | layout->addWidget(text); |
| 50 | // layout->addWidget(refresh); |
| 51 | // layout->addLayout(hbox1); |
| 52 | |
| 53 | // connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents())); |
| 54 | // connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress())); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | // |
| 59 | AllWatchBrowserWindow::~AllWatchBrowserWindow(void) |
| 60 | { |
| 61 | NbWatch = 0; |
| 62 | free(PtrWatchInfo); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | // |
| 67 | void AllWatchBrowserWindow::RefreshContents(void) |
| 68 | { |
| 69 | char string[1024]; |
| 70 | // char buf[64]; |
| 71 | QString WatchAll; |
| 72 | |
| 73 | if (isVisible()) |
| 74 | { |
| 75 | if (!NbWatch) |
| 76 | { |
| 77 | if (NbWatch = DBGManager_GetNbExternalVariables()) |
| 78 | { |
| 79 | PtrWatchInfo = (WatchInfo *)calloc(NbWatch, sizeof(WatchInfo)); |
| 80 | #ifdef _MSC_VER |
| 81 | #pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!") |
| 82 | #else |
| 83 | #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!" |
| 84 | #endif // _MSC_VER |
| 85 | |
| 86 | for (uint32_t i = 0; i < NbWatch; i++) |
| 87 | { |
| 88 | PtrWatchInfo[i].PtrVariableName = DBGManager_GetExternalVariableName(i + 1); |
| 89 | PtrWatchInfo[i].addr = DBGManager_GetExternalVariableAdr(i + 1); |
| 90 | PtrWatchInfo[i].TypeTag = DBGManager_GetExternalVariableTypeTag(i + 1); |
| 91 | if (!strlen(PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetExternalVariableTypeName(i + 1))) |
| 92 | { |
| 93 | PtrWatchInfo[i].PtrVariableBaseTypeName = (char *)"<font color='#ff0000'>N/A</font>"; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | for (uint32_t i = 0; i < NbWatch; i++) |
| 100 | { |
| 101 | if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName) |
| 102 | { |
| 103 | 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)); |
| 104 | WatchAll += QString(string); |
| 105 | sprintf(string, "<br>"); |
| 106 | WatchAll += QString(string); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | text->clear(); |
| 111 | text->setText(WatchAll); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | |
| 116 | #if 0 |
| 117 | void AllWatchBrowserWindow::keyPressEvent(QKeyEvent * e) |
| 118 | { |
| 119 | if (e->key() == Qt::Key_Escape) |
| 120 | hide(); |
| 121 | else if (e->key() == Qt::Key_PageUp) |
| 122 | { |
| 123 | memBase -= 480; |
| 124 | |
| 125 | if (memBase < 0) |
| 126 | memBase = 0; |
| 127 | |
| 128 | RefreshContents(); |
| 129 | } |
| 130 | else if (e->key() == Qt::Key_PageDown) |
| 131 | { |
| 132 | memBase += 480; |
| 133 | |
| 134 | if (memBase > (0x200000 - 480)) |
| 135 | memBase = 0x200000 - 480; |
| 136 | |
| 137 | RefreshContents(); |
| 138 | } |
| 139 | else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus) |
| 140 | { |
| 141 | memBase -= 16; |
| 142 | |
| 143 | if (memBase < 0) |
| 144 | memBase = 0; |
| 145 | |
| 146 | RefreshContents(); |
| 147 | } |
| 148 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal) |
| 149 | { |
| 150 | memBase += 16; |
| 151 | |
| 152 | if (memBase > (0x200000 - 480)) |
| 153 | memBase = 0x200000 - 480; |
| 154 | |
| 155 | RefreshContents(); |
| 156 | } |
| 157 | } |
| 158 | #endif |
| 159 | |
| 160 | |
| 161 | #if 0 |
| 162 | void AllWatchBrowserWindow::GoToAddress(void) |
| 163 | { |
| 164 | bool ok; |
| 165 | QString newAddress = address->text(); |
| 166 | memBase = newAddress.toUInt(&ok, 16); |
| 167 | RefreshContents(); |
| 168 | } |
| 169 | #endif |
| 170 | |