+ Added SSHGDB debugger

git-svn-id: trunk@4417 -
This commit is contained in:
marc 2003-07-24 08:47:37 +00:00
parent 745eae1cef
commit e0a9af5324
9 changed files with 113 additions and 75 deletions

View File

@ -60,7 +60,7 @@ type
procedure SendCmdLn(const ACommand: String); overload;
procedure SendCmdLn(const ACommand: String; Values: array of const); overload;
public
constructor Create(const AExternalDebugger: String); {override; }
constructor Create(const AExternalDebugger: String); override;
destructor Destroy; override;
procedure TestCmd(const ACommand: String); virtual;// For internal debugging purposes
public
@ -171,11 +171,11 @@ end;
function TCmdLineDebugger.CreateDebugProcess(const AOptions: String): Boolean;
begin
if FDbgProcess = nil
if FDbgProcess = nil
then begin
FDbgProcess := TProcess.Create(nil);
FDbgProcess.CommandLine := ExternalDebugger + ' ' + AOptions;
FDbgProcess.Options:= [poUsePipes, poNoConsole, poStdErrToOutPut];
FDbgProcess.Options:= [poUsePipes, {poNoConsole,} poStdErrToOutPut];
FDbgProcess.ShowWindow := swoNone;
FDbgProcess.Environment:=Environment;
end;
@ -369,6 +369,9 @@ end;
end.
{ =============================================================================
$Log$
Revision 1.17 2003/07/24 08:47:37 marc
+ Added SSHGDB debugger
Revision 1.16 2003/06/17 23:13:06 marc
* Canged Linux derective to unit, so it will work on xxxbsd?

View File

@ -835,10 +835,11 @@ type
procedure SetState(const AValue: TDBGState);
procedure InitTargetStart; virtual;
public
constructor Create(const AExternalDebugger: String); {virtual; Virtual constructor makes no sense}
constructor Create(const AExternalDebugger: String); virtual; {Virtual constructor makes no sense}
//MWE: there will be a day that they do make sense :-)
// MG: there will be a day that they do make troubles :)
//MWE: do they ?
//MWE: Now they do make sense !
destructor Destroy; override;
procedure Init; virtual; // Initializes the debugger
@ -878,6 +879,7 @@ type
property OnOutput: TDBGOutputEvent read FOnOutput write FOnOutput; // Passes all output of the debugged target
property OnState: TDebuggerStateChangedEvent read FOnState write FOnState; // Fires when the current state of the debugger changes
end;
TDebuggerClass = class of TDebugger;
const
DBGCommandNames: array[TDBGCommand] of string = (
@ -2988,6 +2990,9 @@ end;
end.
{ =============================================================================
$Log$
Revision 1.45 2003/07/24 08:47:37 marc
+ Added SSHGDB debugger
Revision 1.44 2003/06/13 19:21:31 marc
MWE: + Added initial signal and exception handling

View File

@ -100,9 +100,10 @@ type
function CreateCallStack: TDBGCallStack; override;
function CreateWatches: TDBGWatches; override;
function GetSupportedCommands: TDBGCommands; override;
function ParseInitialization: Boolean; virtual;
function RequestCommand(const ACommand: TDBGCommand; const AParams: array of const): Boolean; override;
public
constructor Create(const AExternalDebugger: String); {override;}
constructor Create(const AExternalDebugger: String); override;
destructor Destroy; override;
procedure Init; override; // Initializes external debugger
@ -794,25 +795,18 @@ procedure TGDBMIDebugger.Init;
FVersion := GetPart(['gdb '], [#10, #13], S, True, False);
if FVersion <> '' then Exit;
end;
var
Line, S: String;
begin
FPauseWaitState := pwsNone;
FInExecuteCount := 0;
if CreateDebugProcess('-silent -i mi')
then begin
// Get initial debugger lines
S := '';
Line := StripLN(ReadLine);
while DebugProcessRunning and (Line <> '(gdb) ') do
begin
S := S + Line + LINE_END;
Line := StripLN(ReadLine);
if not ParseInitialization
then begin
SetState(dsError);
Exit;
end;
if S <> ''
then MessageDlg('Debugger', 'Initialization output: ' + LINE_END + S, mtInformation, [mbOK], 0);
ExecuteCommand('-gdb-set confirm off', []);
// try to find the debugger version
@ -836,6 +830,24 @@ begin
end;
end;
function TGDBMIDebugger.ParseInitialization: Boolean;
var
Line, S: String;
begin
Result := True;
// Get initial debugger lines
S := '';
Line := StripLN(ReadLine);
while DebugProcessRunning and (Line <> '(gdb) ') do
begin
S := S + Line + LINE_END;
Line := StripLN(ReadLine);
end;
if S <> ''
then MessageDlg('Debugger', 'Initialization output: ' + LINE_END + S, mtInformation, [mbOK], 0);
end;
function TGDBMIDebugger.ProcessResult(var ANewState: TDBGState;
var AResultValues: String; const ANoMICommand: Boolean): Boolean;
var
@ -1998,6 +2010,9 @@ end;
end.
{ =============================================================================
$Log$
Revision 1.33 2003/07/24 08:47:37 marc
+ Added SSHGDB debugger
Revision 1.32 2003/06/24 23:56:33 marc
* Fixed version detection of gdb

View File

@ -46,7 +46,7 @@ uses
IDEOptionDefs, LazarusIDEStrConsts, ProjectDefs, BaseDebugManager, MainBar,
SourceMarks,
DebuggerDlg, Watchesdlg, BreakPointsdlg, LocalsDlg, DBGOutputForm,
GDBMIDebugger, CallStackDlg;
GDBMIDebugger, CallStackDlg, SSHGDBMIDebugger;
type
@ -1272,7 +1272,9 @@ var
FreeAndNil(FDebugger);
ResetDialogs;
end;
const
DEBUGGERCLASS: array[TDebuggerType] of TDebuggerClass = (nil, TGDBMIDebugger, TSSHGDBMIDebugger);
var
LaunchingCmdLine, LaunchingApplication, LaunchingParams: String;
NewWorkingDir: String;
@ -1291,45 +1293,48 @@ begin
BeginUpdateDialogs;
try
try
case EnvironmentOptions.DebuggerType of
dtGnuDebugger: begin
// check if debugger is already created with the right type
if (FDebugger <> nil)
and ( not(FDebugger is TGDBMIDebugger)
or (FDebugger.ExternalDebugger <> EnvironmentOptions.DebuggerFilename)
)
then begin
// the current debugger is the wrong type -> free it
FreeDebugger;
end;
// create debugger object
if FDebugger = nil
then begin
SaveDebuggerItems;
FDebugger := TGDBMIDebugger.Create(EnvironmentOptions.DebuggerFilename);
if DEBUGGERCLASS[EnvironmentOptions.DebuggerType] = nil
then begin
if FDebugger <> nil
then FreeDebugger;
Exit;
end;
// check if debugger is already created with the right type
if (FDebugger <> nil)
and ( not (FDebugger is DEBUGGERCLASS[EnvironmentOptions.DebuggerType])
or (FDebugger.ExternalDebugger <> EnvironmentOptions.DebuggerFilename)
)
then begin
// the current debugger is the wrong type -> free it
FreeDebugger;
end;
TManagedBreakPoints(FBreakPoints).Master := FDebugger.BreakPoints;
TManagedSignals(FSignals).Master := FDebugger.Signals;
TManagedExceptions(FExceptions).Master := FDebugger.Exceptions;
// create debugger object
if FDebugger = nil
then begin
SaveDebuggerItems;
FDebugger := DEBUGGERCLASS[EnvironmentOptions.DebuggerType].Create(EnvironmentOptions.DebuggerFilename);
FWatches := FDebugger.Watches;
ResetDialogs;
end;
// restore debugger items
RestoreDebuggerItems;
end;
else
if FDebugger=nil then
FreeDebugger;
exit;
TManagedBreakPoints(FBreakPoints).Master := FDebugger.BreakPoints;
TManagedSignals(FSignals).Master := FDebugger.Signals;
TManagedExceptions(FExceptions).Master := FDebugger.Exceptions;
FWatches := FDebugger.Watches;
ResetDialogs;
// restore debugger items
RestoreDebuggerItems;
end;
finally
OldWatches.Free;
end;
FDebugger.OnState := @OnDebuggerChangeState;
FDebugger.OnCurrent := @OnDebuggerCurrentLine;
FDebugger.OnDbgOutput := @OnDebuggerOutput;
FDebugger.OnException := @OnDebuggerException;
Project1.RunParameterOptions.AssignEnvironmentTo(FDebugger.Environment);
if FDebugger.State = dsNone
then FDebugger.Init;
@ -1340,7 +1345,7 @@ begin
NewWorkingDir:=Project1.ProjectDirectory;
FDebugger.WorkingDir:=NewWorkingDir;
Project1.RunParameterOptions.AssignEnvironmentTo(FDebugger.Environment);
// Project1.RunParameterOptions.AssignEnvironmentTo(FDebugger.Environment);
if FDialogs[ddtOutput] <> nil
then TDbgOutputForm(FDialogs[ddtOutput]).Clear;
@ -1541,6 +1546,9 @@ end.
{ =============================================================================
$Log$
Revision 1.55 2003/07/24 08:47:36 marc
+ Added SSHGDB debugger
Revision 1.54 2003/06/16 00:07:28 marc
MWE:
+ Implemented DebuggerOptions-ExceptonAdd

View File

@ -8,13 +8,13 @@ object DebuggerOptionsForm: TDebuggerOptionsForm
POSITION = podefaultposonly
HORZSCROLLBAR.PAGE = 481
VERTSCROLLBAR.PAGE = 443
LEFT = 515
LEFT = 511
HEIGHT = 442
TOP = 247
TOP = 211
WIDTH = 480
object nbDebugOptions: TNOTEBOOK
ALIGN = altop
PAGEINDEX = 3
PAGEINDEX = 2
HEIGHT = 398
WIDTH = 480
object pgGeneral: TPAGE
@ -149,10 +149,10 @@ object DebuggerOptionsForm: TDebuggerOptionsForm
end
object seLimitLinecount: TSPINEDIT
ENABLED = False
CLIMB_RATE = 7.22976091447488E-34
MINVALUE = 7.22976091447488E-34
MAXVALUE = 7.22976091447488E-34
VALUE = 7.22976091447488E-34
CLIMB_RATE = 4.1015090942382813
MINVALUE = 4.1015090942382813
MAXVALUE = 4.1015090942382813
VALUE = 4.1015090942382813
LEFT = 28
HEIGHT = 20
TOP = 53

View File

@ -5,12 +5,12 @@ LazarusResources.Add('TDebuggerOptionsForm','FORMDATA',[
+'sdialog'#7'CAPTION'#6#16'Debugger Options'#12'CLIENTHEIGHT'#3#186#1#11'CLIE'
+'NTWIDTH'#3#224#1#8'ONCREATE'#7#25'DebuggerOptionsFormCREATE'#9'ONDESTROY'#7
+#26'DebuggerOptionsFormDESTROY'#8'POSITION'#7#16'podefaultposonly'#18'HORZSC'
+'ROLLBAR.PAGE'#3#225#1#18'VERTSCROLLBAR.PAGE'#3#187#1#4'LEFT'#3#3#2#6'HEIGHT'
+#3#186#1#3'TOP'#3#247#0#5'WIDTH'#3#224#1#0#9'TNOTEBOOK'#14'nbDebugOptions'#5
+'ALIGN'#7#5'altop'#9'PAGEINDEX'#2#3#6'HEIGHT'#3#142#1#5'WIDTH'#3#224#1#0#5'T'
+'PAGE'#9'pgGeneral'#7'CAPTION'#6#7'General'#11'CLIENTWIDTH'#3#220#1#12'CLIEN'
+'THEIGHT'#3'p'#1#4'LEFT'#2#2#6'HEIGHT'#3'p'#1#3'TOP'#2#28#5'WIDTH'#3#220#1#0
+#9'TGROUPBOX'#14'gbDebuggerType'#7'CAPTION'#6#22'Debugger type and path'#12
+'ROLLBAR.PAGE'#3#225#1#18'VERTSCROLLBAR.PAGE'#3#187#1#4'LEFT'#3#255#1#6'HEIG'
+'HT'#3#186#1#3'TOP'#3#211#0#5'WIDTH'#3#224#1#0#9'TNOTEBOOK'#14'nbDebugOption'
+'s'#5'ALIGN'#7#5'altop'#9'PAGEINDEX'#2#2#6'HEIGHT'#3#142#1#5'WIDTH'#3#224#1#0
+#5'TPAGE'#9'pgGeneral'#7'CAPTION'#6#7'General'#11'CLIENTWIDTH'#3#220#1#12'CL'
+'IENTHEIGHT'#3'p'#1#4'LEFT'#2#2#6'HEIGHT'#3'p'#1#3'TOP'#2#28#5'WIDTH'#3#220#1
+#0#9'TGROUPBOX'#14'gbDebuggerType'#7'CAPTION'#6#22'Debugger type and path'#12
+'CLIENTHEIGHT'#2'%'#11'CLIENTWIDTH'#3#212#1#11'PARENTCTL3D'#8#8'TABORDER'#2#0
+#4'LEFT'#2#2#6'HEIGHT'#2'6'#3'TOP'#2#8#5'WIDTH'#3#216#1#0#9'TCOMBOBOX'#15'cm'
+'bDebuggerType'#9'MAXLENGTH'#2#0#11'PARENTCTL3D'#8#8'TABORDER'#2#0#7'TABSTOP'
@ -39,9 +39,9 @@ LazarusResources.Add('TDebuggerOptionsForm','FORMDATA',[
+'CHECKBOX'#17'chkLimitLinecount'#11'ALLOWGRAYED'#9#8'AUTOSIZE'#9#7'CAPTION'#6
+#18'Limit linecount to'#10'DRAGCURSOR'#2#0#8'TABORDER'#2#1#7'TABSTOP'#9#4'LE'
+'FT'#2#4#6'HEIGHT'#2#20#3'TOP'#2#29#5'WIDTH'#2'w'#0#0#9'TSPINEDIT'#16'seLimi'
+'tLinecount'#7'ENABLED'#8#10'CLIMB_RATE'#5#0#0#0#0#0#1'@'#240#144'?'#8'MINVA'
+'LUE'#5#0#0#0#0#0#1'@'#240#144'?'#8'MAXVALUE'#5#0#0#0#0#0#1'@'#240#144'?'#5
+'VALUE'#5#0#0#0#0#0#1'@'#240#144'?'#4'LEFT'#2#28#6'HEIGHT'#2#20#3'TOP'#2'5'#5
+'tLinecount'#7'ENABLED'#8#10'CLIMB_RATE'#5#0#0#0#0#0#144'?'#131#1'@'#8'MINVA'
+'LUE'#5#0#0#0#0#0#144'?'#131#1'@'#8'MAXVALUE'#5#0#0#0#0#0#144'?'#131#1'@'#5
+'VALUE'#5#0#0#0#0#0#144'?'#131#1'@'#4'LEFT'#2#28#6'HEIGHT'#2#20#3'TOP'#2'5'#5
+'WIDTH'#2'>'#0#0#0#9'TGROUPBOX'#10'gbMessages'#7'CAPTION'#6#8'Messages'#12'C'
+'LIENTHEIGHT'#3#171#0#11'CLIENTWIDTH'#3#228#0#7'ENABLED'#8#11'PARENTCTL3D'#8
+#8'TABORDER'#2#1#4'LEFT'#3#242#0#6'HEIGHT'#3#188#0#3'TOP'#2#8#5'WIDTH'#3#232

View File

@ -69,11 +69,11 @@ type
{ Debugging }
type
TDebuggerType = (dtNone, dtGnuDebugger);
TDebuggerType = (dtNone, dtGnuDebugger, dtSSHGNUDebugger);
const
DebuggerName : array[TDebuggerType] of string = (
'(None)','GNU debugger (gdb)'
'(None)','GNU debugger (gdb)', 'GNU debugger through SSH (gdb)'
);
@ -951,6 +951,7 @@ begin
FDebuggerFileHistory.Add(DebuggerName[dtNone]);
FDebuggerFileHistory.Add('/usr/bin/gdb');
FDebuggerFileHistory.Add('/opt/fpc/gdb');
FDebuggerFileHistory.Add('/usr/bin/ssh user@hostname /usr/bin/gdb');
end;
LoadDebuggerType(FDebuggerType,'EnvironmentOptions/');
TestBuildDirectory:=XMLConfig.GetValue(

View File

@ -55,7 +55,7 @@ uses
{$IFDEF AddStaticPkgs}
{$I staticpackages.inc}
{$ENDIF}
MainBar;
MainBar, SSHGDBMIDebugger;
begin
Application.Initialize;
@ -99,6 +99,9 @@ end.
{
$Log$
Revision 1.47 2003/07/24 08:47:36 marc
+ Added SSHGDB debugger
Revision 1.46 2003/06/23 09:42:09 mattias
fixes for debugging lazarus

View File

@ -5625,13 +5625,13 @@ begin
end;
// Setup debugger
case EnvironmentOptions.DebuggerType of
dtGnuDebugger: begin
if (DebugBoss.DoInitDebugger <> mrOk)
then Exit;
// ToDo: set working directory
end;
else
if EnvironmentOptions.DebuggerType <> dtNone
then begin
if (DebugBoss.DoInitDebugger <> mrOk)
then Exit;
// ToDo: set working directory
end
else begin
// Temp solution, in future it will be run by dummy debugger
try
CheckIfFileIsExecutable(ProgramFilename);
@ -9354,6 +9354,9 @@ end.
{ =============================================================================
$Log$
Revision 1.625 2003/07/24 08:47:36 marc
+ Added SSHGDB debugger
Revision 1.624 2003/07/14 09:03:39 mattias
deactivated FCL TDataModule