From a46dc8915ab942b18a49a6b913efe8770eba0cc7 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 4 Dec 2014 19:14:22 +0000 Subject: [PATCH] IDE: added TDebuggerIntf.CanExternalDebugSymbolsFile git-svn-id: trunk@47107 - --- .../debuggerintf/dbgintfdebuggerbase.pp | 6 ++++++ components/ideintf/compoptsintf.pas | 2 +- .../lazdebuggergdbmi/cmdlinedebugger.pp | 6 ++++++ .../lazdebuggerfp/fpdebugdebugger.pas | 6 ++++++ debugger/processdebugger.pp | 9 +++++++-- ide/lazarusidestrconsts.pas | 5 +++++ ide/main.pp | 19 ++++++++++++++++++- 7 files changed, 49 insertions(+), 4 deletions(-) diff --git a/components/debuggerintf/dbgintfdebuggerbase.pp b/components/debuggerintf/dbgintfdebuggerbase.pp index e36ceae3c3..26f6941271 100644 --- a/components/debuggerintf/dbgintfdebuggerbase.pp +++ b/components/debuggerintf/dbgintfdebuggerbase.pp @@ -1731,6 +1731,7 @@ type class function ExePaths: String; virtual; // The default locations of the exe class function HasExePath: boolean; virtual; deprecated; // use NeedsExePath instead class function NeedsExePath: boolean; virtual; // If the debugger needs to have an exe path + class function CanExternalDebugSymbolsFile: boolean; virtual; // If the debugger support the -Xg compiler option to store the debug info in an external file // debugger properties class function CreateProperties: TDebuggerProperties; virtual; // Creates debuggerproperties @@ -5490,6 +5491,11 @@ begin Result := HasExePath; end; +class function TDebuggerIntf.CanExternalDebugSymbolsFile: boolean; +begin + Result := false; +end; + function TDebuggerIntf.GetCommands: TDBGCommands; begin Result := COMMANDMAP[State] * GetSupportedCommands; diff --git a/components/ideintf/compoptsintf.pas b/components/ideintf/compoptsintf.pas index 17c1d00450..5eba614c2f 100644 --- a/components/ideintf/compoptsintf.pas +++ b/components/ideintf/compoptsintf.pas @@ -404,7 +404,7 @@ type property Win32GraphicApp: boolean read FWin32GraphicApp write SetWin32GraphicApp; property ExecutableType: TCompilationExecutableType read FExecutableType write SetExecutableType; - property UseExternalDbgSyms: Boolean read FUseExternalDbgSyms write SetUseExternalDbgSyms; + property UseExternalDbgSyms: Boolean read FUseExternalDbgSyms write SetUseExternalDbgSyms; // -Xg // messages: property ShowErrors: Boolean read fShowErrors write SetShowErrors; // -ve diff --git a/components/lazdebuggergdbmi/cmdlinedebugger.pp b/components/lazdebuggergdbmi/cmdlinedebugger.pp index a9f8a0142c..f91448b185 100644 --- a/components/lazdebuggergdbmi/cmdlinedebugger.pp +++ b/components/lazdebuggergdbmi/cmdlinedebugger.pp @@ -79,6 +79,7 @@ type constructor Create(const AExternalDebugger: String); override; destructor Destroy; override; procedure TestCmd(const ACommand: String); virtual;// For internal debugging purposes + class function CanExternalDebugSymbolsFile: boolean; override; public property DebugProcess: TProcessUTF8 read FDbgProcess; property DebugProcessRunning: Boolean read GetDebugProcessRunning; @@ -577,6 +578,11 @@ begin SendCmdLn(ACommand); end; +class function TCmdLineDebugger.CanExternalDebugSymbolsFile: boolean; +begin + Result:=true; +end; + initialization DBG_CMD_ECHO := DebugLogger.RegisterLogGroup('DBG_CMD_ECHO' {$IF defined(DBG_VERBOSE) or defined(DBG_CMD_ECHO)} , True {$ENDIF} ); DBG_CMD_ECHO_FULL := DebugLogger.RegisterLogGroup('DBG_CMD_ECHO_FULL' {$IF defined(DBG_VERBOSE_FULL_DATA) or defined(DBG_CMD_ECHO_FULL)} , True {$ENDIF} ); diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas index bdcf396f76..27a0daea6d 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas @@ -157,6 +157,7 @@ type function GetLocation: TDBGLocationRec; override; class function Caption: String; override; class function NeedsExePath: boolean; override; + class function CanExternalDebugSymbolsFile: boolean; override; class function CreateProperties: TDebuggerProperties; override; function GetSupportedCommands: TDBGCommands; override; end; @@ -1804,6 +1805,11 @@ begin Result:=False; end; +class function TFpDebugDebugger.CanExternalDebugSymbolsFile: boolean; +begin + Result:=False; +end; + class function TFpDebugDebugger.CreateProperties: TDebuggerProperties; begin Result := TFpDebugDebuggerProperties.Create; diff --git a/debugger/processdebugger.pp b/debugger/processdebugger.pp index 5aadef4f4b..44baf3e1c7 100644 --- a/debugger/processdebugger.pp +++ b/debugger/processdebugger.pp @@ -58,7 +58,7 @@ type public class function Caption: String; override; class function NeedsExePath: boolean; override; - + class function CanExternalDebugSymbolsFile: boolean; override; published end; @@ -171,7 +171,12 @@ end; class function TProcessDebugger.NeedsExePath: boolean; begin - Result:= false; // no need to have a valid exe path for the process debugger + Result := false; // no need to have a valid exe path for the process debugger +end; + +class function TProcessDebugger.CanExternalDebugSymbolsFile: boolean; +begin + Result := true; // Yeah, why not. end; initialization diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 490d0b8530..160d45dc2f 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -3758,6 +3758,11 @@ resourcestring +'%sHit Stop, and hope the best, we''re pulling the plug.'; lisExecutionStopped = 'Execution stopped'; lisFileNotFound = 'File not found'; + lisDisableOptionXg = 'Disable Option -Xg?'; + lisTheProjectWritesTheDebugSymbolsToAnExternalFileThe = 'The project writes ' + +'the debug symbols to an external file. The "%s" supports only symbols ' + +'within the executable.'; + lisDisableOptionXg2 = 'Disable option -Xg'; lisCleanUpUnitPath = 'Clean up unit path?'; lisTheDirectoryIsNoLongerNeededInTheUnitPathRemoveIt = 'The directory "%s" is no longer needed in the unit path.%sRemove it?'; diff --git a/ide/main.pp b/ide/main.pp index eed882b447..d21be9020b 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -6820,6 +6820,7 @@ end; function TMainIDE.DoInitProjectRun: TModalResult; var ProgramFilename: string; + DebugClass: TDebuggerClass; begin if ToolStatus <> itNone then begin @@ -6846,6 +6847,22 @@ begin Exit; end; + DebugClass:=DebugBoss.DebuggerClass; + + // check if debugger supports compiler flags + if ((DebugClass <> nil) + and (not DebugClass.CanExternalDebugSymbolsFile)) + and (Project1.CompilerOptions.UseExternalDbgSyms) then + begin + // this debugger does not support external debug symbols + if IDEQuestionDialog(lisDisableOptionXg, Format( + lisTheProjectWritesTheDebugSymbolsToAnExternalFileThe, [DebugClass.Caption + ]), + mtConfirmation, [mrYes, lisDisableOptionXg2, mrCancel])<>mrYes then + exit; + Project1.CompilerOptions.UseExternalDbgSyms:=false; + end; + // Build project first debugln('TMainIDE.DoInitProjectRun Check build ...'); if DoBuildProject(crRun,[pbfOnlyIfNeeded]) <> mrOk then @@ -6854,7 +6871,7 @@ begin // Check project build ProgramFilename := MainBuildBoss.GetProjectTargetFilename(Project1); DebugLn(['TMainIDE.DoInitProjectRun ProgramFilename=',ProgramFilename]); - if ((DebugBoss.DebuggerClass = nil) or DebugBoss.DebuggerClass.RequiresLocalExecutable) + if ((DebugClass = nil) or DebugClass.RequiresLocalExecutable) and not FileExistsUTF8(ProgramFilename) then begin IDEMessageDialog(lisFileNotFound,