X-Git-Url: http://git.hcoop.net/clinton/Virtual-Jaguar-Rx.git/blobdiff_plain/0203b5fd6f49dbc4f4244417c095882eb9882d49..0029c5072f864788020340eab0ed9600ac0f8f4a:/src/debugger/allwatchbrowser.cpp
diff --git a/src/debugger/allwatchbrowser.cpp b/src/debugger/allwatchbrowser.cpp
index 302b462..f17b3f4 100644
--- a/src/debugger/allwatchbrowser.cpp
+++ b/src/debugger/allwatchbrowser.cpp
@@ -8,163 +8,209 @@
// Who When What
// --- ---------- -----------------------------------------------------------
// JPM 12/07/2017 Created this file
+// JPM 09/14/2018 Added a status bar, better status report and set information values in a tab
+// JPM April/2019 Added a sorting filter, tableview unique rows creation
//
// STILL TO DO:
+// Better presentation
+// To set the information display at the right
+// To understand/fix the problem with the sorting filter
+// Display arrays information
+// Display structures information
//
+//#define AW_SORTINGFILTER // Authorise the sorting filtes
+//#define AW_DEBUGNUMVARIABLE 4415 // Set the global variable number to debug
+#ifndef AW_DEBUGNUMVARIABLE
+#define AW_STARTNUMVARIABLE 0 // Must be kept to 0 in case of no debug is required
+#else
+#define AW_STARTNUMVARIABLE AW_DEBUGNUMVARIABLE - 1
+#endif
+
+
#include "debugger/allwatchbrowser.h"
#include "memory.h"
#include "debugger/DBGManager.h"
+//
AllWatchBrowserWindow::AllWatchBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
- layout(new QVBoxLayout), text(new QTextBrowser),
-// layout(new QVBoxLayout), text(new QLabel),
-// refresh(new QPushButton(tr("Refresh"))),
-// address(new QLineEdit),
-// go(new QPushButton(tr("Go"))),
-// memBase(0),
- NbWatch(0),
- PtrWatchInfo(NULL)
+layout(new QVBoxLayout),
+#ifdef AW_LAYOUTTEXTS
+text(new QTextBrowser),
+#else
+TableView(new QTableView),
+model(new QStandardItemModel),
+#endif
+NbWatch(0),
+statusbar(new QStatusBar),
+PtrWatchInfo(NULL)
{
setWindowTitle(tr("All Watch"));
-// address->setInputMask("hhhhhh");
-// QHBoxLayout * hbox1 = new QHBoxLayout;
-// hbox1->addWidget(refresh);
-// hbox1->addWidget(address);
-// hbox1->addWidget(go);
-
- // Need to set the size as well...
-// resize(560, 480);
-
+ // Set the font
QFont fixedFont("Lucida Console", 8, QFont::Normal);
-// QFont fixedFont("", 8, QFont::Normal);
fixedFont.setStyleHint(QFont::TypeWriter);
- text->setFont(fixedFont);
-//// layout->setSizeConstraint(QLayout::SetFixedSize);
- setLayout(layout);
+#ifdef AW_LAYOUTTEXTS
+ // Set original layout
+ text->setFont(fixedFont);
layout->addWidget(text);
-// layout->addWidget(refresh);
-// layout->addLayout(hbox1);
+#else
+ // Set the new layout with proper identation and readibility
+ model->setColumnCount(3);
+ model->setHeaderData(0, Qt::Horizontal, QObject::tr("Name"));
+ model->setHeaderData(1, Qt::Horizontal, QObject::tr("Value"));
+ model->setHeaderData(2, Qt::Horizontal, QObject::tr("Type"));
+ // Information table
+ TableView->setModel(model);
+ TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ TableView->setShowGrid(0);
+ TableView->setFont(fixedFont);
+ TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());
+ TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);
+ layout->addWidget(TableView);
+#endif
-// connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
-// connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));
+ // Status bar
+ layout->addWidget(statusbar);
+ setLayout(layout);
}
//
AllWatchBrowserWindow::~AllWatchBrowserWindow(void)
{
- NbWatch = 0;
+ Reset();
+}
+
+
+//
+void AllWatchBrowserWindow::Reset(void)
+{
free(PtrWatchInfo);
+ NbWatch = 0;
+ PtrWatchInfo = NULL;
}
//
void AllWatchBrowserWindow::RefreshContents(void)
{
+ char msg[100];
+#ifdef AW_LAYOUTTEXTS
char string[1024];
-// char buf[64];
+#endif
QString WatchAll;
+ size_t Error = AW_NOERROR;
+ char *PtrValue;
if (isVisible())
{
if (!NbWatch)
{
+ // Pre-catch the information for each global variables
if (NbWatch = DBGManager_GetNbGlobalVariables())
{
PtrWatchInfo = (WatchInfo *)calloc(NbWatch, sizeof(WatchInfo));
-#ifdef _MSC_VER
-#pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!")
-#else
- #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!"
-#endif // _MSC_VER
-
- for (uint32_t i = 0; i < NbWatch; i++)
+#ifndef AW_LAYOUTTEXTS
+#ifdef AW_SORTINGFILTER
+ TableView->setSortingEnabled(false);
+#endif
+ model->setRowCount(0);
+#endif
+ for (uint32_t i = AW_STARTNUMVARIABLE; i < NbWatch; i++)
{
PtrWatchInfo[i].PtrVariableName = DBGManager_GetGlobalVariableName(i + 1);
- PtrWatchInfo[i].addr = DBGManager_GetGlobalVariableAdr(i + 1);
PtrWatchInfo[i].TypeTag = DBGManager_GetGlobalVariableTypeTag(i + 1);
+#ifdef AW_LAYOUTTEXTS
+ PtrWatchInfo[i].addr = DBGManager_GetGlobalVariableAdr(i + 1);
if (!strlen(PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetGlobalVariableTypeName(i + 1)))
{
PtrWatchInfo[i].PtrVariableBaseTypeName = (char *)"N/A";
}
+#else
+ PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetGlobalVariableTypeName(i + 1);
+ model->insertRow(i);
+#endif
}
}
}
- for (uint32_t i = 0; i < NbWatch; i++)
+ if (NbWatch)
{
- if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName)
+ for (uint32_t i = AW_STARTNUMVARIABLE; i < NbWatch; i++)
{
- sprintf(string, "%i : %s | %s | 0x%06X | %s", (i + 1), PtrWatchInfo[i].PtrVariableBaseTypeName, PtrWatchInfo[i].PtrVariableName, (unsigned int)PtrWatchInfo[i].addr, (PtrWatchInfo[i].TypeTag & 0x8) ? "" : DBGManager_GetGlobalVariableValue(i + 1));
- WatchAll += QString(string);
- sprintf(string, "
");
+ if ((PtrWatchInfo[i].TypeTag & (DBG_TAG_TYPE_array | DBG_TAG_TYPE_structure)))
+ {
+#if defined(AW_SUPPORTARRAY) || defined(AW_SUPPORTSTRUCTURE)
+ //PtrValue = (char *)memcpy(Value, &jaguarMainRAM[PtrWatchInfo[i].addr], 20);
+ PtrValue = NULL;
+#else
+ PtrValue = NULL;
+#endif
+ }
+ else
+ {
+ PtrValue = DBGManager_GetGlobalVariableValue(i + 1);
+ }
+#ifdef AW_LAYOUTTEXTS
+ if (i)
+ {
+ WatchAll += QString("
");
+ }
+ sprintf(string, "%i : %s | %s | 0x%06X | %s", (i + 1), PtrWatchInfo[i].PtrVariableBaseTypeName, PtrWatchInfo[i].PtrVariableName, (unsigned int)PtrWatchInfo[i].addr, PtrValue ? PtrValue : (char *)"N/A");
WatchAll += QString(string);
+#else
+ model->setItem(i, 0, new QStandardItem(QString("%1").arg(PtrWatchInfo[i].PtrVariableName)));
+ model->setItem(i, 1, new QStandardItem(QString("%1").arg(PtrValue)));
+ model->setItem(i, 2, new QStandardItem(QString("%1").arg(PtrWatchInfo[i].PtrVariableBaseTypeName)));
+#endif
}
+#ifdef AW_LAYOUTTEXTS
+ text->clear();
+ text->setText(WatchAll);
+#else
+#ifdef AW_SORTINGFILTER
+ TableView->setSortingEnabled(true);
+#endif
+#endif
+ sprintf(msg, "Ready");
+ }
+ else
+ {
+ sprintf(msg, "No watches");
+ Error = AW_NOALLWATCH;
}
- text->clear();
- text->setText(WatchAll);
+ // Display status bar
+ if (Error)
+ {
+ if ((Error & AW_WARNING))
+ {
+ statusbar->setStyleSheet("background-color: lightyellow; font: bold");
+ }
+ else
+ {
+ statusbar->setStyleSheet("background-color: tomato; font: bold");
+ }
+ }
+ else
+ {
+ statusbar->setStyleSheet("background-color: lightgreen; font: bold");
+ }
+ statusbar->showMessage(QString(msg));
}
}
-#if 0
+//
void AllWatchBrowserWindow::keyPressEvent(QKeyEvent * e)
{
if (e->key() == Qt::Key_Escape)
- hide();
- else if (e->key() == Qt::Key_PageUp)
{
- memBase -= 480;
-
- if (memBase < 0)
- memBase = 0;
-
- RefreshContents();
- }
- else if (e->key() == Qt::Key_PageDown)
- {
- memBase += 480;
-
- if (memBase > (0x200000 - 480))
- memBase = 0x200000 - 480;
-
- RefreshContents();
- }
- else if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
- {
- memBase -= 16;
-
- if (memBase < 0)
- memBase = 0;
-
- RefreshContents();
- }
- else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
- {
- memBase += 16;
-
- if (memBase > (0x200000 - 480))
- memBase = 0x200000 - 480;
-
- RefreshContents();
+ hide();
}
}
-#endif
-
-
-#if 0
-void AllWatchBrowserWindow::GoToAddress(void)
-{
- bool ok;
- QString newAddress = address->text();
- memBase = newAddress.toUInt(&ok, 16);
- RefreshContents();
-}
-#endif