mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:37:35 +00:00
LibJS+LibWebView+WebContent+Ladybird: Output GC-graph into a file
Instead of displaying a massive JSON in stdout, it's more practical to save the GC-graph to a file.
This commit is contained in:
parent
ed1bee222b
commit
57e5abae92
8 changed files with 38 additions and 13 deletions
|
@ -192,7 +192,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void dump()
|
||||
AK::JsonObject dump()
|
||||
{
|
||||
auto graph = AK::JsonObject();
|
||||
for (auto& it : m_graph) {
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
graph.set(DeprecatedString::number(it.key), node);
|
||||
}
|
||||
|
||||
dbgln("{}", graph.to_deprecated_string());
|
||||
return graph;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -253,14 +253,14 @@ private:
|
|||
FlatPtr m_max_block_address;
|
||||
};
|
||||
|
||||
void Heap::dump_graph()
|
||||
AK::JsonObject Heap::dump_graph()
|
||||
{
|
||||
HashMap<Cell*, HeapRoot> roots;
|
||||
gather_roots(roots);
|
||||
GraphConstructorVisitor visitor(*this, roots);
|
||||
vm().bytecode_interpreter().visit_edges(visitor);
|
||||
visitor.visit_all_cells();
|
||||
visitor.dump();
|
||||
return visitor.dump();
|
||||
}
|
||||
|
||||
void Heap::collect_garbage(CollectionType collection_type, bool print_report)
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
};
|
||||
|
||||
void collect_garbage(CollectionType = CollectionType::CollectGarbage, bool print_report = false);
|
||||
void dump_graph();
|
||||
AK::JsonObject dump_graph();
|
||||
|
||||
bool should_collect_on_every_allocation() const { return m_should_collect_on_every_allocation; }
|
||||
void set_should_collect_on_every_allocation(bool b) { m_should_collect_on_every_allocation = b; }
|
||||
|
|
|
@ -403,8 +403,8 @@ static ErrorOr<LexicalPath> save_screenshot(Gfx::ShareableBitmap const& bitmap)
|
|||
|
||||
auto encoded = TRY(Gfx::PNGWriter::encode(*bitmap.bitmap()));
|
||||
|
||||
auto screenshot_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write));
|
||||
TRY(screenshot_file->write_until_depleted(encoded));
|
||||
auto dump_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write));
|
||||
TRY(dump_file->write_until_depleted(encoded));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
@ -432,6 +432,19 @@ ErrorOr<LexicalPath> ViewImplementation::take_dom_node_screenshot(i32 node_id)
|
|||
return save_screenshot(bitmap);
|
||||
}
|
||||
|
||||
ErrorOr<LexicalPath> ViewImplementation::dump_gc_graph()
|
||||
{
|
||||
auto gc_graph_json = client().dump_gc_graph();
|
||||
|
||||
LexicalPath path { Core::StandardPaths::tempfile_directory() };
|
||||
path = path.append(TRY(Core::DateTime::now().to_string("gc-graph-%Y-%m-%d-%H-%M-%S.json"sv)));
|
||||
|
||||
auto screenshot_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write));
|
||||
TRY(screenshot_file->write_until_depleted(gc_graph_json.bytes()));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void ViewImplementation::set_user_style_sheet(String source)
|
||||
{
|
||||
client().async_set_user_style(move(source));
|
||||
|
|
|
@ -99,6 +99,8 @@ public:
|
|||
ErrorOr<LexicalPath> take_screenshot(ScreenshotType);
|
||||
ErrorOr<LexicalPath> take_dom_node_screenshot(i32);
|
||||
|
||||
ErrorOr<LexicalPath> dump_gc_graph();
|
||||
|
||||
void set_user_style_sheet(String source);
|
||||
// Load Native.css as the User style sheet, which attempts to make WebView content look as close to
|
||||
// native GUI widgets as possible.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue