diff --git a/Sources/GDBRemote/DebugSessionImpl.cpp b/Sources/GDBRemote/DebugSessionImpl.cpp index b509d70c..cdd3c4b7 100644 --- a/Sources/GDBRemote/DebugSessionImpl.cpp +++ b/Sources/GDBRemote/DebugSessionImpl.cpp @@ -1093,30 +1093,48 @@ ErrorCode DebugSessionImplBase::onInsertBreakpoint( StringCollection const &commands, bool persistentCommands) { DS2ASSERT(conditions.empty() && commands.empty() && !persistentCommands); + MemoryRegionInfo info; + CHK(_process->getMemoryRegionInfo(address, info)); + BreakpointManager *bpm = nullptr; BreakpointManager::Mode mode; switch (type) { case kSoftwareBreakpoint: + if (!(info.protection & kProtectionExecute)) + return kErrorInvalidAddress; + bpm = _process->softwareBreakpointManager(); mode = BreakpointManager::kModeExec; break; case kHardwareBreakpoint: + if (!(info.protection & kProtectionExecute)) + return kErrorInvalidAddress; + bpm = _process->hardwareBreakpointManager(); mode = BreakpointManager::kModeExec; break; case kReadWatchpoint: + if (!(info.protection & kProtectionRead)) + return kErrorInvalidAddress; + bpm = _process->hardwareBreakpointManager(); mode = BreakpointManager::kModeRead; break; case kWriteWatchpoint: + if (!(info.protection & kProtectionWrite)) + return kErrorInvalidAddress; + bpm = _process->hardwareBreakpointManager(); mode = BreakpointManager::kModeWrite; break; case kAccessWatchpoint: + if (!(info.protection & (kProtectionRead | kProtectionWrite))) + return kErrorInvalidAddress; + bpm = _process->hardwareBreakpointManager(); mode = static_cast(BreakpointManager::kModeRead | BreakpointManager::kModeWrite); diff --git a/Support/Testing/Excluded/ds2/android-x86_64.excluded b/Support/Testing/Excluded/ds2/android-x86_64.excluded index 40780334..9030e37e 100644 --- a/Support/Testing/Excluded/ds2/android-x86_64.excluded +++ b/Support/Testing/Excluded/ds2/android-x86_64.excluded @@ -1,5 +1,4 @@ skip -TestBadAddressBreakpoints.BadAddressBreakpointTestCase.test_bad_address_breakpoints TestBreakpointSerialization.BreakpointSerialization.test_scripted_extra_args TestBreakpointSetRestart.BreakpointSetRestart.test_breakpoint_set_restart_dwarf TestBreakpointSetRestart.BreakpointSetRestart.test_breakpoint_set_restart_dwo diff --git a/Support/Testing/Excluded/ds2/linux-x86_64.excluded b/Support/Testing/Excluded/ds2/linux-x86_64.excluded index 1bd0602f..2acdd0d8 100644 --- a/Support/Testing/Excluded/ds2/linux-x86_64.excluded +++ b/Support/Testing/Excluded/ds2/linux-x86_64.excluded @@ -1,7 +1,6 @@ skip lldbsuite.test.lldbtest.TestPrintf.test_dwarf lldbsuite.test.lldbtest.TestPrintf.test_dwo -TestBadAddressBreakpoints.BadAddressBreakpointTestCase.test_bad_address_breakpoints TestBreakpointInGlobalConstructor.TestBreakpointInGlobalConstructors.test TestBreakpointSerialization.BreakpointSerialization.test_scripted_extra_args TestBreakpointSetRestart.BreakpointSetRestart.test_breakpoint_set_restart_dwo