The address provided in the memory window is now verified to prevent crash
authorJean-Paul Mari <djipi.mari@gmail.com>
Thu, 23 Aug 2018 01:52:14 +0000 (21:52 -0400)
committerJean-Paul Mari <djipi.mari@gmail.com>
Thu, 23 Aug 2018 01:52:14 +0000 (21:52 -0400)
docs/vj_ReleaseNotes.txt
src/debugger/memory1browser.cpp

index 5df4915..e2208b2 100644 (file)
@@ -11,11 +11,13 @@ Release 4 (TBD)
 -- Breakpoint can now occur in the case of a ROM cartridge writing\r
 -- Alert box will display a message with possibility to pass or not the breakpoint only if this is related to a 8 or 16 bits ROM access\r
 8) Local variables window detects now if a variable is used or not by the code\r
 -- Breakpoint can now occur in the case of a ROM cartridge writing\r
 -- Alert box will display a message with possibility to pass or not the breakpoint only if this is related to a 8 or 16 bits ROM access\r
 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 provided address will be displayed in red\r
 \r
 Release 3 (13th November 2017)\r
 ------------------------------\r
 0) Fixed the windows respawning in the next emulator launch within --alpine or --debugger options\r
 \r
 Release 3 (13th November 2017)\r
 ------------------------------\r
 0) Fixed the windows respawning in the next emulator launch within --alpine or --debugger options\r
-1) Added an Exception Vector Table browser window\r
+1) Added an Exception Vector Table window\r
 2) Modified the About window to update the credits list in a more appropriate way\r
 -- Updated the emulator application credits line\r
 3) Added 'Rx' word to the emulator name\r
 2) Modified the About window to update the credits list in a more appropriate way\r
 -- Updated the emulator application credits line\r
 3) Added 'Rx' word to the emulator name\r
@@ -38,7 +40,7 @@ Release 3 (13th November 2017)
 15) Improved the .heap section detection to avoid a detection error\r
 -- Depend vlink version, .heap section may have an Alloc flag\r
 16) Fixed a crash when DWARF information does references to missing source code files\r
 15) Improved the .heap section detection to avoid a detection error\r
 -- Depend vlink version, .heap section may have an Alloc flag\r
 16) Fixed a crash when DWARF information does references to missing source code files\r
-17) Added a Local browser window for local variables\r
+17) Added a local variables window\r
 18) Project has switched to Visual Studio 2017 and QT 5.9.1 library\r
 \r
 Release 2 (3rd September 2017)\r
 18) Project has switched to Visual Studio 2017 and QT 5.9.1 library\r
 \r
 Release 2 (3rd September 2017)\r
@@ -50,9 +52,9 @@ Release 2 (3rd September 2017)
 4) DWARF support\r
 -- TAG: Compilation Unit, Subprogram, Variables, Types\r
 -- Line numbers, symbols, functions\r
 4) DWARF support\r
 -- TAG: Compilation Unit, Subprogram, Variables, Types\r
 -- Line numbers, symbols, functions\r
-5) Added an All Watch browser window for non-local variables\r
-6) Added a heap allocator browser window based on my own memory allocation functions\r
-7) Added additional 4 memory browser windows with address input based on hexa, decimal or symbol name\r
+5) Added an All Watch window for non-local variables\r
+6) Added a heap allocator window based on my own memory allocation functions\r
+7) Added additional 4 memory windows with address input based on hexa, decimal or symbol name\r
 8) Windows refreshing executed only if windows is visible\r
 9) Added a restart function\r
 -- Restart only the 68000 program counter to his original set\r
 8) Windows refreshing executed only if windows is visible\r
 9) Added a restart function\r
 -- Restart only the 68000 program counter to his original set\r
@@ -118,6 +120,7 @@ Known issues
 -- 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
 10) In the case of a ROM cartridge writing, and an occuring breakpoint, the PC pointer will point at the next instruction and not at the instruction causing the breakpoint\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
 10) In the case of a ROM cartridge writing, and an 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 value provided in the memory browser window\r
 \r
 Cosmetic / UX issues\r
 ====================\r
 \r
 Cosmetic / UX issues\r
 ====================\r
index af8cbc2..71c3473 100644 (file)
@@ -16,6 +16,7 @@
 #include "memory1browser.h"
 #include "memory.h"
 #include "debugger/DBGManager.h"
 #include "memory1browser.h"
 #include "memory.h"
 #include "debugger/DBGManager.h"
+#include "settings.h"
 
 
 //
 
 
 //
@@ -63,9 +64,8 @@ void Memory1BrowserWindow::RefreshContents(size_t NumWin)
 
        if (isVisible())
        {
 
        if (isVisible())
        {
-               sprintf(string, "Memory %i - %06X", (unsigned int)((NumWinOrigin = NumWin) + 1), (unsigned int)memOrigin);
+               sprintf(string, "Memory %i - 0x%06X", (unsigned int)((NumWinOrigin = NumWin) + 1), (unsigned int)memOrigin);
                setWindowTitle(tr(string));
                setWindowTitle(tr(string));
-
                RefreshContentsWindow();
        }
 }
                RefreshContentsWindow();
        }
 }
@@ -128,7 +128,9 @@ void Memory1BrowserWindow::keyPressEvent(QKeyEvent * e)
                        memBase -= 480;
 
                        if (memBase < 0)
                        memBase -= 480;
 
                        if (memBase < 0)
+                       {
                                memBase = 0;
                                memBase = 0;
+                       }
 
                        RefreshContentsWindow();
                }
 
                        RefreshContentsWindow();
                }
@@ -138,8 +140,10 @@ void Memory1BrowserWindow::keyPressEvent(QKeyEvent * e)
                        {
                                memBase += 480;
 
                        {
                                memBase += 480;
 
-                               if (memBase > (0x200000 - 480))
-                                       memBase = 0x200000 - 480;
+                               if (memBase > (vjs.DRAM_size - 480))
+                               {
+                                       memBase = vjs.DRAM_size - 480;
+                               }
 
                                RefreshContentsWindow();
                        }
 
                                RefreshContentsWindow();
                        }
@@ -150,7 +154,9 @@ void Memory1BrowserWindow::keyPressEvent(QKeyEvent * e)
                                        memBase -= 16;
 
                                        if (memBase < 0)
                                        memBase -= 16;
 
                                        if (memBase < 0)
+                                       {
                                                memBase = 0;
                                                memBase = 0;
+                                       }
 
                                        RefreshContentsWindow();
                                }
 
                                        RefreshContentsWindow();
                                }
@@ -160,8 +166,10 @@ void Memory1BrowserWindow::keyPressEvent(QKeyEvent * e)
                                        {
                                                memBase += 16;
 
                                        {
                                                memBase += 16;
 
-                                               if (memBase > (0x200000 - 480))
-                                                       memBase = 0x200000 - 480;
+                                               if (memBase > (vjs.DRAM_size - 480))
+                                               {
+                                                       memBase = vjs.DRAM_size - 480;
+                                               }
 
                                                RefreshContentsWindow();
                                        }
 
                                                RefreshContentsWindow();
                                        }
@@ -185,21 +193,39 @@ void Memory1BrowserWindow::GoToAddress(void)
 {
        bool ok;
        QString newAddress;
 {
        bool ok;
        QString newAddress;
+       size_t newmemBase;
 
 
+       QPalette p = address->palette();
        newAddress = address->text();
 
        newAddress = address->text();
 
-       if (( newAddress.at(0) == QChar('0')) && (newAddress.at(1) == QChar('x')))
+       if (newAddress.size())
        {
        {
-               memBase = newAddress.toUInt(&ok, 16);
-       }
-       else
-       {
-               if (!(memBase = DBGManager_GetAdrFromSymbolName(newAddress.toLatin1().data())))
+               if ((newAddress.at(0) == QChar('0')) && (newAddress.at(1) == QChar('x')))
                {
                {
-                       memBase = newAddress.toUInt(&ok, 10);
+                       newmemBase = newAddress.toUInt(&ok, 16);
+               }
+               else
+               {
+                       if (!(newmemBase = DBGManager_GetAdrFromSymbolName(newAddress.toLatin1().data())))
+                       {
+                               newmemBase = newAddress.toUInt(&ok, 10);
+                       }
+                       else
+                       {
+                               ok = true;
+                       }
                }
                }
-       }
 
 
-       memOrigin = memBase;
-       RefreshContents(NumWinOrigin);
+               if (!ok || (newmemBase < 0) || (newmemBase > vjs.DRAM_size))
+               {
+                       p.setColor(QPalette::Text, Qt::red);
+               }
+               else
+               {
+                       p.setColor(QPalette::Text, Qt::black);
+                       memOrigin = (memBase = newmemBase);
+                       RefreshContents(NumWinOrigin);
+               }
+               address->setPalette(p);
+       }
 }
 }