X-Git-Url: http://git.hcoop.net/clinton/Virtual-Jaguar-Rx.git/blobdiff_plain/0203b5fd6f49dbc4f4244417c095882eb9882d49..570dad923e20ad098263df653287a08f5473427a:/src/debugger/localbrowser.cpp diff --git a/src/debugger/localbrowser.cpp b/src/debugger/localbrowser.cpp index 3b8d816..35b858d 100644 --- a/src/debugger/localbrowser.cpp +++ b/src/debugger/localbrowser.cpp @@ -21,39 +21,18 @@ // 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) { 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); - 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); layout->addWidget(text); -// layout->addWidget(refresh); -// layout->addLayout(hbox1); - -// connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents())); -// connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress())); } @@ -62,7 +41,6 @@ LocalBrowserWindow::~LocalBrowserWindow(void) { free(LocalInfo); free(FuncName); -// NbLocal = 0; } @@ -78,21 +56,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)) { - 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].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); + } + } } } } @@ -111,36 +95,30 @@ bool LocalBrowserWindow::UpdateInfos(void) void LocalBrowserWindow::RefreshContents(void) { char string[1024]; -// char buf[64]; QString Local; char Value[100]; 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()) { 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) { - if (((LocalInfo[i].Op >= DBG_OP_breg0) && (LocalInfo[i].Op <= DBG_OP_breg31))) + // Local or parameters variables + if (((LocalInfo[i].Op >= DBG_OP_breg0) && (LocalInfo[i].Op <= DBG_OP_breg31)) || (LocalInfo[i].Op == DBG_OP_fbreg)) { LocalInfo[i].Adr = m68k_get_reg(NULL, M68K_REG_A6) + LocalInfo[i].Offset; + if ((LocalInfo[i].Op == DBG_OP_fbreg)) + { + LocalInfo[i].Adr += 8; + } + if ((LocalInfo[i].Adr >= 0) && (LocalInfo[i].Adr < vjs.DRAM_size)) { PtrValue = DBGManager_GetVariableValueFromAdr(LocalInfo[i].Adr, LocalInfo[i].TypeEncoding, LocalInfo[i].TypeByteSize); @@ -152,8 +130,10 @@ void LocalBrowserWindow::RefreshContents(void) } else { + // Value from CPU register 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); } else @@ -162,19 +142,33 @@ 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) + if (!LocalInfo[i].Op) { - sprintf(string, "0x%06X", (unsigned int)LocalInfo[i].Adr); + sprintf(string, "%i : %s | %s | [Not used]", (i + 1), (LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"N/A"), LocalInfo[i].PtrVariableName); } else { - sprintf(string, "%s", (char *)"N/A"); + 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, "0x%06X", (unsigned int)LocalInfo[i].Adr); + } + else + { + 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)); } Local += QString(string); - sprintf(string, " | %s", (!PtrValue ? (char *)"N/A" : PtrValue)); - Local += QString(string); sprintf(string, "
"); Local += QString(string); } @@ -191,58 +185,11 @@ void LocalBrowserWindow::RefreshContents(void) } -#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 -