-
Notifications
You must be signed in to change notification settings - Fork 28
Memorydump update #16
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <cinttypes> // 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) | ||
MicroSourceCode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this mean? Why do you just multiply by 3? |
||
|
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you don't use this any more you better remove this. |
||
|
||
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; | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty space? |
||
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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming something |
||
unsigned m_PartLength; | ||
wxChar m_LineText[128]; //128 is: 32 * 3 + 32 | ||
uint64_t m_LastRowStartingAddress; | ||
private: | ||
DECLARE_EVENT_TABLE() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,26 +7,26 @@ | |
<object class="wxBoxSizer"> | ||
<object class="sizeritem"> | ||
<object class="wxStaticText" name="ID_STATICTEXT1"> | ||
<label>Address:</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't abbreviate things. The abbreviation of "address" is more common to be "addr" also. |
||
<label>Adr:</label> | ||
</object> | ||
<flag>wxALIGN_CENTER_VERTICAL</flag> | ||
<border>4</border> | ||
<border>2</border> | ||
</object> | ||
<object class="sizeritem"> | ||
<object class="wxTextCtrl" name="txtAddress"> | ||
<value>0x0</value> | ||
<style>wxTE_PROCESS_ENTER</style> | ||
</object> | ||
<flag>wxLEFT|wxALIGN_CENTER_VERTICAL</flag> | ||
<border>4</border> | ||
<flag>wxEXPAND</flag> | ||
<border>2</border> | ||
<option>1</option> | ||
</object> | ||
<object class="sizeritem"> | ||
<object class="wxStaticText" name="ID_STATICTEXT2"> | ||
<label>Bytes:</label> | ||
</object> | ||
<flag>wxLEFT|wxALIGN_CENTER_VERTICAL</flag> | ||
<border>4</border> | ||
<border>2</border> | ||
</object> | ||
<object class="sizeritem"> | ||
<object class="wxComboBox" name="cmbBytes"> | ||
|
@@ -44,15 +44,47 @@ | |
<selection>1</selection> | ||
<style>wxCB_READONLY</style> | ||
</object> | ||
<flag>wxLEFT|wxALIGN_CENTER_VERTICAL</flag> | ||
<border>4</border> | ||
<flag>wxRIGHT|wxEXPAND</flag> | ||
<border>2</border> | ||
</object> | ||
<object class="sizeritem"> | ||
<object class="wxStaticText" name="ID_STATICTEXT4"> | ||
<label>Col:</label> | ||
</object> | ||
<flag>wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL</flag> | ||
<border>2</border> | ||
</object> | ||
<object class="sizeritem"> | ||
<object class="wxComboBox" name="colSelect"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use wxChoice they work better on wxGTK. |
||
<content> | ||
<item>2</item> | ||
<item>4</item> | ||
<item>6</item> | ||
<item>8</item> | ||
<item>10</item> | ||
<item>12</item> | ||
<item>14</item> | ||
<item>16</item> | ||
<item>18</item> | ||
<item>20</item> | ||
<item>22</item> | ||
<item>24</item> | ||
<item>26</item> | ||
<item>28</item> | ||
<item>30</item> | ||
<item>32</item> | ||
</content> | ||
<style>wxCB_READONLY</style> | ||
</object> | ||
<flag>wxRIGHT|wxEXPAND</flag> | ||
<border>2</border> | ||
</object> | ||
<object class="sizeritem"> | ||
<object class="wxButton" name="btnGo"> | ||
<label>Go</label> | ||
</object> | ||
<flag>wxLEFT|wxALIGN_CENTER_VERTICAL</flag> | ||
<border>4</border> | ||
<flag>wxLEFT|wxEXPAND</flag> | ||
<border>2</border> | ||
</object> | ||
</object> | ||
<flag>wxTOP|wxLEFT|wxRIGHT|wxEXPAND</flag> | ||
|
Uh oh!
There was an error while loading. Please reload this page.