mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-25 03:39:14 +02:00
MWE: + Added exception break
* Reworked adding/removing breakpoints + Added Unknown breakpoint type git-svn-id: trunk@4199 -
This commit is contained in:
parent
0a5e30f800
commit
0ee08ef013
@ -238,16 +238,17 @@ type
|
||||
FNotificationList: TList;
|
||||
function GetItem(const AnIndex: Integer): TDBGBreakPoint;
|
||||
procedure SetItem(const AnIndex: Integer; const AValue: TDBGBreakPoint);
|
||||
procedure Removed(const ABreakpoint: TDBGBreakPoint); // called by breakpoint when destructed
|
||||
procedure NotifyRemove(const ABreakpoint: TDBGBreakPoint); // called by breakpoint when destructed
|
||||
procedure NotifyAdd(const ABreakPoint: TDBGBreakPoint); // called when a breakpoint is added
|
||||
protected
|
||||
procedure DoStateChange; virtual;
|
||||
procedure Update(Item: TCollectionItem); override;
|
||||
property Debugger: TDebugger read FDebugger;
|
||||
public
|
||||
constructor Create(const ADebugger: TDebugger;
|
||||
const ABreakPointClass: TDBGBreakPointClass);
|
||||
destructor Destroy; override;
|
||||
function Add(const ASource: String; const ALine: Integer): TDBGBreakPoint;
|
||||
procedure Add(NewBreakPoint: TDBGBreakPoint);
|
||||
function Find(const ASource: String; const ALine: Integer): TDBGBreakPoint;
|
||||
function FindBreakPoint(const ASource: String; const ALine: Integer;
|
||||
Ignore: TDBGBreakPoint): TDBGBreakPoint;
|
||||
@ -986,7 +987,7 @@ end;
|
||||
destructor TDBGBreakPoint.Destroy;
|
||||
begin
|
||||
if (TDBGBreakPoints(Collection) <> nil)
|
||||
then TDBGBreakPoints(Collection).Removed(Self);
|
||||
then TDBGBreakPoints(Collection).NotifyRemove(Self);
|
||||
|
||||
if FGroup <> nil
|
||||
then FGroup.Remove(Self);
|
||||
@ -1294,20 +1295,7 @@ begin
|
||||
Result := TDBGBreakPoint(inherited Add);
|
||||
writeln('TDBGBreakPoints.Add ',Result.ClassName,' ',ASource,' ',ALine);
|
||||
Result.SetLocation(ASource, ALine);
|
||||
Add(Result);
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoints.Add(NewBreakPoint: TDBGBreakPoint);
|
||||
var
|
||||
n: Integer;
|
||||
Notification: TDBGBreakPointsNotification;
|
||||
begin
|
||||
for n := 0 to FNotificationList.Count - 1 do
|
||||
begin
|
||||
Notification := TDBGBreakPointsNotification(FNotificationList[n]);
|
||||
if Assigned(Notification.FOnAdd)
|
||||
then Notification.FOnAdd(Self, NewBreakPoint);
|
||||
end;
|
||||
NotifyAdd(Result);
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoints.AddNotification(
|
||||
@ -1372,7 +1360,20 @@ begin
|
||||
Result := TDBGBreakPoint(inherited GetItem(AnIndex));
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoints.Removed(const ABreakpoint: TDBGBreakPoint);
|
||||
procedure TDBGBreakPoints.NotifyAdd(const ABreakPoint: TDBGBreakPoint);
|
||||
var
|
||||
n: Integer;
|
||||
Notification: TDBGBreakPointsNotification;
|
||||
begin
|
||||
for n := 0 to FNotificationList.Count - 1 do
|
||||
begin
|
||||
Notification := TDBGBreakPointsNotification(FNotificationList[n]);
|
||||
if Assigned(Notification.FOnAdd)
|
||||
then Notification.FOnAdd(Self, ABreakPoint);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDBGBreakPoints.NotifyRemove(const ABreakpoint: TDBGBreakPoint);
|
||||
var
|
||||
n: Integer;
|
||||
Notification: TDBGBreakPointsNotification;
|
||||
@ -1413,8 +1414,9 @@ begin
|
||||
writeln('TDBGBreakPoints.LoadFromXMLConfig i=',i,' ',
|
||||
NewBreakPoint.InitialEnabled,' ',NewBreakPoint.Source,' ',NewBreakPoint.Line,
|
||||
' OldBreakPoint=',OldBreakPoint<>nil);
|
||||
if OldBreakPoint<>nil then NewBreakPoint.Free;
|
||||
Add(NewBreakPoint);
|
||||
if OldBreakPoint <> nil
|
||||
then NewBreakPoint.Free
|
||||
else NotifyAdd(NewBreakPoint);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2166,6 +2168,11 @@ end;
|
||||
end.
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.28 2003/05/27 08:01:31 marc
|
||||
MWE: + Added exception break
|
||||
* Reworked adding/removing breakpoints
|
||||
+ Added Unknown breakpoint type
|
||||
|
||||
Revision 1.27 2003/05/26 20:05:21 mattias
|
||||
made compiling gtk2 interface easier
|
||||
|
||||
|
@ -67,6 +67,10 @@ type
|
||||
procedure EndDebugging; virtual; abstract;
|
||||
function Evaluate(const AExpression: String; var AResult: String): Boolean; virtual; abstract; // Evaluates the given expression, returns true if valid
|
||||
|
||||
function DoCreateBreakPoint(const AFilename: string; ALine: integer): TModalResult; virtual; abstract;
|
||||
function DoDeleteBreakPoint(const AFilename: string; ALine: integer): TModalResult; virtual; abstract;
|
||||
function DoCreateWatch(const AExpression: string): TModalResult; virtual; abstract;
|
||||
|
||||
property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger
|
||||
property State: TDBGState read GetState; // The current state of the debugger
|
||||
|
||||
|
@ -64,10 +64,6 @@ type
|
||||
|
||||
// SrcNotebook events
|
||||
function OnSrcNotebookAddWatchesAtCursor(Sender: TObject): boolean;
|
||||
function OnSrcNotebookCreateBreakPoint(Sender: TObject;
|
||||
Line: Integer): boolean;
|
||||
function OnSrcNotebookDeleteBreakPoint(Sender: TObject;
|
||||
Line: Integer): boolean;
|
||||
|
||||
// Debugger events
|
||||
procedure OnDebuggerChangeState(ADebugger: TDebugger; OldState: TDBGState);
|
||||
@ -123,10 +119,10 @@ type
|
||||
var AResult: String): Boolean; override;
|
||||
|
||||
function DoCreateBreakPoint(const AFilename: string;
|
||||
Line: integer): TModalResult;
|
||||
ALine: integer): TModalResult; override;
|
||||
function DoDeleteBreakPoint(const AFilename: string;
|
||||
Line: integer): TModalResult;
|
||||
function DoCreateWatch(const VariableName: string): TModalResult;
|
||||
ALine: integer): TModalResult; override;
|
||||
function DoCreateWatch(const AExpression: string): TModalResult; override;
|
||||
end;
|
||||
|
||||
|
||||
@ -177,32 +173,6 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TDebugManager.OnSrcNotebookCreateBreakPoint(Sender: TObject;
|
||||
Line: Integer): boolean;
|
||||
var
|
||||
AFilename: String;
|
||||
begin
|
||||
Result:=false;
|
||||
if SourceNotebook.Notebook = nil then Exit;
|
||||
|
||||
AFilename:=TSourceNotebook(Sender).GetActiveSE.FileName;
|
||||
if DoCreateBreakPoint(AFilename,Line)<>mrOk then exit;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TDebugManager.OnSrcNotebookDeleteBreakPoint(Sender: TObject;
|
||||
Line: Integer): boolean;
|
||||
var
|
||||
AFilename: String;
|
||||
begin
|
||||
Result:=false;
|
||||
if SourceNotebook.Notebook = nil then Exit;
|
||||
|
||||
AFilename:=TSourceNotebook(Sender).GetActiveSE.FileName;
|
||||
if DoDeleteBreakPoint(AFilename,Line)<>mrOk then exit;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Debugger events
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -233,6 +203,8 @@ const
|
||||
STATENAME: array[TDBGState] of string = (
|
||||
'dsNone', 'dsIdle', 'dsStop', 'dsPause', 'dsRun', 'dsError'
|
||||
);
|
||||
var
|
||||
Editor: TSourceEditor;
|
||||
begin
|
||||
if (ADebugger<>FDebugger) or (ADebugger=nil) then
|
||||
RaiseException('TDebugManager.OnDebuggerChangeState');
|
||||
@ -272,6 +244,15 @@ begin
|
||||
// unhide IDE
|
||||
MainIDE.UnhideIDE;
|
||||
end;
|
||||
|
||||
// unmark execution line
|
||||
if (FDebugger.State <> dsPause)
|
||||
and (SourceNotebook <> nil)
|
||||
then begin
|
||||
Editor := SourceNotebook.GetActiveSE;
|
||||
if Editor <> nil
|
||||
then Editor.ExecutionLine := -1;
|
||||
end;
|
||||
|
||||
case FDebugger.State of
|
||||
|
||||
@ -303,6 +284,7 @@ var
|
||||
S, SrcFile: String;
|
||||
OpenDialog: TOpenDialog;
|
||||
NewSource: TCodeBuffer;
|
||||
Editor: TSourceEditor;
|
||||
n: Integer;
|
||||
begin
|
||||
if (Sender<>FDebugger) or (Sender=nil) then exit;
|
||||
@ -383,8 +365,14 @@ begin
|
||||
// jump editor to execution line
|
||||
if MainIDE.DoJumpToCodePos(nil,nil,NewSource,1,ALocation.SrcLine,-1,true)
|
||||
<>mrOk then exit;
|
||||
|
||||
// mark execution line
|
||||
SourceNotebook.GetActiveSE.ExecutionLine:=ALocation.SrcLine;
|
||||
if SourceNotebook <> nil
|
||||
then Editor := SourceNotebook.GetActiveSE
|
||||
else Editor := nil;
|
||||
|
||||
if Editor <> nil
|
||||
then Editor.ExecutionLine:=ALocation.SrcLine;
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -499,8 +487,6 @@ end;
|
||||
procedure TDebugManager.ConnectSourceNotebookEvents;
|
||||
begin
|
||||
SourceNotebook.OnAddWatchAtCursor := @OnSrcNotebookAddWatchesAtCursor;
|
||||
SourceNotebook.OnCreateBreakPoint := @OnSrcNotebookCreateBreakPoint;
|
||||
SourceNotebook.OnDeleteBreakPoint := @OnSrcNotebookDeleteBreakPoint;
|
||||
end;
|
||||
|
||||
procedure TDebugManager.SetupMainBarShortCuts;
|
||||
@ -845,45 +831,45 @@ begin
|
||||
and FDebugger.Evaluate(AExpression, AResult);
|
||||
end;
|
||||
|
||||
function TDebugManager.DoCreateBreakPoint(const AFilename: string; Line: integer
|
||||
function TDebugManager.DoCreateBreakPoint(const AFilename: string; ALine: integer
|
||||
): TModalResult;
|
||||
var
|
||||
NewBreak: TDBGBreakPoint;
|
||||
begin
|
||||
if FBreakPoints.Find(AFilename,Line)<>nil then begin
|
||||
if FBreakPoints.Find(AFilename, ALine)<>nil then begin
|
||||
Result:=mrOk;
|
||||
exit;
|
||||
end;
|
||||
Result:=DoBeginChangeDebugger;
|
||||
if Result<>mrOk then exit;
|
||||
NewBreak := FBreakPoints.Add(AFilename,Line);
|
||||
NewBreak := FBreakPoints.Add(AFilename, ALine);
|
||||
NewBreak.InitialEnabled := True;
|
||||
NewBreak.Enabled := True;
|
||||
Project1.Modified:=true;
|
||||
Result:=DoEndChangeDebugger;
|
||||
end;
|
||||
|
||||
function TDebugManager.DoDeleteBreakPoint(const AFilename: string; Line: integer
|
||||
function TDebugManager.DoDeleteBreakPoint(const AFilename: string; ALine: integer
|
||||
): TModalResult;
|
||||
var
|
||||
OldBreakPoint: TDBGBreakPoint;
|
||||
begin
|
||||
Result:=DoBeginChangeDebugger;
|
||||
if Result<>mrOk then exit;
|
||||
OldBreakPoint:=FBreakPoints.Find(AFilename,Line);
|
||||
OldBreakPoint:=FBreakPoints.Find(AFilename,ALine);
|
||||
if OldBreakPoint=nil then exit;
|
||||
OldBreakPoint.Free;
|
||||
Project1.Modified:=true;
|
||||
Result:=DoEndChangeDebugger;
|
||||
end;
|
||||
|
||||
function TDebugManager.DoCreateWatch(const VariableName: string): TModalResult;
|
||||
function TDebugManager.DoCreateWatch(const AExpression: string): TModalResult;
|
||||
var
|
||||
NewWatch: TDBGWatch;
|
||||
begin
|
||||
Result:=DoBeginChangeDebugger;
|
||||
if Result<>mrOk then exit;
|
||||
NewWatch := FWatches.Add(VariableName);
|
||||
NewWatch := FWatches.Add(AExpression);
|
||||
NewWatch.Enabled := True;
|
||||
NewWatch.InitialEnabled := True;
|
||||
Project1.Modified:=true;
|
||||
@ -941,6 +927,11 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.28 2003/05/27 08:01:31 marc
|
||||
MWE: + Added exception break
|
||||
* Reworked adding/removing breakpoints
|
||||
+ Added Unknown breakpoint type
|
||||
|
||||
Revision 1.27 2003/05/26 11:08:20 mattias
|
||||
fixed double breakpoints
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
{ $Id$ }
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
@ -60,7 +61,7 @@ type
|
||||
lshCPP, lshPerl, lshJava);
|
||||
|
||||
TAdditionalHilightAttribute = (ahaNone, ahaTextBlock, ahaExecutionPoint,
|
||||
ahaEnabledBreakpoint, ahaDisabledBreakpoint, ahaInvalidBreakpoint,
|
||||
ahaEnabledBreakpoint, ahaDisabledBreakpoint, ahaInvalidBreakpoint, ahaUnknownBreakpoint,
|
||||
ahaErrorLine);
|
||||
|
||||
const
|
||||
@ -74,6 +75,7 @@ const
|
||||
'Enabled breakpoint',
|
||||
'Disabled breakpoint',
|
||||
'Invalid breakpoint',
|
||||
'Unknown breakpoint',
|
||||
'Error line'
|
||||
);
|
||||
|
||||
@ -767,6 +769,7 @@ begin
|
||||
' Inc(X); { Enabled breakpoint }'#13+
|
||||
' Dec(X); { Disabled breakpoint }'#13+
|
||||
' // { Invalid breakpoint }'#13+
|
||||
' WriteLN(X); { Unknown breakpoint }'#13+
|
||||
' X := X + 1.0; { Error line }'#13+
|
||||
' ListBox1.Items.Add(IntToStr(X));'#13+
|
||||
' end;'#13+
|
||||
@ -775,7 +778,8 @@ begin
|
||||
AddAttrSampleLines[ahaDisabledBreakpoint]:=18;
|
||||
AddAttrSampleLines[ahaEnabledBreakpoint]:=17;
|
||||
AddAttrSampleLines[ahaInvalidBreakpoint]:=19;
|
||||
AddAttrSampleLines[ahaErrorLine]:=20;
|
||||
AddAttrSampleLines[ahaUnknownBreakpoint]:=20;
|
||||
AddAttrSampleLines[ahaErrorLine]:=21;
|
||||
AddAttrSampleLines[ahaExecutionPoint]:=15;
|
||||
AddAttrSampleLines[ahaTextBlock]:=14;
|
||||
end;
|
||||
@ -1446,6 +1450,14 @@ begin
|
||||
then begin
|
||||
DefBGCol:=clLime;
|
||||
DefFGCol:=clRed;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaInvalidBreakpoint]
|
||||
then begin
|
||||
DefBGCol:=clOlive;
|
||||
DefFGCol:=clGreen;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaUnknownBreakpoint]
|
||||
then begin
|
||||
DefBGCol:=clRed;
|
||||
DefFGCol:=clBlack;
|
||||
end else if AttriName=AdditionalHighlightAttributes[ahaErrorLine] then begin
|
||||
DefBGCol:=$50a0ff;
|
||||
DefFGCol:=clBlack;
|
||||
@ -1726,7 +1738,7 @@ begin
|
||||
ahaEnabledBreakpoint:
|
||||
begin
|
||||
BG:=clRed;
|
||||
FG:=clBlack;
|
||||
FG:=clWhite;
|
||||
end;
|
||||
ahaDisabledBreakpoint:
|
||||
begin
|
||||
@ -1738,6 +1750,11 @@ begin
|
||||
BG:=clOlive;
|
||||
FG:=clGreen;
|
||||
end;
|
||||
ahaUnknownBreakpoint:
|
||||
begin
|
||||
BG:=clRed;
|
||||
FG:=clBlack;
|
||||
end;
|
||||
ahaErrorLine:
|
||||
begin
|
||||
BG:=$50a0ff;
|
||||
|
Loading…
Reference in New Issue
Block a user