| 185 | }; |
| 186 | |
| 187 | class DebugAdapter |
| 188 | { |
| 189 | IMPLEMENT_DEBUGGER_API_OBJECT(BNDebugAdapter); |
| 190 | |
| 191 | private: |
| 192 | // Function to call when the DebugAdapter wants to notify the front-end of certain events |
| 193 | // TODO: we should not use a vector here; only the DebuggerController should register one here; |
| 194 | // Other components should register their callbacks to the controller, who is responsible for notify them. |
| 195 | std::function<void(const DebuggerEvent& event)> m_eventCallback; |
| 196 | |
| 197 | protected: |
| 198 | uint64_t m_entryPoint; |
| 199 | bool m_hasEntryFunction; |
| 200 | uint64_t m_start; |
| 201 | std::string m_defaultArchitecture; |
| 202 | std::string m_originalFileName; |
| 203 | |
| 204 | public: |
| 205 | DebugAdapter(BinaryView* data); |
| 206 | virtual ~DebugAdapter() {} |
| 207 | |
| 208 | virtual bool Init() { return true; } |
| 209 | |
| 210 | virtual void SetEventCallback(std::function<void(const DebuggerEvent& event)> function) |
| 211 | { |
| 212 | m_eventCallback = function; |
| 213 | } |
| 214 | |
| 215 | [[nodiscard]] virtual bool Execute(const std::string& path, const LaunchConfigurations& configs = {}) = 0; |
| 216 | |
| 217 | [[nodiscard]] virtual bool ExecuteWithArgs(const std::string& path, const std::string& args, |
| 218 | const std::string& workingDir, const LaunchConfigurations& configs = {}) = 0; |
| 219 | |
| 220 | [[nodiscard]] virtual bool Attach(std::uint32_t pid) = 0; |
| 221 | |
| 222 | [[nodiscard]] virtual bool Connect(const std::string& server, std::uint32_t port) = 0; |
| 223 | |
| 224 | virtual bool ConnectToDebugServer(const std::string& server, std::uint32_t port); |
| 225 | |
| 226 | virtual bool DisconnectDebugServer(); |
| 227 | |
| 228 | virtual bool Detach() = 0; |
| 229 | |
| 230 | virtual bool Quit() = 0; |
| 231 | |
| 232 | virtual std::vector<DebugProcess> GetProcessList() = 0; |
| 233 | |
| 234 | virtual std::vector<DebugThread> GetThreadList() = 0; |
| 235 | |
| 236 | virtual DebugThread GetActiveThread() const = 0; |
| 237 | |
| 238 | virtual std::uint32_t GetActiveThreadId() const = 0; |
| 239 | |
| 240 | virtual bool SetActiveThread(const DebugThread& thread) = 0; |
| 241 | |
| 242 | virtual bool SetActiveThreadId(std::uint32_t tid) = 0; |
| 243 | |
| 244 | virtual bool SuspendThread(std::uint32_t tid) = 0; |
nothing calls this directly
no outgoing calls
no test coverage detected