-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemorydump.patch
More file actions
335 lines (318 loc) · 11.7 KB
/
memorydump.patch
File metadata and controls
335 lines (318 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
diff -ruN codeblocks-20.03/src/include/cbdebugger_interfaces.h codeblocks-20.03-new/src/include/cbdebugger_interfaces.h
--- codeblocks-20.03/src/include/cbdebugger_interfaces.h 2020-03-28 15:36:02.000000000 +0300
+++ codeblocks-20.03-new/src/include/cbdebugger_interfaces.h 2021-03-17 19:23:42.001661606 +0300
@@ -85,6 +85,7 @@
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 -ruN codeblocks-20.03/src/src/examinememorydlg.cpp codeblocks-20.03-new/src/src/examinememorydlg.cpp
--- codeblocks-20.03/src/src/examinememorydlg.cpp 2020-03-28 15:36:04.000000000 +0300
+++ codeblocks-20.03-new/src/src/examinememorydlg.cpp 2021-03-17 19:28:08.064653726 +0300
@@ -25,6 +25,7 @@
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()
@@ -34,38 +35,55 @@
//ctor
if (!wxXmlResource::Get()->LoadPanel(this, parent, _T("MemoryDumpPanel")))
return;
- m_pText = XRCCTRL(*this, "txtDump", wxTextCtrl);
+ m_pText = XRCCTRL(*this, "txtDump", wxListBox);
wxFont font(8, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
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
+ m_pText->SetDoubleBuffered(false);
Clear();
}
void ExamineMemoryDlg::Begin()
{
m_pText->Freeze();
+ strError.Empty();
+ isNull = false;
+ m_count = 0;
}
void ExamineMemoryDlg::End()
{
- m_pText->Thaw();
+ if (!strError.IsNull())
+ m_pText->Append(strError);
+ m_pText->Thaw();
}
void ExamineMemoryDlg::Clear()
{
+ m_ColumnsCtrl = GetCols();
+ m_numStr = GetBytes()/m_ColumnsCtrl * m_ColumnsCtrl - 1;
+ m_numStrEnd = GetBytes() % m_ColumnsCtrl;
m_pText->Clear();
m_LastRowStartingAddress = 0;
m_ByteCounter = 0;
- for (int i = 0; i < 67; ++i)
+
+ m_PartLength = (m_ColumnsCtrl * 2) + m_ColumnsCtrl;
+ for (int i = 0; i < 128; ++i)
m_LineText[i] = _T(' ');
}
@@ -81,56 +99,69 @@
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'));
+ strError = 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_LastRowStartingAddress == 0)
+ switch (m_LastRowStartingAddress)
{
- // because we 'll be appending each row *after* we have consumed it
- // and then "addr" will point to the next row's starting address,
- // we 'll keep the current row's starting address in "m_LastRowStartingAddress".
-
- // if it's zero (i.e this is the first row), keep "addr" as starting address for this row.
- // m_LastRowStartingAddress will be set again when we 've consumed this row...
- addr.ToULong(&m_LastRowStartingAddress, 16);
+ case 0:
+ m_LastRowStartingAddress = cbDebuggerStringToAddress(addr);
+ isNull = true;
+ break;
+ case 8:
+ case 16:
+ case 24:
+ if (m_ColumnsCtrl > m_LastRowStartingAddress && isNull)
+ m_LastRowStartingAddress = 0;
+ break;
}
#define HEX_OFFSET(a) (a*3)
-#define CHAR_OFFSET(a) (16*3 + 3 + a)
+//#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)
+ if (m_ByteCounter != 0 && m_ByteCounter % m_ColumnsCtrl == 0)
+ {
+ wxString str2;
+ str2.Append(wxString::Format(_T("0x%lx: "), m_LastRowStartingAddress));
+ str2.Append(static_cast<wxChar *>(m_LineText), (m_PartLength + m_ColumnsCtrl));
+ m_pText->Append(str2);
+ if (m_count == m_numStr)
+ for (int i = 0; i < 128; ++i)
+ m_LineText[i] = _T(' ');
+ m_LastRowStartingAddress += m_ColumnsCtrl;
+ }
+ else if (m_count == m_numStr + m_numStrEnd && m_numStrEnd > 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)
-
- unsigned long a;
- addr.ToULong(&a, 16);
- m_pText->AppendText(wxString::Format(_T("0x%lx: %.67s"), m_LastRowStartingAddress, m_LineText));
- for (int i = 0; i < 67; ++i)
- m_LineText[i] = _T(' ');
- // update starting address for next row
- // add 8 bytes: addr is the start address of the second 8-byte chunk of this line, so next line is +8
- m_LastRowStartingAddress = a + 8;
+ wxString str2;
+ str2.Append(wxString::Format(_T("0x%lx: "), m_LastRowStartingAddress));
+ str2.Append(static_cast<wxChar *>(m_LineText), (m_PartLength + m_ColumnsCtrl));
+ m_pText->Append(str2);
}
+ ++m_count;
}
void ExamineMemoryDlg::OnGo(cb_unused wxCommandEvent& event)
@@ -141,7 +172,7 @@
// 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);
}
@@ -158,5 +189,4 @@
cbDebuggerPlugin *plugin = Manager::Get()->GetDebuggerManager()->GetActiveDebugger();
if (plugin)
plugin->RequestUpdate(cbDebuggerPlugin::ExamineMemory);
-
}
diff -ruN codeblocks-20.03/src/src/examinememorydlg.h codeblocks-20.03-new/src/src/examinememorydlg.h
--- codeblocks-20.03/src/src/examinememorydlg.h 2020-03-28 15:36:04.000000000 +0300
+++ codeblocks-20.03-new/src/src/examinememorydlg.h 2021-03-17 19:25:18.830776417 +0300
@@ -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 @@
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);
@@ -33,10 +35,18 @@
void OnGo(wxCommandEvent& event);
private:
- wxTextCtrl* m_pText;
+ wxListBox* m_pText;
+ unsigned m_PartLength;
size_t m_ByteCounter;
- wxChar m_LineText[67]; // 16*3 "7F " + 3 " " + 16 "."
+ unsigned m_ColumnsCtrl;
+ wxChar m_LineText[128];
unsigned long m_LastRowStartingAddress;
+ unsigned m_count = 0;
+ unsigned m_numStr;
+ unsigned m_numStrEnd;
+ bool isNull;
+ wxString strError;
+
private:
DECLARE_EVENT_TABLE()
};
diff -ruN codeblocks-20.03/src/src/resources/memdump.xrc codeblocks-20.03-new/src/src/resources/memdump.xrc
--- codeblocks-20.03/src/src/resources/memdump.xrc 2020-03-28 15:36:04.000000000 +0300
+++ codeblocks-20.03-new/src/src/resources/memdump.xrc 2021-03-17 19:23:42.101662774 +0300
@@ -7,18 +7,18 @@
<object class="wxBoxSizer">
<object class="sizeritem">
<object class="wxStaticText" name="ID_STATICTEXT1">
- <label>Address:</label>
+ <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">
@@ -26,7 +26,7 @@
<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">
+ <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>
@@ -66,10 +98,10 @@
<border>4</border>
</object>
<object class="sizeritem">
- <object class="wxTextCtrl" name="txtDump">
- <style>wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL</style>
+ <object class="wxListBox" name="txtDump">
+ <default>-1</default>
</object>
- <flag>wxTOP|wxEXPAND</flag>
+ <flag>wxALL|wxEXPAND</flag>
<border>4</border>
<option>1</option>
</object>