Added a Local browser window for local variables
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / brkWin.cpp
index becd7d8..8ad3cc8 100644 (file)
-//
-// brkWin.cpp - Breakpoints
-//
-// by Jean-Paul Mari
-//
-// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
-//
-// Who  When        What
-// ---  ----------  -----------------------------------------------------------
-// JPM  30/08/2017  Created this file
-//
-
-// STILL TO DO:
-//
-
-#include "debugger/brkWin.h"
-//#include "memory.h"
-#include "debugger/DBGManager.h"
-
-
-//
-BrkWindow::BrkWindow(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)
-{
-       setWindowTitle(tr("Breakpoints window"));
-
-#if 0
-//     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()));
-#endif
-}
-
-
-//
-BrkWindow::~BrkWindow(void)
-{
-#if 0
-       NbWatch = 0;
-       free(PtrWatchInfo);
-#endif
-}
-
-
-//
-void BrkWindow::RefreshContents(void)
-{
-#if 0
-       char string[1024];
-//     char buf[64];
-       QString WatchAll;
-
-       if (isVisible())
-       {
-               if (!NbWatch)
-               {
-                       if (NbWatch = DBGManager_GetNbExternalVariables())
-                       {
-                               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++)
-                               {
-                                       PtrWatchInfo[i].PtrVariableName = DBGManager_GetExternalVariableName(i + 1);
-                                       PtrWatchInfo[i].addr = DBGManager_GetExternalVariableAdr(i + 1);
-                                       PtrWatchInfo[i].TypeTag = DBGManager_GetExternalVariableTypeTag(i + 1);
-                                       if (!strlen(PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetExternalVariableTypeName(i + 1)))
-                                       {
-                                               PtrWatchInfo[i].PtrVariableBaseTypeName = (char *)"<font color='#ff0000'>N/A</font>";
-                                       }
-                               }
-                       }
-               }
-
-               for (uint32_t i = 0; i < NbWatch; i++)
-               {
-                       if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName)
-                       {
-                               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));
-                               WatchAll += QString(string);
-                               sprintf(string, "<br>");
-                               WatchAll += QString(string);
-                       }
-               }
-
-               text->clear();
-               text->setText(WatchAll);
-       }
-#endif
-}
-
-
-//
-void BrkWindow::keyPressEvent(QKeyEvent * e)
-{
-       if (e->key() == Qt::Key_Escape)
-       {
-               hide();
-       }
-       else
-       {
-               if (e->key() == Qt::Key_PageUp)
-               {
-#if 0
-                       memBase -= 480;
-
-                       if (memBase < 0)
-                               memBase = 0;
-
-                       RefreshContents();
-#endif
-               }
-               else
-               {
-                       if (e->key() == Qt::Key_PageDown)
-                       {
-#if 0
-                               memBase += 480;
-
-                               if (memBase > (0x200000 - 480))
-                                       memBase = 0x200000 - 480;
-
-                               RefreshContents();
-#endif
-                       }
-                       else
-                       {
-                               if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)
-                               {
-#if 0
-                                       memBase -= 16;
-
-                                       if (memBase < 0)
-                                               memBase = 0;
-
-                                       RefreshContents();
-#endif
-                               }
-                               else
-                               {
-                                       if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)
-                                       {
-#if 0
-                                               memBase += 16;
-
-                                               if (memBase > (0x200000 - 480))
-                                                       memBase = 0x200000 - 480;
-
-                                               RefreshContents();
-#endif
-                                       }
-                                       else
-                                       {
-                                               if (e->key() == Qt::Key_Return)
-                                               {
-                                                       GoToAddress();
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-}
-
-
-//
-void BrkWindow::RefreshBrkList(size_t Address)
-{
-}
-
-
-// Go to the requested address
-// Address can be an hexa, decimal or a symbol name
-void BrkWindow::GoToAddress(void)
-{
-       size_t Address;
-       bool ok;
-       QString newAddress;
-
-       newAddress = address->text();
-
-       if ((newAddress.at(0) == QChar('0')) && (newAddress.at(1) == QChar('x')))
-       {
-               Address = newAddress.toUInt(&ok, 16);
-       }
-       else
-       {
-               if (!(Address = DBGManager_GetAdrFromSymbolName(newAddress.toLatin1().data())))
-               {
-                       Address = newAddress.toUInt(&ok, 10);
-               }
-       }
-
-       RefreshBrkList(Address);
-}
-
+//\r
+// brkWin.cpp - Breakpoints\r
+//\r
+// by Jean-Paul Mari\r
+//\r
+// JPM = Jean-Paul Mari <djipi.mari@gmail.com>\r
+//\r
+// Who  When        What\r
+// ---  ----------  -----------------------------------------------------------\r
+// JPM  30/08/2017  Created this file\r
+//\r
+\r
+// STILL TO DO:\r
+//\r
+\r
+#include "debugger/brkWin.h"\r
+//#include "memory.h"\r
+#include "debugger/DBGManager.h"\r
+\r
+\r
+//\r
+BrkWindow::BrkWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),\r
+       layout(new QVBoxLayout), text(new QTextBrowser),\r
+//     layout(new QVBoxLayout), text(new QLabel),\r
+//     refresh(new QPushButton(tr("Refresh"))),\r
+       address(new QLineEdit)\r
+//     go(new QPushButton(tr("Go"))),\r
+//     memBase(0),\r
+//     NbWatch(0),\r
+//     PtrWatchInfo(NULL)\r
+{\r
+       setWindowTitle(tr("Breakpoints window"));\r
+\r
+#if 0\r
+//     address->setInputMask("hhhhhh");\r
+//     QHBoxLayout * hbox1 = new QHBoxLayout;\r
+//     hbox1->addWidget(refresh);\r
+//     hbox1->addWidget(address);\r
+//     hbox1->addWidget(go);\r
+\r
+       // Need to set the size as well...\r
+//     resize(560, 480);\r
+\r
+       QFont fixedFont("Lucida Console", 8, QFont::Normal);\r
+//     QFont fixedFont("", 8, QFont::Normal);\r
+       fixedFont.setStyleHint(QFont::TypeWriter);\r
+       text->setFont(fixedFont);\r
+////   layout->setSizeConstraint(QLayout::SetFixedSize);\r
+       setLayout(layout);\r
+\r
+       layout->addWidget(text);\r
+//     layout->addWidget(refresh);\r
+//     layout->addLayout(hbox1);\r
+\r
+//     connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));\r
+//     connect(go, SIGNAL(clicked()), this, SLOT(GoToAddress()));\r
+#endif\r
+}\r
+\r
+\r
+//\r
+BrkWindow::~BrkWindow(void)\r
+{\r
+#if 0\r
+       NbWatch = 0;\r
+       free(PtrWatchInfo);\r
+#endif\r
+}\r
+\r
+\r
+//\r
+void BrkWindow::RefreshContents(void)\r
+{\r
+#if 0\r
+       char string[1024];\r
+//     char buf[64];\r
+       QString WatchAll;\r
+\r
+       if (isVisible())\r
+       {\r
+               if (!NbWatch)\r
+               {\r
+                       if (NbWatch = DBGManager_GetNbGlobalVariables())\r
+                       {\r
+                               PtrWatchInfo = (WatchInfo *)calloc(NbWatch, sizeof(WatchInfo));\r
+#ifdef _MSC_VER\r
+#pragma message("Warning: !!! Need to check the memory desalocation for PtrWatchInfo !!!")\r
+#else\r
+                               #warning "!!! Need to do the memory desalocation for PtrWatchInfo !!!"\r
+#endif // _MSC_VER\r
+                                       \r
+                               for (uint32_t i = 0; i < NbWatch; i++)\r
+                               {\r
+                                       PtrWatchInfo[i].PtrVariableName = DBGManager_GetGlobalVariableName(i + 1);\r
+                                       PtrWatchInfo[i].addr = DBGManager_GetExternalVariableAdr(i + 1);\r
+                                       PtrWatchInfo[i].TypeTag = DBGManager_GetExternalVariableTypeTag(i + 1);\r
+                                       if (!strlen(PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetGlobalVariableTypeName(i + 1)))\r
+                                       {\r
+                                               PtrWatchInfo[i].PtrVariableBaseTypeName = (char *)"<font color='#ff0000'>N/A</font>";\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+\r
+               for (uint32_t i = 0; i < NbWatch; i++)\r
+               {\r
+                       if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName)\r
+                       {\r
+                               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
+                               WatchAll += QString(string);\r
+                               sprintf(string, "<br>");\r
+                               WatchAll += QString(string);\r
+                       }\r
+               }\r
+\r
+               text->clear();\r
+               text->setText(WatchAll);\r
+       }\r
+#endif\r
+}\r
+\r
+\r
+//\r
+void BrkWindow::keyPressEvent(QKeyEvent * e)\r
+{\r
+       if (e->key() == Qt::Key_Escape)\r
+       {\r
+               hide();\r
+       }\r
+       else\r
+       {\r
+               if (e->key() == Qt::Key_PageUp)\r
+               {\r
+#if 0\r
+                       memBase -= 480;\r
+\r
+                       if (memBase < 0)\r
+                               memBase = 0;\r
+\r
+                       RefreshContents();\r
+#endif\r
+               }\r
+               else\r
+               {\r
+                       if (e->key() == Qt::Key_PageDown)\r
+                       {\r
+#if 0\r
+                               memBase += 480;\r
+\r
+                               if (memBase > (0x200000 - 480))\r
+                                       memBase = 0x200000 - 480;\r
+\r
+                               RefreshContents();\r
+#endif\r
+                       }\r
+                       else\r
+                       {\r
+                               if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Minus)\r
+                               {\r
+#if 0\r
+                                       memBase -= 16;\r
+\r
+                                       if (memBase < 0)\r
+                                               memBase = 0;\r
+\r
+                                       RefreshContents();\r
+#endif\r
+                               }\r
+                               else\r
+                               {\r
+                                       if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Equal)\r
+                                       {\r
+#if 0\r
+                                               memBase += 16;\r
+\r
+                                               if (memBase > (0x200000 - 480))\r
+                                                       memBase = 0x200000 - 480;\r
+\r
+                                               RefreshContents();\r
+#endif\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               if (e->key() == Qt::Key_Return)\r
+                                               {\r
+                                                       GoToAddress();\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+}\r
+\r
+\r
+//\r
+void BrkWindow::RefreshBrkList(size_t Address)\r
+{\r
+}\r
+\r
+\r
+// Go to the requested address\r
+// Address can be an hexa, decimal or a symbol name\r
+void BrkWindow::GoToAddress(void)\r
+{\r
+       size_t Address;\r
+       bool ok;\r
+       QString newAddress;\r
+\r
+       newAddress = address->text();\r
+\r
+       if ((newAddress.at(0) == QChar('0')) && (newAddress.at(1) == QChar('x')))\r
+       {\r
+               Address = newAddress.toUInt(&ok, 16);\r
+       }\r
+       else\r
+       {\r
+               if (!(Address = DBGManager_GetAdrFromSymbolName(newAddress.toLatin1().data())))\r
+               {\r
+                       Address = newAddress.toUInt(&ok, 10);\r
+               }\r
+       }\r
+\r
+       RefreshBrkList(Address);\r
+}\r
+\r