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:
uses
ECallStack, // for EurekaCallStackClass, TEurekaBaseStackList
EStackTracing, // for TracerRawEurekaLogV7Mask (optional)
EModules, // for CurrentEurekaLogOptions (optional)
ETypes; // for ddSourceCode, etc. (optional)
procedure TForm1.Button1Click(Sender: TObject);
var
CallStack: TEurekaBaseStackList;
Suspended: Boolean;
begin
CallStack := EurekaCallStackClass.Create(nil);
try
CallStack.BuildForThread(YourThreadHandle, YourThreadId,
// 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
Memo1.Lines.Assign(CallStack);
finally
FreeAndNil(CallStack);
end;
end;
Important Note: please note that background thread will continue to run. In other words, 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.
See also:
Send feedback...
|
Build date: 2024-09-30
Last edited: 2024-06-03
|
PRIVACY STATEMENT
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
|
|