From 00a3d4a0238d06a8c9a01fd18d2ab6e85f5cb154 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 23 May 2003 18:50:07 +0000 Subject: [PATCH] implemented searching debugging files in inherited unit paths git-svn-id: trunk@4177 - --- components/codetools/codetoolmanager.pas | 13 +++ ide/debugmanager.pas | 113 ++++++++++------------- ide/mainbar.pas | 4 + 3 files changed, 66 insertions(+), 64 deletions(-) diff --git a/components/codetools/codetoolmanager.pas b/components/codetools/codetoolmanager.pas index 9fbeabaa2f..029d57b584 100644 --- a/components/codetools/codetoolmanager.pas +++ b/components/codetools/codetoolmanager.pas @@ -206,6 +206,7 @@ type function GetNestedCommentsFlagForFile(const Filename: string): boolean; function GetPascalCompilerForDirectory(const Directory: string): TPascalCompiler; function GetCompilerModeForDirectory(const Directory: string): TCompilerMode; + function GetCompiledSrcExtForDirectory(const Directory: string): string; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -687,6 +688,18 @@ begin Result:=cm; end; +function TCodeToolManager.GetCompiledSrcExtForDirectory(const Directory: string + ): string; +var + Evaluator: TExpressionEvaluator; +begin + Result:='.ppu'; + Evaluator:=DefineTree.GetDefinesForDirectory(Directory,true); + if Evaluator=nil then exit; + if Evaluator.IsDefined('WIN32') then + Result:='.ppw'; +end; + function TCodeToolManager.InitCurCodeTool(Code: TCodeBuffer): boolean; var MainCode: TCodeBuffer; begin diff --git a/ide/debugmanager.pas b/ide/debugmanager.pas index a80b43ade3..c40b97c7e6 100644 --- a/ide/debugmanager.pas +++ b/ide/debugmanager.pas @@ -40,12 +40,12 @@ uses MemCheck, {$ENDIF} Classes, SysUtils, Forms, Controls, Dialogs, Menus, FileCtrl, Laz_XMLCfg, - SynEdit, + SynEdit, CodeCache, CodeToolManager, CompilerOptions, EditorOptions, EnvironmentOpts, KeyMapping, UnitEditor, - Project, IDEProcs, Debugger, RunParamsOpts, ExtToolDialog, IDEOptionDefs, - LazarusIDEStrConsts, ProjectDefs, BaseDebugManager, MainBar, DebuggerDlg, - Watchesdlg, BreakPointsdlg, LocalsDlg, DBGOutputForm, GDBMIDebugger, - CallStackDlg; + Project, IDEProcs, InputHistory, Debugger, RunParamsOpts, ExtToolDialog, + IDEOptionDefs, LazarusIDEStrConsts, ProjectDefs, BaseDebugManager, MainBar, + DebuggerDlg, Watchesdlg, BreakPointsdlg, LocalsDlg, DBGOutputForm, + GDBMIDebugger, CallStackDlg; type @@ -288,11 +288,9 @@ procedure TDebugManager.OnDebuggerCurrentLine(Sender: TObject; // -> show the current execution line in editor // if SrcLine = -1 then no source is available var - ActiveSrcEdit: TSourceEditor; - SearchFile, UnitFile: String; + SrcFile: String; OpenDialog: TOpenDialog; - UnitInfo: TUnitInfo; - n: Integer; + NewSource: TCodeBuffer; begin if (Sender<>FDebugger) or (Sender=nil) then exit; @@ -307,64 +305,48 @@ begin Exit; end; - UnitFile := MainIDE.FindUnitFile(ALocation.SrcFile); - if UnitFile = '' - then UnitFile := ALocation.SrcFile; - - if MainIDE.DoOpenEditorFile(UnitFile,-1,[ofOnlyIfExists, ofQuiet]) <> mrOk - then begin - // Try to find it ourself in the project files - SearchFile := ExtractFilenameOnly(ALocation.SrcFile); - UnitFile := ''; - for n := Project1.UnitCount - 1 downto 0 do - begin - UnitInfo := Project1.Units[n]; - if CompareFileNames(SearchFile, ExtractFilenameOnly(UnitInfo.FileName)) = 0 - then begin - UnitFile := UnitInfo.FileName; - Break; + SrcFile := MainIDE.FindSourceFile(ALocation.SrcFile); + if SrcFile = '' then SrcFile := ALocation.SrcFile; + + if (not FilenameIsAbsolute(SrcFile)) or (not FileExists(SrcFile)) then begin + if MessageDlg(lisFileNotFound, + Format(lisTheFileWasNotFoundDoYouWantToLocateItYourself, ['"', + SrcFile, '"', #13, #13, #13]) + ,mtConfirmation, [mbYes, mbNo], 0) <> mrYes + then Exit; + + repeat + OpenDialog:=TOpenDialog.Create(Application); + try + InputHistories.ApplyFileDialogSettings(OpenDialog); + OpenDialog.Title:=lisOpenFile+' '+SrcFile; + OpenDialog.Options:=OpenDialog.Options+[ofFileMustExist]; + if not OpenDialog.Execute then + exit; + SrcFile:=CleanAndExpandFilename(OpenDialog.FileName); + InputHistories.StoreFileDialogSettings(OpenDialog); + finally + OpenDialog.Free; end; - end; - - if (UnitFile = '') - or (MainIDE.DoOpenEditorFile(UnitFile,-1,[ofOnlyIfExists, ofQuiet]) <> mrOk) - then begin - UnitFile := ALocation.SrcFile; - repeat - if MessageDlg(lisFileNotFound, - Format(lisTheFileWasNotFoundDoYouWantToLocateItYourself, ['"', - UnitFile, '"', #13, #13, #13]) - ,mtConfirmation, [mbYes, mbNo], 0) <> mrYes - then Exit; - - OpenDialog := TOpenDialog.Create(Application); - try - OpenDialog.Title := lisOpenFile; - OpenDialog.FileName := ALocation.SrcFile; - if not OpenDialog.Execute - then Exit; - UnitFile := OpenDialog.FileName; - finally - OpenDialog.Free; - end; - until MainIDE.DoOpenEditorFile(UnitFile,-1,[ofOnlyIfExists, ofQuiet]) = mrOk; - end; - end; + until FilenameIsAbsolute(SrcFile) and FileExists(SrcFile); - ActiveSrcEdit := SourceNoteBook.GetActiveSE; - if ActiveSrcEdit=nil then exit; - - with ActiveSrcEdit.EditorComponent do - begin - CaretXY:=Point(1, ALocation.SrcLine); - BlockBegin:=CaretXY; - BlockEnd:=CaretXY; - TopLine:=ALocation.SrcLine-(LinesInWindow div 2); end; - SourceNotebook.ClearExecutionLines; - SourceNotebook.ClearErrorLines; - ActiveSrcEdit.ExecutionLine:=ALocation.SrcLine; - // ActiveSrcEdit.ErrorLine:=ALocation.SrcLine; + + NewSource:=CodeToolBoss.LoadFile(SrcFile,true,false); + if NewSource=nil then begin + exit; + end; + + // clear old error and execution lines + if SourceNotebook<>nil then begin + SourceNotebook.ClearExecutionLines; + SourceNotebook.ClearErrorLines; + end; + // jump editor to execution line + if MainIDE.DoJumpToCodePos(nil,nil,NewSource,1,ALocation.SrcLine,-1,true) + <>mrOk then exit; + // mark execution line + SourceNotebook.GetActiveSE.ExecutionLine:=ALocation.SrcLine; end; //----------------------------------------------------------------------------- @@ -912,6 +894,9 @@ end. { ============================================================================= $Log$ + Revision 1.21 2003/05/23 18:50:07 mattias + implemented searching debugging files in inherited unit paths + Revision 1.20 2003/05/23 16:46:13 mattias added message, that debugger is readonly while running diff --git a/ide/mainbar.pas b/ide/mainbar.pas index 5e862d879a..947ff73818 100644 --- a/ide/mainbar.pas +++ b/ide/mainbar.pas @@ -417,6 +417,10 @@ type procedure SaveEnvironment; virtual; abstract; procedure SetRecentSubMenu(ParentMenuItem: TMenuItem; FileList: TStringList; OnClickEvent: TNotifyEvent); virtual; + function DoJumpToCodePos( + ActiveSrcEdit: TSourceEditor; ActiveUnitInfo: TUnitInfo; + NewSource: TCodeBuffer; NewX, NewY, NewTopLine: integer; + AddJumpPoint: boolean): TModalResult; virtual; abstract; procedure DoJumpToCodeToolBossError; virtual; abstract; procedure SaveSourceEditorChangesToCodeCache(PageIndex: integer); virtual; abstract; end;