LazDebugger, lldb: fix process terminated / add environment / add cmd line args

git-svn-id: trunk@58845 -
This commit is contained in:
martin 2018-09-03 22:36:24 +00:00
parent 40b1ac11fd
commit d7046574ac
2 changed files with 99 additions and 6 deletions

View File

@ -9,8 +9,8 @@ interface
uses
Classes, SysUtils, math, DbgIntfDebuggerBase, DbgIntfBaseTypes, LazLoggerBase,
LazClasses, LazFileUtils, Maps, strutils, DebugProcess, LldbInstructions,
LldbHelper;
LazClasses, LazFileUtils, Maps, LCLProc, strutils, DebugProcess,
LldbInstructions, LldbHelper;
type
@ -209,6 +209,7 @@ type
function LldbStep(AStepAction: TLldbInstructionProcessStepAction): Boolean;
function LldbStop: Boolean;
function LldbEvaluate(const AExpression: String; EvalFlags: TDBGEvaluateFlags; ACallback: TDBGEvaluateResultCallback): Boolean;
function LldbEnvironment(const AVariable: String; const ASet: Boolean): Boolean;
protected
procedure DoBeginReceivingLines(Sender: TObject);
procedure DoEndReceivingLines(Sender: TObject);
@ -651,6 +652,11 @@ begin
exit;
end;
if (LeftStr(ALine, 8) = 'Process ') and (pos('exited with status = ', ALine) > 0) then begin
Finished;
exit; // handle in main debugger
end;
// Executed, if "frame #0" was not found
if FState = crStoppedAtException then begin // did not get location
Debugger.FCurrentLocation.Address := 0;
@ -1638,6 +1644,10 @@ begin
{$ENDIF}
end;
Instr := TLldbInstructionSettingSet.Create('target.run-args', Debugger.Arguments);
QueueInstruction(Instr);
Instr.ReleaseReference;
Instr := TLldbInstructionBreakSet.Create('fpc_raiseexception');
Instr.OnFinish := @ExceptBreakInstructionFinished;
QueueInstruction(Instr);
@ -1895,6 +1905,25 @@ begin
Result := True;
end;
function TLldbDebugger.LldbEnvironment(const AVariable: String;
const ASet: Boolean): Boolean;
var
Instr: TLldbInstruction;
s: String;
begin
debugln(['-----------------------------------------', AVariable]);
if ASet then
Instr := TLldbInstructionSettingSet.Create('target.env-vars', AVariable, False, True)
else begin
s := AVariable;
Instr := TLldbInstructionSettingRemove.Create('target.env-vars', GetPart([], ['='], s, False, False));
end;
FDebugInstructionQueue.QueueInstruction(Instr);
Instr.ReleaseReference;
Result := True;
end;
procedure TLldbDebugger.LockRelease;
begin
inherited LockRelease;
@ -2005,7 +2034,8 @@ end;
function TLldbDebugger.GetSupportedCommands: TDBGCommands;
begin
Result := [dcRun, dcStop, dcStepOver, dcStepInto, dcStepOut, dcEvaluate];
Result := [dcRun, dcStop, dcStepOver, dcStepInto, dcStepOut, dcEvaluate,
dcEnvironment];
// Result := [dcPause, dcStepOverInstr, dcStepIntoInstr, dcRunTo, dcAttach, dcDetach, dcJumpto,
// dcBreak, dcWatch, dcLocal, dcEvaluate, dcModify, dcEnvironment,
// dcSetStackFrame, dcDisassemble
@ -2038,7 +2068,7 @@ begin
// dcAttach: Result := GDBAttach(String(AParams[0].VAnsiString));
// dcDetach: Result := GDBDetach;
// dcModify: Result := GDBModify(String(AParams[0].VAnsiString), String(AParams[1].VAnsiString));
// dcEnvironment: Result := GDBEnvironment(String(AParams[0].VAnsiString), AParams[1].VBoolean);
dcEnvironment: Result := LldbEnvironment(String(AParams[0].VAnsiString), AParams[1].VBoolean);
// dcDisassemble: Result := GDBDisassemble(AParams[0].VQWord^, AParams[1].VBoolean, TDbgPtr(AParams[2].VPointer^),
// String(AParams[3].VPointer^), String(AParams[4].VPointer^),
// String(AParams[5].VPointer^), Integer(AParams[6].VPointer^))

View File

@ -52,7 +52,25 @@ type
protected
function ProcessInputFromDbg(const AData: String): Boolean; override;
public
constructor Create(AName, AValue: String; AGlobal: Boolean = False);
constructor Create(AName, AValue: String; AGlobal: Boolean = False; AQuote: Boolean = False);
end;
{ TLldbInstructionSettingRemove }
TLldbInstructionSettingRemove = class(TLldbInstruction)
protected
function ProcessInputFromDbg(const AData: String): Boolean; override;
public
constructor Create(AName, AValue: String; AQuote: Boolean = False);
end;
{ TLldbInstructionSettingClear }
TLldbInstructionSettingClear = class(TLldbInstruction)
protected
function ProcessInputFromDbg(const AData: String): Boolean; override;
public
constructor Create(AName: String);
end;
{ TLldbInstructionTargetCreate }
@ -515,14 +533,59 @@ begin
end;
constructor TLldbInstructionSettingSet.Create(AName, AValue: String;
AGlobal: Boolean);
AGlobal: Boolean; AQuote: Boolean);
begin
if AQuote then begin
AValue := StringReplace(AValue, '\', '\\', [rfReplaceAll]);
AValue := StringReplace(AValue, '"', '\"', [rfReplaceAll]);
AValue := '"'+AValue+'"';
end;
if AGlobal then
inherited Create(Format('settings set -g -- %s %s', [AName, AValue]))
else
inherited Create(Format('settings set -- %s %s', [AName, AValue]));
end;
{ TLldbInstructionSettingRemove }
function TLldbInstructionSettingRemove.ProcessInputFromDbg(const AData: String
): Boolean;
begin
Result := inherited ProcessInputFromDbg(AData);
if not Result then // if Result=true then self is destroyed;
MarkAsSuccess;
Result := true;
end;
constructor TLldbInstructionSettingRemove.Create(AName, AValue: String;
AQuote: Boolean);
begin
if AQuote then begin
AValue := StringReplace(AValue, '\', '\\', [rfReplaceAll]);
AValue := StringReplace(AValue, '"', '\"', [rfReplaceAll]);
AValue := '"'+AValue+'"';
end;
inherited Create(Format('settings remove %s %s', [AName, AValue]));
end;
{ TLldbInstructionSettingClear }
function TLldbInstructionSettingClear.ProcessInputFromDbg(const AData: String
): Boolean;
begin
Result := inherited ProcessInputFromDbg(AData);
if not Result then // if Result=true then self is destroyed;
MarkAsSuccess;
Result := true;
end;
constructor TLldbInstructionSettingClear.Create(AName: String);
begin
inherited Create(Format('settings clear -- %s', [AName]));
end;
{ TLldbInstructionTargetCreate }
function TLldbInstructionTargetCreate.ProcessInputFromDbg(const AData: String