mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 11:41:04 +02:00
Debugger: let the debugger request certain compiler opts (eg: needs dwarf, or external info)
git-svn-id: trunk@58679 -
This commit is contained in:
parent
f8fcb833f4
commit
9f8beba93e
@ -1721,6 +1721,9 @@ type
|
||||
etWindowsMessageSent
|
||||
);
|
||||
|
||||
TDebugCompilerRequirement = (dcrNoExternalDbgInfo, dcrExternalDbgInfoOnly, dcrDwarfOnly);
|
||||
TDebugCompilerRequirements = set of TDebugCompilerRequirement;
|
||||
|
||||
TDBGFeedbackType = (ftInformation, ftWarning, ftError);
|
||||
TDBGFeedbackResult = (frOk, frStop);
|
||||
TDBGFeedbackResults = set of TDBGFeedbackResult;
|
||||
@ -1885,7 +1888,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
|
||||
class function RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements; virtual;
|
||||
|
||||
// debugger properties
|
||||
class function CreateProperties: TDebuggerProperties; virtual; // Creates debuggerproperties
|
||||
@ -6044,9 +6047,9 @@ begin
|
||||
Result := true; // most debugger are external and have an exe path
|
||||
end;
|
||||
|
||||
class function TDebuggerIntf.CanExternalDebugSymbolsFile: boolean;
|
||||
class function TDebuggerIntf.RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements;
|
||||
begin
|
||||
Result := false;
|
||||
Result := [];
|
||||
end;
|
||||
|
||||
function TDebuggerIntf.GetCommands: TDBGCommands;
|
||||
|
@ -79,7 +79,6 @@ type
|
||||
constructor Create(const AExternalDebugger: String); override;
|
||||
destructor Destroy; override;
|
||||
procedure TestCmd(const ACommand: String); override;// For internal debugging purposes
|
||||
class function CanExternalDebugSymbolsFile: boolean; override;
|
||||
public
|
||||
property DebugProcess: TProcessUTF8 read FDbgProcess;
|
||||
property DebugProcessRunning: Boolean read GetDebugProcessRunning;
|
||||
@ -607,11 +606,6 @@ begin
|
||||
SendCmdLn(ACommand);
|
||||
end;
|
||||
|
||||
class function TCmdLineDebugger.CanExternalDebugSymbolsFile: boolean;
|
||||
begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
initialization
|
||||
DBG_CMD_ECHO := DebugLogger.FindOrRegisterLogGroup('DBG_CMD_ECHO' {$IF defined(DBG_VERBOSE) or defined(DBG_CMD_ECHO)} , True {$ENDIF} );
|
||||
DBG_CMD_ECHO_FULL := DebugLogger.FindOrRegisterLogGroup('DBG_CMD_ECHO_FULL' {$IF defined(DBG_VERBOSE_FULL_DATA) or defined(DBG_CMD_ECHO_FULL)} , True {$ENDIF} );
|
||||
|
@ -169,7 +169,7 @@ type
|
||||
function GetLocation: TDBGLocationRec; override;
|
||||
class function Caption: String; override;
|
||||
class function NeedsExePath: boolean; override;
|
||||
class function CanExternalDebugSymbolsFile: boolean; override;
|
||||
class function RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements; override;
|
||||
class function CreateProperties: TDebuggerProperties; override;
|
||||
function GetSupportedCommands: TDBGCommands; override;
|
||||
end;
|
||||
@ -2054,14 +2054,21 @@ begin
|
||||
Result:=False;
|
||||
end;
|
||||
|
||||
class function TFpDebugDebugger.CanExternalDebugSymbolsFile: boolean;
|
||||
class function TFpDebugDebugger.RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements;
|
||||
begin
|
||||
{$ifdef CD_Cocoa}{$DEFINE MacOS}{$ENDIF}
|
||||
{$IFDEF Darwin}{$DEFINE MacOS}{$ENDIF}
|
||||
{$ifdef CD_Cocoa}{$DEFINE MacOS}
|
||||
if ATargetCPU = '' then ATargetCPU := 'x86_64'
|
||||
{$ENDIF}
|
||||
{$IFDEF Darwin}{$DEFINE MacOS}
|
||||
if ATargetCPU = '' then ATargetCPU := 'i386'
|
||||
{$ENDIF}
|
||||
{$IFDEF MacOs}
|
||||
Result:=True;
|
||||
if LowerCase(ATargetCPU) = 'i386' then
|
||||
Result:=[dcrDwarfOnly] // carbon
|
||||
else
|
||||
Result:=[dcrExternalDbgInfoOnly, dcrDwarfOnly]; // cocoa
|
||||
{$ELSE}
|
||||
Result:=False;
|
||||
Result:=[dcrNoExternalDbgInfo, dcrDwarfOnly];
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
|
@ -122,7 +122,7 @@ type
|
||||
property CurrentStackFrame;
|
||||
public
|
||||
class function Caption: String; override;
|
||||
class function CanExternalDebugSymbolsFile: boolean; override;
|
||||
class function RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements; override;
|
||||
public
|
||||
constructor Create(const AExternalDebugger: String); override;
|
||||
destructor Destroy; override;
|
||||
@ -1147,14 +1147,21 @@ begin
|
||||
Result := 'LLDB debugger (with fpdebug) (Alpha)';
|
||||
end;
|
||||
|
||||
class function TFpLldbDebugger.CanExternalDebugSymbolsFile: boolean;
|
||||
class function TFpLldbDebugger.RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements;
|
||||
begin
|
||||
{$ifdef CD_Cocoa}{$DEFINE MacOS}{$ENDIF}
|
||||
{$IFDEF Darwin}{$DEFINE MacOS}{$ENDIF}
|
||||
{$ifdef CD_Cocoa}{$DEFINE MacOS}
|
||||
if ATargetCPU = '' then ATargetCPU := 'x86_64'
|
||||
{$ENDIF}
|
||||
{$IFDEF Darwin}{$DEFINE MacOS}
|
||||
if ATargetCPU = '' then ATargetCPU := 'i386'
|
||||
{$ENDIF}
|
||||
{$IFDEF MacOs}
|
||||
Result:=True;
|
||||
if LowerCase(ATargetCPU) = 'i386' then
|
||||
Result:=[dcrDwarfOnly] // carbon
|
||||
else
|
||||
Result:=[dcrExternalDbgInfoOnly, dcrDwarfOnly]; // cocoa
|
||||
{$ELSE}
|
||||
Result:=False;
|
||||
Result:=[dcrNoExternalDbgInfo, dcrDwarfOnly];
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
|
@ -59,7 +59,6 @@ type
|
||||
public
|
||||
class function Caption: String; override;
|
||||
class function NeedsExePath: boolean; override;
|
||||
class function CanExternalDebugSymbolsFile: boolean; override;
|
||||
published
|
||||
end;
|
||||
|
||||
@ -177,11 +176,6 @@ begin
|
||||
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
|
||||
RegisterDebugger(TProcessDebugger);
|
||||
|
||||
|
@ -154,6 +154,7 @@ type
|
||||
|
||||
procedure DoRestoreDebuggerMarks(AnUnitInfo: TUnitInfo); virtual; abstract;
|
||||
|
||||
function RequiredCompilerOpts(ATargetCPU, ATargetOS: String): TDebugCompilerRequirements; virtual; abstract;
|
||||
function InitDebugger(AFlags: TDbgInitFlags = []): Boolean; virtual; abstract;
|
||||
|
||||
function DoPauseProject: TModalResult; virtual; abstract;
|
||||
|
@ -211,6 +211,8 @@ type
|
||||
procedure ClearDebugOutputLog;
|
||||
procedure ClearDebugEventsLog;
|
||||
|
||||
function RequiredCompilerOpts(ATargetCPU, ATargetOS: String
|
||||
): TDebugCompilerRequirements; override;
|
||||
function InitDebugger(AFlags: TDbgInitFlags = []): Boolean; override;
|
||||
function DoSetBreakkPointWarnIfNoDebugger: boolean;
|
||||
|
||||
@ -2277,6 +2279,14 @@ begin
|
||||
FEventLogManager.ClearDebugEventsLog;
|
||||
end;
|
||||
|
||||
function TDebugManager.RequiredCompilerOpts(ATargetCPU, ATargetOS: String
|
||||
): TDebugCompilerRequirements;
|
||||
begin
|
||||
if DebuggerClass = nil then
|
||||
exit([]);
|
||||
Result := DebuggerClass.RequiredCompilerOpts(ATargetCPU, ATargetOS);
|
||||
end;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Debugger routines
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -4056,6 +4056,18 @@ resourcestring
|
||||
+'the debug symbols to an external file. The "%s" supports only symbols '
|
||||
+'within the executable.';
|
||||
lisDisableOptionXg2 = 'Disable option -Xg';
|
||||
lisEnableOptionXg = 'Enable Option -Xg?';
|
||||
lisTheProjectWritesTheDebugSymbolsToTheExexcutable = 'The project writes '
|
||||
+'the debug symbols into the executable, rather than to an external file. '
|
||||
+ 'The "%s" supports only symbols in an external file.';
|
||||
lisEnableOptionXg2 = 'Enable option -Xg';
|
||||
lisEnableOptionDwarf = 'Enable Dwarf 2 (-gw)?';
|
||||
lisTheProjectDoesNotUseDwarf = 'The project does not '
|
||||
+'write debug info in Dwarf format.'
|
||||
+ 'The "%s" supports only Dwarf.';
|
||||
lisEnableOptionDwarf2 = 'Enable Dwarf 2 (-gw)';
|
||||
lisEnableOptionDwarf2Sets = 'Enable Dwarf 2 with sets';
|
||||
lisEnableOptionDwarf3 = 'Enable Dwarf 3 (-gw3)';
|
||||
lisCleanUpUnitPath = 'Clean up unit path?';
|
||||
lisTheDirectoryIsNoLongerNeededInTheUnitPathRemoveIt =
|
||||
'The directory "%s" is no longer needed in the unit path.%sRemove it?';
|
||||
|
61
ide/main.pp
61
ide/main.pp
@ -7090,6 +7090,7 @@ var
|
||||
ProgramFilename: string;
|
||||
DebugClass: TDebuggerClass;
|
||||
ARunMode: TRunParamsOptionsMode;
|
||||
ReqOpts: TDebugCompilerRequirements;
|
||||
begin
|
||||
if ToolStatus <> itNone
|
||||
then begin
|
||||
@ -7119,19 +7120,53 @@ begin
|
||||
|
||||
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;
|
||||
if DebugClass <> nil then begin
|
||||
ReqOpts := DebugBoss.RequiredCompilerOpts(Project1.CompilerOptions.TargetCPU, Project1.CompilerOptions.TargetOS);
|
||||
// check if debugger supports compiler flags
|
||||
if (dcrNoExternalDbgInfo in ReqOpts)
|
||||
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
|
||||
else
|
||||
if (dcrExternalDbgInfoOnly in ReqOpts)
|
||||
and (not Project1.CompilerOptions.UseExternalDbgSyms) then
|
||||
begin
|
||||
// this debugger does ONLY support external debug symbols
|
||||
if IDEQuestionDialog(lisEnableOptionXg,
|
||||
Format(lisTheProjectWritesTheDebugSymbolsToTheExexcutable, [DebugClass.Caption]),
|
||||
mtConfirmation, [mrYes, lisEnableOptionXg,
|
||||
mrCancel]) <> mrYes
|
||||
then
|
||||
exit;
|
||||
Project1.CompilerOptions.UseExternalDbgSyms:=true;
|
||||
end;
|
||||
|
||||
if (dcrDwarfOnly in ReqOpts)
|
||||
and (not (Project1.CompilerOptions.DebugInfoType in [dsDwarf2, dsDwarf2Set, dsDwarf3])) then
|
||||
begin
|
||||
// this debugger does ONLY support external debug symbols
|
||||
case IDEQuestionDialog(lisEnableOptionDwarf,
|
||||
Format(lisTheProjectDoesNotUseDwarf, [DebugClass.Caption]),
|
||||
mtConfirmation, [1 {mrOk}, lisEnableOptionDwarf2Sets,
|
||||
12, lisEnableOptionDwarf2,
|
||||
13, lisEnableOptionDwarf3,
|
||||
mrCancel])
|
||||
of
|
||||
1: Project1.CompilerOptions.DebugInfoType := dsDwarf2Set;
|
||||
12: Project1.CompilerOptions.DebugInfoType := dsDwarf2;
|
||||
13: Project1.CompilerOptions.DebugInfoType := dsDwarf3;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Build project first
|
||||
|
Loading…
Reference in New Issue
Block a user