LazDebugger(Fp)Lldb: Errors during launch may be warnings (e.g. outdated debug info). Report to user, and allow to ignore.

git-svn-id: trunk@60649 -
This commit is contained in:
martin 2019-03-10 17:59:59 +00:00
parent db921aff87
commit 8e825867ba
3 changed files with 71 additions and 12 deletions

View File

@ -96,6 +96,7 @@ type
FDwarfInfo: TFpDwarfInfo;
FMemReader: TFpLldbDbgMemReader;
FMemManager: TFpDbgMemManager;
FReaderErrors: String;
public
procedure Execute; override;
constructor Create(AFileName: String; ADebugger: TFpLldbDebugger);
@ -106,6 +107,7 @@ type
property DwarfInfo: TFpDwarfInfo read FDwarfInfo;
property MemReader: TFpLldbDbgMemReader read FMemReader;
property MemManager: TFpDbgMemManager read FMemManager;
property ReaderErrors: String read FReaderErrors;
end;
const
@ -129,13 +131,14 @@ type
procedure DoEndReceivingLines(Sender: TObject);
protected
procedure DoBeforeLaunch; override;
procedure DoAfterLaunch(var LaunchWarnings: string); override;
function CreateLineInfo: TDBGLineInfo; override;
function CreateWatches: TWatchesSupplier; override;
function CreateLocals: TLocalsSupplier; override;
function CreateDisassembler: TDBGDisassembler; override;
procedure DoState(const OldState: TDBGState); override;
function HasDwarf: Boolean;
procedure LoadDwarf;
function LoadDwarf: String;
procedure UnLoadDwarf;
function RequestCommand(const ACommand: TDBGCommand;
const AParams: array of const;
@ -299,6 +302,7 @@ begin
FImageLoaderList := TDbgImageLoaderList.Create(True);
AnImageLoader.AddToLoaderList(FImageLoaderList);
FReaderErrors := AnImageLoader.ReaderErrors;
if Terminated then
exit;
@ -1047,14 +1051,7 @@ var
begin
inherited DoState(OldState);
if State in [dsStop, dsError, dsNone] then
UnLoadDwarf
else
if (State = dsRun) and (OldState = dsInit) then begin
LoadDwarf;
{$IFdef WithWinMemReader}
TFpLldbAndWin32DbgMemReader(FMemReader).OpenProcess(TargetPid);
{$ENDIF}
end;
UnLoadDwarf;
if OldState in [dsPause, dsInternalPause] then begin
for i := 0 to MAX_CTX_CACHE-1 do
@ -1067,7 +1064,7 @@ begin
FWatchEvalList.Clear;
end;
end;
if (State = dsRun) then
if (State = dsRun) and (FMemManager <> nil) then
TFpLldbDbgMemCacheManagerSimple(FMemManager.CacheManager).Clear;
end;
@ -1076,11 +1073,12 @@ begin
Result := FDwarfInfo <> nil;
end;
procedure TFpLldbDebugger.LoadDwarf;
function TFpLldbDebugger.LoadDwarf: String;
var
AnImageLoader: TDbgImageLoader;
Loader: TDwarfLoaderThread;
begin
Result := ''; // no errors/warnings
Loader := FDwarfLoaderThread;
FDwarfLoaderThread := nil;
@ -1093,6 +1091,7 @@ begin
FMemReader := Loader.MemReader;
FMemManager := Loader.MemManager;
FDwarfInfo := Loader.DwarfInfo;
Result := Loader.ReaderErrors;
Loader.Free;
if FDwarfInfo.Image64Bit then
@ -1110,6 +1109,7 @@ begin
end;
FImageLoaderList := TDbgImageLoaderList.Create(True);
AnImageLoader.AddToLoaderList(FImageLoaderList);
Result := AnImageLoader.ReaderErrors;
{$IFdef WithWinMemReader}
FMemReader := TFpLldbAndWin32DbgMemReader.Create(Self);
{$Else}
@ -1529,6 +1529,15 @@ begin
end;
end;
procedure TFpLldbDebugger.DoAfterLaunch(var LaunchWarnings: string);
begin
inherited DoAfterLaunch(LaunchWarnings);
LaunchWarnings := LaunchWarnings + LoadDwarf;
{$IFdef WithWinMemReader}
TFpLldbAndWin32DbgMemReader(FMemReader).OpenProcess(TargetPid);
{$ENDIF}
end;
function TFpLldbDebugger.CreateLineInfo: TDBGLineInfo;
begin
Result := TFpLldbLineInfo.Create(Self);

View File

@ -166,6 +166,7 @@ type
private
FRunInstr: TLldbInstruction;
procedure ExceptBreakInstructionFinished(Sender: TObject);
procedure LaunchInstructionSucceeded(Sender: TObject);
procedure TargetCreated(Sender: TObject);
protected
procedure DoInitialExecute; override;
@ -269,12 +270,14 @@ type
private
FLaunchNewTerminal: Boolean;
FSkipGDBDetection: Boolean;
FIgnoreLaunchWarnings: Boolean;
public
constructor Create; override;
procedure Assign(Source: TPersistent); override;
published
property LaunchNewTerminal: Boolean read FLaunchNewTerminal write FLaunchNewTerminal default False;
property SkipGDBDetection: Boolean read FSkipGDBDetection write FSkipGDBDetection default False;
property IgnoreLaunchWarnings: Boolean read FIgnoreLaunchWarnings write FIgnoreLaunchWarnings default False;
end;
TLldbDebugger = class(TDebuggerIntf)
@ -316,6 +319,7 @@ type
procedure TerminateLldb; // Kills external debugger
protected
procedure DoBeforeLaunch; virtual;
procedure DoAfterLaunch(var LaunchWarnings: string); virtual;
procedure DoBeginReceivingLines(Sender: TObject);
procedure DoEndReceivingLines(Sender: TObject);
procedure LockRelease; override;
@ -533,6 +537,7 @@ begin
inherited Create;
FLaunchNewTerminal := False;
FSkipGDBDetection := False;
FIgnoreLaunchWarnings := False;
end;
procedure TLldbDebuggerProperties.Assign(Source: TPersistent);
@ -540,6 +545,7 @@ begin
inherited Assign(Source);
FLaunchNewTerminal := TLldbDebuggerProperties(Source).FLaunchNewTerminal;
FSkipGDBDetection := TLldbDebuggerProperties(Source).FSkipGDBDetection;
FIgnoreLaunchWarnings := TLldbDebuggerProperties(Source).FIgnoreLaunchWarnings;
end;
{ TLldbDebuggerCommandRun }
@ -2383,12 +2389,39 @@ begin
// the state change allows breakpoints to be set, before the run command is issued.
FRunInstr := TLldbInstructionProcessLaunch.Create(TLldbDebuggerProperties(Debugger.GetProperties).LaunchNewTerminal);
FRunInstr.OnSuccess := @RunInstructionSucceeded;
FRunInstr.OnSuccess := @LaunchInstructionSucceeded;
FRunInstr.OnFailure := @InstructionFailed;
QueueInstruction(FRunInstr);
FRunInstr.ReleaseReference;
end;
procedure TLldbDebuggerCommandRunLaunch.LaunchInstructionSucceeded(Sender: TObject);
var
LaunchWarnings: String;
begin
LaunchWarnings := TLldbInstructionProcessLaunch(Sender).Errors;
Debugger.DoAfterLaunch(LaunchWarnings);
if (not TLldbDebuggerProperties(Debugger.GetProperties).IgnoreLaunchWarnings) and
(LaunchWarnings <> '') and
assigned(Debugger.OnFeedback)
then begin
case Debugger.OnFeedback(self,
Format('The debugger encountered some errors/warnings while launching the target application.%0:s'
+ 'Press "Ok" to continue debugging.%0:s'
+ 'Press "Stop" to end the debug session.',
[LineEnding]),
LaunchWarnings, ftWarning, [frOk, frStop]
) of
frOk: begin
end;
frStop: begin
Debugger.Stop;
end;
end;
end;
RunInstructionSucceeded(Sender);
end;
procedure TLldbDebuggerCommandRunLaunch.DoInitialExecute;
var
Instr: TLldbInstruction;
@ -2756,6 +2789,11 @@ begin
//
end;
procedure TLldbDebugger.DoAfterLaunch(var LaunchWarnings: string);
begin
//
end;
procedure TLldbDebugger.LockRelease;
begin
inherited LockRelease;

View File

@ -119,10 +119,13 @@ type
{ TLldbInstructionProcessLaunch }
TLldbInstructionProcessLaunch = class(TLldbInstruction)
private
FErrors: String;
protected
function ProcessInputFromDbg(const AData: String): Boolean; override;
public
constructor Create(AOpenTerminal: Boolean);
property Errors: String read FErrors;
end;
{ TLldbInstructionProcessStep }
@ -693,6 +696,15 @@ begin
if StrStartsWith(AData, 'Process ') and (pos(' launched:', AData) > 8) then begin
SetContentReceieved;
end
else
if LeftStr(AData, 7) = 'error: ' then begin
if StrContains(LowerCase(AData), 'launch failed') or
StrContains(LowerCase(AData), 'process')
then
Result := inherited
else
FErrors := FErrors + AData + LineEnding;
end
else
Result := inherited;
Result := True; // Ignore any "process stopped", before "launched"