Tracking down Access Violations

BCS BCS_member at pathlink.com
Fri May 19 12:29:25 PDT 2006


In article <e4l47p$52$1 at digitaldaemon.com>, Jeremy says...
>
>In article <e4l2dk$2uhd$1 at digitaldaemon.com>, BCS says...
>>
>>IIRC their is a version of Phobos that does stack traces.
>
>Really? Where? :-O
>

backtracing your own stuff shouldn't be to hard, put this at the top of each
function. (you will still need to look up function from line numbers but it's
the best you can do until a __FUNC_NAME__ const it added).


vertion(backtrace) scope(falure) writef(__FILE__":" ~ itoa!(__LINE__)~\n);


you will need the itoa template:
(from http://www.digitalmars.com/d/templates-revisited.html


<code>
template decimalDigit(int n)	// [3]
{
const char[] decimalDigit = "0123456789"[n..n+1];
} 

template itoa(long n)
{   
static if (n < 0)
const char[] itoa = "-" ~ itoa!(-n);  
else static if (n < 10)
const char[] itoa = decimalDigit!(n); 
else
const char[] itoa = itoa!(n/10L) ~ decimalDigit!(n%10L); 
}

</code>





More information about the Digitalmars-d mailing list