diff --git a/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas b/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas index 09959a4f10..4aa61f7bd5 100644 --- a/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas +++ b/components/lazdebuggers/lazdebuggerlldb/lldbdebugger.pas @@ -2592,12 +2592,26 @@ begin end; procedure TLldbDebuggerCommandEvaluate.DoExecute; +var + s: String; begin if FWatchValue <> nil then - FInstr := TLldbInstructionExpression.Create(FWatchValue.Expression, FWatchValue.ThreadId, FWatchValue.StackFrame) + s := FWatchValue.Expression + else + s := FExpr; + + s := Trim(RemoveLineBreaks(s)); + if s = '' then begin + EvalInstructionFailed(nil); + exit; + end; + + + if FWatchValue <> nil then + FInstr := TLldbInstructionExpression.Create(s, FWatchValue.ThreadId, FWatchValue.StackFrame) else // todo: only if FCallback ? - FInstr := TLldbInstructionExpression.Create(FExpr, Debugger.FCurrentThreadId, Debugger.FCurrentStackFrame); + FInstr := TLldbInstructionExpression.Create(s, Debugger.FCurrentThreadId, Debugger.FCurrentStackFrame); FInstr.OnSuccess := @EvalInstructionSucceeded; FInstr.OnFailure := @EvalInstructionFailed; QueueInstruction(FInstr); diff --git a/components/lazdebuggers/lazdebuggerlldb/lldbhelper.pas b/components/lazdebuggers/lazdebuggerlldb/lldbhelper.pas index 0959d4b8bd..e10a2c760b 100644 --- a/components/lazdebuggers/lazdebuggerlldb/lldbhelper.pas +++ b/components/lazdebuggers/lazdebuggerlldb/lldbhelper.pas @@ -46,6 +46,8 @@ function ParseNewThreadLocation(AnInput: String; out AnId: Integer; out AFuncName: String; out AnArgs: TStringList; out AFile, AFullFile: String; out ALine: Integer; out AReminder: String): Boolean; +function RemoveLineBreaks(const s: String): String; + implementation function LastPos(ASearch, AString: string): Integer; @@ -358,5 +360,16 @@ begin AFuncName, AnArgs, AFile, AFullFile, ALine, AReminder); end; +function RemoveLineBreaks(const s: String): String; +var + i: Integer; +begin + Result := s; + UniqueString(Result); + for i := 1 to Length(Result) do + if Result[i] in [#0..#31] then + pchar(Result)[i-1] := ' '; +end; + end. diff --git a/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas b/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas index e2f1bd204a..4f492786c8 100644 --- a/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas +++ b/components/lazdebuggers/lazdebuggerlldb/lldbinstructions.pas @@ -1137,6 +1137,8 @@ constructor TLldbInstructionExpression.Create(AnExpression: String; AThread, AFrame: Integer); begin // inherited Create(Format('expression -R -- %s', [UpperCase(AnExpression)])); + AnExpression := Trim(RemoveLineBreaks(AnExpression)); + if AnExpression = '' then AnExpression := '0-()'; // some error as last resort inherited Create(Format('expression -T -- %s', [UpperCase(AnExpression)]), AThread, AFrame); end;