Debugger: refactor

git-svn-id: trunk@44476 -
This commit is contained in:
martin 2014-03-20 14:59:29 +00:00
parent bc7b175f6d
commit eeef6684f7
7 changed files with 463 additions and 445 deletions

View File

@ -576,68 +576,106 @@ type
{ TWatchValueBase }
TWatchValueBase = class(TFreeNotifyingObject)
TWatchValue = class(TFreeNotifyingObject)
private
FTypeInfo: TDBGType;
FValue: String;
FValidity: TDebuggerDataState;
FWatch: TWatchBase;
procedure SetValidity(AValue: TDebuggerDataState); virtual;
procedure SetValue(AValue: String);
procedure SetTypeInfo(AValue: TDBGType);
function GetWatch: TWatchBase;
protected
FDisplayFormat: TWatchDisplayFormat;
FEvaluateFlags: TDBGEvaluateFlags;
FRepeatCount: Integer;
FStackFrame: Integer;
FThreadId: Integer;
procedure DoDataValidityChanged({%H-}AnOldValidity: TDebuggerDataState); virtual;
function GetDisplayFormat: TWatchDisplayFormat; virtual; abstract;
function GetEvaluateFlags: TDBGEvaluateFlags; virtual; abstract;
function GetExpression: String; virtual; abstract;
function GetRepeatCount: Integer; virtual; abstract;
function GetStackFrame: Integer; virtual; abstract;
function GetThreadId: Integer; virtual; abstract;
function GetExpression: String; virtual;
function GetTypeInfo: TDBGType; virtual;
function GetValue: String; virtual;
function GetWatchBase: TWatchBase; virtual; abstract;
public
constructor Create(AOwnerWatch: TWatchBase);
destructor Destroy; override;
procedure Assign(AnOther: TWatchValueBase); virtual;
property DisplayFormat: TWatchDisplayFormat read GetDisplayFormat;
property EvaluateFlags: TDBGEvaluateFlags read GetEvaluateFlags;
property RepeatCount: Integer read GetRepeatCount;
property ThreadId: Integer read GetThreadId;
property StackFrame: Integer read GetStackFrame;
procedure Assign(AnOther: TWatchValue); virtual;
property DisplayFormat: TWatchDisplayFormat read FDisplayFormat;
property EvaluateFlags: TDBGEvaluateFlags read FEvaluateFlags;
property RepeatCount: Integer read FRepeatCount;
property ThreadId: Integer read FThreadId;
property StackFrame: Integer read FStackFrame;
property Expression: String read GetExpression;
property Watch: TWatchBase read GetWatchBase;
property Watch: TWatchBase read GetWatch;
public
property Validity: TDebuggerDataState read FValidity write SetValidity;
property Value: String read GetValue write SetValue;
property TypeInfo: TDBGType read GetTypeInfo write SetTypeInfo;
end;
{ TWatchValueList }
TWatchValueList = class
private
FList: TList;
FWatch: TWatchBase;
function GetEntry(const AThreadId: Integer; const AStackFrame: Integer): TWatchValue;
function GetEntryByIdx(AnIndex: integer): TWatchValue;
protected
function CreateEntry(const {%H-}AThreadId: Integer; const {%H-}AStackFrame: Integer): TWatchValue; virtual;
function CopyEntry(AnEntry: TWatchValue): TWatchValue; virtual;
public
procedure Assign(AnOther: TWatchValueList);
constructor Create(AOwnerWatch: TWatchBase);
destructor Destroy; override;
procedure Add(AnEntry: TWatchValue);
procedure Clear;
function Count: Integer;
property EntriesByIdx[AnIndex: integer]: TWatchValue read GetEntryByIdx;
property Entries[const AThreadId: Integer; const AStackFrame: Integer]: TWatchValue
read GetEntry; default;
property Watch: TWatchBase read FWatch;
end;
{ TWatchBase }
TWatchBase = class(TDelayedUdateItem)
private
procedure SetDisplayFormat(AValue: TWatchDisplayFormat);
procedure SetEnabled(AValue: Boolean);
procedure SetEvaluateFlags(AValue: TDBGEvaluateFlags);
procedure SetExpression(AValue: String);
procedure SetRepeatCount(AValue: Integer);
function GetValue(const AThreadId: Integer; const AStackFrame: Integer): TWatchValue;
protected
function GetDisplayFormat: TWatchDisplayFormat; virtual; abstract;
function GetEnabled: Boolean; virtual; abstract;
function GetEvaluateFlags: TDBGEvaluateFlags; virtual; abstract;
function GetExpression: String; virtual; abstract;
function GetRepeatCount: Integer; virtual; abstract;
function GetValueBase(const AThreadId: Integer; const AStackFrame: Integer): TWatchValueBase; virtual; abstract;
procedure SetDisplayFormat(AValue: TWatchDisplayFormat); virtual; abstract;
procedure SetEnabled(AValue: Boolean); virtual; abstract;
procedure SetEvaluateFlags(AValue: TDBGEvaluateFlags); virtual; abstract;
procedure SetExpression(AValue: String); virtual; abstract;
procedure SetRepeatCount(AValue: Integer); virtual; abstract;
FEnabled: Boolean;
FEvaluateFlags: TDBGEvaluateFlags;
FExpression: String;
FDisplayFormat: TWatchDisplayFormat;
FRepeatCount: Integer;
FValueList: TWatchValueList;
procedure DoModified; virtual; // user-storable data: expression, enabled, display-format
procedure DoEnableChange; virtual;
procedure DoExpressionChange; virtual;
procedure DoDisplayFormatChanged; virtual;
procedure AssignTo(Dest: TPersistent); override;
function CreateValueList: TWatchValueList; virtual;
public
procedure ClearValues; virtual; abstract;
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
procedure ClearValues; virtual;
public
property Enabled: Boolean read GetEnabled write SetEnabled;
property Expression: String read GetExpression write SetExpression;
property DisplayFormat: TWatchDisplayFormat read GetDisplayFormat write SetDisplayFormat;
property EvaluateFlags: TDBGEvaluateFlags read GetEvaluateFlags write SetEvaluateFlags;
property RepeatCount: Integer read GetRepeatCount write SetRepeatCount;
property Values[const AThreadId: Integer; const AStackFrame: Integer]: TWatchValueBase
read GetValueBase;
property Enabled: Boolean read FEnabled write SetEnabled;
property Expression: String read FExpression write SetExpression;
property DisplayFormat: TWatchDisplayFormat read FDisplayFormat write SetDisplayFormat;
property EvaluateFlags: TDBGEvaluateFlags read FEvaluateFlags write SetEvaluateFlags;
property RepeatCount: Integer read FRepeatCount write SetRepeatCount;
property Values[const AThreadId: Integer; const AStackFrame: Integer]: TWatchValue
read GetValue;
end;
TBaseWatchClass = class of TWatchBase;
@ -664,10 +702,10 @@ type
procedure SetMonitor(AValue: TWatchesMonitor);
protected
procedure DoStateChange(const AOldState: TDBGState); override; // workaround for state changes during TWatchValue.GetValue
procedure InternalRequestData(AWatchValue: TWatchValueBase); virtual;
procedure InternalRequestData(AWatchValue: TWatchValue); virtual;
public
constructor Create(const ADebugger: TDebuggerIntf);
procedure RequestData(AWatchValue: TWatchValueBase);
procedure RequestData(AWatchValue: TWatchValue);
property CurrentWatches: TWatches read GetCurrentWatches;
property Monitor: TWatchesMonitor read GetMonitor write SetMonitor;
end;
@ -725,7 +763,7 @@ type
function CreateEntry: TDbgEntityValue; override;
public
procedure Add(const AName, AValue: String);
procedure SetDataValidity(AValidity: TDebuggerDataState); virtual;
procedure SetDataValidity({%H-}AValidity: TDebuggerDataState); virtual;
public
function Count: Integer;reintroduce; virtual;
property Entries[AnIndex: Integer]: TLocalsValue read GetEntry;
@ -1005,11 +1043,11 @@ type
procedure Assign(AnOther: TCallStackEntry); virtual;
procedure Init(const AnAddress: TDbgPtr;
const AnArguments: TStrings; const AFunctionName: String;
const AUnitName, AClassName, AProcName, AFunctionArgs: String;
const {%H-}AUnitName, {%H-}AClassName, {%H-}AProcName, {%H-}AFunctionArgs: String;
const ALine: Integer; AState: TDebuggerDataState = ddsValid); virtual;
procedure Init(const AnAddress: TDbgPtr;
const AnArguments: TStrings; const AFunctionName: String;
const FileName, FullName: String;
const {%H-}FileName, {%H-}FullName: String;
const ALine: Integer; AState: TDebuggerDataState = ddsValid); virtual;
procedure ClearLocation; virtual; // TODO need a way to call Changed on TCallStack or TThreads // corrently done in SetThreadState
function GetFunctionWithArg: String;
@ -1054,9 +1092,9 @@ type
procedure PrepareRange({%H-}AIndex, {%H-}ACount: Integer); virtual; abstract;
procedure DoEntriesCreated; virtual; abstract;
procedure DoEntriesUpdated; virtual; abstract;
procedure SetCountValidity(AValidity: TDebuggerDataState); virtual;
procedure SetHasAtLeastCountInfo(AValidity: TDebuggerDataState; AMinCount: Integer = -1); virtual;
procedure SetCurrentValidity(AValidity: TDebuggerDataState); virtual;
procedure SetCountValidity({%H-}AValidity: TDebuggerDataState); virtual;
procedure SetHasAtLeastCountInfo({%H-}AValidity: TDebuggerDataState; {%H-}AMinCount: Integer = -1); virtual;
procedure SetCurrentValidity({%H-}AValidity: TDebuggerDataState); virtual;
function CountLimited(ALimit: Integer): Integer; virtual; abstract;
property Count: Integer read GetCount write SetCount;
property CurrentIndex: Integer read GetCurrent write SetCurrent;
@ -1077,7 +1115,7 @@ type
function GetEntry(const AIndex: Integer): TCallStackBase;
function GetEntryForThread(const AThreadId: Integer): TCallStackBase;
protected
function NewEntryForThread(const AThreadId: Integer): TCallStackBase; virtual;
function NewEntryForThread(const {%H-}AThreadId: Integer): TCallStackBase; virtual;
public
constructor Create;
destructor Destroy; override;
@ -1356,7 +1394,7 @@ type
const AThreadId: Integer; const AThreadName: String;
const AThreadState: String;
AState: TDebuggerDataState = ddsValid): TThreadEntry; virtual;
procedure SetValidity(AValidity: TDebuggerDataState); virtual;
procedure SetValidity({%H-}AValidity: TDebuggerDataState); virtual;
property Entries[const AnIndex: Integer]: TThreadEntry read GetEntry; default;
property EntryById[const AnID: Integer]: TThreadEntry read GetEntryById;
property CurrentThreadId: Integer read FCurrentThreadId write SetCurrentThreadId;
@ -2227,56 +2265,72 @@ begin
Result := FUpdateCount > 0;
end;
{ TWatchValueBase }
{ TWatchValue }
procedure TWatchValueBase.SetValidity(AValue: TDebuggerDataState);
procedure TWatchValue.SetValidity(AValue: TDebuggerDataState);
var
OldValidity: TDebuggerDataState;
begin
if FValidity = AValue then exit;
//DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TWatchValueBase.SetValidity: FThreadId=', FThreadId, ' FStackFrame=',FStackFrame, ' Expr=', Expression, ' AValidity=',dbgs(AValue)]);
DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TWatchValueBase.SetValidity: Expr=', Expression, ' AValidity=',dbgs(AValue)]);
//DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TWatchValue.SetValidity: FThreadId=', FThreadId, ' FStackFrame=',FStackFrame, ' Expr=', Expression, ' AValidity=',dbgs(AValue)]);
DebugLn(DBG_DATA_MONITORS, ['DebugDataMonitor: TWatchValue.SetValidity: Expr=', Expression, ' AValidity=',dbgs(AValue)]);
OldValidity := FValidity;
FValidity := AValue;
DoDataValidityChanged(OldValidity);
end;
procedure TWatchValueBase.SetValue(AValue: String);
procedure TWatchValue.SetValue(AValue: String);
begin
if FValue = AValue then exit;
//asser not immutable
FValue := AValue;
end;
procedure TWatchValueBase.SetTypeInfo(AValue: TDBGType);
procedure TWatchValue.SetTypeInfo(AValue: TDBGType);
begin
//assert(Self is TCurrentWatchValue, 'TWatchValue.SetTypeInfo');
FreeAndNil(FTypeInfo);
FTypeInfo := AValue;
end;
procedure TWatchValueBase.DoDataValidityChanged(AnOldValidity: TDebuggerDataState);
procedure TWatchValue.DoDataValidityChanged(AnOldValidity: TDebuggerDataState);
begin
end;
function TWatchValueBase.GetTypeInfo: TDBGType;
function TWatchValue.GetExpression: String;
begin
Result := FWatch.Expression;
end;
function TWatchValue.GetTypeInfo: TDBGType;
begin
Result := FTypeInfo;
end;
function TWatchValueBase.GetValue: String;
function TWatchValue.GetValue: String;
begin
Result := FValue;
end;
destructor TWatchValueBase.Destroy;
constructor TWatchValue.Create(AOwnerWatch: TWatchBase);
begin
FWatch := AOwnerWatch;
inherited Create;
end;
function TWatchValue.GetWatch: TWatchBase;
begin
Result := FWatch;
end;
destructor TWatchValue.Destroy;
begin
inherited Destroy;
FreeAndNil(FTypeInfo);
end;
procedure TWatchValueBase.Assign(AnOther: TWatchValueBase);
procedure TWatchValue.Assign(AnOther: TWatchValue);
begin
FreeAndNil(FTypeInfo);
//FTypeInfo := TWatchValue(AnOther).FTypeInfo.cre;
@ -2284,6 +2338,195 @@ begin
FValidity := AnOther.FValidity;
end;
{ TWatchBase }
procedure TWatchBase.SetDisplayFormat(AValue: TWatchDisplayFormat);
begin
if AValue = FDisplayFormat then exit;
FDisplayFormat := AValue;
DoDisplayFormatChanged;
end;
procedure TWatchBase.SetEnabled(AValue: Boolean);
begin
if FEnabled <> AValue
then begin
FEnabled := AValue;
DoEnableChange;
end;
end;
procedure TWatchBase.SetEvaluateFlags(AValue: TDBGEvaluateFlags);
begin
if FEvaluateFlags = AValue then Exit;
FEvaluateFlags := AValue;
Changed;
DoModified;
end;
procedure TWatchBase.SetExpression(AValue: String);
begin
if AValue <> FExpression
then begin
FExpression := AValue;
FValueList.Clear;
DoExpressionChange;
end;
end;
procedure TWatchBase.SetRepeatCount(AValue: Integer);
begin
if FRepeatCount = AValue then Exit;
FRepeatCount := AValue;
Changed;
DoModified;
end;
function TWatchBase.GetValue(const AThreadId: Integer;
const AStackFrame: Integer): TWatchValue;
begin
Result := FValueList[AThreadId, AStackFrame];
end;
procedure TWatchBase.DoModified;
begin
//
end;
procedure TWatchBase.DoEnableChange;
begin
//
end;
procedure TWatchBase.DoExpressionChange;
begin
//
end;
procedure TWatchBase.DoDisplayFormatChanged;
begin
//
end;
procedure TWatchBase.AssignTo(Dest: TPersistent);
begin
if Dest is TWatchBase
then begin
TWatchBase(Dest).FExpression := FExpression;
TWatchBase(Dest).FEnabled := FEnabled;
TWatchBase(Dest).FDisplayFormat := FDisplayFormat;
TWatchBase(Dest).FRepeatCount := FRepeatCount;
TWatchBase(Dest).FEvaluateFlags := FEvaluateFlags;
TWatchBase(Dest).FValueList.Assign(FValueList);
end
else inherited;
end;
function TWatchBase.CreateValueList: TWatchValueList;
begin
Result := TWatchValueList.Create(Self);
end;
constructor TWatchBase.Create(ACollection: TCollection);
begin
FEnabled := False;
FValueList := CreateValueList;
inherited Create(ACollection);
end;
destructor TWatchBase.Destroy;
begin
FValueList.Clear;
inherited Destroy;
FreeAndNil(FValueList);
end;
procedure TWatchBase.ClearValues;
begin
FValueList.Clear;
end;
{ TWatchValueList }
function TWatchValueList.GetEntry(const AThreadId: Integer;
const AStackFrame: Integer): TWatchValue;
var
i: Integer;
begin
i := FList.Count - 1;
while i >= 0 do begin
Result := TWatchValue(FList[i]);
if (Result.ThreadId = AThreadId) and (Result.StackFrame = AStackFrame) and
(Result.DisplayFormat = FWatch.DisplayFormat) and
(Result.RepeatCount = FWatch.RepeatCount) and
(Result.EvaluateFlags = FWatch.EvaluateFlags)
then
exit;
dec(i);
end;
Result := CreateEntry(AThreadId, AStackFrame);
end;
function TWatchValueList.GetEntryByIdx(AnIndex: integer): TWatchValue;
begin
Result := TWatchValue(FList[AnIndex]);
end;
function TWatchValueList.CreateEntry(const AThreadId: Integer;
const AStackFrame: Integer): TWatchValue;
begin
Result := nil;
end;
function TWatchValueList.CopyEntry(AnEntry: TWatchValue): TWatchValue;
begin
Result := TWatchValue.Create(FWatch);
Result.Assign(AnEntry);
end;
procedure TWatchValueList.Assign(AnOther: TWatchValueList);
var
i: Integer;
begin
Clear;
for i := 0 to AnOther.FList.Count - 1 do begin
FList.Add(CopyEntry(TWatchValue(AnOther.FList[i])));
end;
end;
constructor TWatchValueList.Create(AOwnerWatch: TWatchBase);
begin
assert(AOwnerWatch <> nil, 'TWatchValueList.Create without owner');
FList := TList.Create;
FWatch := AOwnerWatch;
inherited Create;
end;
destructor TWatchValueList.Destroy;
begin
Clear;
inherited Destroy;
FreeAndNil(FList);
end;
procedure TWatchValueList.Add(AnEntry: TWatchValue);
begin
Flist.Add(AnEntry);
end;
procedure TWatchValueList.Clear;
begin
while FList.Count > 0 do begin
TObject(FList[0]).Free;
FList.Delete(0);
end;
end;
function TWatchValueList.Count: Integer;
begin
Result := FList.Count;
end;
{ TRegisterSupplier }
function TRegisterSupplier.GetCurrentRegistersList: TRegistersList;
@ -3478,7 +3721,7 @@ end;
{ TWatchesSupplier }
procedure TWatchesSupplier.RequestData(AWatchValue: TWatchValueBase);
procedure TWatchesSupplier.RequestData(AWatchValue: TWatchValue);
begin
if FNotifiedState in [dsPause, dsInternalPause]
then InternalRequestData(AWatchValue)
@ -3510,7 +3753,7 @@ begin
inherited DoStateChange(AOldState);
end;
procedure TWatchesSupplier.InternalRequestData(AWatchValue: TWatchValueBase);
procedure TWatchesSupplier.InternalRequestData(AWatchValue: TWatchValue);
begin
AWatchValue.SetValidity(ddsInvalid);
end;

View File

@ -100,7 +100,7 @@ type
property TargetPID;
protected
procedure DoWatchFreed(Sender: TObject);
function EvaluateExpression(AWatchValue: TWatchValueBase;
function EvaluateExpression(AWatchValue: TWatchValue;
AExpression: String;
var AResText: String;
out ATypeInfo: TDBGType;
@ -156,7 +156,7 @@ type
//procedure DoStateChange(const AOldState: TDBGState); override;
procedure ProcessEvalList;
procedure QueueCommand;
procedure InternalRequestData(AWatchValue: TWatchValueBase); override;
procedure InternalRequestData(AWatchValue: TWatchValue); override;
public
end;
@ -917,7 +917,7 @@ end;
procedure TFPGDBMIWatches.ProcessEvalList;
var
WatchValue: TWatchValueBase;
WatchValue: TWatchValue;
ResTypeInfo: TDBGType;
ResText: String;
@ -939,7 +939,7 @@ begin
try // TODO: if the stack/thread is changed, registers will be wrong
while (FpDebugger.FWatchEvalList.Count > 0) and (FEvaluationCmdObj = nil) do begin
try
WatchValue := TWatchValueBase(FpDebugger.FWatchEvalList[0]);
WatchValue := TWatchValue(FpDebugger.FWatchEvalList[0]);
ResTypeInfo := nil;
if not FpDebugger.EvaluateExpression(WatchValue, WatchValue.Expression, ResText, ResTypeInfo)
then begin
@ -968,7 +968,7 @@ begin
FpDebugger.QueueCommand(FEvaluationCmdObj, ForceQueuing);
end;
procedure TFPGDBMIWatches.InternalRequestData(AWatchValue: TWatchValueBase);
procedure TFPGDBMIWatches.InternalRequestData(AWatchValue: TWatchValue);
begin
if (Debugger = nil) or not(Debugger.State in [dsPause, dsInternalPause]) then begin
AWatchValue.Validity := ddsInvalid;
@ -1099,7 +1099,7 @@ begin
ReleaseRefAndNil(FLastContext[i]);
if not(State in [dsPause, dsInternalPause]) then begin
for i := 0 to FWatchEvalList.Count - 1 do begin
TWatchValueBase(FWatchEvalList[i]).RemoveFreeeNotification(@DoWatchFreed);
TWatchValue(FWatchEvalList[i]).RemoveFreeeNotification(@DoWatchFreed);
//TWatchValueBase(FWatchEvalList[i]).Validity := ddsInvalid;
end;
FWatchEvalList.Clear;
@ -1300,7 +1300,7 @@ begin
FWatchEvalList.Remove(pointer(Sender));
end;
function TFpGDBMIDebugger.EvaluateExpression(AWatchValue: TWatchValueBase;
function TFpGDBMIDebugger.EvaluateExpression(AWatchValue: TWatchValue;
AExpression: String; var AResText: String; out ATypeInfo: TDBGType;
EvalFlags: TDBGEvaluateFlags): Boolean;
var

View File

@ -623,7 +623,7 @@ type
procedure Changed;
procedure Clear;
function ForceQueuing: Boolean;
procedure InternalRequestData(AWatchValue: TWatchValueBase); override;
procedure InternalRequestData(AWatchValue: TWatchValue); override;
property ParentFPListChangeStamp: Integer read FParentFPListChangeStamp;
public
constructor Create(const ADebugger: TDebuggerIntf);
@ -1164,7 +1164,7 @@ type
FEvalFlags: TDBGEvaluateFlags;
FExpression: String;
FDisplayFormat: TWatchDisplayFormat;
FWatchValue: TWatchValueBase;
FWatchValue: TWatchValue;
FTextValue: String;
FTypeInfo: TGDBType;
FValidity: TDebuggerDataState;
@ -1182,7 +1182,7 @@ type
procedure UnSelectContext;
public
constructor Create(AOwner: TGDBMIDebugger; AExpression: String; ADisplayFormat: TWatchDisplayFormat);
constructor Create(AOwner: TGDBMIDebugger; AWatchValue: TWatchValueBase);
constructor Create(AOwner: TGDBMIDebugger; AWatchValue: TWatchValue);
destructor Destroy; override;
function DebugText: String; override;
property Expression: String read FExpression;
@ -9808,7 +9808,7 @@ begin
and (Debugger.State <> dsInternalPause);
end;
procedure TGDBMIWatches.InternalRequestData(AWatchValue: TWatchValueBase);
procedure TGDBMIWatches.InternalRequestData(AWatchValue: TWatchValue);
var
EvaluationCmdObj: TGDBMIDebuggerCommandEvaluate;
begin
@ -12732,7 +12732,7 @@ begin
end;
constructor TGDBMIDebuggerCommandEvaluate.Create(AOwner: TGDBMIDebugger;
AWatchValue: TWatchValueBase);
AWatchValue: TWatchValue);
begin
Create(AOwner, AWatchValue.Watch.Expression, AWatchValue.DisplayFormat);
EvalFlags := AWatchValue.EvaluateFlags;

View File

@ -232,7 +232,7 @@ type
TIDEBreakPoints = class;
TIDEBreakPointGroup = class;
TIDEBreakPointGroups = class;
TWatch = class;
TIdeWatch = class;
TIdeWatches = class;
TCurrentWatch = class;
TCurrentWatches = class;
@ -541,7 +541,7 @@ const
type
TWatchesEvent =
procedure(const ASender: TIdeWatches; const AWatch: TWatch) of object;
procedure(const ASender: TIdeWatches; const AWatch: TIdeWatch) of object;
TWatchesNotification = class(TDebuggerNotification)
private
@ -568,25 +568,15 @@ type
{ TWatchValue }
TWatchValue = class(TWatchValueBase)
private
FWatch: TWatch;
FDisplayFormat: TWatchDisplayFormat;
FEvaluateFlags: TDBGEvaluateFlags;
FRepeatCount: Integer;
FStackFrame: Integer;
FThreadId: Integer;
{ TIdeWatchValue }
TIdeWatchValue = class(TWatchValue)
private
function GetWatch: TIdeWatch;
protected
function GetDisplayFormat: TWatchDisplayFormat; override;
function GetEvaluateFlags: TDBGEvaluateFlags; override;
function GetExpression: String; override;
function GetRepeatCount: Integer; override;
function GetStackFrame: Integer; override;
function GetThreadId: Integer; override;
function GetTypeInfo: TDBGType; override;
function GetValue: String; override;
function GetWatchBase: TWatchBase; override;
procedure RequestData; virtual;
procedure LoadDataFromXMLConfig(const AConfig: TXMLConfig;
@ -594,73 +584,47 @@ type
procedure SaveDataToXMLConfig(const AConfig: TXMLConfig;
const APath: string);
public
constructor Create; virtual; overload;
constructor Create(AOwnerWatch: TWatch); overload;
constructor Create(AOwnerWatch: TWatch;
constructor Create(AOwnerWatch: TIdeWatch);
constructor Create(AOwnerWatch: TIdeWatch;
const AThreadId: Integer;
const AStackFrame: Integer
); overload;
procedure Assign(AnOther: TWatchValueBase); override;
);
procedure Assign(AnOther: TWatchValue); override;
property Watch: TWatch read FWatch;
property Watch: TIdeWatch read GetWatch;
end;
{ TWatchValueList }
{ TIdeWatchValueList }
TWatchValueList = class
TIdeWatchValueList = class(TWatchValueList)
private
FList: TList;
FWatch: TWatch;
function GetEntry(const AThreadId: Integer; const AStackFrame: Integer): TWatchValue;
function GetEntryByIdx(AnIndex: integer): TWatchValue;
function GetEntry(const AThreadId: Integer; const AStackFrame: Integer): TIdeWatchValue;
function GetEntryByIdx(AnIndex: integer): TIdeWatchValue;
function GetWatch: TIdeWatch;
protected
function CreateEntry(const {%H-}AThreadId: Integer; const {%H-}AStackFrame: Integer): TWatchValue; virtual;
function CopyEntry(AnEntry: TWatchValue): TWatchValue; override;
procedure LoadDataFromXMLConfig(const AConfig: TXMLConfig;
APath: string);
procedure SaveDataToXMLConfig(const AConfig: TXMLConfig;
APath: string);
public
procedure Assign(AnOther: TWatchValueList);
constructor Create(AOwnerWatch: TWatch);
destructor Destroy; override;
procedure Add(AnEntry: TWatchValue);
procedure Clear;
function Count: Integer;
property EntriesByIdx[AnIndex: integer]: TWatchValue read GetEntryByIdx;
property Entries[const AThreadId: Integer; const AStackFrame: Integer]: TWatchValue
constructor Create(AOwnerWatch: TIdeWatch);
property EntriesByIdx[AnIndex: integer]: TIdeWatchValue read GetEntryByIdx;
property Entries[const AThreadId: Integer; const AStackFrame: Integer]: TIdeWatchValue
read GetEntry; default;
property Watch: TWatch read FWatch;
property Watch: TIdeWatch read GetWatch;
end;
{ TWatch }
{ TIdeWatch }
TWatch = class(TWatchBase)
TIdeWatch = class(TWatchBase)
private
FEnabled: Boolean;
FEvaluateFlags: TDBGEvaluateFlags;
FExpression: String;
FDisplayFormat: TWatchDisplayFormat;
FRepeatCount: Integer;
FValueList: TWatchValueList;
function GetValue(const AThreadId: Integer; const AStackFrame: Integer): TIdeWatchValue;
protected
function GetDisplayFormat: TWatchDisplayFormat; override;
function GetEnabled: Boolean; override;
function GetEvaluateFlags: TDBGEvaluateFlags; override;
function GetExpression: String; override;
function GetRepeatCount: Integer; override;
function GetValueBase(const AThreadId: Integer; const AStackFrame: Integer): TWatchValueBase; override;
procedure SetDisplayFormat(AValue: TWatchDisplayFormat); override;
procedure SetEnabled(AValue: Boolean); override;
procedure SetEvaluateFlags(AValue: TDBGEvaluateFlags); override;
procedure SetExpression(AValue: String); override;
procedure SetRepeatCount(AValue: Integer); override;
function GetValue(const AThreadId: Integer; const AStackFrame: Integer): TWatchValue;
procedure AssignTo(Dest: TPersistent); override;
function CreateValueList: TWatchValueList; virtual;
procedure DoModified; virtual; // user-storable data: expression, enabled, display-format
procedure DoEnableChange; virtual;
procedure DoExpressionChange; virtual;
procedure DoDisplayFormatChanged; virtual;
function CreateValueList: TWatchValueList; override;
procedure DoEnableChange; override;
procedure DoExpressionChange; override;
procedure DoDisplayFormatChanged; override;
protected
procedure LoadDataFromXMLConfig(const AConfig: TXMLConfig;
const APath: string);
@ -668,16 +632,9 @@ type
const APath: string);
public
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
procedure ClearValues; override;
public
property Enabled: Boolean read GetEnabled write SetEnabled;
property Expression: String read GetExpression write SetExpression;
property DisplayFormat: TWatchDisplayFormat read GetDisplayFormat write SetDisplayFormat;
property EvaluateFlags: TDBGEvaluateFlags read FEvaluateFlags write SetEvaluateFlags;
property RepeatCount: Integer read FRepeatCount write SetRepeatCount;
public
property Values[const AThreadId: Integer; const AStackFrame: Integer]: TWatchValue
property Values[const AThreadId: Integer; const AStackFrame: Integer]: TIdeWatchValue
read GetValue;
end;
@ -685,8 +642,8 @@ type
TIdeWatches = class(TWatches)
private
function GetItem(const AnIndex: Integer): TWatch;
procedure SetItem(const AnIndex: Integer; const AValue: TWatch);
function GetItem(const AnIndex: Integer): TIdeWatch;
procedure SetItem(const AnIndex: Integer; const AValue: TIdeWatch);
protected
function WatchClass: TBaseWatchClass; override;
procedure LoadDataFromXMLConfig(const AConfig: TXMLConfig;
@ -694,48 +651,48 @@ type
procedure SaveDataToXMLConfig(const AConfig: TXMLConfig;
APath: string);
public
function Add(const AExpression: String): TWatch;
function Find(const AExpression: String): TWatch; override;
property Items[const AnIndex: Integer]: TWatch read GetItem write SetItem; default;
function Add(const AExpression: String): TIdeWatch;
function Find(const AExpression: String): TIdeWatch; override;
property Items[const AnIndex: Integer]: TIdeWatch read GetItem write SetItem; default;
procedure ClearValues; override;
end;
{ TCurrentWatchValue }
TCurrentWatchValue = class(TWatchValue)
TCurrentWatchValue = class(TIdeWatchValue)
private
FSnapShot: TWatchValue;
procedure SetSnapShot(const AValue: TWatchValue);
FSnapShot: TIdeWatchValue;
procedure SetSnapShot(const AValue: TIdeWatchValue);
protected
procedure RequestData; override;
procedure DoDataValidityChanged(AnOldValidity: TDebuggerDataState); override;
public
property SnapShot: TWatchValue read FSnapShot write SetSnapShot;
property SnapShot: TIdeWatchValue read FSnapShot write SetSnapShot;
end;
{ TCurrentWatchValueList }
TCurrentWatchValueList = class(TWatchValueList)
TCurrentWatchValueList = class(TIdeWatchValueList)
private
FSnapShot: TWatchValueList;
procedure SetSnapShot(const AValue: TWatchValueList);
FSnapShot: TIdeWatchValueList;
procedure SetSnapShot(const AValue: TIdeWatchValueList);
protected
function CreateEntry(const AThreadId: Integer; const AStackFrame: Integer): TWatchValue; override;
property SnapShot: TWatchValueList read FSnapShot write SetSnapShot;
function CreateEntry(const AThreadId: Integer; const AStackFrame: Integer): TIdeWatchValue; override;
property SnapShot: TIdeWatchValueList read FSnapShot write SetSnapShot;
end;
{ TCurrentWatch }
TCurrentWatch = class(TWatch)
TCurrentWatch = class(TIdeWatch)
private
FSnapShot: TWatch;
procedure SetSnapShot(const AValue: TWatch);
FSnapShot: TIdeWatch;
procedure SetSnapShot(const AValue: TIdeWatch);
protected
function CreateValueList: TWatchValueList; override;
function CreateValueList: TIdeWatchValueList; override;
procedure DoChanged; override;
procedure DoModified; override;
procedure RequestData(AWatchValue: TCurrentWatchValue);
property SnapShot: TWatch read FSnapShot write SetSnapShot;
property SnapShot: TIdeWatch read FSnapShot write SetSnapShot;
public
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
@ -1180,7 +1137,7 @@ type
constructor Create;
function CreateCopy: TCallStackBase; override;
destructor Destroy; override;
procedure Assign(AnOther: TCallStackBase);
procedure Assign(AnOther: TCallStackBase); override;
procedure PrepareRange({%H-}AIndex, {%H-}ACount: Integer); override;
procedure ChangeCurrentIndex(ANewIndex: Integer); virtual;
function HasAtLeastCount(ARequiredMinCount: Integer): TNullableBool; virtual; // Can be faster than getting the full count
@ -1239,7 +1196,7 @@ type
public
constructor Create(AMonitor: TIdeCallStackMonitor);
destructor Destroy; override;
procedure Assign(AnOther: TIdeCallStack);
procedure Assign(AnOther: TCallStackBase); override;
procedure PrepareRange(AIndex, ACount: Integer); override;
procedure ChangeCurrentIndex(ANewIndex: Integer); override;
procedure DoEntriesCreated; override;
@ -3220,7 +3177,7 @@ end;
{ TCurrentWatchValue }
procedure TCurrentWatchValue.SetSnapShot(const AValue: TWatchValue);
procedure TCurrentWatchValue.SetSnapShot(const AValue: TIdeWatchValue);
begin
assert((FSnapShot=nil) or (AValue=nil), 'TCurrentWatchValue already have snapshot');
if FSnapShot = AValue then exit;
@ -3231,22 +3188,22 @@ end;
procedure TCurrentWatchValue.RequestData;
begin
TCurrentWatch(FWatch).RequestData(self);
TCurrentWatch(Watch).RequestData(self);
end;
procedure TCurrentWatchValue.DoDataValidityChanged(AnOldValidity: TDebuggerDataState);
begin
if Validity = ddsRequested then exit;
TCurrentWatches(TCurrentWatch(FWatch).Collection).Update(FWatch);
TCurrentWatches(TCurrentWatch(Watch).Collection).Update(Watch);
if FSnapShot <> nil
then FSnapShot.Assign(self);
end;
{ TCurrentWatchValueList }
procedure TCurrentWatchValueList.SetSnapShot(const AValue: TWatchValueList);
procedure TCurrentWatchValueList.SetSnapShot(const AValue: TIdeWatchValueList);
var
R: TWatchValue;
R: TIdeWatchValue;
i: Integer;
begin
assert((FSnapShot=nil) or (AValue=nil), 'TCurrentWatchValueList already have snapshot');
@ -3261,7 +3218,7 @@ begin
// Assign
FSnapShot.Clear;
for i := 0 to Count - 1 do begin
R := TWatchValue.Create(FSnapShot.FWatch);
R := TIdeWatchValue.Create(FSnapShot.Watch);
R.Assign(EntriesByIdx[i]);
FSnapShot.Add(R);
TCurrentWatchValue(EntriesByIdx[i]).SnapShot := R;
@ -3271,15 +3228,15 @@ begin
end;
function TCurrentWatchValueList.CreateEntry(const AThreadId: Integer;
const AStackFrame: Integer): TWatchValue;
const AStackFrame: Integer): TIdeWatchValue;
var
R: TWatchValue;
R: TIdeWatchValue;
begin
try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: TCurrentWatchValueList.CreateEntry AThreadId=', AThreadId, ' AStackFrame=',AStackFrame, ' Expr=', FWatch.Expression]);
Result := TCurrentWatchValue.Create(FWatch, AThreadId, AStackFrame);
try DebugLnEnter(DBG_DATA_MONITORS, ['DebugDataMonitor: >>ENTER: TCurrentWatchValueList.CreateEntry AThreadId=', AThreadId, ' AStackFrame=',AStackFrame, ' Expr=', Watch.Expression]);
Result := TCurrentWatchValue.Create(Watch, AThreadId, AStackFrame);
Add(Result);
if FSnapShot <> nil then begin
R := TWatchValue.Create(FSnapShot.FWatch);
R := TIdeWatchValue.Create(FSnapShot.Watch);
FSnapShot.Add(R);
TCurrentWatchValue(Result).SnapShot := R;
end;
@ -3288,53 +3245,45 @@ end;
{ TWatchValueList }
function TWatchValueList.GetEntry(const AThreadId: Integer;
const AStackFrame: Integer): TWatchValue;
var
i: Integer;
function TIdeWatchValueList.GetEntry(const AThreadId: Integer;
const AStackFrame: Integer): TIdeWatchValue;
begin
i := FList.Count - 1;
while i >= 0 do begin
Result := TWatchValue(FList[i]);
if (Result.ThreadId = AThreadId) and (Result.StackFrame = AStackFrame) and
(Result.DisplayFormat = FWatch.DisplayFormat) and
(Result.RepeatCount = FWatch.RepeatCount) and
(Result.EvaluateFlags = FWatch.EvaluateFlags)
then
exit;
dec(i);
end;
Result := CreateEntry(AThreadId, AStackFrame);
Result := TIdeWatchValue(inherited Entries[AThreadId, AStackFrame]);
end;
function TWatchValueList.GetEntryByIdx(AnIndex: integer): TWatchValue;
function TIdeWatchValueList.GetEntryByIdx(AnIndex: integer): TIdeWatchValue;
begin
Result := TWatchValue(FList[AnIndex]);
Result := TIdeWatchValue(inherited EntriesByIdx[AnIndex]);
end;
function TWatchValueList.CreateEntry(const AThreadId: Integer;
const AStackFrame: Integer): TWatchValue;
function TIdeWatchValueList.GetWatch: TIdeWatch;
begin
Result := nil;
Result := TIdeWatch(inherited Watch);
end;
procedure TWatchValueList.LoadDataFromXMLConfig(const AConfig: TXMLConfig;
function TIdeWatchValueList.CopyEntry(AnEntry: TWatchValue): TWatchValue;
begin
Result := TIdeWatchValue.Create(Watch);
Result.Assign(AnEntry);
end;
procedure TIdeWatchValueList.LoadDataFromXMLConfig(const AConfig: TXMLConfig;
APath: string);
var
e: TWatchValue;
e: TIdeWatchValue;
c, i: Integer;
begin
Clear;
c := AConfig.GetValue(APath + 'Count', 0);
APath := APath + 'Entry';
for i := 0 to c - 1 do begin
e := TWatchValue.Create(FWatch);
e := TIdeWatchValue.Create(Watch);
e.LoadDataFromXMLConfig(AConfig, APath + IntToStr(i) + '/');
Add(e);
end;
end;
procedure TWatchValueList.SaveDataToXMLConfig(const AConfig: TXMLConfig;
procedure TIdeWatchValueList.SaveDataToXMLConfig(const AConfig: TXMLConfig;
APath: string);
var
i: Integer;
@ -3345,61 +3294,20 @@ begin
EntriesByIdx[i].SaveDataToXMLConfig(AConfig, APath + IntToStr(i) + '/');
end;
procedure TWatchValueList.Assign(AnOther: TWatchValueList);
var
i: Integer;
v: TWatchValue;
constructor TIdeWatchValueList.Create(AOwnerWatch: TIdeWatch);
begin
Clear;
for i := 0 to AnOther.FList.Count - 1 do begin
v := TWatchValue.Create(FWatch);
v.Assign(TWatchValue(AnOther.FList[i]));
FList.Add(v);
end;
end;
constructor TWatchValueList.Create(AOwnerWatch: TWatch);
begin
assert(AOwnerWatch <> nil, 'TWatchValueList.Create without owner');
assert(((Self is TCurrentWatchValueList) and (AOwnerWatch is TCurrentWatch)) or ((not(Self is TCurrentWatchValueList)) and not(AOwnerWatch is TCurrentWatch)),
'TWatchValueList.Create: Watch and list differ (current and none current)');
FList := TList.Create;
FWatch := AOwnerWatch;
inherited Create;
end;
destructor TWatchValueList.Destroy;
begin
Clear;
inherited Destroy;
FreeAndNil(FList);
end;
procedure TWatchValueList.Add(AnEntry: TWatchValue);
begin
Flist.Add(AnEntry);
end;
procedure TWatchValueList.Clear;
begin
while FList.Count > 0 do begin
TObject(FList[0]).Free;
FList.Delete(0);
end;
end;
function TWatchValueList.Count: Integer;
begin
Result := FList.Count;
inherited Create(AOwnerWatch);
end;
{ TWatchValue }
function TWatchValue.GetValue: String;
function TIdeWatchValue.GetValue: String;
var
i: Integer;
begin
if not FWatch.Enabled then begin
if not Watch.Enabled then begin
Result := '<disabled>';
exit;
end;
@ -3420,47 +3328,22 @@ begin
end;
function TWatchValue.GetWatchBase: TWatchBase;
function TIdeWatchValue.GetWatch: TIdeWatch;
begin
Result := FWatch;
Result := TIdeWatch(inherited Watch);
end;
function TWatchValue.GetDisplayFormat: TWatchDisplayFormat;
function TIdeWatchValue.GetExpression: String;
begin
Result := FDisplayFormat;
Result := inherited GetExpression;
end;
function TWatchValue.GetEvaluateFlags: TDBGEvaluateFlags;
begin
Result := FEvaluateFlags;
end;
function TWatchValue.GetExpression: String;
begin
Result := FWatch.Expression;
end;
function TWatchValue.GetRepeatCount: Integer;
begin
Result := FRepeatCount;
end;
function TWatchValue.GetStackFrame: Integer;
begin
Result := FStackFrame;
end;
function TWatchValue.GetThreadId: Integer;
begin
Result := FThreadId;
end;
function TWatchValue.GetTypeInfo: TDBGType;
function TIdeWatchValue.GetTypeInfo: TDBGType;
var
i: Integer;
begin
Result := nil;
if not FWatch.Enabled then
if not Watch.Enabled then
exit;
i := DbgStateChangeCounter; // workaround for state changes during TWatchValue.GetValue
if Validity = ddsUnknown then begin
@ -3477,12 +3360,12 @@ begin
end;
end;
procedure TWatchValue.RequestData;
procedure TIdeWatchValue.RequestData;
begin
Validity := ddsInvalid;
end;
procedure TWatchValue.LoadDataFromXMLConfig(const AConfig: TXMLConfig;
procedure TIdeWatchValue.LoadDataFromXMLConfig(const AConfig: TXMLConfig;
const APath: string);
var
NewValidity: TDebuggerDataState;
@ -3504,40 +3387,31 @@ begin
end;
end;
procedure TWatchValue.SaveDataToXMLConfig(const AConfig: TXMLConfig; const APath: string);
procedure TIdeWatchValue.SaveDataToXMLConfig(const AConfig: TXMLConfig; const APath: string);
var
s: String;
begin
AConfig.SetValue(APath + 'ThreadId', FThreadId);
AConfig.SetValue(APath + 'StackFrame', FStackFrame);
AConfig.SetValue(APath + 'ThreadId', ThreadId);
AConfig.SetValue(APath + 'StackFrame', StackFrame);
AConfig.SetValue(APath + 'Value', Value);
WriteStr(s{%H-}, FDisplayFormat);
WriteStr(s{%H-}, DisplayFormat);
AConfig.SetDeleteValue(APath + 'DisplayFormat', s, 'wdfDefault');
WriteStr(s, Validity);
AConfig.SetDeleteValue(APath + 'Validity', s, 'ddsValid');
AConfig.SetDeleteValue(APath + 'ClassAutoCast', defClassAutoCast in FEvaluateFlags, False);
AConfig.SetDeleteValue(APath + 'RepeatCount', FRepeatCount, 0);
AConfig.SetDeleteValue(APath + 'ClassAutoCast', defClassAutoCast in EvaluateFlags, False);
AConfig.SetDeleteValue(APath + 'RepeatCount', RepeatCount, 0);
end;
constructor TWatchValue.Create;
begin
assert(FWatch <> nil, 'TwatchValue without owner');
assert(((Self is TCurrentWatchValue) and (FWatch is TCurrentWatch)) or ((not(Self is TCurrentWatchValue)) and not(FWatch is TCurrentWatch)),
'TWatchValue.Create: Watch and self differ (current and none current)');
inherited Create;
end;
constructor TWatchValue.Create(AOwnerWatch: TWatch);
constructor TIdeWatchValue.Create(AOwnerWatch: TIdeWatch);
begin
inherited Create(AOwnerWatch);
Validity := ddsUnknown;
FWatch := AOwnerWatch;
FDisplayFormat := FWatch.DisplayFormat;
FEvaluateFlags := FWatch.EvaluateFlags;
FRepeatCount := FWatch.RepeatCount;
Create;
FDisplayFormat := Watch.DisplayFormat;
FEvaluateFlags := Watch.EvaluateFlags;
FRepeatCount := Watch.RepeatCount;
end;
constructor TWatchValue.Create(AOwnerWatch: TWatch; const AThreadId: Integer;
constructor TIdeWatchValue.Create(AOwnerWatch: TIdeWatch; const AThreadId: Integer;
const AStackFrame: Integer);
begin
Create(AOwnerWatch);
@ -3545,12 +3419,12 @@ begin
FStackFrame := AStackFrame;
end;
procedure TWatchValue.Assign(AnOther: TWatchValueBase);
procedure TIdeWatchValue.Assign(AnOther: TWatchValue);
begin
inherited Assign(AnOther);
FThreadId := TWatchValue(AnOther).FThreadId;
FStackFrame := TWatchValue(AnOther).FStackFrame;
FDisplayFormat := TWatchValue(AnOther).FDisplayFormat;
FThreadId := TIdeWatchValue(AnOther).FThreadId;
FStackFrame := TIdeWatchValue(AnOther).FStackFrame;
FDisplayFormat := TIdeWatchValue(AnOther).FDisplayFormat;
end;
{ TIdeWatchesMonitor }
@ -3797,7 +3671,7 @@ begin
FreeAndNil(FEntries);
end;
procedure TCurrentCallStack.Assign(AnOther: TIdeCallStack);
procedure TCurrentCallStack.Assign(AnOther: TCallStackBase);
begin
inherited Assign(AnOther);
if AnOther is TCurrentCallStack then begin
@ -5474,116 +5348,52 @@ end;
(******************************************************************************)
{ =========================================================================== }
{ TWatch }
{ TIdeWatch }
{ =========================================================================== }
procedure TWatch.AssignTo(Dest: TPersistent);
function TIdeWatch.CreateValueList: TWatchValueList;
begin
if Dest is TWatch
then begin
TWatch(Dest).FExpression := FExpression;
TWatch(Dest).FEnabled := FEnabled;
TWatch(Dest).FDisplayFormat := FDisplayFormat;
TWatch(Dest).FValueList.Assign(FValueList);
end
else inherited;
Result := TIdeWatchValueList.Create(Self);
end;
function TWatch.CreateValueList: TWatchValueList;
begin
Result := TWatchValueList.Create(Self);
end;
procedure TWatch.DoModified;
begin
//
end;
constructor TWatch.Create(ACollection: TCollection);
constructor TIdeWatch.Create(ACollection: TCollection);
begin
assert(((Self is TCurrentWatch) and (ACollection is TCurrentWatches)) or ((not(Self is TCurrentWatch)) and not(ACollection is TCurrentWatches)),
'Twatch.Create: Watch and collection differ (current and none current)');
FEnabled := False;
FValueList := CreateValueList;
'TIdewatch.Create: Watch and collection differ (current and none current)');
inherited Create(ACollection);
end;
destructor TWatch.Destroy;
procedure TIdeWatch.ClearValues;
begin
FValueList.Clear;
inherited Destroy;
FreeAndNil(FValueList);
end;
procedure TWatch.ClearValues;
begin
FValueList.Clear;
inherited ClearValues;
TCurrentWatches(Collection).Update(Self);
end;
procedure TWatch.DoEnableChange;
procedure TIdeWatch.DoEnableChange;
begin
Changed;
DoModified;
end;
procedure TWatch.DoExpressionChange;
procedure TIdeWatch.DoExpressionChange;
begin
Changed;
DoModified;
end;
procedure TWatch.DoDisplayFormatChanged;
procedure TIdeWatch.DoDisplayFormatChanged;
begin
Changed;
DoModified;
end;
function TWatch.GetEnabled: Boolean;
function TIdeWatch.GetValue(const AThreadId: Integer; const AStackFrame: Integer): TIdeWatchValue;
begin
Result := FEnabled;
Result := TIdeWatchValue(inherited Values[AThreadId, AStackFrame]);
end;
function TWatch.GetEvaluateFlags: TDBGEvaluateFlags;
begin
Result := FEvaluateFlags;
end;
function TWatch.GetValue(const AThreadId: Integer; const AStackFrame: Integer): TWatchValue;
begin
Result := FValueList[AThreadId, AStackFrame];
end;
procedure TWatch.SetEvaluateFlags(AValue: TDBGEvaluateFlags);
begin
if FEvaluateFlags = AValue then Exit;
FEvaluateFlags := AValue;
Changed;
DoModified;
end;
procedure TWatch.SetRepeatCount(AValue: Integer);
begin
if FRepeatCount = AValue then Exit;
FRepeatCount := AValue;
Changed;
DoModified;
end;
function TWatch.GetDisplayFormat: TWatchDisplayFormat;
begin
Result := FDisplayFormat;
end;
procedure TWatch.SetDisplayFormat(AValue: TWatchDisplayFormat);
begin
if AValue = FDisplayFormat then exit;
FDisplayFormat := AValue;
DoDisplayFormatChanged;
end;
procedure TWatch.LoadDataFromXMLConfig(const AConfig: TXMLConfig; const APath: string);
procedure TIdeWatch.LoadDataFromXMLConfig(const AConfig: TXMLConfig; const APath: string);
begin
FEnabled := AConfig.GetValue(APath + 'Enabled', True);
FExpression := AConfig.GetValue(APath + 'Expression', '');
@ -5594,10 +5404,10 @@ begin
except FDisplayFormat := wdfDefault; end;
FRepeatCount := AConfig.GetValue(APath + 'RepeatCount', 0);
FValueList.LoadDataFromXMLConfig(AConfig, APath + 'ValueList/');
TIdeWatchValueList(FValueList).LoadDataFromXMLConfig(AConfig, APath + 'ValueList/');
end;
procedure TWatch.SaveDataToXMLConfig(const AConfig: TXMLConfig; const APath: string);
procedure TIdeWatch.SaveDataToXMLConfig(const AConfig: TXMLConfig; const APath: string);
var
s: String;
begin
@ -5608,49 +5418,14 @@ begin
AConfig.SetDeleteValue(APath + 'ClassAutoCast', defClassAutoCast in FEvaluateFlags, False);
AConfig.SetDeleteValue(APath + 'RepeatCount', FRepeatCount, 0);
FValueList.SaveDataToXMLConfig(AConfig, APath + 'ValueList/');
end;
function TWatch.GetExpression: String;
begin
Result := FExpression;
end;
function TWatch.GetRepeatCount: Integer;
begin
Result := FRepeatCount;
end;
function TWatch.GetValueBase(const AThreadId: Integer;
const AStackFrame: Integer): TWatchValueBase;
begin
Result := TWatchValueBase(FValueList[AThreadId, AStackFrame]);
end;
procedure TWatch.SetEnabled(AValue: Boolean);
begin
if FEnabled <> AValue
then begin
FEnabled := AValue;
DoEnableChange;
end;
end;
procedure TWatch.SetExpression(AValue: String);
begin
if AValue <> FExpression
then begin
FExpression := AValue;
FValueList.Clear;
DoExpressionChange;
end;
TIdeWatchValueList(FValueList).SaveDataToXMLConfig(AConfig, APath + 'ValueList/');
end;
{ =========================================================================== }
{ TCurrentWatch }
{ =========================================================================== }
procedure TCurrentWatch.SetSnapShot(const AValue: TWatch);
procedure TCurrentWatch.SetSnapShot(const AValue: TIdeWatch);
begin
assert((FSnapShot=nil) or (AValue=nil), 'TCurrentWatch already have snapshot');
if FSnapShot = AValue then exit;
@ -5661,11 +5436,11 @@ begin
// TODO: FValueList is copied twice ?
FSnapShot.Assign(self);
FSnapShot.Enabled := True; // Snapshots are always enabled
TCurrentWatchValueList(FValueList).SnapShot := FSnapShot.FValueList;
TCurrentWatchValueList(FValueList).SnapShot := TIdeWatchValueList(FSnapShot.FValueList);
end;
end;
function TCurrentWatch.CreateValueList: TWatchValueList;
function TCurrentWatch.CreateValueList: TIdeWatchValueList;
begin
Result := TCurrentWatchValueList.Create(Self);
end;
@ -5737,27 +5512,27 @@ end;
{ TIdeWatches }
{ =========================================================================== }
function TIdeWatches.Add(const AExpression: String): TWatch;
function TIdeWatches.Add(const AExpression: String): TIdeWatch;
begin
BeginUpdate;
Result := TWatch(inherited Add);
Result := TIdeWatch(inherited Add);
Result.Expression := AExpression;
EndUpdate;
end;
function TIdeWatches.GetItem(const AnIndex: Integer): TWatch;
function TIdeWatches.GetItem(const AnIndex: Integer): TIdeWatch;
begin
Result := TWatch(inherited Items[AnIndex]);
Result := TIdeWatch(inherited Items[AnIndex]);
end;
procedure TIdeWatches.SetItem(const AnIndex: Integer; const AValue: TWatch);
procedure TIdeWatches.SetItem(const AnIndex: Integer; const AValue: TIdeWatch);
begin
inherited Items[AnIndex] := AValue;
end;
function TIdeWatches.WatchClass: TBaseWatchClass;
begin
Result := TWatch;
Result := TIdeWatch;
end;
procedure TIdeWatches.LoadDataFromXMLConfig(const AConfig: TXMLConfig; APath: string);
@ -5781,7 +5556,7 @@ begin
Items[i].SaveDataToXMLConfig(AConfig, APath + IntToStr(i) + '/');
end;
function TIdeWatches.Find(const AExpression: String): TWatch;
function TIdeWatches.Find(const AExpression: String): TIdeWatch;
var
n: Integer;
S: String;
@ -5789,7 +5564,7 @@ begin
S := UpperCase(AExpression);
for n := 0 to Count - 1 do
begin
Result := TWatch(GetItem(n));
Result := TIdeWatch(GetItem(n));
if UpperCase(Result.Expression) = S
then Exit;
end;
@ -5801,7 +5576,7 @@ var
n: Integer;
begin
for n := 0 to Count - 1 do
TWatch(GetItem(n)).ClearValues;
TIdeWatch(GetItem(n)).ClearValues;
end;
{ =========================================================================== }
@ -5810,7 +5585,7 @@ end;
function TCurrentWatches.Add(const AExpression: String): TCurrentWatch;
var
R: TWatch;
R: TIdeWatch;
begin
// if this is modified, then also update LoadFromXMLConfig
Result := TCurrentWatch(inherited Add(AExpression));
@ -5847,7 +5622,7 @@ end;
procedure TCurrentWatches.SetSnapShot(const AValue: TIdeWatches);
var
R: TWatch;
R: TIdeWatch;
i: Integer;
begin
assert((FSnapShot=nil) or (AValue=nil), 'TCurrentWatches already have snapshot');

View File

@ -2027,7 +2027,7 @@ var
rx: TRegExpr;
s, s2: String;
flag, IsValid, HasTpInfo, f2: Boolean;
WV: TWatchValue;
WV: TIdeWatchValue;
Stack: Integer;
n: String;
DataRes: TWatchExpectationResult;

View File

@ -142,12 +142,12 @@ type
function GetThreadId: Integer;
function GetSelectedThreads(Snap: TSnapshot): TIdeThreads;
function GetStackframe: Integer;
procedure WatchAdd(const ASender: TIdeWatches; const AWatch: TWatch);
procedure WatchUpdate(const ASender: TIdeWatches; const AWatch: TWatch);
procedure WatchRemove(const ASender: TIdeWatches; const AWatch: TWatch);
procedure WatchAdd(const ASender: TIdeWatches; const AWatch: TIdeWatch);
procedure WatchUpdate(const ASender: TIdeWatches; const AWatch: TIdeWatch);
procedure WatchRemove(const ASender: TIdeWatches; const AWatch: TIdeWatch);
procedure UpdateInspectPane;
procedure UpdateItem(const AItem: TListItem; const AWatch: TWatch);
procedure UpdateItem(const AItem: TListItem; const AWatch: TIdeWatch);
procedure UpdateAll;
procedure DisableAllActions;
function GetSelectedSnapshot: TSnapshot;
@ -728,7 +728,7 @@ procedure TWatchesDlg.UpdateInspectPane;
var
Watch: TCurrentWatch;
i: integer;
d: TWatchValue;
d: TIdeWatchValue;
t: TDBGType;
begin
if not nbInspect.Visible then exit;
@ -789,7 +789,7 @@ begin
end;
end;
procedure TWatchesDlg.UpdateItem(const AItem: TListItem; const AWatch: TWatch);
procedure TWatchesDlg.UpdateItem(const AItem: TListItem; const AWatch: TIdeWatch);
function ClearMultiline(const AValue: ansistring): ansistring;
var
j: SizeInt;
@ -821,7 +821,7 @@ procedure TWatchesDlg.UpdateItem(const AItem: TListItem; const AWatch: TWatch);
end;
end;
var
WatchValue: TWatchValue;
WatchValue: TIdeWatchValue;
begin
DebugBoss.LockCommandProcessing;
try
@ -911,7 +911,7 @@ begin
then Result := SnapshotManager.SelectedEntry;
end;
procedure TWatchesDlg.WatchAdd(const ASender: TIdeWatches; const AWatch: TWatch);
procedure TWatchesDlg.WatchAdd(const ASender: TIdeWatches; const AWatch: TIdeWatch);
var
Item: TListItem;
begin
@ -928,7 +928,7 @@ begin
lvWatchesSelectItem(nil, nil, False);
end;
procedure TWatchesDlg.WatchUpdate(const ASender: TIdeWatches; const AWatch: TWatch);
procedure TWatchesDlg.WatchUpdate(const ASender: TIdeWatches; const AWatch: TIdeWatch);
var
Item: TListItem;
begin
@ -948,7 +948,7 @@ begin
finally DebugLnExit(DBG_DATA_MONITORS, ['DebugDataWindow: TWatchesDlg.WatchUpdate']); end;
end;
procedure TWatchesDlg.WatchRemove(const ASender: TIdeWatches; const AWatch: TWatch);
procedure TWatchesDlg.WatchRemove(const ASender: TIdeWatches; const AWatch: TIdeWatch);
begin
lvWatches.Items.FindData(AWatch).Free;
lvWatchesSelectItem(nil, nil, False);

View File

@ -61,9 +61,9 @@ type
procedure btnHelpClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
private
FWatch: TWatch;
FWatch: TIdeWatch;
public
constructor Create(AOWner: TComponent; const AWatch: TWatch; const AWatchExpression: String = ''); overload;
constructor Create(AOWner: TComponent; const AWatch: TIdeWatch; const AWatchExpression: String = ''); overload;
destructor Destroy; override;
end;
@ -107,7 +107,7 @@ begin
LazarusHelp.ShowHelpForIDEControl(Self);
end;
constructor TWatchPropertyDlg.Create(AOwner: TComponent; const AWatch: TWatch;
constructor TWatchPropertyDlg.Create(AOwner: TComponent; const AWatch: TIdeWatch;
const AWatchExpression: String = '');
const
DispFormatToStyle: Array [TWatchDisplayFormat] of Integer =