IDE, Debugger: fix r63306 #06b1a964b6 "Fix Run menu, to show correct available debugger commands" -- Do not init the debugger. => Review the entire calculation of available actions in the Run menu. Issue #0037183

git-svn-id: trunk@63317 -
This commit is contained in:
martin 2020-06-06 16:45:12 +00:00
parent 000ea7c493
commit 26272363cd
7 changed files with 48 additions and 53 deletions

View File

@ -1891,7 +1891,7 @@ type
procedure DoState(const OldState: TDBGState); virtual; procedure DoState(const OldState: TDBGState); virtual;
function ChangeFileName: Boolean; virtual; function ChangeFileName: Boolean; virtual;
function GetCommands: TDBGCommands; virtual; function GetCommands: TDBGCommands; virtual;
function GetSupportedCommands: TDBGCommands; virtual; class function GetSupportedCommands: TDBGCommands; virtual;
function GetTargetWidth: Byte; virtual; function GetTargetWidth: Byte; virtual;
function GetWaiting: Boolean; virtual; function GetWaiting: Boolean; virtual;
function GetIsIdle: Boolean; virtual; function GetIsIdle: Boolean; virtual;
@ -1986,6 +1986,7 @@ type
property PseudoTerminal: TPseudoTerminal read GetPseudoTerminal; experimental; // 'may be replaced with a more general API'; property PseudoTerminal: TPseudoTerminal read GetPseudoTerminal; experimental; // 'may be replaced with a more general API';
property State: TDBGState read FState; // The current state of the debugger property State: TDBGState read FState; // The current state of the debugger
property SupportedCommands: TDBGCommands read GetSupportedCommands; // All available commands of the debugger property SupportedCommands: TDBGCommands read GetSupportedCommands; // All available commands of the debugger
class function SupportedCommandsFor(AState: TDBGState): TDBGCommands;
property TargetWidth: Byte read GetTargetWidth; // Currently only 32 or 64 property TargetWidth: Byte read GetTargetWidth; // Currently only 32 or 64
//property Waiting: Boolean read GetWaiting; // Set when the debugger is wating for a command to complete //property Waiting: Boolean read GetWaiting; // Set when the debugger is wating for a command to complete
property Watches: TWatchesSupplier read FWatches; // list of all watches etc property Watches: TWatchesSupplier read FWatches; // list of all watches etc
@ -5954,6 +5955,11 @@ begin
FDestroyNotificationList[AReason].Remove(TMethod(AnEvent)); FDestroyNotificationList[AReason].Remove(TMethod(AnEvent));
end; end;
class function TDebuggerIntf.SupportedCommandsFor(AState: TDBGState): TDBGCommands;
begin
Result := COMMANDMAP[AState] * GetSupportedCommands;
end;
procedure TDebuggerIntf.Done; procedure TDebuggerIntf.Done;
begin begin
SetState(dsNone); SetState(dsNone);
@ -6160,7 +6166,7 @@ begin
ReqCmd(ACommand, AParams, dummy); ReqCmd(ACommand, AParams, dummy);
end; end;
function TDebuggerIntf.GetSupportedCommands: TDBGCommands; class function TDebuggerIntf.GetSupportedCommands: TDBGCommands;
begin begin
Result := []; Result := [];
end; end;

View File

@ -1014,7 +1014,7 @@ type
function CreateDisassembler: TDBGDisassembler; override; function CreateDisassembler: TDBGDisassembler; override;
function CreateWatches: TWatchesSupplier; override; function CreateWatches: TWatchesSupplier; override;
function CreateThreads: TThreadsSupplier; override; function CreateThreads: TThreadsSupplier; override;
function GetSupportedCommands: TDBGCommands; override; class function GetSupportedCommands: TDBGCommands; override;
function GetCommands: TDBGCommands; override; function GetCommands: TDBGCommands; override;
function GetTargetWidth: Byte; override; function GetTargetWidth: Byte; override;
procedure InterruptTarget; virtual; procedure InterruptTarget; virtual;
@ -9738,7 +9738,7 @@ begin
Result := True; Result := True;
end; end;
function TGDBMIDebuggerBase.GetSupportedCommands: TDBGCommands; class function TGDBMIDebuggerBase.GetSupportedCommands: TDBGCommands;
begin begin
Result := [dcRun, dcPause, dcStop, dcStepOver, dcStepInto, dcStepOut, Result := [dcRun, dcPause, dcStop, dcStepOver, dcStepInto, dcStepOut,
dcStepOverInstr, dcStepIntoInstr, dcStepTo, dcRunTo, dcAttach, dcDetach, dcJumpto, dcStepOverInstr, dcStepIntoInstr, dcStepTo, dcRunTo, dcAttach, dcDetach, dcJumpto,

View File

@ -319,7 +319,7 @@ type
class function NeedsExePath: boolean; override; class function NeedsExePath: boolean; override;
class function RequiredCompilerOpts({%H-}ATargetCPU, {%H-}ATargetOS: String): TDebugCompilerRequirements; override; class function RequiredCompilerOpts({%H-}ATargetCPU, {%H-}ATargetOS: String): TDebugCompilerRequirements; override;
class function CreateProperties: TDebuggerProperties; override; class function CreateProperties: TDebuggerProperties; override;
function GetSupportedCommands: TDBGCommands; override; class function GetSupportedCommands: TDBGCommands; override;
end; end;
{ TFpLineInfo } { TFpLineInfo }
@ -3472,7 +3472,7 @@ begin
Result := Result - [dcStepInto, dcStepOver, dcStepOut, dcStepIntoInstr, dcStepOverInstr]; Result := Result - [dcStepInto, dcStepOver, dcStepOut, dcStepIntoInstr, dcStepOverInstr];
end; end;
function TFpDebugDebugger.GetSupportedCommands: TDBGCommands; class function TFpDebugDebugger.GetSupportedCommands: TDBGCommands;
begin begin
Result:=[dcRun, dcStop, dcStepIntoInstr, dcStepOverInstr, dcStepOver, Result:=[dcRun, dcStop, dcStepIntoInstr, dcStepOverInstr, dcStepOver,
dcStepTo, dcRunTo, dcPause, dcStepOut, dcStepInto, dcEvaluate, dcSendConsoleInput dcStepTo, dcRunTo, dcPause, dcStepOut, dcStepInto, dcEvaluate, dcSendConsoleInput

View File

@ -300,7 +300,7 @@ type
procedure DisconnectFromFPDServer; procedure DisconnectFromFPDServer;
protected protected
// Overrides of TDebuggerIntf methods. // Overrides of TDebuggerIntf methods.
function GetSupportedCommands: TDBGCommands; override; class function GetSupportedCommands: TDBGCommands; override;
// Handle Notifications received from the FPDebug-server // Handle Notifications received from the FPDebug-server
procedure HandleNotification(ANotification: TJSONObject); procedure HandleNotification(ANotification: TJSONObject);
// Handle log-messages received from the FPDebug-server // Handle log-messages received from the FPDebug-server
@ -1244,7 +1244,7 @@ begin
end; end;
end; end;
function TFPDServerDebugger.GetSupportedCommands: TDBGCommands; class function TFPDServerDebugger.GetSupportedCommands: TDBGCommands;
begin begin
Result:=[dcRun, dcStepOver, dcStepInto, dcStepOut, dcStepOverInstr, dcStepIntoInstr, dcStop, dcEvaluate]; Result:=[dcRun, dcStepOver, dcStepInto, dcStepOut, dcStepOverInstr, dcStepIntoInstr, dcStop, dcEvaluate];
end; end;

View File

@ -362,7 +362,7 @@ type
function GetTargetWidth: Byte; override; function GetTargetWidth: Byte; override;
function GetIsIdle: Boolean; override; function GetIsIdle: Boolean; override;
function GetSupportedCommands: TDBGCommands; override; class function GetSupportedCommands: TDBGCommands; override;
//function GetCommands: TDBGCommands; override; //function GetCommands: TDBGCommands; override;
function RequestCommand(const ACommand: TDBGCommand; function RequestCommand(const ACommand: TDBGCommand;
const AParams: array of const; const AParams: array of const;
@ -2985,7 +2985,7 @@ begin
Result := FInIdle or ( (CommandQueue.Count = 0) and (CommandQueue.RunningCommand = nil) ); Result := FInIdle or ( (CommandQueue.Count = 0) and (CommandQueue.RunningCommand = nil) );
end; end;
function TLldbDebugger.GetSupportedCommands: TDBGCommands; class function TLldbDebugger.GetSupportedCommands: TDBGCommands;
begin begin
Result := [dcRun, dcStop, dcStepOver, dcStepInto, dcStepOut, dcEvaluate, Result := [dcRun, dcStop, dcStepOver, dcStepInto, dcStepOut, dcEvaluate,
dcStepOverInstr, dcStepIntoInstr, dcPause, dcEnvironment]; dcStepOverInstr, dcStepIntoInstr, dcPause, dcEnvironment];

View File

@ -53,7 +53,7 @@ type
function ProcessRun: Boolean; function ProcessRun: Boolean;
function ProcessStop: Boolean; function ProcessStop: Boolean;
protected protected
function GetSupportedCommands: TDBGCommands; override; class function GetSupportedCommands: TDBGCommands; override;
function RequestCommand(const ACommand: TDBGCommand; const AParams: array of const; function RequestCommand(const ACommand: TDBGCommand; const AParams: array of const;
const {%H-}ACallback: TMethod): Boolean; override; const {%H-}ACallback: TMethod): Boolean; override;
public public
@ -156,7 +156,7 @@ begin
Result := True; Result := True;
end; end;
function TProcessDebugger.GetSupportedCommands: TDBGCommands; class function TProcessDebugger.GetSupportedCommands: TDBGCommands;
begin begin
Result := [dcRun, dcStop, dcEnvironment] Result := [dcRun, dcStop, dcEnvironment]
end; end;

View File

@ -2072,67 +2072,63 @@ var
CanRun: Boolean; CanRun: Boolean;
SrcEdit: TSourceEditorInterface; SrcEdit: TSourceEditorInterface;
AnUnitInfo: TUnitInfo; AnUnitInfo: TUnitInfo;
AvailCommands: TDBGCommands;
CurState: TDBGState;
begin begin
if (MainIDE=nil) or (MainIDE.ToolStatus = itExiting) then exit; if (MainIDE=nil) or (MainIDE.ToolStatus = itExiting) then exit;
if FDebugger = nil then if FDebugger <> nil then begin
InitDebugger(); // make sure we get the supported commands AvailCommands := FDebugger.Commands;
DebuggerIsValid:=(FDebugger<>nil) and (MainIDE.ToolStatus in [itNone, itDebugger]); CurState := FDebugger.State;
end
else begin
AvailCommands := GetDebuggerClass.SupportedCommandsFor(dsStop);
CurState := dsStop;
end;
DebuggerIsValid:=(MainIDE.ToolStatus in [itNone, itDebugger]);
MainIDE.GetCurrentUnitInfo(SrcEdit,AnUnitInfo); MainIDE.GetCurrentUnitInfo(SrcEdit,AnUnitInfo);
with MainIDEBar do begin with MainIDEBar do begin
// For 'run' and 'step' bypass 'idle', so we can set the filename later // For 'run' and 'step' bypass 'idle', so we can set the filename later
CanRun:=false; CanRun:=false;
if Project1<>nil then if (Project1<>nil) and DebuggerIsValid then
CanRun:=( (AnUnitInfo<>nil) and (AnUnitInfo.RunFileIfActive) ) or CanRun:=( (AnUnitInfo<>nil) and (AnUnitInfo.RunFileIfActive) ) or
( ((Project1.CompilerOptions.ExecutableType=cetProgram) or ( ((Project1.CompilerOptions.ExecutableType=cetProgram) or
((Project1.RunParameterOptions.GetActiveMode<>nil) and (Project1.RunParameterOptions.GetActiveMode.HostApplicationFilename<>''))) ((Project1.RunParameterOptions.GetActiveMode<>nil) and (Project1.RunParameterOptions.GetActiveMode.HostApplicationFilename<>'')))
and (pfRunnable in Project1.Flags) and (pfRunnable in Project1.Flags)
); );
// Run // Run
itmRunMenuRun.Enabled := CanRun and (not DebuggerIsValid itmRunMenuRun.Enabled := CanRun and (dcRun in AvailCommands);
or (dcRun in FDebugger.Commands));
// Pause // Pause
itmRunMenuPause.Enabled := CanRun and DebuggerIsValid itmRunMenuPause.Enabled := CanRun and ((dcPause in AvailCommands) or FAutoContinueTimer.Enabled);
and ((dcPause in FDebugger.Commands) or FAutoContinueTimer.Enabled);
// Show execution point // Show execution point
itmRunMenuShowExecutionPoint.Enabled := CanRun and DebuggerIsValid itmRunMenuShowExecutionPoint.Enabled := CanRun and (CurState = dsPause);
and (FDebugger.State = dsPause);
// Step into // Step into
itmRunMenuStepInto.Enabled := CanRun and (not DebuggerIsValid itmRunMenuStepInto.Enabled := CanRun and (dcStepInto in AvailCommands);
or (dcStepInto in FDebugger.Commands));
// Step over // Step over
itmRunMenuStepOver.Enabled := CanRun and (not DebuggerIsValid itmRunMenuStepOver.Enabled := CanRun and (dcStepOver in AvailCommands);
or (dcStepOver in FDebugger.Commands));
// Step out // Step out
itmRunMenuStepOut.Enabled := CanRun and DebuggerIsValid itmRunMenuStepOut.Enabled := CanRun and (dcStepOut in AvailCommands) and (CurState = dsPause);
and (dcStepOut in FDebugger.Commands) and (FDebugger.State = dsPause);
// Step to cursor // Step to cursor
itmRunMenuStepToCursor.Enabled := CanRun and DebuggerIsValid itmRunMenuStepToCursor.Enabled := CanRun and (dcStepTo in AvailCommands);
and (dcStepTo in FDebugger.Commands);
// Run to cursor // Run to cursor
itmRunMenuRunToCursor.Enabled := CanRun and DebuggerIsValid itmRunMenuRunToCursor.Enabled := CanRun and (dcRunTo in AvailCommands);
and (dcRunTo in FDebugger.Commands);
// Stop // Stop
itmRunMenuStop.Enabled := CanRun and DebuggerIsValid and (MainIDE.ToolStatus = itDebugger) and itmRunMenuStop.Enabled := CanRun and (MainIDE.ToolStatus = itDebugger) and
(FDebugger.State in [dsPause, dsInternalPause, dsInit, dsRun, dsError]); (CurState in [dsPause, dsInternalPause, dsInit, dsRun, dsError]);
//Attach / Detach //Attach / Detach
itmRunMenuAttach.Enabled := (not DebuggerIsValid) or (dcAttach in FDebugger.Commands); itmRunMenuAttach.Enabled := DebuggerIsValid and (dcAttach in AvailCommands);
itmRunMenuDetach.Enabled := (DebuggerIsValid) and (dcDetach in FDebugger.Commands); itmRunMenuDetach.Enabled := DebuggerIsValid and (dcDetach in AvailCommands);
// Evaluate // Evaluate
itmRunMenuEvaluate.Enabled := CanRun and DebuggerIsValid itmRunMenuEvaluate.Enabled := CanRun and (dcEvaluate in AvailCommands);
and (dcEvaluate in FDebugger.Commands);
// Evaluate / modify // Evaluate / modify
SrcEditMenuEvaluateModify.Enabled := CanRun and DebuggerIsValid SrcEditMenuEvaluateModify.Enabled := CanRun and (dcEvaluate in AvailCommands);
and (dcEvaluate in FDebugger.Commands);
// Inspect // Inspect
SrcEditMenuInspect.Enabled := CanRun and DebuggerIsValid SrcEditMenuInspect.Enabled := CanRun and (dcEvaluate in AvailCommands);
and (dcEvaluate in FDebugger.Commands); itmRunMenuInspect.Enabled := CanRun and (dcEvaluate in AvailCommands);
itmRunMenuInspect.Enabled := CanRun and DebuggerIsValid
and (dcEvaluate in FDebugger.Commands);
// Add watch // Add watch
itmRunMenuAddWatch.Enabled := True; // always allow to add a watch itmRunMenuAddWatch.Enabled := True; // always allow to add a watch
// Add Breakpoint // Add Breakpoint
itmRunMenuAddBpSource.Enabled := True; itmRunMenuAddBpSource.Enabled := True;
@ -3093,12 +3089,6 @@ var
ActiveUnitInfo: TUnitInfo; ActiveUnitInfo: TUnitInfo;
UnitFilename: string; UnitFilename: string;
begin begin
if (FDebugger = nil) or not(dcRunTo in FDebugger.Commands)
then begin
Result := mrAbort;
Exit;
end;
if (MainIDE.DoInitProjectRun <> mrOK) if (MainIDE.DoInitProjectRun <> mrOK)
or (MainIDE.ToolStatus <> itDebugger) or (MainIDE.ToolStatus <> itDebugger)
or (FDebugger = nil) or Destroying or (FDebugger = nil) or Destroying
@ -3107,8 +3097,6 @@ begin
Exit; Exit;
end; end;
Result := mrCancel;
MainIDE.GetCurrentUnitInfo(ActiveSrcEdit,ActiveUnitInfo); MainIDE.GetCurrentUnitInfo(ActiveSrcEdit,ActiveUnitInfo);
if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil) if (ActiveSrcEdit=nil) or (ActiveUnitInfo=nil)
then begin then begin
@ -3122,6 +3110,7 @@ begin
then UnitFilename:=ActiveUnitInfo.Filename then UnitFilename:=ActiveUnitInfo.Filename
else UnitFilename:=BuildBoss.GetTestUnitFilename(ActiveUnitInfo); else UnitFilename:=BuildBoss.GetTestUnitFilename(ActiveUnitInfo);
FStepping:=True;
FDebugger.RunTo(ExtractFilename(UnitFilename), FDebugger.RunTo(ExtractFilename(UnitFilename),
TSourceEditor(ActiveSrcEdit).EditorComponent.CaretY); TSourceEditor(ActiveSrcEdit).EditorComponent.CaretY);