Skip to content

Commit

Permalink
Merge pull request #11186 from unknownbrackets/debugger
Browse files Browse the repository at this point in the history
Debugger: Add APIs to retrieve render image
  • Loading branch information
hrydgard committed Jun 17, 2018
2 parents 03c89e7 + 35ccd16 commit da5f0f7
Show file tree
Hide file tree
Showing 22 changed files with 583 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -1414,6 +1414,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Debugger/WebSocket/GameBroadcaster.h
Core/Debugger/WebSocket/GameSubscriber.cpp
Core/Debugger/WebSocket/GameSubscriber.h
Core/Debugger/WebSocket/GPUBufferSubscriber.cpp
Core/Debugger/WebSocket/GPUBufferSubscriber.h
Core/Debugger/WebSocket/HLESubscriber.cpp
Core/Debugger/WebSocket/HLESubscriber.h
Core/Debugger/WebSocket/LogBroadcaster.cpp
Expand Down
4 changes: 4 additions & 0 deletions Core/Core.cpp
Expand Up @@ -37,6 +37,7 @@
#include "Core/System.h"
#include "Core/Debugger/Breakpoints.h"
#include "Core/MIPS/MIPS.h"
#include "GPU/Debugger/Stepping.h"

#ifdef _WIN32
#include "Common/CommonWindows.h"
Expand Down Expand Up @@ -280,6 +281,9 @@ void Core_ProcessStepping() {
return;
}

// Or any GPU actions.
GPUStepping::SingleStep();

// We're not inside jit now, so it's safe to clear the breakpoints.
CBreakPoints::ClearTemporaryBreakPoints();
host->UpdateDisassembly();
Expand Down
2 changes: 2 additions & 0 deletions Core/Core.vcxproj
Expand Up @@ -189,6 +189,7 @@
<ClCompile Include="Debugger\WebSocket\CPUCoreSubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\GameBroadcaster.cpp" />
<ClCompile Include="Debugger\WebSocket\GameSubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\GPUBufferSubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\HLESubscriber.cpp" />
<ClCompile Include="Debugger\WebSocket\LogBroadcaster.cpp" />
<ClCompile Include="Debugger\WebSocket\DisasmSubscriber.cpp" />
Expand Down Expand Up @@ -547,6 +548,7 @@
<ClInclude Include="Debugger\WebSocket\BreakpointSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\GameSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\DisasmSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\GPUBufferSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\HLESubscriber.h" />
<ClInclude Include="Debugger\WebSocket\SteppingSubscriber.h" />
<ClInclude Include="Debugger\WebSocket\WebSocketUtils.h" />
Expand Down
6 changes: 6 additions & 0 deletions Core/Core.vcxproj.filters
Expand Up @@ -728,6 +728,9 @@
<ClCompile Include="Debugger\WebSocket\HLESubscriber.cpp">
<Filter>Debugger\WebSocket</Filter>
</ClCompile>
<ClCompile Include="Debugger\WebSocket\GPUBufferSubscriber.cpp">
<Filter>Debugger\WebSocket</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
Expand Down Expand Up @@ -1346,6 +1349,9 @@
<ClInclude Include="Debugger\WebSocket\HLESubscriber.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>
<ClInclude Include="Debugger\WebSocket\GPUBufferSubscriber.h">
<Filter>Debugger\WebSocket</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
Expand Down
2 changes: 2 additions & 0 deletions Core/Debugger/WebSocket.cpp
Expand Up @@ -52,6 +52,7 @@
#include "Core/Debugger/WebSocket/CPUCoreSubscriber.h"
#include "Core/Debugger/WebSocket/DisasmSubscriber.h"
#include "Core/Debugger/WebSocket/GameSubscriber.h"
#include "Core/Debugger/WebSocket/GPUBufferSubscriber.h"
#include "Core/Debugger/WebSocket/HLESubscriber.h"
#include "Core/Debugger/WebSocket/SteppingSubscriber.h"

Expand All @@ -67,6 +68,7 @@ static const std::vector<SubscriberInfo> subscribers({
{ &WebSocketCPUCoreInit, nullptr },
{ &WebSocketDisasmInit, &WebSocketDisasmShutdown },
{ &WebSocketGameInit, nullptr },
{ &WebSocketGPUBufferInit, nullptr },
{ &WebSocketHLEInit, nullptr },
{ &WebSocketSteppingInit, &WebSocketSteppingShutdown },
});
Expand Down
94 changes: 94 additions & 0 deletions Core/Debugger/WebSocket/BreakpointSubscriber.cpp
Expand Up @@ -121,6 +121,18 @@ struct WebSocketCPUBreakpointParams {
}
};

// Add a new CPU instruction breakpoint (cpu.breakpoint.add)
//
// Parameters:
// - address: unsigned integer address of instruction to break at.
// - enabled: optional boolean, whether to actually enter stepping when this breakpoint trips.
// - log: optional boolean, whether to log when this breakpoint trips.
// - condition: optional string expression to evaluate - breakpoint does not trip if false.
// - logFormat: optional string to log when breakpoint trips, may include {expression} parts.
//
// Response (same event name) with no extra data.
//
// Note: will replace any breakpoint at the same address.
void WebSocketCPUBreakpointAdd(DebuggerRequest &req) {
WebSocketCPUBreakpointParams params;
if (!params.Parse(req))
Expand All @@ -131,6 +143,16 @@ void WebSocketCPUBreakpointAdd(DebuggerRequest &req) {
req.Respond();
}

// Update a CPU instruction breakpoint (cpu.breakpoint.update)
//
// Parameters:
// - address: unsigned integer address of instruction to break at.
// - enabled: optional boolean, whether to actually enter stepping when this breakpoint trips.
// - log: optional boolean, whether to log when this breakpoint trips.
// - condition: optional string expression to evaluate - breakpoint does not trip if false.
// - logFormat: optional string to log when breakpoint trips, may include {expression} parts.
//
// Response (same event name) with no extra data.
void WebSocketCPUBreakpointUpdate(DebuggerRequest &req) {
WebSocketCPUBreakpointParams params;
if (!params.Parse(req))
Expand All @@ -143,6 +165,12 @@ void WebSocketCPUBreakpointUpdate(DebuggerRequest &req) {
req.Respond();
}

// Remove a CPU instruction breakpoint (cpu.breakpoint.remove)
//
// Parameters:
// - address: unsigned integer address of instruction to break at.
//
// Response (same event name) with no extra data.
void WebSocketCPUBreakpointRemove(DebuggerRequest &req) {
if (!currentDebugMIPS->isAlive()) {
return req.Fail("CPU not started");
Expand All @@ -156,6 +184,19 @@ void WebSocketCPUBreakpointRemove(DebuggerRequest &req) {
req.Respond();
}

// List all CPU instruction breakpoints (cpu.breakpoint.list)
//
// No parameters.
//
// Response (same event name):
// - breakpoints: array of objects, each with properties:
// - address: unsigned integer address of instruction to break at.
// - enabled: boolean, whether to actually enter stepping when this breakpoint trips.
// - log: optional boolean, whether to log when this breakpoint trips.
// - condition: null, or string expression to evaluate - breakpoint does not trip if false.
// - logFormat: null, or string to log when breakpoint trips, may include {expression} parts.
// - symbol: null, or string label or symbol at breakpoint address.
// - code: string disassembly of breakpoint address.
void WebSocketCPUBreakpointList(DebuggerRequest &req) {
if (!currentDebugMIPS->isAlive()) {
return req.Fail("CPU not started");
Expand Down Expand Up @@ -278,6 +319,22 @@ struct WebSocketMemoryBreakpointParams {
}
};

// Add a new memory breakpoint (memory.breakpoint.add)
//
// Parameters:
// - address: unsigned integer address for the start of the memory range.
// - size: unsigned integer specifying size of memory range.
// - enabled: optional boolean, whether to actually enter stepping when this breakpoint trips.
// - log: optional boolean, whether to log when this breakpoint trips.
// - read: optional boolean, whether to trip on any read to this address.
// - write: optional boolean, whether to trip on any write to this address.
// - change: optional boolean, whether to trip on a write to this address which modifies data
// (or any write that may modify data.)
// - logFormat: optional string to log when breakpoint trips, may include {expression} parts.
//
// Response (same event name) with no extra data.
//
// Note: will replace any breakpoint that has the same start address and size.
void WebSocketMemoryBreakpointAdd(DebuggerRequest &req) {
WebSocketMemoryBreakpointParams params;
if (!params.Parse(req))
Expand All @@ -288,6 +345,20 @@ void WebSocketMemoryBreakpointAdd(DebuggerRequest &req) {
req.Respond();
}

// Update a memory breakpoint (memory.breakpoint.update)
//
// Parameters:
// - address: unsigned integer address for the start of the memory range.
// - size: unsigned integer specifying size of memory range.
// - enabled: optional boolean, whether to actually enter stepping when this breakpoint trips.
// - log: optional boolean, whether to log when this breakpoint trips.
// - read: optional boolean, whether to trip on any read to this address.
// - write: optional boolean, whether to trip on any write to this address.
// - change: optional boolean, whether to trip on a write to this address which modifies data
// (or any write that may modify data.)
// - logFormat: optional string to log when breakpoint trips, may include {expression} parts.
//
// Response (same event name) with no extra data.
void WebSocketMemoryBreakpointUpdate(DebuggerRequest &req) {
WebSocketMemoryBreakpointParams params;
if (!params.Parse(req))
Expand All @@ -302,6 +373,13 @@ void WebSocketMemoryBreakpointUpdate(DebuggerRequest &req) {
req.Respond();
}

// Remove a memory breakpoint (memory.breakpoint.remove)
//
// Parameters:
// - address: unsigned integer address for the start of the memory range.
// - size: unsigned integer specifying size of memory range.
//
// Response (same event name) with no extra data.
void WebSocketMemoryBreakpointRemove(DebuggerRequest &req) {
if (!currentDebugMIPS->isAlive()) {
return req.Fail("CPU not started");
Expand All @@ -318,6 +396,22 @@ void WebSocketMemoryBreakpointRemove(DebuggerRequest &req) {
req.Respond();
}

// List all memory breakpoints (memory.breakpoint.list)
//
// No parameters.
//
// Response (same event name):
// - breakpoints: array of objects, each with properties:
// - address: unsigned integer address for the start of the memory range.
// - size: unsigned integer specifying size of memory range.
// - enabled: boolean, whether to actually enter stepping when this breakpoint trips.
// - log: optional boolean, whether to log when this breakpoint trips.
// - read: optional boolean, whether to trip on any read to this address.
// - write: optional boolean, whether to trip on any write to this address.
// - change: optional boolean, whether to trip on a write to this address which modifies data
// (or any write that may modify data.)
// - logFormat: null, or string to log when breakpoint trips, may include {expression} parts.
// - symbol: null, or string label or symbol at breakpoint address.
void WebSocketMemoryBreakpointList(DebuggerRequest &req) {
if (!currentDebugMIPS->isAlive()) {
return req.Fail("CPU not started");
Expand Down

0 comments on commit da5f0f7

Please sign in to comment.