Changeset 40 for ExceptionLogger


Ignore:
Timestamp:
Sep 9, 2010, 1:58:30 PM (14 years ago)
Author:
george
Message:
  • Přidáno: Podpora pro možnost ignorovat opakující se výjimky.
Location:
ExceptionLogger
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ExceptionLogger/CustomLineInfo.pas

    r39 r40  
    9494        exit;
    9595    end;
    96   e.processaddress:=ptruint(baseaddr)-e.processaddress;
     96  e.processaddress := ptruint(baseaddr) - e.processaddress;
    9797  StabsFunctionRelative := E.FunctionRelative;
    9898  if FindExeSection(e,'.stab',stabofs,stablen) and
     
    109109end;
    110110
    111 
    112111procedure CloseStabs;
    113112begin
    114113  CloseExeFile(e);
    115114end;
    116 
    117115
    118116function GetLineInfo(addr:ptruint;var func,source:shortstring;var line:longint) : boolean;
     
    248246end;
    249247
    250 
    251248function StabBackTraceStr(addr:Pointer):shortstring;
    252249var
     
    291288end;
    292289
    293 
    294290initialization
    295   BackTraceStrFunc:=@StabBackTraceStr;
     291  BackTraceStrFunc := @StabBackTraceStr;
    296292
    297293finalization
  • ExceptionLogger/UExceptionForm.lfm

    r39 r40  
    33  Height = 316
    44  Top = 171
    5   Width = 682
     5  Width = 691
    66  Caption = 'Exception info'
    77  ClientHeight = 316
    8   ClientWidth = 682
     8  ClientWidth = 691
    99  OnCreate = FormCreate
    1010  OnDestroy = FormDestroy
     
    1212  LCLVersion = '0.9.29'
    1313  object ButtonClose: TButton
    14     Left = 602
     14    Left = 611
    1515    Height = 25
    1616    Top = 286
     
    2222  end
    2323  object ButtonKill: TButton
    24     Left = 512
     24    Left = 521
    2525    Height = 25
    2626    Top = 286
     
    3535    Height = 277
    3636    Top = 3
    37     Width = 669
     37    Width = 678
    3838    ActivePage = TabSheet2
    3939    Anchors = [akTop, akLeft, akRight, akBottom]
     
    5959      Caption = 'Call stack'
    6060      ClientHeight = 251
    61       ClientWidth = 661
     61      ClientWidth = 670
    6262      object ListView1: TListView
    6363        Left = 4
    6464        Height = 241
    6565        Top = 7
    66         Width = 655
     66        Width = 664
    6767        Anchors = [akTop, akLeft, akRight, akBottom]
    6868        Columns = <       
     
    7777          item
    7878            Caption = 'Class'
    79             Width = 100
     79            Width = 150
    8080          end       
    8181          item
     
    9999    end
    100100  end
     101  object CheckBoxIgnore: TCheckBox
     102    Left = 10
     103    Height = 17
     104    Top = 298
     105    Width = 169
     106    Anchors = [akLeft, akBottom]
     107    Caption = 'Next time ignore this exception'
     108    TabOrder = 3
     109  end
    101110end
  • ExceptionLogger/UExceptionForm.lrt

    r39 r40  
    1010TEXCEPTIONFORM.LISTVIEW1.COLUMNS[4].CAPTION=Unit
    1111TEXCEPTIONFORM.LISTVIEW1.COLUMNS[5].CAPTION=Line
     12TEXCEPTIONFORM.CHECKBOXIGNORE.CAPTION=Next time ignore this exception
  • ExceptionLogger/UExceptionForm.pas

    r39 r40  
    1818    ButtonKill: TButton;
    1919    ButtonClose: TButton;
     20    CheckBoxIgnore: TCheckBox;
    2021    ListView1: TListView;
    2122    MemoExceptionInfo: TMemo;
     
    4243procedure TExceptionForm.FormShow(Sender: TObject);
    4344begin
     45  PageControl1.ActivePageIndex := 0;
     46  CheckBoxIgnore.Checked := False;
    4447end;
    4548
     
    5659procedure TExceptionForm.ButtonKillClick(Sender: TObject);
    5760begin
    58   Halt;
     61  //Halt;
     62  Application.Terminate;
    5963end;
    6064
  • ExceptionLogger/UExceptionLogger.pas

    r39 r40  
    2121    StackTrace: TStackTrace;
    2222    LastException: Exception;
     23    IgnoreList: TStringList;
    2324    constructor Create(AOwner: TComponent); override;
    2425    destructor Destroy; override;
     
    5455end;
    5556
    56 
    5757{ TExceptionLogger }
    5858
     
    6060begin
    6161  inherited Create(AOwner);
     62  IgnoreList := TStringList.Create;
    6263  StackTrace := TStackTrace.Create;
    6364  MaxCallStackDepth := 20;
     
    6970begin
    7071  StackTrace.Free;
     72  IgnoreList.Free;
    7173  inherited Destroy;
    7274end;
     
    155157  Report: TStringList;
    156158begin
    157   Report := TStringList.Create;
    158   try
    159     CreateTextReport(Report);
    160     if FLogFileName <> '' then begin
    161       LogToFile(Report);
    162       LogStackTraceToFile(StackTrace);
     159  if IgnoreList.IndexOf(LastException.ClassName) = -1 then begin
     160    Report := TStringList.Create;
     161    try
     162      CreateTextReport(Report);
     163      if FLogFileName <> '' then begin
     164        LogToFile(Report);
     165        LogStackTraceToFile(StackTrace);
     166      end;
     167      ExceptionForm.MemoExceptionInfo.Lines.Assign(Report);
     168      ShowReportForm;
     169    finally
     170      Report.Free;
    163171    end;
    164     ExceptionForm.MemoExceptionInfo.Lines.Assign(Report);
    165     ShowReportForm;
    166   finally
    167     Report.Free;
     172    if ExceptionForm.CheckBoxIgnore.Checked then
     173      IgnoreList.Add(LastException.ClassName);
    168174  end;
    169175end;
Note: See TracChangeset for help on using the changeset viewer.