-
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 1 commit
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() | ||
|
||
|
@@ -38,17 +37,24 @@ ExamineMemoryDlg::ExamineMemoryDlg(wxWindow* parent) : | |
return; | ||
m_pText = XRCCTRL(*this, "txtDump", wxTextCtrl); | ||
|
||
wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | ||
wxFont font(12, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | ||
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. Why have you increased the size? |
||
m_pText->SetFont(font); | ||
|
||
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); | ||
} | ||
|
||
void ExamineMemoryDlg::Clear() | ||
{ | ||
m_ColumnsCtrl = GetCols(); | ||
m_pText->Clear(); | ||
m_LastRowStartingAddress = 0; | ||
m_ByteCounter = 0; | ||
for (int i = 0; i < 67; ++i) | ||
|
||
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) | ||
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,34 +122,35 @@ 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) | ||
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, | ||
if (m_ByteCounter != m_ColumnsCtrl) // 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; | ||
|
||
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]); | ||
|
||
// for (int i = 0; i < (m_PartLength + m_ColumnsCtrl); ++i) | ||
// m_LineText[i] = _T(' '); | ||
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. The identation of this block is a mess. Please fix. |
||
|
||
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(); | ||
|
@@ -140,6 +159,7 @@ void ExamineMemoryDlg::OnGo(cb_unused wxCommandEvent& event) | |
// 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 | ||
|
@@ -16,26 +17,29 @@ class ExamineMemoryDlg : public wxPanel, public cbExamineMemoryDlg | |
public: | ||
ExamineMemoryDlg(wxWindow* parent); | ||
|
||
wxWindow* GetWindow() override { return this; } | ||
wxWindow* GetWindow() { return this; } | ||
|
||
// used for Freeze()/Thaw() calls | ||
void Begin() override; | ||
void End() override; | ||
|
||
void Clear() override; | ||
wxString GetBaseAddress() override; | ||
void SetBaseAddress(const wxString &addr) override; | ||
int GetBytes() override; | ||
void AddError(const wxString& err) override; | ||
void AddHexByte(const wxString& addr, const wxString& hexbyte) override; | ||
void EnableWindow(bool enable) override; | ||
void Begin(); | ||
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. Why have you removed |
||
void End(); | ||
|
||
void Clear(); | ||
wxString GetBaseAddress(); | ||
void SetBaseAddress(const wxString &addr); | ||
int GetBytes(); | ||
int GetCols(); | ||
void AddError(const wxString& err); | ||
void AddHexByte(const wxString& addr, const wxString& hexbyte); | ||
void EnableWindow(bool enable); | ||
protected: | ||
void OnGo(wxCommandEvent& event); | ||
|
||
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]; | ||
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.