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 29 import std.string;
30 30 import dbghelp;
31 31 import core.runtime;
32 32 import std.stdio;
33 33 import std.c.stdlib;
34 34 import std.demangle;
35 35 import std.conv;
36 +import std.path;
36 37
37 38 extern(Windows){
38 39 DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR pBuffer, DWORD nSize);
39 40 void RtlCaptureContext(CONTEXT* ContextRecord);
40 41 typedef LONG function(void*) UnhandeledExceptionFilterFunc;
41 42 void* SetUnhandledExceptionFilter(void* handler);
42 43 }
................................................................................
333 334 break;
334 335 }
335 336
336 337 if(stackframe.AddrPC.Offset != 0){
337 338 string lineStr = "";
338 339 Dbghelp.DWORD64 offsetFromSymbol = cast(Dbghelp.DWORD64)0;
339 340 if( Dbghelp.SymGetSymFromAddr64(hProcess,stackframe.AddrPC.Offset,&offsetFromSymbol,Symbol) == TRUE){
340 - char[] symName = new char[strlen(cast(const(char)*)Symbol.Name.ptr)+1];
341 + char[] symName = new char[strlen(cast(const(char)*)Symbol.Name.ptr)];
341 342 memcpy(symName.ptr,Symbol.Name.ptr,symName.length);
342 343 string symString = "";
343 344 if(symName[0] == 'D')
344 345 symString = "_";
345 346 symString ~= symName;
346 347
347 - string demangeledName = demangle(symString);
348 - lineStr ~= demangeledName;
348 + string demangledName = demangle(symString);
349 + bool isOK = true;
350 + for(int i=0; i<demangledName.length; ++i)
351 + if( demangledName[i] >= 0x80 )
352 + isOK = false;
353 + if(isOK)
354 + lineStr ~= demangledName;
349 355
350 356 DWORD zeichen = 0;
351 357 if(Dbghelp.SymGetLineFromAddr64(hProcess,stackframe.AddrPC.Offset,&zeichen,&Line) == TRUE){
352 358 char[] fileName = new char[strlen(Line.FileName)];
353 - fileName[] = Line.FileName[0..fileName.length];
359 + fileName = std.path.basename( Line.FileName[0..fileName.length] );
354 360 lineStr = to!string(fileName ~ "::" ~ to!string(Line.LineNumber) ~ "(" ~ to!string(zeichen) ~ ") " ~ lineStr);
355 361 }
356 362 }
357 363 else {
358 364 lineStr = to!string(cast(ulong)stackframe.AddrPC.Offset);
359 365 }
360 366 lineStr = to!string(frameNum-2) ~ " " ~ lineStr;