| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2014 Eran Ifrah |
| 5 |
// file name : LLDBPlugin.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
|
| 26 |
#ifndef DAP_DEBUGGER_CLIENT_HPP |
| 27 |
#define DAP_DEBUGGER_CLIENT_HPP |
| 28 |
|
| 29 |
#include "BreakpointsHelper.hpp" |
| 30 |
#include "DAPOutputPane.hpp" |
| 31 |
#include "DAPTextView.h" |
| 32 |
#include "DebugSession.hpp" |
| 33 |
#include "RunInTerminalHelper.hpp" |
| 34 |
#include "SessionBreakpoints.hpp" |
| 35 |
#include "asyncprocess.h" |
| 36 |
#include "clDapSettingsStore.hpp" |
| 37 |
#include "clModuleLogger.hpp" |
| 38 |
#include "cl_command_event.h" |
| 39 |
#include "dap/Client.hpp" |
| 40 |
#include "plugin.h" |
| 41 |
#include "ssh_account_info.h" |
| 42 |
|
| 43 |
#include <vector> |
| 44 |
#include <wx/stc/stc.h> |
| 45 |
|
| 46 |
class DAPMainView; |
| 47 |
class DAPTooltip; |
| 48 |
class DAPConsoleOutput; |
| 49 |
class DAPModuleView; |
| 50 |
class DAPBreakpointsView; |
| 51 |
class IProcess; |
| 52 |
class DAPWatchesView; |
| 53 |
|
| 54 |
class DebugAdapterClient : public IPlugin |
| 55 |
{ |
| 56 |
dap::Client m_client; |
| 57 |
wxString m_defaultPerspective; |
| 58 |
DebugSession m_session; |
| 59 |
clDapSettingsStore m_dap_store; |
| 60 |
IProcess* m_dap_server = nullptr; |
| 61 |
RunInTerminalHelper m_terminal_helper; |
| 62 |
wxFileName m_breakpointsFile; |
| 63 |
BreakpointsHelper* m_breakpointsHelper = nullptr; |
| 64 |
SessionBreakpoints m_sessionBreakpoints; |
| 65 |
|
| 66 |
/// ------------------------------------ |
| 67 |
/// UI elements |
| 68 |
/// ------------------------------------ |
| 69 |
DAPMainView* m_threadsView = nullptr; |
| 70 |
DAPBreakpointsView* m_breakpointsView = nullptr; |
| 71 |
DAPTextView* m_textView = nullptr; |
| 72 |
DAPOutputPane* m_outputView = nullptr; |
| 73 |
DAPTooltip* m_tooltip = nullptr; |
| 74 |
DAPWatchesView* m_watchesView = nullptr; |
| 75 |
|
| 76 |
bool m_raisOnBpHit; |
| 77 |
bool m_isPerspectiveLoaded; |
| 78 |
bool m_showThreadNames; |
| 79 |
bool m_showFileNamesOnly; |
| 80 |
|
| 81 |
friend class LLDBTooltip; |
| 82 |
|
| 83 |
private: |
| 84 |
wxString ReplacePlaceholders(const wxString& str) const; |
| 85 |
void UpdateWatches(); |
| 86 |
void DestroyUI(); |
| 87 |
void InitializeUI(); |
| 88 |
void LoadPerspective(); |
| 89 |
void ShowPane(const wxString& paneName, bool show); |
| 90 |
void ClearDebuggerMarker(); |
| 91 |
void DoCleanup(); |
| 92 |
void StartAndConnectToDapServer(); |
| 93 |
bool LaunchDAPServer(); |
| 94 |
void RefreshBreakpointsView(); |
| 95 |
bool InitialiseSession(const DapEntry& dap_server, const wxString& exepath, const wxString& args, |
| 96 |
const wxString& working_directory, const wxString& ssh_account, const clEnvList_t& env); |
| 97 |
|
| 98 |
clEnvList_t PrepareEnvForFileSystemWorkspace(const DapEntry& dap_server, bool resolve_vars); |
| 99 |
|
| 100 |
/// stop the dap server if it is running and send DEBUG_STOP event |
| 101 |
void StopProcess(); |
| 102 |
void RestoreUI(); |
| 103 |
|
| 104 |
/// Place breakpoint markers for a given editor |
| 105 |
void RefreshBreakpointsMarkersForEditor(IEditor* editor); |
| 106 |
wxString NormaliseReceivedPath(const wxString& path) const; |
| 107 |
void RegisterDebuggers(); |
| 108 |
/** |
| 109 |
* @brief return true of the debugger identified by "name" |
| 110 |
* is owned by this plugin |
| 111 |
*/ |
| 112 |
bool IsDebuggerOwnedByPlugin(const wxString& name) const; |
| 113 |
|
| 114 |
void DestroyTooltip(); |
| 115 |
|
| 116 |
public: |
| 117 |
DebugAdapterClient(IManager* manager); |
| 118 |
~DebugAdapterClient(); |
| 119 |
|
| 120 |
IManager* GetManager() { return m_mgr; } |
| 121 |
|
| 122 |
/** |
| 123 |
* @brief Should thread name column be shown in thread pane? |
| 124 |
*/ |
| 125 |
bool ShowThreadNames() const; |
| 126 |
|
| 127 |
/** |
| 128 |
* @brief Maybe convert a path to filename only for display. |
| 129 |
*/ |
| 130 |
wxString GetFilenameForDisplay(const wxString& fileName) const; |
| 131 |
|
| 132 |
protected: |
| 133 |
// Other codelite events |
| 134 |
void OnWorkspaceLoaded(clWorkspaceEvent& event); |
| 135 |
void OnWorkspaceClosed(clWorkspaceEvent& event); |
| 136 |
void OnSettings(wxCommandEvent& event); |
| 137 |
void OnInitDone(wxCommandEvent& event); |
| 138 |
void OnFileLoaded(clCommandEvent& event); |
| 139 |
void OnPageClosing(wxNotifyEvent& event); |
| 140 |
|
| 141 |
// UI debugger events |
| 142 |
void OnDebugStart(clDebugEvent& event); |
| 143 |
void OnDebugContinue(clDebugEvent& event); |
| 144 |
void OnDebugNext(clDebugEvent& event); |
| 145 |
void OnDebugStop(clDebugEvent& event); |
| 146 |
void OnDebugIsRunning(clDebugEvent& event); |
| 147 |
void OnDebugCanInteract(clDebugEvent& event); |
| 148 |
void OnDebugStepIn(clDebugEvent& event); |
| 149 |
void OnDebugStepOut(clDebugEvent& event); |
| 150 |
void OnToggleInterrupt(clDebugEvent& event); |
| 151 |
void OnDebugTooltip(clDebugEvent& event); |
| 152 |
void OnDebugQuickDebug(clDebugEvent& event); |
| 153 |
void OnDebugCoreFile(clDebugEvent& event); |
| 154 |
void OnDebugAttachToProcess(clDebugEvent& event); |
| 155 |
void OnDebugDeleteAllBreakpoints(clDebugEvent& event); |
| 156 |
void OnDebugEnableAllBreakpoints(clDebugEvent& event); |
| 157 |
void OnDebugDisableAllBreakpoints(clDebugEvent& event); |
| 158 |
void OnDebugNextInst(clDebugEvent& event); |
| 159 |
void OnDebugVOID(clDebugEvent& event); |
| 160 |
void OnDebugShowCursor(clDebugEvent& event); |
| 161 |
|
| 162 |
void OnBuildStarting(clBuildEvent& event); |
| 163 |
void OnDestroyTip(clCommandEvent& event); |
| 164 |
|
| 165 |
void OnAddWatch(wxCommandEvent& event); |
| 166 |
void OnProcessOutput(clProcessEvent& event); |
| 167 |
void OnProcessTerminated(clProcessEvent& event); |
| 168 |
void OnIdle(wxIdleEvent& event); |
| 169 |
|
| 170 |
// DAP events |
| 171 |
void OnDapExited(DAPEvent& event); |
| 172 |
void OnDapLaunchResponse(DAPEvent& event); |
| 173 |
void OnDapInitializedEvent(DAPEvent& event); |
| 174 |
void OnDapInitializeResponse(DAPEvent& event); |
| 175 |
void OnDapStoppedEvent(DAPEvent& event); |
| 176 |
void OnDapThreadsResponse(DAPEvent& event); |
| 177 |
void OnDapStackTraceResponse(DAPEvent& event); |
| 178 |
void OnDapSetFunctionBreakpointResponse(DAPEvent& event); |
| 179 |
void OnDapSetSourceBreakpointResponse(DAPEvent& event); |
| 180 |
void OnDapBreakpointEvent(DAPEvent& event); |
| 181 |
void OnDapRunInTerminal(DAPEvent& event); |
| 182 |
void OnDapLog(DAPEvent& event); |
| 183 |
void OnDapScopesResponse(DAPEvent& event); |
| 184 |
void OnDapVariablesResponse(DAPEvent& event); |
| 185 |
void OnDapOutputEvent(DAPEvent& event); |
| 186 |
void OnDapModuleEvent(DAPEvent& event); |
| 187 |
|
| 188 |
public: |
| 189 |
//-------------------------------------------- |
| 190 |
// Abstract methods |
| 191 |
//-------------------------------------------- |
| 192 |
void CreateToolBar(clToolBarGeneric* toolbar) override; |
| 193 |
void CreatePluginMenu(wxMenu* pluginsMenu) override; |
| 194 |
void HookPopupMenu(wxMenu* menu, MenuType type) override; |
| 195 |
void UnPlug() override; |
| 196 |
|
| 197 |
// expose these API calls to the views can use it |
| 198 |
dap::Client& GetClient() { return m_client; } |
| 199 |
int GetCurrentFrameId() const; |
| 200 |
void LoadFile(const dap::Source& sourceId, int line_number); |
| 201 |
}; |
| 202 |
|
| 203 |
#endif // LLDBDebuggerPlugin |