mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 11:58:12 +02:00
Debugger: added Attach/Detach
git-svn-id: trunk@38544 -
This commit is contained in:
parent
b8de86d9ae
commit
696d0835c2
@ -4668,6 +4668,16 @@ begin
|
||||
Result := True;
|
||||
FSuccess := False;
|
||||
|
||||
if not ExecuteCommand('-file-exec-and-symbols %s',
|
||||
[FTheDebugger.ConvertToGDBPath(UTF8ToSys(''), cgptExeName)], R)
|
||||
then
|
||||
R.State := dsError;
|
||||
if R.State = dsError then begin
|
||||
SetDebuggerErrorState('Attach failed');
|
||||
exit;
|
||||
end;
|
||||
|
||||
|
||||
// Tnit (StartDebugging)
|
||||
TargetInfo^.TargetFlags := [tfHasSymbols]; // Set until proven otherwise
|
||||
ExecuteCommand('-gdb-set language pascal', [cfCheckError]);
|
||||
@ -4748,6 +4758,14 @@ begin
|
||||
|
||||
TargetInfo^.TargetPID := NewPID;
|
||||
|
||||
debugln(['XXXXXXXXXXXXXX ',FTheDebugger.FileName, ' -- ', pos('Reading symbols from', CmdResp)]);
|
||||
if (FTheDebugger.FileName <> '') and (pos('READING SYMBOLS FROM', UpperCase(CmdResp)) < 1) then begin
|
||||
ExecuteCommand('ptype TObject', [], R);
|
||||
if pos('NO SYMBOL TABLE IS LOADED', UpperCase(FFullCmdReply)) > 0 then begin
|
||||
ExecuteCommand('-file-exec-and-symbols %s',
|
||||
[FTheDebugger.ConvertToGDBPath(UTF8ToSys(FTheDebugger.FileName), cgptExeName)], R);
|
||||
end;
|
||||
end;
|
||||
|
||||
// Tnit (StartDebugging)
|
||||
// check if the exe is compiled with FPC >= 1.9.2
|
||||
|
@ -152,7 +152,7 @@ type
|
||||
procedure ResetDebugger;
|
||||
|
||||
function GetLaunchPathAndExe(out LaunchingCmdLine, LaunchingApplication,
|
||||
LaunchingParams: String): Boolean;
|
||||
LaunchingParams: String; PromptOnError: Boolean = True): Boolean;
|
||||
protected
|
||||
function GetState: TDBGState; override;
|
||||
function GetCommands: TDBGCommands; override;
|
||||
@ -2018,7 +2018,16 @@ begin
|
||||
end;
|
||||
|
||||
function TDebugManager.GetLaunchPathAndExe(out LaunchingCmdLine,
|
||||
LaunchingApplication, LaunchingParams: String): Boolean;
|
||||
LaunchingApplication, LaunchingParams: String; PromptOnError: Boolean
|
||||
): Boolean;
|
||||
|
||||
procedure ClearPathAndExe;
|
||||
begin
|
||||
LaunchingApplication := '';
|
||||
LaunchingParams := '';
|
||||
LaunchingCmdLine := '';
|
||||
end;
|
||||
|
||||
var
|
||||
NewDebuggerClass: TDebuggerClass;
|
||||
begin
|
||||
@ -2038,43 +2047,53 @@ begin
|
||||
|
||||
if not DirectoryExistsUTF8(LaunchingApplication) then
|
||||
begin
|
||||
if MessageDlg(lisLaunchingApplicationInvalid,
|
||||
Format(lisTheLaunchingApplicationBundleDoesNotExists,
|
||||
[LaunchingCmdLine, #13, #13, #13, #13]),
|
||||
mtError, [mbYes, mbNo, mbCancel], 0) = mrYes then
|
||||
begin
|
||||
if not BuildBoss.CreateProjectApplicationBundle then Exit;
|
||||
end
|
||||
if not PromptOnError then
|
||||
ClearPathAndExe
|
||||
else
|
||||
Exit;
|
||||
if MessageDlg(lisLaunchingApplicationInvalid,
|
||||
Format(lisTheLaunchingApplicationBundleDoesNotExists,
|
||||
[LaunchingCmdLine, #13, #13, #13, #13]),
|
||||
mtError, [mbYes, mbNo, mbCancel], 0) = mrYes then
|
||||
begin
|
||||
if not BuildBoss.CreateProjectApplicationBundle then Exit;
|
||||
end
|
||||
else
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if NewDebuggerClass = TProcessDebugger then
|
||||
if (NewDebuggerClass = TProcessDebugger) and (LaunchingApplication <> '') then
|
||||
begin // use executable path inside Application Bundle (darwin only)
|
||||
LaunchingApplication := LaunchingApplication + '/Contents/MacOS/' +
|
||||
ExtractFileNameOnly(LaunchingApplication);
|
||||
LaunchingParams := LaunchingParams;
|
||||
end;
|
||||
end
|
||||
else
|
||||
if not FileIsExecutable(LaunchingApplication)
|
||||
then begin
|
||||
MessageDlg(lisLaunchingApplicationInvalid,
|
||||
Format(lisTheLaunchingApplicationDoesNotExistsOrIsNotExecuta, ['"',
|
||||
LaunchingCmdLine, '"', #13, #13, #13]),
|
||||
mtError, [mbOK],0);
|
||||
Exit;
|
||||
if not PromptOnError then
|
||||
ClearPathAndExe
|
||||
else begin
|
||||
MessageDlg(lisLaunchingApplicationInvalid,
|
||||
Format(lisTheLaunchingApplicationDoesNotExistsOrIsNotExecuta, ['"',
|
||||
LaunchingCmdLine, '"', #13, #13, #13]),
|
||||
mtError, [mbOK],0);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
//todo: this check depends on the debugger class
|
||||
if (NewDebuggerClass <> TProcessDebugger)
|
||||
and not FileIsExecutable(EnvironmentOptions.GetParsedDebuggerFilename)
|
||||
then begin
|
||||
MessageDlg(lisDebuggerInvalid,
|
||||
Format(lisTheDebuggerDoesNotExistsOrIsNotExecutableSeeEnviro, ['"',
|
||||
EnvironmentOptions.DebuggerFilename, '"', #13, #13, #13]),
|
||||
mtError,[mbOK],0);
|
||||
Exit;
|
||||
if not PromptOnError then
|
||||
ClearPathAndExe
|
||||
else begin
|
||||
MessageDlg(lisDebuggerInvalid,
|
||||
Format(lisTheDebuggerDoesNotExistsOrIsNotExecutableSeeEnviro, ['"',
|
||||
EnvironmentOptions.DebuggerFilename, '"', #13, #13, #13]),
|
||||
mtError,[mbOK],0);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
end; // if NewDebuggerClass.RequiresLocalExecutable then
|
||||
@ -2097,11 +2116,14 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
if Destroying then Exit;
|
||||
if not(difInitForAttach in AFlags) then begin
|
||||
if (Project1.MainUnitID < 0) or Destroying then Exit;
|
||||
if (Project1.MainUnitID < 0) then Exit;
|
||||
if not GetLaunchPathAndExe(LaunchingCmdLine, LaunchingApplication, LaunchingParams) then
|
||||
exit;
|
||||
end;
|
||||
end
|
||||
else
|
||||
GetLaunchPathAndExe(LaunchingCmdLine, LaunchingApplication, LaunchingParams, False);
|
||||
|
||||
FUnitInfoProvider.Clear;
|
||||
FIsInitializingDebugger:= True;
|
||||
@ -2206,6 +2228,11 @@ begin
|
||||
then FDebugger.Arguments := LaunchingParams;
|
||||
if FDebugger <> nil
|
||||
then FDebugger.ShowConsole := not Project1.CompilerOptions.Win32GraphicApp;
|
||||
end
|
||||
else begin
|
||||
// attach
|
||||
if (FDebugger <> nil) and (LaunchingApplication <> '')
|
||||
then FDebugger.FileName := LaunchingApplication;
|
||||
end;
|
||||
|
||||
// check if debugging needs restart
|
||||
|
@ -3391,7 +3391,10 @@ begin
|
||||
if InputQuery(rsAttachTo, rsEnterPID, s) then begin
|
||||
ToolStatus := itDebugger;
|
||||
DebugBoss.Attach(s);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if ToolStatus = itDebugger then
|
||||
ToolStatus := itNone;
|
||||
end;
|
||||
end;
|
||||
ecDetach:
|
||||
|
Loading…
Reference in New Issue
Block a user