Skip to content

Commit

Permalink
Debugger: Add some missing memory locks.
Browse files Browse the repository at this point in the history
We can restart memory when loading save states, so we need this even while
we've got startup/shutdown locked.
  • Loading branch information
unknownbrackets committed May 7, 2018
1 parent 1f472f5 commit 4d93a1a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Core/Debugger/DisassemblyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ std::vector<BranchLine> DisassemblyManager::getBranchLines(u32 start, u32 size)

void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLineInfo& dest)
{
// This is here really to avoid lock ordering issues.
auto memLock = Memory::Lock();
std::lock_guard<std::recursive_mutex> guard(entriesLock_);
auto it = findDisassemblyEntry(entries,address,false);
if (it == entries.end())
Expand Down
3 changes: 3 additions & 0 deletions Core/Debugger/WebSocket/DisasmSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void WebSocketDisasmState::Base(DebuggerRequest &req) {
// - params: formatted parameters for the instruction.
// - (other info about the disassembled line.)
void WebSocketDisasmState::Disasm(DebuggerRequest &req) {
auto memLock = Memory::Lock();
if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) {
return req.Fail("CPU not started");
}
Expand Down Expand Up @@ -338,6 +339,7 @@ void WebSocketDisasmState::Disasm(DebuggerRequest &req) {
// Response (same event name):
// - address: number address of match or null if none was found.
void WebSocketDisasmState::SearchDisasm(DebuggerRequest &req) {
auto memLock = Memory::Lock();
if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) {
return req.Fail("CPU not started");
}
Expand Down Expand Up @@ -415,6 +417,7 @@ void WebSocketDisasmState::SearchDisasm(DebuggerRequest &req) {
// Response (same event name):
// - encoding: resulting encoding at this address. Always returns one value, even for macros.
void WebSocketDisasmState::Assemble(DebuggerRequest &req) {
auto memLock = Memory::Lock();
if (!currentDebugMIPS->isAlive() || !Memory::IsActive()) {
return req.Fail("CPU not started");
}
Expand Down
4 changes: 3 additions & 1 deletion Windows/Debugger/CtrlDisAsmView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ COLORREF scaleColor(COLORREF color, float factor)

bool CtrlDisAsmView::getDisasmAddressText(u32 address, char* dest, bool abbreviateLabels, bool showData)
{
auto memLock = Memory::Lock();
if (!PSP_IsInited())
return false;

Expand Down Expand Up @@ -469,6 +468,7 @@ void CtrlDisAsmView::drawArguments(HDC hdc, const DisassemblyLineInfo &line, int

void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
{
auto memLock = Memory::Lock();
if (!debugger->isAlive()) return;

PAINTSTRUCT ps;
Expand Down Expand Up @@ -1180,6 +1180,7 @@ void CtrlDisAsmView::calculatePixelPositions()

void CtrlDisAsmView::search(bool continueSearch)
{
auto memLock = Memory::Lock();
u32 searchAddress;

if (continueSearch == false || searchQuery[0] == 0)
Expand Down Expand Up @@ -1260,6 +1261,7 @@ void CtrlDisAsmView::search(bool continueSearch)

std::string CtrlDisAsmView::disassembleRange(u32 start, u32 size)
{
auto memLock = Memory::Lock();
std::string result;

// gather all branch targets without labels
Expand Down
5 changes: 5 additions & 0 deletions Windows/Debugger/CtrlMemView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ CtrlMemView *CtrlMemView::getFrom(HWND hwnd)

void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam)
{
auto memLock = Memory::Lock();

// draw to a bitmap for double buffering
PAINTSTRUCT ps;
HDC actualHdc = BeginPaint(wnd, &ps);
Expand Down Expand Up @@ -445,6 +447,7 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)

case ID_MEMVIEW_COPYVALUE_8:
{
auto memLock = Memory::Lock();
char temp[24];

// it's admittedly not really useful like this
Expand All @@ -462,6 +465,7 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)

case ID_MEMVIEW_COPYVALUE_16:
{
auto memLock = Memory::Lock();
char temp[24];

sprintf(temp,"%04X",Memory::IsValidAddress(curAddress) ? Memory::Read_U16(curAddress) : 0xFFFF);
Expand All @@ -471,6 +475,7 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)

case ID_MEMVIEW_COPYVALUE_32:
{
auto memLock = Memory::Lock();
char temp[24];

sprintf(temp,"%08X",Memory::IsValidAddress(curAddress) ? Memory::Read_U32(curAddress) : 0xFFFFFFFF);
Expand Down

0 comments on commit 4d93a1a

Please sign in to comment.