aboutsummaryrefslogtreecommitdiffstats
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
parentSpecify Clouseau library to link the extension (diff)
downloadclouseau-170923b1647164ab759289a7205f0bbfbc490210.tar.gz
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)
find_package(Ecore REQUIRED)
find_package(Evas REQUIRED)
find_package(Ffi REQUIRED)
+find_package(efl_profiler)
add_subdirectory(src/bin)
add_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()
_config->extensions_cfgs = eina_list_append(_config->extensions_cfgs, ext_cfg);
}
+ if (!_ext_cfg_find_by_path(INSTALL_PREFIX"/lib/libclouseau_profiling_viewer.so"))
+ {
+ ext_cfg = calloc(1, sizeof(*ext_cfg));
+ ext_cfg->lib_path = eina_stringshare_add(INSTALL_PREFIX"/lib/libclouseau_profiling_viewer.so");
+ _config->extensions_cfgs = eina_list_append(_config->extensions_cfgs, ext_cfg);
+ }
+
_config_save();
}
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 @@
add_subdirectory(objects_introspection)
add_subdirectory(evlog)
+
+if (${EFL_PROFILER_FOUND})
+ add_subdirectory(profiling_viewer)
+endif (${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 @@
+set(CMAKE_BUILD_TYPE Debug)
+
+
+
+STRING(REGEX REPLACE "\n" "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
+STRING(REGEX REPLACE " " "" EOLIAN_EO_DIR ${EOLIAN_EO_DIR})
+add_definitions(${CLI_COMMON_DEFINITIONS} -DEFL_EO_API_SUPPORT
+ -DEOLIAN_EO_DIR="${EOLIAN_EO_DIR}")
+
+add_definitions(-DEFL_EO_API_SUPPORT -DGUI_IMAGES_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME_LOWER}")
+
+set(EOLIAN_INCLUDE_FLAG -I \"${EOLIAN_EO_DIR}/eo-1\" -I${CMAKE_CURRENT_SOURCE_DIR})
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${EFL_PROFILER_INCLUDE_DIRS}
+ ${ELEMENTARY_INCLUDE_DIRS}
+ ${EVAS_INCLUDE_DIRS}
+ ${EO_INCLUDE_DIRS}
+ ${EINA_INCLUDE_DIRS}
+ ${EET_INCLUDE_DIRS}
+ ${EOLIAN_INCLUDE_DIRS}
+ )
+
+link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS})
+
+add_library(clouseau_profiling_viewer SHARED main.c)
+
+target_link_libraries(clouseau_profiling_viewer
+ efl_profiler
+ ${ELEMENTARY_LIBRARIES}
+ ${EVAS_LIBRARIES}
+ ${EO_LIBRARIES}
+ ${EINA_LIBRARIES}
+ ${EET_LIBRARIES}
+ ${EOLIAN_LIBRARIES}
+ )
+
+INSTALL(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 @@
+#include <Eina.h>
+#include <Elementary.h>
+#include <Efl_Profiler.h>
+
+#include "../../Clouseau.h"
+
+#define _EET_ENTRY "config"
+
+
+typedef enum {
+ STREAM_STOPPED = 0,
+ STREAM_PROCESSING,
+ STREAM_PAUSED
+} CLOUSEAU_PROFILER_STATUS;
+
+typedef struct {
+ Evas_Object *profiler;
+ Ecore_Timer *record_get_timer;
+ struct {
+ CLOUSEAU_PROFILER_STATUS status; /*<< 0 - stopped, 1 - processing, 2 - paused */
+ } stream;
+} Inf;
+
+static int _clouseau_profiling_extension_log_dom = 0;
+
+static int _record_on_op = EINA_DEBUG_OPCODE_INVALID;
+static int _record_off_op = EINA_DEBUG_OPCODE_INVALID;
+static int _record_get_op = EINA_DEBUG_OPCODE_INVALID;
+
+static Eina_Bool _record_get_cb(Eina_Debug_Session *, int, void *, int);
+
+EINA_DEBUG_OPCODES_ARRAY_DEFINE(_ops,
+ {"CPU/Freq/on", &_record_on_op, NULL},
+ {"CPU/Freq/off", &_record_off_op, NULL},
+ {"EvLog/get", &_record_get_op, &_record_get_cb},
+ {NULL, NULL, NULL}
+);
+
+
+EAPI const char *
+extension_name_get()
+{
+ return "Profiling viewer";
+}
+
+static Eina_Bool
+_record_request_cb(void *data)
+{
+ Clouseau_Extension *ext = data;
+ eina_debug_session_send(ext->session, ext->app_id, _record_get_op, NULL, 0);
+ return EINA_TRUE;
+}
+
+static void
+_stream_processing_pause_cb(void *data,
+ Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Clouseau_Extension *ext = data;
+ Inf *inf = ext->data;
+
+ eina_debug_session_send(ext->session, ext->app_id, _record_off_op, NULL, 0);
+ ecore_timer_del(inf->record_get_timer);
+}
+
+static void
+_stream_processing_resume_cb(void *data,
+ Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Clouseau_Extension *ext = data;
+ Inf *inf = ext->data;
+
+ eina_debug_session_send(ext->session, ext->app_id, _record_on_op, NULL, 0);
+ if (!inf->record_get_timer)
+ inf->record_get_timer = ecore_timer_add(0.2, _record_request_cb, ext);
+}
+
+static void
+_session_changed(Clouseau_Extension *ext)
+{
+ Inf *inf = ext->data;
+ int i = 0;
+ Eina_Debug_Opcode *ops = _ops();
+
+ switch (inf->stream.status)
+ {
+ case STREAM_PROCESSING:
+ evas_object_smart_callback_call(inf->profiler, "stream,processing,pause", NULL);
+ break;
+ case STREAM_PAUSED:
+ case STREAM_STOPPED:
+ default:
+ evas_object_smart_callback_call(inf->profiler, "stream,processing,resume", NULL);
+
+ }
+ EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Session changed");
+
+ while (ops[i].opcode_name)
+ {
+ if (ops[i].opcode_id) *(ops[i].opcode_id) = EINA_DEBUG_OPCODE_INVALID;
+ i++;
+ }
+ if (ext->session)
+ {
+ eina_debug_session_data_set(ext->session, ext);
+ eina_debug_opcodes_register(ext->session, ops, NULL, NULL);
+ }
+
+ return;
+}
+
+static void
+_app_changed(Clouseau_Extension *ext)
+{
+ Inf *inf = ext->data;
+ evas_object_smart_callback_call(inf->profiler, "stream,processing,stop", &ext->app_id);
+ EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Application changed");
+ return;
+}
+
+static void
+_profiling_import(Clouseau_Extension *ext,
+ void *buffer, int size,
+ int version EINA_UNUSED)
+{
+ EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Data imported");
+ Inf *inf = ext->data;
+
+ Stream_Block_Data block_data = { .size = size, .data = buffer };
+
+ evas_object_smart_callback_call(inf->profiler, "stream,block,process", &block_data);
+ _stream_processing_resume_cb(ext,NULL, NULL);
+ return;
+}
+
+static Eina_Bool
+_record_get_cb(Eina_Debug_Session *session, int cid EINA_UNUSED, void *buffer, int size)
+{
+ Clouseau_Extension *ext = eina_debug_session_data_get(session);
+ _profiling_import(ext, buffer, size, -1);
+ return EINA_TRUE;
+}
+static Eo *
+_ui_get(Clouseau_Extension *ext, Eo *parent)
+{
+ Inf *inf = ext->data;
+ inf->profiler = efl_profiling_viewer_init(parent);
+ evas_object_size_hint_weight_set(inf->profiler, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(inf->profiler, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ evas_object_smart_callback_add(inf->profiler, "stream,processing,pause",
+ _stream_processing_pause_cb, ext);
+ evas_object_smart_callback_add(inf->profiler, "stream,processing,resume",
+ _stream_processing_resume_cb, ext);
+
+ return inf->profiler;
+}
+
+EAPI Eina_Bool
+extension_start(Clouseau_Extension *ext, Eo *parent)
+{
+ Inf *inf;
+
+ eina_init();
+ const char *log_dom = "clouseau_profiling_extension";
+ _clouseau_profiling_extension_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_ORANGE);
+ if (_clouseau_profiling_extension_log_dom < 0)
+ {
+ EINA_LOG_ERR("Could not register log domain: %s", log_dom);
+ return EINA_FALSE;
+ }
+
+ EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Extension started");
+
+ inf = calloc(1, sizeof(Inf));
+ ext->data = inf;
+ ext->session_changed_cb = _session_changed;
+ ext->app_changed_cb = _app_changed;
+ ext->import_data_cb = _profiling_import;
+
+ ext->ui_object = _ui_get(ext, parent);
+ return !!ext->ui_object;
+}
+
+EAPI Eina_Bool
+extension_stop(Clouseau_Extension *ext)
+{
+ Inf *inf = ext->data;
+
+ evas_object_smart_callback_call(inf->profiler, "log,close", NULL);
+ efl_del(ext->ui_object);
+
+ free(inf);
+
+ EINA_LOG_DOM_DBG(_clouseau_profiling_extension_log_dom, "Extension stopped");
+ eina_log_domain_unregister(_clouseau_profiling_extension_log_dom);
+ eina_shutdown();
+
+ return EINA_TRUE;
+}