Patch #3241 2011-12-11 15:29
nevelo
Support for MIPS GDB & ability to run an ext tool to break.- Download
- 3241-Support_for_MI.patch (15.1 KB)
- Category
- Plugin::FeatureAdd
- Status
- Open
- Close date
- Assigned to
- tpetrov
Index: debuggergdb.cpp
===================================================================
--- debuggergdb.cpp (revision 7632)
+++ debuggergdb.cpp (working copy)
@@ -2110,21 +2110,33 @@
else
wxKill(pid, wxSIGINT);
#else
- // windows gdb can interrupt the running process too. yay!
- bool done = false;
- if (DebugBreakProcessFunc && pid > 0)
- {
- Log(_("Trying to pause the running process..."));
- HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
- if (proc)
- {
- DebugBreakProcessFunc(proc); // yay!
- CloseHandle(proc);
- done = true;
- }
- else
- Log(_("Failed."));
- }
+
+ wxString run_tool_on_break = Manager::Get()->GetConfigManager(_T("debugger"))->Read(_T("run_tool_on_break"), wxEmptyString);
+
+ // Sometimes with embedded systems you need to run some other tool to trigger an asynchronous break
+ if (run_tool_on_break != wxEmptyString)
+ {
+ Log(wxString::Format(_T("Starting external tool to break execution (%s)..."), run_tool_on_break.c_str()));
+ system(run_tool_on_break.ToAscii());
+ }
+ else
+ {
+ // windows gdb can interrupt the running process too. yay!
+ bool done = false;
+ if (DebugBreakProcessFunc && pid > 0)
+ {
+ Log(_("Trying to pause the running process..."));
+ HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid);
+ if (proc)
+ {
+ DebugBreakProcessFunc(proc); // yay!
+ CloseHandle(proc);
+ done = true;
+ }
+ else
+ Log(_("Failed."));
+ }
+ }
#endif
// Notify debugger plugins for end of debug session
PluginManager *plm = Manager::Get()->GetPluginManager();
Index: debuggeroptionsdlg.cpp
===================================================================
--- debuggeroptionsdlg.cpp (revision 7632)
+++ debuggeroptionsdlg.cpp (working copy)
@@ -39,6 +39,7 @@
XRCCTRL(*this, "choDisassemblyFlavor", wxChoice)->SetSelection(cfg->ReadInt(_T("disassembly_flavor"), 0));
XRCCTRL(*this, "txtInstructionSet", wxTextCtrl)->SetValue(cfg->Read(_T("instruction_set"), wxEmptyString));
XRCCTRL(*this, "spnArrayElems", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("single_line_array_elem_count"), 8));
+ XRCCTRL(*this, "txtRunExtToolOnBreak", wxTextCtrl)->SetValue(cfg->Read(_T("run_tool_on_break"), wxEmptyString));
}
DebuggerOptionsDlg::~DebuggerOptionsDlg()
@@ -62,6 +63,7 @@
cfg->Write(_T("disassembly_flavor"), XRCCTRL(*this, "choDisassemblyFlavor", wxChoice)->GetSelection());
cfg->Write(_T("instruction_set"), XRCCTRL(*this, "txtInstructionSet", wxTextCtrl)->GetValue());
cfg->Write(_T("single_line_array_elem_count"), XRCCTRL(*this, "spnArrayElems", wxSpinCtrl)->GetValue());
+ cfg->Write(_T("run_tool_on_break"), XRCCTRL(*this, "txtRunExtToolOnBreak", wxTextCtrl)->GetValue());
m_pPlugin->RefreshConfiguration();
}
Index: gdb_commands.h
===================================================================
--- gdb_commands.h (revision 7632)
+++ gdb_commands.h (working copy)
@@ -150,13 +150,13 @@
// ebx at 0x22ff6c, ebp at 0x22ff78, esi at 0x22ff70, edi at 0x22ff74, eip at 0x22ff7c
static wxRegEx reDisassemblyInit(_T("^Stack level [0-9]+, frame at (0x[A-Fa-f0-9]+):"));
static wxRegEx reDisassemblyInitFunc(_T("eip = (0x[A-Fa-f0-9]+) in ([^;]*)"));
-// or32 variant
+// or32/mips variant
#ifdef __WXMSW__
-static wxRegEx reDisassemblyInitFuncOR32(_T("PC = (0x[A-Fa-f0-9]+) in ([^;]*)"));
+static wxRegEx reDisassemblyInitFuncOR32_MIPS(_T("PC = (0x[A-Fa-f0-9]+) in ([^;]*)"));
#else
// not used on linux, but make sure it exists otherwise compilation fails on linux
// if(platform::windows && m_disassemblyFlavor == _T("set disassembly-flavor or32")) blabla
-static wxRegEx reDisassemblyInitFuncOR32(_T("PC = (0x[A-Fa-f0-9]+) in ([^;]*)"));
+static wxRegEx reDisassemblyInitFuncOR32_MIPS(_T("PC = (0x[A-Fa-f0-9]+) in ([^;]*)"));
#endif
// Using the running image of child Thread 46912568064384 (LWP 7051).
static wxRegEx reInfoProgramThread(_T("\\(LWP[ \t]([0-9]+)\\)"));
@@ -1135,6 +1135,11 @@
{
ParseOutputFromOR32gdbPort(output);
}
+ // MIPS register string parser
+ if(m_disassemblyFlavor == _T("set disassembly-flavor mips"))
+ {
+ ParseOutputFromMIPSgdbPort(output);
+ }
else
// use generic parser - this may work for other platforms or you may have to write your own
{
@@ -1153,6 +1158,77 @@
// m_pDriver->DebugLog(output);
}
+ void ParseOutputFromMIPSgdb
download for full patch...
History
Hi,
I added support for MIPS GDB debugging which is pretty similar to what was already there for OR32.
I also added the option to specify an external tool to be run on requesting debugger break from execution (DebuggerGDB::Break).
Some embedded setups need specific handling to break from execution (well mine does and I've seen forum posts to indicate that others also might benefit from this).
[Only added in for Win32 for the moment]
With these changes I know have a perfectly function debugger for MIPs via GDB in Code::Blocks :-)
Hi,
Unfortunately all debugger development happens in the wxpropgrid_debugger branch and the branch is quite different to trunk already, so your patch won't apply.
Can I ask you to modify it to apply on the branch?
Also can you separate in two different patches the MIPS support and the external tool break support?