1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

UserspaceEmulator: Make generated profiles debugable with cli tools

The fact that profiles are json on one giant line makes them very
difficult to debug when things go wrong. Instead make sure to wrap
each event or sample on a newline so you can easily grep/heap/tail
the profile files.
This commit is contained in:
Brian Gianforcaro 2021-08-28 04:31:08 -07:00 committed by Andreas Kling
parent 74c3359bed
commit e00c871f65

View file

@ -476,7 +476,7 @@ void Emulator::emit_profile_sample(AK::OutputStream& output)
gettimeofday(&tv, nullptr);
builder.appendff(R"~(, {{"type": "sample", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": [)~", getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000);
builder.join(',', raw_backtrace());
builder.append("]}");
builder.append("]}\n");
output.write_or_error(builder.string_view().bytes());
}
@ -486,6 +486,7 @@ void Emulator::emit_profile_event(AK::OutputStream& output, StringView event_nam
timeval tv {};
gettimeofday(&tv, nullptr);
builder.appendff(R"~(, {{"type": "{}", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": [], {}}})~", event_name, getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000, contents);
builder.append('\n');
output.write_or_error(builder.string_view().bytes());
}