2011-06-20 9 views

cevap

1

JclHookExcept biriminde JclAddExceptNotifier'a bakın.

+0

Teşekkürler, bu bana çok yardımcı oluyor. Ayrıca bu http://andremussche.blogspot.com/2007/09/adv-debugging-hook-all-exceptions.html –

+0

@Melaum'u da ziyaret ettim: Muhtemelen çok ilginç ama maalesef Almanca bilmiyorum. (Ya da bu Alman değilse, ne olursa olsun, ben de bunu bilmiyorum.) –

+1

Almanca değil, Hollandalı. – jpfollenius

10

Bu JCL tabanlı değil, açık Kaynaklıdır ve Delphi 5'ten XE'ye kadar çalışır.

Bu logging mechanism, herhangi bir özel durumu engelleyebilir.

Aslında, Delphi 6 yana, herhangi bir özel duruma neden olduğunda lauched edilecek RtlUnwindProc global prosedürü tanımlayabilirsiniz:

{$ifdef DELPHI5OROLDER} 
procedure RtlUnwind; external kernel32 name 'RtlUnwind'; 
{$else} 
var 
    oldUnWindProc: pointer; 
{$endif} 

procedure SynRtlUnwind(TargetFrame, TargetIp: pointer; 
    ExceptionRecord: PExceptionRecord; ReturnValue: Pointer); stdcall; 
asm 
    pushad 
    cmp byte ptr SynLogExceptionEnabled,0 
    jz @oldproc 
    mov eax,TargetFrame 
    mov edx,ExceptionRecord 
    call LogExcept 
@oldproc: 
    popad 
    pop ebp // hidden push ebp at asm level 
{$ifdef DELPHI5OROLDER} 
    jmp RtlUnwind 
{$else} 
    jmp oldUnWindProc 
{$endif} 
end; 


oldUnWindProc := RTLUnwindProc; 
RTLUnwindProc := @SynRtlUnwind; 

aşağıdaki işlevi başlatacak Bu kod:

type 
    PExceptionRecord = ^TExceptionRecord; 
    TExceptionRecord = record 
    ExceptionCode: DWord; 
    ExceptionFlags: DWord; 
    OuterException: PExceptionRecord; 
    ExceptionAddress: PtrUInt; 
    NumberParameters: Longint; 
    case {IsOsException:} Boolean of 
    True: (ExceptionInformation : array [0..14] of PtrUInt); 
    False: (ExceptAddr: PtrUInt; ExceptObject: Exception); 
    end; 
    GetExceptionClass = function(const P: TExceptionRecord): ExceptClass; 

const 
    cDelphiExcept = $0EEDFAE0; 
    cDelphiException = $0EEDFADE; 

procedure LogExcept(stack: PPtrUInt; const Exc: TExceptionRecord); 
begin 
    LastError := GetLastError; 
    (...) intercept the exception 
    SetLastError(LastError); // code above could have changed this 
end; 

Delphi 5 için, had to patch the VCL in-process, çünkü global bir istisna önleme yoktur.

+2

+1, ilginç –

+0

Çok ilginç, cevabınız için teşekkürler! –

+0

Son sürümler XE4/XE5 ve Win32/Win64 platformlarını destekliyor. –

İlgili konular