LazDebugger(Fp)Lldb: improve checks for errors during launch command. Ignore text in file names.

git-svn-id: trunk@61001 -
This commit is contained in:
martin 2019-04-17 15:01:01 +00:00
parent 97dbba89f5
commit b31e03db6b
2 changed files with 66 additions and 22 deletions

View File

@ -168,6 +168,8 @@ type
TLldbDebuggerCommandRunLaunch = class(TLldbDebuggerCommandRun)
private
FRunInstr: TLldbInstruction;
FLaunchWarnings: String;
procedure CollectDwarfLoadErrors(Sender: TObject);
procedure ExceptBreakInstructionFinished(Sender: TObject);
procedure LaunchInstructionSucceeded(Sender: TObject);
procedure TargetCreated(Sender: TObject);
@ -227,6 +229,7 @@ type
TlldbInternalBreakPoint = class
private
FDwarfLoadErrors: String;
FName: String;
FBeforePrologue: Boolean;
FId: Integer;
@ -246,6 +249,7 @@ type
property BreakId: Integer read FId;
property OnFail: TNotifyEvent read FOnFail write FOnFail;
property OnFinish: TNotifyEvent read FOnFinish write FOnFinish;
property DwarfLoadErrors: String read FDwarfLoadErrors;
end;
{ TLldbDebuggerCommandRegister }
@ -2320,6 +2324,7 @@ begin
SetDebuggerState(dsError);
Finished;
end;
CollectDwarfLoadErrors(Sender);
If StrMatches(TargetInstr.Res, [''{}, '','('{}, ')',''], found) then begin
if (found[1] = 'i386') or (found[1] = 'i686') then begin
@ -2373,21 +2378,35 @@ begin
Instr := TLldbInstructionSettingSet.Create('target.run-args', Debugger.Arguments)
else
Instr := TLldbInstructionSettingClear.Create('target.run-args');
Instr.OnFinish := @CollectDwarfLoadErrors;
QueueInstruction(Instr);
Instr.ReleaseReference;
Debugger.FBreakErrorBreak.OnFinish := @CollectDwarfLoadErrors;
Debugger.FRunErrorBreak.OnFinish := @CollectDwarfLoadErrors;
Debugger.FExceptionBreak.OnFinish := @ExceptBreakInstructionFinished;
Debugger.FBreakErrorBreak.Enable;
Debugger.FRunErrorBreak.Enable;
Debugger.FExceptionBreak.OnFinish := @ExceptBreakInstructionFinished;
Debugger.FExceptionBreak.Enable;
end;
procedure TLldbDebuggerCommandRunLaunch.CollectDwarfLoadErrors(Sender: TObject);
begin
if Sender is TlldbInternalBreakPoint then begin
FLaunchWarnings := FLaunchWarnings + TlldbInternalBreakPoint(Sender).DwarfLoadErrors;
TlldbInternalBreakPoint(Sender).OnFinish := nil;
end
else
FLaunchWarnings := FLaunchWarnings + TLldbInstruction(Sender).DwarfLoadErrors;
end;
procedure TLldbDebuggerCommandRunLaunch.ExceptBreakInstructionFinished(Sender: TObject
);
var
Instr: TLldbInstruction;
BrkId: Integer;
begin
CollectDwarfLoadErrors(Sender);
Debugger.FBreakErrorBreak.OnFinish := nil;
Debugger.FExceptionInfo.FReg0Cmd := '';
@ -2406,6 +2425,7 @@ begin
Instr := TLldbInstructionBreakAddCommands.Create(BrkId, [
Debugger.FExceptionInfo.FReg0Cmd, Debugger.FExceptionInfo.FReg2Cmd, Debugger.FExceptionInfo.FExceptClassCmd, Debugger.FExceptionInfo.FExceptMsgCmd
]);
Instr.OnFinish := @CollectDwarfLoadErrors;
QueueInstruction(Instr);
Instr.ReleaseReference;
end;
@ -2414,6 +2434,7 @@ begin
if BrkId > 0 then begin
Debugger.FExceptionInfo.FReg0Cmd := 'p/x ' + Debugger.FTargetRegisters[0];
Instr := TLldbInstructionBreakAddCommands.Create(BrkId, [Debugger.FExceptionInfo.FReg0Cmd]);
Instr.OnFinish := @CollectDwarfLoadErrors;
QueueInstruction(Instr);
Instr.ReleaseReference;
end;
@ -2422,6 +2443,7 @@ begin
if BrkId > 0 then begin
Debugger.FExceptionInfo.FReg0Cmd := 'p/x ' + Debugger.FTargetRegisters[0];
Instr := TLldbInstructionBreakAddCommands.Create(BrkId, [Debugger.FExceptionInfo.FReg0Cmd]);
Instr.OnFinish := @CollectDwarfLoadErrors;
QueueInstruction(Instr);
Instr.ReleaseReference;
end;
@ -2437,13 +2459,11 @@ begin
end;
procedure TLldbDebuggerCommandRunLaunch.LaunchInstructionSucceeded(Sender: TObject);
var
LaunchWarnings: String;
begin
LaunchWarnings := TLldbInstructionProcessLaunch(Sender).Errors;
Debugger.DoAfterLaunch(LaunchWarnings);
CollectDwarfLoadErrors(Sender);
Debugger.DoAfterLaunch(FLaunchWarnings);
if (not TLldbDebuggerProperties(Debugger.GetProperties).IgnoreLaunchWarnings) and
(LaunchWarnings <> '') and
(FLaunchWarnings <> '') and
assigned(Debugger.OnFeedback)
then begin
case Debugger.OnFeedback(self,
@ -2451,7 +2471,7 @@ begin
+ 'Press "Ok" to continue debugging.%0:s'
+ 'Press "Stop" to end the debug session.',
[LineEnding]),
LaunchWarnings, ftWarning, [frOk, frStop]
FLaunchWarnings, ftWarning, [frOk, frStop]
) of
frOk: begin
end;
@ -2607,6 +2627,7 @@ end;
procedure TlldbInternalBreakPoint.DoFinshed(Sender: TObject);
begin
FDwarfLoadErrors := TLldbInstruction(Sender).DwarfLoadErrors;
if OnFinish <> nil then
OnFinish(Self);
end;

View File

@ -19,7 +19,7 @@ interface
uses
SysUtils, math, Classes, LazLoggerBase, DbgIntfDebuggerBase, DbgIntfBaseTypes,
DebugInstructions, LldbHelper;
strutils, DebugInstructions, LldbHelper;
type
@ -47,9 +47,11 @@ type
TLldbInstruction = class(TDBGInstruction)
private
FDwarfLoadErrors: String;
FOwningCommand: TObject;
function GetQueue: TLldbInstructionQueue;
protected
function MaskQuotedText(ALine: String): String;
function ProcessInputFromDbg(const AData: String): Boolean; override;
procedure SetContentReceieved; reintroduce;
@ -57,6 +59,7 @@ type
property NextInstruction;
public
property OwningCommand: TObject read FOwningCommand write FOwningCommand;
property DwarfLoadErrors: String read FDwarfLoadErrors;
end;
{ TLldbInstructionSettingSet }
@ -119,13 +122,10 @@ 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 }
@ -546,12 +546,42 @@ begin
Result := TLldbInstructionQueue(inherited Queue);
end;
function TLldbInstruction.MaskQuotedText(ALine: String): String;
var
p: PChar;
q: Boolean;
i: Integer;
begin
Result := ALine;
if Result = '' then
Exit;
UniqueString(Result);
p := @Result[1];
q := False;
for i := Length(Result) - 1 downto 0 do begin
if p^ = '''' then
q := not q;
if q then
p^ := ' ';
// The closing ' remains in text...
inc(p);
end;
end;
function TLldbInstruction.ProcessInputFromDbg(const AData: String): Boolean;
var
s: String;
begin
Result := False;
if LeftStr(AData, 7) = 'error: ' then begin
Result := True;
s := MaskQuotedText(LowerCase(AData));
if (StrContains(s, 'debug map time') and StrContains(s, 'file will be ignored'))
then begin
FDwarfLoadErrors := FDwarfLoadErrors + AData + LineEnding;
exit;
end;
Result := True;
HandleError(ifeContentError);
exit;
end;
@ -692,21 +722,14 @@ end;
function TLldbInstructionProcessLaunch.ProcessInputFromDbg(const AData: String
): Boolean;
var
s: String;
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;
inherited;
Result := True; // Ignore any "process stopped", before "launched"
end;