From e8253cc221f005cb617f683c730133a3e4fd0641 Mon Sep 17 00:00:00 2001 From: Shing Lyu Date: Fri, 9 Sep 2016 21:13:42 -0500 Subject: [PATCH] servo: Merge #13214 - Create separate layout trace file for each reflow (from shinglyu:gen_trace); r=SimonSapin Currently only the layout trace from the last reflow is dumped to the file. But the interesting reflow may not be the last one. So we are dumping each of them with filename `layout_trace-{generation}.json`. This will be used by a GUI viewer to visualize the layout process, which I will check-in later. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). - [ ] There are tests for these changes OR - [x] These changes do not require tests because its a minor debug tool Source-Repo: https://github.com/servo/servo Source-Revision: b38d9cc3ad307a341a1f3b35d24ccc623df8cb20 --- servo/components/layout/layout_debug.rs | 4 ++-- servo/components/layout_thread/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/servo/components/layout/layout_debug.rs b/servo/components/layout/layout_debug.rs index 20e8a16714b0..77ed1741adda 100644 --- a/servo/components/layout/layout_debug.rs +++ b/servo/components/layout/layout_debug.rs @@ -121,13 +121,13 @@ pub fn begin_trace(flow_root: FlowRef) { /// End the debug layout trace. This will write the layout /// trace to disk in the current directory. The output /// file can then be viewed with an external tool. -pub fn end_trace() { +pub fn end_trace(generation: u32) { let mut thread_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap()); assert!(thread_state.scope_stack.len() == 1); let mut root_scope = thread_state.scope_stack.pop().unwrap(); root_scope.post = json::encode(&flow::base(&*thread_state.flow_root)).unwrap(); let result = json::encode(&root_scope).unwrap(); - let mut file = File::create("layout_trace.json").unwrap(); + let mut file = File::create(format!("layout_trace-{}.json", generation)).unwrap(); file.write_all(result.as_bytes()).unwrap(); } diff --git a/servo/components/layout_thread/lib.rs b/servo/components/layout_thread/lib.rs index fcda02426576..2b080bb0d702 100644 --- a/servo/components/layout_thread/lib.rs +++ b/servo/components/layout_thread/lib.rs @@ -1522,7 +1522,7 @@ impl LayoutThread { self.first_reflow = false; if opts::get().trace_layout { - layout_debug::end_trace(); + layout_debug::end_trace(self.generation); } if opts::get().dump_flow_tree {