project.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include <string>
  3. #include <stdint.h>
  4. #include <cassert>
  5. #include <list>
  6. #include <boost/icl/interval.hpp>
  7. #include <boost/icl/interval_map.hpp>
  8. #include <boost/icl/split_interval_map.hpp>
  9. #include <unordered_set>
  10. #include <QtCore/QString>
  11. #include "symtab.h"
  12. #include "BinaryImage.h"
  13. #include "Procedure.h"
  14. class QString;
  15. class SourceMachine;
  16. struct CALL_GRAPH;
  17. class IProject
  18. {
  19. virtual PROG *binary()=0;
  20. virtual const QString & project_name() const =0;
  21. virtual const QString & binary_path() const =0;
  22. };
  23. class Project : public IProject
  24. {
  25. static Project *s_instance;
  26. QString m_fname;
  27. QString m_project_name;
  28. QString m_output_path;
  29. public:
  30. typedef std::list<Function> FunctionListType;
  31. typedef FunctionListType lFunction;
  32. typedef FunctionListType::iterator ilFunction;
  33. SYMTAB symtab; /* Global symbol table */
  34. FunctionListType pProcList;
  35. CALL_GRAPH * callGraph; /* Pointer to the head of the call graph */
  36. PROG prog; /* Loaded program image parameters */
  37. // no copies
  38. Project(const Project&) = delete;
  39. const Project & operator=(const Project & l) =delete;
  40. // only moves
  41. Project(); // default constructor,
  42. public:
  43. void create(const QString &a);
  44. bool load();
  45. const QString & output_path() const {return m_output_path;}
  46. const QString & project_name() const {return m_project_name;}
  47. const QString & binary_path() const {return m_fname;}
  48. QString output_name(const char *ext);
  49. ilFunction funcIter(Function *to_find);
  50. ilFunction findByEntry(uint32_t entry);
  51. ilFunction createFunction(FunctionType *f, const QString & name);
  52. bool valid(ilFunction iter);
  53. int getSymIdxByAddr(uint32_t adr);
  54. bool validSymIdx(size_t idx);
  55. size_t symbolSize(size_t idx);
  56. hlType symbolType(size_t idx);
  57. const QString & symbolName(size_t idx);
  58. const SYM & getSymByIdx(size_t idx) const;
  59. static Project * get();
  60. PROG * binary() {return &prog;}
  61. SourceMachine *machine();
  62. const FunctionListType &functions() const { return pProcList; }
  63. FunctionListType &functions() { return pProcList; }
  64. protected:
  65. void initialize();
  66. void writeGlobSymTable();
  67. };
  68. //extern Project g_proj;