UI modifications
authorJean-Paul Mari <djipi.mari@gmail.com>
Sun, 16 Sep 2018 10:34:12 +0000 (06:34 -0400)
committerJean-Paul Mari <djipi.mari@gmail.com>
Sun, 16 Sep 2018 10:34:12 +0000 (06:34 -0400)
docs/vj_ReleaseNotes.txt
src/debugger/allwatchbrowser.cpp
src/debugger/allwatchbrowser.h
src/debugger/callstackbrowser.cpp
src/debugger/callstackbrowser.h
src/debugger/exceptionvectortablebrowser.cpp
src/debugger/exceptionvectortablebrowser.h
src/debugger/heapallocatorbrowser.cpp
src/debugger/heapallocatorbrowser.h
src/debugger/localbrowser.cpp
src/debugger/localbrowser.h

index 41643b4..5ad331e 100644 (file)
@@ -1,5 +1,7 @@
 Release 4 (TBD)\r
 ---------------\r
+Git commit: TBD\r
+-\r
 0) The zoom value setting has been fixed in the registry\r
 1) Debugger mode now shares the same alpine rom path setting\r
 2) Local variables window displays register name now\r
@@ -13,28 +15,43 @@ Release 4 (TBD)
 8) Local variables window detects now if a variable is used or not by the code\r
 9) The address provided in the memory window is now verified to prevent crash\r
 -- Wrong address will be displayed in red\r
-10) UI cosmetic changes \r
+10) UI changes \r
 -- Added new icons for the exit and status features\r
 -- Modified icons for the SP (Stack) browser\r
 -- Unified icons sizes depend on their usage (drop down menu and main menu)\r
 -- Underline the active M68K line in the disassembly window\r
 -- Allow the up/down navigation on the SP (Stack) browser\r
 -- Restart function cleans-up the SP (Stack) browser and the heap allocator system\r
-11) Fixed the up navigation on the memory window\r
-12) Added some log information for the emulator initialisations\r
-13) Breakpoint will happen in case of writing at unknown memory location\r
--- Alert box will display a message and then code will stop\r
-14) Added the DRAM size in the emulator status window\r
-15) Debugger sources code clean-up\r
-16) Added a call stack feature\r
-17) Prevent source file reading issue on no-Windows system \r
-18) UI modifications\r
+-- Fixed the up navigation on the memory window\r
+11) Added some log information for the emulator initialisations\r
+12) Breakpoint will happen in case of writing at unknown memory location\r
+-- Alert box will display a message and then the code will stop\r
+13) Added the DRAM size in the emulator status window\r
+14) Debugger sources code clean-up\r
+15) Added a call stack feature\r
+16) Follow platform requirement to prevent source file reading issue\r
+17) UI modifications\r
 -- Modified icon for the memory window to make a distinction with the memory browser\r
 -- The all watch, and Exception Vector Table windows, can be closed using keyboard\r
 -- Renamed the debugger dedicated icons to make a distinction\r
 -- Added the call stack window\r
-19) Fixed a crash in the all watch window after loading a new binary without ELF/DWARF information\r
+18) Fixed a crash in the all watch window after loading a new binary without ELF/DWARF information\r
 -- Previously used ELF/DWARF information was still accessible\r
+19) Fixed slash/backslash issue, in the Alpine tab, to follow platform requirement\r
+20) Heap allocation window uses the DRAM size limit option and detect if heap allocation shares space with SP (Stack)\r
+21) Added a Jaguar model and BIOS configuration tab\r
+22) Jaguar model and BIOS configuration integration\r
+23) Added LEB128 decoding functions\r
+-- It is used for the DWARF decoding information\r
+24) Debugger support improvement\r
+-- DWARF support for the enum type (partial), and subroutine type\r
+-- Debugger can report variable's unsigned char value\r
+25) UI modifications\r
+-- Added a status bar, better status report & information display for the heap allocation window\r
+-- Added a status bar, better status report & information display for the local variables window\r
+-- Added better information display for the exception vectors table window, and added some missing vectors\r
+-- Added a status bar, better status report & information display for the call stack window\r
+-- Added a status bar, better status report & information display for the all watches window\r
 \r
 Release 3 (13th November 2017)\r
 ------------------------------\r
@@ -133,8 +150,9 @@ Known issues
 -- Need to trace over the BPM or unset the BPM\r
 -- The issue can be prevented if the code doesn't set IRQ, otherwise the IRQ will need to be traced to get back control\r
 3) To support DWARF 2 with GCC, the code must be compiled with the -gdwarf-2 option\r
-4) The Local and Watch variables window  may display not available (N/A) type information\r
+4) The Local and Watch variables window  may display not available type information or empty information\r
 -- Such missing information may be included in future release\r
+-- The 'const' type may not be reported correctly in the DWARF information \r
 5) The 2MB mirroring is no longer applied in case of --dram-max option usage\r
 6) Stack must reflect the --dram-max option usage otherwise the stack may be corrupted\r
 -- The application needs to set the SP (Stack) in accordance\r
@@ -142,7 +160,9 @@ Known issues
 -- Missing vectors may be added in future release\r
 8) User needs to manualy check if the Atari Jaguar executable match his source code files\r
 -- Otherwise, source code and assembly may not match or leads to instabilities\r
-9) The emulator needs to be restarted in case of keybindings changes\r
+9) The emulator needs to be restarted in case of the following actions occur\r
+-- Keybindings changes\r
+-- BIOS selection changes and without new executable load\r
 10) In the case of a ROM cartridge writing, and with occuring breakpoint, the PC pointer will point at the next instruction and not at the instruction causing the breakpoint\r
 11) Emulator will crash in case of wrong address value provided in the memory browser\r
 12) The RAM access log is limited to the 2MB\r
index c7430d7..8021b7e 100644 (file)
@@ -8,12 +8,23 @@
 // Who  When        What\r
 // ---  ----------  -----------------------------------------------------------\r
 // JPM  12/07/2017  Created this file\r
+// JPM  09/14/2018  Added a status bar and better status report\r
+// JPM  09/14/2018  Set information values in a tab\r
 //\r
 \r
 // STILL TO DO:\r
 // Better presentation\r
+// To set the information display at the right\r
 //\r
 \r
+//#define AW_DEBUGNUMVARIABLE          177                                             // Set the global variable number to debug\r
+#ifndef AW_DEBUGNUMVARIABLE\r
+#define AW_STARTNUMVARIABLE            0                                                       // Must be kept to 0 in case of no debug is required\r
+#else\r
+#define AW_STARTNUMVARIABLE            AW_DEBUGNUMVARIABLE - 1\r
+#endif\r
+\r
+\r
 #include "debugger/allwatchbrowser.h"\r
 #include "memory.h"\r
 #include "debugger/DBGManager.h"\r
 \r
 // \r
 AllWatchBrowserWindow::AllWatchBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),\r
-       layout(new QVBoxLayout), text(new QTextBrowser),\r
-       NbWatch(0),\r
-       PtrWatchInfo(NULL)\r
+layout(new QVBoxLayout),\r
+#ifdef AW_LAYOUTTEXTS\r
+text(new QTextBrowser),\r
+#else\r
+TableView(new QTableView),\r
+model(new QStandardItemModel),\r
+#endif\r
+NbWatch(0),\r
+statusbar(new QStatusBar),\r
+PtrWatchInfo(NULL)\r
 {\r
        setWindowTitle(tr("All Watch"));\r
 \r
+       // Set the font\r
        QFont fixedFont("Lucida Console", 8, QFont::Normal);\r
        fixedFont.setStyleHint(QFont::TypeWriter);\r
-       text->setFont(fixedFont);\r
-       setLayout(layout);\r
 \r
+#ifdef AW_LAYOUTTEXTS\r
+       // Set original layout\r
+       text->setFont(fixedFont);\r
        layout->addWidget(text);\r
+#else\r
+       // Set the new layout with proper identation and readibility\r
+       model->setColumnCount(3);\r
+       model->setHeaderData(0, Qt::Horizontal, QObject::tr("Name"));\r
+       model->setHeaderData(1, Qt::Horizontal, QObject::tr("Value"));\r
+       model->setHeaderData(2, Qt::Horizontal, QObject::tr("Type"));\r
+       // Information table\r
+       TableView->setModel(model);\r
+       TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);\r
+       TableView->setShowGrid(0);\r
+       TableView->setFont(fixedFont);\r
+       TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());\r
+       TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);\r
+       layout->addWidget(TableView);\r
+#endif\r
+\r
+       // Status bar\r
+       layout->addWidget(statusbar);\r
+       setLayout(layout);\r
 }\r
 \r
 \r
@@ -55,44 +94,102 @@ void AllWatchBrowserWindow::Reset(void)
 //\r
 void AllWatchBrowserWindow::RefreshContents(void)\r
 {\r
+       char msg[100];\r
+#ifdef AW_LAYOUTTEXTS\r
        char string[1024];\r
+#endif\r
        QString WatchAll;\r
+       size_t Error = AW_NOERROR;\r
+       char *PtrValue;\r
 \r
        if (isVisible())\r
        {\r
-               text->clear();\r
-\r
                if (!NbWatch)\r
                {\r
+                       // Pre-catch the information for each global variables\r
                        if (NbWatch = DBGManager_GetNbGlobalVariables())\r
                        {\r
                                PtrWatchInfo = (WatchInfo *)calloc(NbWatch, sizeof(WatchInfo));\r
 \r
-                               for (uint32_t i = 0; i < NbWatch; i++)\r
+                               for (uint32_t i = AW_STARTNUMVARIABLE; i < NbWatch; i++)\r
                                {\r
                                        PtrWatchInfo[i].PtrVariableName = DBGManager_GetGlobalVariableName(i + 1);\r
-                                       PtrWatchInfo[i].addr = DBGManager_GetGlobalVariableAdr(i + 1);\r
                                        PtrWatchInfo[i].TypeTag = DBGManager_GetGlobalVariableTypeTag(i + 1);\r
+#ifdef AW_LAYOUTTEXTS\r
+                                       PtrWatchInfo[i].addr = DBGManager_GetGlobalVariableAdr(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
+#else\r
+                                       PtrWatchInfo[i].PtrVariableBaseTypeName = DBGManager_GetGlobalVariableTypeName(i + 1);\r
+#endif\r
                                }\r
                        }\r
                }\r
-\r
-               for (uint32_t i = 0; i < NbWatch; i++)\r
+#ifndef AW_LAYOUTTEXTS\r
+               model->setRowCount(0);\r
+#endif\r
+               if (NbWatch)\r
                {\r
-                       if (PtrWatchInfo[i].PtrVariableName && PtrWatchInfo[i].PtrVariableBaseTypeName)\r
+                       for (uint32_t i = AW_STARTNUMVARIABLE; i < NbWatch; i++)\r
                        {\r
-                               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));\r
-                               WatchAll += QString(string);\r
-                               sprintf(string, "<br>");\r
+                               if ((PtrWatchInfo[i].TypeTag & (DBG_TAG_TYPE_array | DBG_TAG_TYPE_structure)))\r
+                               {\r
+#if defined(AW_SUPPORTARRAY) || defined(AW_SUPPORTSTRUCTURE)\r
+                                       //PtrValue = (char *)memcpy(Value, &jaguarMainRAM[PtrWatchInfo[i].addr], 20);\r
+                                       PtrValue = NULL;\r
+#else\r
+                                       PtrValue = NULL;\r
+#endif\r
+                               }\r
+                               else\r
+                               {\r
+                                       PtrValue = DBGManager_GetGlobalVariableValue(i + 1);\r
+                               }\r
+#ifdef AW_LAYOUTTEXTS\r
+                               if (i)\r
+                               {\r
+                                       WatchAll += QString("<br>");\r
+                               }\r
+                               sprintf(string, "%i : %s | %s | 0x%06X | %s", (i + 1), PtrWatchInfo[i].PtrVariableBaseTypeName, PtrWatchInfo[i].PtrVariableName, (unsigned int)PtrWatchInfo[i].addr, PtrValue ? PtrValue : (char *)"<font color='#ff0000'>N/A</font>");\r
                                WatchAll += QString(string);\r
+#else\r
+                               model->insertRow(i);\r
+                               model->setItem(i, 0, new QStandardItem(QString("%1").arg(PtrWatchInfo[i].PtrVariableName)));\r
+                               model->setItem(i, 1, new QStandardItem(QString("%1").arg(PtrValue)));\r
+                               model->setItem(i, 2, new QStandardItem(QString("%1").arg(PtrWatchInfo[i].PtrVariableBaseTypeName)));\r
+#endif\r
                        }\r
+#ifdef AW_LAYOUTTEXTS\r
+                       text->clear();\r
+                       text->setText(WatchAll);\r
+#endif\r
+                       sprintf(msg, "Ready");\r
+               }\r
+               else\r
+               {\r
+                       sprintf(msg, "No watches");\r
+                       Error = AW_NOALLWATCH;\r
                }\r
 \r
-               text->setText(WatchAll);\r
+               // Display status bar\r
+               if (Error)\r
+               {\r
+                       if ((Error & AW_WARNING))\r
+                       {\r
+                               statusbar->setStyleSheet("background-color: lightyellow; font: bold");\r
+                       }\r
+                       else\r
+                       {\r
+                               statusbar->setStyleSheet("background-color: tomato; font: bold");\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       statusbar->setStyleSheet("background-color: lightgreen; font: bold");\r
+               }\r
+               statusbar->showMessage(QString(msg));\r
        }\r
 }\r
 \r
index e477409..63107f4 100644 (file)
@@ -7,9 +7,21 @@
 #ifndef __ALLWATCHBROWSER_H__\r
 #define __ALLWATCHBROWSER_H__\r
 \r
+//#define AW_LAYOUTTEXTS                                               // Use a layout with just texts\r
+//#define AW_SUPPORTARRAY                                              // Support array\r
+//#define AW_SUPPORTSTRUCTURE                                  // Support structure\r
+\r
 #include <QtWidgets>\r
 #include <stdint.h>\r
+
+// Error code definitions
+#define        AW_NOERROR              0x00
+#define        AW_ERROR                0x80
+#define        AW_WARNING              0x40\r
+#define        AW_NOALLWATCH   (0x01 | AW_WARNING)\r
+\r
 \r
+// \r
 class AllWatchBrowserWindow: public QWidget\r
 {\r
        Q_OBJECT\r
@@ -17,7 +29,9 @@ class AllWatchBrowserWindow: public QWidget
        //\r
        typedef struct WatchInfo\r
        {\r
+#ifdef AW_LAYOUTTEXTS\r
                size_t addr;\r
+#endif\r
                size_t TypeTag;\r
                char *PtrVariableName;\r
                char *PtrVariableBaseTypeName;\r
@@ -36,7 +50,13 @@ class AllWatchBrowserWindow: public QWidget
 \r
        private:\r
                QVBoxLayout *layout;\r
+#ifdef AW_LAYOUTTEXTS\r
                QTextBrowser *text;\r
+#else\r
+               QTableView *TableView;\r
+               QStandardItemModel *model;\r
+#endif\r
+               QStatusBar *statusbar;\r
                WatchInfo *PtrWatchInfo;\r
                size_t NbWatch;\r
 };\r
index 77fe154..c2d349e 100644 (file)
@@ -8,11 +8,11 @@
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JPM  08/31/2018  Created this file
+// JPM  09/12/2018  Added a status bar and better status report
 //
 
 // STILL TO DO:
-// Better display presentation
-// To display call function
+// To set the information display at the right
 // To use DWARF frame information
 //
 
 #include "m68000/m68kinterface.h"
 
 
-//
+// 
 CallStackBrowserWindow::CallStackBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
-       layout(new QVBoxLayout), text(new QTextBrowser)
+#ifdef CS_LAYOUTTEXTS
+text(new QTextBrowser),
+#else
+TableView(new QTableView),
+model(new QStandardItemModel),
+#endif
+statusbar(new QStatusBar),
+layout(new QVBoxLayout)
 {
        setWindowTitle(tr("Call Stack"));
 
+       // Set the font
        QFont fixedFont("Lucida Console", 8, QFont::Normal);
        fixedFont.setStyleHint(QFont::TypeWriter);
-       text->setFont(fixedFont);
-       setLayout(layout);
 
+#ifdef CS_LAYOUTTEXTS
+       // Set original layout
+       text->setFont(fixedFont);
        layout->addWidget(text);
+#else
+       // Set the new layout with proper identation and readibility
+       model->setColumnCount(2);
+       model->setHeaderData(0, Qt::Horizontal, QObject::tr("Name"));
+       model->setHeaderData(1, Qt::Horizontal, QObject::tr("Line"));
+       // 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
+
+       // Status bar
+       layout->addWidget(statusbar);
+       setLayout(layout);
 }
 
 
-//
+// 
 CallStackBrowserWindow::~CallStackBrowserWindow(void)
 {
 }
 
 
-//
+// 
 void CallStackBrowserWindow::RefreshContents(void)
 {
+       char msg[1024];
+       size_t Error = CS_NOERROR;
        unsigned int a6, Sa6, ret;
        char *FuncName;
+#ifdef CS_LAYOUTTEXTS
        QString CallStack;
        char string[1024];
+#else
+       size_t NbRaw = 0;
+       QString FunctionName;
+#endif
 
        if (isVisible())
        {
+#ifndef CS_LAYOUTTEXTS
+               model->setRowCount(0);
+#endif
                if ((a6 = m68k_get_reg(NULL, M68K_REG_A6)) && DBGManager_GetType())
                {
                        while ((Sa6 = a6))
                        {
                                a6 = GET32(jaguarMainRAM, Sa6);
                                ret = GET32(jaguarMainRAM, Sa6 + 4);
-
-                               sprintf(string, "0x%06X | Ret: 0x%06X | From: %s - 0x%06X", Sa6, ret, (FuncName = DBGManager_GetFunctionName(ret)), (unsigned int)DBGManager_GetAdrFromSymbolName(FuncName));
+#ifdef CS_LAYOUTTEXTS
+                               sprintf(string, "0x%06X | Ret: 0x%06X | From: %s - 0x%06X | Line: %s", Sa6, ret, (FuncName = DBGManager_GetFunctionName(ret)), (unsigned int)DBGManager_GetAdrFromSymbolName(FuncName), DBGManager_GetLineSrcFromAdr(ret, DBG_NO_TAG));
                                CallStack += QString(string);
                                if (a6)
                                {
-                                       sprintf(string, "<br>");
-                                       CallStack += QString(string);
+                                       CallStack += QString("<br>");
                                }
+#else
+                               model->insertRow(NbRaw);
+                               model->setItem(NbRaw, 0, new QStandardItem(QString("%1").arg((FuncName = DBGManager_GetFunctionName(ret)) ? FuncName : "(null)")));
+                               FunctionName = QString(FuncName = DBGManager_GetLineSrcFromAdr(ret, DBG_NO_TAG));
+                               FunctionName.replace("&nbsp;", " ");
+                               model->setItem(NbRaw++, 1, new QStandardItem(QString("%1").arg(FuncName ? FunctionName : "(null)")));
+#endif
                        }
-
+#ifdef CS_LAYOUTTEXTS
                        text->clear();
                        text->setText(CallStack);
+#endif
+                       sprintf(msg, "Ready");
+                       Error = CS_NOERROR;
                }
                else
                {
+                       sprintf(msg, "Call Stack not available");
+                       Error = CS_NOCALLSTACK;
+#ifdef CS_LAYOUTTEXTS
                        text->clear();
+#endif
+               }
+
+               // Display status bar
+               if (Error)
+               {
+                       if ((Error & CS_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));
        }
 }
 
 
-//
+// 
 void CallStackBrowserWindow::keyPressEvent(QKeyEvent * e)
 {
        if (e->key() == Qt::Key_Escape)
index 8ae56f1..91223f1 100644 (file)
@@ -7,9 +7,19 @@
 #ifndef __CALLSTACKBROWSER_H__
 #define __CALLSTACKBROWSER_H__
 
+//#define CS_LAYOUTTEXTS                                               // Use a layout with just texts
+
 #include <QtWidgets>
 #include <stdint.h>
 
+// Error code definitions
+#define        CS_NOERROR              0x00
+#define        CS_ERROR                0x80
+#define        CS_WARNING              0x40
+#define        CS_NOCALLSTACK  (0x01 | CS_WARNING)
+
+
+// 
 class CallStackBrowserWindow : public QWidget
 {
        Q_OBJECT
@@ -26,7 +36,13 @@ class CallStackBrowserWindow : public QWidget
 
        private:
                QVBoxLayout *layout;
+               QStatusBar *statusbar;
+#ifdef CS_LAYOUTTEXTS
                QTextBrowser * text;
+#else
+               QTableView *TableView;
+               QStandardItemModel *model;
+#endif
 };
 
 #endif // __CALLSTACKBROWSER_H__
dissimilarity index 72%
index e7fd51b..2324ac7 100644 (file)
-//
-// exceptionvectortable.cpp - Exception Vector Table
-//
-// by Jean-Paul Mari
-//
-// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
-//
-// Who  When        What
-// ---  ----------  -----------------------------------------------------------
-// JPM  05/09/2017  Created this file
-//
-
-// STILL TO DO:
-// Better display presentation
-//
-
-#include "debugger/exceptionvectortablebrowser.h"
-#include "memory.h"
-#include "debugger/DBGManager.h"
-
-
-//
-struct ExceptionVectorTable
-{
-       size_t VectorNumber;
-       size_t Address;
-       const char *ExceptionName;
-}S_ExceptionVectorTable;
-
-
-ExceptionVectorTable   TabExceptionVectorTable[] =     {
-                                                                                                               {       0, 0x000000, "RESET - Initial SSP"                              },
-                                                                                                               {       1, 0x000004, "RESET - Initial PC"                               },
-                                                                                                               {       2, 0x000008, "Bus error"                                                },
-                                                                                                               {       3, 0x00000C, "Address error"                                    },
-                                                                                                               {       4, 0x000010, "Illegal instruction"                              },
-                                                                                                               {       5, 0x000014, "Division by zero"                                 },
-                                                                                                               {       6, 0x000018, "CHK instruction"                                  },
-                                                                                                               {       7, 0x00001C, "TRAPV instruction"                                },
-                                                                                                               {       8, 0x000020, "Privilege violation"                              },
-                                                                                                               {       9, 0x000024, "Trace"                                                    },
-                                                                                                               {       10, 0x000028, "Unimplemented instruction"               },
-                                                                                                               {       11, 0x00002C, "Unimplemented instruction"               },
-                                                                                                               {       12, 0x000030, "Reserved by Motorola"                    },
-                                                                                                               {       13, 0x000034, "Reserved by Motorola"                    },
-                                                                                                               {       14, 0x000038, "Reserved by Motorola"                    },
-                                                                                                               {       15, 0x00003C, "Uninitialised interrupt vector"  },
-                                                                                                               {       16, 0x000040, "Reserved by Motorola"                    },
-                                                                                                               {       17, 0x000044, "Reserved by Motorola"                    },
-                                                                                                               {       18, 0x000048, "Reserved by Motorola"                    },
-                                                                                                               {       19, 0x00004C, "Reserved by Motorola"                    },
-                                                                                                               {       20, 0x000050, "Reserved by Motorola"                    },
-                                                                                                               {       21, 0x000054, "Reserved by Motorola"                    },
-                                                                                                               {       22, 0x000058, "Reserved by Motorola"                    },
-                                                                                                               {       23, 0x00005C, "Reserved by Motorola"                    },
-                                                                                                               {       24, 0x000060, "Spurious interrupt"                              },
-                                                                                                               {       25, 0x000064, "Level 1 interrupt autovector"    },
-                                                                                                               {       26, 0x000068, "Level 2 interrupt autovector"    },
-                                                                                                               {       27, 0x00006C, "Level 3 interrupt autovector"    },
-                                                                                                               {       28, 0x000070, "Level 4 interrupt autovector"    },
-                                                                                                               {       29, 0x000074, "Level 5 interrupt autovector"    },
-                                                                                                               {       30, 0x000078, "Level 6 interrupt autovector"    },
-                                                                                                               {       31, 0x00007C, "Level 7 interrupt autovector"    },
-                                                                                                               {       32, 0x000080, "TRAP #0 instruction"                             },
-                                                                                                               {       33, 0x000084, "TRAP #1 instruction"                             },
-                                                                                                               {       34, 0x000088, "TRAP #2 instruction"                             },
-                                                                                                               {       35, 0x00008C, "TRAP #3 instruction"                             },
-                                                                                                               {       36, 0x000090, "TRAP #4 instruction"                             },
-                                                                                                               {       37, 0x000094, "TRAP #5 instruction"                             },
-                                                                                                               {       38, 0x000098, "TRAP #6 instruction"                             },
-                                                                                                               {       39, 0x00009C, "TRAP #7 instruction"                             },
-                                                                                                               {       40, 0x0000A0, "TRAP #8 instruction"                             },
-                                                                                                               {       41, 0x0000A4, "TRAP #9 instruction"                             },
-                                                                                                               {       42, 0x0000A8, "TRAP #10 instruction"                    },
-                                                                                                               {       43, 0x0000AC, "TRAP #11 instruction"                    },
-                                                                                                               {       44, 0x0000B0, "TRAP #12 instruction"                    },
-                                                                                                               {       45, 0x0000B4, "TRAP #13 instruction"                    },
-                                                                                                               {       46, 0x0000B8, "TRAP #14 instruction"                    },
-                                                                                                               {       47, 0x0000BC, "TRAP #15 instruction"                    },
-                                                                                                               {       48, 0x0000C0, "Reserved by Motorola"                    },
-                                                                                                               {       49, 0x0000C4, "Reserved by Motorola"                    },
-                                                                                                               {       50, 0x0000C8, "Reserved by Motorola"                    },
-                                                                                                               {       51, 0x0000CC, "Reserved by Motorola"                    },
-                                                                                                               {       52, 0x0000D0, "Reserved by Motorola"                    },
-                                                                                                               {       53, 0x0000D4, "Reserved by Motorola"                    },
-                                                                                                               {       54, 0x0000D8, "Reserved by Motorola"                    },
-                                                                                                               {       55, 0x0000DC, "Reserved by Motorola"                    },
-                                                                                                               {       56, 0x0000E0, "Reserved by Motorola"                    },
-                                                                                                               {       57, 0x0000E4, "Reserved by Motorola"                    },
-                                                                                                               {       58, 0x0000E8, "Reserved by Motorola"                    },
-                                                                                                               {       59, 0x0000EC, "Reserved by Motorola"                    },
-                                                                                                               {       60, 0x0000F0, "Reserved by Motorola"                    },
-                                                                                                               {       61, 0x0000F4, "Reserved by Motorola"                    },
-                                                                                                               {       62, 0x0000F8, "Reserved by Motorola"                    },
-                                                                                                               {       63, 0x0000FC, "Reserved by Motorola"                    },
-                                                                                                               {       64, 0x000100, "User interrupt vectors"                  },
-                                                                                                               {       255, 0x0003FC, "User interrupt vectors"                 }
-                                                                                                       };
-
-
-ExceptionVectorTableBrowserWindow::ExceptionVectorTableBrowserWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
-       layout(new QVBoxLayout), text(new QTextBrowser),
-       refresh(new QPushButton(tr("Refresh")))
-{
-       setWindowTitle(tr("Exception Vector Table"));
-
-       QHBoxLayout *hbox1 = new QHBoxLayout;
-       hbox1->addWidget(refresh);
-
-       QFont fixedFont("Lucida Console", 8, QFont::Normal);
-       fixedFont.setStyleHint(QFont::TypeWriter);
-       text->setFont(fixedFont);
-       setLayout(layout);
-
-       layout->addWidget(text);
-       layout->addWidget(refresh);
-
-       connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
-}
-
-
-//
-ExceptionVectorTableBrowserWindow::~ExceptionVectorTableBrowserWindow(void)
-{
-}
-
-
-//
-void ExceptionVectorTableBrowserWindow::RefreshContents(void)
-{
-       char string[1024];
-       QString ExceptionVector;
-       size_t i;
-
-       if (isVisible())
-       {
-               for (i = 0; i < (sizeof(TabExceptionVectorTable) / sizeof(ExceptionVectorTable)); i++)
-               {
-                       sprintf(string, "%03i : 0x%06X | 0x%06X | %s<br>", (unsigned int)TabExceptionVectorTable[i].VectorNumber, (unsigned int)TabExceptionVectorTable[i].Address, GET32(jaguarMainRAM, TabExceptionVectorTable[i].Address), TabExceptionVectorTable[i].ExceptionName);
-                       ExceptionVector += QString(string);
-               }
-
-               text->clear();
-               text->setText(ExceptionVector);
-       }
-}
-
-
-void ExceptionVectorTableBrowserWindow::keyPressEvent(QKeyEvent * e)
-{
-       if (e->key() == Qt::Key_Escape)
-       {
-               hide();
-       }
-}
+//
+// exceptionvectortable.cpp - Exception Vector Table
+//
+// by Jean-Paul Mari
+//
+// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JPM  05/09/2017  Created this file
+// JPM  09/09/2018  Set information values in a tab
+// JPM  09/09/2018  Added vectors in the table
+//
+
+// STILL TO DO:
+// To set the information display at the right
+//
+
+
+#include "debugger/exceptionvectortablebrowser.h"
+#include "memory.h"
+#include "debugger/DBGManager.h"
+
+
+//
+struct ExceptionVectorTable
+{
+       size_t VectorNumber;
+       size_t Address;
+       const char *ExceptionName;
+}
+S_ExceptionVectorTable;
+
+//
+ExceptionVectorTable   TabExceptionVectorTable[] =     {
+                                                                                                               { 0, 0x000000, "RESET - Initial SSP" },
+                                                                                                               { 1, 0x000004, "RESET - Initial PC" },
+                                                                                                               { 2, 0x000008, "Bus error" },
+                                                                                                               { 3, 0x00000C, "Address error" },
+                                                                                                               { 4, 0x000010, "Illegal instruction" },
+                                                                                                               { 5, 0x000014, "Division by zero" },
+                                                                                                               { 6, 0x000018, "CHK instruction" },
+                                                                                                               { 7, 0x00001C, "TRAPV instruction" },
+                                                                                                               { 8, 0x000020, "Privilege violation" },
+                                                                                                               { 9, 0x000024, "Trace" },
+                                                                                                               { 10, 0x000028, "Unimplemented instruction"     },
+                                                                                                               { 11, 0x00002C, "Unimplemented instruction"     },
+                                                                                                               { 12, 0x000030, "Reserved by Motorola" },
+                                                                                                               { 13, 0x000034, "Reserved by Motorola" },
+                                                                                                               { 14, 0x000038, "Reserved by Motorola" },
+                                                                                                               { 15, 0x00003C, "Uninitialised interrupt vector" },
+                                                                                                               { 16, 0x000040, "Reserved by Motorola" },
+                                                                                                               { 17, 0x000044, "Reserved by Motorola" },
+                                                                                                               { 18, 0x000048, "Reserved by Motorola" },
+                                                                                                               { 19, 0x00004C, "Reserved by Motorola" },
+                                                                                                               { 20, 0x000050, "Reserved by Motorola" },
+                                                                                                               { 21, 0x000054, "Reserved by Motorola" },
+                                                                                                               { 22, 0x000058, "Reserved by Motorola" },
+                                                                                                               { 23, 0x00005C, "Reserved by Motorola" },
+                                                                                                               { 24, 0x000060, "Spurious interrupt" },
+                                                                                                               { 25, 0x000064, "Level 1 interrupt autovector" },
+                                                                                                               { 26, 0x000068, "Level 2 interrupt autovector" },
+                                                                                                               { 27, 0x00006C, "Level 3 interrupt autovector" },
+                                                                                                               { 28, 0x000070, "Level 4 interrupt autovector" },
+                                                                                                               { 29, 0x000074, "Level 5 interrupt autovector" },
+                                                                                                               { 30, 0x000078, "Level 6 interrupt autovector" },
+                                                                                                               { 31, 0x00007C, "Level 7 interrupt autovector" },
+                                                                                                               { 32, 0x000080, "TRAP #0 instruction" },
+                                                                                                               { 33, 0x000084, "TRAP #1 instruction" },
+                                                                                                               { 34, 0x000088, "TRAP #2 instruction" },
+                                                                                                               { 35, 0x00008C, "TRAP #3 instruction" },
+                                                                                                               { 36, 0x000090, "TRAP #4 instruction" },
+                                                                                                               { 37, 0x000094, "TRAP #5 instruction" },
+                                                                                                               { 38, 0x000098, "TRAP #6 instruction" },
+                                                                                                               { 39, 0x00009C, "TRAP #7 instruction" },
+                                                                                                               { 40, 0x0000A0, "TRAP #8 instruction" },
+                                                                                                               { 41, 0x0000A4, "TRAP #9 instruction" },
+                                                                                                               { 42, 0x0000A8, "TRAP #10 instruction" },
+                                                                                                               { 43, 0x0000AC, "TRAP #11 instruction" },
+                                                                                                               { 44, 0x0000B0, "TRAP #12 instruction" },
+                                                                                                               { 45, 0x0000B4, "TRAP #13 instruction" },
+                                                                                                               { 46, 0x0000B8, "TRAP #14 instruction" },
+                                                                                                               { 47, 0x0000BC, "TRAP #15 instruction" },
+                                                                                                               { 48, 0x0000C0, "Reserved by Motorola" },
+                                                                                                               { 49, 0x0000C4, "Reserved by Motorola" },
+                                                                                                               { 50, 0x0000C8, "Reserved by Motorola" },
+                                                                                                               { 51, 0x0000CC, "Reserved by Motorola" },
+                                                                                                               { 52, 0x0000D0, "Reserved by Motorola" },
+                                                                                                               { 53, 0x0000D4, "Reserved by Motorola" },
+                                                                                                               { 54, 0x0000D8, "Reserved by Motorola" },
+                                                                                                               { 55, 0x0000DC, "Reserved by Motorola" },
+                                                                                                               { 56, 0x0000E0, "Reserved by Motorola" },
+                                                                                                               { 57, 0x0000E4, "Reserved by Motorola" },
+                                                                                                               { 58, 0x0000E8, "Reserved by Motorola" },
+                                                                                                               { 59, 0x0000EC, "Reserved by Motorola" },
+                                                                                                               { 60, 0x0000F0, "Reserved by Motorola" },
+                                                                                                               { 61, 0x0000F4, "Reserved by Motorola" },
+                                                                                                               { 62, 0x0000F8, "Reserved by Motorola" },
+                                                                                                               { 63, 0x0000FC, "Reserved by Motorola" },
+                                                                                                               { 64, 0x000100, "User interrupt vectors" },
+                                                                                                               { 65, 0x000104, "User interrupt vectors" },
+                                                                                                               { 66, 0x000108, "User interrupt vectors" },
+                                                                                                               { 67, 0x00010C, "User interrupt vectors" },
+                                                                                                               { 68, 0x000200, "User interrupt vectors" },
+                                                                                                               { 69, 0x000204, "User interrupt vectors" },
+                                                                                                               { 70, 0x000208, "User interrupt vectors" },
+                                                                                                               { 71, 0x00020C, "User interrupt vectors" },
+                                                                                                               { 72, 0x000210, "User interrupt vectors" },
+                                                                                                               { 73, 0x000214, "User interrupt vectors" },
+                                                                                                               { 74, 0x000218, "User interrupt vectors" },
+                                                                                                               { 75, 0x00021C, "User interrupt vectors" },
+                                                                                                               { 252, 0x0003F0, "User interrupt vectors" },
+                                                                                                               { 253, 0x0003F4, "User interrupt vectors" },
+                                                                                                               { 254, 0x0003F8, "User interrupt vectors" },
+                                                                                                               { 255, 0x0003FC, "User interrupt vectors" }
+                                                                                                       };
+
+
+// 
+ExceptionVectorTableBrowserWindow::ExceptionVectorTableBrowserWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog),
+layout(new QVBoxLayout),
+#ifdef EV_LAYOUTTEXTS
+text(new QTextBrowser),
+#else
+TableView (new QTableView),
+model (new QStandardItemModel),
+#endif
+refresh(new QPushButton(tr("Refresh")))
+{
+       setWindowTitle(tr("Exception Vector Table"));
+
+       // Refresh feature
+       QHBoxLayout *hbox1 = new QHBoxLayout;
+       hbox1->addWidget(refresh);
+
+       // Setup font
+       QFont fixedFont("Lucida Console", 8, QFont::Normal);
+       fixedFont.setStyleHint(QFont::TypeWriter);
+
+#ifdef EV_LAYOUTTEXTS
+       text->setFont(fixedFont);
+       layout->addWidget(text);
+#else
+       // Set the new layout with proper identation and readibility
+       model->setColumnCount(3);
+       model->setHeaderData(0, Qt::Horizontal, QObject::tr("Vector"));
+       model->setHeaderData(1, Qt::Horizontal, QObject::tr("Pointer"));
+       model->setHeaderData(2, Qt::Horizontal, QObject::tr("Use"));
+       // 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
+
+       layout->addWidget(refresh);
+       setLayout(layout);
+
+       // Event setup
+       connect(refresh, SIGNAL(clicked()), this, SLOT(RefreshContents()));
+}
+
+
+//
+ExceptionVectorTableBrowserWindow::~ExceptionVectorTableBrowserWindow(void)
+{
+}
+
+
+//
+void ExceptionVectorTableBrowserWindow::RefreshContents(void)
+{
+       char string[1024];
+#ifdef EV_LAYOUTTEXTS
+       QString ExceptionVector;
+#endif
+       size_t i;
+
+       if (isVisible())
+       {
+#ifndef HA_LAYOUTTEXTS
+               model->setRowCount(0);
+#endif
+               for (i = 0; i < (sizeof(TabExceptionVectorTable) / sizeof(ExceptionVectorTable)); i++)
+               {
+#ifdef EV_LAYOUTTEXTS
+                       if (i)
+                       {
+                               ExceptionVector += QString("<br>");
+                       }
+                       sprintf(string, "%03i : 0x%06X | 0x%06X | %s", (unsigned int)TabExceptionVectorTable[i].VectorNumber, (unsigned int)TabExceptionVectorTable[i].Address, GET32(jaguarMainRAM, TabExceptionVectorTable[i].Address), TabExceptionVectorTable[i].ExceptionName);
+                       ExceptionVector += QString(string);
+#else
+                       model->insertRow(i);
+                       model->setItem(i, 0, new QStandardItem(QString("0x%1").arg(TabExceptionVectorTable[i].Address, 4, 16, QChar('0'))));
+                       sprintf(string, "0x%06x", (unsigned int)GET32(jaguarMainRAM, TabExceptionVectorTable[i].Address));
+                       model->setItem(i, 1, new QStandardItem(QString("%1").arg(string)));
+                       model->setItem(i, 2, new QStandardItem(QString("%1").arg(TabExceptionVectorTable[i].ExceptionName)));
+#endif
+               }
+#ifdef EV_LAYOUTTEXTS
+               text->clear();
+               text->setText(ExceptionVector);
+#endif
+       }
+}
+
+
+// 
+void ExceptionVectorTableBrowserWindow::keyPressEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Escape)
+       {
+               hide();
+       }
+}
index 12bf882..aaccda0 100644 (file)
@@ -7,10 +7,13 @@
 #ifndef __EXCEPTIONVECTORTABLEBROWSER_H__
 #define __EXCEPTIONVECTORTABLEBROWSER_H__
 
+//#define EV_LAYOUTTEXTS                                               // Use a layout with just texts
+
 #include <QtWidgets>
 #include <stdint.h>
 
 
+// 
 class ExceptionVectorTableBrowserWindow: public QWidget
 {
        Q_OBJECT
@@ -27,7 +30,12 @@ class ExceptionVectorTableBrowserWindow: public QWidget
 
        private:
                QVBoxLayout *layout;
+#ifdef EV_LAYOUTTEXTS
                QTextBrowser *text;
+#else
+               QTableView *TableView;
+               QStandardItemModel *model;
+#endif
                QPushButton *refresh;
 };
 
index b65587b..024a9cf 100644 (file)
 // JPM  09/05/2018  Support of the DRAM size limit option\r
 // JPM  09/05/2018  Use definitions for error instead of hard values\r
 // JPM  09/05/2018  Detect if heap allocation shares space with SP (Stack)\r
+// JPM  09/06/2018  Added a status bar and better status report\r
+// JPM  09/07/2018  Set information values in a tab\r
 //\r
 \r
 // STILL TO DO:\r
-// Better information display\r
+// To have filters\r
+// To set the information display at the right\r
+// Feature to list the pointer(s) in the code using the allocation\r
 //\r
 \r
+\r
 #include "settings.h"\r
 #include "debugger/heapallocatorbrowser.h"\r
 #include "memory.h"\r
 #include "m68000/m68kinterface.h"\r
 \r
 \r
+// \r
 HeapAllocatorBrowserWindow::HeapAllocatorBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),\r
-layout(new QVBoxLayout), text(new QTextBrowser),\r
+layout(new QVBoxLayout),\r
+#ifdef HA_LAYOUTTEXTS\r
+text(new QTextBrowser),\r
+#else\r
+TableView(new QTableView),\r
+model(new QStandardItemModel),\r
+proxyModel(new QSortFilterProxyModel),\r
+#endif\r
+statusbar(new QStatusBar),\r
 Adr(0)\r
 {\r
        setWindowTitle(tr("Heap Allocation"));\r
 \r
+       // Set the font\r
        QFont fixedFont("Lucida Console", 8, QFont::Normal);\r
        fixedFont.setStyleHint(QFont::TypeWriter);\r
-       text->setFont(fixedFont);\r
-       setLayout(layout);\r
 \r
+#ifdef HA_LAYOUTTEXTS\r
+       // Set original layout\r
+       text->setFont(fixedFont);\r
        layout->addWidget(text);\r
+#else\r
+       // Set the new layout with proper identation and readibility\r
+       model->setColumnCount(3);\r
+       model->setHeaderData(0, Qt::Horizontal, QObject::tr("Pointer"));\r
+       model->setHeaderData(1, Qt::Horizontal, QObject::tr("Size"));\r
+       model->setHeaderData(2, Qt::Horizontal, QObject::tr("Use"));\r
+       // Information table\r
+       TableView->setModel(model);\r
+       TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);\r
+       TableView->setShowGrid(0);\r
+       TableView->setFont(fixedFont);\r
+       TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());\r
+       TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);\r
+       layout->addWidget(TableView);\r
+       // Set filter\r
+       proxyModel->setSourceModel(model);\r
+       QRegExp regExp("*", Qt::CaseInsensitive, QRegExp::Wildcard);\r
+       proxyModel->setFilterRegExp(regExp);\r
+#endif\r
+\r
+       // Status bar\r
+       layout->addWidget(statusbar);\r
+       setLayout(layout);\r
 }\r
 \r
 \r
@@ -48,16 +87,25 @@ HeapAllocatorBrowserWindow::~HeapAllocatorBrowserWindow(void)
 //\r
 void HeapAllocatorBrowserWindow::RefreshContents(void)\r
 {\r
-       char string[1024];\r
+#ifdef HA_LAYOUTTEXTS\r
+       char string[1024] = { 0 };\r
        QString HA;\r
-       size_t Adr68K;\r
+#endif\r
+       char msg[1024];\r
+       QString MSG;\r
+       size_t Adr68K, Adr68KHigh;\r
        size_t Error = HA_NOERROR;\r
+       size_t NbBlocks, TotalBytesUsed;\r
        HeapAllocation HeapAllocation;\r
 \r
        if (isVisible())\r
        {\r
                if (Adr68K = Adr)\r
                {\r
+                       Adr68KHigh = TotalBytesUsed = NbBlocks = 0;\r
+#ifndef HA_LAYOUTTEXTS\r
+                       model->setRowCount(0);\r
+#endif\r
                        do\r
                        {\r
                                if ((Adr68K >= 0x4000) && (Adr68K < vjs.DRAM_size))\r
@@ -76,48 +124,64 @@ void HeapAllocatorBrowserWindow::RefreshContents(void)
 \r
                                                                        if ((HeapAllocation.nextalloc >= 0x4000) && (HeapAllocation.nextalloc < vjs.DRAM_size))\r
                                                                        {\r
-                                                                               sprintf(string, "0x%06x | 0x%06x (%zi) | %s | 0x%06x<br>", Adr68K, HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.used ? "Allocated" : "Free", HeapAllocation.nextalloc);\r
-                                                                               Adr68K = HeapAllocation.nextalloc;\r
+#ifdef HA_LAYOUTTEXTS\r
+                                                                               if (NbBlocks++)\r
+                                                                               {\r
+                                                                                       HA += QString("<br>");\r
+                                                                               }\r
+                                                                               sprintf(string, "0x%06x | 0x%0x (%zi) | %s | 0x%06x", Adr68K, HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.used ? "Allocated" : "Free", HeapAllocation.nextalloc);\r
+                                                                               HA += QString(string);\r
+#else\r
+                                                                               model->insertRow(NbBlocks);\r
+                                                                               model->setItem(NbBlocks, 0, new QStandardItem(QString("0x%1").arg(Adr68K, 6, 16, QChar('0'))));\r
+                                                                               model->setItem(NbBlocks, 1, new QStandardItem(QString("%1").arg((HeapAllocation.size - sizeof(HeapAllocation)))));\r
+                                                                               model->setItem(NbBlocks++, 2, new QStandardItem(QString("%1").arg(HeapAllocation.used ? "Allocated" : "Free")));\r
+#endif\r
+                                                                               TotalBytesUsed += HeapAllocation.size;\r
+\r
+                                                                               if ((Adr68K = HeapAllocation.nextalloc) > Adr68KHigh)\r
+                                                                               {\r
+                                                                                       Adr68KHigh = Adr68K;\r
+                                                                               }\r
                                                                        }\r
                                                                        else\r
                                                                        {\r
-                                                                               sprintf(string, "<br><font color='#ff0000'><b>Unable to determine the next memory allocation</b></font>");\r
+                                                                               sprintf(msg, "Unable to determine the next memory allocation");\r
                                                                                Error = HA_UNABLENEXTMEMORYALLOC;\r
                                                                        }\r
                                                                }\r
                                                                else\r
                                                                {\r
-                                                                       sprintf(string, "<br><font color='#ff0000'><b>Unable to determine if the allocated memory is used or not</b></font>");\r
+                                                                       sprintf(msg, "Unable to determine if the allocated memory is used or not");\r
                                                                        Error = HA_UNABLEALLOCATEMEMORYUSAGE;\r
                                                                }\r
                                                        }\r
                                                        else\r
                                                        {\r
-                                                               sprintf(string, "<br><font color='#ff0000'><b>Memory bloc size has a problem</b></font>");\r
+                                                               sprintf(msg, "Memory bloc size has a problem");\r
                                                                Error = HA_MEMORYBLOCKSIZEPROBLEM;\r
                                                        }\r
                                                }\r
                                                else\r
                                                {\r
-                                                       sprintf(string, "<br><font color='#0000ff'><b>Memory allocations browsing successfully completed</b></font>");\r
+                                                       sprintf(msg, "%i blocks | %i bytes in blocks | %i contiguous bytes free", NbBlocks, TotalBytesUsed, (m68k_get_reg(NULL, M68K_REG_SP) - Adr68KHigh));\r
                                                }\r
                                        }\r
                                        else\r
                                        {\r
-                                               sprintf(string, "<br><font color='#ff0000'><b>Memory allocations and Stack are sharing the same space</b></font>");\r
+                                               sprintf(msg, "Memory allocations and Stack have reached the same space");\r
                                                Error = HA_HAANDSPSHARESPACE;\r
                                        }\r
                                }\r
                                else\r
                                {\r
-                                       sprintf(string, "<br><font color='#ff0000'><b>Memory allocations may have a problem</b></font>");\r
+                                       sprintf(msg, "Memory allocations may have a problem");\r
                                        Error = HA_MEMORYALLOCATIONPROBLEM;\r
                                }\r
-\r
-                               HA += QString(string);\r
-\r
                        }\r
                        while (HeapAllocation.size && !Error);\r
+\r
+                       MSG += QString(msg);\r
                }\r
                else\r
                {\r
@@ -127,7 +191,8 @@ void HeapAllocatorBrowserWindow::RefreshContents(void)
                                {\r
                                        if (!(Adr68K = (jaguarMainRAM[Adr68K] << 24) + (jaguarMainRAM[Adr68K + 1] << 16) + (jaguarMainRAM[Adr68K + 2] << 8) + (jaguarMainRAM[Adr68K + 3])) || ((Adr68K < 0x4000) || (Adr68K >= 0x200000)))\r
                                        {\r
-                                               sprintf(string, "<font color='#ff0000'><b>Memory allocator not yet initialised</b></font>");\r
+                                               sprintf(msg, "Memory allocator not yet initialised");\r
+                                               Error = HA_MEMORYALLOCATORNOTINITIALIZED;\r
                                                Adr = 0;\r
                                        }\r
                                        else\r
@@ -137,20 +202,47 @@ void HeapAllocatorBrowserWindow::RefreshContents(void)
                                }\r
                                else\r
                                {\r
-                                       sprintf(string, "<font color='#ff0000'><b>Memory allocator is not compatible</b></font>");\r
+                                       sprintf(msg, "Memory allocator is not compatible");\r
+                                       Error = HA_MEMORYALLOCATORNOTCOMPATIBLE;\r
                                        Adr = 0;\r
                                }\r
                        }\r
                        else\r
                        {\r
-                               sprintf(string, "<font color='#ff0000'><b>Memory allocator doesn't exist</b></font>");\r
+                               sprintf(msg, "Memory allocator doesn't exist");\r
+                               Error = HA_MEMORYALLOCATORNOTEXIST;\r
                        }\r
+#ifdef HA_LAYOUTTEXTS\r
+                       HA += QString("");\r
+#else\r
+                       model->setRowCount(0);\r
+#endif\r
+                       MSG += QString(msg);\r
+               }\r
 \r
-                       HA += QString(string);\r
+               // Display status bar\r
+               if (Error)\r
+               {\r
+                       if ((Error & HA_WARNING))\r
+                       {\r
+                               statusbar->setStyleSheet("background-color: lightyellow; font: bold");\r
+                       }\r
+                       else\r
+                       {\r
+                               statusbar->setStyleSheet("background-color: tomato; font: bold");\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       statusbar->setStyleSheet("background-color: lightgreen; font: bold");\r
                }\r
+               statusbar->showMessage(MSG);\r
 \r
+#ifdef HA_LAYOUTTEXTS\r
+               // Display values\r
                text->clear();\r
                text->setText(HA);\r
+#endif\r
        }\r
 }\r
 \r
index b3521f0..bbc2a4e 100644 (file)
@@ -7,18 +7,24 @@
 #ifndef __HEAPALLOCATORBROWSER_H__
 #define __HEAPALLOCATORBROWSER_H__
 
+//#define HA_LAYOUTTEXTS                                               // Use a layout with just texts
 
 #include <QtWidgets>
 #include <stdint.h>
 
-
 // Error code definitions
-#define        HA_NOERROR                                              0
-#define        HA_UNABLENEXTMEMORYALLOC                1
-#define HA_UNABLEALLOCATEMEMORYUSAGE   2
-#define HA_MEMORYBLOCKSIZEPROBLEM              3
-#define HA_MEMORYALLOCATIONPROBLEM             4
-#define HA_HAANDSPSHARESPACE                   5
+#define        HA_NOERROR                                                      0x00
+#define        HA_ERROR                                                        0x80
+#define        HA_WARNING                                                      0x40
+#define        HA_UNABLENEXTMEMORYALLOC                        (0x01 | HA_ERROR)
+#define HA_UNABLEALLOCATEMEMORYUSAGE           (0x02 | HA_ERROR)
+#define HA_MEMORYBLOCKSIZEPROBLEM                      (0x03 | HA_ERROR)
+#define HA_MEMORYALLOCATIONPROBLEM                     (0x04 | HA_ERROR)
+#define HA_HAANDSPSHARESPACE                           (0x05 | HA_ERROR)
+#define        HA_MEMORYALLOCATORNOTEXIST                      (0x06 | HA_WARNING)
+#define        HA_MEMORYALLOCATORNOTCOMPATIBLE         (0x07 | HA_WARNING)
+#define        HA_MEMORYALLOCATORNOTINITIALIZED        (0x08 | HA_WARNING)
+
 
 // 
 class HeapAllocatorBrowserWindow: public QWidget
@@ -30,7 +36,8 @@ class HeapAllocatorBrowserWindow: public QWidget
                uint32_t nextalloc;
                uint32_t size;
                uint16_t used;
-       }S_HeapAllocation;
+       }
+       S_HeapAllocation;
 
        public:
                HeapAllocatorBrowserWindow(QWidget *parent = 0);
@@ -45,7 +52,14 @@ class HeapAllocatorBrowserWindow: public QWidget
 
        private:
                QVBoxLayout *layout;
+#ifdef HA_LAYOUTTEXTS
                QTextBrowser *text;
+#else
+               QTableView *TableView;
+               QStandardItemModel *model;
+               QSortFilterProxyModel *proxyModel;
+#endif
+               QStatusBar *statusbar;
                size_t Adr;
 };
 
index 35b858d..9c59b43 100644 (file)
@@ -8,6 +8,14 @@
 // Who  When        What\r
 // ---  ----------  -----------------------------------------------------------\r
 // JPM  11/03/2017  Created this file\r
+// JPM  09/08/2018  Added a status bar and better status report\r
+// JPM  09/08/2018  Set information values in a tab\r
+//\r
+\r
+// STILL TO DO:\r
+// Feature to list the pointer(s) in the code using the allocation\r
+// To set the information display at the right\r
+// To support the array\r
 //\r
 \r
 \r
 \r
 // \r
 LocalBrowserWindow::LocalBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),\r
-       layout(new QVBoxLayout), text(new QTextBrowser),\r
-       NbLocal(0),\r
-       FuncName((char *)calloc(1, 1)),\r
-       LocalInfo(NULL)\r
+layout(new QVBoxLayout),\r
+#ifdef LOCAL_LAYOUTTEXTS\r
+text(new QTextBrowser),\r
+#else\r
+TableView(new QTableView),\r
+model(new QStandardItemModel),\r
+#endif\r
+NbLocal(0),\r
+FuncName((char *)calloc(1, 1)),\r
+LocalInfo(NULL),\r
+statusbar(new QStatusBar)\r
 {\r
-       setWindowTitle(tr("Local"));\r
+       setWindowTitle(tr("Locals"));\r
 \r
+       // Set the font\r
        QFont fixedFont("Lucida Console", 8, QFont::Normal);\r
        fixedFont.setStyleHint(QFont::TypeWriter);\r
-       text->setFont(fixedFont);\r
-       setLayout(layout);\r
 \r
+#ifdef LOCAL_LAYOUTTEXTS\r
+       // Set original layout\r
+       text->setFont(fixedFont);\r
        layout->addWidget(text);\r
+#else\r
+       // Set the new layout with proper identation and readibility\r
+       model->setColumnCount(3);\r
+       model->setHeaderData(0, Qt::Horizontal, QObject::tr("Name"));\r
+       model->setHeaderData(1, Qt::Horizontal, QObject::tr("Value"));\r
+       model->setHeaderData(2, Qt::Horizontal, QObject::tr("Type"));\r
+       // Information table\r
+       TableView->setModel(model);\r
+       TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);\r
+       TableView->setShowGrid(0);\r
+       TableView->setFont(fixedFont);\r
+       TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());\r
+       TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);\r
+       layout->addWidget(TableView);\r
+#endif\r
+\r
+       // Status bar\r
+       layout->addWidget(statusbar);\r
+       setLayout(layout);\r
 }\r
 \r
 \r
@@ -94,21 +130,40 @@ bool LocalBrowserWindow::UpdateInfos(void)
 //\r
 void LocalBrowserWindow::RefreshContents(void)\r
 {\r
+#ifdef LOCAL_LAYOUTTEXTS\r
        char string[1024];\r
+#endif\r
+       size_t Error = LOCAL_NOERROR;\r
        QString Local;\r
+       QString MSG;\r
+       char Value1[100];\r
+#ifdef LOCAL_SUPPORTARRAY\r
        char Value[100];\r
+#endif\r
        char *PtrValue;\r
 \r
        const char *CPURegName[] = { "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7" };\r
 \r
        if (isVisible())\r
        {\r
+#ifndef LOCAL_LAYOUTTEXTS\r
+               model->setRowCount(0);\r
+#endif\r
                if (UpdateInfos())\r
                {\r
                        for (size_t i = 0; i < NbLocal; i++)\r
                        {\r
                                if (LocalInfo[i].PtrVariableName)\r
                                {\r
+                                       memset(Value1, 0, sizeof(Value1));\r
+#ifdef LOCAL_LAYOUTTEXTS\r
+                                       if (i)\r
+                                       {\r
+                                               Local += QString("<br>");\r
+                                       }\r
+#else\r
+                                       model->insertRow(i);\r
+#endif\r
                                        // Local or parameters variables\r
                                        if (((LocalInfo[i].Op >= DBG_OP_breg0) && (LocalInfo[i].Op <= DBG_OP_breg31)) || (LocalInfo[i].Op == DBG_OP_fbreg))\r
                                        {\r
@@ -121,7 +176,25 @@ void LocalBrowserWindow::RefreshContents(void)
 \r
                                                if ((LocalInfo[i].Adr >= 0) && (LocalInfo[i].Adr < vjs.DRAM_size))\r
                                                {\r
-                                                       PtrValue = DBGManager_GetVariableValueFromAdr(LocalInfo[i].Adr, LocalInfo[i].TypeEncoding, LocalInfo[i].TypeByteSize);\r
+                                                       if ((LocalInfo[i].TypeTag & (DBG_TAG_TYPE_array | DBG_TAG_TYPE_structure)))\r
+                                                       {\r
+#if defined(LOCAL_SUPPORTARRAY) || defined(LOCAL_SUPPORTSTRUCTURE)\r
+                                                               //memcpy(Value1, &jaguarMainRAM[LocalInfo[i].Adr], 20);\r
+#ifdef LOCAL_LAYOUTTEXTS\r
+                                                               //sprintf(Value, "\"%s\"", Value1);\r
+#else\r
+                                                               //sprintf(Value, "0x%06X, \"%s\"", LocalInfo[i].Adr, Value1);\r
+#endif\r
+                                                               //PtrValue = Value;\r
+                                                               PtrValue = NULL;\r
+#else\r
+                                                               PtrValue = NULL;\r
+#endif\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               PtrValue = DBGManager_GetVariableValueFromAdr(LocalInfo[i].Adr, LocalInfo[i].TypeEncoding, LocalInfo[i].TypeByteSize);\r
+                                                       }\r
                                                }\r
                                                else\r
                                                {\r
@@ -134,7 +207,7 @@ void LocalBrowserWindow::RefreshContents(void)
                                                if ((LocalInfo[i].Op >= DBG_OP_reg0) && (LocalInfo[i].Op <= DBG_OP_reg31))\r
                                                {\r
                                                        LocalInfo[i].PtrCPURegisterName = (char *)CPURegName[(LocalInfo[i].Op - DBG_OP_reg0)];\r
-                                                       PtrValue = itoa(m68k_get_reg(NULL, (m68k_register_t)((size_t)M68K_REG_D0 + (LocalInfo[i].Op - DBG_OP_reg0))), Value, 10);\r
+                                                       PtrValue = itoa(m68k_get_reg(NULL, (m68k_register_t)((size_t)M68K_REG_D0 + (LocalInfo[i].Op - DBG_OP_reg0))), Value1, 10);\r
                                                }\r
                                                else\r
                                                {\r
@@ -142,14 +215,25 @@ void LocalBrowserWindow::RefreshContents(void)
                                                }\r
                                        }\r
 \r
+#ifndef LOCAL_LAYOUTTEXTS\r
+                                       model->setItem(i, 0, new QStandardItem(QString("%1").arg(LocalInfo[i].PtrVariableName)));\r
+#endif\r
+                                       // Check if the local variable is use by the code\r
                                        if (!LocalInfo[i].Op)\r
                                        {\r
+#ifdef LOCAL_LAYOUTTEXTS\r
                                                sprintf(string, "<font color='#A52A2A'>%i : %s | %s | [Not used]</font>", (i + 1), (LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"<font color='#ff0000'>N/A</font>"), LocalInfo[i].PtrVariableName);\r
+#else\r
+#endif\r
                                        }\r
                                        else\r
                                        {\r
+#ifndef LOCAL_LAYOUTTEXTS\r
+                                               model->setItem(i, 1, new QStandardItem(QString("%1").arg(PtrValue)));\r
+#else\r
                                                sprintf(string, "%i : %s | %s | ", (i + 1), (LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"<font color='#ff0000'>N/A</font>"), LocalInfo[i].PtrVariableName);\r
                                                Local += QString(string);\r
+\r
                                                if ((unsigned int)LocalInfo[i].Adr)\r
                                                {\r
                                                        sprintf(string, "0x%06X", (unsigned int)LocalInfo[i].Adr);\r
@@ -165,22 +249,52 @@ void LocalBrowserWindow::RefreshContents(void)
                                                                sprintf(string, "%s", (char *)"<font color='#ff0000'>N/A</font>");\r
                                                        }\r
                                                }\r
+\r
                                                Local += QString(string);\r
                                                sprintf(string, " | %s", (!PtrValue ? (char *)"<font color='#ff0000'>N/A</font>" : PtrValue));\r
+#endif\r
                                        }\r
+#ifndef LOCAL_LAYOUTTEXTS\r
+                                       model->setItem(i, 2, new QStandardItem(QString("%1").arg((LocalInfo[i].PtrVariableBaseTypeName ? LocalInfo[i].PtrVariableBaseTypeName : (char *)"<font color='#ff0000'>N/A</font>"))));\r
+#else\r
                                        Local += QString(string);\r
-                                       sprintf(string, "<br>");\r
-                                       Local += QString(string);\r
+#endif\r
                                }\r
                        }\r
 \r
+                       MSG += QString("Ready");\r
+#ifdef LOCAL_LAYOUTTEXTS\r
                        text->clear();\r
                        text->setText(Local);\r
+#endif\r
                }\r
                else\r
                {\r
+                       // No locals\r
+                       MSG += QString("No locals");\r
+                       Error = LOCAL_NOLOCALS;\r
+#ifdef LOCAL_LAYOUTTEXTS\r
                        text->clear();\r
+#endif\r
+               }\r
+\r
+               // Display status bar\r
+               if (Error)\r
+               {\r
+                       if ((Error & LOCAL_WARNING))\r
+                       {\r
+                               statusbar->setStyleSheet("background-color: lightyellow; font: bold");\r
+                       }\r
+                       else\r
+                       {\r
+                               statusbar->setStyleSheet("background-color: tomato; font: bold");\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       statusbar->setStyleSheet("background-color: lightgreen; font: bold");\r
                }\r
+               statusbar->showMessage(MSG);\r
        }\r
 }\r
 \r
index 544957a..056fd73 100644 (file)
@@ -7,9 +7,21 @@
 #ifndef __LOCALBROWSER_H__\r
 #define __LOCALBROWSER_H__\r
 \r
+//#define LOCAL_LAYOUTTEXTS                                            // Use a layout with just texts\r
+//#define LOCAL_SUPPORTARRAY                                           // Support array\r
+//#define LOCAL_SUPPORTSTRUCTURE                                       // Support structure\r
+\r
 #include <QtWidgets>\r
 #include <stdint.h>\r
+
+// Error code definitions\r
+#define        LOCAL_NOERROR           0x00\r
+#define        LOCAL_ERROR                     0x80
+#define        LOCAL_WARNING           0x40\r
+#define        LOCAL_NOLOCALS          (0x01 | LOCAL_WARNING)\r
+\r
 \r
+// \r
 class LocalBrowserWindow: public QWidget\r
 {\r
        Q_OBJECT\r
@@ -26,7 +38,8 @@ class LocalBrowserWindow: public QWidget
                char *PtrVariableName;\r
                char *PtrVariableBaseTypeName;\r
                char *PtrCPURegisterName;\r
-       }S_WatchInfo;\r
+       }\r
+       S_WatchInfo;\r
 \r
        public:\r
                LocalBrowserWindow(QWidget *parent = 0);\r
@@ -41,8 +54,14 @@ class LocalBrowserWindow: public QWidget
 \r
        private:\r
                QVBoxLayout *layout;\r
+#ifdef LOCAL_LAYOUTTEXTS\r
                QTextBrowser *text;\r
+#else\r
+               QTableView *TableView;\r
+               QStandardItemModel *model;\r
+#endif\r
                WatchInfo *LocalInfo;\r
+               QStatusBar *statusbar;\r
                size_t NbLocal;\r
                char *FuncName;\r
 };\r