utahplt / CSTG

CLI tool for generating and visualizing graphs from stacktraces
MIT License
4 stars 0 forks source link

Make line parsing more robust #1

Open ashton314 opened 1 year ago

ashton314 commented 1 year ago

With FloatTracker we're seeing some funky behavior from CSTG, and I think it's because of a strangely-formatted line. Most of these lines are just how Julia decides to stringify stack frames, so while we could make FloatTracker print prettier frames, I think it might be good to make CSTG a little more flexible/robust in the format it accepts.

Example line that's proving a problem:

(::ShallowWaters.var"#run_model##kw")(::NamedTuple{(:T, :nx, :L_ratio, :bc, :wind_forcing_x, :topography, :cfl, :Ndays), Tuple{DataType, Int64, Int64, String, String, String, Int64, Int64}}, ::typeof(run_model)) at run_model.jl:12

I think the code we'll want to look at is here in tracerSum.cpp:

    // read input
    double startTime = 0;
    getline(inFile, line);
    sscanf(line.c_str(), "%s %lf", tmp, &startTime);
    splitToken = tmp;
    while (getline(inFile, line)){
        sscanf(line.c_str(), "%s", tmp);
        if (tmp == splitToken){
            processStack(startTime);
            sscanf(line.c_str(), "%s %lf", tmp, &startTime);
            continue;
        }
        queue.push_back(line);
    }
    processStack(startTime);