فهرست منبع

Use BreakpointAddress struct instead of passing address directly

polaris- 10 سال پیش
والد
کامیت
42928659e8
3فایلهای تغییر یافته به همراه18 افزوده شده و 8 حذف شده
  1. 3 3
      src/core/arm/dyncom/arm_dyncom_interpreter.cpp
  2. 9 4
      src/core/gdbstub/gdbstub.cpp
  3. 6 1
      src/core/gdbstub/gdbstub.h

+ 3 - 3
src/core/arm/dyncom/arm_dyncom_interpreter.cpp

@@ -3583,7 +3583,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
     Common::Profiling::ScopeTimer timer_execute(profile_execute);
     MICROPROFILE_SCOPE(DynCom_Execute);
 
-    int breakpoint_offset = -1;
+    GDBStub::BreakpointAddress breakpoint_data;
 
     #undef RM
     #undef RS
@@ -3613,7 +3613,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
     cpu->Cpsr &= ~(1 << 5); \
     cpu->Cpsr |= cpu->TFlag << 5; \
     if (GDBStub::g_server_enabled) { \
-        if (GDBStub::IsMemoryBreak() || PC == breakpoint_offset) { \
+        if (GDBStub::IsMemoryBreak() || (breakpoint_data.type != GDBStub::BreakpointType::None && PC == breakpoint_data.address)) { \
             GDBStub::Break(); \
             goto END; \
         } \
@@ -3923,7 +3923,7 @@ unsigned InterpreterMainLoop(ARMul_State* cpu) {
 
         // Find breakpoint if one exists within the block
         if (GDBStub::g_server_enabled && GDBStub::IsConnected()) {
-            breakpoint_offset = GDBStub::GetNextBreakpointFromAddress(cpu->Reg[15], GDBStub::BreakpointType::Execute);
+            breakpoint_data = GDBStub::GetNextBreakpointFromAddress(cpu->Reg[15], GDBStub::BreakpointType::Execute);
         }
 
         inst_base = (arm_inst *)&inst_buf[ptr];

+ 9 - 4
src/core/gdbstub/gdbstub.cpp

@@ -231,13 +231,18 @@ static void RemoveBreakpoint(BreakpointType type, PAddr addr) {
     }
 }
 
-PAddr GetNextBreakpointFromAddress(PAddr addr, BreakpointType type) {
+BreakpointAddress GetNextBreakpointFromAddress(PAddr addr, BreakpointType type) {
     std::map<u32, Breakpoint>& p = GetBreakpointList(type);
     auto next_breakpoint = p.lower_bound(addr);
-    u32 breakpoint = -1;
+    BreakpointAddress breakpoint;
 
-    if (next_breakpoint != p.end())
-        breakpoint = next_breakpoint->first;
+    if (next_breakpoint != p.end()) {
+        breakpoint.address = next_breakpoint->first;
+        breakpoint.type = type;
+    } else {
+        breakpoint.address = 0;
+        breakpoint.type = BreakpointType::None;
+    }
 
     return breakpoint;
 }

+ 6 - 1
src/core/gdbstub/gdbstub.h

@@ -18,6 +18,11 @@ enum class BreakpointType {
     Access    ///< Access (R/W) Breakpoint
 };
 
+struct BreakpointAddress {
+    PAddr address;
+    BreakpointType type;
+};
+
 /// If set to false, the server will never be started and no gdbstub-related functions will be executed.
 extern std::atomic<bool> g_server_enabled;
 
@@ -63,7 +68,7 @@ void HandlePacket();
  * @param addr Address to search from.
  * @param type Type of breakpoint.
  */
-PAddr GetNextBreakpointFromAddress(u32 addr, GDBStub::BreakpointType type);
+BreakpointAddress GetNextBreakpointFromAddress(u32 addr, GDBStub::BreakpointType type);
 
 /**
  * Check if a breakpoint of the specified type exists at the given address.