diff --git a/ide/fpdebug.pas b/ide/fpdebug.pas index 2eae58d28a..2bc62e2edc 100644 --- a/ide/fpdebug.pas +++ b/ide/fpdebug.pas @@ -1770,28 +1770,28 @@ procedure TBreakpoint.Insert; var p,p2 : pchar; st : string; + bkpt_no: LongInt = 0; begin {$ifndef NODEBUG} If not assigned(Debugger) then Exit; Remove; - Debugger^.last_breakpoint_number:=0; if (GDBState=bs_deleted) and (state=bs_enabled) then begin if (typ=bt_file_line) and assigned(FileName) then - Debugger^.Command('break '+GDBFileName(NameAndExtOf(GetStr(FileName)))+':'+IntToStr(Line)) + bkpt_no := Debugger^.BreakpointInsert(GDBFileName(NameAndExtOf(GetStr(FileName)))+':'+IntToStr(Line)) else if (typ=bt_function) and assigned(name) then - Debugger^.Command('break '+name^) + bkpt_no := Debugger^.BreakpointInsert(name^) else if (typ=bt_address) and assigned(name) then - Debugger^.Command('break *0x'+name^) + bkpt_no := Debugger^.BreakpointInsert('*0x'+name^) else if (typ=bt_watch) and assigned(name) then - Debugger^.Command('watch '+name^) + bkpt_no := Debugger^.WatchpointInsert(name^, wtWrite) else if (typ=bt_awatch) and assigned(name) then - Debugger^.Command('awatch '+name^) + bkpt_no := Debugger^.WatchpointInsert(name^, wtReadWrite) else if (typ=bt_rwatch) and assigned(name) then - Debugger^.Command('rwatch '+name^); - if Debugger^.last_breakpoint_number<>0 then + bkpt_no := Debugger^.WatchpointInsert(name^, wtRead); + if bkpt_no<>0 then begin - GDBIndex:=Debugger^.last_breakpoint_number; + GDBIndex:=bkpt_no; GDBState:=bs_enabled; Debugger^.Command('cond '+IntToStr(GDBIndex)+' '+GetStr(Conditions)); If IgnoreCount>0 then diff --git a/ide/gdbmicon.pas b/ide/gdbmicon.pas index 35f18ee185..d0a7a8fe1a 100644 --- a/ide/gdbmicon.pas +++ b/ide/gdbmicon.pas @@ -25,6 +25,8 @@ uses gdbmiint, gdbmiwrap; type + TWatchpointType = (wtWrite, wtReadWrite, wtRead); + TGDBController = object(TGDBInterface) private procedure RunExecCommand(const Cmd: string); @@ -52,6 +54,7 @@ type procedure Continue; virtual; procedure UntilReturn; virtual; function BreakpointInsert(const location: string): LongInt; + function WatchpointInsert(const location: string; WatchpointType: TWatchpointType): LongInt; procedure SetTBreak(tbreakstring : string); procedure Backtrace; function LoadFile(var fn: string): Boolean; @@ -175,6 +178,22 @@ begin BreakpointInsert := 0; end; +function TGDBController.WatchpointInsert(const location: string; WatchpointType: TWatchpointType): LongInt; +begin + case WatchpointType of + wtWrite: + Command('-break-watch ' + location); + wtReadWrite: + Command('-break-watch -a ' + location); + wtRead: + Command('-break-watch -r ' + location); + end; + if GDB.ResultRecord.Success then + WatchpointInsert := GDB.ResultRecord.Parameters['wpt'].AsTuple['number'].AsLongInt + else + WatchpointInsert := 0; +end; + procedure TGDBController.SetTBreak(tbreakstring : string); begin Command('-break-insert -t ' + tbreakstring); diff --git a/packages/gdbint/src/gdbcon.pp b/packages/gdbint/src/gdbcon.pp index 4d85dc669d..154dbc8bd0 100644 --- a/packages/gdbint/src/gdbcon.pp +++ b/packages/gdbint/src/gdbcon.pp @@ -25,6 +25,8 @@ uses GDBInt; type + TWatchpointType = (wtWrite, wtReadWrite, wtRead); + PGDBController=^TGDBController; TGDBController=object(TGDBInterface) progname, @@ -50,6 +52,7 @@ type procedure Continue;virtual; procedure UntilReturn;virtual; function BreakpointInsert(const location: string): LongInt; + function WatchpointInsert(const location: string; WatchpointType: TWatchpointType): LongInt; procedure SetTBreak(tbreakstring : string); procedure Backtrace; { needed for dos because newlines are only #10 (PM) } @@ -307,12 +310,28 @@ end; function TGDBController.BreakpointInsert(const location: string): LongInt; begin + Last_breakpoint_number:=0; Command('break '+location); BreakpointInsert:=Last_breakpoint_number; end; +function TGDBController.WatchpointInsert(const location: string; WatchpointType: TWatchpointType): LongInt; +begin + Last_breakpoint_number:=0; + case WatchpointType of + wtWrite: + Command('watch ' + location); + wtReadWrite: + Command('awatch ' + location); + wtRead: + Command('rwatch ' + location); + end; + BreakpointInsert:=Last_breakpoint_number; +end; + procedure TGDBController.SetTBreak(tbreakstring : string); begin + Last_breakpoint_number:=0; Command('tbreak '+tbreakstring); TBreakNumber:=Last_breakpoint_number; end;