project.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include <string>
  3. #include <stdint.h>
  4. #include <cassert>
  5. #include <list>
  6. #include <llvm/ADT/ilist.h>
  7. #include "symtab.h"
  8. struct Function;
  9. struct CALL_GRAPH;
  10. typedef llvm::iplist<Function> FunctionListType;
  11. typedef FunctionListType lFunction;
  12. typedef lFunction::iterator ilFunction;
  13. struct Project
  14. {
  15. SYMTAB symtab; /* Global symbol table */
  16. std::string m_fname;
  17. FunctionListType pProcList;
  18. CALL_GRAPH * callGraph; /* Pointer to the head of the call graph */
  19. Project() {}
  20. // no copies
  21. Project(const Project&) = delete;
  22. const Project &operator=(const Project & l) =delete;
  23. // only moves
  24. Project(Project && l)
  25. {
  26. m_fname =l.m_fname;
  27. size_t before=l.pProcList.size();
  28. pProcList.splice(pProcList.end(),l.pProcList);
  29. callGraph=l.callGraph;
  30. l.m_fname.clear();
  31. l.pProcList.clear();
  32. l.callGraph=0;
  33. assert(before==pProcList.size());
  34. }
  35. Project &operator=(Project && l)
  36. {
  37. if(this == &l)
  38. return *this;
  39. m_fname =l.m_fname;
  40. size_t before=l.pProcList.size();
  41. pProcList.splice(pProcList.end(),l.pProcList);
  42. callGraph=l.callGraph;
  43. l.m_fname.clear();
  44. l.pProcList.clear();
  45. l.callGraph=0;
  46. assert(before==pProcList.size());
  47. return *this;
  48. }
  49. static Project *get();
  50. public:
  51. ilFunction funcIter(Function *to_find);
  52. ilFunction findByEntry(uint32_t entry);
  53. ilFunction createFunction();
  54. bool valid(ilFunction iter);
  55. int getSymIdxByAdd(uint32_t adr);
  56. bool validSymIdx(size_t idx);
  57. size_t symbolSize(size_t idx);
  58. hlType symbolType(size_t idx);
  59. const std::string &symbolName(size_t idx);
  60. const SYM &getSymByIdx(size_t idx) const;
  61. protected:
  62. void writeGlobSymTable();
  63. };
  64. //extern Project g_proj;