From e00c871f650c9178c1d1b8975bb1551d925287f3 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 28 Aug 2021 04:31:08 -0700 Subject: [PATCH] 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. --- Userland/DevTools/UserspaceEmulator/Emulator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index 64bb35c54e..65e50e8908 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -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()); }