From ff5f02afd22d8a896e2a037fdf57677c890d9baa Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 27 Jun 2013 17:20:03 +0000 Subject: [PATCH] IDE: callstack: search source via mangled function name git-svn-id: trunk@41929 - --- components/codetools/methodjumptool.pas | 2 +- ide/debugmanager.pas | 56 ++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index 9cb88f5dd0..5fae0a202a 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -77,7 +77,7 @@ type Attr: TProcHeadAttributes): TStringList; function FindSubProcPath(SubProcPath: TStrings; Attr: TProcHeadAttributes; SkipInterface: boolean): TCodeTreeNode; - + function FindJumpPointForLinkerPos( const SourceFilename: string; SourceLine: integer; const MangledFunction, Identifier: string; diff --git a/ide/debugmanager.pas b/ide/debugmanager.pas index 901d95f1f9..117ea955e5 100644 --- a/ide/debugmanager.pas +++ b/ide/debugmanager.pas @@ -44,7 +44,7 @@ uses Classes, SysUtils, Forms, Controls, Dialogs, Menus, ExtCtrls, FileUtil, LCLProc, LCLType, LCLIntf, LazLoggerBase, Laz2_XMLCfg, // SynEdit, codetools - SynEdit, CodeCache, CodeToolManager, + SynEdit, CodeCache, CodeToolManager, PascalParserTool, CodeTree, // IDEIntf IDEWindowIntf, SrcEditorIntf, MenuIntf, IDECommands, LazIDEIntf, ProjectIntf, CompOptsIntf, IDEDialogs, @@ -560,6 +560,52 @@ function TDebugManager.GetFullFilename(const AUnitinfo: TDebuggerUnitInfo; debugln(DBG_LOCATION_INFO, ['ResolveFromDbg Final Filename=', Filename]); end; + function FindSrc: boolean; + var + SrcUnitName: String; + SrcInFilename: String; + SrcFilename: String; + Code: TCodeBuffer; + ProcDef: String; + CurCodeTool: TCodeTool; + CurCodeNode: TCodeTreeNode; + CodePos: TCodeXYPosition; + begin + Result:=false; + debugln(['TDebugManager.GetFullFilename searching Unit=', AUnitinfo.UnitName, ', Class=', AUnitinfo.SrcClassName, ', Func=', AUnitinfo.FunctionName]); + // search unit in project unit path + SrcUnitName := AUnitinfo.UnitName; + SrcInFilename := ''; + SrcFilename:=CodeToolBoss.DirectoryCachePool.FindUnitSourceInCompletePath('', + SrcUnitName,SrcInFilename); + if SrcFilename='' then exit; + // load unit + Code:=CodeToolBoss.LoadFile(SrcFilename,true,false); + if Code=nil then exit; // read error + // procedure declaration: classname.functionname + ProcDef:=''; + if AUnitinfo.SrcClassName<>'' then + ProcDef:=AUnitinfo.SrcClassName+'.'; + ProcDef:=ProcDef+AUnitinfo.FunctionName; + //debugln(['TDebugManager.GetFullFilename Code="',Code.Filename,'" ProcDef="',ProcDef,'"']); + // search proc in unit + if not CodeToolBoss.FindProcDeclaration(Code,ProcDef,CurCodeTool,CurCodeNode, + [phpWithoutParamList,phpWithoutBrackets,phpWithoutClassKeyword,phpWithoutSemicolon]) + then begin + debugln(['TDebugManager.GetFullFilename not found: Code="',Code.Filename,'" ProcDef="',ProcDef,'"']); + exit; + end; + // get file, line, column + if CurCodeNode.Desc=ctnProcedure then + CurCodeNode:=CurCodeNode.FirstChild; // jump to Name instead of keyword 'procedure' + if not CurCodeTool.CleanPosToCaret(CurCodeNode.StartPos,CodePos) then + exit; + debugln(['TDebugManager.GetFullFilename found ',CodePos.Code.Filename,' Line=',CodePos.Y,' Col=',CodePos.X]); + AUnitinfo.LocationFullFile := CodePos.Code.Filename; + DumpStack; + Result:=true; + end; + begin Result := False; if Destroying or (AUnitinfo = nil) then exit; @@ -567,11 +613,9 @@ begin Result := Filename <> ''; if Result then exit; - if dlfSearchByFunctionName in AUnitinfo.Flags then begin - //debuln(['need locatien for', AUnitinfo.UnitName, ', ', AUnitinfo.SrcClassName, ', ', AUnitinfo.FunctionName]); - //Result := ''; - //AUnitinfo.LocationFullFile := Result; - //exit; + if (dlfSearchByFunctionName in AUnitinfo.Flags) + and (AUnitinfo.FunctionName<>'') then begin + if FindSrc then exit; end; case AUnitinfo.LocationType of