Local variables window detects now if a variable is used or not by the code
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / localbrowser.cpp
index ce69ffa..c5782da 100644 (file)
@@ -78,22 +78,27 @@ bool LocalBrowserWindow::UpdateInfos(void)
                {\r
                        if (strcmp(FuncName, Ptr))\r
                        {\r
-                               FuncName = (char *)realloc(FuncName, strlen(Ptr) + 1);\r
-                               strcpy(FuncName, Ptr);\r
-\r
-                               LocalInfo = (WatchInfo *)realloc(LocalInfo, (sizeof(WatchInfo) * NbLocal));\r
-                               for (size_t i = 0; i < NbLocal; i++)\r
+                               if (FuncName = (char *)realloc(FuncName, strlen(Ptr) + 1))\r
                                {\r
-                                       if (LocalInfo[i].PtrVariableName = DBGManager_GetLocalVariableName(Adr, i + 1))\r
+                                       strcpy(FuncName, Ptr);\r
+\r
+                                       if (LocalInfo = (WatchInfo *)realloc(LocalInfo, (sizeof(WatchInfo) * NbLocal)))\r
                                        {\r
-                                               LocalInfo[i].Op = DBGManager_GetLocalVariableOp(Adr, i + 1);\r
-                                               LocalInfo[i].Adr = NULL;\r
-                                               LocalInfo[i].PtrCPURegisterName = NULL;\r
-                                               LocalInfo[i].TypeTag = DBGManager_GetLocalVariableTypeTag(Adr, i + 1);\r
-                                               LocalInfo[i].PtrVariableBaseTypeName = DBGManager_GetLocalVariableTypeName(Adr, i + 1);\r
-                                               LocalInfo[i].TypeEncoding = DBGManager_GetLocalVariableTypeEncoding(Adr, i + 1);\r
-                                               LocalInfo[i].TypeByteSize = DBGManager_GetLocalVariableTypeByteSize(Adr, i + 1);\r
-                                               LocalInfo[i].Offset = DBGManager_GetLocalVariableOffset(Adr, i + 1);\r
+                                               for (size_t i = 0; i < NbLocal; i++)\r
+                                               {\r
+                                                       // Get local variable name and his information\r
+                                                       if (LocalInfo[i].PtrVariableName = DBGManager_GetLocalVariableName(Adr, i + 1))\r
+                                                       {\r
+                                                               LocalInfo[i].Op = DBGManager_GetLocalVariableOp(Adr, i + 1);\r
+                                                               LocalInfo[i].Adr = NULL;\r
+                                                               LocalInfo[i].PtrCPURegisterName = NULL;\r
+                                                               LocalInfo[i].TypeTag = DBGManager_GetLocalVariableTypeTag(Adr, i + 1);\r
+                                                               LocalInfo[i].PtrVariableBaseTypeName = DBGManager_GetLocalVariableTypeName(Adr, i + 1);\r
+                                                               LocalInfo[i].TypeEncoding = DBGManager_GetLocalVariableTypeEncoding(Adr, i + 1);\r
+                                                               LocalInfo[i].TypeByteSize = DBGManager_GetLocalVariableTypeByteSize(Adr, i + 1);\r
+                                                               LocalInfo[i].Offset = DBGManager_GetLocalVariableOffset(Adr, i + 1);\r
+                                                       }\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
@@ -140,10 +145,16 @@ void LocalBrowserWindow::RefreshContents(void)
                        {\r
                                if (LocalInfo[i].PtrVariableName)\r
                                {\r
-                                       if (((LocalInfo[i].Op >= DBG_OP_breg0) && (LocalInfo[i].Op <= DBG_OP_breg31)))\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
                                                LocalInfo[i].Adr = m68k_get_reg(NULL, M68K_REG_A6) + LocalInfo[i].Offset;\r
 \r
+                                               if ((LocalInfo[i].Op == DBG_OP_fbreg))\r
+                                               {\r
+                                                       LocalInfo[i].Adr += 8;\r
+                                               }\r
+\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
@@ -167,26 +178,33 @@ void LocalBrowserWindow::RefreshContents(void)
                                                }\r
                                        }\r
 \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
-                                       if ((unsigned int)LocalInfo[i].Adr)\r
+                                       if (!LocalInfo[i].Op)\r
                                        {\r
-                                               sprintf(string, "0x%06X", (unsigned int)LocalInfo[i].Adr);\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
                                        }\r
                                        else\r
                                        {\r
-                                               if (LocalInfo[i].PtrCPURegisterName)\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
+                                               if ((unsigned int)LocalInfo[i].Adr)\r
                                                {\r
-                                                       sprintf(string, "<font color='#0000FF'>%s</font>", LocalInfo[i].PtrCPURegisterName);\r
+                                                       sprintf(string, "0x%06X", (unsigned int)LocalInfo[i].Adr);\r
                                                }\r
                                                else\r
                                                {\r
-                                                       sprintf(string, "%s", (char *)"<font color='#ff0000'>N/A</font>");\r
-                                               }                                               \r
+                                                       if (LocalInfo[i].PtrCPURegisterName)\r
+                                                       {\r
+                                                               sprintf(string, "<font color='#0000FF'>%s</font>", LocalInfo[i].PtrCPURegisterName);\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               sprintf(string, "%s", (char *)"<font color='#ff0000'>N/A</font>");\r
+                                                       }\r
+                                               }\r
+                                               Local += QString(string);\r
+                                               sprintf(string, " | %s", (!PtrValue ? (char *)"<font color='#ff0000'>N/A</font>" : PtrValue));\r
                                        }\r
                                        Local += QString(string);\r
-                                       sprintf(string, " | %s", (!PtrValue ? (char *)"<font color='#ff0000'>N/A</font>" : PtrValue));\r
-                                       Local += QString(string);\r
                                        sprintf(string, "<br>");\r
                                        Local += QString(string);\r
                                }\r