diff --git a/src/include/cbdebugger_interfaces.h b/src/include/cbdebugger_interfaces.h index 48a5b56471..6f0a5c5741 100644 --- a/src/include/cbdebugger_interfaces.h +++ b/src/include/cbdebugger_interfaces.h @@ -85,6 +85,7 @@ class DLLIMPORT cbExamineMemoryDlg virtual void Clear() = 0; virtual wxString GetBaseAddress() = 0; virtual int GetBytes() = 0; + virtual int GetCols() = 0; virtual void AddError(const wxString& err) = 0; virtual void AddHexByte(const wxString& addr, const wxString& hexbyte) = 0; virtual void EnableWindow(bool enable) = 0; diff --git a/src/src/examinememorydlg.cpp b/src/src/examinememorydlg.cpp index 57fd218b66..c5c918fae7 100644 --- a/src/src/examinememorydlg.cpp +++ b/src/src/examinememorydlg.cpp @@ -1,7 +1,7 @@ /* * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3 * http://www.gnu.org/licenses/gpl-3.0.html - * + * Modified MicroSourceCode https://github.com/MicroSourceCode * $Revision$ * $Id$ * $HeadURL$ @@ -22,11 +22,10 @@ #include "examinememorydlg.h" #include "debuggermanager.h" -#include // For PRIx64 - BEGIN_EVENT_TABLE(ExamineMemoryDlg, wxPanel) EVT_BUTTON(XRCID("btnGo"), ExamineMemoryDlg::OnGo) EVT_COMBOBOX(XRCID("cmbBytes"), ExamineMemoryDlg::OnGo) + EVT_COMBOBOX(XRCID("colSelect"), ExamineMemoryDlg::OnGo) EVT_TEXT_ENTER(XRCID("txtAddress"), ExamineMemoryDlg::OnGo) END_EVENT_TABLE() @@ -43,12 +42,19 @@ ExamineMemoryDlg::ExamineMemoryDlg(wxWindow* parent) : ConfigManager *c = Manager::Get()->GetConfigManager(wxT("debugger_common")); int bytes = c->ReadInt(wxT("/common/examine_memory/size_to_show"), 32); - wxString strBytes; + int bytesCols = c->ReadInt(wxT("/common/examine_memory/columns_to_show"), 8); + wxString strBytes, strCols; strBytes << bytes; + strCols << bytesCols; + wxComboBox *combo = XRCCTRL(*this, "cmbBytes", wxComboBox); if (!combo->SetStringSelection(strBytes)) combo->SetSelection(1); // Default is 32 bytes + wxComboBox *combo2 = XRCCTRL(*this, "colSelect", wxComboBox); + if (!combo2->SetStringSelection(strCols)) + combo2->SetSelection(3); // Default is 8 columns + Clear(); } @@ -60,14 +66,19 @@ void ExamineMemoryDlg::Begin() void ExamineMemoryDlg::End() { m_pText->Thaw(); + m_pText->SetInsertionPoint(0); //Scrolling up } void ExamineMemoryDlg::Clear() { + m_ColumnsCtrl = GetCols(); m_pText->Clear(); m_LastRowStartingAddress = 0; m_ByteCounter = 0; - for (int i = 0; i < 67; ++i) + // (4 column * 2) + 4 column = 12, for 6 is m_PartLength = 18 + m_PartLength = (m_ColumnsCtrl * 2) + m_ColumnsCtrl; + + for (int i = 0; i < 128; ++i) //128 is: 32 * 3 + 32 m_LineText[i] = _T(' '); } @@ -83,6 +94,13 @@ int ExamineMemoryDlg::GetBytes() return a; } +int ExamineMemoryDlg::GetCols() +{ + long a; + XRCCTRL(*this, "colSelect", wxComboBox)->GetValue().ToLong(&a); + return a; +} + void ExamineMemoryDlg::AddError(const wxString& err) { m_pText->AppendText(err + _T('\n')); @@ -91,9 +109,9 @@ void ExamineMemoryDlg::AddError(const wxString& err) void ExamineMemoryDlg::AddHexByte(const wxString& addr, const wxString& hexbyte) { // m_pDbg->Log(_T("AddHexByte(") + addr + _T(", ") + hexbyte + _T(')')); - int bcmod = m_ByteCounter % 16; + int bcmod = m_ByteCounter % m_ColumnsCtrl; - if (m_ByteCounter == 0) + if (m_LastRowStartingAddress == 0) { // because we 'll be appending each row *after* we have consumed it // and then "addr" will point to the next row's starting address, @@ -104,42 +122,44 @@ void ExamineMemoryDlg::AddHexByte(const wxString& addr, const wxString& hexbyte) m_LastRowStartingAddress = cbDebuggerStringToAddress(addr); } -#define HEX_OFFSET(a) (a*3) -#define CHAR_OFFSET(a) (16*3 + 3 + a) + #define HEX_OFFSET(a) (a*3) +//#define CHAR_OFFSET(a) (16*3 + 3 + a) unsigned long hb; hexbyte.ToULong(&hb, 16); // m_pDbg->Log(wxString::Format(_T("hb=%d, [0]=%c, [1]=%c"), hb, hexbyte[0], hexbyte[1])); // m_pDbg->Log(wxString::Format(_T("HEX_OFFSET(bcmod)=%d, CHAR_OFFSET(bcmod)=%d"), HEX_OFFSET(bcmod), CHAR_OFFSET(bcmod))); + m_LineText[HEX_OFFSET(bcmod)] = hexbyte[0]; m_LineText[HEX_OFFSET(bcmod) + 1] = hexbyte[1]; - m_LineText[CHAR_OFFSET(bcmod)] = hb >= 32 ? wxChar(hb) : wxChar(_T('.')); + m_LineText[(m_PartLength + bcmod)] = hb >= 32 ? wxChar(hb) : wxChar(_T('.')); ++m_ByteCounter; - // flush every 16 bytes - if (m_ByteCounter != 0 && m_ByteCounter % 16 == 0) + // flush every m_ColumnsCtrl bytes + if (m_ByteCounter != 0 && m_ByteCounter % m_ColumnsCtrl == 0) { - // filled 16 bytes window; append text and reset accumulator array - if (m_ByteCounter != 16) // after the first line, - m_pText->AppendText(_T('\n')); // prepend a newline - m_LineText[23] = _T('|'); // put a "separator" in the middle (just to ease reading a bit) - - m_pText->AppendText(wxString::Format(_T("0x%" PRIx64 ": %.67s"), m_LastRowStartingAddress, m_LineText)); - for (int i = 0; i < 67; ++i) - m_LineText[i] = _T(' '); - // update starting address for next row every 16 bytes - m_LastRowStartingAddress += 16; + // filled m_ColumnsCtrl bytes window; append text and reset accumulator array + if (m_ByteCounter != m_ColumnsCtrl) // after the first line, + m_pText->AppendText(_T('\n')); // prepend a newline + + m_pText->AppendText(wxString::Format(_T("0x%lx: "), m_LastRowStartingAddress)); + for (unsigned i = 0; i < (m_PartLength + m_ColumnsCtrl); ++i) + m_pText->AppendText(m_LineText[i]); + + // update starting address for next row every m_ColumnsCtrl bytes + m_LastRowStartingAddress += m_ColumnsCtrl; } } - + void ExamineMemoryDlg::OnGo(cb_unused wxCommandEvent& event) { cbDebuggerPlugin *plugin = Manager::Get()->GetDebuggerManager()->GetActiveDebugger(); - // Save the value of the bytes combo box in the config, + // Save the values of the bytes combo box in the config, // so it is the same next time the dialog is used. ConfigManager *c = Manager::Get()->GetConfigManager(wxT("debugger_common")); c->Write(wxT("/common/examine_memory/size_to_show"), GetBytes()); + c->Write(wxT("/common/examine_memory/columns_to_show"), GetCols()); if (plugin) plugin->RequestUpdate(cbDebuggerPlugin::ExamineMemory); diff --git a/src/src/examinememorydlg.h b/src/src/examinememorydlg.h index 650e67fa43..82e352a2e2 100644 --- a/src/src/examinememorydlg.h +++ b/src/src/examinememorydlg.h @@ -1,6 +1,7 @@ /* * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3 * http://www.gnu.org/licenses/gpl-3.0.html + * Modified MicroSourceCode https://github.com/MicroSourceCode */ #ifndef EXAMINEMEMORYDLG_H @@ -26,6 +27,7 @@ class ExamineMemoryDlg : public wxPanel, public cbExamineMemoryDlg wxString GetBaseAddress() override; void SetBaseAddress(const wxString &addr) override; int GetBytes() override; + int GetCols() override; void AddError(const wxString& err) override; void AddHexByte(const wxString& addr, const wxString& hexbyte) override; void EnableWindow(bool enable) override; @@ -35,7 +37,9 @@ class ExamineMemoryDlg : public wxPanel, public cbExamineMemoryDlg private: wxTextCtrl* m_pText; size_t m_ByteCounter; - wxChar m_LineText[67]; // 16*3 "7F " + 3 " " + 16 "." + unsigned m_ColumnsCtrl; + unsigned m_PartLength; + wxChar m_LineText[128]; //128 is: 32 * 3 + 32 uint64_t m_LastRowStartingAddress; private: DECLARE_EVENT_TABLE() diff --git a/src/src/resources/memdump.xrc b/src/src/resources/memdump.xrc index 1306514c21..8af714c0c8 100644 --- a/src/src/resources/memdump.xrc +++ b/src/src/resources/memdump.xrc @@ -7,18 +7,18 @@ - + wxALIGN_CENTER_VERTICAL - 4 + 2 0x0 - wxLEFT|wxALIGN_CENTER_VERTICAL - 4 + wxEXPAND + 2 @@ -26,7 +26,7 @@ wxLEFT|wxALIGN_CENTER_VERTICAL - 4 + 2 @@ -44,15 +44,47 @@ 1 - wxLEFT|wxALIGN_CENTER_VERTICAL - 4 + wxRIGHT|wxEXPAND + 2 + + + + + + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 2 + + + + + 2 + 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + 20 + 22 + 24 + 26 + 28 + 30 + 32 + + + + wxRIGHT|wxEXPAND + 2 - wxLEFT|wxALIGN_CENTER_VERTICAL - 4 + wxLEFT|wxEXPAND + 2 wxTOP|wxLEFT|wxRIGHT|wxEXPAND