source: MicroThreading/UMicroThreadCallStack.pas

Last change on this file was 168, checked in by george, 13 years ago
  • Added: Context menu in microthreads list to show microthread call stack.
File size: 1.5 KB
Line 
1unit UMicroThreadCallStack;
2
3{$mode Delphi}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
9 UStackTrace;
10
11type
12
13 { TCallStackForm }
14
15 TCallStackForm = class(TForm)
16 ListView1: TListView;
17 procedure FormCreate(Sender: TObject);
18 procedure FormDestroy(Sender: TObject);
19 private
20 StackTrace: TStackTrace;
21 procedure LoadStackTraceToListView(StackTrace: TStackTrace);
22 public
23 procedure Show(BasePointer: Pointer);
24 end;
25
26implementation
27
28{$R *.lfm}
29
30procedure TCallStackForm.FormCreate(Sender: TObject);
31begin
32 StackTrace := TStackTrace.Create;
33end;
34
35procedure TCallStackForm.FormDestroy(Sender: TObject);
36begin
37 StackTrace.Free;
38end;
39
40procedure TCallStackForm.LoadStackTraceToListView(StackTrace: TStackTrace);
41var
42 I: Integer;
43 NewItem: TListItem;
44begin
45 with ListView1, Items do begin
46 BeginUpdate;
47 Clear;
48 for I := 0 to StackTrace.Count - 1 do
49 with TStackFrameInfo(StackTrace[I]) do begin
50 NewItem := Add;
51 with NewItem do begin
52 Caption := IntToStr(Index);
53 SubItems.Add(IntToHex(Address, 8));
54 SubItems.Add(IntToStr(LineNumber));
55 SubItems.Add(FunctionClassName);
56 SubItems.Add(FunctionName);
57 SubItems.Add(Source);
58 end;
59 end;
60 EndUpdate;
61 end;
62end;
63
64procedure TCallStackForm.Show(BasePointer: Pointer);
65begin
66 StackTrace.GetCallStack(BasePointer);
67 LoadStackTraceToListView(StackTrace);
68 ShowModal;
69end;
70
71end.
72
Note: See TracBrowser for help on using the repository browser.