Code::Blocks  SVN r11506
debuggerdriver.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  */
5 
6 #ifndef DEBUGGERDRIVER_H
7 #define DEBUGGERDRIVER_H
8 
9 #ifndef WX_PRECOMP
10 # ifdef __WXMSW__
11 # include <wx/msw/wrapwin.h> // Needed to prevent GetCommandLine define bug.
12 # endif
13 #endif
14 
15 #include "debugger_defs.h"
16 #include <wx/regex.h>
17 #include <globals.h>
18 
19 #define NOT_IMPLEMENTED() \
20  do { \
21  DebugLog(wxString(cbC2U(__PRETTY_FUNCTION__)) + _T(": Not implemented in driver")); \
22  Log(wxString(cbC2U(__PRETTY_FUNCTION__)) + _T(": Not implemented in driver")); \
23  } while(0)
24 
25 class DebuggerGDB;
26 class Compiler;
27 class ProjectBuildTarget;
28 
29 WX_DEFINE_ARRAY(DebuggerCmd*, DebuggerCommands);
30 
32 {
33  public:
39  {
40  Low = 0,
42  };
43  typedef std::vector<cb::shared_ptr<cbStackFrame> > StackFrameContainer;
44  typedef std::vector<cb::shared_ptr<cbThread> > ThreadsContainer;
45 
46  DebuggerDriver(DebuggerGDB* plugin);
47  virtual ~DebuggerDriver();
48 
49  void Log(const wxString& msg);
50  void DebugLog(const wxString& msg);
51 
53 
55  // BEFORE PROCESS STARTS - BEGIN
57 
59  virtual void AddDirectory(const wxString& dir);
60 
62  virtual void ClearDirectories();
63 
65  virtual void SetWorkingDirectory(const wxString& dir);
66 
68  virtual void SetArguments(const wxString& args);
69 
71  virtual wxString GetCommandLine(const wxString& debugger,
72  const wxString& debuggee,
73  const wxString &userArguments) = 0;
74 
76  virtual wxString GetCommandLine(const wxString& debugger, int pid, const wxString &userArguments) = 0;
77 
79  virtual void SetTarget(ProjectBuildTarget* target) = 0;
80 
84  virtual void Prepare(bool isConsole, int printElements) = 0;
85 
87  virtual void Start(bool breakOnEntry) = 0;
88 
90  // BEFORE PROCESS STARTS - END
92 
94  virtual void Stop() = 0;
95 
96  virtual void Continue() = 0;
97  virtual void Step() = 0;
98  virtual void StepInstruction() = 0;
99  virtual void StepIntoInstruction() = 0;
100  virtual void StepIn() = 0;
101  virtual void StepOut() = 0;
102  virtual void SetNextStatement(const wxString& filename, int line) = 0;
103  virtual void Backtrace() = 0;
104  virtual void Disassemble() = 0;
105  virtual void CPURegisters() = 0;
106  virtual void SwitchToFrame(size_t number) = 0;
107  virtual void SetVarValue(const wxString& var, const wxString& value) = 0;
108  virtual void MemoryDump() = 0;
109  virtual void RunningThreads() = 0;
110 
111  virtual void InfoFrame() = 0;
112  virtual void InfoDLL() = 0;
113  virtual void InfoFiles() = 0;
114  virtual void InfoFPU() = 0;
115  virtual void InfoSignals() = 0;
116 
117  virtual void EnableCatchingThrow(bool enable) = 0;
118 
123  virtual void AddBreakpoint(cb::shared_ptr<DebuggerBreakpoint> bp) = 0;
124 
128  virtual void RemoveBreakpoint(cb::shared_ptr<DebuggerBreakpoint> bp) = 0;
129 
134  virtual void EvaluateSymbol(const wxString& symbol, const wxRect& tipRect) = 0;
135 
141  virtual void UpdateWatches(cb::shared_ptr<GDBWatch> localsWatch, cb::shared_ptr<GDBWatch> funcArgsWatch,
142  WatchesContainer &watches) = 0;
143  virtual void UpdateWatch(cb::shared_ptr<GDBWatch> const &watch) = 0;
144  virtual void UpdateWatchLocalsArgs(cb::shared_ptr<GDBWatch> const &watch, bool locals) = 0;
145 
147  virtual void Attach(int pid) = 0;
149  virtual void Detach() = 0;
150 
152  virtual void ParseOutput(const wxString& output) = 0;
153 
155  virtual bool IsDebuggingStarted() const = 0;
157  bool IsProgramStopped() const { return m_ProgramIsStopped; }
158  void MarkProgramStopped(bool stopped) { m_ProgramIsStopped = stopped; }
160  bool IsQueueBusy() const { return m_QueueBusy; }
162  void SetChildPID(long pid) { m_ChildPID = pid; }
164  long GetChildPID() const { return m_ChildPID; }
166  virtual void SwitchThread(size_t threadIndex) = 0;
167 
168 #ifdef __WXMSW__
169 
170  virtual bool UseDebugBreakProcess() = 0;
171 #endif
173 
175  void ShowFile(const wxString& file, int line);
176 
177  void QueueCommand(DebuggerCmd* dcmd, QueuePriority prio = Low);
179  void RunQueue();
180  void RemoveTopCommand(bool deleteIt = true);
181 
182  const StackFrameContainer & GetStackFrames() const;
183  StackFrameContainer & GetStackFrames();
184 
185  const ThreadsContainer & GetThreads() const;
186  ThreadsContainer & GetThreads();
187 
189  const Cursor& GetCursor() const { return m_Cursor; }
191  void SetCursor(const Cursor& cursor) { m_Cursor = cursor; }
192 
193  void ResetCurrentFrame();
194  int GetCurrentFrame() const { return m_currentFrameNo; }
196  void SetCurrentFrame(int number, bool user_selected);
197 
200  void NotifyCursorChanged();
201 
203  virtual void DetermineLanguage() {};
204  protected:
206  void ResetCursor();
207  protected:
208  // the debugger plugin
210 
211  // convenience properties for starting up
215 
216  // cursor related
220 
222 
223  // commands
224  DebuggerCommands m_DCmds;
226 
227  StackFrameContainer m_backtrace;
228  ThreadsContainer m_threads;
231 
233 };
234 
235 #endif // DEBUGGERDRIVER_H
virtual void RemoveBreakpoint(cb::shared_ptr< DebuggerBreakpoint > bp)=0
Remove a breakpoint.
void SetCursor(const Cursor &cursor)
Set debugger&#39;s cursor.
virtual void StepIn()=0
void NotifyCursorChanged()
Called by implementations to notify cursor changes.
virtual void UpdateWatchLocalsArgs(cb::shared_ptr< GDBWatch > const &watch, bool locals)=0
virtual ~DebuggerDriver()
void ShowFile(const wxString &file, int line)
Show a file/line without changing the cursor.
virtual void ParseOutput(const wxString &output)=0
Parse debugger&#39;s output.
virtual void UpdateWatches(cb::shared_ptr< GDBWatch > localsWatch, cb::shared_ptr< GDBWatch > funcArgsWatch, WatchesContainer &watches)=0
Update watches.
virtual void AddDirectory(const wxString &dir)
Add a directory in search list.
virtual void Continue()=0
void RunQueue()
runs the next command in the queue, if it is idle
std::vector< cb::shared_ptr< GDBWatch > > WatchesContainer
DebuggerGDB * m_pDBG
virtual void StepIntoInstruction()=0
wxString GetDebuggersWorkingDirectory() const
bool IsProgramStopped() const
Is the program stopped?
virtual void SetArguments(const wxString &args)
Set the execution arguments.
virtual void Start(bool breakOnEntry)=0
Begin the debugging process by launching a program.
virtual void SwitchToFrame(size_t number)=0
virtual void UpdateWatch(cb::shared_ptr< GDBWatch > const &watch)=0
StackFrameContainer m_backtrace
virtual void EvaluateSymbol(const wxString &symbol, const wxRect &tipRect)=0
Evaluate a symbol.
virtual void EnableCatchingThrow(bool enable)=0
virtual void InfoFiles()=0
QueuePriority
The priority used when adding a command in the queue.
const ThreadsContainer & GetThreads() const
returns the thread container with the current list of threads
void RemoveTopCommand(bool deleteIt=true)
removes the top command (it has finished)
virtual void SetTarget(ProjectBuildTarget *target)=0
Sets the target.
void Log(const wxString &msg)
std::vector< cb::shared_ptr< cbStackFrame > > StackFrameContainer
DebuggerGDB * GetDebugger()
const StackFrameContainer & GetStackFrames() const
returns the container with the current backtrace
virtual void StepOut()=0
virtual void SetWorkingDirectory(const wxString &dir)
Set the working directory.
virtual void DetermineLanguage()
Determine language is debugged.
virtual void SwitchThread(size_t threadIndex)=0
Request to switch to another thread.
virtual void InfoDLL()=0
void DebugLog(const wxString &msg)
bool IsQueueBusy() const
Is the driver processing some commands?
virtual void SetVarValue(const wxString &var, const wxString &value)=0
virtual bool IsDebuggingStarted() const =0
Is debugging started.
virtual void RunningThreads()=0
void ResetCursor()
Called by implementations to reset the cursor.
virtual void Step()=0
wxString m_FileName
virtual void Backtrace()=0
virtual void CPURegisters()=0
void NotifyDebuggeeContinued()
void SetChildPID(long pid)
Set child PID (debuggee&#39;s).
virtual void InfoFrame()=0
virtual void AddBreakpoint(cb::shared_ptr< DebuggerBreakpoint > bp)=0
Add a breakpoint.
void QueueCommand(DebuggerCmd *dcmd, QueuePriority prio=Low)
add a command in the queue. The DebuggerCmd will be deleted automatically when finished.
wxArrayString m_Dirs
std::vector< cb::shared_ptr< cbThread > > ThreadsContainer
virtual void Stop()=0
Stop debugging.
virtual void Attach(int pid)=0
Attach to process.
virtual void Detach()=0
Detach from running process.
virtual void ClearDirectories()
Clear directories search list.
virtual bool UseDebugBreakProcess()=0
Ask the driver if the debugger should be interrupted with DebugBreakProcess or Ctrl+C event...
virtual void StepInstruction()=0
ThreadsContainer m_threads
long GetChildPID() const
Get the child&#39;s (debuggee&#39;s) PID.
wxString m_LastCursorAddress
int GetCurrentFrame() const
WX_DEFINE_ARRAY(DebuggerCmd *, DebuggerCommands)
virtual void SetNextStatement(const wxString &filename, int line)=0
Abstract base class for compilers.
Definition: compiler.h:274
virtual void Disassemble()=0
void SetCurrentFrame(int number, bool user_selected)
Debugger cursor info.
Definition: debugger_defs.h:26
virtual wxString GetCommandLine(const wxString &debugger, const wxString &debuggee, const wxString &userArguments)=0
Get the command-line to launch the debugger.
virtual void MemoryDump()=0
DebuggerDriver(DebuggerGDB *plugin)
const Cursor & GetCursor() const
Get debugger&#39;s cursor.
Represents a Code::Blocks project build target.
DebuggerCmd * CurrentCommand()
returns the currently executing command
DebuggerCommands m_DCmds
wxString m_WorkingDir
virtual void Prepare(bool isConsole, int printElements)=0
Prepares the debugging process by setting up search dirs etc.
virtual void InfoSignals()=0
Basic interface for debugger commands.
Definition: debugger_defs.h:49
int GetUserSelectedFrame() const
void MarkProgramStopped(bool stopped)
virtual void InfoFPU()=0