X-Git-Url: http://git.hcoop.net/clinton/Virtual-Jaguar-Rx.git/blobdiff_plain/169c1409e2a4b4f5d733ccddb928ba8b775bcc86..79a018fa160ead41dc5ea29a3939531f0e4a7e21:/src/debugger/localbrowser.cpp diff --git a/src/debugger/localbrowser.cpp b/src/debugger/localbrowser.cpp index 77e7102..9c59b43 100644 --- a/src/debugger/localbrowser.cpp +++ b/src/debugger/localbrowser.cpp @@ -8,6 +8,14 @@ // Who When What // --- ---------- ----------------------------------------------------------- // JPM 11/03/2017 Created this file +// JPM 09/08/2018 Added a status bar and better status report +// JPM 09/08/2018 Set information values in a tab +// + +// STILL TO DO: +// Feature to list the pointer(s) in the code using the allocation +// To set the information display at the right +// To support the array // @@ -20,40 +28,47 @@ // LocalBrowserWindow::LocalBrowserWindow(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), - NbLocal(0), - FuncName((char *)calloc(1, 1)), - LocalInfo(NULL) +layout(new QVBoxLayout), +#ifdef LOCAL_LAYOUTTEXTS +text(new QTextBrowser), +#else +TableView(new QTableView), +model(new QStandardItemModel), +#endif +NbLocal(0), +FuncName((char *)calloc(1, 1)), +LocalInfo(NULL), +statusbar(new QStatusBar) { - setWindowTitle(tr("Local")); - -// 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); + setWindowTitle(tr("Locals")); + // 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 LOCAL_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); } @@ -62,7 +77,6 @@ LocalBrowserWindow::~LocalBrowserWindow(void) { free(LocalInfo); free(FuncName); -// NbLocal = 0; } @@ -78,23 +92,27 @@ bool LocalBrowserWindow::UpdateInfos(void) { if (strcmp(FuncName, Ptr)) { - FuncName = (char *)realloc(FuncName, strlen(Ptr) + 1); - strcpy(FuncName, Ptr); - - LocalInfo = (WatchInfo *)realloc(LocalInfo, (sizeof(WatchInfo) * NbLocal)); - for (size_t i = 0; i < NbLocal; i++) + if (FuncName = (char *)realloc(FuncName, strlen(Ptr) + 1)) { - // Get local variable name and his information - if (LocalInfo[i].PtrVariableName = DBGManager_GetLocalVariableName(Adr, i + 1)) + strcpy(FuncName, Ptr); + + if (LocalInfo = (WatchInfo *)realloc(LocalInfo, (sizeof(WatchInfo) * NbLocal))) { - LocalInfo[i].Op = DBGManager_GetLocalVariableOp(Adr, i + 1); - LocalInfo[i].Adr = NULL; - LocalInfo[i].PtrCPURegisterName = NULL; - LocalInfo[i].TypeTag = DBGManager_GetLocalVariableTypeTag(Adr, i + 1); - LocalInfo[i].PtrVariableBaseTypeName = DBGManager_GetLocalVariableTypeName(Adr, i + 1); - LocalInfo[i].TypeEncoding = DBGManager_GetLocalVariableTypeEncoding(Adr, i + 1); - LocalInfo[i].TypeByteSize = DBGManager_GetLocalVariableTypeByteSize(Adr, i + 1); - LocalInfo[i].Offset = DBGManager_GetLocalVariableOffset(Adr, i + 1); + for (size_t i = 0; i < NbLocal; i++) + { + // Get local variable name and his information + if (LocalInfo[i].PtrVariableName = DBGManager_GetLocalVariableName(Adr, i + 1)) + { + LocalInfo[i].Op = DBGManager_GetLocalVariableOp(Adr, i + 1); + LocalInfo[i].Adr = NULL; + LocalInfo[i].PtrCPURegisterName = NULL; + LocalInfo[i].TypeTag = DBGManager_GetLocalVariableTypeTag(Adr, i + 1); + LocalInfo[i].PtrVariableBaseTypeName = DBGManager_GetLocalVariableTypeName(Adr, i + 1); + LocalInfo[i].TypeEncoding = DBGManager_GetLocalVariableTypeEncoding(Adr, i + 1); + LocalInfo[i].TypeByteSize = DBGManager_GetLocalVariableTypeByteSize(Adr, i + 1); + LocalInfo[i].Offset = DBGManager_GetLocalVariableOffset(Adr, i + 1); + } + } } } } @@ -112,35 +130,40 @@ bool LocalBrowserWindow::UpdateInfos(void) // void LocalBrowserWindow::RefreshContents(void) { +#ifdef LOCAL_LAYOUTTEXTS char string[1024]; -// char buf[64]; +#endif + size_t Error = LOCAL_NOERROR; QString Local; + QString MSG; + char Value1[100]; +#ifdef LOCAL_SUPPORTARRAY char Value[100]; +#endif char *PtrValue; -// size_t NbWatch, Adr; -// WatchInfo PtrLocalInfo; const char *CPURegName[] = { "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7" }; if (isVisible()) { +#ifndef LOCAL_LAYOUTTEXTS + model->setRowCount(0); +#endif if (UpdateInfos()) { -//#ifdef _MSC_VER - //#pragma message("Warning: !!! Need to check the memory desalocation for LocalInfo !!!") -//#else - //#warning "!!! Need to do the memory desalocation for LocalInfo !!!" -//#endif // _MSC_VER -//#ifdef _MSC_VER - //#pragma message("Warning: !!! Need to check the memory desalocation for FuncName !!!") -//#else - //#warning "!!! Need to do the memory desalocation for FuncName !!!" -//#endif // _MSC_VER - for (size_t i = 0; i < NbLocal; i++) { if (LocalInfo[i].PtrVariableName) { + memset(Value1, 0, sizeof(Value1)); +#ifdef LOCAL_LAYOUTTEXTS + if (i) + { + Local += QString("
"); + } +#else + model->insertRow(i); +#endif // Local or parameters variables if (((LocalInfo[i].Op >= DBG_OP_breg0) && (LocalInfo[i].Op <= DBG_OP_breg31)) || (LocalInfo[i].Op == DBG_OP_fbreg)) { @@ -153,7 +176,25 @@ void LocalBrowserWindow::RefreshContents(void) if ((LocalInfo[i].Adr >= 0) && (LocalInfo[i].Adr < vjs.DRAM_size)) { - PtrValue = DBGManager_GetVariableValueFromAdr(LocalInfo[i].Adr, LocalInfo[i].TypeEncoding, LocalInfo[i].TypeByteSize); + if ((LocalInfo[i].TypeTag & (DBG_TAG_TYPE_array | DBG_TAG_TYPE_structure))) + { +#if defined(LOCAL_SUPPORTARRAY) || defined(LOCAL_SUPPORTSTRUCTURE) + //memcpy(Value1, &jaguarMainRAM[LocalInfo[i].Adr], 20); +#ifdef LOCAL_LAYOUTTEXTS + //sprintf(Value, "\"%s\"", Value1); +#else + //sprintf(Value, "0x%06X, \"%s\"", LocalInfo[i].Adr, Value1); +#endif + //PtrValue = Value; + PtrValue = NULL; +#else + PtrValue = NULL; +#endif + } + else + { + PtrValue = DBGManager_GetVariableValueFromAdr(LocalInfo[i].Adr, LocalInfo[i].TypeEncoding, LocalInfo[i].TypeByteSize); + } } else { @@ -166,7 +207,7 @@ void LocalBrowserWindow::RefreshContents(void) if ((LocalInfo[i].Op >= DBG_OP_reg0) && (LocalInfo[i].Op <= DBG_OP_reg31)) { LocalInfo[i].PtrCPURegisterName = (char *)CPURegName[(LocalInfo[i].Op - DBG_OP_reg0)]; - PtrValue = itoa(m68k_get_reg(NULL, (m68k_register_t)((size_t)M68K_REG_D0 + (LocalInfo[i].Op - DBG_OP_reg0))), Value, 10); + PtrValue = itoa(m68k_get_reg(NULL, (m68k_register_t)((size_t)M68K_REG_D0 + (LocalInfo[i].Op - DBG_OP_reg0))), Value1, 10); } else { @@ -174,94 +215,95 @@ void LocalBrowserWindow::RefreshContents(void) } } - sprintf(string, "%i : %s | %s | ", (i + 1), (LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"N/A"), LocalInfo[i].PtrVariableName); - Local += QString(string); - if ((unsigned int)LocalInfo[i].Adr) +#ifndef LOCAL_LAYOUTTEXTS + model->setItem(i, 0, new QStandardItem(QString("%1").arg(LocalInfo[i].PtrVariableName))); +#endif + // Check if the local variable is use by the code + if (!LocalInfo[i].Op) { - sprintf(string, "0x%06X", (unsigned int)LocalInfo[i].Adr); +#ifdef LOCAL_LAYOUTTEXTS + sprintf(string, "%i : %s | %s | [Not used]", (i + 1), (LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"N/A"), LocalInfo[i].PtrVariableName); +#else +#endif } else { - if (LocalInfo[i].PtrCPURegisterName) +#ifndef LOCAL_LAYOUTTEXTS + model->setItem(i, 1, new QStandardItem(QString("%1").arg(PtrValue))); +#else + sprintf(string, "%i : %s | %s | ", (i + 1), (LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"N/A"), LocalInfo[i].PtrVariableName); + Local += QString(string); + + if ((unsigned int)LocalInfo[i].Adr) { - sprintf(string, "%s", LocalInfo[i].PtrCPURegisterName); + sprintf(string, "0x%06X", (unsigned int)LocalInfo[i].Adr); } else { - sprintf(string, "%s", (char *)"N/A"); - } + if (LocalInfo[i].PtrCPURegisterName) + { + sprintf(string, "%s", LocalInfo[i].PtrCPURegisterName); + } + else + { + sprintf(string, "%s", (char *)"N/A"); + } + } + + Local += QString(string); + sprintf(string, " | %s", (!PtrValue ? (char *)"N/A" : PtrValue)); +#endif } +#ifndef LOCAL_LAYOUTTEXTS + model->setItem(i, 2, new QStandardItem(QString("%1").arg((LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"N/A")))); +#else Local += QString(string); - sprintf(string, " | %s", (!PtrValue ? (char *)"N/A" : PtrValue)); - Local += QString(string); - sprintf(string, "
"); - Local += QString(string); +#endif } } + MSG += QString("Ready"); +#ifdef LOCAL_LAYOUTTEXTS text->clear(); text->setText(Local); +#endif } else { + // No locals + MSG += QString("No locals"); + Error = LOCAL_NOLOCALS; +#ifdef LOCAL_LAYOUTTEXTS text->clear(); +#endif } + + // Display status bar + if (Error) + { + if ((Error & LOCAL_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(MSG); } } -#if 0 +// void LocalBrowserWindow::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 LocalBrowserWindow::GoToAddress(void) -{ - bool ok; - QString newAddress = address->text(); - memBase = newAddress.toUInt(&ok, 16); - RefreshContents(); -} -#endif -