Local variables window detects now if a variable is used or not by the code
authorJean-Paul Mari <djipi.mari@gmail.com>
Wed, 22 Aug 2018 05:57:07 +0000 (01:57 -0400)
committerJean-Paul Mari <djipi.mari@gmail.com>
Wed, 22 Aug 2018 05:57:07 +0000 (01:57 -0400)
docs/vj_ReleaseNotes.txt
src/debugger/DWARFManager.cpp
src/debugger/localbrowser.cpp

index b968540..5df4915 100644 (file)
@@ -10,6 +10,7 @@ Release 4 (TBD)
 7) ROM cartridge writing detection follow the alpine "allow writes to cartridge rom"'s flag check\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
 \r
 Release 3 (13th November 2017)\r
 ------------------------------\r
index 3817763..b6c149e 100644 (file)
@@ -675,11 +675,18 @@ void DWARFManager_InitDMI(void)
                                                                                                                                                                case 2:\r
                                                                                                                                                                        PtrCU[NbCU].PtrSubProgs[PtrCU[NbCU].NbSubProgs].PtrVariables[PtrCU[NbCU].PtrSubProgs[PtrCU[NbCU].NbSubProgs].NbVariables].Offset = *((char *)(return_block->bl_data) + 1);\r
 \r
-                                                                                                                                                                       if (return_tagval == DW_TAG_variable)\r
+                                                                                                                                                                       switch (return_tagval)\r
                                                                                                                                                                        {\r
+                                                                                                                                                                       case    DW_TAG_variable:\r
                                                                                                                                                                                PtrCU[NbCU].PtrSubProgs[PtrCU[NbCU].NbSubProgs].PtrVariables[PtrCU[NbCU].PtrSubProgs[PtrCU[NbCU].NbSubProgs].NbVariables].Offset -= 0x80;\r
+                                                                                                                                                                               break;\r
+\r
+                                                                                                                                                                       case    DW_TAG_formal_parameter:\r
+                                                                                                                                                                               break;\r
+\r
+                                                                                                                                                                       default:\r
+                                                                                                                                                                               break;\r
                                                                                                                                                                        }\r
-                                                                                                                                                                       break;\r
 \r
                                                                                                                                                                default:\r
                                                                                                                                                                        break;\r
@@ -709,6 +716,12 @@ void DWARFManager_InitDMI(void)
                                                                                                                                                        }\r
                                                                                                                                                        break;\r
 \r
+                                                                                                                                               case    DW_AT_decl_file:\r
+                                                                                                                                                       break;\r
+\r
+                                                                                                                                               case    DW_AT_decl_line:\r
+                                                                                                                                                       break;\r
+\r
                                                                                                                                                default:\r
                                                                                                                                                        break;\r
                                                                                                                                                }\r
@@ -749,7 +762,9 @@ void DWARFManager_InitDMI(void)
 \r
                                        // Release the memory used by the source lines\r
                                        for (i = 0; i < (size_t)cnt; ++i)\r
+                                       {\r
                                                dwarf_dealloc(dbg, linebuf[i], DW_DLA_LINE);\r
+                                       }\r
                                        dwarf_dealloc(dbg, linebuf, DW_DLA_LIST);\r
                                }\r
 \r
index 77e7102..c5782da 100644 (file)
@@ -78,23 +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
-                                       // Get local variable name and his information\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
@@ -174,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