Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // EurekaLog has hang detection feature (see: http://www.eurekalog.com/help/eurekalog/hang_detection_page.php )
- // However, this feature will work only for main thread on XP and older systems (see: http://www.eurekalog.com/help/eurekalog/hangs_and_deadlocks.php ).
- // Sometimes, you need to debug problems with hanged/deadlock threads, or threads eating 100% of CPU core.
- // You can create a bug report with call stacks for such threads on demand.
- // See also: http://pastebin.com/rdNbEwPH - "how to get call stack on demand"
- // Option 1: mark certain thread as "hang".
- uses
- EFreeze;
- var
- ThreadID: Cardinal;
- // ...
- ThreadID := { get ID of handed/deadlocked thread };
- RaiseFreezeException(ThreadID);
- // ...
- // Note: EurekaLog uses this method inside its freeze detection feature (ThreadID matches MainThreadID).
- // Alternative (preferred solution when you have thread handle available):
- uses
- EFreeze;
- var
- ThreadID: Cardinal;
- ThreadHandle: THandle;
- // ...
- ThreadID := { get ID of handed/deadlocked thread };
- ThreadHandle := { get handle of handed/deadlocked thread };
- RaiseFreezeException(ThreadID, ThreadHandle);
- // ...
- // The above examples will trigger EFrozenApplication exception inside CURRENT thread, but exception information will contain the specified thread. If you do not catch this exception - it will generate usual EurekaLog's bug report. Hanged thread will be included as "exception thread" in this report (with full call stack). Other threads may or may be not included in the bug report - depending on your options (see "Capture stack of ..." options: http://www.eurekalog.com/help/eurekalog/multi_threading_page.php ).
- // Option 2: generate full bug report
- uses
- EModules,
- EExceptionManager;
- // ...
- CurrentEurekaLogOptions.csoShowELThreads := True; // <- enable "Capture stack of EurekaLog threads"
- ExceptionManager.StandardEurekaError('Application seems to be frozen');
- // The above solution will create bug report inside current thread. Current thread will be used as "exception thread". However, hanged/deadlocked thread will appear in the bug report - because we enabled corresponding option (your thread must be EurekaLog-enabled thread, otherwise you should use another csoShowXYZ option).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement