Browse Source

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

nickysn 10 years ago
parent
commit
df234bd7fe
3 changed files with 47 additions and 9 deletions
  1. 9 9
      ide/fpdebug.pas
  2. 19 0
      ide/gdbmicon.pas
  3. 19 0
      packages/gdbint/src/gdbcon.pp

+ 9 - 9
ide/fpdebug.pas

@@ -1770,28 +1770,28 @@ procedure TBreakpoint.Insert;
   var
   var
     p,p2 : pchar;
     p,p2 : pchar;
     st : string;
     st : string;
+    bkpt_no: LongInt = 0;
 begin
 begin
 {$ifndef NODEBUG}
 {$ifndef NODEBUG}
   If not assigned(Debugger) then Exit;
   If not assigned(Debugger) then Exit;
   Remove;
   Remove;
-  Debugger^.last_breakpoint_number:=0;
   if (GDBState=bs_deleted) and (state=bs_enabled) then
   if (GDBState=bs_deleted) and (state=bs_enabled) then
     begin
     begin
       if (typ=bt_file_line) and assigned(FileName) then
       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
       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
       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
       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
       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
       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
         begin
-          GDBIndex:=Debugger^.last_breakpoint_number;
+          GDBIndex:=bkpt_no;
           GDBState:=bs_enabled;
           GDBState:=bs_enabled;
           Debugger^.Command('cond '+IntToStr(GDBIndex)+' '+GetStr(Conditions));
           Debugger^.Command('cond '+IntToStr(GDBIndex)+' '+GetStr(Conditions));
           If IgnoreCount>0 then
           If IgnoreCount>0 then

+ 19 - 0
ide/gdbmicon.pas

@@ -25,6 +25,8 @@ uses
   gdbmiint, gdbmiwrap;
   gdbmiint, gdbmiwrap;
 
 
 type
 type
+  TWatchpointType = (wtWrite, wtReadWrite, wtRead);
+
   TGDBController = object(TGDBInterface)
   TGDBController = object(TGDBInterface)
   private
   private
     procedure RunExecCommand(const Cmd: string);
     procedure RunExecCommand(const Cmd: string);
@@ -52,6 +54,7 @@ type
     procedure Continue; virtual;
     procedure Continue; virtual;
     procedure UntilReturn; virtual;
     procedure UntilReturn; virtual;
     function BreakpointInsert(const location: string): LongInt;
     function BreakpointInsert(const location: string): LongInt;
+    function WatchpointInsert(const location: string; WatchpointType: TWatchpointType): LongInt;
     procedure SetTBreak(tbreakstring : string);
     procedure SetTBreak(tbreakstring : string);
     procedure Backtrace;
     procedure Backtrace;
     function LoadFile(var fn: string): Boolean;
     function LoadFile(var fn: string): Boolean;
@@ -175,6 +178,22 @@ begin
     BreakpointInsert := 0;
     BreakpointInsert := 0;
 end;
 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);
 procedure TGDBController.SetTBreak(tbreakstring : string);
 begin
 begin
   Command('-break-insert -t ' + tbreakstring);
   Command('-break-insert -t ' + tbreakstring);

+ 19 - 0
packages/gdbint/src/gdbcon.pp

@@ -25,6 +25,8 @@ uses
   GDBInt;
   GDBInt;
 
 
 type
 type
+  TWatchpointType = (wtWrite, wtReadWrite, wtRead);
+
   PGDBController=^TGDBController;
   PGDBController=^TGDBController;
   TGDBController=object(TGDBInterface)
   TGDBController=object(TGDBInterface)
     progname,
     progname,
@@ -50,6 +52,7 @@ type
     procedure Continue;virtual;
     procedure Continue;virtual;
     procedure UntilReturn;virtual;
     procedure UntilReturn;virtual;
     function BreakpointInsert(const location: string): LongInt;
     function BreakpointInsert(const location: string): LongInt;
+    function WatchpointInsert(const location: string; WatchpointType: TWatchpointType): LongInt;
     procedure SetTBreak(tbreakstring : string);
     procedure SetTBreak(tbreakstring : string);
     procedure Backtrace;
     procedure Backtrace;
     { needed for dos because newlines are only #10 (PM) }
     { needed for dos because newlines are only #10 (PM) }
@@ -307,12 +310,28 @@ end;
 
 
 function TGDBController.BreakpointInsert(const location: string): LongInt;
 function TGDBController.BreakpointInsert(const location: string): LongInt;
 begin
 begin
+  Last_breakpoint_number:=0;
   Command('break '+location);
   Command('break '+location);
   BreakpointInsert:=Last_breakpoint_number;
   BreakpointInsert:=Last_breakpoint_number;
 end;
 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);
 procedure TGDBController.SetTBreak(tbreakstring : string);
 begin
 begin
+  Last_breakpoint_number:=0;
   Command('tbreak '+tbreakstring);
   Command('tbreak '+tbreakstring);
   TBreakNumber:=Last_breakpoint_number;
   TBreakNumber:=Last_breakpoint_number;
 end;
 end;