IdeDebugger: Move unit DebuggerDlg from Ide to IdeDebugger.

This commit is contained in:
Martin 2023-01-09 23:01:19 +01:00
parent d469c50a29
commit 0d3a7504d7
6 changed files with 55 additions and 31 deletions

View File

@ -261,6 +261,7 @@ type
function GetFullFilename(const AUnitinfo: TDebuggerUnitInfo; out Filename: string;
AskUserIfNotFound: Boolean): Boolean; override;
function GetFullFilename(var Filename: string; AskUserIfNotFound: Boolean): Boolean; override;
procedure JumpToUnitSource(AnUnitInfo: TDebuggerUnitInfo; ALine: Integer); override;
function DoCreateBreakPoint(const AFilename: string; ALine: integer;
WarnIfNoDebugger: boolean): TModalResult; override;
@ -971,6 +972,39 @@ begin
end;
end;
procedure TDebugManager.JumpToUnitSource(AnUnitInfo: TDebuggerUnitInfo;
ALine: Integer);
const
JmpFlags: TJumpToCodePosFlags =
[jfAddJumpPoint, jfFocusEditor, jfMarkLine, jfMapLineFromDebug, jfSearchVirtualFullPath];
var
Filename: String;
ok: Boolean;
begin
if AnUnitInfo = nil then exit;
debugln(DBG_LOCATION_INFO, ['JumpToUnitSource AnUnitInfo=', AnUnitInfo.DebugText ]);
// avoid any process-messages, so this proc can not be re-entered (avoid opening one files many times)
LockCommandProcessing;
try
(* Maybe trim the filename here and use jfDoNotExpandFilename
ExpandFilename works with the current IDE path, and may be wrong
*)
// TODO: better detection of unsaved project files
if GetFullFilename(AnUnitInfo, Filename, False) then
begin
ok := false;
if ALine <= 0 then
ALine := AnUnitInfo.SrcLine;
if FilenameIsAbsolute(Filename) then
ok := MainIDEInterface.DoJumpToSourcePosition(Filename, 0, ALine, 0, JmpFlags) = mrOK;
if not ok then
MainIDEInterface.DoJumpToSourcePosition(Filename, 0, ALine, 0, JmpFlags+[jfDoNotExpandFilename]);
end;
finally
UnLockCommandProcessing;
end;
end;
procedure TDebugManager.DebuggerConsoleOutput(Sender: TObject;
const AText: String);
begin

View File

@ -1024,6 +1024,12 @@ end;
{ TMainIDE }
function DoTranslateKey(Key: word; Shift: TShiftState;
IDEWindowClass: TCustomFormClass; UseLastKey: boolean = true): word;
begin
EditorOpts.KeyMap.TranslateKey(Key, Shift, IDEWindowClass, UseLastKey);
end;
{-------------------------------------------------------------------------------
procedure TMainIDE.ParseCmdLineOptions;
@ -1616,6 +1622,7 @@ begin
DebugBossManager:=DebugBoss;
DebugBoss.ConnectMainBarEvents;
DebuggerDlg.OnProcessCommand := @ProcessIDECommand;
DebuggerDlg.OnTranslateKey:= @DoTranslateKey;
PkgMngr:=TPkgManager.Create(nil);
PkgBoss:=PkgMngr;

View File

@ -176,6 +176,8 @@ type
function GetFullFilename(var Filename: string; AskUserIfNotFound: Boolean): Boolean; virtual; abstract;
procedure EvaluateModify(const AExpression: String; AWatch: TWatch = nil); virtual; abstract;
procedure JumpToUnitSource(AnUnitInfo: TDebuggerUnitInfo; ALine: Integer); virtual; abstract;
procedure Inspect(const AExpression: String; AWatch: TWatch = nil); virtual; abstract;
function DoCreateBreakPoint(const AFilename: string; ALine: integer;

View File

@ -47,7 +47,7 @@ uses
// DebuggerIntf
DbgIntfDebuggerBase, DbgIntfMiscClasses,
// IDE
MainIntf, EditorOptions, BaseDebugManager, Debugger;
BaseDebugManager, Debugger;
type
@ -123,6 +123,7 @@ type
TDebuggerDlgClass = class of TDebuggerDlg;
var
OnTranslateKey: function (Key: word; Shift: TShiftState; IDEWindowClass: TCustomFormClass; UseLastKey: boolean = true): word;
OnProcessCommand: procedure(Sender: TObject; Command: word; var Handled: boolean) of object;
procedure CreateDebugDialog(Sender: TObject; aFormName: string;
@ -367,35 +368,8 @@ begin
end;
procedure TDebuggerDlg.JumpToUnitSource(AnUnitInfo: TDebuggerUnitInfo; ALine: Integer);
const
JmpFlags: TJumpToCodePosFlags =
[jfAddJumpPoint, jfFocusEditor, jfMarkLine, jfMapLineFromDebug, jfSearchVirtualFullPath];
var
Filename: String;
ok: Boolean;
begin
if AnUnitInfo = nil then exit;
debugln(DBG_LOCATION_INFO, ['JumpToUnitSource AnUnitInfo=', AnUnitInfo.DebugText ]);
// avoid any process-messages, so this proc can not be re-entered (avoid opening one files many times)
DebugBoss.LockCommandProcessing;
try
(* Maybe trim the filename here and use jfDoNotExpandFilename
ExpandFilename works with the current IDE path, and may be wrong
*)
// TODO: better detection of unsaved project files
if DebugBoss.GetFullFilename(AnUnitInfo, Filename, False) then
begin
ok := false;
if ALine <= 0 then
ALine := AnUnitInfo.SrcLine;
if FilenameIsAbsolute(Filename) then
ok := MainIDEInterface.DoJumpToSourcePosition(Filename, 0, ALine, 0, JmpFlags) = mrOK;
if not ok then
MainIDEInterface.DoJumpToSourcePosition(Filename, 0, ALine, 0, JmpFlags+[jfDoNotExpandFilename]);
end;
finally
DebugBoss.UnLockCommandProcessing;
end;
DebugBoss.JumpToUnitSource(AnUnitInfo, ALine);
end;
procedure TDebuggerDlg.DoWatchesChanged;
@ -524,7 +498,9 @@ var
Command: Word;
Handled: Boolean;
begin
Command := EditorOpts.KeyMap.TranslateKey(Key,Shift,TDebuggerDlg);
if OnTranslateKey = nil then
exit;
Command := OnTranslateKey(Key,Shift,TDebuggerDlg);
if Assigned(OnProcessCommand) and (Command <> ecNone) and
(Command <> ecContextHelp) and(Command <> ecEditContextHelp)

View File

@ -106,6 +106,10 @@
<Filename Value="watchpropertydlg.pp"/>
<UnitName Value="WatchPropertyDlg"/>
</Item>
<Item>
<Filename Value="debuggerdlg.pp"/>
<UnitName Value="DebuggerDlg"/>
</Item>
</Files>
<i18n>
<EnableI18N Value="True"/>

View File

@ -13,7 +13,8 @@ uses
IdeDebuggerWatchResUtils, ArrayNavigationFrame, IdeDebuggerStringConstants,
IdeDebuggerBackendValueConv, IdeDbgValueConverterSettingsFrame,
IdeDebugger_ValConv_Options, IdeDebuggerOpts, IdeDebuggerWatchResultJSon,
WatchInspectToolbar, BaseDebugManager, WatchPropertyDlg, LazarusPackageIntf;
WatchInspectToolbar, BaseDebugManager, WatchPropertyDlg, DebuggerDlg,
LazarusPackageIntf;
implementation