Thinking about stack traces in D

Jascha Wetzel firstname at mainia.de
Sun Sep 16 10:47:47 PDT 2007


Myron Alexander wrote:
> I have been thinking about exception design as a whole and for D 
> specifically. The lack of stack traces make certain types of bug tracing 
> very difficult so I went a googling looking for the answer and came 
> across this article in Dr. Dobbs:
> 
> http://www.ddj.com/184405270
> 
> This paragraph, in particular, has me interested:
> 
>> Hooking Entry and Exit
>>
>> This version uses an explicit code to report the function name (as a 
>> string). An alternative, used by code profilers (such as Numega 
>> TrueTime), is to parse the binary code, and inject hooks to it. The 
>> best alternative is to use compiler supplied hooks. In this 
>> hook—_penter() and _pexit()—the function address is written to the 
>> registrar. A symbol engine can then convert the address to a 
>> well-formed function name. This requires compilation with debug 
>> symbols. The technique is thoroughly described by John Robbins in his 
>> article on creating the Smooth Working Set tool (MSDN Magazine, 
>> October and December 2000; http://msdn.microsoft.com/msdnmag/ 
>> issues/1000/bugslayer/bugslayer1000.asp). This technique seems to be 
>> the ideal solution, but since I use VC 6, the compiler supplies only 
>> the _penter(). I tried injecting my own _pexit() from it but failed. A 
>> full explanation is beyond the scope of this article.
>>
> 
> Does D have entry and exit hooks already and, if not, would Walter add 
> them?
> 
> Regards,
> 
> Myron.

as a side note, on windows you can use ddbg (http://ddbg.mainia.de) to 
get full stack traces.



More information about the Digitalmars-d mailing list