Patch #3122 2011-01-21 12:50
etheranger
[Debugger branch] CDB bugfixes- Download
- 3122-Debugger_branc.patch (8.4 KB)
Index: src/plugins/debuggergdb/cdb_commands.h
===================================================================
--- src/plugins/debuggergdb/cdb_commands.h (revision 6930)
+++ src/plugins/debuggergdb/cdb_commands.h (working copy)
@@ -20,6 +20,7 @@
#include "disassemblydlg.h"
#include "parsewatchvalue.h"
+static wxRegEx reProcessInf(_T("id:[ \t]+([A-Fa-f0-9]+)[ \t]+create"));
static wxRegEx reWatch(_T("(\\+0x[A-Fa-f0-9]+ )"));
static wxRegEx reBT1(_T("([0-9]+) ([A-Fa-f0-9]+) ([A-Fa-f0-9]+) ([^[]*)"));
static wxRegEx reBT2(_T("\\[([A-z]:)(.*) @ ([0-9]+)\\]"));
@@ -127,15 +128,51 @@
}
};
+ /**
+ * Command to find the PID of the active child
+ */
+ class CdbCmd_GetPID : public DebuggerCmd
+{
+ public:
+ /** @param file The file to debug. */
+ CdbCmd_GetPID(DebuggerDriver* driver)
+ : DebuggerCmd(driver)
+ {
+ m_Cmd << _T("|.");
+ }
+ void ParseOutput(const wxString& output)
+ {
+ // Output:
+ // <decimal process num> id: <hex PID> create name: <process name>
+ wxArrayString lines = GetArrayFromString(output, _T('\n'));
+ for (unsigned int i = 0; i < lines.GetCount(); ++i)
+ {
+ if (reProcessInf.Matches(lines[i]))
+ {
+ wxString hexID = reProcessInf.GetMatch(lines[i],1);
+
+ long pid;
+ if (hexID.ToLong(&pid,16))
+ {
+ m_pDriver->SetChildPID(pid);
+ }
+ }
+ }
+ }
+};
+
/**
* Command to the attach to a process.
*/
class CdbCmd_AttachToProcess : public DebuggerCmd
{
+ private:
+ int m_pid;
public:
/** @param file The file to debug. */
CdbCmd_AttachToProcess(DebuggerDriver* driver, int pid)
- : DebuggerCmd(driver)
+ : DebuggerCmd(driver),
+ m_pid(pid)
{
m_Cmd << _T("attach ") << wxString::Format(_T("%d"), pid);
}
@@ -149,7 +186,10 @@
for (unsigned int i = 0; i < lines.GetCount(); ++i)
{
if (lines[i].StartsWith(_T("Attaching")))
+ {
m_pDriver->Log(lines[i]);
+ m_pDriver->SetChildPID(m_pid);
+ }
else if (lines[i].StartsWith(_T("Can't ")))
{
// log this and quit debugging
@@ -181,6 +221,23 @@
};
/**
+ * Command to continue execution and notify the debugger plugin.
+ */
+class CdbCmd_Continue : public DebuggerCmd
+{
+ public:
+ /** @param bp The breakpoint to set. */
+ CdbCmd_Continue(DebuggerDriver* driver)
+ : DebuggerCmd(driver,_T("g"))
+ {
+ }
+ virtual void Action()
+ {
+ m_pDriver->NotifyDebuggeeContinued();
+ }
+};
+
+/**
* Command to add a breakpoint.
*/
class CdbCmd_AddBreakpoint : public DebuggerCmd
Index: src/plugins/debuggergdb/cdb_driver.cpp
===================================================================
--- src/plugins/debuggergdb/cdb_driver.cpp (revision 6930)
+++ src/plugins/debuggergdb/cdb_driver.cpp (working copy)
@@ -22,9 +22,10 @@
#include <globals.h>
#include <infowindow.h>
-#define CDB_PROMPT0 _T("0:000>")
-#define CDB_PROMPT1 _T("0:001>")
+//#define DEBUG_CDB_COMMANDS
+#define ENABLE_WORKINGDIR_WORKAROUND
+static wxRegEx rePrompt(_T("([0-9]+:){1,2}[0-9]+>"));
static wxRegEx reBP(_T("Breakpoint ([0-9]+) hit"));
// one stack frame (to access current file; is there another way???)
// # ChildEBP RetAddr
@@ -33,6 +34,7 @@
CDB_driver::CDB_driver(DebuggerGDB* plugin)
: DebuggerDriver(plugin),
+ m_Debuggee(wxEmptyString),
m_IsStarted(false)
{
//ctor
@@ -72,7 +74,14 @@
cmd << _T(' ') << debuggee;
if (!m_WorkingDir.IsEmpty())
+ {
wxSetWorkingDirectory(m_WorkingDir);
+#ifdef ENABLE_WORKINGDIR_WORKAROUND
+ // Because of the lack of ChDir functionality for a process which has already been launched,
+ // do a dodgy workaround by starting with a dummy version of the process, then starting in the right folder later.
+ m_Debuggee.assign(debuggee);
+#endif
+ }
return cmd;
}
@@ -116,7 +125,29 @@
void CDB_driver::Prepare(bool /*isConsole*/)
{
- // default initialization
+ // The very first command won't get the right output back due to the spam on CDB launch.
+ // Throw in a dummy command to flush the output buffer.
+ m_QueueBusy = true;
+ QueueCommand(new DebuggerCmd(this,_T(".echo Clear buffer")),High);
+
+#ifdef ENABLE_WORKINGDIR_WORKAROUND
+ if (!m_Debuggee.IsEmpty())
+ {
+ // Workaround for setting the correct working dir:
+ wxString cmd = _T(".kill; .createdir ");
+ cmd << m_WorkingDir;
+ QueueCommand(new DebuggerCmd(this,cmd)); // Kill the process and CD to the right place
+
+
download for full patch...
History
etheranger 2011-01-21 12:56
Carry over most of my fixes to trunk, and some new ones in the branch:
+ Added workaround to correctly set working dir (can still be disabled by #undefining ENABLE_WORKINGDIR_WORKAROUND.
+ Grab the PID at launch so that process break / killing works - this allows setting breakpoints while running
+ NotifyDebuggeeContinued on Continue so that the cursor doesn't disappear forever after setting breakpoints while running
+ Slightly improve recognising breakpoint & assert hits