summaryrefslogtreecommitdiff
path: root/Userland/DevTools
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-08-28 04:31:08 -0700
committerAndreas Kling <kling@serenityos.org>2021-08-28 20:03:08 +0200
commite00c871f650c9178c1d1b8975bb1551d925287f3 (patch)
treea8c18904fd50d7ae2d5d2e1b86951fb8bdfeb6d4 /Userland/DevTools
parent74c3359bedc6e4e9c0e69c98dca931bf55c5746b (diff)
downloadserenity-e00c871f650c9178c1d1b8975bb1551d925287f3.zip
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.
Diffstat (limited to 'Userland/DevTools')
-rw-r--r--Userland/DevTools/UserspaceEmulator/Emulator.cpp3
1 files changed, 2 insertions, 1 deletions
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());
}