mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 18:22:54 +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;
|
Result := True;
|
||||||
FSuccess := False;
|
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)
|
// Tnit (StartDebugging)
|
||||||
TargetInfo^.TargetFlags := [tfHasSymbols]; // Set until proven otherwise
|
TargetInfo^.TargetFlags := [tfHasSymbols]; // Set until proven otherwise
|
||||||
ExecuteCommand('-gdb-set language pascal', [cfCheckError]);
|
ExecuteCommand('-gdb-set language pascal', [cfCheckError]);
|
||||||
@ -4748,6 +4758,14 @@ begin
|
|||||||
|
|
||||||
TargetInfo^.TargetPID := NewPID;
|
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)
|
// Tnit (StartDebugging)
|
||||||
// check if the exe is compiled with FPC >= 1.9.2
|
// check if the exe is compiled with FPC >= 1.9.2
|
||||||
|
@ -152,7 +152,7 @@ type
|
|||||||
procedure ResetDebugger;
|
procedure ResetDebugger;
|
||||||
|
|
||||||
function GetLaunchPathAndExe(out LaunchingCmdLine, LaunchingApplication,
|
function GetLaunchPathAndExe(out LaunchingCmdLine, LaunchingApplication,
|
||||||
LaunchingParams: String): Boolean;
|
LaunchingParams: String; PromptOnError: Boolean = True): Boolean;
|
||||||
protected
|
protected
|
||||||
function GetState: TDBGState; override;
|
function GetState: TDBGState; override;
|
||||||
function GetCommands: TDBGCommands; override;
|
function GetCommands: TDBGCommands; override;
|
||||||
@ -2018,7 +2018,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TDebugManager.GetLaunchPathAndExe(out LaunchingCmdLine,
|
function TDebugManager.GetLaunchPathAndExe(out LaunchingCmdLine,
|
||||||
LaunchingApplication, LaunchingParams: String): Boolean;
|
LaunchingApplication, LaunchingParams: String; PromptOnError: Boolean
|
||||||
|
): Boolean;
|
||||||
|
|
||||||
|
procedure ClearPathAndExe;
|
||||||
|
begin
|
||||||
|
LaunchingApplication := '';
|
||||||
|
LaunchingParams := '';
|
||||||
|
LaunchingCmdLine := '';
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
NewDebuggerClass: TDebuggerClass;
|
NewDebuggerClass: TDebuggerClass;
|
||||||
begin
|
begin
|
||||||
@ -2038,6 +2047,9 @@ begin
|
|||||||
|
|
||||||
if not DirectoryExistsUTF8(LaunchingApplication) then
|
if not DirectoryExistsUTF8(LaunchingApplication) then
|
||||||
begin
|
begin
|
||||||
|
if not PromptOnError then
|
||||||
|
ClearPathAndExe
|
||||||
|
else
|
||||||
if MessageDlg(lisLaunchingApplicationInvalid,
|
if MessageDlg(lisLaunchingApplicationInvalid,
|
||||||
Format(lisTheLaunchingApplicationBundleDoesNotExists,
|
Format(lisTheLaunchingApplicationBundleDoesNotExists,
|
||||||
[LaunchingCmdLine, #13, #13, #13, #13]),
|
[LaunchingCmdLine, #13, #13, #13, #13]),
|
||||||
@ -2049,33 +2061,40 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if NewDebuggerClass = TProcessDebugger then
|
if (NewDebuggerClass = TProcessDebugger) and (LaunchingApplication <> '') then
|
||||||
begin // use executable path inside Application Bundle (darwin only)
|
begin // use executable path inside Application Bundle (darwin only)
|
||||||
LaunchingApplication := LaunchingApplication + '/Contents/MacOS/' +
|
LaunchingApplication := LaunchingApplication + '/Contents/MacOS/' +
|
||||||
ExtractFileNameOnly(LaunchingApplication);
|
ExtractFileNameOnly(LaunchingApplication);
|
||||||
LaunchingParams := LaunchingParams;
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not FileIsExecutable(LaunchingApplication)
|
if not FileIsExecutable(LaunchingApplication)
|
||||||
then begin
|
then begin
|
||||||
|
if not PromptOnError then
|
||||||
|
ClearPathAndExe
|
||||||
|
else begin
|
||||||
MessageDlg(lisLaunchingApplicationInvalid,
|
MessageDlg(lisLaunchingApplicationInvalid,
|
||||||
Format(lisTheLaunchingApplicationDoesNotExistsOrIsNotExecuta, ['"',
|
Format(lisTheLaunchingApplicationDoesNotExistsOrIsNotExecuta, ['"',
|
||||||
LaunchingCmdLine, '"', #13, #13, #13]),
|
LaunchingCmdLine, '"', #13, #13, #13]),
|
||||||
mtError, [mbOK],0);
|
mtError, [mbOK],0);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
//todo: this check depends on the debugger class
|
//todo: this check depends on the debugger class
|
||||||
if (NewDebuggerClass <> TProcessDebugger)
|
if (NewDebuggerClass <> TProcessDebugger)
|
||||||
and not FileIsExecutable(EnvironmentOptions.GetParsedDebuggerFilename)
|
and not FileIsExecutable(EnvironmentOptions.GetParsedDebuggerFilename)
|
||||||
then begin
|
then begin
|
||||||
|
if not PromptOnError then
|
||||||
|
ClearPathAndExe
|
||||||
|
else begin
|
||||||
MessageDlg(lisDebuggerInvalid,
|
MessageDlg(lisDebuggerInvalid,
|
||||||
Format(lisTheDebuggerDoesNotExistsOrIsNotExecutableSeeEnviro, ['"',
|
Format(lisTheDebuggerDoesNotExistsOrIsNotExecutableSeeEnviro, ['"',
|
||||||
EnvironmentOptions.DebuggerFilename, '"', #13, #13, #13]),
|
EnvironmentOptions.DebuggerFilename, '"', #13, #13, #13]),
|
||||||
mtError,[mbOK],0);
|
mtError,[mbOK],0);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end; // if NewDebuggerClass.RequiresLocalExecutable then
|
end; // if NewDebuggerClass.RequiresLocalExecutable then
|
||||||
Result := True;
|
Result := True;
|
||||||
@ -2097,11 +2116,14 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if Destroying then Exit;
|
||||||
if not(difInitForAttach in AFlags) then begin
|
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
|
if not GetLaunchPathAndExe(LaunchingCmdLine, LaunchingApplication, LaunchingParams) then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end
|
||||||
|
else
|
||||||
|
GetLaunchPathAndExe(LaunchingCmdLine, LaunchingApplication, LaunchingParams, False);
|
||||||
|
|
||||||
FUnitInfoProvider.Clear;
|
FUnitInfoProvider.Clear;
|
||||||
FIsInitializingDebugger:= True;
|
FIsInitializingDebugger:= True;
|
||||||
@ -2206,6 +2228,11 @@ begin
|
|||||||
then FDebugger.Arguments := LaunchingParams;
|
then FDebugger.Arguments := LaunchingParams;
|
||||||
if FDebugger <> nil
|
if FDebugger <> nil
|
||||||
then FDebugger.ShowConsole := not Project1.CompilerOptions.Win32GraphicApp;
|
then FDebugger.ShowConsole := not Project1.CompilerOptions.Win32GraphicApp;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
// attach
|
||||||
|
if (FDebugger <> nil) and (LaunchingApplication <> '')
|
||||||
|
then FDebugger.FileName := LaunchingApplication;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check if debugging needs restart
|
// check if debugging needs restart
|
||||||
|
@ -3391,7 +3391,10 @@ begin
|
|||||||
if InputQuery(rsAttachTo, rsEnterPID, s) then begin
|
if InputQuery(rsAttachTo, rsEnterPID, s) then begin
|
||||||
ToolStatus := itDebugger;
|
ToolStatus := itDebugger;
|
||||||
DebugBoss.Attach(s);
|
DebugBoss.Attach(s);
|
||||||
end;
|
end
|
||||||
|
else
|
||||||
|
if ToolStatus = itDebugger then
|
||||||
|
ToolStatus := itNone;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ecDetach:
|
ecDetach:
|
||||||
|
Loading…
Reference in New Issue
Block a user