mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 18:59:10 +02:00
LldbDebugger: prevent empty watch value / this leads to an incorrect command send to lldb.
(cherry picked from commit cefc513642
)
This commit is contained in:
parent
7b1d980aeb
commit
e76005ab44
@ -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);
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user