Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
0bc34f03
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0bc34f03
编写于
12月 02, 2015
作者:
C
Chinmay Garde
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow tracing during startup
上级
ad63ba0f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
78 addition
and
28 deletion
+78
-28
sky/shell/shell.cc
sky/shell/shell.cc
+3
-0
sky/shell/switches.cc
sky/shell/switches.cc
+1
-0
sky/shell/switches.h
sky/shell/switches.h
+1
-0
sky/shell/tracing_controller.cc
sky/shell/tracing_controller.cc
+66
-28
sky/shell/tracing_controller.h
sky/shell/tracing_controller.h
+6
-0
sky/shell/ui/engine.cc
sky/shell/ui/engine.cc
+1
-0
未找到文件。
sky/shell/shell.cc
浏览文件 @
0bc34f03
...
...
@@ -81,6 +81,9 @@ void Shell::InitStandalone() {
settings
.
enable_dart_checked_mode
=
command_line
.
HasSwitch
(
switches
::
kEnableCheckedMode
);
Init
(
settings
);
if
(
command_line
.
HasSwitch
(
switches
::
kTraceStartup
))
{
Shared
().
tracing_controller
().
StartTracing
();
}
}
void
Shell
::
Init
(
const
Settings
&
settings
)
{
...
...
sky/shell/switches.cc
浏览文件 @
0bc34f03
...
...
@@ -15,6 +15,7 @@ const char kFLX[] = "flx";
const
char
kHelp
[]
=
"help"
;
const
char
kNonInteractive
[]
=
"non-interactive"
;
const
char
kPackageRoot
[]
=
"package-root"
;
const
char
kTraceStartup
[]
=
"trace-startup"
;
void
PrintUsage
(
const
std
::
string
&
executable_name
)
{
std
::
cerr
<<
"Usage: "
<<
executable_name
...
...
sky/shell/switches.h
浏览文件 @
0bc34f03
...
...
@@ -16,6 +16,7 @@ extern const char kFLX[];
extern
const
char
kHelp
[];
extern
const
char
kNonInteractive
[];
extern
const
char
kPackageRoot
[];
extern
const
char
kTraceStartup
[];
void
PrintUsage
(
const
std
::
string
&
executable_name
);
...
...
sky/shell/tracing_controller.cc
浏览文件 @
0bc34f03
...
...
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/shell/tracing_controller.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/trace_event/trace_config.h"
#include "base/trace_event/trace_event.h"
#include "sky/shell/shell.h"
#include "sky/shell/tracing_controller.h"
#include "dart/runtime/include/dart_tools_api.h"
#include "sky/shell/shell.h"
#include <string>
#include <sstream>
...
...
@@ -41,46 +42,52 @@ static const char* ObservatoryInvoke(const char* method,
if
(
strncmp
(
method
,
kObservatoryMethodStartTracing
,
sizeof
(
kObservatoryMethodStartTracing
))
==
0
)
{
tracing_controller
->
StartTracing
();
return
strdup
(
kObservatoryResultOk
);
if
(
!
tracing_controller
->
tracing_active
())
{
tracing_controller
->
StartTracing
();
return
strdup
(
kObservatoryResultOk
);
}
}
if
(
strncmp
(
method
,
kObservatoryMethodStopTracing
,
sizeof
(
kObservatoryMethodStopTracing
))
==
0
)
{
// Flushing the trace log requires an active message loop. However,
// observatory callbacks are made on a dart worker thread. We setup a
// message loop manually and tell the flush completion handler to terminate
// the loop when done
base
::
MessageLoop
worker_thread_loop
;
if
(
tracing_controller
->
tracing_active
())
{
// Flushing the trace log requires an active message loop. However,
// observatory callbacks are made on a dart worker thread. We setup a
// message loop manually and tell the flush completion handler to
// terminate
// the loop when done
base
::
MessageLoop
worker_thread_loop
;
base
::
FilePath
temp_dir
;
bool
temp_access
=
base
::
GetTempDir
(
&
temp_dir
);
DCHECK
(
temp_access
)
<<
"Must be able to access the temp directory"
;
base
::
FilePath
temp_dir
;
bool
temp_access
=
base
::
GetTempDir
(
&
temp_dir
);
DCHECK
(
temp_access
)
<<
"Must be able to access the temp directory"
;
base
::
FilePath
path
=
tracing_controller
->
TracePathForCurrentTime
(
temp_dir
);
base
::
FilePath
path
=
tracing_controller
->
TracePathForCurrentTime
(
temp_dir
);
tracing_controller
->
StopTracing
(
path
,
true
);
tracing_controller
->
StopTracing
(
path
,
true
);
// Run the loop till the flush callback terminates the activation
worker_thread_loop
.
Run
();
// Run the loop till the flush callback terminates the activation
worker_thread_loop
.
Run
();
base
::
File
file
(
path
,
base
::
File
::
Flags
::
FLAG_OPEN
|
base
::
File
::
Flags
::
FLAG_READ
);
int64
length
=
file
.
GetLength
();
base
::
File
file
(
path
,
base
::
File
::
Flags
::
FLAG_OPEN
|
base
::
File
::
Flags
::
FLAG_READ
);
int64
length
=
file
.
GetLength
();
if
(
length
==
0
)
{
base
::
DeleteFile
(
path
,
false
);
return
strdup
(
kObservatoryResultFail
);
}
if
(
length
==
0
)
{
base
::
DeleteFile
(
path
,
false
);
return
strdup
(
kObservatoryResultFail
);
}
char
*
data
=
reinterpret_cast
<
char
*>
(
malloc
(
length
));
int
length_read
=
file
.
Read
(
0
,
data
,
length
);
char
*
data
=
reinterpret_cast
<
char
*>
(
malloc
(
length
));
int
length_read
=
file
.
Read
(
0
,
data
,
length
);
DCHECK
(
length
==
length_read
);
DCHECK
(
length
==
length_read
);
base
::
DeleteFile
(
path
,
false
);
base
::
DeleteFile
(
path
,
false
);
return
data
;
return
data
;
}
}
return
strdup
(
kObservatoryResultFail
);
...
...
@@ -89,6 +96,8 @@ static const char* ObservatoryInvoke(const char* method,
TracingController
::
TracingController
()
:
picture_tracing_enabled_
(
false
),
terminate_loop_on_write_
(
false
),
dart_initialized_
(
false
),
tracing_active_
(
false
),
weak_factory_
(
this
)
{
ManageObservatoryCallbacks
(
true
);
}
...
...
@@ -97,6 +106,18 @@ TracingController::~TracingController() {
ManageObservatoryCallbacks
(
false
);
}
void
TracingController
::
SetDartInitialized
()
{
DCHECK
(
!
dart_initialized_
);
dart_initialized_
=
true
;
// In case early lifecycle is being traced, base tracing has already begun
// but we have just been notified of initialization of the Dart VM. Start
// collecting traces in Dart.
if
(
tracing_active_
)
{
StartDartTracing
();
}
}
void
TracingController
::
ManageObservatoryCallbacks
(
bool
add
)
{
void
*
baton
=
add
?
this
:
nullptr
;
Dart_RegisterRootServiceRequestCallback
(
kObservatoryMethodStartTracing
,
...
...
@@ -106,8 +127,12 @@ void TracingController::ManageObservatoryCallbacks(bool add) {
}
void
TracingController
::
StartTracing
()
{
DCHECK
(
!
tracing_active_
);
LOG
(
INFO
)
<<
"Starting trace"
;
tracing_active_
=
true
;
StartDartTracing
();
StartBaseTracing
();
}
...
...
@@ -138,6 +163,10 @@ void TracingController::StopTracingAsync(const base::FilePath& path,
}
void
TracingController
::
StartDartTracing
()
{
if
(
!
dart_initialized_
)
{
return
;
}
Dart_GlobalTimelineSetRecordedStreams
(
~
0
);
}
...
...
@@ -161,6 +190,13 @@ static void TracingController_DartStreamConsumer(
}
void
TracingController
::
StopDartTracing
()
{
if
(
!
dart_initialized_
)
{
// This is checking for the highly unlikely case where the user starts and
// stops tracing before the dart VM is initialized.
FinalizeTraceFile
();
return
;
}
if
(
trace_file_
){
trace_file_
->
WriteAtCurrentPos
(
","
,
1
);
}
...
...
@@ -204,6 +240,8 @@ void TracingController::FinalizeTraceFile() {
terminate_loop_on_write_
=
false
;
}
tracing_active_
=
false
;
LOG
(
INFO
)
<<
"Trace complete"
;
}
...
...
sky/shell/tracing_controller.h
浏览文件 @
0bc34f03
...
...
@@ -34,6 +34,10 @@ class TracingController {
base
::
FilePath
TracePathForCurrentTime
(
base
::
FilePath
dir
)
const
;
void
SetDartInitialized
();
bool
tracing_active
()
const
{
return
tracing_active_
;
}
void
set_traces_base_path
(
const
base
::
FilePath
&
base_path
)
{
traces_base_path_
=
base_path
;
}
...
...
@@ -49,6 +53,8 @@ class TracingController {
base
::
FilePath
traces_base_path_
;
bool
picture_tracing_enabled_
;
bool
terminate_loop_on_write_
;
bool
dart_initialized_
;
bool
tracing_active_
;
void
StartDartTracing
();
void
StartBaseTracing
();
...
...
sky/shell/ui/engine.cc
浏览文件 @
0bc34f03
...
...
@@ -78,6 +78,7 @@ void Engine::Init() {
DCHECK
(
!
g_platform_impl
);
g_platform_impl
=
new
PlatformImpl
();
blink
::
initialize
(
g_platform_impl
);
Shell
::
Shared
().
tracing_controller
().
SetDartInitialized
();
}
std
::
unique_ptr
<
compositor
::
LayerTree
>
Engine
::
BeginFrame
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录