Code refactoring for the variables support
[clinton/Virtual-Jaguar-Rx.git] / src / debugger / DBGManager.cpp
index 0dec2c0..edbc766 100644 (file)
@@ -4,6 +4,7 @@
 // by Jean-Paul Mari\r
 //\r
 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>\r
+//  RG = Richard Goedeken\r
 //\r
 // WHO  WHEN        WHAT\r
 // ---  ----------  ------------------------------------------------------------\r
@@ -14,6 +15,8 @@
 // JPM   Oct./2018  Cosmetic changes, added source file search paths, and ELF function name\r
 // JPM   Aug./2019  Added new functions mainly for source text lines\r
 // JPM  Sept./2019  Support the unsigned/signed short type\r
+//  RG   Jan./2021  Linux build fixes\r
+// JPM    May/2021  Code refactoring for the variables\r
 //\r
 \r
 // To Do\r
@@ -227,6 +230,53 @@ char *DBGManager_GetFullSourceFilenameFromAdr(size_t Adr, DBGstatus *Status)
 }\r
 \r
 \r
+// Get number of variables\r
+// A NULL address will return the numbre of global variables, otherwise it will return the number of local variables\r
+size_t DBGManager_GetNbVariables(size_t Adr)\r
+{\r
+       if ((DBGType & DBG_ELFDWARF))\r
+       {\r
+               return DWARFManager_GetNbVariables(Adr);\r
+       }\r
+       else\r
+       {\r
+               return  0;\r
+       }\r
+}\r
+\r
+\r
+// Get variable's information\r
+// A NULL address will return the pointer to the global variable structure, otherwise it will return the local's one\r
+S_VariablesStruct* DBGManager_GetInfosVariable(size_t Adr, size_t Index)\r
+{\r
+       if ((DBGType & DBG_ELFDWARF))\r
+       {\r
+               return (S_VariablesStruct*)DWARFManager_GetInfosVariable(Adr, Index);\r
+       }\r
+       else\r
+       {\r
+               return  NULL;\r
+       }\r
+}\r
+\r
+\r
+// Get global variable's Address based on his Name\r
+// Return found Address\r
+// Return NULL if no Address has been found\r
+size_t DBGManager_GetGlobalVariableAdrFromName(char *VariableName)\r
+{\r
+       if ((DBGType & DBG_ELFDWARF))\r
+       {\r
+               return DWARFManager_GetGlobalVariableAdrFromName(VariableName);\r
+       }\r
+       else\r
+       {\r
+               return 0;\r
+       }\r
+}\r
+\r
+\r
+#if 0\r
 // Get number of local variables\r
 // Return 0 if none has been found\r
 size_t DBGManager_GetNbLocalVariables(size_t Adr)\r
@@ -255,6 +305,7 @@ size_t DBGManager_GetNbGlobalVariables(void)
                return  0;\r
        }\r
 }\r
+#endif\r
 \r
 \r
 // Get address from symbol name\r
@@ -274,22 +325,7 @@ size_t DBGManager_GetAdrFromSymbolName(char *SymbolName)
 }\r
 \r
 \r
-// Get global variable's Address based on his Name\r
-// Return found Address\r
-// Return NULL if no Address has been found\r
-size_t DBGManager_GetGlobalVariableAdrFromName(char *VariableName)\r
-{\r
-       if ((DBGType & DBG_ELFDWARF))\r
-       {\r
-               return DWARFManager_GetGlobalVariableAdrFromName(VariableName);\r
-       }\r
-       else\r
-       {\r
-               return 0;\r
-       }\r
-}\r
-\r
-\r
+#if 0\r
 // Get local variable's type encoding based on his address and Index\r
 // Return the type encoding found\r
 // Return 0 if no type encoding has been found\r
@@ -448,6 +484,71 @@ char *DBGManager_GetGlobalVariableValue(size_t Index)
 }\r
 \r
 \r
+// Get local variable's type name based on his Index\r
+// Return type name's text pointer found\r
+// Return NULL if no type name has been found\r
+char *DBGManager_GetLocalVariableTypeName(size_t Adr, size_t Index)\r
+{\r
+       if ((DBGType & DBG_ELFDWARF))\r
+       {\r
+               return DWARFManager_GetLocalVariableTypeName(Adr, Index);\r
+       }\r
+       else\r
+       {\r
+               return  NULL;\r
+       }\r
+}\r
+\r
+\r
+// Get local variable Op based on his Index\r
+// Return variable Op's found\r
+// Return 0 if no variable Op has been found\r
+size_t DBGManager_GetLocalVariableOp(size_t Adr, size_t Index)\r
+{\r
+       if ((DBGType & DBG_ELFDWARF))\r
+       {\r
+               return DWARFManager_GetLocalVariableOp(Adr, Index);\r
+       }\r
+       else\r
+       {\r
+               return  0;\r
+       }\r
+}\r
+\r
+\r
+// Get local variable name based on his Index\r
+// Return variable name's text pointer found\r
+// Return NULL if no variable name has been found\r
+char *DBGManager_GetLocalVariableName(size_t Adr, size_t Index)\r
+{\r
+       if ((DBGType & DBG_ELFDWARF))\r
+       {\r
+               return DWARFManager_GetLocalVariableName(Adr, Index);\r
+       }\r
+       else\r
+       {\r
+               return  NULL;\r
+       }\r
+}\r
+\r
+\r
+// Get global variable name based on his Index\r
+// Return variable name's text pointer found\r
+// Return NULL if no variable name has been found\r
+char *DBGManager_GetGlobalVariableName(size_t Index)\r
+{\r
+       if ((DBGType & DBG_ELFDWARF))\r
+       {\r
+               return DWARFManager_GetGlobalVariableName(Index);\r
+       }\r
+       else\r
+       {\r
+               return  NULL;\r
+       }\r
+}\r
+#endif\r
+\r
+\r
 // Get variable value based on his Adresse, Encoding Type and Size\r
 // Return value as a text pointer\r
 // Note: Pointer may point on a 0 length text\r
@@ -571,70 +672,6 @@ char *DBGManager_GetVariableValueFromAdr(size_t Adr, size_t TypeEncoding, size_t
 }\r
 \r
 \r
-// Get local variable's type name based on his Index\r
-// Return type name's text pointer found\r
-// Return NULL if no type name has been found\r
-char *DBGManager_GetLocalVariableTypeName(size_t Adr, size_t Index)\r
-{\r
-       if ((DBGType & DBG_ELFDWARF))\r
-       {\r
-               return DWARFManager_GetLocalVariableTypeName(Adr, Index);\r
-       }\r
-       else\r
-       {\r
-               return  NULL;\r
-       }\r
-}\r
-\r
-\r
-// Get local variable Op based on his Index\r
-// Return variable Op's found\r
-// Return 0 if no variable Op has been found\r
-size_t DBGManager_GetLocalVariableOp(size_t Adr, size_t Index)\r
-{\r
-       if ((DBGType & DBG_ELFDWARF))\r
-       {\r
-               return DWARFManager_GetLocalVariableOp(Adr, Index);\r
-       }\r
-       else\r
-       {\r
-               return  0;\r
-       }\r
-}\r
-\r
-\r
-// Get local variable name based on his Index\r
-// Return variable name's text pointer found\r
-// Return NULL if no variable name has been found\r
-char *DBGManager_GetLocalVariableName(size_t Adr, size_t Index)\r
-{\r
-       if ((DBGType & DBG_ELFDWARF))\r
-       {\r
-               return DWARFManager_GetLocalVariableName(Adr, Index);\r
-       }\r
-       else\r
-       {\r
-               return  NULL;\r
-       }\r
-}\r
-\r
-\r
-// Get global variable name based on his Index\r
-// Return variable name's text pointer found\r
-// Return NULL if no variable name has been found\r
-char *DBGManager_GetGlobalVariableName(size_t Index)\r
-{\r
-       if ((DBGType & DBG_ELFDWARF))\r
-       {\r
-               return DWARFManager_GetGlobalVariableName(Index);\r
-       }\r
-       else\r
-       {\r
-               return  NULL;\r
-       }\r
-}\r
-\r
-\r
 // Get function name from address\r
 // Return function name found\r
 // Return NULL if no function name has been found\r