Getting the typeid of an object disguised under an interface

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 28 14:28:46 PDT 2016


On Monday, 28 March 2016 at 17:40:15 UTC, Tomer Filiba wrote:
> yes, but it's used for logging exceptions. instead of doing the 
> to-string conversion in place, we just keep the raw pointers 
> and do addr2line on demand. so we're given an exception and 
> need to extract the bt from it

Perhaps you can set your own trace handler and either copy/paste 
code from druntime or just do your own backtrace() based thing:

http://dpldocs.info/experimental-docs/core.runtime.Runtime.traceHandler.1.html


Ugh, the druntime authors didn't actually document TraceHandler 
(it is listed as private, but that function obviously isn't). It 
is:

     alias Throwable.TraceInfo function( void* ptr ) TraceHandler;


The thing it passes is typically null. So you construct your own 
class fitting the TraceInfo interface and this is called when an 
exception is built.


More information about the Digitalmars-d mailing list