clang-format: Debugger files (check commit message)

gui/Debugger/CtrlDisassemblyView.cpp
gui/Debugger/CtrlMemView.cpp
gui/DebugerLists.cpp

Had to manually format wx event tables
This commit is contained in:
Ty Lamontagne 2021-06-09 13:01:58 -04:00 committed by refractionpcsx2
parent 58a9460f7c
commit efd2df8a33
3 changed files with 1065 additions and 867 deletions

View File

@ -82,7 +82,6 @@ public:
const wxString& name = wxTextCtrlNameStr)
: wxTextCtrl(parent, id, value, pos, size, style, validator, name)
{
}
#ifdef _WIN32
@ -136,7 +135,8 @@ private:
wxButton* cancelButton;
};
inline wxIcon _wxGetIconFromMemory(const unsigned char *data, int length) {
inline wxIcon _wxGetIconFromMemory(const unsigned char* data, int length)
{
wxMemoryInputStream is(data, length);
wxBitmap b = wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1);
wxIcon icon;
@ -145,7 +145,8 @@ inline wxIcon _wxGetIconFromMemory(const unsigned char *data, int length) {
}
CtrlDisassemblyView::CtrlDisassemblyView(wxWindow* parent, DebugInterface* _cpu)
: wxWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS|wxBORDER_SIMPLE|wxVSCROLL), cpu(_cpu)
: wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxBORDER_SIMPLE | wxVSCROLL)
, cpu(_cpu)
{
manager.setCpu(cpu);
windowStart = 0x100000;
@ -259,11 +260,15 @@ bool CtrlDisassemblyView::getDisasmAddressText(u32 address, char* dest, bool abb
*dest++ = ':';
*dest = 0;
return true;
} else {
}
else
{
sprintf(dest, " %08X", address);
return false;
}
} else {
}
else
{
if (showData)
sprintf(dest, "%08X %08X", address, cpu->read32(address));
else
@ -297,20 +302,26 @@ void CtrlDisassemblyView::drawBranchLine(wxDC& dc, std::map<u32,int>& addressPos
if (line.first < windowStart)
{
topY = -1;
} else if (line.first >= windowEnd)
}
else if (line.first >= windowEnd)
{
topY = GetSize().GetHeight() + 1;
} else {
}
else
{
topY = addressPositions[line.first] + rowHeight / 2;
}
if (line.second < windowStart)
{
bottomY = -1;
} else if (line.second >= windowEnd)
}
else if (line.second >= windowEnd)
{
bottomY = GetSize().GetHeight() + 1;
} else {
}
else
{
bottomY = addressPositions[line.second] + rowHeight / 2;
}
@ -324,7 +335,9 @@ void CtrlDisassemblyView::drawBranchLine(wxDC& dc, std::map<u32,int>& addressPos
if (line.first == curAddress || line.second == curAddress)
{
color = wxColor(0xFF257AFA);
} else {
}
else
{
color = wxColor(0xFFFF3020);
}
@ -344,7 +357,8 @@ void CtrlDisassemblyView::drawBranchLine(wxDC& dc, std::map<u32,int>& addressPos
dc.DrawLine(x, bottomY - 4, x - 4, bottomY);
dc.DrawLine(x - 4, bottomY, x + 1, bottomY + 5);
}
} else if (bottomY > winBottom) // second is not visible, but first is
}
else if (bottomY > winBottom) // second is not visible, but first is
{
dc.DrawLine(x - 2, topY, x + 2, topY);
dc.DrawLine(x + 2, topY, x + 2, winBottom);
@ -354,7 +368,9 @@ void CtrlDisassemblyView::drawBranchLine(wxDC& dc, std::map<u32,int>& addressPos
dc.DrawLine(x, topY - 4, x - 4, topY);
dc.DrawLine(x - 4, topY, x + 1, topY + 5);
}
} else { // both are visible
}
else
{ // both are visible
if (line.type == LINE_UP)
{
dc.DrawLine(x - 2, bottomY, x + 2, bottomY);
@ -363,7 +379,9 @@ void CtrlDisassemblyView::drawBranchLine(wxDC& dc, std::map<u32,int>& addressPos
dc.DrawLine(x, topY - 4, x - 4, topY);
dc.DrawLine(x - 4, topY, x + 1, topY + 5);
} else {
}
else
{
dc.DrawLine(x - 2, topY, x + 2, topY);
dc.DrawLine(x + 2, topY, x + 2, bottomY);
dc.DrawLine(x + 2, bottomY, x - 4, bottomY);
@ -378,34 +396,39 @@ int getBackgroundColor(unsigned int address)
{
u32 colors[6] = {0xFFe0FFFF, 0xFFFFe0e0, 0xFFe8e8FF, 0xFFFFe0FF, 0xFFe0FFe0, 0xFFFFFFe0};
int n = symbolMap.GetFunctionNum(address);
if (n==-1) return 0xFFFFFFFF;
if (n == -1)
return 0xFFFFFFFF;
return colors[n % 6];
}
std::set<std::string> CtrlDisassemblyView::getSelectedLineArguments() {
std::set<std::string> CtrlDisassemblyView::getSelectedLineArguments()
{
std::set<std::string> args;
DisassemblyLineInfo line = DisassemblyLineInfo();
for (u32 addr = selectRangeStart; addr < selectRangeEnd; addr += 4) {
for (u32 addr = selectRangeStart; addr < selectRangeEnd; addr += 4)
{
manager.getLine(addr, displaySymbols, line);
size_t p = 0, nextp = line.params.find(',');
while (nextp != line.params.npos) {
while (nextp != line.params.npos)
{
args.insert(line.params.substr(p, nextp - p));
p = nextp + 1;
nextp = line.params.find(',', p);
}
if (p < line.params.size()) {
if (p < line.params.size())
{
args.insert(line.params.substr(p));
}
// check for registers in memory opcodes
p = line.params.find('(');
nextp = line.params.find(')');
if (p != line.params.npos && nextp != line.params.npos && nextp > p) {
if (p != line.params.npos && nextp != line.params.npos && nextp > p)
{
args.insert(line.params.substr(p + 1, nextp - p - 1));
}
}
return args;
@ -427,7 +450,8 @@ void CtrlDisassemblyView::drawArguments(wxDC& dc, const DisassemblyLineInfo &lin
wxColor highlightedColor = wxColor(textColor == 0xFF0000FF ? 0xFFAABB77 : 0xFFAABB00);
size_t p = 0, nextp = line.params.find(',');
while (nextp != line.params.npos) {
while (nextp != line.params.npos)
{
const std::string arg = line.params.substr(p, nextp - p);
if (currentArguments.find(arg) != currentArguments.end() && textColor != 0xFFFFFFFF)
{
@ -443,7 +467,8 @@ void CtrlDisassemblyView::drawArguments(wxDC& dc, const DisassemblyLineInfo &lin
dc.DrawText(L",", x, y);
x += charWidth;
}
if (p < line.params.size()) {
if (p < line.params.size())
{
const std::string arg = line.params.substr(p);
if (currentArguments.find(arg) != currentArguments.end() && textColor != 0xFFFFFFFF)
{
@ -509,7 +534,9 @@ void CtrlDisassemblyView::render(wxDC& dc)
{
backgroundColor = address == curAddress ? 0xFFFF8822 : 0xFFFF9933;
textColor = 0xFFFFFFFF;
} else {
}
else
{
backgroundColor = 0xFFC0C0C0;
}
}
@ -558,7 +585,6 @@ void CtrlDisassemblyView::render(wxDC& dc)
{
drawBranchLine(dc, addressPositions, branchLines[i]);
}
}
void CtrlDisassemblyView::gotoAddress(u32 addr)
@ -608,12 +634,14 @@ void CtrlDisassemblyView::followBranch()
{
jumpStack.push_back(curAddress);
gotoAddress(line.info.branchTarget);
} else if (line.info.hasRelevantAddress)
}
else if (line.info.hasRelevantAddress)
{
// well, not exactly a branch, but we can do something anyway
postEvent(debEVT_GOTOINMEMORYVIEW, line.info.releventAddress);
}
} else if (line.type == DISTYPE_DATA)
}
else if (line.type == DISTYPE_DATA)
{
// jump to the start of the current line
postEvent(debEVT_GOTOINMEMORYVIEW, curAddress);
@ -648,7 +676,9 @@ void CtrlDisassemblyView::assembleOpcode(u32 address, std::string defaultText)
gotoAddress(manager.getNthNextAddress(curAddress, 1));
redraw();
} else {
}
else
{
wxMessageBox(wxString(errorText.c_str(), wxConvUTF8), L"Error.", wxICON_ERROR);
}
}
@ -839,7 +869,9 @@ void CtrlDisassemblyView::keydownEvent(wxKeyEvent& evt)
if (jumpStack.empty())
{
gotoAddress(cpu->getPC());
} else {
}
else
{
u32 addr = jumpStack[jumpStack.size() - 1];
jumpStack.pop_back();
gotoAddress(addr);
@ -862,20 +894,26 @@ void CtrlDisassemblyView::keydownEvent(wxKeyEvent& evt)
displaySymbols = !displaySymbols;
break;
case WXK_PAGEUP:
if (curAddress != windowStart && curAddressIsVisible()) {
if (curAddress != windowStart && curAddressIsVisible())
{
setCurAddress(windowStart, wxGetKeyState(WXK_SHIFT));
scrollAddressIntoView();
} else {
}
else
{
setCurAddress(manager.getNthPreviousAddress(windowStart, visibleRows), wxGetKeyState(WXK_SHIFT));
scrollAddressIntoView();
}
scanFunctions();
break;
case WXK_PAGEDOWN:
if (manager.getNthNextAddress(curAddress,1) != windowEnd && curAddressIsVisible()) {
if (manager.getNthNextAddress(curAddress, 1) != windowEnd && curAddressIsVisible())
{
setCurAddress(manager.getNthPreviousAddress(windowEnd, 1), wxGetKeyState(WXK_SHIFT));
scrollAddressIntoView();
} else {
}
else
{
setCurAddress(manager.getNthNextAddress(windowEnd, visibleRows - 1), wxGetKeyState(WXK_SHIFT));
scrollAddressIntoView();
}
@ -908,15 +946,18 @@ void CtrlDisassemblyView::scrollbarEvent(wxScrollWinEvent& evt)
{
windowStart = manager.getNthPreviousAddress(windowStart, 1);
scanFunctions();
} else if (type == wxEVT_SCROLLWIN_LINEDOWN)
}
else if (type == wxEVT_SCROLLWIN_LINEDOWN)
{
windowStart = manager.getNthNextAddress(windowStart, 1);
scanFunctions();
} else if (type == wxEVT_SCROLLWIN_PAGEUP)
}
else if (type == wxEVT_SCROLLWIN_PAGEUP)
{
windowStart = manager.getNthPreviousAddress(windowStart, visibleRows);
scanFunctions();
} else if (type == wxEVT_SCROLLWIN_PAGEDOWN)
}
else if (type == wxEVT_SCROLLWIN_PAGEDOWN)
{
windowStart = manager.getNthNextAddress(windowStart, visibleRows);
scanFunctions();
@ -934,19 +975,25 @@ void CtrlDisassemblyView::toggleBreakpoint(bool toggleEnabled)
{
// enable disabled breakpoints
CBreakPoints::ChangeBreakPoint(cpu->getCpuType(), curAddress, true);
} else if (!toggleEnabled && CBreakPoints::GetBreakPointCondition(cpu->getCpuType(), curAddress) != NULL)
}
else if (!toggleEnabled && CBreakPoints::GetBreakPointCondition(cpu->getCpuType(), curAddress) != NULL)
{
// don't just delete a breakpoint with a custom condition
CBreakPoints::RemoveBreakPoint(cpu->getCpuType(), curAddress);
} else if (toggleEnabled)
}
else if (toggleEnabled)
{
// disable breakpoint
CBreakPoints::ChangeBreakPoint(cpu->getCpuType(), curAddress, false);
} else {
}
else
{
// otherwise just remove breakpoint
CBreakPoints::RemoveBreakPoint(cpu->getCpuType(), curAddress);
}
} else {
}
else
{
CBreakPoints::AddBreakPoint(cpu->getCpuType(), curAddress);
}
}
@ -966,10 +1013,13 @@ void CtrlDisassemblyView::updateStatusBarText()
if (!cpu->isValidAddress(line.info.dataAddress))
{
sprintf(text, "Invalid address %08X", line.info.dataAddress);
} else if (line.info.lrType == MIPSAnalyst::LOADSTORE_NORMAL && line.info.dataAddress % line.info.dataSize)
}
else if (line.info.lrType == MIPSAnalyst::LOADSTORE_NORMAL && line.info.dataAddress % line.info.dataSize)
{
sprintf(text, "Unaligned address %08X", line.info.dataAddress);
} else {
}
else
{
switch (line.info.dataSize)
{
case 1:
@ -986,7 +1036,9 @@ void CtrlDisassemblyView::updateStatusBarText()
u32 address = line.info.dataAddress;
data = cpu->read32(address & ~3) >> (address & 3) * 8;
data |= cpu->read32((address + 3) & ~3) << (4 - (address & 3)) * 8;
} else {
}
else
{
data = cpu->read32(line.info.dataAddress);
}
@ -994,7 +1046,9 @@ void CtrlDisassemblyView::updateStatusBarText()
if (!addressSymbol.empty())
{
sprintf(text, "[%08X] = %s (%08X)", line.info.dataAddress, addressSymbol.c_str(), data);
} else {
}
else
{
sprintf(text, "[%08X] = %08X", line.info.dataAddress, data);
}
break;
@ -1007,7 +1061,9 @@ void CtrlDisassemblyView::updateStatusBarText()
u32 address = line.info.dataAddress;
data = cpu->read64(address & ~7) >> (address & 7) * 8;
data |= cpu->read64((address + 7) & ~7) << (8 - (address & 7)) * 8;
} else {
}
else
{
data = cpu->read64(line.info.dataAddress);
}
@ -1030,11 +1086,14 @@ void CtrlDisassemblyView::updateStatusBarText()
if (addressSymbol.empty())
{
sprintf(text, "%08X", line.info.branchTarget);
} else {
}
else
{
sprintf(text, "%08X = %s", line.info.branchTarget, addressSymbol.c_str());
}
}
} else if (line.type == DISTYPE_DATA)
}
else if (line.type == DISTYPE_DATA)
{
u32 start = symbolMap.GetDataStart(curAddress);
if (start == 0xFFFFFFFF)
@ -1049,7 +1108,9 @@ void CtrlDisassemblyView::updateStatusBarText()
sprintf(text, "%08X (%s) + %08X", start, label.c_str(), diff);
else
sprintf(text, "%08X (%s)", start, label.c_str());
} else {
}
else
{
if (diff != 0)
sprintf(text, "%08X + %08X", start, diff);
else
@ -1076,7 +1137,9 @@ void CtrlDisassemblyView::mouseEvent(wxMouseEvent& evt)
// Maintain the current selection if right clicking into it.
if (newAddress >= selectRangeStart && newAddress < selectRangeEnd)
extend = true;
} else {
}
else
{
if (curAddress == newAddress && hasFocus)
toggleBreakpoint(false);
}
@ -1084,29 +1147,37 @@ void CtrlDisassemblyView::mouseEvent(wxMouseEvent& evt)
setCurAddress(newAddress, extend);
SetFocus();
SetFocusFromKbd();
} else if (evt.GetEventType() == wxEVT_RIGHT_UP)
}
else if (evt.GetEventType() == wxEVT_RIGHT_UP)
{
PopupMenu(&menu, evt.GetPosition());
return;
} else if (evt.GetEventType() == wxEVT_MOUSEWHEEL)
}
else if (evt.GetEventType() == wxEVT_MOUSEWHEEL)
{
if (evt.GetWheelRotation() > 0)
{
windowStart = manager.getNthPreviousAddress(windowStart, 3);
scanFunctions();
} else if (evt.GetWheelRotation() < 0) {
}
else if (evt.GetWheelRotation() < 0)
{
windowStart = manager.getNthNextAddress(windowStart, 3);
scanFunctions();
}
} else if (evt.GetEventType() == wxEVT_MOTION)
}
else if (evt.GetEventType() == wxEVT_MOTION)
{
if (evt.ButtonIsDown(wxMOUSE_BTN_LEFT))
{
int newAddress = yToAddress(evt.GetY());
setCurAddress(newAddress, wxGetKeyState(WXK_SHIFT));
} else
}
else
return;
} else {
}
else
{
evt.Skip();
return;
}
@ -1174,19 +1245,20 @@ std::string CtrlDisassemblyView::disassembleRange(u32 start, u32 size)
if (isLabel)
{
if (!previousLabel) result += "\r\n";
if (!previousLabel)
result += "\r\n";
sprintf(buffer, "%s\r\n\r\n", addressText);
result += buffer;
} else if (branchAddresses.find(disAddress) != branchAddresses.end())
}
else if (branchAddresses.find(disAddress) != branchAddresses.end())
{
if (!previousLabel) result += "\r\n";
if (!previousLabel)
result += "\r\n";
sprintf(buffer, "pos_%08X:\r\n\r\n", disAddress);
result += buffer;
}
if (line.info.isBranch && !line.info.isBranchToRegister
&& symbolMap.GetLabelString(line.info.branchTarget).empty()
&& branchAddresses.find(line.info.branchTarget) != branchAddresses.end())
if (line.info.isBranch && !line.info.isBranchToRegister && symbolMap.GetLabelString(line.info.branchTarget).empty() && branchAddresses.find(line.info.branchTarget) != branchAddresses.end())
{
sprintf(buffer, "pos_%08X", line.info.branchTarget);
line.params = line.params.substr(0, line.params.find("0x")) + buffer;
@ -1235,7 +1307,8 @@ void CtrlDisassemblyView::copyInstructions(u32 startAddr, u32 endAddr, bool with
wxTheClipboard->SetData(new wxTextDataObject(wxString(temp, wxConvUTF8)));
delete[] temp;
} else
}
else
{
std::string disassembly = disassembleRange(startAddr, endAddr - startAddr);
wxTheClipboard->SetData(new wxTextDataObject(wxString(disassembly.c_str(), wxConvUTF8)));

View File

@ -62,7 +62,8 @@ enum MemoryViewMenuIdentifiers
};
CtrlMemView::CtrlMemView(wxWindow* parent, DebugInterface* _cpu)
: wxWindow(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxWANTS_CHARS|wxVSCROLL), cpu(_cpu)
: wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxVSCROLL)
, cpu(_cpu)
{
rowHeight = getDebugFontHeight();
charWidth = getDebugFontWidth();
@ -108,7 +109,8 @@ CtrlMemView::CtrlMemView(wxWindow* parent, DebugInterface* _cpu)
SetDoubleBuffered(true);
}
void CtrlMemView::setRowSize(int bytesInRow) {
void CtrlMemView::setRowSize(int bytesInRow)
{
rowSize = (std::max(16, std::min(256, bytesInRow)) / 16) * 16;
asciiStart = hexStart + (rowSize * 3 + 1) * charWidth;
}
@ -203,13 +205,15 @@ void CtrlMemView::render(wxDC& dc)
u8 byteCurrent = 0;
bool byteValid = false;
try {
try
{
byteValid = validCpu && cpu->isValidAddress(byteAddress);
if (byteValid)
byteCurrent = cpu->read8(byteAddress);
}
catch (Exception::Ps2Generic &) {
catch (Exception::Ps2Generic&)
{
byteValid = false;
}
@ -230,12 +234,15 @@ void CtrlMemView::render(wxDC& dc)
if (curAddress >= groupAddress && curAddress < groupAddress + byteGroupSize)
{
// if group selected, draw rectangle behind
if (groupIndex == 0) {
if (hasFocus && !asciiSelected) {
if (groupIndex == 0)
{
if (hasFocus && !asciiSelected)
{
dc.SetPen(COLOR_SELECTED_BG);
dc.SetBrush(COLOR_SELECTED_BG);
}
else {
else
{
dc.SetPen(COLOR_SELECTED_INACTIVE_BG);
dc.SetBrush(COLOR_SELECTED_INACTIVE_BG);
}
@ -245,7 +252,8 @@ void CtrlMemView::render(wxDC& dc)
backgroundIsDark = hasFocus && !asciiSelected;
}
if (groupAddress + groupIndex == referencedAddress) {
if (groupAddress + groupIndex == referencedAddress)
{
dc.SetPen(COLOR_REFRENCE_BG);
dc.SetBrush(COLOR_REFRENCE_BG);
dc.DrawRectangle(symbolPosX, rowY, charWidth * 2, rowHeight);
@ -256,7 +264,8 @@ void CtrlMemView::render(wxDC& dc)
swprintf(temp, TEMP_SIZE, byteValid ? L"%02X" : L"??", byteCurrent);
// if selected byte, need hint current nibble
if (byteAddress == curAddress) {
if (byteAddress == curAddress)
{
if (selectedNibble == 1)
dc.SetFont(underlineFont);
@ -273,7 +282,8 @@ void CtrlMemView::render(wxDC& dc)
if (selectedNibble == 0)
dc.SetFont(font);
}
else {
else
{
dc.DrawText(temp, symbolPosX, rowY);
}
@ -281,20 +291,24 @@ void CtrlMemView::render(wxDC& dc)
temp[1] = 0;
temp[0] = (!byteValid || byteCurrent < 32 || byteCurrent > 128) ? '.' : byteCurrent;
if (byteAddress == curAddress) {
if (hasFocus && asciiSelected) {
if (byteAddress == curAddress)
{
if (hasFocus && asciiSelected)
{
dc.SetPen(COLOR_SELECTED_BG);
dc.SetBrush(COLOR_SELECTED_BG);
dc.SetTextForeground(COLOR_WHITE);
}
else {
else
{
dc.SetPen(COLOR_SELECTED_INACTIVE_BG);
dc.SetBrush(COLOR_SELECTED_INACTIVE_BG);
dc.SetTextForeground(COLOR_BLACK);
}
dc.DrawRectangle(asciiStart + j * (charWidth + 2), rowY, charWidth, rowHeight);
}
else {
else
{
dc.SetTextForeground(COLOR_BLACK);
}
@ -399,7 +413,8 @@ void CtrlMemView::onPopupClick(wxCommandEvent& evt)
break;
case ID_MEMVIEW_ALIGNWINDOW:
g_Conf->EmuOptions.Debugger.AlignMemoryWindowStart = evt.IsChecked();
if (g_Conf->EmuOptions.Debugger.AlignMemoryWindowStart) {
if (g_Conf->EmuOptions.Debugger.AlignMemoryWindowStart)
{
windowStart -= windowStart % rowSize;
redraw();
}
@ -410,13 +425,13 @@ void CtrlMemView::onPopupClick(wxCommandEvent& evt)
void CtrlMemView::mouseEvent(wxMouseEvent& evt)
{
// left button
if (evt.GetEventType() == wxEVT_LEFT_DOWN || evt.GetEventType() == wxEVT_LEFT_DCLICK
|| evt.GetEventType() == wxEVT_RIGHT_DOWN || evt.GetEventType() == wxEVT_RIGHT_DCLICK)
if (evt.GetEventType() == wxEVT_LEFT_DOWN || evt.GetEventType() == wxEVT_LEFT_DCLICK || evt.GetEventType() == wxEVT_RIGHT_DOWN || evt.GetEventType() == wxEVT_RIGHT_DCLICK)
{
gotoPoint(evt.GetPosition().x, evt.GetPosition().y);
SetFocus();
SetFocusFromKbd();
} else if (evt.GetEventType() == wxEVT_RIGHT_UP)
}
else if (evt.GetEventType() == wxEVT_RIGHT_UP)
{
curAddress -= (curAddress - windowStart) % byteGroupSize;
@ -437,26 +452,34 @@ void CtrlMemView::mouseEvent(wxMouseEvent& evt)
PopupMenu(&menu);
return;
} else if (evt.GetEventType() == wxEVT_MOUSEWHEEL)
}
else if (evt.GetEventType() == wxEVT_MOUSEWHEEL)
{
if (evt.ControlDown())
{
if (evt.GetWheelRotation() > 0)
{
if (evt.ControlDown()) {
if (evt.GetWheelRotation() > 0) {
setRowSize(rowSize + 16);
}
else {
else
{
setRowSize(rowSize - 16);
}
}
else {
else
{
if (evt.GetWheelRotation() > 0)
{
scrollWindow(-3);
}
else if (evt.GetWheelRotation() < 0) {
else if (evt.GetWheelRotation() < 0)
{
scrollWindow(3);
}
}
} else {
}
else
{
evt.Skip();
return;
}
@ -532,7 +555,8 @@ void CtrlMemView::keydownEvent(wxKeyEvent& evt)
scrollWindow(GetClientSize().y / rowHeight);
break;
case WXK_ESCAPE:
if (!history.empty()) {
if (!history.empty())
{
gotoAddress(history.top());
history.pop();
}
@ -563,12 +587,16 @@ void CtrlMemView::charEvent(wxKeyEvent& evt)
u8 newValue = evt.GetKeyCode();
cpu->write8(curAddress, newValue);
scrollCursor(1);
} else {
}
else
{
u8 key = tolower(evt.GetKeyCode());
int inputValue = -1;
if (key >= '0' && key <= '9') inputValue = key - '0';
if (key >= 'a' && key <= 'f') inputValue = key -'a' + 10;
if (key >= '0' && key <= '9')
inputValue = key - '0';
if (key >= 'a' && key <= 'f')
inputValue = key - 'a' + 10;
if (inputValue >= 0)
{
@ -593,13 +621,16 @@ void CtrlMemView::scrollbarEvent(wxScrollWinEvent& evt)
if (type == wxEVT_SCROLLWIN_LINEUP)
{
scrollCursor(-rowSize);
} else if (type == wxEVT_SCROLLWIN_LINEDOWN)
}
else if (type == wxEVT_SCROLLWIN_LINEDOWN)
{
scrollCursor(rowSize);
} else if (type == wxEVT_SCROLLWIN_PAGEUP)
}
else if (type == wxEVT_SCROLLWIN_PAGEUP)
{
scrollWindow(-GetClientSize().y / rowHeight);
} else if (type == wxEVT_SCROLLWIN_PAGEDOWN)
}
else if (type == wxEVT_SCROLLWIN_PAGEDOWN)
{
scrollWindow(GetClientSize().y / rowHeight);
}
@ -622,15 +653,20 @@ void CtrlMemView::scrollCursor(int bytes)
{
selectedNibble = 1;
bytes = 0;
} else {
}
else
{
selectedNibble = 0;
}
} else if (!asciiSelected && bytes == -1)
}
else if (!asciiSelected && bytes == -1)
{
if (selectedNibble == 0)
{
selectedNibble = 1;
} else {
}
else
{
selectedNibble = 0;
bytes = 0;
}
@ -644,7 +680,8 @@ void CtrlMemView::scrollCursor(int bytes)
if (curAddress < windowStart)
{
windowStart = (curAddress / rowSize) * rowSize;
} else if (curAddress >= windowEnd)
}
else if (curAddress >= windowEnd)
{
windowStart = curAddress - (visibleRows - 1) * rowSize;
windowStart = (windowStart / rowSize) * rowSize;
@ -674,13 +711,16 @@ void CtrlMemView::gotoAddress(u32 addr, bool pushInHistory)
curAddress = addr;
selectedNibble = 0;
if (g_Conf->EmuOptions.Debugger.AlignMemoryWindowStart) {
if (g_Conf->EmuOptions.Debugger.AlignMemoryWindowStart)
{
int visibleRows = GetClientSize().y / rowHeight;
u32 windowEnd = windowStart + visibleRows * rowSize;
if (curAddress < windowStart || curAddress >= windowEnd)
windowStart = (curAddress / rowSize) * rowSize;
} else {
}
else
{
windowStart = curAddress;
}
@ -696,14 +736,16 @@ void CtrlMemView::gotoPoint(int x, int y)
if (x >= asciiStart)
{
int col = (x - asciiStart) / (charWidth + 2);
if (col >= rowSize) return;
if (col >= rowSize)
return;
asciiSelected = true;
curAddress = lineAddress + col;
selectedNibble = 0;
updateStatusBarText();
redraw();
} else if (x >= hexStart)
}
else if (x >= hexStart)
{
int col = (x - hexStart);
@ -714,7 +756,8 @@ void CtrlMemView::gotoPoint(int x, int y)
int indexInGroup = -1;
for (int i = 0; i < int(byteGroupSize); i++) {
for (int i = 0; i < int(byteGroupSize); i++)
{
int start = hexGroupPositionFromIndex(i);
int end = start + 2 * charWidth - 1;
if (posInGroup < start)
@ -740,7 +783,8 @@ void CtrlMemView::gotoPoint(int x, int y)
}
}
void CtrlMemView::updateReference(u32 address) {
void CtrlMemView::updateReference(u32 address)
{
referencedAddress = address;
redraw();
}
@ -771,7 +815,8 @@ void CtrlMemView::pasteHex()
{
cpu->write8(curAddress + i, static_cast<u8>(byte));
}
else {
else
{
break;
}
}

View File

@ -54,7 +54,8 @@ void GenericListView::insertColumns(GenericListViewColumn* columns, int count)
void GenericListView::resizeColumn(int col, int width)
{
if (!m_isInResizeColumn) {
if (!m_isInResizeColumn)
{
m_isInResizeColumn = true;
SetColumnWidth(col, width);
@ -88,13 +89,15 @@ void GenericListView::keydownEvent(wxKeyEvent& evt)
switch (evt.GetKeyCode())
{
case WXK_UP:
if (sel > 0) {
if (sel > 0)
{
Select(sel - 1);
Focus(sel - 1);
}
break;
case WXK_DOWN:
if (sel+1 < GetItemCount()) {
if (sel + 1 < GetItemCount())
{
Select(sel + 1);
Focus(sel + 1);
}
@ -145,10 +148,12 @@ void GenericListView::mouseEvent(wxMouseEvent& evt)
{
clickPos = evt.GetPosition();
evt.Skip();
} else if (type == wxEVT_RIGHT_UP)
}
else if (type == wxEVT_RIGHT_UP)
{
onRightClick(GetFirstSelected(), evt.GetPosition());
} else if (type == wxEVT_LEFT_DCLICK)
}
else if (type == wxEVT_LEFT_DCLICK)
{
onDoubleClick(GetFirstSelected(), evt.GetPosition());
}
@ -163,7 +168,17 @@ void GenericListView::listEvent(wxListEvent& evt)
// BreakpointList
//
enum { BPL_TYPE, BPL_OFFSET, BPL_SIZELABEL, BPL_OPCODE, BPL_CONDITION, BPL_HITS, BPL_ENABLED, BPL_COLUMNCOUNT };
enum
{
BPL_TYPE,
BPL_OFFSET,
BPL_SIZELABEL,
BPL_OPCODE,
BPL_CONDITION,
BPL_HITS,
BPL_ENABLED,
BPL_COLUMNCOUNT
};
enum BreakpointListMenuIdentifiers
{
@ -180,11 +195,12 @@ GenericListViewColumn breakpointColumns[BPL_COLUMNCOUNT] = {
{L"Opcode", 0.28f},
{L"Condition", 0.17f},
{L"Hits", 0.05f},
{ L"Enabled", 0.08f }
};
{L"Enabled", 0.08f}};
BreakpointList::BreakpointList(wxWindow* parent, DebugInterface* _cpu, CtrlDisassemblyView* _disassembly)
: GenericListView(parent,breakpointColumns,BPL_COLUMNCOUNT), cpu(_cpu),disasm(_disassembly)
: GenericListView(parent, breakpointColumns, BPL_COLUMNCOUNT)
, cpu(_cpu)
, disasm(_disassembly)
{
}
@ -193,11 +209,13 @@ int BreakpointList::getRowCount()
int count = 0;
for (size_t i = 0; i < CBreakPoints::GetMemChecks().size(); i++)
{
if (displayedMemChecks_[i].cpu == cpu->getCpuType()) count++;
if (displayedMemChecks_[i].cpu == cpu->getCpuType())
count++;
}
for (size_t i = 0; i < CBreakPoints::GetBreakpoints().size(); i++)
{
if (!displayedBreakPoints_[i].temporary && displayedBreakPoints_[i].cpu == cpu->getCpuType()) count++;
if (!displayedBreakPoints_[i].temporary && displayedBreakPoints_[i].cpu == cpu->getCpuType())
count++;
}
return count;
@ -208,14 +226,17 @@ wxString BreakpointList::getColumnText(int item, int col) const
FastFormatUnicode dest;
bool isMemory;
int index = getBreakpointIndex(item, isMemory);
if (index == -1) return L"Invalid";
if (index == -1)
return L"Invalid";
switch (col)
{
case BPL_TYPE:
{
if (isMemory) {
switch ((int)displayedMemChecks_[index].cond) {
if (isMemory)
{
switch ((int)displayedMemChecks_[index].cond)
{
case MEMCHECK_READ:
dest.Write("Read");
break;
@ -232,34 +253,44 @@ wxString BreakpointList::getColumnText(int item, int col) const
dest.Write("Read/Write Change");
break;
}
} else {
}
else
{
dest.Write(L"Execute");
}
}
break;
case BPL_OFFSET:
{
if (isMemory) {
if (isMemory)
{
dest.Write("0x%08X", displayedMemChecks_[index].start);
} else {
}
else
{
dest.Write("0x%08X", displayedBreakPoints_[index].addr);
}
}
break;
case BPL_SIZELABEL:
{
if (isMemory) {
if (isMemory)
{
auto mc = displayedMemChecks_[index];
if (mc.end == 0)
dest.Write("0x%08X", 1);
else
dest.Write("0x%08X", mc.end - mc.start);
} else {
}
else
{
const std::string sym = symbolMap.GetLabelString(displayedBreakPoints_[index].addr);
if (!sym.empty())
{
dest.Write("%s", sym.c_str());
} else {
}
else
{
dest.Write("-");
}
}
@ -267,9 +298,12 @@ wxString BreakpointList::getColumnText(int item, int col) const
break;
case BPL_OPCODE:
{
if (isMemory) {
if (isMemory)
{
dest.Write(L"-");
} else {
}
else
{
if (!cpu->isAlive())
break;
char temp[256];
@ -280,27 +314,36 @@ wxString BreakpointList::getColumnText(int item, int col) const
break;
case BPL_CONDITION:
{
if (isMemory || !displayedBreakPoints_[index].hasCond) {
if (isMemory || !displayedBreakPoints_[index].hasCond)
{
dest.Write("-");
} else {
}
else
{
dest.Write("%s", displayedBreakPoints_[index].cond.expressionString);
}
}
break;
case BPL_HITS:
{
if (isMemory) {
if (isMemory)
{
dest.Write("%d", displayedMemChecks_[index].numHits);
} else {
}
else
{
dest.Write("-");
}
}
break;
case BPL_ENABLED:
{
if (isMemory) {
if (isMemory)
{
dest.Write("%s", displayedMemChecks_[index].result & MEMCHECK_BREAK ? "true" : "false");
} else {
}
else
{
dest.Write("%s", displayedBreakPoints_[index].enabled ? "true" : "false");
}
}
@ -334,7 +377,8 @@ int BreakpointList::getBreakpointIndex(int itemIndex, bool& isMemory) const
// memory breakpoints first
for (size_t i = 0; i < displayedMemChecks_.size(); i++)
{
if (displayedMemChecks_[i].cpu != cpu->getCpuType()) continue;
if (displayedMemChecks_[i].cpu != cpu->getCpuType())
continue;
if (itemIndex == 0)
{
isMemory = true;
@ -378,7 +422,8 @@ void BreakpointList::editBreakpoint(int itemIndex)
{
bool isMemory;
int index = getBreakpointIndex(itemIndex, isMemory);
if (index == -1) return;
if (index == -1)
return;
BreakpointWindow win(this, cpu);
if (isMemory)
@ -390,7 +435,9 @@ void BreakpointList::editBreakpoint(int itemIndex)
CBreakPoints::RemoveMemCheck(cpu->getCpuType(), mem.start, mem.end);
win.addBreakpoint();
}
} else {
}
else
{
auto bp = displayedBreakPoints_[index];
win.loadFromBreakpoint(bp);
if (win.ShowModal() == wxID_OK)
@ -405,12 +452,16 @@ void BreakpointList::toggleEnabled(int itemIndex)
{
bool isMemory;
int index = getBreakpointIndex(itemIndex, isMemory);
if (index == -1) return;
if (index == -1)
return;
if (isMemory) {
if (isMemory)
{
MemCheck mcPrev = displayedMemChecks_[index];
CBreakPoints::ChangeMemCheck(cpu->getCpuType(), mcPrev.start, mcPrev.end, mcPrev.cond, MemCheckResult(mcPrev.result ^ MEMCHECK_BREAK));
} else {
}
else
{
BreakPoint bpPrev = displayedBreakPoints_[index];
CBreakPoints::ChangeBreakPoint(cpu->getCpuType(), bpPrev.addr, !bpPrev.enabled);
}
@ -420,13 +471,16 @@ void BreakpointList::gotoBreakpointAddress(int itemIndex)
{
bool isMemory;
int index = getBreakpointIndex(itemIndex, isMemory);
if (index == -1) return;
if (index == -1)
return;
if (isMemory)
{
u32 address = displayedMemChecks_[index].start;
postEvent(debEVT_GOTOINMEMORYVIEW, address);
} else {
}
else
{
u32 address = displayedBreakPoints_[index].addr;
postEvent(debEVT_GOTOINDISASM, address);
}
@ -436,13 +490,16 @@ void BreakpointList::removeBreakpoint(int itemIndex)
{
bool isMemory;
int index = getBreakpointIndex(itemIndex, isMemory);
if (index == -1) return;
if (index == -1)
return;
if (isMemory)
{
auto mc = displayedMemChecks_[index];
CBreakPoints::RemoveMemCheck(cpu->getCpuType(), mc.start, mc.end);
} else {
}
else
{
u32 address = displayedBreakPoints_[index].addr;
CBreakPoints::RemoveBreakPoint(displayedBreakPoints_[index].cpu, address);
}
@ -515,7 +572,16 @@ void BreakpointList::onDoubleClick(int itemIndex, const wxPoint& point)
// ThreadList
//
enum { TL_TID, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_PRIORITY, TL_STATE, TL_WAITTYPE, TL_COLUMNCOUNT };
enum
{
TL_TID,
TL_PROGRAMCOUNTER,
TL_ENTRYPOINT,
TL_PRIORITY,
TL_STATE,
TL_WAITTYPE,
TL_COLUMNCOUNT
};
GenericListViewColumn threadColumns[TL_COLUMNCOUNT] = {
{L"TID", 0.08f},
@ -527,7 +593,8 @@ GenericListViewColumn threadColumns[TL_COLUMNCOUNT] = {
};
ThreadList::ThreadList(wxWindow* parent, DebugInterface* _cpu)
: GenericListView(parent,threadColumns,TL_COLUMNCOUNT), cpu(_cpu)
: GenericListView(parent, threadColumns, TL_COLUMNCOUNT)
, cpu(_cpu)
{
}
@ -655,7 +722,16 @@ EEThread ThreadList::getRunningThread()
// StackFramesList
//
enum { SF_ENTRY, SF_ENTRYNAME, SF_CURPC, SF_CUROPCODE, SF_CURSP, SF_FRAMESIZE, SF_COLUMNCOUNT };
enum
{
SF_ENTRY,
SF_ENTRYNAME,
SF_CURPC,
SF_CUROPCODE,
SF_CURSP,
SF_FRAMESIZE,
SF_COLUMNCOUNT
};
GenericListViewColumn stackFrameolumns[SF_COLUMNCOUNT] = {
{L"Entry", 0.12f},
@ -663,11 +739,12 @@ GenericListViewColumn stackFrameolumns[SF_COLUMNCOUNT] = {
{L"PC", 0.12f},
{L"Opcode", 0.28f},
{L"SP", 0.12f},
{ L"Frame Size", 0.12f }
};
{L"Frame Size", 0.12f}};
StackFramesList::StackFramesList(wxWindow* parent, DebugInterface* _cpu, CtrlDisassemblyView* _disassembly)
: GenericListView(parent,stackFrameolumns,SF_COLUMNCOUNT), cpu(_cpu), disassembly(_disassembly)
: GenericListView(parent, stackFrameolumns, SF_COLUMNCOUNT)
, cpu(_cpu)
, disassembly(_disassembly)
{
}
@ -699,9 +776,12 @@ wxString StackFramesList::getColumnText(int item, int col) const
case SF_ENTRYNAME:
{
const std::string sym = symbolMap.GetLabelString(frame.entry);
if (!sym.empty()) {
if (!sym.empty())
{
dest.Write("%s", sym.c_str());
} else {
}
else
{
dest.Write("-");
}
}