Throwable.TraceInfo

david via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 28 06:09:11 PST 2015


I have a question regarding Throwable.TraceInfo.


=== Context ===
The application we're developing can have a high throughput of
Exceptions.
Whenever an exception occurs we log it.
Currently, this is done via the Throwable.toString() method.

The problem is this takes ages - around 2-3ms per exception!
If we don't toString it, the whole process takes a mere few usecs
(as it should).
That's 3 orders of magnitude difference.

What I want to do, is just dump the stack-trace itself (the
pointers) - and produce the strings later on, when reading the
logs.


=== To The Point ===
TraceInfo is an interface with unspecified compile-time
implementation.
During runtime, the DefaultTraceInfo is set as the runtime Trace
handler.
This lovely class, has a private member
           void*[MAXFRAMES]  callstack
I want to access this member. However I can't.
I can't even do this with compile time reflection, as it's
runtime assigned and the type itslef is hidden in the assigning
method the returns an interface implementation.
Why make this member private?
Why not make the interface expose a getCallstack() method - which
implementors can either implement, or return empty?

If we don't make this change to the interface - I'm left with
pointless code duplication from druntime.


More information about the Digitalmars-d mailing list