summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2015-11-12 14:22:53 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2015-11-12 14:22:53 +0200
commitf762e87013a0b1302a2ec41458364987950d16e3 (patch)
treee223f61f2366f581832935af3ead40adfcfd527b
parent0ae460a2fc6ce61e249e869c53f685117c19525f (diff)
Elementary: add module and move code from Elm branch
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/lib/CMakeLists.txt19
-rw-r--r--src/lib/elementary_debug.c153
3 files changed, 166 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7be7eca..f5039d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/EdebugConfig.cmake"
33find_package(Eina REQUIRED) 33find_package(Eina REQUIRED)
34find_package(Eolian REQUIRED) 34find_package(Eolian REQUIRED)
35find_package(Eo REQUIRED) 35find_package(Eo REQUIRED)
36find_package(Elementary REQUIRED)
36find_package(Ffi REQUIRED) 37find_package(Ffi REQUIRED)
37 38
38add_subdirectory(src/lib) 39add_subdirectory(src/lib)
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 1348f2f..e69c467 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -1,19 +1,16 @@
1set(CMAKE_BUILD_TYPE Debug) 1set(CMAKE_BUILD_TYPE Debug)
2 2
3LIST(APPEND CC_SOURCES eolian_debug.c)
4
5include_directories (${CMAKE_SOURCE_DIR}/src)
6include_directories(${CMAKE_CURRENT_BINARY_DIR}) 3include_directories(${CMAKE_CURRENT_BINARY_DIR})
7include_directories( 4include_directories(
8 ${EINA_INCLUDE_DIRS} 5 ${EINA_INCLUDE_DIRS}
9 ${EOLIAN_INCLUDE_DIRS} 6 ${EOLIAN_INCLUDE_DIRS}
10 ${EO_INCLUDE_DIRS} 7 ${EO_INCLUDE_DIRS}
11 ${FFI_INCLUDE_DIRS} 8 ${FFI_INCLUDE_DIRS}
9 ${ELEMENTARY_INCLUDE_DIRS}
12 ) 10 )
13 11
14set(EOLIAN_INCLUDE_FLAG -I${CMAKE_CURRENT_SOURCE_DIR}) 12add_library(eolian_debug SHARED eolian_debug.c)
15 13add_library(elementary_debug SHARED elementary_debug.c)
16add_library(eolian_debug SHARED ${CC_SOURCES})
17 14
18target_link_libraries(eolian_debug 15target_link_libraries(eolian_debug
19 ${EINA_LIBRARIES} 16 ${EINA_LIBRARIES}
@@ -22,6 +19,14 @@ target_link_libraries(eolian_debug
22 ${FFI_LIBRARIES} 19 ${FFI_LIBRARIES}
23 ) 20 )
24 21
22target_link_libraries(elementary_debug
23 ${EINA_LIBRARIES}
24 ${EO_LIBRARIES}
25 ${EOLIAN_LIBRARIES}
26 ${FFI_LIBRARIES}
27 ${ELEMENTARY_LIBRARIES}
28 )
29
25INSTALL(FILES Eolian_Debug.h DESTINATION include/edebug) 30INSTALL(FILES Eolian_Debug.h DESTINATION include/edebug)
26 31
27INSTALL(TARGETS eolian_debug LIBRARY DESTINATION lib) 32INSTALL(TARGETS eolian_debug elementary_debug LIBRARY DESTINATION lib)
diff --git a/src/lib/elementary_debug.c b/src/lib/elementary_debug.c
new file mode 100644
index 0000000..7265e15
--- /dev/null
+++ b/src/lib/elementary_debug.c
@@ -0,0 +1,153 @@
1#define _GNU_SOURCE
2
3#include <Eo.h>
4#include <Eina.h>
5#include <Elementary.h>
6#define ELM_INTERNAL_API_ARGESFSDFEFC
7#include <elm_widget.h>
8
9#ifdef EAPI
10# undef EAPI
11#endif
12
13#ifdef _WIN32
14# ifdef DEBUG_BUILD
15# ifdef DLL_EXPORT
16# define EAPI __declspec(dllexport)
17# else
18# define EAPI
19# endif /* ! DLL_EXPORT */
20# else
21# define EAPI __declspec(dllimport)
22# endif /* ! DEBUG_BUILD */
23#else
24# ifdef __GNUC__
25# if __GNUC__ >= 4
26# define EAPI __attribute__ ((visibility("default")))
27# else
28# define EAPI
29# endif
30# else
31# define EAPI
32# endif
33#endif /* ! _WIN32 */
34
35#define STORE(_buf, pval, sz) \
36{ \
37 memcpy(_buf, pval, sz); \
38 _buf += sz; \
39}
40
41#define EXTRACT(_buf, pval, sz) \
42{ \
43 memcpy(pval, _buf, sz); \
44 _buf += sz; \
45}
46
47static int _init_counter = 0;
48
49static uint32_t _debug_objs_list_op = EINA_DEBUG_OPCODE_INVALID;
50
51static Eina_Bool
52_debug_list_req_cb(Eina_Debug_Client *src, void *buffer EINA_UNUSED, int size EINA_UNUSED)
53{
54 Eo_Class *kl_id = NULL;
55#if 0
56 if (size > 0)
57 {
58 char *req_classname = buffer;
59 unsigned int i;
60 for (i = 0; i < _eo_classes_last_id && !kl_id; i++)
61 {
62 if (!strcmp(_eo_classes[i]->desc->name, req_classname))
63 kl_id = _eo_class_id_get(_eo_classes[i]);
64 }
65 }
66#endif
67 const Eina_List *objs = eo_debug_objects_list_get(), *itr;
68 Eo *obj;
69 unsigned int strings_size = 0;
70 unsigned int objs_count = 0;
71
72 EINA_LIST_FOREACH(objs, itr, obj)
73 {
74 if (!kl_id || eo_isa(obj, kl_id))
75 {
76 strings_size += strlen(eo_class_name_get(obj)) + 1;
77 objs_count++;
78 }
79 }
80
81 unsigned int resp_size = 2 * objs_count * sizeof(uint64_t) + strings_size;
82 unsigned char *buf = alloca(resp_size);
83 unsigned int size_curr = 0;
84
85 EINA_LIST_FOREACH(objs, itr, obj)
86 {
87 if (!kl_id || eo_isa(obj, kl_id))
88 {
89 const char *kl_name = eo_class_name_get(obj);
90 Eo *parent = NULL;
91 memcpy(buf + size_curr, &obj, sizeof(uint64_t));
92 size_curr += sizeof(uint64_t);
93 do
94 {
95 if (eo_isa(obj, ELM_WIDGET_CLASS))
96 eo_do(obj, parent = elm_obj_widget_parent_get());
97 if (!parent && eo_isa(obj, EVAS_OBJECT_CLASS))
98 {
99 parent = evas_object_data_get(obj, "elm-parent");
100 if (!parent) parent = evas_object_smart_parent_get(obj);
101 }
102 if (!parent) parent = eo_do_ret(obj, parent, eo_parent_get());
103 }
104 while (parent && kl_id && !eo_isa(parent, kl_id));
105 memcpy(buf + size_curr, &parent, sizeof(uint64_t));
106 size_curr += sizeof(uint64_t);
107 unsigned int len = strlen(kl_name) + 1;
108 memcpy(buf + size_curr, kl_name, len);
109 size_curr += len;
110 }
111 }
112
113 eina_debug_session_send(src, _debug_objs_list_op, buf, resp_size);
114
115 return EINA_TRUE;
116}
117
118static const Eina_Debug_Opcode _debug_ops[] =
119{
120 {"Elementary/objects_list", &_debug_objs_list_op, &_debug_list_req_cb},
121 {NULL, NULL, NULL}
122};
123
124EAPI int
125elementary_debug_init(void)
126{
127 if (_init_counter > 0) return ++_init_counter;
128
129 elm_init(0, NULL);
130 eina_init();
131
132 eina_debug_opcodes_register(NULL, _debug_ops, NULL);
133
134 printf("%s - In\n", __FUNCTION__);
135 return EINA_TRUE;
136}
137
138EAPI int
139elementary_debug_shutdown(void)
140{
141 if (_init_counter <= 0)
142 {
143 EINA_LOG_ERR("Init count not greater than 0 in shutdown.");
144 return 0;
145 }
146
147 if (--_init_counter) return _init_counter;
148
149 eina_shutdown();
150 elm_shutdown();
151
152 return 0;
153}