Debugger: Add custom breakpoint log message.

This commit is contained in:
Unknown W. Brackets committed 2016-08-04 13:07:56 -07:00
1 parent 9972e5b10a
commit e4ca124b0e
6 files changed
+98 -38

No files matched your search

+44 -17
View File
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "base/compat.h"
#include "util/text/utf8.h"
#include "BreakpointWindow.h"
#include "../resource.h"
@@ -28,7 +29,7 @@ INT_PTR CALLBACK BreakpointWindow::dlgFunc(HWND hwnd, UINT iMsg, WPARAM wParam,
EnableWindow(GetDlgItem(hwnd,IDC_BREAKPOINT_ONCHANGE),bp->memory);
EnableWindow(GetDlgItem(hwnd,IDC_BREAKPOINT_SIZE),bp->memory);
EnableWindow(GetDlgItem(hwnd,IDC_BREAKPOINT_CONDITION),!bp->memory);
EnableWindow(GetDlgItem(hwnd,IDC_BREAKPOINT_LOG_FORMAT), bp->log);
if (bp->address != -1)
{
@@ -37,9 +38,10 @@ INT_PTR CALLBACK BreakpointWindow::dlgFunc(HWND hwnd, UINT iMsg, WPARAM wParam,
}
snprintf(str, sizeof(str), "0x%08X", bp->size);
SetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_SIZE),str);
SetWindowTextA(GetDlgItem(hwnd, IDC_BREAKPOINT_SIZE),str);
SetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_CONDITION),bp->condition);
SetWindowTextW(GetDlgItem(hwnd, IDC_BREAKPOINT_CONDITION), ConvertUTF8ToWString(bp->condition).c_str());
SetWindowTextW(GetDlgItem(hwnd, IDC_BREAKPOINT_LOG_FORMAT), ConvertUTF8ToWString(bp->logFormat).c_str());
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
@@ -70,6 +72,14 @@ INT_PTR CALLBACK BreakpointWindow::dlgFunc(HWND hwnd, UINT iMsg, WPARAM wParam,
break;
}
break;
case IDC_BREAKPOINT_LOG:
switch (HIWORD(wParam))
{
case BN_CLICKED:
EnableWindow(GetDlgItem(hwnd, IDC_BREAKPOINT_LOG_FORMAT), bp->GetCheckState(hwnd, IDC_BREAKPOINT_LOG));
break;
}
break;
case IDC_BREAKPOINT_OK:
switch (HIWORD(wParam))
{
@@ -113,12 +123,12 @@ bool BreakpointWindow::fetchDialogData(HWND hwnd)
char str[256],errorMessage[512];
PostfixExpression exp;
memory = SendMessage(GetDlgItem(hwnd,IDC_BREAKPOINT_MEMORY),BM_GETCHECK,0,0) != 0;
read = SendMessage(GetDlgItem(hwnd,IDC_BREAKPOINT_READ),BM_GETCHECK,0,0) != 0;
write = SendMessage(GetDlgItem(hwnd,IDC_BREAKPOINT_WRITE),BM_GETCHECK,0,0) != 0;
enabled = SendMessage(GetDlgItem(hwnd,IDC_BREAKPOINT_ENABLED),BM_GETCHECK,0,0) != 0;
log = SendMessage(GetDlgItem(hwnd,IDC_BREAKPOINT_LOG),BM_GETCHECK,0,0) != 0;
onChange = SendMessage(GetDlgItem(hwnd,IDC_BREAKPOINT_ONCHANGE),BM_GETCHECK,0,0) != 0;
memory = GetCheckState(hwnd, IDC_BREAKPOINT_MEMORY);
read = GetCheckState(hwnd, IDC_BREAKPOINT_READ);
write = GetCheckState(hwnd, IDC_BREAKPOINT_WRITE);
enabled = GetCheckState(hwnd, IDC_BREAKPOINT_ENABLED);
log = GetCheckState(hwnd, IDC_BREAKPOINT_LOG);
onChange = GetCheckState(hwnd, IDC_BREAKPOINT_ONCHANGE);
// parse address
GetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_ADDRESS),str,256);
@@ -156,11 +166,13 @@ bool BreakpointWindow::fetchDialogData(HWND hwnd)
}
// condition
GetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_CONDITION),condition,128);
wchar_t tempCond[512];
GetWindowTextW(GetDlgItem(hwnd, IDC_BREAKPOINT_CONDITION), tempCond, 512);
condition = ConvertWStringToUTF8(tempCond);
compiledCondition.clear();
if (condition[0] != 0)
if (!condition.empty())
{
if (cpu->initExpression(condition,compiledCondition) == false)
if (cpu->initExpression(condition.c_str(), compiledCondition) == false)
{
snprintf(errorMessage, sizeof(errorMessage), "Invalid expression \"%s\".",str);
MessageBoxA(hwnd,errorMessage,"Error",MB_OK);
@@ -168,9 +180,18 @@ bool BreakpointWindow::fetchDialogData(HWND hwnd)
}
}
wchar_t tempLogFormat[512];
GetWindowTextW(GetDlgItem(hwnd, IDC_BREAKPOINT_LOG_FORMAT), tempLogFormat, 512);
logFormat = ConvertWStringToUTF8(tempLogFormat);
// TODO: Verify format.
return true;
}
bool BreakpointWindow::GetCheckState(HWND hwnd, int dlgItem) {
return SendMessage(GetDlgItem(hwnd, dlgItem), BM_GETCHECK, 0, 0) != 0;
}
bool BreakpointWindow::exec()
{
bp = this;
@@ -198,20 +219,22 @@ void BreakpointWindow::addBreakpoint()
cond |= MEMCHECK_WRITE_ONCHANGE;
CBreakPoints::AddMemCheck(address, address + size, (MemCheckCondition)cond, result);
CBreakPoints::ChangeMemCheckLogFormat(address, address + size, logFormat);
} else {
// add breakpoint
CBreakPoints::AddBreakPoint(address,false);
if (condition[0] != 0)
if (!condition.empty())
{
BreakPointCond cond;
cond.debug = cpu;
strcpy(cond.expressionString,condition);
cond.expressionString = condition;
cond.expression = compiledCondition;
CBreakPoints::ChangeBreakPointAddCond(address,cond);
}
CBreakPoints::ChangeBreakPoint(address, result);
CBreakPoints::ChangeBreakPointLogFormat(address, logFormat);
}
}
@@ -228,6 +251,8 @@ void BreakpointWindow::loadFromMemcheck(MemCheck& memcheck)
address = memcheck.start;
size = memcheck.end-address;
logFormat = memcheck.logFormat;
}
void BreakpointWindow::loadFromBreakpoint(BreakPoint& breakpoint)
@@ -240,10 +265,12 @@ void BreakpointWindow::loadFromBreakpoint(BreakPoint& breakpoint)
size = 1;
if (breakpoint.hasCond) {
strcpy(condition,breakpoint.cond.expressionString);
condition = breakpoint.cond.expressionString;
} else {
condition[0] = 0;
condition.clear();
}
logFormat = breakpoint.logFormat;
}
void BreakpointWindow::initBreakpoint(u32 _address)
@@ -252,5 +279,5 @@ void BreakpointWindow::initBreakpoint(u32 _address)
enabled = true;
address = _address;
size = 1;
condition[0] = 0;
condition.clear();
}