24 #include "wx/msw/wrapwin.h"         32 #define GDB_PROMPT _T("cb_gdb:")    33 #define FULL_GDB_PROMPT _T(">>>>>>") GDB_PROMPT    37 static wxRegEx reThreadSwitch2(
_T(
"^\\[Switching to thread .*\\]#0[ \t]+(0x[A-Fa-f0-9]+) in (.*) from (.*):([0-9]+)"));
    45 static wxRegEx reBreak(
_T(
"\032*([A-Za-z]*[:]*)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"));
    50 static wxRegEx reCatchThrow(
_T(
"^Catchpoint ([0-9]+) \\(exception thrown\\), (0x[0-9a-f]+) in (.+) from (.+)$"));
    82     m_CygwinPresent(false),
    83     m_BreakOnEntry(false),
    84     m_ManualBreakOnEntry(false),
    88     m_attachedToProcess(false),
   107     cmd << 
_T(
" -fullname");    
   108     cmd << _T(
" -quiet");       
   109     cmd << 
wxT(
" ") << userArguments;
   110     cmd << _T(
" -args ") << debuggee;
   120     cmd << 
_T(
" -fullname");    
   121     cmd << _T(
" -quiet");       
   122     cmd << 
wxT(
" ") << userArguments;
   137     if (platform::windows)
   160     if (platform::windows && isConsole)
   198             for (
unsigned int i = 0; i < initCmds.
GetCount(); ++i)
   207             for (
unsigned int i = 0; i < initCmds.
GetCount(); ++i)
   216     if (rd && rd->
IsOk())
   230             for (
unsigned int i = 0; i < initCmds.
GetCount(); ++i)
   239             for (
unsigned int i = 0; i < initCmds.
GetCount(); ++i)
   274     LONG lRegistryAPIresult;
   278     DWORD dwBufLen=
BUFSIZE*
sizeof(TCHAR);
   281     lRegistryAPIresult = RegOpenKeyEx( HKEY_CURRENT_USER,
   282                          TEXT(
"Software\\Cygnus Solutions\\Cygwin\\mounts v2"),
   283                          0, KEY_QUERY_VALUE, &hKey_CU );
   284     if ( lRegistryAPIresult == ERROR_SUCCESS )
   287         lRegistryAPIresult = RegQueryValueEx( hKey_CU, TEXT(
"cygdrive prefix"), 
NULL, 
NULL,
   288                              (LPBYTE) szCygwinRoot, &dwBufLen);
   294     if ( lRegistryAPIresult != ERROR_SUCCESS )
   297         lRegistryAPIresult = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
   298                              TEXT(
"SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2"),
   299                              0, KEY_QUERY_VALUE, &hKey_LM );
   300         if ( lRegistryAPIresult != ERROR_SUCCESS )
   308         lRegistryAPIresult = RegQueryValueEx( hKey_LM, TEXT(
"cygdrive prefix"), 
NULL, 
NULL,
   309                              (LPBYTE) szCygwinRoot, &dwBufLen);
   313     if ( (lRegistryAPIresult != ERROR_SUCCESS) || (dwBufLen > 
BUFSIZE*
sizeof(TCHAR)) )
   321     RegCloseKey( hKey_CU ); 
   322     RegCloseKey( hKey_LM ); 
   330     unsigned int i=0, EscCount=0;
   348     wxString PathWithoutEsc(path); PathWithoutEsc.
Remove(0, EscCount);
   361         PathWithoutEsc.
Replace(DriveLetter, DriveLetter + 
_T(
":"), 
false);
   366     for (i=0; i<EscCount; i++)
   368     path += PathWithoutEsc;
   379     bool remoteDebugging = rd && rd->
IsOk();
   380     return !remoteDebugging;
   398     if (
Manager::Get()->GetDebuggerManager()->UpdateDisassembly())
   406     bool remoteDebugging = rd && rd->
IsOk();
   445         bool remoteDebugging = rd && rd->
IsOk();
   500     if (platform::windows)
   508     if (platform::windows)
   533     if (
Manager::Get()->GetDebuggerManager()->UpdateThreads())
   544     if (platform::windows)
   580     if (
Manager::Get()->GetDebuggerManager()->UpdateBacktrace())
   591         if (bp->func.IsEmpty() && !bp->lineText.IsEmpty())
   593             wxRegEx reCtorDtor(
_T(
"([0-9A-z_]+)::([~]?)([0-9A-z_]+)[ \t\(]*"));
   594             if (reCtorDtor.
Matches(bp->lineText))
   602                     bp->func << 
_T(
"::");
   604                     bp->func << strMethod;
   619     if (bp && bp->index != -1)
   637     bool updateWatches = 
false;
   638     if (localsWatch && localsWatch->IsAutoUpdateEnabled())
   641         updateWatches = 
true;
   643     if (funcArgsWatch && funcArgsWatch->IsAutoUpdateEnabled())
   646         updateWatches = 
true;
   649     for (WatchesContainer::iterator it = watches.begin(); it != watches.end(); ++it)
   651         WatchesContainer::reference watch = *it;
   652         if (watch->IsAutoUpdateEnabled())
   655             updateWatches = 
true;
   708     else if (!platform::windows && 
m_ChildPID == 0)
   729     buffer << output << 
_T(
'\n');
   744     int changeFrameAddr = 0 ;
   753         while (!buffer.
empty() && buffer.
Last() == _T(
'>') && cnt--)
   755         if (!buffer.
empty() && buffer.
Last() == _T(
'\n'))
   777     for (
unsigned int i = 0; i < lines.
GetCount(); ++i)
   787         if (lines[i].StartsWith(_T(
"GNU gdb")))
   790             m_pDBG->
Log(
_(
"Debugger name and version: ") + lines[i]);
   795                 m_pDBG->
Log(_T(
"Unable to determine the version of gdb"));
   817         else if (   lines[i].StartsWith(_T(
"Error creating process"))
   818                  || lines[i].StartsWith(_T(
"Program exited"))
   819                  || lines[i].StartsWith(
wxT(
"Program terminated with signal"))
   820                  || lines[i].StartsWith(
wxT(
"During startup program exited"))
   821                  || lines[i].Contains(_T(
"program is not being run"))
   822                  || lines[i].Contains(_T(
"Target detached"))
   833         else if (lines[i].Contains(_T(
"(no debugging symbols found)")))
   837         else if (lines[i].StartsWith(_T(
"Program received signal SIG")))
   842             if (   lines[i].StartsWith(_T(
"Program received signal SIGINT"))
   843                 || lines[i].StartsWith(_T(
"Program received signal SIGTRAP"))
   844                 || lines[i].StartsWith(_T(
"Program received signal SIGSTOP")) )
   854                 if (
Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog())
   866         else if (   lines[i].StartsWith(_T(
"Error "))
   867                  || lines[i].StartsWith(_T(
"No such"))
   868                  || lines[i].StartsWith(_T(
"Cannot evaluate")) )
   873         else if (   (lines[i].StartsWith(_T(
"Cannot find bounds of current function")))
   874                  || (lines[i].StartsWith(_T(
"No stack"))) )
   884         else if (lines[i].StartsWith(_T(
"Pending breakpoint ")))
   905                     newbpstr = lines[++i];
   914                     if (platform::windows)
   931                     cb::shared_ptr<DebuggerBreakpoint> bp = state.
GetBreakpoint(bpindex);
   945         else if (lines[i].StartsWith(
wxT(
"Breakpoint ")))
   953                 if (bp && bp->wantsCondition)
   955                     bp->wantsCondition = 
false;
   962         else if (lines[i].StartsWith(
wxT(
"Temporary breakpoint")))
  1066         if (1 == changeFrameAddr)
  1088     if ( reBreak_in.
Matches(line) )
  1100             if (platform::windows)
  1111             lineStr = reBreak_in.
GetMatch(line, 3);
  1121         m_pDBG->
Log(
_(
"The program has stopped on a breakpoint but the breakpoint format is not recognized:"));
 virtual void StepIntoInstruction()
Command to get a watched variable's type. 
static wxRegEx reBreak3(_T("^(0x[A-Fa-f0-9]+) in (.*)"))
DLLIMPORT wxArrayString GetArrayFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
Command that notifies the debugger plugin that the debuggee has been continued. 
Command to add a data breakpoint. 
static void Display(const wxString &title, const wxString &message, unsigned int delay=5000, unsigned int hysteresis=1)
virtual void Start(bool breakOnEntry)
Begin the debugging process by launching a program. 
void NotifyCursorChanged()
Called by implementations to notify cursor changes. 
virtual void Detach()
Detach from running process. 
virtual void Attach(int pid)
Attach to process. 
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
Command to setup an exception breakpoint (for a throw or a catch). 
wxString m_CygdrivePrefix
Base class for all Continue type of commands. 
virtual void RunningThreads()
void CorrectCygwinPath(wxString &path)
Command to remove a breakpoint. 
wxString additionalCmds
commands after remote connection established 
void RunQueue()
runs the next command in the queue, if it is idle 
std::vector< cb::shared_ptr< GDBWatch > > WatchesContainer
wxString additionalShellCmdsAfter
shell commands after remote connection established 
static wxRegEx rePendingFound1(_T("^Breakpoint[ \+([0-9]+),.*"))
RemoteDebugging m_MergedRDInfo
virtual void SwitchThread(size_t threadIndex)
Request to switch to another thread. 
virtual void EvaluateSymbol(const wxString &symbol, const wxRect &tipRect)
Evaluate a symbol. 
bool Matches(const wxString &text, int flags=0) const
static wxRegEx reChildPid2(_T("\New [tT]hread[ \+[0-9]+\[xA-Fa-f0-9-]+\"))
Command to get info about running threads. 
virtual void SwitchToFrame(size_t number)
void Log(const wxString &msg, Logger::level level=Logger::info)
wxString & Remove(size_t pos)
void RemoveTopCommand(bool deleteIt=true)
removes the top command (it has finished) 
static wxRegEx reInferiorExited(wxT("^\Inferior[ \].+[ \]exited normally\$"), wxRE_EXTENDED)
long int line
If -1, no line info. 
Action-only debugger command to signal the watches tree to update. 
void Log(const wxString &msg)
wxString AfterFirst(wxUniChar ch) const
void RemoveBreakpoint(int idx, bool removeFromDriver=true)
virtual void SetNextStatement(const wxString &filename, int line)
static wxRegEx reInferiorExitedWithCode(wxT("^\[Ii]nferior[ \].+[ \]exited[ \]with[ \]code[ \]([0-9]+)\$"), wxRE_EXTENDED)
wxString additionalCmdsBefore
commands before establishing remote connection 
Command which tries to find the current cursor position. 
wxString GetInitCommands()
Command to initialize a disassembly. 
virtual void CPURegisters()
Command to get info about current program and state. 
bool IsAttachedToProcess() const
void DetectCygwinMount(void)
wxString BeforeFirst(wxUniChar ch, wxString *rest=NULL) const
wxString GetDisassemblyFlavorCommand()
static wxRegEx reBreak(_T("\2*([A-Za-z]*[:]*)([^:]+):([0-9]+):[0-9]+:[begmidl]+:(0x[0-9A-Fa-f]+)"))
DebuggerManager * GetDebuggerManager() const
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
Command to determine the debugging (working) language. 
virtual void MemoryDump()
cb::shared_ptr< DebuggerBreakpoint > GetBreakpointByNumber(int num)
Command to add a search directory for source files in debugger's paths. 
virtual wxString GetCommandLine(const wxString &debugger, const wxString &debuggee, const wxString &userArguments)
Get the command-line to launch the debugger. 
static wxRegEx reCatchThrow(_T("^Catchpoint ([0-9]+) \exception thrown\, (0x[0-9a-f]+) in (.+) from (.+)$"))
wxString & RemoveLast(size_t n=1)
const wxString g_EscapeChar
cbDisassemblyDlg * GetDisassemblyDialog()
Returns a pointer to the disassembly dialog. 
void ResetCursor()
Called by implementations to reset the cursor. 
Command to change the current frame. 
wxString Left(size_t count) const
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
RemoteDebugging * GetRemoteDebuggingInfo()
DebuggerState & GetState()
bool IsSameAs(const wxString &s, bool caseSensitive=true) const
void SetChildPID(long pid)
Set child PID (debuggee's). 
int HasBreakpoint(const wxString &file, int line, bool temp)
bool GetMatch(size_t *start, size_t *len, size_t index=0) const
static wxRegEx reThreadSwitch(_T("^\Switching to thread .*\#0[ \+(0x[A-Fa-f0-9]+) in (.*) from (.*)"))
wxString & Item(size_t nIndex)
This command is similar to DebuggerCmd The only difference is that instead of logging its output in t...
Command to run a backtrace. 
Utility command to set a breakpoint condition. 
virtual void StepInstruction()
Command to add a breakpoint. 
void QueueCommand(DebuggerCmd *dcmd, QueuePriority prio=Low)
add a command in the queue. The DebuggerCmd will be deleted automatically when finished. 
static wxRegEx reCatchThrowNoFile(_T("^Catchpoint ([0-9]+) \exception thrown\, (0x[0-9a-f]+) in (.+)$"))
virtual void Clear(const cbStackFrame &frame)=0
virtual void ParseOutput(const wxString &output)
Parse debugger's output. 
DebuggerConfiguration & GetActiveConfigEx()
MacrosManager * GetMacrosManager() const
void EnableCatchingThrow(bool enable)
virtual void AddBreakpoint(cb::shared_ptr< DebuggerBreakpoint > bp)
Add a breakpoint. 
const wxString & _(const wxString &string)
virtual void Disassemble()
void ReplaceMacros(wxString &buffer, ProjectBuildTarget *target=nullptr, bool subrequest=false)
virtual void Prepare(bool isConsole, int printElements)
Prepares the debugging process by setting up search dirs etc. 
virtual void UpdateWatchLocalsArgs(cb::shared_ptr< GDBWatch > const &watch, bool locals)
int First(wxUniChar ch) const
static wxRegEx reChildPid1(_T("Thread[ \+[xA-Fa-f0-9-]+[ \+\LWP ([0-9]+)\]"))
bool ToLong(long *val, int base=10) const
GDB_driver(DebuggerGDB *plugin)
static wxRegEx reThreadSwitch2(_T("^\Switching to thread .*\#0[ \+(0x[A-Fa-f0-9]+) in (.*) from (.*):([0-9]+)"))
virtual bool UseDebugBreakProcess()
Ask the driver if the debugger should be interrupted with DebugBreakProcess or Ctrl+C event...
Command to the attach to a process. 
virtual wxString GetDisassemblyFlavour(void)
cbBreakpointsDlg * GetBreakpointDialog()
Returns a pointer to the breakpoints dialog. 
virtual void ParseOutput(const wxString &output)
Parses the command's output. 
wxString CleanStringValue(wxString value)
RemoteDebuggingMap & GetRemoteDebuggingMap(cbProject *project=0)
static wxRegEx reTempBreakFound(wxT("^[Tt]emporary[ \breakpoint[ \([0-9]+),.*"))
bool m_ManualBreakOnEntry
bool EndsWith(const wxString &suffix, wxString *rest=NULL) const
virtual void RemoveBreakpoint(cb::shared_ptr< DebuggerBreakpoint > bp)
Remove a breakpoint. 
Command to examine a memory region. 
bool StartsWith(const wxString &prefix, wxString *rest=NULL) const
wxString additionalShellCmdsBefore
shell commands before establishing remote connection 
Represents a Code::Blocks project build target. 
virtual void UpdateWatches(cb::shared_ptr< GDBWatch > localsWatch, cb::shared_ptr< GDBWatch > funcArgsWatch, WatchesContainer &watches)
Update watches. 
Command to obtain register info. 
DebuggerCmd * CurrentCommand()
returns the currently executing command 
wxUniChar GetChar(size_t n) const
virtual void SetVarValue(const wxString &var, const wxString &value)
virtual void DetermineLanguage()
Determine language is debugged. 
static wxRegEx rePendingFound(_T("^Pending[ \+breakpoint[ \+[\+([A-Za-z]:)([^:]+):([0-9]+)\*"))
ProjectBuildTarget * m_pTarget
Command to the detach from the process. 
void MergeWith(const RemoteDebugging &other)
Basic interface for debugger commands. 
static wxString Format(const wxString &format,...)
virtual void SetTarget(ProjectBuildTarget *target)
Sets the target. 
void HandleMainBreakPoint(const wxRegEx &reBreak, wxString line)
void DebugLog(const wxString &msg, Logger::level level=Logger::info)
virtual void Stop()
Stop debugging. 
static wxRegEx reBreak2(_T("^(0x[A-Fa-f0-9]+) in (.*) from (.*)"))
cb::shared_ptr< DebuggerBreakpoint > GetBreakpoint(int idx)
virtual void UpdateWatch(const cb::shared_ptr< GDBWatch > &watch)