1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
{***************************************************************************
* *
* This unit is distributed under the LGPL version 2 *
* *
* Additionally this unit can be used under any newer version (3 or up) *
* of the LGPL *
* *
* Users are also granted the same "linking exception" as defined *
* for the LCL. *
* See the LCL license for details *
* *
* *
***************************************************************************
@author(Martin Friebe)
}
unit LazDebuggerTemplate;
{$mode objfpc}{$H+}
{$INTERFACES CORBA} // no ref counting needed
interface
uses
Classes, SysUtils, fgl, LazDebuggerIntf;
type
{ TDbgDataRequestTemplateBase }
generic TDbgDataRequestTemplateBase<_BASE: TObject; _SENDER_INTF: IDbgDataRequestIntf> = class(_BASE)
private type
TDbgDataRequestEventList = specialize TFPGList<TDbgDataRequestEvent>;
strict private
FEventLists: array [TDbgDataRequestEventType] of TDbgDataRequestEventList;
FUpdateCount: Integer;
function GetIsUpdating: boolean; inline;
protected
procedure SetSliceIndexPos(APos, ALen: Integer); (* IDbgWatchValueIntf *)
procedure AddNotification(AnEventType: TDbgDataRequestEventType; AnEvent: TDbgDataRequestEvent);
procedure RemoveNotification(AnEventType: TDbgDataRequestEventType; AnEvent: TDbgDataRequestEvent);
procedure CallNotifications(AnEventType: TDbgDataRequestEventType; AnEventData: TDbgDataRequestEventData);
procedure BeginUpdate;
procedure EndUpdate;
procedure DoBeginUpdating; virtual;
procedure DoEndUpdating; virtual;
property UpdateCount: Integer read FUpdateCount;
property IsUpdating: boolean read GetIsUpdating;
procedure DoDestroy; // FPC can not compile "destructor Destroy; override;"
end;
{ TDbgDataRequestTemplate }
generic TDbgDataRequestTemplate<_BASE: TObject; _SENDER_INTF: IDbgDataRequestIntf>
= class(specialize TDbgDataRequestTemplateBase<_BASE, _SENDER_INTF>, IDbgDataRequestIntf)
private type
TNotifyEventList = specialize TFPGList<TNotifyEvent>;
strict private
FFreeNotifyList: TNotifyEventList;
protected
procedure AddFreeNotification(ANotification: TNotifyEvent);
procedure RemoveFreeNotification(ANotification: TNotifyEvent);
procedure CallFreeNotifications;
procedure DoDestroy; // FPC can not compile "destructor Destroy; override;"
end;
{ TInternalDbgMonitorBase }
generic TInternalDbgMonitorBase<
_BASE: TObject;
_MONITOR_INTF: IInternalDbgMonitorIntfType;
_SUPPLIER_INTF//: IInternalDbgSupplierIntfType
>
= class(_BASE)
strict private
FSupplier: _SUPPLIER_INTF;
protected
procedure SetSupplier(ASupplier: _SUPPLIER_INTF);
procedure RemoveSupplier(ASupplier: _SUPPLIER_INTF);
protected
procedure DoNewSupplier; virtual;
procedure DoDestroy; // FPC can not compile "destructor Destroy; override;"
public
property Supplier: _SUPPLIER_INTF read FSupplier write SetSupplier;
end;
{ TInternalDbgSupplierBase }
generic TInternalDbgSupplierBase<
_BASE: TObject;
_SUPPLIER_INTF: IInternalDbgSupplierIntfType;
_MONITOR_INTF //: IInternalDbgMonitorIntfType
>
= class(_BASE)
strict private
FMonitor: _MONITOR_INTF;
protected
procedure SetMonitor(AMonitor: _MONITOR_INTF);
protected
procedure DoNewMonitor; virtual;
procedure DoDestroy; // FPC can not compile "destructor Destroy; override;"
property Monitor: _MONITOR_INTF read FMonitor;
end;
type
{ TWatchesMonitorClassTemplate }
generic TWatchesMonitorClassTemplate<_BASE: TObject> = class(
specialize TInternalDbgMonitorBase<_BASE, IDbgWatchesMonitorIntf, IDbgWatchesSupplierIntf>,
IDbgWatchesMonitorIntf
)
protected
procedure InvalidateWatchValues; virtual;
procedure DoStateChange(const AOldState, ANewState: TDBGState); virtual; // deprecated;
end;
{ TWatchesSupplierClassTemplate }
generic TWatchesSupplierClassTemplate<_BASE: TObject> = class(
specialize TInternalDbgSupplierBase<_BASE, IDbgWatchesSupplierIntf, IDbgWatchesMonitorIntf>,
IDbgWatchesSupplierIntf
)
protected
public
procedure RequestData(AWatchValue: IDbgWatchValueIntf); virtual;
procedure TriggerInvalidateWatchValues; virtual;
end;
{ TLocalsMonitorClassTemplate }
generic TLocalsMonitorClassTemplate<_BASE: TObject> = class(
specialize TInternalDbgMonitorBase<_BASE, IDbgLocalsMonitorIntf, IDbgLocalsSupplierIntf>,
IDbgLocalsMonitorIntf
)
protected
procedure InvalidateLocalValues; virtual;
procedure DoStateChange(const AOldState, ANewState: TDBGState); virtual; // deprecated;
end;
{ TLocalsSupplierClassTemplate }
generic TLocalsSupplierClassTemplate<_BASE: TObject> = class(
specialize TInternalDbgSupplierBase<_BASE, IDbgLocalsSupplierIntf, IDbgLocalsMonitorIntf>,
IDbgLocalsSupplierIntf
)
protected
public
procedure RequestData(ALocalsList: IDbgLocalsListIntf); virtual;
procedure TriggerInvalidateLocalsValues; virtual;
end;
implementation
{ TDbgDataRequestTemplateBase }
function TDbgDataRequestTemplateBase.GetIsUpdating: boolean;
begin
Result := FUpdateCount > 0;
end;
procedure TDbgDataRequestTemplateBase.SetSliceIndexPos(APos, ALen: Integer);
begin
//
end;
procedure TDbgDataRequestTemplateBase.AddNotification(
AnEventType: TDbgDataRequestEventType; AnEvent: TDbgDataRequestEvent);
begin
if FEventLists[AnEventType] = nil then
FEventLists[AnEventType] := TDbgDataRequestEventList.Create;
FEventLists[AnEventType].Add(AnEvent);
end;
procedure TDbgDataRequestTemplateBase.RemoveNotification(
AnEventType: TDbgDataRequestEventType; AnEvent: TDbgDataRequestEvent);
begin
if FEventLists[AnEventType] = nil then
exit;
FEventLists[AnEventType].Remove(AnEvent);
end;
procedure TDbgDataRequestTemplateBase.CallNotifications(
AnEventType: TDbgDataRequestEventType; AnEventData: TDbgDataRequestEventData);
var
i: integer;
begin
if FEventLists[AnEventType] = nil then
exit;
for i := FEventLists[AnEventType].Count - 1 downto 0 do
FEventLists[AnEventType][i](Self as _SENDER_INTF, AnEventData)
end;
procedure TDbgDataRequestTemplateBase.BeginUpdate;
begin
inc(FUpdateCount);
if FUpdateCount = 1 then
DoBeginUpdating;
end;
procedure TDbgDataRequestTemplateBase.EndUpdate;
begin
dec(FUpdateCount);
if FUpdateCount = 0 then
DoEndUpdating;
end;
procedure TDbgDataRequestTemplateBase.DoBeginUpdating;
begin
//
end;
procedure TDbgDataRequestTemplateBase.DoEndUpdating;
begin
//
end;
procedure TDbgDataRequestTemplateBase.DoDestroy;
var
i: TDbgDataRequestEventType;
begin
for i := low(TDbgDataRequestEventType) to high(TDbgDataRequestEventType) do
FEventLists[i].Free;
end;
{ TDbgDataRequestTemplate }
procedure TDbgDataRequestTemplate.AddFreeNotification(
ANotification: TNotifyEvent);
begin
if FFreeNotifyList = nil then
FFreeNotifyList := TNotifyEventList.Create;
FFreeNotifyList.Add(ANotification);
end;
procedure TDbgDataRequestTemplate.RemoveFreeNotification(
ANotification: TNotifyEvent);
begin
if FFreeNotifyList = nil then
exit;
FFreeNotifyList.Remove(ANotification);
end;
procedure TDbgDataRequestTemplate.CallFreeNotifications;
var
i: integer;
begin
if FFreeNotifyList = nil then
exit;
for i := FFreeNotifyList.Count - 1 downto 0 do
FFreeNotifyList[i](nil)
end;
procedure TDbgDataRequestTemplate.DoDestroy;
begin
FFreeNotifyList.Free;
inherited DoDestroy;
end;
{ TInternalDbgMonitorBase }
procedure TInternalDbgMonitorBase.SetSupplier(ASupplier: _SUPPLIER_INTF);
begin
if FSupplier = ASupplier then exit;
assert((FSupplier=nil) or (ASupplier=nil), 'TInternalDbgMonitorBase.SetSupplier: (FSupplier=nil) or (ASupplier=nil)');
if FSupplier <> nil then FSupplier.SetMonitor(nil);
FSupplier := ASupplier;
if FSupplier <> nil then FSupplier.SetMonitor(Self as _MONITOR_INTF);
DoNewSupplier;
end;
procedure TInternalDbgMonitorBase.RemoveSupplier(ASupplier: _SUPPLIER_INTF);
begin
if Supplier = ASupplier then
Supplier := nil;
end;
procedure TInternalDbgMonitorBase.DoNewSupplier;
begin
//
end;
procedure TInternalDbgMonitorBase.DoDestroy;
begin
Supplier := nil;
end;
{ TInternalDbgSupplierBase }
procedure TInternalDbgSupplierBase.SetMonitor(AMonitor: _MONITOR_INTF);
begin
if FMonitor = AMonitor then exit;
assert((FMonitor=nil) or (AMonitor=nil), 'TInternalDbgSupplierBase.SetMonitor: (FMonitor=nil) or (AMonitor=nil)');
FMonitor := AMonitor;
DoNewMonitor;
end;
procedure TInternalDbgSupplierBase.DoNewMonitor;
begin
//
end;
procedure TInternalDbgSupplierBase.DoDestroy;
begin
if FMonitor <> nil then
FMonitor.RemoveSupplier(Self as _SUPPLIER_INTF);
end;
{ TWatchesMonitorClassTemplate }
procedure TWatchesMonitorClassTemplate.InvalidateWatchValues;
begin
//
end;
procedure TWatchesMonitorClassTemplate.DoStateChange(const AOldState,
ANewState: TDBGState);
begin
//
end;
{ TWatchesSupplierClassTemplate }
procedure TWatchesSupplierClassTemplate.RequestData(AWatchValue: IDbgWatchValueIntf);
begin
AWatchValue.Validity := ddsError;
end;
procedure TWatchesSupplierClassTemplate.TriggerInvalidateWatchValues;
begin
if (Self <> nil) and (Monitor <> nil) then
Monitor.InvalidateWatchValues;
end;
{ TLocalsMonitorClassTemplate }
procedure TLocalsMonitorClassTemplate.InvalidateLocalValues;
begin
//
end;
procedure TLocalsMonitorClassTemplate.DoStateChange(const AOldState,
ANewState: TDBGState);
begin
//
end;
{ TLocalsSupplierClassTemplate }
procedure TLocalsSupplierClassTemplate.RequestData(ALocalsList: IDbgLocalsListIntf
);
begin
ALocalsList.Validity := ddsError;
end;
procedure TLocalsSupplierClassTemplate.TriggerInvalidateLocalsValues;
begin
if (Self <> nil) and (Monitor <> nil) then
Monitor.InvalidateLocalValues;
end;
end.
|