+ added method WatchpointInsert to TGDBController, with a gdb/mi implementation

* all breakpoint and watchpoint adding now go through TGDBController and use
  the proper gdb/mi commands when compiled with the gdb/mi debugger

git-svn-id: trunk@29746 -
This commit is contained in:
nickysn 2015-02-17 22:49:31 +00:00
parent d6e4af8279
commit df234bd7fe
3 changed files with 47 additions and 9 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;