From 8fd0269baeb26adde32597bf37d71e2256c0e341 Mon Sep 17 00:00:00 2001 From: joost Date: Sat, 16 Aug 2014 21:40:08 +0000 Subject: [PATCH] FpDebug (pure): Detect if a HW breakpoint has been triggered on Linux git-svn-id: trunk@46045 - --- components/fpdebug/fpdbglinuxclasses.pas | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/fpdebug/fpdbglinuxclasses.pas b/components/fpdebug/fpdbglinuxclasses.pas index 84d81c38eb..012aa4fc6a 100644 --- a/components/fpdebug/fpdbglinuxclasses.pas +++ b/components/fpdebug/fpdbglinuxclasses.pas @@ -231,6 +231,7 @@ type function ResetInstructionPointerAfterBreakpoint: boolean; override; function AddWatchpoint(AnAddr: TDBGPtr): integer; override; function RemoveWatchpoint(AnId: integer): boolean; override; + function DetectHardwareWatchpoint: integer; override; procedure BeforeContinue; override; procedure LoadRegisterValues; override; end; @@ -433,10 +434,27 @@ begin end; end; +function TDbgLinuxThread.DetectHardwareWatchpoint: integer; +var + dr6: PtrUInt; +begin + result := -1; + if ReadDebugReg(6, dr6) then + begin + if dr6 and 1 = 1 then result := 0 + else if dr6 and 2 = 2 then result := 1 + else if dr6 and 4 = 4 then result := 2 + else if dr6 and 8 = 8 then result := 3; + end; +end; + procedure TDbgLinuxThread.BeforeContinue; var io: iovec; begin + if Process.CurrentWatchpoint>-1 then + WriteDebugReg(6, 0); + if FUserRegsChanged then begin io.iov_base:=@(FUserRegs.regs64[0]);