Discussion:
IdGlobal.SetThreadName using EIdException?
(too old to reply)
Yahoo Serious
2008-06-20 13:35:43 UTC
Permalink
I just started using JCL to log the call stack for Exceptions. To ignore
the 'normal' Indy Exceptions I use AddIgnoredException(EIdException),
because they should be handled in the regular program flow.

However, Indy's IdGlobal.SetThreadName uses RaiseException(...). This
Exception seems necessary to do the job. Like any Exception this does
trigger JCL to log the call stack. I am wondering whether it is possible to
use a 'typed' Exception, inheriting from EIdException?
(I have no knowledge at all about RaiseException, so I have no idea wether
this is possible/easy.)

(Another option would be to use JCL's stDelayedTrace, which prevents JCL
from resolving the call stack until asked for it. However, this will have
no resolution for intermediately unloaded modules.)

Yahoo.
Remy Lebeau (TeamB)
2008-06-20 16:55:07 UTC
Permalink
Post by Yahoo Serious
However, Indy's IdGlobal.SetThreadName uses RaiseException(...).
Because it has to. That is a requirement of debuggers. $406D1388 is a
special-case exception code that tells the debugger what the name of the
calling thread is so it can be cached for display purposes. There is no way
to raise $406D1388 other than by calling RaiseException() directly. This
technique for naming threads was introduced by Microsoft, and is used by
both Microsoft and CodeGear debuggers:

How to: Set a Thread Name in Native Code
http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
Post by Yahoo Serious
This Exception seems necessary to do the job.
Yes, it is.
Post by Yahoo Serious
Like any Exception this does trigger JCL to log the call stack.
I would expect it to if JCL is hooking into the RTL's lower-level exception
handling mechanisms. When the exception is raised, the debugger catches it
first, retreives the provided thread name, and then returns the exception
back to the application for normal handling (which is why Indy has a
try..except around the RaiseException() call), thus triggering JCL's
logging.
Post by Yahoo Serious
I am wondering whether it is possible to use a 'typed' Exception,
inheriting from EIdException?
No, it is not possible.


Gambit

Loading...