Changeset 264 for ExceptionLogger/UStackTrace.pas
- Timestamp:
- Aug 17, 2011, 10:08:55 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ExceptionLogger/UStackTrace.pas
r167 r264 22 22 23 23 TStackTrace = class(TObjectList) 24 Frames: array of Pointer; 24 25 MaxDepth: Integer; 25 26 procedure GetExceptionBackTrace; 26 27 procedure GetCallStack(BP: Pointer); 27 28 procedure GetCurrentCallStack; 29 procedure GetInfo; 28 30 constructor Create; 29 31 end; … … 66 68 try 67 69 I := 0; 70 SetLength(Frames, 0); 68 71 while (BP <> nil) and (I < MaxDepth) do begin 69 CallerAddress := TStackFrameInfo(get_caller_addr(BP)); 70 StackFrameInfo := TStackFrameInfo.Create; 71 StackFrameInfo.GetFrameInfo(CallerAddress); 72 StackFrameInfo.Index := I + 1; 73 Add(StackFrameInfo); 72 SetLength(Frames, Length(Frames) + 1); 73 Frames[I] := TStackFrameInfo(get_caller_addr(BP)); 74 74 Inc(I); 75 75 BP := TStackFrameInfo(get_caller_frame(BP)); … … 89 89 var 90 90 FrameCount: Integer; 91 Frames : PPointer;91 FramesList: PPointer; 92 92 FrameNumber: Integer; 93 StackFrameInfo: TStackFrameInfo;94 93 begin 95 Clear; 96 StackFrameInfo := TStackFrameInfo.Create; 97 StackFrameInfo.GetFrameInfo(ExceptAddr); 98 StackFrameInfo.Index := 1; 99 Add(StackFrameInfo); 94 SetLength(Frames, 1); 95 Frames[0] := ExceptAddr; 100 96 FrameCount := ExceptFrameCount; 101 Frames := ExceptFrames;97 FramesList := ExceptFrames; 102 98 if FrameCount > MaxDepth then FrameCount := MaxDepth; 99 SetLength(Frames, FrameCount + 1); 103 100 for FrameNumber := 0 to FrameCount - 1 do begin 104 StackFrameInfo := TStackFrameInfo.Create; 105 StackFrameInfo.GetFrameInfo(Frames[FrameNumber]); 106 StackFrameInfo.Index := FrameNumber + 1; 107 Add(StackFrameInfo); 101 Frames[FrameNumber + 1] := FramesList[FrameNumber] 108 102 end; 109 103 end; … … 114 108 end; 115 109 110 procedure TStackTrace.GetInfo; 111 var 112 I: Integer; 113 StackFrameInfo: TStackFrameInfo; 114 begin 115 Clear; 116 for I := 0 to High(Frames) do begin 117 StackFrameInfo := TStackFrameInfo.Create; 118 StackFrameInfo.GetFrameInfo(Frames[I]); 119 StackFrameInfo.Index := I + 1; 120 Add(StackFrameInfo); 121 end; 122 end; 123 116 124 end. 117 125
Note:
See TracChangeset
for help on using the changeset viewer.