mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 12:29:30 +02:00
implemented restoring breakpoints
git-svn-id: trunk@4174 -
This commit is contained in:
parent
b455d076da
commit
4782526435
@ -231,8 +231,12 @@ procedure TBreakPointsDlg.UpdateItem(const AItem: TListItem;
|
||||
const
|
||||
DEBUG_ACTION: array[TDBGBreakPointAction] of string =
|
||||
('Break', 'Enable Group', 'Disable Group');
|
||||
|
||||
// enabled valid
|
||||
DEBUG_STATE: array[Boolean, Boolean] of String = (('?', ''), ('!', '*'));
|
||||
DEBUG_STATE: array[Boolean, TValidState] of String = (
|
||||
{vsUnknown, vsValid, vsInvalid}
|
||||
{Enabled} ('', '?', ''),
|
||||
{Disabled}('*', '!', '*'));
|
||||
var
|
||||
Action: TDBGBreakPointAction;
|
||||
S: String;
|
||||
@ -272,6 +276,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.11 2003/05/23 14:12:51 mattias
|
||||
implemented restoring breakpoints
|
||||
|
||||
Revision 1.10 2003/05/22 23:08:19 marc
|
||||
MWE: = Moved and renamed debuggerforms so that they can be
|
||||
modified by the ide
|
||||
|
@ -39,7 +39,7 @@ unit CmdLineDebugger;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, Process, Debugger{, strmlsnr};
|
||||
Classes, Process, Debugger, Forms, DBGUtils;
|
||||
|
||||
type
|
||||
TCmdLineDebugger = class(TDebugger)
|
||||
@ -48,13 +48,13 @@ type
|
||||
FLineEnds: TStringList; // List of strings considered as lineends
|
||||
FOutputBuf: String;
|
||||
FReading: Boolean; // Set if we are in the ReadLine loop
|
||||
FFlushAfterRead: Boolean;// Set if we should flus if we finished reading
|
||||
FPeekOffset: Integer; // Counst the number of lines we have peeked
|
||||
FFlushAfterRead: Boolean;// Set if we should flush after finished reading
|
||||
FPeekOffset: Integer; // Count the number of lines we have peeked
|
||||
function GetDebugProcessRunning: Boolean;
|
||||
protected
|
||||
function CreateDebugProcess(const AOptions: String): Boolean;
|
||||
procedure Flush; // Flushes output buffer
|
||||
// procedure KillTargetProcess;
|
||||
// procedure KillTargetProcess;
|
||||
function ReadLine: String; overload;
|
||||
function ReadLine(const APeek: Boolean): String; overload;
|
||||
procedure SendCmdLn(const ACommand: String); overload;
|
||||
@ -72,6 +72,11 @@ procedure SendBreak(const AHandle: Integer);
|
||||
|
||||
implementation
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Needs to go to proper include
|
||||
// Platform dependent
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
uses
|
||||
{$IFDEF Linux}
|
||||
{$IFDEF Ver1_0}
|
||||
@ -80,13 +85,8 @@ uses
|
||||
Unix,
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
SysUtils, Forms, DBGUtils;
|
||||
SysUtils;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Needs to go to proper include
|
||||
// Platform dependent
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: SendBreak
|
||||
Params: AHandle THe handle of the proces tosend break to
|
||||
@ -336,6 +336,7 @@ end;
|
||||
|
||||
procedure TCmdLineDebugger.SendCmdLn(const ACommand: String); overload;
|
||||
begin
|
||||
writeln('TCmdLineDebugger.SendCmdLn "',ACommand,'"');
|
||||
if DebugProcessRunning
|
||||
then begin
|
||||
DoDbgOutput('<' + ACommand + '>');
|
||||
@ -362,6 +363,9 @@ end;
|
||||
end.
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.14 2003/05/23 14:12:51 mattias
|
||||
implemented restoring breakpoints
|
||||
|
||||
Revision 1.13 2002/08/28 11:41:52 lazarus
|
||||
MG: activated environment opts in debugger
|
||||
|
||||
|
@ -103,10 +103,14 @@ type
|
||||
|
||||
}
|
||||
|
||||
TValidState = (vsUnknown, vsValid, vsInvalid);
|
||||
|
||||
|
||||
const
|
||||
dcRunCommands = [dcRun,dcStepInto,dcStepOver,dcRunTo];
|
||||
|
||||
XMLBreakPointsNode = 'BreakPoints';
|
||||
XMLBreakPointGroupsNode = 'BreakPointGroups';
|
||||
XMLWatchesNode = 'Watches';
|
||||
|
||||
type
|
||||
@ -124,10 +128,11 @@ type
|
||||
procedure ReleaseReference;
|
||||
end;
|
||||
|
||||
TDebugger = class;
|
||||
TDBGBreakPointGroup = class;
|
||||
TDBGWatches = class;
|
||||
TDBGBreakPoints = class;
|
||||
TDBGBreakPointGroup = class;
|
||||
TDBGBreakPointGroups = class;
|
||||
TDBGWatches = class;
|
||||
TDebugger = class;
|
||||
|
||||
TOnSaveFilenameToConfig = procedure(var Filename: string) of object;
|
||||
TOnLoadFilenameFromConfig = procedure(var Filename: string) of object;
|
||||
@ -147,7 +152,7 @@ type
|
||||
FGroup: TDBGBreakPointGroup;
|
||||
FInitialEnabled: Boolean;
|
||||
FLoading: Boolean;
|
||||
FValid: Boolean;
|
||||
FValid: TValidState;
|
||||
FEnabled: Boolean;
|
||||
FHitCount: Integer;
|
||||
FExpression: String;
|
||||
@ -173,11 +178,16 @@ type
|
||||
procedure EnableGroups;
|
||||
procedure SetHitCount(const AValue: Integer);
|
||||
procedure SetLocation(const ASource: String; const ALine: Integer); virtual;
|
||||
procedure SetValid(const AValue: Boolean);
|
||||
procedure SetValid(const AValue: TValidState);
|
||||
property Debugger: TDebugger read GetDebugger;
|
||||
procedure RemoveFromGroupList(const AGroup: TDBGBreakPointGroup;
|
||||
const AGroupList: TList);
|
||||
procedure ClearGroupList(const AGroupList: TList);
|
||||
procedure CopyGroupList(SrcGroupList, DestGroupList: TList;
|
||||
DestGroups: TDBGBreakPointGroups);
|
||||
procedure CopyAllGroupLists(SrcBreakPoint: TDBGBreakPoint;
|
||||
DestGroups: TDBGBreakPointGroups);
|
||||
procedure ClearAllGroupLists;
|
||||
public
|
||||
constructor Create(ACollection: TCollection); override;
|
||||
destructor Destroy; override;
|
||||
@ -199,7 +209,7 @@ type
|
||||
property InitialEnabled: Boolean read FInitialEnabled write SetInitialEnabled;
|
||||
property Line: Integer read FLine;
|
||||
property Source: String read FSource;
|
||||
property Valid: Boolean read FValid;
|
||||
property Valid: TValidState read FValid;
|
||||
property Loading: Boolean read FLoading;
|
||||
end;
|
||||
TDBGBreakPointClass = class of TDBGBreakPoint;
|
||||
@ -266,6 +276,7 @@ type
|
||||
procedure SetInitialEnabled(const AValue: Boolean);
|
||||
procedure SetName(const AValue: String);
|
||||
protected
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
procedure AddReference(const ABreakPoint: TDBGBreakPoint);
|
||||
procedure RemoveReference(const ABreakPoint: TDBGBreakPoint);
|
||||
public
|
||||
@ -303,6 +314,8 @@ type
|
||||
function GetGroupByName(const GroupName: string): TDBGBreakPointGroup;
|
||||
function IndexOfGroupWithName(const GroupName: string): integer;
|
||||
procedure InitTargetStart; virtual;
|
||||
procedure Regroup(SrcGroups: TDBGBreakPointGroups;
|
||||
SrcBreakPoints, DestBreakPoints: TDBGBreakPoints);
|
||||
public
|
||||
property Items[const AnIndex: Integer]: TDBGBreakPointGroup
|
||||
read GetItem write SetItem; default;
|
||||
@ -316,7 +329,7 @@ type
|
||||
FEnabled: Boolean;
|
||||
FExpression: String;
|
||||
FInitialEnabled: Boolean;
|
||||
FValid: Boolean;
|
||||
FValid: TValidState;
|
||||
function GetDebugger: TDebugger;
|
||||
procedure SetEnabled(const AValue: Boolean);
|
||||
procedure SetExpression(const AValue: String);
|
||||
@ -327,8 +340,8 @@ type
|
||||
procedure DoExpressionChange; virtual;
|
||||
procedure DoStateChange; virtual;
|
||||
function GetValue: String; virtual;
|
||||
function GetValid: Boolean; virtual;
|
||||
procedure SetValid(const AValue: Boolean);
|
||||
function GetValid: TValidState; virtual;
|
||||
procedure SetValid(const AValue: TValidState);
|
||||
property Debugger: TDebugger read GetDebugger;
|
||||
public
|
||||
constructor Create(ACollection: TCollection); override;
|
||||
@ -340,7 +353,7 @@ type
|
||||
property Enabled: Boolean read FEnabled write SetEnabled;
|
||||
property InitialEnabled: Boolean read FInitialEnabled write SetInitialEnabled;
|
||||
property Expression: String read FExpression write SetExpression;
|
||||
property Valid: Boolean read GetValid;
|
||||
property Valid: TValidState read GetValid;
|
||||
property Value: String read GetValue;
|
||||
end;
|
||||
|
||||
@ -470,6 +483,8 @@ type
|
||||
|
||||
{ TDebugger }
|
||||
|
||||
TDebuggerStateChangedEvent = procedure(ADebugger: TDebugger;
|
||||
OldState: TDBGState) of object;
|
||||
TDBGOutputEvent = procedure(Sender: TObject; const AText: String) of object;
|
||||
TDBGCurrentLineEvent = procedure(Sender: TObject;
|
||||
const ALocation: TDBGLocationRec) of object;
|
||||
@ -493,7 +508,7 @@ type
|
||||
FOnException: TDBGExceptionEvent;
|
||||
FOnOutput: TDBGOutputEvent;
|
||||
FOnDbgOutput: TDBGOutputEvent;
|
||||
FOnState: TNotifyEvent;
|
||||
FOnState: TDebuggerStateChangedEvent;
|
||||
function GetState: TDBGState;
|
||||
function ReqCmd(const ACommand: TDBGCommand;
|
||||
const AParams: array of const): Boolean;
|
||||
@ -508,7 +523,7 @@ type
|
||||
procedure DoDbgOutput(const AText: String);
|
||||
procedure DoException(const AExceptionID: Integer; const AExceptionText: String);
|
||||
procedure DoOutput(const AText: String);
|
||||
procedure DoState;
|
||||
procedure DoState(const OldState: TDBGState);
|
||||
function ChangeFileName: Boolean; virtual;
|
||||
function GetCommands: TDBGCommands;
|
||||
function GetSupportedCommands: TDBGCommands; virtual;
|
||||
@ -559,7 +574,7 @@ type
|
||||
property OnDbgOutput: TDBGOutputEvent read FOnDbgOutput write FOnDbgOutput; // Passes all debuggeroutput
|
||||
property OnException: TDBGExceptionEvent read FOnException write FOnException; // Fires when the debugger received an exeption
|
||||
property OnOutput: TDBGOutputEvent read FOnOutput write FOnOutput; // Passes all output of the debugged target
|
||||
property OnState: TNotifyEvent read FOnState write FOnState; // Fires when the current state of the debugger changes
|
||||
property OnState: TDebuggerStateChangedEvent read FOnState write FOnState; // Fires when the current state of the debugger changes
|
||||
property State: TDBGState read FState; // The current state of the debugger
|
||||
property SupportedCommands: TDBGCommands read GetSupportedCommands; // All available commands of the debugger
|
||||
property Watches: TDBGWatches read FWatches; // list of all watches localvars etc
|
||||
@ -737,9 +752,9 @@ begin
|
||||
if Assigned(FOnOutput) then FOnOutput(Self, AText);
|
||||
end;
|
||||
|
||||
procedure TDebugger.DoState;
|
||||
procedure TDebugger.DoState(const OldState: TDBGState);
|
||||
begin
|
||||
if Assigned(FOnState) then FOnState(Self);
|
||||
if Assigned(FOnState) then FOnState(Self,OldState);
|
||||
end;
|
||||
|
||||
function TDebugger.Evaluate(const AExpression: String;
|
||||
@ -786,32 +801,25 @@ end;
|
||||
|
||||
procedure TDebugger.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string; const OnLoadFilename: TOnLoadFilenameFromConfig);
|
||||
var
|
||||
AFilename: String;
|
||||
begin
|
||||
Arguments:=XMLConfig.GetValue(Path+'Arguments/Value','');
|
||||
BreakPointGroups.LoadFromXMLConfig(XMLConfig,Path+'BreakPointGroups/');
|
||||
BreakPointGroups.LoadFromXMLConfig(XMLConfig,Path+XMLBreakPointGroupsNode+'/');
|
||||
BreakPoints.LoadFromXMLConfig(XMLConfig,Path+XMLBreakPointsNode+'/',
|
||||
OnLoadFilename,@BreakPointGroups.GetGroupByName);
|
||||
LoadStringList(XMLConfig,Environment, Path+'Environment/');
|
||||
AFilename:=XMLConfig.GetValue(Path+'ExternalDebugger/Value','');
|
||||
if Assigned(OnLoadFilename) then OnLoadFilename(AFilename);
|
||||
Watches.LoadFromXMLConfig(XMLConfig,Path+XMLWatchesNode+'/');
|
||||
// the environment is controlled by the run parameters, so don't load it
|
||||
Environment.Clear;
|
||||
end;
|
||||
|
||||
procedure TDebugger.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
const OnSaveFilename: TOnSaveFilenameToConfig);
|
||||
var
|
||||
AFilename: String;
|
||||
begin
|
||||
XMLConfig.SetDeleteValue(Path+'Arguments/Value',Arguments,'');
|
||||
BreakPointGroups.SaveToXMLConfig(XMLConfig,Path+'BreakPointGroups/');
|
||||
BreakPointGroups.SaveToXMLConfig(XMLConfig,Path+XMLBreakPointGroupsNode+'/');
|
||||
BreakPoints.SaveToXMLConfig(XMLConfig,Path+XMLBreakPointsNode+'/',
|
||||
OnSaveFilename);
|
||||
SaveStringList(XMLConfig,Environment,Path+'Environment/');
|
||||
AFilename:=ExternalDebugger;
|
||||
if Assigned(OnSaveFilename) then OnSaveFilename(AFilename);
|
||||
Watches.SaveToXMLConfig(XMLConfig,Path+XMLWatchesNode+'/');
|
||||
// the environment is controlled by the run parameters, so don't save it
|
||||
end;
|
||||
|
||||
procedure TDebugger.Pause;
|
||||
@ -878,15 +886,18 @@ begin
|
||||
end;
|
||||
|
||||
procedure TDebugger.SetState(const AValue: TDBGState);
|
||||
var
|
||||
OldState: TDBGState;
|
||||
begin
|
||||
if AValue <> FState
|
||||
then begin
|
||||
OldState := FState;
|
||||
FState := AValue;
|
||||
FBreakpoints.DoStateChange;
|
||||
FLocals.DoStateChange;
|
||||
FCallStack.DoStateChange;
|
||||
FWatches.DoStateChange;
|
||||
DoState;
|
||||
DoState(OldState);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -933,13 +944,18 @@ begin
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoint.AssignTo(Dest: TPersistent);
|
||||
var
|
||||
DestBreakPoint: TDBGBreakPoint;
|
||||
begin
|
||||
if Dest is TDBGBreakPoint
|
||||
then begin
|
||||
TDBGBreakPoint(Dest).SetLocation(FSource, FLine);
|
||||
TDBGBreakPoint(Dest).SetExpression(FExpression);
|
||||
TDBGBreakPoint(Dest).SetActions(FActions);
|
||||
TDBGBreakPoint(Dest).SetEnabled(FEnabled);
|
||||
DestBreakPoint:=TDBGBreakPoint(Dest);
|
||||
writeln('TDBGBreakPoint.AssignTo Src=',ClassName,' Dest=',Dest.ClassName,' File="',FSource,'" Line=',FLine);
|
||||
DestBreakPoint.SetLocation(FSource, FLine);
|
||||
DestBreakPoint.SetExpression(FExpression);
|
||||
DestBreakPoint.SetActions(FActions);
|
||||
DestBreakPoint.SetInitialEnabled(FInitialEnabled);
|
||||
DestBreakPoint.SetEnabled(FEnabled);
|
||||
end
|
||||
else inherited;
|
||||
end;
|
||||
@ -949,7 +965,7 @@ begin
|
||||
inherited Create(ACollection);
|
||||
FSource := '';
|
||||
FLine := -1;
|
||||
FValid := False;
|
||||
FValid := vsUnknown;
|
||||
FEnabled := False;
|
||||
FInitialEnabled:=false;
|
||||
FHitCount := 0;
|
||||
@ -969,8 +985,7 @@ begin
|
||||
if FGroup <> nil
|
||||
then FGroup.Remove(Self);
|
||||
|
||||
ClearGroupList(FDisableGroupList);
|
||||
ClearGroupList(FEnableGroupList);
|
||||
ClearAllGroupLists;
|
||||
|
||||
inherited;
|
||||
FreeAndNil(FDisableGroupList);
|
||||
@ -1078,7 +1093,8 @@ begin
|
||||
Filename:=XMLConfig.GetValue(Path+'Source/Value','');
|
||||
if Assigned(OnLoadFilename) then OnLoadFilename(Filename);
|
||||
FSource:=Filename;
|
||||
FInitialEnabled:=XMLConfig.GetValue(Path+'InitialEnabled/Value',true);
|
||||
InitialEnabled:=XMLConfig.GetValue(Path+'InitialEnabled/Value',true);
|
||||
Enabled:=FInitialEnabled;
|
||||
FLine:=XMLConfig.GetValue(Path+'Line/Value',-1);
|
||||
NewActions:=[];
|
||||
for CurAction:=Low(TDBGBreakPointAction) to High(TDBGBreakPointAction) do
|
||||
@ -1196,18 +1212,16 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoint.SetLocation(const ASource: String; const ALine: Integer);
|
||||
procedure TDBGBreakPoint.SetLocation(const ASource: String;
|
||||
const ALine: Integer);
|
||||
begin
|
||||
if (FSource <> ASource)
|
||||
or (FLine <> ALine)
|
||||
then begin
|
||||
FSource := ASource;
|
||||
FLine := ALine;
|
||||
Changed(False);
|
||||
end;
|
||||
if (FSource = ASource) and (FLine = ALine) then exit;
|
||||
FSource := ASource;
|
||||
FLine := ALine;
|
||||
Changed(False);
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoint.SetValid(const AValue: Boolean);
|
||||
procedure TDBGBreakPoint.SetValid(const AValue: TValidState);
|
||||
begin
|
||||
if FValid <> AValue
|
||||
then begin
|
||||
@ -1236,6 +1250,34 @@ begin
|
||||
AGroupList.Clear;
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoint.CopyGroupList(SrcGroupList, DestGroupList: TList;
|
||||
DestGroups: TDBGBreakPointGroups);
|
||||
var
|
||||
i: Integer;
|
||||
CurGroup: TDBGBreakPointGroup;
|
||||
NewGroup: TDBGBreakPointGroup;
|
||||
begin
|
||||
ClearGroupList(DestGroupList);
|
||||
for i:=0 to SrcGroupList.Count-1 do begin
|
||||
CurGroup:=TDBGBreakPointGroup(SrcGroupList[i]);
|
||||
NewGroup:=DestGroups.GetGroupByName(CurGroup.Name);
|
||||
DestGroupList.Add(NewGroup);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoint.CopyAllGroupLists(SrcBreakPoint: TDBGBreakPoint;
|
||||
DestGroups: TDBGBreakPointGroups);
|
||||
begin
|
||||
CopyGroupList(SrcBreakPoint.FEnableGroupList,FEnableGroupList,DestGroups);
|
||||
CopyGroupList(SrcBreakPoint.FDisableGroupList,FDisableGroupList,DestGroups);
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoint.ClearAllGroupLists;
|
||||
begin
|
||||
ClearGroupList(FDisableGroupList);
|
||||
ClearGroupList(FEnableGroupList);
|
||||
end;
|
||||
|
||||
{ =========================================================================== }
|
||||
{ TDBGBreakPoints }
|
||||
{ =========================================================================== }
|
||||
@ -1244,6 +1286,7 @@ function TDBGBreakPoints.Add(const ASource: String;
|
||||
const ALine: Integer): TDBGBreakPoint;
|
||||
begin
|
||||
Result := TDBGBreakPoint(inherited Add);
|
||||
writeln('TDBGBreakPoints.Add ',Result.ClassName,' ',ASource,' ',ALine);
|
||||
Result.SetLocation(ASource, ALine);
|
||||
Add(Result);
|
||||
end;
|
||||
@ -1305,7 +1348,7 @@ begin
|
||||
begin
|
||||
Result := GetItem(n);
|
||||
if (Result.Line = ALine)
|
||||
and (Result.Source = ASource)
|
||||
and (CompareFilenames(Result.Source,ASource)=0)
|
||||
then Exit;
|
||||
end;
|
||||
Result := nil;
|
||||
@ -1346,10 +1389,13 @@ var
|
||||
begin
|
||||
Clear;
|
||||
NewCount:=XMLConfig.GetValue(Path+'Count',0);
|
||||
writeln('TDBGBreakPoints.LoadFromXMLConfig NewCount=',NewCount);
|
||||
for i:=0 to NewCount-1 do begin
|
||||
NewBreakPoint:=TDBGBreakPoint(inherited Add);
|
||||
NewBreakPoint.LoadFromXMLConfig(XMLConfig,
|
||||
Path+'Item'+IntToStr(i+1)+'/',OnLoadFilename,OnGetGroup);
|
||||
writeln('TDBGBreakPoints.LoadFromXMLConfig i=',i,' ',
|
||||
NewBreakPoint.InitialEnabled,' ',NewBreakPoint.Source,' ',NewBreakPoint.Line);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1469,6 +1515,7 @@ begin
|
||||
// the breakpoints of this group are not loaded here.
|
||||
// They are loaded by the TDBGBreakPoints object.
|
||||
InitialEnabled:=XMLConfig.GetValue(Path+'InitialEnabled/Value',true);
|
||||
FEnabled:=InitialEnabled;
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPointGroup.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
@ -1508,6 +1555,19 @@ begin
|
||||
FName := AValue;
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPointGroup.AssignTo(Dest: TPersistent);
|
||||
var
|
||||
DestGroup: TDBGBreakPointGroup;
|
||||
begin
|
||||
if Dest is TDBGBreakPointGroup then begin
|
||||
DestGroup:=TDBGBreakPointGroup(Dest);
|
||||
DestGroup.Name:=Name;
|
||||
DestGroup.InitialEnabled:=InitialEnabled;
|
||||
DestGroup.Enabled:=Enabled;
|
||||
end else
|
||||
inherited AssignTo(Dest);
|
||||
end;
|
||||
|
||||
{ =========================================================================== }
|
||||
{ TDBGBreakPointGroups }
|
||||
{ =========================================================================== }
|
||||
@ -1526,10 +1586,12 @@ var
|
||||
begin
|
||||
Clear;
|
||||
NewCount:=XMLConfig.GetValue(Path+'Count',0);
|
||||
writeln('TDBGBreakPointGroups.LoadFromXMLConfig Count=',NewCount);
|
||||
for i:=0 to NewCount-1 do begin
|
||||
NewGroup:=TDBGBreakPointGroup(inherited Add);
|
||||
NewGroup.LoadFromXMLConfig(XMLConfig,
|
||||
Path+'Item'+IntToStr(i+1)+'/');
|
||||
writeln('TDBGBreakPointGroups.LoadFromXMLConfig i=',i,' ',NewGroup.Name);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1577,6 +1639,34 @@ begin
|
||||
Items[i].Enabled:=Items[i].InitialEnabled;
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPointGroups.Regroup(SrcGroups: TDBGBreakPointGroups;
|
||||
SrcBreakPoints, DestBreakPoints: TDBGBreakPoints);
|
||||
var
|
||||
BreakPointCnt: Integer;
|
||||
i: Integer;
|
||||
SrcBreakPoint: TDBGBreakPoint;
|
||||
DestBreakPoint: TDBGBreakPoint;
|
||||
begin
|
||||
// copy the groups
|
||||
Assign(SrcGroups);
|
||||
// copy the groups of the SrcBreakPoints to the DestBreakPoints by using
|
||||
// the new groups
|
||||
BreakPointCnt:=SrcBreakPoints.Count;
|
||||
if BreakPointCnt<>DestBreakPoints.Count then
|
||||
RaiseException('TDBGBreakPointGroups.Regroup Src<>Dest breakpoints');
|
||||
for i:=0 to BreakPointCnt-1 do begin
|
||||
SrcBreakPoint:=SrcBreakPoints[i];
|
||||
DestBreakPoint:=DestBreakPoints[i];
|
||||
// copy group of breakpoint
|
||||
if SrcBreakPoint.Group<>nil then
|
||||
DestBreakPoint.Group:=GetGroupByName(SrcBreakPoint.Group.Name)
|
||||
else
|
||||
DestBreakPoint.Group:=nil;
|
||||
// copy group lists of breakpoint
|
||||
DestBreakPoint.CopyAllGroupLists(SrcBreakPoint,Self);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDBGBreakPointGroups.GetItem(const AnIndex: Integer
|
||||
): TDBGBreakPointGroup;
|
||||
begin
|
||||
@ -1614,6 +1704,7 @@ procedure TDBGWatch.LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string
|
||||
begin
|
||||
Expression:=XMLConfig.GetValue(Path+'Expression/Value','');
|
||||
InitialEnabled:=XMLConfig.GetValue(Path+'InitialEnabled/Value',true);
|
||||
FEnabled:=FInitialEnabled;
|
||||
end;
|
||||
|
||||
procedure TDBGWatch.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
|
||||
@ -1641,18 +1732,22 @@ begin
|
||||
Result := TDBGWatches(Collection).FDebugger;
|
||||
end;
|
||||
|
||||
function TDBGWatch.GetValid: Boolean;
|
||||
function TDBGWatch.GetValid: TValidState;
|
||||
begin
|
||||
Result := False;
|
||||
Result := vsUnknown;
|
||||
end;
|
||||
|
||||
function TDBGWatch.GetValue: String;
|
||||
begin
|
||||
if not Enabled
|
||||
then Result := '<disabled>'
|
||||
else if Valid
|
||||
then Result := '<unknown>'
|
||||
else Result := '<invalid>';
|
||||
else
|
||||
case Valid of
|
||||
vsValid: Result := '<valid>';
|
||||
vsInvalid: Result := '<invalid>';
|
||||
else
|
||||
{vsUnknown:}Result := '<unknown>';
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDBGWatch.SetEnabled(const AValue: Boolean);
|
||||
@ -1679,7 +1774,7 @@ begin
|
||||
FInitialEnabled:=AValue;
|
||||
end;
|
||||
|
||||
procedure TDBGWatch.SetValid(const AValue: Boolean);
|
||||
procedure TDBGWatch.SetValid(const AValue: TValidState);
|
||||
begin
|
||||
if FValid <> AValue
|
||||
then begin
|
||||
@ -1794,9 +1889,11 @@ var
|
||||
begin
|
||||
Clear;
|
||||
NewCount:=XMLConfig.GetValue(Path+'Count',0);
|
||||
writeln('TDBGWatches.LoadFromXMLConfig Count=',NewCount);
|
||||
for i:=0 to NewCount-1 do begin
|
||||
NewWatch:=TDBGWatch(inherited Add);
|
||||
NewWatch.LoadFromXMLConfig(XMLConfig,Path+'Item'+IntToStr(i+1)+'/');
|
||||
writeln('TDBGWatches.LoadFromXMLConfig i=',i,' ',NewWatch.Expression);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2033,6 +2130,9 @@ end;
|
||||
end.
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.23 2003/05/23 14:12:51 mattias
|
||||
implemented restoring breakpoints
|
||||
|
||||
Revision 1.22 2003/05/22 23:08:19 marc
|
||||
MWE: = Moved and renamed debuggerforms so that they can be
|
||||
modified by the ide
|
||||
|
@ -366,7 +366,7 @@ var
|
||||
FKind := skRecord;
|
||||
FFields := TGDBFields.Create;
|
||||
|
||||
//concatinate all lines and skip last end
|
||||
//concatenate all lines and skip last end
|
||||
S := '';
|
||||
for n := 0 to Lines.Count - 2 do
|
||||
S := S + Lines[n];
|
||||
@ -379,6 +379,7 @@ var
|
||||
Field.FGDBType := TGDBType.Create;
|
||||
Field.FGDBType.FKind := skSimple; // for now
|
||||
Field.FGDBType.FTypeName := GetPart([' : '], [';'], S);
|
||||
FFields.FList.Add(Field);
|
||||
Delete(S, 1, 1);
|
||||
end;
|
||||
end;
|
||||
@ -391,7 +392,7 @@ var
|
||||
FKind := skEnum;
|
||||
|
||||
S := GetPart(['('], [], Line);
|
||||
//concatinate all lines
|
||||
//concatenate all lines
|
||||
for n := 0 to Lines.Count - 1 do
|
||||
S := S + Lines[n];
|
||||
|
||||
@ -428,7 +429,7 @@ var
|
||||
FKind := skProcedure;
|
||||
|
||||
S := GetPart(['('], [], Line);
|
||||
//concatinate all lines
|
||||
//concatenate all lines
|
||||
for n := 0 to Lines.Count - 1 do
|
||||
S := S + Lines[n];
|
||||
|
||||
@ -444,7 +445,7 @@ var
|
||||
FKind := skFunction;
|
||||
|
||||
S := GetPart(['('], [], Line);
|
||||
//concatinate all lines
|
||||
//concatenate all lines
|
||||
for n := 0 to Lines.Count - 1 do
|
||||
S := S + Lines[n];
|
||||
|
||||
@ -597,6 +598,9 @@ end;
|
||||
end.
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.2 2003/05/23 14:12:51 mattias
|
||||
implemented restoring breakpoints
|
||||
|
||||
Revision 1.1 2003/05/22 23:08:19 marc
|
||||
MWE: = Moved and renamed debuggerforms so that they can be
|
||||
modified by the ide
|
||||
|
@ -40,7 +40,7 @@ uses
|
||||
{$IFDEF IDE_MEM_CHECK}
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Forms, Laz_XMLCfg, Debugger;
|
||||
Classes, SysUtils, Forms, Laz_XMLCfg, Project, Debugger;
|
||||
|
||||
type
|
||||
TBaseDebugManager = class(TComponent)
|
||||
@ -52,7 +52,9 @@ type
|
||||
procedure ConnectSourceNotebookEvents; virtual; abstract;
|
||||
procedure SetupMainBarShortCuts; virtual; abstract;
|
||||
|
||||
procedure LoadProjectSpecificInfo(XMLConfig: TXMLConfig); virtual; abstract;
|
||||
procedure SaveProjectSpecificInfo(XMLConfig: TXMLConfig); virtual; abstract;
|
||||
procedure DoRestoreDebuggerMarks(AnUnitInfo: TUnitInfo); virtual; abstract;
|
||||
|
||||
function DoInitDebugger: TModalResult; virtual; abstract;
|
||||
function DoPauseProject: TModalResult; virtual; abstract;
|
||||
|
@ -40,6 +40,7 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Forms, Controls, Dialogs, Menus, FileCtrl, Laz_XMLCfg,
|
||||
SynEdit,
|
||||
CompilerOptions, EditorOptions, EnvironmentOpts, KeyMapping, UnitEditor,
|
||||
Project, IDEProcs, Debugger, RunParamsOpts, ExtToolDialog, IDEOptionDefs,
|
||||
LazarusIDEStrConsts, ProjectDefs, BaseDebugManager, MainBar, DebuggerDlg,
|
||||
@ -59,6 +60,7 @@ type
|
||||
TDebugManager = class(TBaseDebugManager)
|
||||
// Menu events
|
||||
procedure mnuViewDebugDialogClick(Sender: TObject);
|
||||
procedure mnuResetDebuggerClicked(Sender : TObject);
|
||||
|
||||
// SrcNotebook events
|
||||
procedure OnSrcNotebookAddWatchesAtCursor(Sender: TObject);
|
||||
@ -66,20 +68,21 @@ type
|
||||
procedure OnSrcNotebookDeleteBreakPoint(Sender: TObject; Line: Integer);
|
||||
|
||||
// Debugger events
|
||||
procedure OnDebuggerChangeState(Sender: TObject);
|
||||
procedure OnDebuggerChangeState(ADebugger: TDebugger; OldState: TDBGState);
|
||||
procedure OnDebuggerCurrentLine(Sender: TObject;
|
||||
const ALocation: TDBGLocationRec);
|
||||
procedure OnDebuggerOutput(Sender: TObject; const AText: String);
|
||||
procedure OnDebuggerException(Sender: TObject; const AExceptionID: Integer;
|
||||
const AExceptionText: String);
|
||||
private
|
||||
FBreakPoints: TDBGBreakPoints; // Points to debugger breakpoints if available
|
||||
// Else to own object
|
||||
FWatches: TDBGWatches; // Points to debugger watches if available
|
||||
// Else to own object
|
||||
FDialogs: array[TDebugDialogType] of TDebuggerDlg;
|
||||
|
||||
FDebugger: TDebugger;
|
||||
// When no debugger is created the IDE stores all debugger settings in its
|
||||
// own variables. When the debugger object is created these items point
|
||||
// to the corresponding items in the FDebugger object.
|
||||
FBreakPoints: TDBGBreakPoints;
|
||||
FBreakPointGroups: TDBGBreakPointGroups;
|
||||
FWatches: TDBGWatches;
|
||||
FDialogs: array[TDebugDialogType] of TDebuggerDlg;
|
||||
|
||||
procedure DebugDialogDestroy(Sender: TObject);
|
||||
procedure ViewDebugDialog(const ADialogType: TDebugDialogType);
|
||||
@ -94,7 +97,9 @@ type
|
||||
procedure ConnectSourceNotebookEvents; override;
|
||||
procedure SetupMainBarShortCuts; override;
|
||||
|
||||
procedure LoadProjectSpecificInfo(XMLConfig: TXMLConfig); override;
|
||||
procedure SaveProjectSpecificInfo(XMLConfig: TXMLConfig); override;
|
||||
procedure DoRestoreDebuggerMarks(AnUnitInfo: TUnitInfo); override;
|
||||
|
||||
function DoInitDebugger: TModalResult; override;
|
||||
function DoPauseProject: TModalResult; override;
|
||||
@ -128,6 +133,14 @@ begin
|
||||
ViewDebugDialog(TDebugDialogType(TMenuItem(Sender).Tag));
|
||||
end;
|
||||
|
||||
procedure TDebugManager.mnuResetDebuggerClicked(Sender: TObject);
|
||||
begin
|
||||
if State = dsNone then Exit;
|
||||
|
||||
EndDebugging;
|
||||
DoInitDebugger;
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ScrNoteBook events
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -159,20 +172,24 @@ var
|
||||
begin
|
||||
if SourceNotebook.Notebook = nil then Exit;
|
||||
|
||||
NewBreak := FBreakPoints.Add(
|
||||
ExtractFilename(TSourceNotebook(Sender).GetActiveSe.FileName),
|
||||
NewBreak := FBreakPoints.Add(TSourceNotebook(Sender).GetActiveSE.FileName,
|
||||
Line);
|
||||
NewBreak.Enabled := True;
|
||||
NewBreak.InitialEnabled := True;
|
||||
NewBreak.Enabled := True;
|
||||
Project1.Modified:=true;
|
||||
end;
|
||||
|
||||
procedure TDebugManager.OnSrcNotebookDeleteBreakPoint(Sender: TObject; Line: Integer);
|
||||
procedure TDebugManager.OnSrcNotebookDeleteBreakPoint(Sender: TObject;
|
||||
Line: Integer);
|
||||
var
|
||||
OldBreakPoint: TDBGBreakPoint;
|
||||
begin
|
||||
if SourceNotebook.Notebook = nil then Exit;
|
||||
|
||||
FBreakPoints.Find(ExtractFilename(
|
||||
TSourceNotebook(Sender).GetActiveSe.FileName), Line).Free;
|
||||
OldBreakPoint:=FBreakPoints.Find(TSourceNotebook(Sender).GetActiveSE.FileName,
|
||||
Line);
|
||||
if OldBreakPoint=nil then exit;
|
||||
OldBreakPoint.Free;
|
||||
Project1.Modified:=true;
|
||||
end;
|
||||
|
||||
@ -180,10 +197,12 @@ end;
|
||||
// Debugger events
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
procedure TDebugManager.OnDebuggerException(Sender: TObject; const AExceptionID: Integer; const AExceptionText: String);
|
||||
procedure TDebugManager.OnDebuggerException(Sender: TObject;
|
||||
const AExceptionID: Integer; const AExceptionText: String);
|
||||
begin
|
||||
MessageDlg('Error',
|
||||
Format('Project %s raised exception class %d with message ''%s''.', [Project1.Title, AExceptionID, AExceptionText]),
|
||||
Format('Project %s raised exception class %d with message ''%s''.',
|
||||
[Project1.Title, AExceptionID, AExceptionText]),
|
||||
mtError,[mbOk],0);
|
||||
end;
|
||||
|
||||
@ -193,7 +212,8 @@ begin
|
||||
then TDbgOutputForm(FDialogs[ddtOutput]).AddText(AText);
|
||||
end;
|
||||
|
||||
procedure TDebugManager.OnDebuggerChangeState(Sender: TObject);
|
||||
procedure TDebugManager.OnDebuggerChangeState(ADebugger: TDebugger;
|
||||
OldState: TDBGState);
|
||||
const
|
||||
// dsNone, dsIdle, dsStop, dsPause, dsRun, dsError
|
||||
TOOLSTATEMAP: array[TDBGState] of TIDEToolStatus = (
|
||||
@ -205,7 +225,7 @@ const
|
||||
);
|
||||
begin
|
||||
// Is the next line needed ???
|
||||
if (Sender<>FDebugger) or (Sender=nil) then exit;
|
||||
if (ADebugger<>FDebugger) or (ADebugger=nil) then exit;
|
||||
|
||||
WriteLN('[TDebugManager.OnDebuggerChangeState] state: ', STATENAME[FDebugger.State]);
|
||||
|
||||
@ -215,7 +235,7 @@ begin
|
||||
// -------------------
|
||||
|
||||
with MainIDE do begin
|
||||
// For run end step bypass idle, so we can set the filename later
|
||||
// For 'run' and 'step' bypass 'idle', so we can set the filename later
|
||||
RunSpeedButton.Enabled := (dcRun in FDebugger.Commands) or (FDebugger.State = dsIdle);
|
||||
itmProjectRun.Enabled := RunSpeedButton.Enabled;
|
||||
PauseSpeedButton.Enabled := dcPause in FDebugger.Commands;
|
||||
@ -234,19 +254,25 @@ begin
|
||||
ToolStatus := TOOLSTATEMAP[FDebugger.State];
|
||||
end;
|
||||
|
||||
|
||||
case FDebugger.State of
|
||||
dsError: begin
|
||||
|
||||
dsError:
|
||||
begin
|
||||
WriteLN('Ooops, the debugger entered the error state');
|
||||
MessageDlg(lisDebuggerError,
|
||||
Format(lisDebuggerErrorOoopsTheDebuggerEnteredTheErrorState, [#13#13,
|
||||
#13, #13#13]),
|
||||
mtError, [mbOK],0);
|
||||
end;
|
||||
dsStop: begin
|
||||
|
||||
dsStop:
|
||||
if (OldState<>dsIdle) then begin
|
||||
MessageDlg(lisExecutionStopped,
|
||||
Format(lisExecutionStoppedOn, [#13#13]),
|
||||
mtInformation, [mbOK],0);
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -353,18 +379,19 @@ const
|
||||
DEBUGDIALOGCLASS: array[TDebugDialogType] of TDebuggerDlgClass = (
|
||||
TDbgOutputForm, TBreakPointsDlg, TWatchesDlg, TLocalsDlg, TCallStackDlg
|
||||
);
|
||||
var
|
||||
CurDialog: TDebuggerDlg;
|
||||
begin
|
||||
if FDialogs[ADialogType] = nil
|
||||
then begin
|
||||
FDialogs[ADialogType] := DEBUGDIALOGCLASS[ADialogType].Create(Self);
|
||||
FDialogs[ADialogType].Name:=
|
||||
NonModalIDEWindowNames[DebugDlgIDEWindow[ADialogType]];
|
||||
FDialogs[ADialogType].Tag := Integer(ADialogType);
|
||||
FDialogs[ADialogType].OnDestroy := @DebugDialogDestroy;
|
||||
CurDialog:=FDialogs[ADialogType];
|
||||
CurDialog.Name:=NonModalIDEWindowNames[DebugDlgIDEWindow[ADialogType]];
|
||||
CurDialog.Tag := Integer(ADialogType);
|
||||
CurDialog.OnDestroy := @DebugDialogDestroy;
|
||||
DoInitDebugger;
|
||||
FDialogs[ADialogType].Debugger := FDebugger;
|
||||
EnvironmentOptions.IDEWindowLayoutList.Apply(
|
||||
FDialogs[ADialogType],FDialogs[ADialogType].Name);
|
||||
CurDialog.Debugger := FDebugger;
|
||||
EnvironmentOptions.IDEWindowLayoutList.Apply(CurDialog,CurDialog.Name);
|
||||
end;
|
||||
FDialogs[ADialogType].Show;
|
||||
FDialogs[ADialogType].BringToFront;
|
||||
@ -388,6 +415,7 @@ begin
|
||||
|
||||
FDebugger := nil;
|
||||
FBreakPoints := TDBGBreakPoints.Create(nil, TDBGBreakPoint);
|
||||
FBreakPointGroups := TDBGBreakPointGroups.Create;
|
||||
FWatches := TDBGWatches.Create(nil, TDBGWatch);
|
||||
inherited Create(TheOwner);
|
||||
end;
|
||||
@ -403,6 +431,8 @@ begin
|
||||
then begin
|
||||
if FDebugger.BreakPoints = FBreakPoints
|
||||
then FBreakPoints := nil;
|
||||
if FDebugger.BreakPointGroups = FBreakPointGroups
|
||||
then FBreakPointGroups := nil;
|
||||
if FDebugger.Watches = FWatches
|
||||
then FWatches := nil;
|
||||
|
||||
@ -410,6 +440,7 @@ begin
|
||||
end
|
||||
else begin
|
||||
FreeThenNil(FBreakPoints);
|
||||
FreeThenNil(FBreakPointGroups);
|
||||
FreeThenNil(FWatches);
|
||||
end;
|
||||
|
||||
@ -429,6 +460,8 @@ begin
|
||||
itmViewCallStack.Tag := Ord(ddtCallStack);
|
||||
itmViewDebugOutput.OnClick := @mnuViewDebugDialogClick;
|
||||
itmViewDebugOutput.Tag := Ord(ddtOutput);
|
||||
|
||||
itmProjectResetDebugger.OnClick := @mnuResetDebuggerClicked;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -451,9 +484,35 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TDebugManager.LoadProjectSpecificInfo(XMLConfig: TXMLConfig);
|
||||
|
||||
Called when the main project is loaded from the XMLConfig.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TDebugManager.LoadProjectSpecificInfo(XMLConfig: TXMLConfig);
|
||||
begin
|
||||
if FDebugger=nil then begin
|
||||
FBreakPointGroups.LoadFromXMLConfig(XMLConfig,
|
||||
'Debugging/'+XMLBreakPointGroupsNode+'/');
|
||||
FBreakPoints.LoadFromXMLConfig(XMLConfig,'Debugging/'+XMLBreakPointsNode+'/',
|
||||
@Project1.LongenFilename,
|
||||
@FBreakPointGroups.GetGroupByName);
|
||||
FWatches.LoadFromXMLConfig(XMLConfig,'Debugging/'+XMLWatchesNode+'/');
|
||||
end else begin
|
||||
FDebugger.LoadFromXMLConfig(XMLConfig,'Debugging/',@Project1.LongenFilename);
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TDebugManager.SaveProjectSpecificInfo(XMLConfig: TXMLConfig);
|
||||
|
||||
Called when the main project is saved to an XMLConfig.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TDebugManager.SaveProjectSpecificInfo(XMLConfig: TXMLConfig);
|
||||
begin
|
||||
if FDebugger=nil then begin
|
||||
FBreakPointGroups.SaveToXMLConfig(XMLConfig,
|
||||
'Debugging/'+XMLBreakPointGroupsNode+'/');
|
||||
FBreakPoints.SaveToXMLConfig(XMLConfig,'Debugging/'+XMLBreakPointsNode+'/',
|
||||
@Project1.ShortenFilename);
|
||||
FWatches.SaveToXMLConfig(XMLConfig,'Debugging/'+XMLWatchesNode+'/');
|
||||
@ -462,11 +521,56 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDebugManager.DoRestoreDebuggerMarks(AnUnitInfo: TUnitInfo);
|
||||
var
|
||||
ASrcEdit: TSourceEditor;
|
||||
EditorComponent: TSynEdit;
|
||||
Marks: TSynEditMarkList;
|
||||
i: Integer;
|
||||
CurBreakPoint: TDBGBreakPoint;
|
||||
SrcFilename: String;
|
||||
AMark: TSynEditMark;
|
||||
CurType: TSrcEditMarkerType;
|
||||
begin
|
||||
if AnUnitInfo.EditorIndex<0 then exit;
|
||||
ASrcEdit:=SourceNotebook.Editors[AnUnitInfo.EditorIndex];
|
||||
EditorComponent:=ASrcEdit.EditorComponent;
|
||||
Marks:=EditorComponent.Marks;
|
||||
// delete old breakpoints
|
||||
for i:=Marks.Count-1 downto 0 do begin
|
||||
AMark:=Marks[i];
|
||||
if ASrcEdit.IsBreakPointMark(Marks[i]) then begin
|
||||
Marks.Delete(i);
|
||||
AMark.Free;
|
||||
end;
|
||||
end;
|
||||
// set breakpoints
|
||||
SrcFilename:=AnUnitInfo.Filename;
|
||||
for i:=0 to FBreakpoints.Count-1 do begin
|
||||
CurBreakPoint:=FBreakpoints[i];
|
||||
if CompareFileNames(CurBreakPoint.Source,SrcFilename)=0 then begin
|
||||
if CurBreakPoint.Enabled then begin
|
||||
if CurBreakPoint.Valid in [vsValid,vsUnknown] then
|
||||
CurType:=semActiveBreakPoint
|
||||
else
|
||||
CurType:=semInvalidBreakPoint;
|
||||
end else
|
||||
CurType:=semInactiveBreakPoint;
|
||||
ASrcEdit.SetBreakPoint(CurBreakPoint.Line,CurType);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Debugger routines
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function TDebugManager.DoInitDebugger: TModalResult;
|
||||
var
|
||||
OldBreakpoints: TDBGBreakpoints;
|
||||
OldBreakPointGroups: TDBGBreakPointGroups;
|
||||
OldWatches: TDBGWatches;
|
||||
|
||||
procedure ResetDialogs;
|
||||
var
|
||||
DialogType: TDebugDialogType;
|
||||
@ -477,9 +581,55 @@ function TDebugManager.DoInitDebugger: TModalResult;
|
||||
then FDialogs[DialogType].Debugger := FDebugger;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure SaveDebuggerItems;
|
||||
begin
|
||||
// copy the break point list without the group references
|
||||
OldBreakpoints := TDBGBreakpoints.Create(nil, TDBGBreakpoint);
|
||||
OldBreakpoints.Assign(FBreakPoints);
|
||||
|
||||
// copy the groups and all group references
|
||||
OldBreakPointGroups := TDBGBreakPointGroups.Create;
|
||||
OldBreakPointGroups.Regroup(FBreakPointGroups,FBreakPoints,OldBreakPoints);
|
||||
|
||||
// copy the watches
|
||||
OldWatches := TDBGWatches.Create(nil, TDBGWatch);
|
||||
OldWatches.Assign(FWatches);
|
||||
|
||||
FBreakPointGroups := nil;
|
||||
FBreakPoints := nil;
|
||||
FWatches := nil;
|
||||
end;
|
||||
|
||||
procedure RestoreDebuggerItems;
|
||||
begin
|
||||
// restore the break point list without the group references
|
||||
if (OldBreakpoints<>nil) then
|
||||
FBreakPoints.Assign(OldBreakpoints);
|
||||
|
||||
// restore the groups and all group references
|
||||
if (OldBreakPointGroups<>nil) then begin
|
||||
if (OldBreakpoints<>nil) then
|
||||
FBreakPointGroups.Regroup(OldBreakPointGroups,OldBreakpoints,
|
||||
FBreakPoints)
|
||||
else
|
||||
FBreakPointGroups.Assign(OldBreakPointGroups);
|
||||
end;
|
||||
|
||||
// restore the watches
|
||||
if OldWatches<>nil then
|
||||
FWatches.Assign(OldWatches);
|
||||
end;
|
||||
|
||||
procedure FreeDebugger;
|
||||
begin
|
||||
SaveDebuggerItems;
|
||||
FDebugger.Free;
|
||||
FDebugger := nil;
|
||||
ResetDialogs;
|
||||
end;
|
||||
|
||||
var
|
||||
OldBreakpoints: TDBGBreakpoints;
|
||||
OldWatches: TDBGWatches;
|
||||
LaunchingCmdLine, LaunchingApplication, LaunchingParams: String;
|
||||
begin
|
||||
WriteLN('[TDebugManager.DoInitDebugger] A');
|
||||
@ -491,62 +641,44 @@ begin
|
||||
SplitCmdLine(LaunchingCmdLine,LaunchingApplication,LaunchingParams);
|
||||
|
||||
OldBreakpoints := nil;
|
||||
OldBreakPointGroups := nil;
|
||||
OldWatches := nil;
|
||||
|
||||
try
|
||||
|
||||
case EnvironmentOptions.DebuggerType of
|
||||
dtGnuDebugger: begin
|
||||
if (FDebugger <> nil)
|
||||
and ( not(FDebugger is TGDBMIDebugger)
|
||||
or (FDebugger.ExternalDebugger <> EnvironmentOptions.DebuggerFilename)
|
||||
)
|
||||
then begin
|
||||
OldBreakpoints := TDBGBreakpoints.Create(nil, TDBGBreakpoint);
|
||||
OldBreakpoints.Assign(FBreakPoints);
|
||||
FBreakPoints := nil;
|
||||
|
||||
OldWatches := TDBGWatches.Create(nil, TDBGWatch);
|
||||
OldWatches.Assign(FWatches);
|
||||
FWatches := nil;
|
||||
|
||||
FDebugger.Free;
|
||||
FDebugger := nil;
|
||||
ResetDialogs;
|
||||
end;
|
||||
if FDebugger = nil
|
||||
then begin
|
||||
if FBreakPoints <> nil
|
||||
case EnvironmentOptions.DebuggerType of
|
||||
dtGnuDebugger: begin
|
||||
// check if debugger already created with the right type
|
||||
if (FDebugger <> nil)
|
||||
and ( not(FDebugger is TGDBMIDebugger)
|
||||
or (FDebugger.ExternalDebugger <> EnvironmentOptions.DebuggerFilename)
|
||||
)
|
||||
then begin
|
||||
OldBreakpoints := TDBGBreakpoints.Create(nil, TDBGBreakpoint);
|
||||
OldBreakpoints.Assign(FBreakPoints);
|
||||
// the current debugger is the wrong type -> free it
|
||||
FreeDebugger;
|
||||
end;
|
||||
if FWatches <> nil
|
||||
// create debugger object
|
||||
if FDebugger = nil
|
||||
then begin
|
||||
OldWatches := TDBGWatches.Create(nil, TDBGWatch);
|
||||
OldWatches.Assign(FWatches);
|
||||
SaveDebuggerItems;
|
||||
FDebugger := TGDBMIDebugger.Create(EnvironmentOptions.DebuggerFilename);
|
||||
FBreakPointGroups := FDebugger.BreakPointGroups;
|
||||
FBreakPoints := FDebugger.BreakPoints;
|
||||
FWatches := FDebugger.Watches;
|
||||
ResetDialogs;
|
||||
end;
|
||||
FDebugger := TGDBMIDebugger.Create(EnvironmentOptions.DebuggerFilename);
|
||||
FBreakPoints := FDebugger.BreakPoints;
|
||||
FWatches := FDebugger.Watches;
|
||||
ResetDialogs;
|
||||
// restore debugger items
|
||||
RestoreDebuggerItems;
|
||||
end;
|
||||
if OldBreakpoints <> nil
|
||||
then FBreakPoints.Assign(OldBreakpoints);
|
||||
if OldWatches <> nil
|
||||
then FWatches.Assign(OldWatches);
|
||||
else
|
||||
if FDebugger=nil then
|
||||
FreeDebugger;
|
||||
exit;
|
||||
end;
|
||||
else
|
||||
OldBreakpoints := FBreakPoints;
|
||||
FBreakPoints := TDBGBreakpoints.Create(nil, TDBGBreakpoint);
|
||||
FBreakPoints.Assign(OldBreakpoints);
|
||||
|
||||
OldWatches := FWatches;
|
||||
FWatches := TDBGWatches.Create(nil, TDBGWatch);
|
||||
FWatches.Assign(OldWatches);
|
||||
|
||||
FDebugger.Free;
|
||||
FDebugger := nil;
|
||||
ResetDialogs;
|
||||
Exit;
|
||||
finally
|
||||
OldBreakpoints.Free;
|
||||
OldBreakPointGroups.Free;
|
||||
OldWatches.Free;
|
||||
end;
|
||||
FDebugger.OnState := @OnDebuggerChangeState;
|
||||
FDebugger.OnCurrent := @OnDebuggerCurrentLine;
|
||||
@ -554,7 +686,7 @@ begin
|
||||
FDebugger.OnException := @OnDebuggerException;
|
||||
if FDebugger.State = dsNone
|
||||
then FDebugger.Init;
|
||||
|
||||
|
||||
FDebugger.FileName := LaunchingApplication;
|
||||
FDebugger.Arguments := LaunchingParams;
|
||||
Project1.RunParameterOptions.AssignEnvironmentTo(FDebugger.Environment);
|
||||
@ -564,9 +696,6 @@ begin
|
||||
|
||||
//TODO: Show/hide debug menuitems based on FDebugger.SupportedCommands
|
||||
|
||||
// property BreakPointGroups: TDBGBreakPointGroups read FBreakPointGroups; // list of all breakpoints
|
||||
// property Watches: TDBGWatches read FWatches; // list of all watches localvars etc
|
||||
|
||||
Result := mrOk;
|
||||
WriteLN('[TDebugManager.DoInitDebugger] END');
|
||||
end;
|
||||
@ -694,6 +823,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.19 2003/05/23 14:12:50 mattias
|
||||
implemented restoring breakpoints
|
||||
|
||||
Revision 1.18 2003/05/22 17:06:49 mattias
|
||||
implemented InitialEnabled for breakpoints and watches
|
||||
|
||||
|
@ -215,7 +215,8 @@ type
|
||||
SynColorScheme: string; DefaultPascalSyn: TPreviewPasSyn);
|
||||
procedure WriteHighlighterSettings(Syn: TCustomSyn; SynColorScheme: string);
|
||||
procedure GetSpecialLineColors(Syn: TCustomSyn;
|
||||
AddHilightAttr: TAdditionalHilightAttribute; var FG, BG: TColor);
|
||||
AddHilightAttr: TAdditionalHilightAttribute; var Special: boolean;
|
||||
var FG, BG: TColor);
|
||||
published
|
||||
// general options
|
||||
property SynEditOptions:TSynEditorOptions
|
||||
@ -765,6 +766,7 @@ begin
|
||||
' begin'#13+
|
||||
' Inc(X); { Enabled breakpoint }'#13+
|
||||
' Dec(X); { Disabled breakpoint }'#13+
|
||||
' // { Invalid breakpoint }'#13+
|
||||
' X := X + 1.0; { Error line }'#13+
|
||||
' ListBox1.Items.Add(IntToStr(X));'#13+
|
||||
' end;'#13+
|
||||
@ -772,7 +774,8 @@ begin
|
||||
#13;
|
||||
AddAttrSampleLines[ahaDisabledBreakpoint]:=18;
|
||||
AddAttrSampleLines[ahaEnabledBreakpoint]:=17;
|
||||
AddAttrSampleLines[ahaErrorLine]:=19;
|
||||
AddAttrSampleLines[ahaInvalidBreakpoint]:=19;
|
||||
AddAttrSampleLines[ahaErrorLine]:=20;
|
||||
AddAttrSampleLines[ahaExecutionPoint]:=15;
|
||||
AddAttrSampleLines[ahaTextBlock]:=14;
|
||||
end;
|
||||
@ -1688,16 +1691,22 @@ begin
|
||||
end;
|
||||
|
||||
procedure TEditorOptions.GetSpecialLineColors(Syn: TCustomSyn;
|
||||
AddHilightAttr: TAdditionalHilightAttribute; var FG, BG: TColor);
|
||||
var i: integer;
|
||||
AddHilightAttr: TAdditionalHilightAttribute; var Special: boolean;
|
||||
var FG, BG: TColor);
|
||||
var
|
||||
i: integer;
|
||||
NewFG, NewBG: TColor;
|
||||
begin
|
||||
if Syn<>nil then begin
|
||||
for i:=0 to Syn.AttrCount-1 do begin
|
||||
if Syn.Attribute[i].Name='' then continue;
|
||||
if Syn.Attribute[i].Name=AdditionalHighlightAttributes[AddHilightAttr]
|
||||
then begin
|
||||
FG:=Syn.Attribute[i].Foreground;
|
||||
BG:=Syn.Attribute[i].Background;
|
||||
NewFG:=Syn.Attribute[i].Foreground;
|
||||
NewBG:=Syn.Attribute[i].Background;
|
||||
Special:=(NewFG<>clNone) or (NewBG<>clNone);
|
||||
if NewFG<>clNone then FG:=NewFG;
|
||||
if NewBG<>clNone then BG:=NewBG;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -2787,9 +2796,9 @@ begin
|
||||
e:=PreviewSyn.Attribute[i];
|
||||
if e.Name='' then continue;
|
||||
if e.Name=AdditionalHighlightAttributes[AddAttr] then begin
|
||||
Special:=true;
|
||||
FG:=e.ForeGround;
|
||||
BG:=e.BackGround;
|
||||
Special:=(e.ForeGround<>clNone) or (e.BackGround<>clNone);
|
||||
if e.ForeGround<>clNone then FG:=e.ForeGround;
|
||||
if e.BackGround<>clNone then BG:=e.BackGround;
|
||||
exit;
|
||||
end;
|
||||
dec(i);
|
||||
|
@ -803,14 +803,9 @@ var XMLConfig: TXMLConfig;
|
||||
|
||||
procedure LoadDebuggerType(var ADebuggerType: TDebuggerType;
|
||||
const Path: string);
|
||||
var i:integer;
|
||||
begin
|
||||
i:=XMLConfig.GetValue(Path+'DebuggerType/Value',5);
|
||||
case i of
|
||||
1:ADebuggerType:=dtGnuDebugger;
|
||||
else
|
||||
ADebuggerType:=dtNone;
|
||||
end;
|
||||
ADebuggerType:=DebuggerNameToType(
|
||||
XMLConfig.GetValue(Path+'Debugger/Type',''));
|
||||
end;
|
||||
|
||||
procedure LoadPascalFileExt(const Path: string);
|
||||
@ -1030,13 +1025,9 @@ var XMLConfig: TXMLConfig;
|
||||
end;
|
||||
|
||||
procedure SaveDebuggerType(ADebuggerType: TDebuggerType; Path:string);
|
||||
var i:integer;
|
||||
begin
|
||||
case ADebuggerType of
|
||||
dtNone: i:=0;
|
||||
dtGnuDebugger: i:=1;
|
||||
end;
|
||||
XMLConfig.SetDeleteValue(Path+'DebuggerType/Value',i,1);
|
||||
XMLConfig.SetDeleteValue(Path+'Debugger/Type',DebuggerName[ADebuggerType],
|
||||
DebuggerName[dtNone]);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -360,6 +360,7 @@ type
|
||||
procedure CreateOftenUsedForms; virtual; abstract;
|
||||
|
||||
function FindUnitFile(const AFilename: string): string; virtual; abstract;
|
||||
function FindSourceFile(const AFilename: string): string; virtual; abstract;
|
||||
procedure GetCurrentUnit(var ActiveSourceEditor:TSourceEditor;
|
||||
var ActiveUnitInfo:TUnitInfo); virtual; abstract;
|
||||
|
||||
|
@ -741,7 +741,7 @@ begin
|
||||
Loaded:=XMLConfig.GetValue(Path+'Loaded/Value',false);
|
||||
fUserReadOnly:=XMLConfig.GetValue(Path+'ReadOnly/Value',false);
|
||||
AFilename:=XMLConfig.GetValue(Path+'ResourceFilename/Value','');
|
||||
if Assigned(fOnLoadSaveFilename) then
|
||||
if (AFilename<>'') and Assigned(fOnLoadSaveFilename) then
|
||||
fOnLoadSaveFilename(AFilename,true);
|
||||
FResourceFilename:=AFilename;
|
||||
if (FResourceFilename<>'')
|
||||
@ -2080,9 +2080,10 @@ begin
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TProject.OnLoadSaveFilename(var AFilename:string; Load:boolean);
|
||||
procedure TProject.OnLoadSaveFilename(var AFilename: string; Load:boolean);
|
||||
var ProjectPath:string;
|
||||
begin
|
||||
if AFileName='' then exit;
|
||||
ProjectPath:=ProjectDirectory;
|
||||
if ProjectPath='' then ProjectPath:=GetCurrentDir;
|
||||
DoDirSeparators(AFilename);
|
||||
@ -2682,6 +2683,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.121 2003/05/23 14:12:51 mattias
|
||||
implemented restoring breakpoints
|
||||
|
||||
Revision 1.120 2003/05/21 16:19:12 mattias
|
||||
implemented saving breakpoints and watches
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user