From: Jean-Paul Mari Date: Wed, 5 Sep 2018 18:14:53 +0000 (-0400) Subject: Heap allocation window uses the DRAM size limit option and detect if heap allocation... X-Git-Tag: v2.1.3-R4~36 X-Git-Url: http://git.hcoop.net/clinton/Virtual-Jaguar-Rx.git/commitdiff_plain/5d765b04b0aefa64382ec352b27e344d3a4db97e Heap allocation window uses the DRAM size limit option and detect if heap allocation shares space with SP (Stack) --- diff --git a/src/debugger/heapallocatorbrowser.cpp b/src/debugger/heapallocatorbrowser.cpp index 7224be3..b65587b 100644 --- a/src/debugger/heapallocatorbrowser.cpp +++ b/src/debugger/heapallocatorbrowser.cpp @@ -8,11 +8,16 @@ // Who When What // --- ---------- ----------------------------------------------------------- // JPM 01/08/2017 Created this file +// JPM 09/05/2018 Support of the DRAM size limit option +// JPM 09/05/2018 Use definitions for error instead of hard values +// JPM 09/05/2018 Detect if heap allocation shares space with SP (Stack) // // STILL TO DO: +// Better information display // +#include "settings.h" #include "debugger/heapallocatorbrowser.h" #include "memory.h" #include "debugger/DBGManager.h" @@ -46,7 +51,7 @@ void HeapAllocatorBrowserWindow::RefreshContents(void) char string[1024]; QString HA; size_t Adr68K; - size_t Error = 0; + size_t Error = HA_NOERROR; HeapAllocation HeapAllocation; if (isVisible()) @@ -55,55 +60,64 @@ void HeapAllocatorBrowserWindow::RefreshContents(void) { do { - if ((Adr68K >= 0x4000) && (Adr68K < 0x200000)) + if ((Adr68K >= 0x4000) && (Adr68K < vjs.DRAM_size)) { - memcpy(&HeapAllocation, &jaguarMainRAM[Adr68K], sizeof(HeapAllocation)); - - if (HeapAllocation.size = ((HeapAllocation.size & 0xff) << 24) + ((HeapAllocation.size & 0xff00) << 8) + ((HeapAllocation.size & 0xff0000) >> 8) + ((HeapAllocation.size & 0xff000000) >> 24)) + if (Adr68K < m68k_get_reg(NULL, M68K_REG_SP)) { - if (HeapAllocation.size <= (0x200000 - 0x4000)) + memcpy(&HeapAllocation, &jaguarMainRAM[Adr68K], sizeof(HeapAllocation)); + + if (HeapAllocation.size = ((HeapAllocation.size & 0xff) << 24) + ((HeapAllocation.size & 0xff00) << 8) + ((HeapAllocation.size & 0xff0000) >> 8) + ((HeapAllocation.size & 0xff000000) >> 24)) { - if ((HeapAllocation.used = ((HeapAllocation.used & 0xff) << 8) + ((HeapAllocation.used & 0xff00) >> 8)) <= 1) + if (HeapAllocation.size <= (vjs.DRAM_size - 0x4000)) { - HeapAllocation.nextalloc = ((HeapAllocation.nextalloc & 0xff) << 24) + ((HeapAllocation.nextalloc & 0xff00) << 8) + ((HeapAllocation.nextalloc & 0xff0000) >> 8) + ((HeapAllocation.nextalloc & 0xff000000) >> 24); - - if ((HeapAllocation.nextalloc >= 0x4000) && (HeapAllocation.nextalloc < 0x200000)) + if ((HeapAllocation.used = ((HeapAllocation.used & 0xff) << 8) + ((HeapAllocation.used & 0xff00) >> 8)) <= 1) { - sprintf(string, "0x%06x | 0x%06x (%i) | %s | 0x%06x
", Adr68K, HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.used ? "Allocated" : "Free", HeapAllocation.nextalloc); - Adr68K = HeapAllocation.nextalloc; + HeapAllocation.nextalloc = ((HeapAllocation.nextalloc & 0xff) << 24) + ((HeapAllocation.nextalloc & 0xff00) << 8) + ((HeapAllocation.nextalloc & 0xff0000) >> 8) + ((HeapAllocation.nextalloc & 0xff000000) >> 24); + + if ((HeapAllocation.nextalloc >= 0x4000) && (HeapAllocation.nextalloc < vjs.DRAM_size)) + { + sprintf(string, "0x%06x | 0x%06x (%zi) | %s | 0x%06x
", Adr68K, HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.used ? "Allocated" : "Free", HeapAllocation.nextalloc); + Adr68K = HeapAllocation.nextalloc; + } + else + { + sprintf(string, "
Unable to determine the next memory allocation"); + Error = HA_UNABLENEXTMEMORYALLOC; + } } else { - sprintf(string, "
Unable to determine the next memory allocation"); - Error = 1; + sprintf(string, "
Unable to determine if the allocated memory is used or not"); + Error = HA_UNABLEALLOCATEMEMORYUSAGE; } } else { - sprintf(string, "
Unable to determine if the allocated memory is used or not"); - Error = 2; + sprintf(string, "
Memory bloc size has a problem"); + Error = HA_MEMORYBLOCKSIZEPROBLEM; } } else { - sprintf(string, "
Memory bloc size has a problem"); - Error = 3; + sprintf(string, "
Memory allocations browsing successfully completed"); } } else { - sprintf(string, "
Memory allocations browsing successfully completed"); + sprintf(string, "
Memory allocations and Stack are sharing the same space"); + Error = HA_HAANDSPSHARESPACE; } } else { sprintf(string, "
Memory allocations may have a problem"); - Error = 4; + Error = HA_MEMORYALLOCATIONPROBLEM; } HA += QString(string); - } while (HeapAllocation.size && !Error); + } + while (HeapAllocation.size && !Error); } else { diff --git a/src/debugger/heapallocatorbrowser.h b/src/debugger/heapallocatorbrowser.h index 234d8ae..b3521f0 100644 --- a/src/debugger/heapallocatorbrowser.h +++ b/src/debugger/heapallocatorbrowser.h @@ -7,9 +7,20 @@ #ifndef __HEAPALLOCATORBROWSER_H__ #define __HEAPALLOCATORBROWSER_H__ + #include #include + +// 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 + +// class HeapAllocatorBrowserWindow: public QWidget { Q_OBJECT