Differences From Artifact [1456272a3238466c]:
- File
d2stacktrace/stacktrace.d
- 2010-11-09 05:19:20 - part of checkin [8de5b49cdf] on branch trunk - split tricks module into a separate package. (user: kinaba) [annotate]
To Artifact [2d470e3c95d4cfbd]:
- File
d2stacktrace/stacktrace.d
- 2010-11-13 12:16:47 - part of checkin [5afe8e3f26] on branch trunk - Memoization on non "@v" layer. Now simplest metalevel computation works!! Also, added -l option. (user: kinaba) [annotate]
29 import std.string; 29 import std.string;
30 import dbghelp; 30 import dbghelp;
31 import core.runtime; 31 import core.runtime;
32 import std.stdio; 32 import std.stdio;
33 import std.c.stdlib; 33 import std.c.stdlib;
34 import std.demangle; 34 import std.demangle;
35 import std.conv; 35 import std.conv;
> 36 import std.path;
36 37
37 extern(Windows){ 38 extern(Windows){
38 DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR pBuffer, DWORD nSize) 39 DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR pBuffer, DWORD nSize)
39 void RtlCaptureContext(CONTEXT* ContextRecord); 40 void RtlCaptureContext(CONTEXT* ContextRecord);
40 typedef LONG function(void*) UnhandeledExceptionFilterFunc; 41 typedef LONG function(void*) UnhandeledExceptionFilterFunc;
41 void* SetUnhandledExceptionFilter(void* handler); 42 void* SetUnhandledExceptionFilter(void* handler);
42 } 43 }
................................................................................................................................................................................
333 break; 334 break;
334 } 335 }
335 336
336 if(stackframe.AddrPC.Offset != 0){ 337 if(stackframe.AddrPC.Offset != 0){
337 string lineStr = ""; 338 string lineStr = "";
338 Dbghelp.DWORD64 offsetFromSymbol = cast(Dbghelp. 339 Dbghelp.DWORD64 offsetFromSymbol = cast(Dbghelp.
339 if( Dbghelp.SymGetSymFromAddr64(hProcess,stackfr 340 if( Dbghelp.SymGetSymFromAddr64(hProcess,stackfr
340 char[] symName = new char[strlen(cast(co | 341 char[] symName = new char[strlen(cast(co
341 memcpy(symName.ptr,Symbol.Name.ptr,symNa 342 memcpy(symName.ptr,Symbol.Name.ptr,symNa
342 string symString = ""; 343 string symString = "";
343 if(symName[0] == 'D') 344 if(symName[0] == 'D')
344 symString = "_"; 345 symString = "_";
345 symString ~= symName; 346 symString ~= symName;
346 347
347 string demangeledName = demangle(symStri | 348 string demangledName = demangle(symStrin
> 349 bool isOK = true;
> 350 for(int i=0; i<demangledName.length; ++i
> 351 if( demangledName[i] >= 0x80 )
> 352 isOK = false;
> 353 if(isOK)
348 lineStr ~= demangeledName; | 354 lineStr ~= demangledName;
349 355
350 DWORD zeichen = 0; 356 DWORD zeichen = 0;
351 if(Dbghelp.SymGetLineFromAddr64(hProcess 357 if(Dbghelp.SymGetLineFromAddr64(hProcess
352 char[] fileName = new char[strle 358 char[] fileName = new char[strle
353 fileName[] = Line.FileName[0..fi | 359 fileName = std.path.basename( Li
354 lineStr = to!string(fileName ~ " 360 lineStr = to!string(fileName ~ "
355 } 361 }
356 } 362 }
357 else { 363 else {
358 lineStr = to!string(cast(ulong)stackfram 364 lineStr = to!string(cast(ulong)stackfram
359 } 365 }
360 lineStr = to!string(frameNum-2) ~ " " ~ lineStr; 366 lineStr = to!string(frameNum-2) ~ " " ~ lineStr;