// 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
// 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
#include <stdlib.h>\r
#include <string.h>\r
#include <stdint.h>\r
-#include "libelf/libelf.h"\r
-#include "libelf/gelf.h"\r
+#include "libelf.h"\r
+#include "gelf.h"\r
#include "log.h"\r
#include "ELFManager.h"\r
-#include "DwarfManager.h"\r
+#include "DWARFManager.h"\r
#include "DBGManager.h"\r
#include "HWLABELManager.h"\r
#include "settings.h"\r
}\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
return 0;\r
}\r
}\r
+#endif\r
\r
\r
// Get address from symbol name\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 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
}\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
break;\r
\r
case DBG_ATE_unsigned_char:\r
- sprintf(value, "%u", (unsigned int(V.C)));\r
+ sprintf(value, "%u", (unsigned int) V.C);\r
break;\r
\r
case DBG_ATE_ptr:\r
}\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