added Destroying flag, debugger now always shuts down

git-svn-id: trunk@4211 -
This commit is contained in:
mattias 2003-05-29 07:25:02 +00:00
parent 06270715bc
commit 2f9b4a5c83
2 changed files with 28 additions and 13 deletions

View File

@ -44,8 +44,8 @@ uses
type type
TBaseDebugManager = class(TComponent) TBaseDebugManager = class(TComponent)
private
protected protected
FDestroying: boolean;
FBreakPoints: TDBGBreakPoints; FBreakPoints: TDBGBreakPoints;
function GetState: TDBGState; virtual; abstract; function GetState: TDBGState; virtual; abstract;
function GetCommands: TDBGCommands; virtual; abstract; function GetCommands: TDBGCommands; virtual; abstract;
@ -78,9 +78,11 @@ type
): TModalResult; virtual; abstract; ): TModalResult; virtual; abstract;
function DoCreateWatch(const AExpression: string): TModalResult; virtual; abstract; function DoCreateWatch(const AExpression: string): TModalResult; virtual; abstract;
public
property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger property Commands: TDBGCommands read GetCommands; // All current available commands of the debugger
property State: TDBGState read GetState; // The current state of the debugger property State: TDBGState read GetState; // The current state of the debugger
property BreakPoints: TDBGBreakPoints read FBreakpoints; property BreakPoints: TDBGBreakPoints read FBreakpoints;
property Destroying: boolean read FDestroying;
end; end;
var var

View File

@ -450,6 +450,7 @@ end;
procedure TDebugManager.OnDebuggerException(Sender: TObject; procedure TDebugManager.OnDebuggerException(Sender: TObject;
const AExceptionID: Integer; const AExceptionText: String); const AExceptionID: Integer; const AExceptionText: String);
begin begin
if Destroying then exit;
MessageDlg('Error', MessageDlg('Error',
Format('Project %s raised exception class %d with message ''%s''.', Format('Project %s raised exception class %d with message ''%s''.',
[Project1.Title, AExceptionID, AExceptionText]), [Project1.Title, AExceptionID, AExceptionText]),
@ -458,6 +459,7 @@ end;
procedure TDebugManager.OnDebuggerOutput(Sender: TObject; const AText: String); procedure TDebugManager.OnDebuggerOutput(Sender: TObject; const AText: String);
begin begin
if Destroying then exit;
if FDialogs[ddtOutput] <> nil if FDialogs[ddtOutput] <> nil
then TDbgOutputForm(FDialogs[ddtOutput]).AddText(AText); then TDbgOutputForm(FDialogs[ddtOutput]).AddText(AText);
end; end;
@ -479,6 +481,8 @@ begin
if (ADebugger<>FDebugger) or (ADebugger=nil) then if (ADebugger<>FDebugger) or (ADebugger=nil) then
RaiseException('TDebugManager.OnDebuggerChangeState'); RaiseException('TDebugManager.OnDebuggerChangeState');
if Destroying then exit;
WriteLN('[TDebugManager.OnDebuggerChangeState] state: ', STATENAME[FDebugger.State]); WriteLN('[TDebugManager.OnDebuggerChangeState] state: ', STATENAME[FDebugger.State]);
// All conmmands // All conmmands
@ -558,6 +562,7 @@ var
n: Integer; n: Integer;
begin begin
if (Sender<>FDebugger) or (Sender=nil) then exit; if (Sender<>FDebugger) or (Sender=nil) then exit;
if Destroying then exit;
//TODO: Show assembler window if no source can be found. //TODO: Show assembler window if no source can be found.
if ALocation.SrcLine = -1 if ALocation.SrcLine = -1
@ -666,6 +671,7 @@ const
var var
CurDialog: TDebuggerDlg; CurDialog: TDebuggerDlg;
begin begin
if Destroying then exit;
if FDialogs[ADialogType] = nil if FDialogs[ADialogType] = nil
then begin then begin
FDialogs[ADialogType] := DEBUGDIALOGCLASS[ADialogType].Create(Self); FDialogs[ADialogType] := DEBUGDIALOGCLASS[ADialogType].Create(Self);
@ -760,6 +766,8 @@ destructor TDebugManager.Destroy;
var var
DialogType: TDebugDialogType; DialogType: TDebugDialogType;
begin begin
FDestroying:=true;
for DialogType := Low(TDebugDialogType) to High(TDebugDialogType) do for DialogType := Low(TDebugDialogType) to High(TDebugDialogType) do
DestroyDebugDialog(DialogType); DestroyDebugDialog(DialogType);
@ -868,7 +876,7 @@ var
CurBreakPoint: TDBGBreakPoint; CurBreakPoint: TDBGBreakPoint;
SrcFilename: String; SrcFilename: String;
begin begin
if AnUnitInfo.EditorIndex<0 then exit; if (AnUnitInfo.EditorIndex<0) or Destroying then exit;
ASrcEdit:=SourceNotebook.Editors[AnUnitInfo.EditorIndex]; ASrcEdit:=SourceNotebook.Editors[AnUnitInfo.EditorIndex];
// set breakpoints for this unit // set breakpoints for this unit
SrcFilename:=AnUnitInfo.Filename; SrcFilename:=AnUnitInfo.Filename;
@ -927,7 +935,7 @@ begin
RaiseException('TDebugManager.CreateSourceMarkForBreakPoint'); RaiseException('TDebugManager.CreateSourceMarkForBreakPoint');
ManagedBreakPoint:=TManagedBreakPoint(ABreakpoint); ManagedBreakPoint:=TManagedBreakPoint(ABreakpoint);
if (ManagedBreakPoint.SourceMark<>nil) then exit; if (ManagedBreakPoint.SourceMark<>nil) or Destroying then exit;
if ASrcEdit=nil then if ASrcEdit=nil then
GetSourceEditorForBreakPoint(ManagedBreakPoint,ASrcEdit); GetSourceEditorForBreakPoint(ManagedBreakPoint,ASrcEdit);
if ASrcEdit=nil then exit; if ASrcEdit=nil then exit;
@ -1035,7 +1043,7 @@ begin
WriteLN('[TDebugManager.DoInitDebugger] A'); WriteLN('[TDebugManager.DoInitDebugger] A');
Result:=mrCancel; Result:=mrCancel;
if Project1.MainUnitID < 0 then Exit; if (Project1.MainUnitID < 0) or Destroying then Exit;
LaunchingCmdLine:=MainIDE.GetRunCommandLine; LaunchingCmdLine:=MainIDE.GetRunCommandLine;
SplitCmdLine(LaunchingCmdLine,LaunchingApplication,LaunchingParams); SplitCmdLine(LaunchingCmdLine,LaunchingApplication,LaunchingParams);
@ -1116,7 +1124,7 @@ function TDebugManager.DoPauseProject: TModalResult;
begin begin
Result := mrCancel; Result := mrCancel;
if (MainIDE.ToolStatus <> itDebugger) if (MainIDE.ToolStatus <> itDebugger)
or (FDebugger = nil) or (FDebugger = nil) or Destroying
then Exit; then Exit;
FDebugger.Pause; FDebugger.Pause;
Result := mrOk; Result := mrOk;
@ -1126,7 +1134,7 @@ function TDebugManager.DoStepIntoProject: TModalResult;
begin begin
if (MainIDE.DoInitProjectRun <> mrOK) if (MainIDE.DoInitProjectRun <> mrOK)
or (MainIDE.ToolStatus <> itDebugger) or (MainIDE.ToolStatus <> itDebugger)
or (FDebugger = nil) or (FDebugger = nil) or Destroying
then begin then begin
Result := mrAbort; Result := mrAbort;
Exit; Exit;
@ -1140,7 +1148,7 @@ function TDebugManager.DoStepOverProject: TModalResult;
begin begin
if (MainIDE.DoInitProjectRun <> mrOK) if (MainIDE.DoInitProjectRun <> mrOK)
or (MainIDE.ToolStatus <> itDebugger) or (MainIDE.ToolStatus <> itDebugger)
or (FDebugger = nil) or (FDebugger = nil) or Destroying
then begin then begin
Result := mrAbort; Result := mrAbort;
Exit; Exit;
@ -1155,7 +1163,7 @@ begin
Result := mrCancel; Result := mrCancel;
SourceNotebook.ClearExecutionLines; SourceNotebook.ClearExecutionLines;
if (MainIDE.ToolStatus <> itDebugger) if (MainIDE.ToolStatus <> itDebugger)
or (FDebugger=nil) or (FDebugger=nil) or Destroying
then Exit; then Exit;
FDebugger.Stop; FDebugger.Stop;
@ -1205,7 +1213,8 @@ end;
procedure TDebugManager.RunDebugger; procedure TDebugManager.RunDebugger;
begin begin
if FDebugger <> nil then FDebugger.Run; if Destroying then exit;
if (FDebugger <> nil) then FDebugger.Run;
end; end;
procedure TDebugManager.EndDebugging; procedure TDebugManager.EndDebugging;
@ -1216,10 +1225,11 @@ end;
function TDebugManager.Evaluate(const AExpression: String; function TDebugManager.Evaluate(const AExpression: String;
var AResult: String): Boolean; var AResult: String): Boolean;
begin begin
Result := (MainIDE.ToolStatus = itDebugger) Result := (not Destroying)
and (MainIDE.ToolStatus = itDebugger)
and (dcEvaluate in DebugBoss.Commands) and (dcEvaluate in DebugBoss.Commands)
and (FDebugger <> nil) and (FDebugger <> nil)
and FDebugger.Evaluate(AExpression, AResult); and FDebugger.Evaluate(AExpression, AResult)
end; end;
function TDebugManager.DoCreateBreakPoint(const AFilename: string; function TDebugManager.DoCreateBreakPoint(const AFilename: string;
@ -1286,7 +1296,7 @@ var
begin begin
if (MainIDE.DoInitProjectRun <> mrOK) if (MainIDE.DoInitProjectRun <> mrOK)
or (MainIDE.ToolStatus <> itDebugger) or (MainIDE.ToolStatus <> itDebugger)
or (FDebugger = nil) or (FDebugger = nil) or Destroying
then begin then begin
Result := mrAbort; Result := mrAbort;
Exit; Exit;
@ -1330,6 +1340,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.36 2003/05/29 07:25:02 mattias
added Destroying flag, debugger now always shuts down
Revision 1.35 2003/05/28 22:43:21 marc Revision 1.35 2003/05/28 22:43:21 marc
MWE: * Fixed adding/removing breakpoints while paused MWE: * Fixed adding/removing breakpoints while paused