İşlenenler de dahil olmak üzere tüm istisnaları günlüğe kaydetmek için JCLDebug'ı kullanmak istiyorum.JCLDebug ile tüm istisnaları (ele alınanları bile) yakalamanın bir yolu var mı?
Bunu yapmak mümkün mü?
İşlenenler de dahil olmak üzere tüm istisnaları günlüğe kaydetmek için JCLDebug'ı kullanmak istiyorum.JCLDebug ile tüm istisnaları (ele alınanları bile) yakalamanın bir yolu var mı?
Bunu yapmak mümkün mü?
JclHookExcept
biriminde JclAddExceptNotifier
'a bakın.
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.
+1, ilginç –
Çok ilginç, cevabınız için teşekkürler! –
Son sürümler XE4/XE5 ve Win32/Win64 platformlarını destekliyor. –
Teşekkürler, bu bana çok yardımcı oluyor. Ayrıca bu http://andremussche.blogspot.com/2007/09/adv-debugging-hook-all-exceptions.html –
@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.) –
Almanca değil, Hollandalı. – jpfollenius