| 54 | }; |
| 55 | |
| 56 | class AbstractProcessManager : public std::enable_shared_from_this<AbstractProcessManager> |
| 57 | { |
| 58 | public: |
| 59 | // Enums |
| 60 | enum InterpreterStatus { RUNNING = 1, FINALIZED = 2, UNKNOWN = -1 }; |
| 61 | |
| 62 | // Constructor |
| 63 | AbstractProcessManager( |
| 64 | pid_t pid, |
| 65 | std::vector<VirtualMap>&& memory_maps, |
| 66 | MemoryMapInformation&& map_info); |
| 67 | |
| 68 | // Getters |
| 69 | pid_t Pid() const; |
| 70 | virtual const std::vector<int>& Tids() const = 0; |
| 71 | remote_addr_t getAddressFromCache(const std::string& symbol) const; |
| 72 | void registerAddressInCache(const std::string& symbol, remote_addr_t address) const; |
| 73 | |
| 74 | // Methods |
| 75 | std::vector<NativeFrame> unwindThread(pid_t tid) const; |
| 76 | bool isAddressValid(remote_addr_t addr) const; |
| 77 | remote_addr_t findInterpreterStateFromPointer(remote_addr_t pointer) const; |
| 78 | remote_addr_t findInterpreterStateFromPyRuntime(remote_addr_t runtime_addr) const; |
| 79 | remote_addr_t findInterpreterStateFromSymbols() const; |
| 80 | remote_addr_t findInterpreterStateFromElfData() const; |
| 81 | remote_addr_t findInterpreterStateFromDebugOffsets() const; |
| 82 | remote_addr_t findSymbol(const std::string& symbol) const; |
| 83 | ssize_t copyMemoryFromProcess(remote_addr_t addr, size_t size, void* destination) const; |
| 84 | template<typename T> |
| 85 | ssize_t copyObjectFromProcess(remote_addr_t addr, T* destination) const; |
| 86 | std::string getBytesFromAddress(remote_addr_t addr) const; |
| 87 | std::string getStringFromAddress(remote_addr_t addr) const; |
| 88 | std::string getCStringFromAddress(remote_addr_t addr) const; |
| 89 | remote_addr_t scanAllAnonymousMaps() const; |
| 90 | remote_addr_t scanBSS() const; |
| 91 | remote_addr_t scanHeap() const; |
| 92 | InterpreterStatus isInterpreterActive() const; |
| 93 | std::pair<int, int> findPythonVersion() const; |
| 94 | |
| 95 | void setPythonVersionFromDebugOffsets(); |
| 96 | void setPythonVersion(const std::pair<int, int>& version); |
| 97 | bool versionIsAtLeast(int required_major, int required_minor) const; |
| 98 | bool isFreeThreaded() const; |
| 99 | const python_v& offsets() const; |
| 100 | |
| 101 | protected: |
| 102 | // Data members |
| 103 | pid_t d_pid; |
| 104 | std::optional<VirtualMap> d_main_map{std::nullopt}; |
| 105 | std::optional<VirtualMap> d_bss{std::nullopt}; |
| 106 | std::optional<VirtualMap> d_heap{std::nullopt}; |
| 107 | std::vector<VirtualMap> d_memory_maps; |
| 108 | std::unique_ptr<AbstractRemoteMemoryManager> d_manager; |
| 109 | std::unique_ptr<AbstractUnwinder> d_unwinder; |
| 110 | mutable std::unordered_map<std::string, remote_addr_t> d_symbol_cache; |
| 111 | std::shared_ptr<Analyzer> d_analyzer; |
| 112 | int d_major{}; |
| 113 | int d_minor{}; |
nothing calls this directly
no outgoing calls
no test coverage detected