summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMykyta Biliavskyi <m.biliavskyi@samsung.com>2017-09-01 14:06:21 +0300
committerMykyta Biliavskyi <m.biliavskyi@samsung.com>2017-09-01 14:06:21 +0300
commit170923b1647164ab759289a7205f0bbfbc490210 (patch)
tree2152358a86ba6a51b062b78631a5eff741b3c547
parent26c85dda2d720b3743b9164afb300d8016dcc1ce (diff)
Add profiling viewer extension.
Summary: Due to splitting efl_profiling_viewer to the library this extension was prepared. This is a first version of extension and will be improved. After @Deepwarrior will publish code for efl_profiling_viewer that make possible to work with real time data from efl_debug system, it will be possible compile clouseau with efl_profiling_viewer support. Test Plan: Inctall Profiling_Viewer library in the system. Build clouseau. Launch clouseau and select Profiling viewer extesion. Reviewers: Deepwarrior, JackDanielZ Reviewed By: Deepwarrior Tags: #clouseau, PHID-PROJ-w56dx3enc43oqdzz2xpa Differential Revision: https://phab.enlightenment.org/D5061
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/bin/clouseau_client.c7
-rw-r--r--src/lib/extensions/CMakeLists.txt4
-rw-r--r--src/lib/extensions/profiling_viewer/CMakeLists.txt39
-rw-r--r--src/lib/extensions/profiling_viewer/main.c201
5 files changed, 252 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 71a5906..3685640 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,7 @@ find_package(Elementary REQUIRED)
18find_package(Ecore REQUIRED) 18find_package(Ecore REQUIRED)
19find_package(Evas REQUIRED) 19find_package(Evas REQUIRED)
20find_package(Ffi REQUIRED) 20find_package(Ffi REQUIRED)
21find_package(efl_profiler)
21 22
22add_subdirectory(src/bin) 23add_subdirectory(src/bin)
23add_subdirectory(src/lib) 24add_subdirectory(src/lib)
diff --git a/src/bin/clouseau_client.c b/src/bin/clouseau_client.c
index fbaeb31..d854fc7 100644
--- a/src/bin/clouseau_client.c
+++ b/src/bin/clouseau_client.c
@@ -317,6 +317,13 @@ _configs_load()
317 _config->extensions_cfgs = eina_list_append(_config->extensions_cfgs, ext_cfg); 317 _config->extensions_cfgs = eina_list_append(_config->extensions_cfgs, ext_cfg);
318 } 318 }
319 319
320 if (!_ext_cfg_find_by_path(INSTALL_PREFIX"/lib/libclouseau_profiling_viewer.so"))
321 {
322 ext_cfg = calloc(1, sizeof(*ext_cfg));
323 ext_cfg->lib_path = eina_stringshare_add(INSTALL_PREFIX"/lib/libclouseau_profiling_viewer.so");
324 _config->extensions_cfgs = eina_list_append(_config->extensions_cfgs, ext_cfg);
325 }
326
320 _config_save(); 327 _config_save();
321} 328}
322 329
diff --git a/src/lib/extensions/CMakeLists.txt b/src/lib/extensions/CMakeLists.txt
index f205ad3..6392e44 100644
--- a/src/lib/extensions/CMakeLists.txt
+++ b/src/lib/extensions/CMakeLists.txt
@@ -1,2 +1,6 @@
1add_subdirectory(objects_introspection) 1add_subdirectory(objects_introspection)
2add_subdirectory(evlog) 2add_subdirectory(evlog)
3
4if (${EFL_PROFILER_FOUND})
5 add_subdirectory(profiling_viewer)
6endif (${EFL_PROFILER_FOUND})
diff --git a/src/lib/extensions/profiling_viewer/CMakeLists.txt b/src/lib/extensions/profiling_viewer/CMakeLists.txt
new file mode 100644
index 0000000..0bf1204
--- /dev/null
+++ b/src/lib/extensions/profiling_viewer/CMakeLists.txt
@@ -0,0 +1,39 @@
1set(CMAKE_BUILD_TYPE Debug)
2
3
4
5STRING(REGEX REPLACE "\n" "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
6STRING(REGEX REPLACE " " "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
7add_definitions(${CLI_COMMON_DEFINITIONS} -DEFL_EO_API_SUPPORT
8 -DEOLIAN_EO_DIR="${EOLIAN_EO_DIR}")
9
10add_definitions(-DEFL_EO_API_SUPPORT -DGUI_IMAGES_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME_LOWER}")
11
12set(EOLIAN_INCLUDE_FLAG -I \"${EOLIAN_EO_DIR}/eo-1\" -I${CMAKE_CURRENT_SOURCE_DIR})
13
14include_directories(
15 ${CMAKE_CURRENT_BINARY_DIR}
16 ${EFL_PROFILER_INCLUDE_DIRS}
17 ${ELEMENTARY_INCLUDE_DIRS}
18 ${EVAS_INCLUDE_DIRS}
19 ${EO_INCLUDE_DIRS}
20 ${EINA_INCLUDE_DIRS}
21 ${EET_INCLUDE_DIRS}
22 ${EOLIAN_INCLUDE_DIRS}
23 )
24
25link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS})
26
27add_library(clouseau_profiling_viewer SHARED main.c)
28
29target_link_libraries(clouseau_profiling_viewer
30 efl_profiler
31 ${ELEMENTARY_LIBRARIES}
32 ${EVAS_LIBRARIES}
33 ${EO_LIBRARIES}
34 ${EINA_LIBRARIES}
35 ${EET_LIBRARIES}
36 ${EOLIAN_LIBRARIES}
37 )
38
39INSTALL(TARGETS clouseau_profiling_viewer LIBRARY DESTINATION lib)
diff --git a/src/lib/extensions/profiling_viewer/main.c b/src/lib/extensions/profiling_viewer/main.c
new file mode 100644
index 0000000..293ea20
--- /dev/null
+++ b/src/lib/extensions/profiling_viewer/main.c
@@ -0,0 +1,201 @@
1#include <Eina.h>
2#include <Elementary.h>
3#include <Efl_Profiler.h>
4
5#include "../../Clouseau.h"
6
7#define _EET_ENTRY "config"
8
9
10typedef enum {
11 STREAM_STOPPED = 0,
12 STREAM_PROCESSING,
13 STREAM_PAUSED
14} CLOUSEAU_PROFILER_STATUS;
15
16typedef struct {
17 Evas_Object *profiler;
18 Ecore_Timer *record_get_timer;
19 struct {
20 CLOUSEAU_PROFILER_STATUS status; /*<< 0 - stopped, 1 - processing, 2 - paused */
21 } stream;
22} Inf;
23
24static int _clouseau_profiling_extension_log_dom = 0;
25
26static int _record_on_op = EINA_DEBUG_OPCODE_INVALID;
27static int _record_off_op = EINA_DEBUG_OPCODE_INVALID;
28static int _record_get_op = EINA_DEBUG_OPCODE_INVALID;
29
30static Eina_Bool _record_get_cb(Eina_Debug_Session *, int, void *, int);
31
32EINA_DEBUG_OPCODES_ARRAY_DEFINE(_ops,
33 {"CPU/Freq/on", &_record_on_op, NULL},
34 {"CPU/Freq/off", &_record_off_op, NULL},
35 {"EvLog/get", &_record_get_op, &_record_get_cb},
36 {NULL, NULL, NULL}
37);
38
39
40EAPI const char *
41extension_name_get()
42{
43 return "Profiling viewer";
44}
45
46static Eina_Bool
47_record_request_cb(void *data)
48{
49 Clouseau_Extension *ext = data;
50 eina_debug_session_send(ext->session, ext->app_id, _record_get_op, NULL, 0);
51 return EINA_TRUE;
52}
53
54static void
55_stream_processing_pause_cb(void *data,
56 Evas_Object *obj EINA_UNUSED,
57 void *event_info EINA_UNUSED)
58{
59 Clouseau_Extension *ext = data;
60 Inf *inf = ext->data;
61
62 eina_debug_session_send(ext->session, ext->app_id, _record_off_op, NULL, 0);
63 ecore_timer_del(inf->record_get_timer);
64}
65
66static void
67_stream_processing_resume_cb(void *data,
68 Evas_Object *obj EINA_UNUSED,
69 void *event_info EINA_UNUSED)
70{
71 Clouseau_Extension *ext = data;
72 Inf *inf = ext->data;
73
74 eina_debug_session_send(ext->session, ext->app_id, _record_on_op, NULL, 0);
75 if (!inf->record_get_timer)
76 inf->record_get_timer = ecore_timer_add(0.2, _record_request_cb, ext);
77}
78
79static void
80_session_changed(Clouseau_Extension *ext)
81{
82 Inf *inf = ext->data;
83 int i = 0;
84 Eina_Debug_Opcode *ops = _ops();
85
86 switch (inf->stream.status)
87 {
88 case STREAM_PROCESSING:
89 evas_object_smart_callback_call(inf->profiler, "stream,processing,pause", NULL);
90 break;
91 case STREAM_PAUSED:
92 case STREAM_STOPPED:
93 default:
94 evas_object_smart_callback_call(inf->profiler, "stream,processing,resume", NULL);
95
96 }
97 EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Session changed");
98
99 while (ops[i].opcode_name)
100 {
101 if (ops[i].opcode_id) *(ops[i].opcode_id) = EINA_DEBUG_OPCODE_INVALID;
102 i++;
103 }
104 if (ext->session)
105 {
106 eina_debug_session_data_set(ext->session, ext);
107 eina_debug_opcodes_register(ext->session, ops, NULL, NULL);
108 }
109
110 return;
111}
112
113static void
114_app_changed(Clouseau_Extension *ext)
115{
116 Inf *inf = ext->data;
117 evas_object_smart_callback_call(inf->profiler, "stream,processing,stop", &ext->app_id);
118 EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Application changed");
119 return;
120}
121
122static void
123_profiling_import(Clouseau_Extension *ext,
124 void *buffer, int size,
125 int version EINA_UNUSED)
126{
127 EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Data imported");
128 Inf *inf = ext->data;
129
130 Stream_Block_Data block_data = { .size = size, .data = buffer };
131
132 evas_object_smart_callback_call(inf->profiler, "stream,block,process", &block_data);
133 _stream_processing_resume_cb(ext,NULL, NULL);
134 return;
135}
136
137static Eina_Bool
138_record_get_cb(Eina_Debug_Session *session, int cid EINA_UNUSED, void *buffer, int size)
139{
140 Clouseau_Extension *ext = eina_debug_session_data_get(session);
141 _profiling_import(ext, buffer, size, -1);
142 return EINA_TRUE;
143}
144static Eo *
145_ui_get(Clouseau_Extension *ext, Eo *parent)
146{
147 Inf *inf = ext->data;
148 inf->profiler = efl_profiling_viewer_init(parent);
149 evas_object_size_hint_weight_set(inf->profiler, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
150 evas_object_size_hint_align_set(inf->profiler, EVAS_HINT_FILL, EVAS_HINT_FILL);
151
152 evas_object_smart_callback_add(inf->profiler, "stream,processing,pause",
153 _stream_processing_pause_cb, ext);
154 evas_object_smart_callback_add(inf->profiler, "stream,processing,resume",
155 _stream_processing_resume_cb, ext);
156
157 return inf->profiler;
158}
159
160EAPI Eina_Bool
161extension_start(Clouseau_Extension *ext, Eo *parent)
162{
163 Inf *inf;
164
165 eina_init();
166 const char *log_dom = "clouseau_profiling_extension";
167 _clouseau_profiling_extension_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_ORANGE);
168 if (_clouseau_profiling_extension_log_dom < 0)
169 {
170 EINA_LOG_ERR("Could not register log domain: %s", log_dom);
171 return EINA_FALSE;
172 }
173
174 EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Extension started");
175
176 inf = calloc(1, sizeof(Inf));
177 ext->data = inf;
178 ext->session_changed_cb = _session_changed;
179 ext->app_changed_cb = _app_changed;
180 ext->import_data_cb = _profiling_import;
181
182 ext->ui_object = _ui_get(ext, parent);
183 return !!ext->ui_object;
184}
185
186EAPI Eina_Bool
187extension_stop(Clouseau_Extension *ext)
188{
189 Inf *inf = ext->data;
190
191 evas_object_smart_callback_call(inf->profiler, "log,close", NULL);
192 efl_del(ext->ui_object);
193
194 free(inf);
195
196 EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Extension stopped");
197 eina_log_domain_unregister(_clouseau_profiling_extension_log_dom);
198 eina_shutdown();
199
200 return EINA_TRUE;
201}