From c7de909539125bdcc62bb73067f7da04f731a467 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 31 Dec 2022 18:56:39 +0100 Subject: [PATCH] Debugger: Add dfNotSuitableForOsArch, to filter out unusable backends --- components/debuggerintf/dbgintfdebuggerbase.pp | 8 +++++++- .../lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas | 4 ++++ debugger/frames/debugger_class_options.pas | 2 ++ ide/packages/idedebugger/idedebuggeropts.pas | 13 +++++++++---- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/components/debuggerintf/dbgintfdebuggerbase.pp b/components/debuggerintf/dbgintfdebuggerbase.pp index 4789ebdd94..65f7745b00 100644 --- a/components/debuggerintf/dbgintfdebuggerbase.pp +++ b/components/debuggerintf/dbgintfdebuggerbase.pp @@ -62,7 +62,13 @@ type TDBGFeature = ( dfEvalFunctionCalls, // The debugger supports calling functions in watches/expressions. defAllowFunctionCall in TWatcheEvaluateFlags - dfThreadSuspension + dfThreadSuspension, + + (* dfNotSuitableForOsArch: + If this is set, then this debugger can not be used on the current + architecture and/or OS + *) + dfNotSuitableForOsArch ); TDBGFeatures = set of TDBGFeature; diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas index 52ab790df5..e244429b02 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas @@ -4621,7 +4621,11 @@ end; class function TFpDebugDebugger.SupportedFeatures: TDBGFeatures; begin + {$IF defined(windows) or defined(linux)} Result := [dfEvalFunctionCalls, dfThreadSuspension]; + {$ELSE} + Result := [dfNotSuitableForOsArch]; + {$ENDIF} end; initialization diff --git a/debugger/frames/debugger_class_options.pas b/debugger/frames/debugger_class_options.pas index 40706b0ca5..306e6dcf26 100644 --- a/debugger/frames/debugger_class_options.pas +++ b/debugger/frames/debugger_class_options.pas @@ -332,6 +332,8 @@ begin List := TStringListUTF8Fast.Create; for i := 0 to TBaseDebugManagerIntf.DebuggerCount - 1 do begin d := TBaseDebugManagerIntf.Debuggers[i]; + if dfNotSuitableForOsArch in d.SupportedFeatures then + continue; List.AddObject(d.Caption, TObject(d)); end; List.Sorted := True; diff --git a/ide/packages/idedebugger/idedebuggeropts.pas b/ide/packages/idedebugger/idedebuggeropts.pas index 4ecc3c7236..7a1fd38dd4 100644 --- a/ide/packages/idedebugger/idedebuggeropts.pas +++ b/ide/packages/idedebugger/idedebuggeropts.pas @@ -187,7 +187,9 @@ begin FActive := False; FDebuggerClass := TBaseDebugManagerIntf.DebuggersByClassName[ConfigClass]; - if FDebuggerClass <> nil then begin + if (FDebuggerClass <> nil) and + ( Active or not (dfNotSuitableForOsArch in FDebuggerClass.SupportedFeatures) ) // Active entries will always be loaded for compatibility + then begin FDebuggerProperties := FDebuggerClass.CreateProperties; if FDebuggerProperties <> nil then AXMLCfg.ReadObject(APath + 'Properties/', FDebuggerProperties); @@ -235,7 +237,8 @@ begin FDebuggerProperties := FDebuggerClass.CreateProperties; if FDebuggerProperties <> nil then AXMLCfg.ReadObject(p, FDebuggerProperties); - FFLags := [dpcLoaded]; + if Active or not (dfNotSuitableForOsArch in FDebuggerClass.SupportedFeatures) then + FFLags := [dpcLoaded]; end else begin if p[Length(p)] = '/' then @@ -263,7 +266,8 @@ begin FConfigName := ''; FActive := ACreateAsActive; FDebuggerProperties := ADebuggerClass.CreateProperties; - FFLags := [dpcLoaded]; // i.e. treat as loaded, save when saving all + if FActive or not (dfNotSuitableForOsArch in FDebuggerClass.SupportedFeatures) then + FFLags := [dpcLoaded]; // i.e. treat as loaded, save when saving all InitUID; end; @@ -279,7 +283,8 @@ begin FDebuggerClass := TBaseDebugManagerIntf.DebuggersByClassName[ConfigClass]; if FDebuggerClass <> nil then begin FDebuggerProperties := FDebuggerClass.CreateProperties; - FFLags := [dpcLoaded]; // i.e. treat as loaded, save when saving all + if FActive or not (dfNotSuitableForOsArch in FDebuggerClass.SupportedFeatures) then + FFLags := [dpcLoaded]; // i.e. treat as loaded, save when saving all end; InitUID;