From 364b458aec792a8199f68dfb4bf03597685250df Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 9 Jun 2003 15:58:05 +0000 Subject: [PATCH] implemented view call stack key and jumping to last stack frame with debug info git-svn-id: trunk@4250 - --- debugger/dbgutils.pp | 19 +++++++++++++ debugger/debugger.pp | 9 ++---- ide/basedebugmanager.pas | 3 +- ide/debugmanager.pas | 56 +++++++++++++++++++++++++++++-------- ide/lazarusidestrconsts.pas | 1 + 5 files changed, 70 insertions(+), 18 deletions(-) diff --git a/debugger/dbgutils.pp b/debugger/dbgutils.pp index af6ee9f2e1..d4c97aff1d 100644 --- a/debugger/dbgutils.pp +++ b/debugger/dbgutils.pp @@ -42,6 +42,7 @@ function GetPart(const ASkipTo, AnEnd: array of String; var ASource: String): St function GetPart(const ASkipTo, AnEnd: array of String; var ASource: String; const AnIgnoreCase: Boolean): String; overload; function GetPart(const ASkipTo, AnEnd: array of String; var ASource: String; const AnIgnoreCase, AnUpdateSource: Boolean): String; overload; function ConvertToCString(const AText: String): String; +function DeleteBackSlashes(const AText: String): String; const {$IFDEF WIN32} @@ -201,9 +202,27 @@ begin end; end; +function DeleteBackSlashes(const AText: String): String; +var + i: Integer; + l: Integer; +begin + Result:=AText; + i:=1; + l:=length(Result); + while iFDebugger) or (Sender=nil) then exit; if Destroying then exit; + SrcFile:=ALocation.SrcFile; + SrcLine:=ALocation.SrcLine; + //TODO: Show assembler window if no source can be found. - if ALocation.SrcLine = -1 + if SrcLine = -1 then begin MessageDlg(lisExecutionPaused, Format(lisExecutionPausedAdress, [#13#13, ALocation.Address, #13, ALocation.FuncName, #13, ALocation.SrcFile, #13#13#13, #13]), mtInformation, [mbOK],0); - - Exit; + + // jump to the deepest stack frame with debugging info + i:=FDebugger.CallStack.Count-1; + while (i>=0) do begin + StackEntry:=FDebugger.CallStack.Entries[i]; + if StackEntry.Line>0 then begin + SrcLine:=StackEntry.Line; + SrcFile:=StackEntry.Source; + break; + end; + end; + if SrcLine<1 then + Exit; end; - SrcFile:=ALocation.SrcFile; if DebuggerDlgGetFullFilename(nil,SrcFile,true)<>mrOk then exit; NewSource:=CodeToolBoss.LoadFile(SrcFile,true,false); @@ -718,8 +739,8 @@ begin end; // jump editor to execution line - if MainIDE.DoJumpToCodePos(nil,nil,NewSource,1,ALocation.SrcLine,-1,true) - <>mrOk then exit; + if MainIDE.DoJumpToCodePos(nil,nil,NewSource,1,SrcLine,-1,true)<>mrOk + then exit; // mark execution line if SourceNotebook <> nil @@ -727,7 +748,7 @@ begin else Editor := nil; if Editor <> nil - then Editor.ExecutionLine:=ALocation.SrcLine; + then Editor.ExecutionLine:=SrcLine; end; //----------------------------------------------------------------------------- @@ -1085,6 +1106,7 @@ var var LaunchingCmdLine, LaunchingApplication, LaunchingParams: String; + NewWorkingDir: String; begin WriteLN('[TDebugManager.DoInitDebugger] A'); @@ -1094,7 +1116,7 @@ begin LaunchingCmdLine:=MainIDE.GetRunCommandLine; SplitCmdLine(LaunchingCmdLine,LaunchingApplication,LaunchingParams); if (not FileExists(LaunchingApplication)) then exit; - + OldWatches := nil; BeginUpdateDialogs; @@ -1142,7 +1164,11 @@ begin FDebugger.FileName := LaunchingApplication; FDebugger.Arguments := LaunchingParams; - FDebugger.WorkingDir := Project1.RunParameterOptions.WorkingDirectory; + NewWorkingDir:=Project1.RunParameterOptions.WorkingDirectory; + if NewWorkingDir='' then + NewWorkingDir:=Project1.ProjectDirectory; + FDebugger.WorkingDir:=NewWorkingDir; + Project1.RunParameterOptions.AssignEnvironmentTo(FDebugger.Environment); if FDialogs[ddtOutput] <> nil @@ -1253,6 +1279,11 @@ begin Result:=mrOk; end; +procedure TDebugManager.DoToggleCallStack; +begin + ViewDebugDialog(ddtCallStack); +end; + procedure TDebugManager.RunDebugger; begin if Destroying then exit; @@ -1389,6 +1420,9 @@ end. { ============================================================================= $Log$ + Revision 1.50 2003/06/09 15:58:05 mattias + implemented view call stack key and jumping to last stack frame with debug info + Revision 1.49 2003/06/09 14:39:52 mattias implemented setting working directory for debugger diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index d39faee25f..5515c5c4c5 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -940,6 +940,7 @@ resourcestring uemAddBreakpoint = '&Add Breakpoint'; uemAddWatchAtCursor = 'Add &Watch At Cursor'; uemRunToCursor='&Run to Cursor'; + uemViewCallStackCursor = 'View Call Stack'; uemMoveEditorLeft='Move Editor Left'; uemMoveEditorRight='Move Editor Right'; uemEditorproperties='Editor properties';