Browse Source

Add TGDBController.SetCommand method and use it

git-svn-id: trunk@30046 -
pierre 10 years ago
parent
commit
caa77e1f8d
4 changed files with 38 additions and 11 deletions
  1. 7 7
      ide/fpdebug.pas
  2. 4 4
      ide/fpviews.pas
  3. 13 0
      ide/gdbmicon.pas
  4. 14 0
      packages/gdbint/src/gdbcon.pp

+ 7 - 7
ide/fpdebug.pas

@@ -668,12 +668,12 @@ begin
   WindowWidth:=-1;
   WindowWidth:=-1;
   switch_to_user:=true;
   switch_to_user:=true;
   GetDir(0,OrigPwd);
   GetDir(0,OrigPwd);
-  Command('set print object off');
+  SetCommand('print object off');
 {$ifdef SUPPORT_REMOTE}
 {$ifdef SUPPORT_REMOTE}
   isFirstRemote:=true;
   isFirstRemote:=true;
 {$ifdef FPC_ARMEL32}
 {$ifdef FPC_ARMEL32}
   { GDB needs advice on exact file type }
   { GDB needs advice on exact file type }
-  Command('set gnutarget elf32-littlearm');
+  SetCommand('gnutarget elf32-littlearm');
 {$endif FPC_ARMEL32}
 {$endif FPC_ARMEL32}
 {$endif SUPPORT_REMOTE}
 {$endif SUPPORT_REMOTE}
 end;
 end;
@@ -728,7 +728,7 @@ end;
 procedure TDebugController.SetWidth(AWidth : longint);
 procedure TDebugController.SetWidth(AWidth : longint);
 begin
 begin
   WindowWidth:=AWidth;
   WindowWidth:=AWidth;
-  Command('set width '+inttostr(WindowWidth));
+  SetCommand('width '+inttostr(WindowWidth));
 end;
 end;
 
 
 procedure TDebugController.SetSourceDirs;
 procedure TDebugController.SetSourceDirs;
@@ -940,9 +940,9 @@ begin
 {$ifdef Windows}
 {$ifdef Windows}
   { Run the debugge in another console }
   { Run the debugge in another console }
   if DebuggeeTTY<>'' then
   if DebuggeeTTY<>'' then
-    Command('set new-console on')
+    SetCommand('new-console on')
   else
   else
-    Command('set new-console off');
+    SetCommand('new-console off');
   NoSwitch:=DebuggeeTTY<>'';
   NoSwitch:=DebuggeeTTY<>'';
 {$endif Windows}
 {$endif Windows}
 {$ifdef Unix}
 {$ifdef Unix}
@@ -3538,7 +3538,7 @@ end;
       Clear;
       Clear;
 
 
       if Debugger^.WindowWidth<>-1 then
       if Debugger^.WindowWidth<>-1 then
-        Debugger^.Command('set width 0xffffffff');
+        Debugger^.SetCommand('width 0xffffffff');
       Debugger^.Backtrace;
       Debugger^.Backtrace;
       { generate list }
       { generate list }
       { all is in tframeentry }
       { all is in tframeentry }
@@ -3580,7 +3580,7 @@ end;
       if Assigned(list) and (List^.Count > 0) then
       if Assigned(list) and (List^.Count > 0) then
         FocusItem(0);
         FocusItem(0);
       if Debugger^.WindowWidth<>-1 then
       if Debugger^.WindowWidth<>-1 then
-        Debugger^.Command('set width '+IntToStr(Debugger^.WindowWidth));
+        Debugger^.SetCommand('width '+IntToStr(Debugger^.WindowWidth));
       DeskTop^.Unlock;
       DeskTop^.Unlock;
 {$endif NODEBUG}
 {$endif NODEBUG}
     end;
     end;

+ 4 - 4
ide/fpviews.pas

@@ -2764,8 +2764,8 @@ var
 begin
 begin
 {$ifndef NODEBUG}
 {$ifndef NODEBUG}
   If not assigned(Debugger) then Exit;
   If not assigned(Debugger) then Exit;
-  Debugger^.Command('set print sym on');
-  Debugger^.Command('set width 0xffffffff');
+  Debugger^.SetCommand('print sym on');
+  Debugger^.SetCommand('width 0xffffffff');
   Debugger^.Command('disas '+FuncName);
   Debugger^.Command('disas '+FuncName);
   p:=StrNew(Debugger^.GetOutput);
   p:=StrNew(Debugger^.GetOutput);
   ProcessPChar(p);
   ProcessPChar(p);
@@ -2780,8 +2780,8 @@ var
 begin
 begin
 {$ifndef NODEBUG}
 {$ifndef NODEBUG}
   If not assigned(Debugger) then Exit;
   If not assigned(Debugger) then Exit;
-  Debugger^.Command('set print sym on');
-  Debugger^.Command('set width 0xffffffff');
+  Debugger^.SetCommand('print sym on');
+  Debugger^.SetCommand('width 0xffffffff');
   Debugger^.Command('disas 0x'+HexStr(Addr,8));
   Debugger^.Command('disas 0x'+HexStr(Addr,8));
   p:=StrNew(Debugger^.GetOutput);
   p:=StrNew(Debugger^.GetOutput);
   ProcessPChar(p);
   ProcessPChar(p);

+ 13 - 0
ide/gdbmicon.pas

@@ -64,6 +64,8 @@ type
     function GetIntRegister(const RegName: string; var Value: Int64): Boolean;
     function GetIntRegister(const RegName: string; var Value: Int64): Boolean;
     function GetIntRegister(const RegName: string; var Value: UInt32): Boolean;
     function GetIntRegister(const RegName: string; var Value: UInt32): Boolean;
     function GetIntRegister(const RegName: string; var Value: Int32): Boolean;
     function GetIntRegister(const RegName: string; var Value: Int32): Boolean;
+    { set command }
+    function SetCommand(Const SetExpr : string) : boolean;
     { print }
     { print }
     function PrintCommand(const expr : string): pchar;
     function PrintCommand(const expr : string): pchar;
     function PrintFormattedCommand(const expr : string; Format : TPrintFormatType): pchar;
     function PrintFormattedCommand(const expr : string; Format : TPrintFormatType): pchar;
@@ -286,6 +288,17 @@ begin
 end;
 end;
 
 
 
 
+{ set command }
+function TGDBController.SetCommand(Const SetExpr : string) : boolean;
+begin
+  SetCommand:=false;
+  Command('-gdb-set '+SetExpr);
+  if error then
+    exit;
+  SetCommand:=true;
+end;
+
+
 { print }
 { print }
 function TGDBController.PrintCommand(const expr : string): pchar;
 function TGDBController.PrintCommand(const expr : string): pchar;
 begin
 begin

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

@@ -58,6 +58,8 @@ type
     function GetIntRegister(const RegName: string; var Value: Int64): Boolean;
     function GetIntRegister(const RegName: string; var Value: Int64): Boolean;
     function GetIntRegister(const RegName: string; var Value: UInt32): Boolean;
     function GetIntRegister(const RegName: string; var Value: UInt32): Boolean;
     function GetIntRegister(const RegName: string; var Value: Int32): Boolean;
     function GetIntRegister(const RegName: string; var Value: Int32): Boolean;
+    { set command }
+    function SetCommand(Const SetExpr : string) : boolean;
     { print }
     { print }
     function InternalGetValue(Const expr : string) : pchar;
     function InternalGetValue(Const expr : string) : pchar;
     function PrintCommand(const expr : string): pchar;
     function PrintCommand(const expr : string): pchar;
@@ -325,6 +327,8 @@ begin
   Command('finish');
   Command('finish');
 end;
 end;
 
 
+{ Register functions }
+
 function TGDBController.GetIntRegister(const RegName: string; var Value: UInt64): Boolean;
 function TGDBController.GetIntRegister(const RegName: string; var Value: UInt64): Boolean;
 var
 var
   RegValueStr: string;
   RegValueStr: string;
@@ -402,6 +406,16 @@ begin
   Value := Int32(U32Value);
   Value := Int32(U32Value);
 end;
 end;
 
 
+{ set command }
+function TGDBController.SetCommand(Const SetExpr : string) : boolean;
+begin
+  SetCommand:=false;
+  Command('set '+SetExpr);
+  if error then
+    exit;
+  SetCommand:=true;
+end;
+
 { print }
 { print }
 
 
 function TGDBController.InternalGetValue(Const expr : string) : pchar;
 function TGDBController.InternalGetValue(Const expr : string) : pchar;