A few lines of code to clean the trace.log produced by DMD
bobef
bobef at abv-nospam.bg
Wed Apr 9 11:53:19 PDT 2008
Demangles the names. Needs tangobos.
------------------------------
import tango.io.File;
import tango.io.FileConduit;
import tango.text.Util;
import tango.io.Stdout;
import tango.io.Print;
import tango.text.convert.Layout;
import Regex;
import std.demangle;
pragma(lib,"tangobos.lib");
void main(char[][] argv)
{
char[] filein="trace.log";
char[] fileout="trace.fixed.txt";
if(argv.length>1) filein=argv[0];
if(argv.length>2) filein=argv[1];
auto buf=cast(char[])File(filein).read;
buf=buf[locatePattern(buf,"======== Timer Is")..$];
uint nl=0;
for(uint c=0;c<buf.length;)
{
if(buf[c++]=='\n')
{
if(++nl==5)
{
auto print = new Print!(char)(new Layout!(char),new FileConduit(fileout,FileConduit.WriteCreate));
print(buf[0..c]);
foreach(line;lines(buf[c..$]))
{
foreach(m; Regex.Regex(r"(\s*\d+)(\s*\d+)(\s*\d+)(\s*\d+)(\s*)([^$]+)").search(line))
{
print(m.match(1))(m.match(2))(m.match(3))(m.match(4))(m.match(5))(demangle(m.match(6))).newline;
}
}
break;
}
}
}
}
More information about the Digitalmars-d-announce
mailing list