// Who When What\r
// --- ---------- -----------------------------------------------------------\r
// JPM 01/08/2017 Created this file\r
+// 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
//\r
\r
// STILL TO DO:\r
+// Better information display\r
//\r
\r
+#include "settings.h"\r
#include "debugger/heapallocatorbrowser.h"\r
#include "memory.h"\r
#include "debugger/DBGManager.h"\r
char string[1024];\r
QString HA;\r
size_t Adr68K;\r
- size_t Error = 0;\r
+ size_t Error = HA_NOERROR;\r
HeapAllocation HeapAllocation;\r
\r
if (isVisible())\r
{\r
do\r
{\r
- if ((Adr68K >= 0x4000) && (Adr68K < 0x200000))\r
+ if ((Adr68K >= 0x4000) && (Adr68K < vjs.DRAM_size))\r
{\r
- memcpy(&HeapAllocation, &jaguarMainRAM[Adr68K], sizeof(HeapAllocation));\r
-\r
- if (HeapAllocation.size = ((HeapAllocation.size & 0xff) << 24) + ((HeapAllocation.size & 0xff00) << 8) + ((HeapAllocation.size & 0xff0000) >> 8) + ((HeapAllocation.size & 0xff000000) >> 24))\r
+ if (Adr68K < m68k_get_reg(NULL, M68K_REG_SP))\r
{\r
- if (HeapAllocation.size <= (0x200000 - 0x4000))\r
+ memcpy(&HeapAllocation, &jaguarMainRAM[Adr68K], sizeof(HeapAllocation));\r
+\r
+ if (HeapAllocation.size = ((HeapAllocation.size & 0xff) << 24) + ((HeapAllocation.size & 0xff00) << 8) + ((HeapAllocation.size & 0xff0000) >> 8) + ((HeapAllocation.size & 0xff000000) >> 24))\r
{\r
- if ((HeapAllocation.used = ((HeapAllocation.used & 0xff) << 8) + ((HeapAllocation.used & 0xff00) >> 8)) <= 1)\r
+ if (HeapAllocation.size <= (vjs.DRAM_size - 0x4000))\r
{\r
- HeapAllocation.nextalloc = ((HeapAllocation.nextalloc & 0xff) << 24) + ((HeapAllocation.nextalloc & 0xff00) << 8) + ((HeapAllocation.nextalloc & 0xff0000) >> 8) + ((HeapAllocation.nextalloc & 0xff000000) >> 24);\r
-\r
- if ((HeapAllocation.nextalloc >= 0x4000) && (HeapAllocation.nextalloc < 0x200000))\r
+ if ((HeapAllocation.used = ((HeapAllocation.used & 0xff) << 8) + ((HeapAllocation.used & 0xff00) >> 8)) <= 1)\r
{\r
- sprintf(string, "0x%06x | 0x%06x (%i) | %s | 0x%06x<br>", Adr68K, HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.size - sizeof(HeapAllocation), HeapAllocation.used ? "Allocated" : "Free", HeapAllocation.nextalloc);\r
- Adr68K = HeapAllocation.nextalloc;\r
+ HeapAllocation.nextalloc = ((HeapAllocation.nextalloc & 0xff) << 24) + ((HeapAllocation.nextalloc & 0xff00) << 8) + ((HeapAllocation.nextalloc & 0xff0000) >> 8) + ((HeapAllocation.nextalloc & 0xff000000) >> 24);\r
+\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
+ }\r
+ else\r
+ {\r
+ sprintf(string, "<br><font color='#ff0000'><b>Unable to determine the next memory allocation</b></font>");\r
+ Error = HA_UNABLENEXTMEMORYALLOC;\r
+ }\r
}\r
else\r
{\r
- sprintf(string, "<br><font color='#ff0000'><b>Unable to determine the next memory allocation</b></font>");\r
- Error = 1;\r
+ sprintf(string, "<br><font color='#ff0000'><b>Unable to determine if the allocated memory is used or not</b></font>");\r
+ Error = HA_UNABLEALLOCATEMEMORYUSAGE;\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
- Error = 2;\r
+ sprintf(string, "<br><font color='#ff0000'><b>Memory bloc size has a problem</b></font>");\r
+ Error = HA_MEMORYBLOCKSIZEPROBLEM;\r
}\r
}\r
else\r
{\r
- sprintf(string, "<br><font color='#ff0000'><b>Memory bloc size has a problem</b></font>");\r
- Error = 3;\r
+ sprintf(string, "<br><font color='#0000ff'><b>Memory allocations browsing successfully completed</b></font>");\r
}\r
}\r
else\r
{\r
- sprintf(string, "<br><font color='#0000ff'><b>Memory allocations browsing successfully completed</b></font>");\r
+ sprintf(string, "<br><font color='#ff0000'><b>Memory allocations and Stack are sharing the same space</b></font>");\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
- Error = 4;\r
+ Error = HA_MEMORYALLOCATIONPROBLEM;\r
}\r
\r
HA += QString(string);\r
\r
- } while (HeapAllocation.size && !Error);\r
+ }\r
+ while (HeapAllocation.size && !Error);\r
}\r
else\r
{\r