If you need call stacks of background threads for/during exception's processing - we recommend to use appropriate options. Call stacks of background threads will be available in same .CallStack property of TEurekaExceptionInfo object. CallStack's items from background threads will have a different .ThreadID property. Exception call stack's items always come first.
If you need to create call stack on demand:
ECallStack, // for EurekaCallStackClass, TEurekaBaseStackList
EStackTracing, // for TracerRawEurekaLogV7Mask (optional)
EModules, // for CurrentEurekaLogOptions (optional)
ETypes; // for ddSourceCode, etc. (optional)
procedure TForm1.Button1Click(Sender: TObject);
CallStack := EurekaCallStackClass.Create(nil);
// Replace with your thread's handle and ID.
// Thread handle must have:
// THREAD_GET_CONTEXT, THREAD_QUERY_INFORMATION, and THREAD_SUSPEND_RESUME access rights
// DO NOT PASS GetCurrentThread and GetCurrentThreadId!!!
// There is also .BuildForThreadByID method, which does not require thread handle argument.
nil, // first addr
[ddUnit, ddProcedure, ddSourceCode], // CurrentEurekaLogOptions.csoDebugInfo
True, // get debug info?
False, // show begin calls?
TracerRawEurekaLogV7Mask, // CurrentEurekaLogOptions.csoAllowedRenderMethods
True, // running thread?
@Suspended); // will return True if thread was suspended before call stack is taken
Important Note: please note that background thread will continue to run. E.g. its actual call stack may be different from call stack that you have taken.
You may also be interested in RaiseFreezeException routine from EFreeze unit, which will create report for the specified individual thread.
Build date: 2020-09-23
Last edited: 2019-07-01
The documentation team uses the feedback submitted to improve the EurekaLog documentation.
We do not use your e-mail address for any other purpose.
We will remove your e-mail address from our system after the issue you are reporting has been resolved.
While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback.
After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.
Permanent link to this article: https://www.eurekalog.com/help/eurekalog/how_to_get_background_thread_call_stack.php