summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2015-07-29 10:58:48 +0300
committerDaniel Hirt <daniel.hirt@samsung.com>2015-07-29 10:58:48 +0300
commit87605590908e7bd638b26850da064ea708f222b2 (patch)
tree3e5e7a6ffd309e48aa3fe69576695050ce83cd9a
Add initial stuff and working POC
-rw-r--r--220
-rw-r--r--CMakeLists.txt19
-rw-r--r--README4
-rw-r--r--TODO1
-rw-r--r--cmake/Modules/EFLCheck.cmake12
-rw-r--r--cmake/Modules/FindCGraph.cmake41
-rw-r--r--cmake/Modules/FindCheck.cmake32
-rw-r--r--cmake/Modules/FindFfi.cmake40
-rw-r--r--cmake/Modules/FindGvc.cmake41
-rw-r--r--src/lib/.eo_preload.c.swpbin0 -> 20480 bytes
-rw-r--r--src/lib/CMakeLists.txt29
-rw-r--r--src/lib/eo_preload.c177
12 files changed, 416 insertions, 0 deletions
diff --git a/2 b/2
new file mode 100644
index 0000000..d18ec6d
--- /dev/null
+++ b/2
@@ -0,0 +1,20 @@
1#define _GNU_SOURCE
2#include <dlfcn.h>
3
4#include <Eo.h>
5#include <Evas.h>
6#include <Elementary.h>
7
8#include <Eolian.h>
9
10EAPI Eo *
11_eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id, Eina_Bool ref)
12{
13 Eo *ret = NULL;
14 Eo *(*_eo_add_start)(const char *, int, const Eo_Class *, Eo *, Eina_Bool) = dlsym(RTLD_NEXT, __func__);
15
16 ret = _eo_add_start(file, line, klass_id, parent_id, ref);
17 eo_do(ret, eo_key_data_set("__espion_data", EINA_TRUE));
18
19}
20
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..5c3c15f
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,19 @@
1cmake_minimum_required(VERSION 2.8.1)
2
3set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
4
5project(EDBG)
6
7set(EDBG_COMMON_DEFINITIONS -DEFL_EO_API_SUPPORT -DEFL_BETA_API_SUPPORT)
8add_definitions(${EDBG_COMMON_DEFINITIONS})
9
10find_package(Eina REQUIRED)
11find_package(Eo REQUIRED)
12find_package(Eolian REQUIRED)
13find_package(Ecore REQUIRED)
14find_package(Evas REQUIRED)
15find_package(Elementary REQUIRED)
16
17include(EFLCheck)
18
19add_subdirectory(src/lib)
diff --git a/README b/README
new file mode 100644
index 0000000..ca8cdab
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
1Textblock Debug Tool
2
3[ ] Load to a program (LD_PRELOAD)
4[ ] Add key for textblock objects, for textblock to use during render stages (LD_PRELOAD)
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..a6e4887
--- /dev/null
+++ b/TODO
@@ -0,0 +1 @@
[ ] Add TODO items :)
diff --git a/cmake/Modules/EFLCheck.cmake b/cmake/Modules/EFLCheck.cmake
new file mode 100644
index 0000000..f729325
--- /dev/null
+++ b/cmake/Modules/EFLCheck.cmake
@@ -0,0 +1,12 @@
1include(CTest)
2ENABLE_TESTING()
3add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
4
5find_package(Check)
6set (CHECK_ENABLED ${CHECK_FOUND})
7
8set(EFL_COVERAGE false CACHE BOOL "Whether coverage support should be built.'")
9if (EFL_COVERAGE)
10 include(EFLlcov REQUIRED)
11 ENABLE_COVERAGE()
12endif (EFL_COVERAGE)
diff --git a/cmake/Modules/FindCGraph.cmake b/cmake/Modules/FindCGraph.cmake
new file mode 100644
index 0000000..200efe1
--- /dev/null
+++ b/cmake/Modules/FindCGraph.cmake
@@ -0,0 +1,41 @@
1# - Try to find GraphViz
2# Once done this will define
3# CGRAPH_FOUND - System has GraphViz
4# CGRAPH_INCLUDE_DIRS - The GraphViz include directories
5# CGRAPH_LIBRARIES - The libraries needed to use GraphViz
6# CGRAPH_LDFLAGS_OTHER - Other LDFLAGS needed te use GraphViz
7# CGRAPH_DEFINITIONS - Compiler switches required for using GraphViz
8
9find_package(PkgConfig)
10if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
11 # "QUIET" was introduced in 2.8.2
12 set(_QUIET QUIET)
13endif ()
14pkg_check_modules(PC_LIBCGRAPH ${_QUIET} libcgraph)
15
16set (CGRAPH_MIN_VERSION "2.35.0.0")
17if ("${PC_LIBCGRAPH_VERSION}" VERSION_LESS ${CGRAPH_MIN_VERSION})
18 MESSAGE(STATUS "libcgraph version required: ${CGRAPH_MIN_VERSION}. Current version: ${PC_LIBCGRAPH_VERSION}.")
19else()
20 SET(LIBCGRAPH_REQUIRED_VERSION 1)
21endif()
22
23if (LIBCGRAPH_REQUIRED_VERSION)
24 find_path(CGRAPH_INCLUDE_DIR cgraph.h
25 HINTS ${PC_LIBCGRAPH_INCLUDEDIR} ${PC_LIBCCGRAPH_INCLUDE_DIRS}
26 PATH_SUFFIXES cgraph )
27
28 find_library(CGRAPH_LIBRARY NAMES cgraph libcgraph
29 HINTS ${PC_LIBCGRAPH_LIBDIR} ${PC_LIBCGRAPH_LIBRARY_DIRS} )
30
31 set(CGRAPH_INCLUDE_DIRS ${CGRAPH_INCLUDE_DIR})
32 set(CGRAPH_LIBRARIES ${CGRAPH_LIBRARY} )
33
34 #include(FindPackageHandleStandardArgs)
35 # handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE
36 # if all listed variables are TRUE
37 find_package_handle_standard_args(cgraph DEFAULT_MSG
38 CGRAPH_LIBRARY)
39endif (LIBCGRAPH_REQUIRED_VERSION)
40
41mark_as_advanced(CGRAPH_INCLUDE_DIR CGRAPH_LIBRARY)
diff --git a/cmake/Modules/FindCheck.cmake b/cmake/Modules/FindCheck.cmake
new file mode 100644
index 0000000..13ed8e9
--- /dev/null
+++ b/cmake/Modules/FindCheck.cmake
@@ -0,0 +1,32 @@
1# - Try to find check
2# Once done this will define
3# CHECK_FOUND - System has check
4# CHECK_INCLUDE_DIRS - The check include directories
5# CHECK_LIBRARIES - The libraries needed to use check
6# CHECK_DEFINITIONS - Compiler switches required for using check
7
8find_package(PkgConfig)
9if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
10 # "QUIET" was introduced in 2.8.2
11 set(_QUIET QUIET)
12endif ()
13pkg_check_modules(PC_LIBCHECK ${_QUIET} check)
14set(CHECK_DEFINITIONS ${PC_LIBCHECK_CFLAGS_OTHER})
15
16find_path(CHECK_INCLUDE_DIR check.h
17 HINTS ${PC_LIBCHECK_INCLUDEDIR} ${PC_LIBCHECK_INCLUDE_DIRS}
18 PATH_SUFFIXES check )
19
20find_library(CHECK_LIBRARY NAMES check
21 HINTS ${PC_LIBCHECK_LIBDIR} ${PC_LIBCHECK_LIBRARY_DIRS} )
22
23set(CHECK_LIBRARIES ${CHECK_LIBRARY} )
24set(CHECK_INCLUDE_DIRS ${CHECK_INCLUDE_DIR} )
25
26include(FindPackageHandleStandardArgs)
27# handle the QUIETLY and REQUIRED arguments and set CHECK_FOUND to TRUE
28# if all listed variables are TRUE
29find_package_handle_standard_args(check DEFAULT_MSG
30 CHECK_LIBRARY CHECK_INCLUDE_DIR)
31
32mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARY )
diff --git a/cmake/Modules/FindFfi.cmake b/cmake/Modules/FindFfi.cmake
new file mode 100644
index 0000000..c9224d1
--- /dev/null
+++ b/cmake/Modules/FindFfi.cmake
@@ -0,0 +1,40 @@
1# - Try to find ffi
2# Once done this will define
3# FFI_FOUND - System has ffi
4# FFI_INCLUDE_DIRS - The ffi include directories
5# FFI_LIBRARIES - The libraries needed to use ffi
6# FFI_LDFLAGS_OTHER - Other LDFLAGS needed te use ffi.
7# FFI_DEFINITIONS - Compiler switches required for using ffi
8
9find_package(PkgConfig)
10if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
11 # "QUIET" was introduced in 2.8.2
12 set(_QUIET QUIET)
13endif ()
14pkg_check_modules(PC_LIBFFI ${_QUIET} libffi)
15#set(FFI_DEFINITIONS ${PC_LIBFFI_CFLAGS_OTHER})
16#set(FFI_LDFLAGS_OTHER ${PC_LIBFFI_LDFLAGS_OTHER})
17
18# before verison 2.8.11 variable CMAKE_LIBRARY_ARCHITECTURE wasn't automatically added to search path
19if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.11")
20 set(FIND_PATH_HINTS ${PC_LIBFFI_INCLUDEDIR}/${CMAKE_LIBRARY_ARCHITECTURE})
21endif ()
22
23find_path(FFI_INCLUDE_DIR ffi.h
24 HINTS ${PC_LIBFFI_INCLUDEDIR} ${PC_LIBFFI_INCLUDE_DIRS}
25 ${FIND_PATH_HINTS}
26 )
27
28find_library(FFI_LIBRARY NAMES ffi libffi
29 HINTS ${PC_LIBFFI_LIBDIR} ${PC_LIBFFI_LIBRARY_DIRS})
30
31set(FFI_INCLUDE_DIRS ${FFI_INCLUDE_DIR})
32set(FFI_LIBRARIES ${FFI_LIBRARY})
33
34#include(FindPackageHandleStandardArgs)
35# handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE
36# if all listed variables are TRUE
37find_package_handle_standard_args(ffi DEFAULT_MSG
38 FFI_LIBRARY)
39
40mark_as_advanced(FFI_INCLUDE_DIRS FFI_LIBRARY)
diff --git a/cmake/Modules/FindGvc.cmake b/cmake/Modules/FindGvc.cmake
new file mode 100644
index 0000000..5bcb911
--- /dev/null
+++ b/cmake/Modules/FindGvc.cmake
@@ -0,0 +1,41 @@
1# - Try to find GraphViz
2# Once done this will define
3# GVC_FOUND - System has GraphViz
4# GVC_INCLUDE_DIRS - The GraphViz include directories
5# GVC_LIBRARIES - The libraries needed to use GraphViz
6# GVC_LDFLAGS_OTHER - Other LDFLAGS needed te use GraphViz
7# GVC_DEFINITIONS - Compiler switches required for using GraphViz
8
9find_package(PkgConfig)
10if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1")
11 # "QUIET" was introduced in 2.8.2
12 set(_QUIET QUIET)
13endif ()
14
15pkg_check_modules(PC_LIBGVC ${_QUIET} libgvc)
16set (LIBGVC_MIN_VERSION "2.35.0.0")
17if ("${PC_LIBGVC_VERSION}" VERSION_LESS ${LIBGVC_MIN_VERSION})
18 MESSAGE(STATUS "libgvc version required: ${LIBGVC_MIN_VERSION}. Current version: ${PC_LIBGVC_VERSION}.")
19else()
20 SET(LIBGVC_REQUIRED_VERSION 1)
21endif()
22
23if (LIBGVC_REQUIRED_VERSION)
24 find_path(GVC_INCLUDE_DIR gvc.h
25 HINTS ${PC_LIBGVC_INCLUDEDIR} ${PC_LIBCGVC_INCLUDE_DIRS}
26 PATH_SUFFIXES gvc )
27
28 find_library(GVC_LIBRARY NAMES gvc libgvc
29 HINTS ${PC_LIBGVC_LIBDIR} ${PC_LIBGVC_LIBRARY_DIRS} )
30
31 set(GVC_INCLUDE_DIRS ${GVC_INCLUDE_DIR})
32 set(GVC_LIBRARIES ${GVC_LIBRARY} )
33
34 #include(FindPackageHandleStandardArgs)
35 # handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE
36 # if all listed variables are TRUE
37 find_package_handle_standard_args(gvc DEFAULT_MSG
38 GVC_LIBRARY)
39endif (LIBGVC_REQUIRED_VERSION)
40
41mark_as_advanced(GVC_INCLUDE_DIR GVC_LIBRARY)
diff --git a/src/lib/.eo_preload.c.swp b/src/lib/.eo_preload.c.swp
new file mode 100644
index 0000000..c20781d
--- /dev/null
+++ b/src/lib/.eo_preload.c.swp
Binary files differ
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
new file mode 100644
index 0000000..5b85955
--- /dev/null
+++ b/src/lib/CMakeLists.txt
@@ -0,0 +1,29 @@
1set(CMAKE_BUILD_TYPE Debug)
2
3LIST(APPEND EDBG_CC_SOURCES eo_preload.c)
4
5link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS})
6
7add_definitions(${EDBG_COMMON_DEFINITIONS})
8
9include_directories (${CMAKE_SOURCE_DIR}/src/lib)
10include_directories(${CMAKE_CURRENT_BINARY_DIR})
11include_directories(
12 ${EINA_INCLUDE_DIRS}
13 ${EOLIAN_INCLUDE_DIRS}
14 ${EVAS_INCLUDE_DIRS}
15 ${ELEMENTARY_INCLUDE_DIRS}
16 )
17
18#set(EOLIAN_INCLUDE_FLAG -I \"${EOLIAN_EO_DIR}/eo-1\" -I${CMAKE_CURRENT_SOURCE_DIR})
19
20add_library(edbg SHARED ${EDBG_CC_SOURCES})
21
22target_link_libraries(edbg
23 ${EINA_LIBRARIES}
24 ${EO_LIBRARIES}
25 ${EOLIAN_LIBRARIES}
26 ${EVAS_LIBRARIES}
27 ${ELEMENTARY_LIBRARIES}
28 )
29
diff --git a/src/lib/eo_preload.c b/src/lib/eo_preload.c
new file mode 100644
index 0000000..d51316e
--- /dev/null
+++ b/src/lib/eo_preload.c
@@ -0,0 +1,177 @@
1#define _GNU_SOURCE
2#include <dlfcn.h>
3
4#include <Eo.h>
5#include <Evas.h>
6#include <Elementary.h>
7
8#include <Eolian.h>
9
10static Eina_List *tracked = NULL;
11
12
13typedef struct
14{
15 int r, g, b, a;
16} Rect_Color;
17
18#define CYCLE_ARR(arr, idx) \
19 (idx)++; \
20 if ((idx) >= (sizeof(arr) / sizeof(arr)[0])) \
21 (idx) = 0; \
22 do {}while(0)
23
24int color_idx = 0;
25Rect_Color colors[] = {{255, 255, 0 , 128},
26 {255, 0 , 255, 128}};
27
28static void
29_init_colors()
30{
31 int i;
32 for (i = 0; i < (sizeof(colors) / sizeof(colors[0])); i++)
33 {
34 Rect_Color *c = &colors[i];
35 evas_color_argb_premul(c->a, &c->r, &c->g, &c->b);
36 }
37 /* Premuls the colors */
38}
39
40typedef struct
41{
42 EINA_INLIST;
43 Evas_Object *obj; /* Evas_Object (Rectangle) */
44} Debug_Rect;
45
46typedef struct
47{
48 EINA_INLIST;
49 Evas_Object *obj;
50 Debug_Rect *rects;
51} Debug_Decorate;
52
53static Debug_Decorate *g_decor = NULL;
54
55EAPI Eina_List *
56_evas_textblock_par_rects_get(Evas_Object *obj);
57
58static void
59_rects_populate(Debug_Decorate *dec)
60{
61 Eina_List *rects = _evas_textblock_par_rects_get(dec->obj);
62 Eina_Rectangle *rect;
63 Evas_Coord ox, oy;
64 evas_object_geometry_get(dec->obj, &ox, &oy, NULL, NULL);
65 EINA_LIST_FREE(rects, rect)
66 {
67 Debug_Rect *r = malloc(sizeof(Debug_Rect));
68 Rect_Color c = colors[color_idx];
69 CYCLE_ARR(colors, color_idx);
70
71 r->obj = evas_object_rectangle_add(dec->obj);
72 evas_object_pass_events_set(r->obj, EINA_TRUE);
73 evas_object_color_set(r->obj, c.r, c.g, c.b, c.a);
74 printf("Color set to (%d,%d,%d,%d)\n", c.r, c.g, c.b, c.a);
75 evas_object_resize(r->obj, rect->w, rect->h);
76 evas_object_move(r->obj, ox + rect->x, oy + rect->y);
77 dec->rects = (Debug_Rect *)eina_inlist_append(
78 EINA_INLIST_GET(dec->rects),
79 EINA_INLIST_GET(r));
80 evas_object_show(r->obj);
81
82 eina_rectangle_free(rect);
83 }
84}
85
86/* Clears debug rectangles for given obj */
87static void
88_clear_rects(Debug_Decorate *dec)
89{
90 Debug_Rect *rect;
91
92 EINA_INLIST_FREE(EINA_INLIST_GET(dec->rects), rect)
93 {
94 evas_object_del(rect->obj);
95 dec->rects = (Debug_Rect *) eina_inlist_remove(
96 EINA_INLIST_GET(dec->rects), EINA_INLIST_GET(rect));
97 free(rect);
98 }
99}
100
101static void
102_rects_update(Evas_Object *obj)
103{
104 /* Find if obj already has entry */
105 Debug_Decorate *dec;
106 EINA_INLIST_FOREACH(EINA_INLIST_GET(g_decor), dec)
107 {
108 if (dec->obj == obj)
109 break;
110 }
111 if (!dec)
112 {
113 dec = calloc(1, sizeof(Debug_Decorate));
114 dec->obj = obj;
115 g_decor = (Debug_Decorate *) eina_inlist_append(
116 EINA_INLIST_GET(g_decor),
117 EINA_INLIST_GET(dec));
118 }
119 else
120 {
121 _clear_rects(dec);
122 }
123 _rects_populate(dec);
124}
125
126static void
127_decorate_textblock(Evas_Object *obj)
128{
129 _rects_update(obj);
130}
131
132Eina_Bool
133_timer_cb(void *data)
134{
135 /* Iterate the list and decorate all tracked items */
136 Eina_List *i;
137 Evas_Object *obj; /* ATM all tracked objects are Evas_Objects */
138
139 EINA_LIST_FOREACH(tracked, i, obj)
140 {
141 if (eo_isa(obj, EVAS_TEXTBLOCK_CLASS))
142 _decorate_textblock(obj);
143 }
144
145 return EINA_TRUE;
146}
147
148static Eina_Bool
149_on_obj_del(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info)
150{
151 tracked = eina_list_remove(tracked, obj);
152 return EINA_TRUE;
153}
154
155EAPI Eo *
156_eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent_id, Eina_Bool ref)
157{
158 Eo *ret = NULL;
159 Eo *(*_eo_add_start)(const char *, int, const Eo_Class *, Eo *, Eina_Bool) = dlsym(RTLD_NEXT, __func__);
160
161 ret = _eo_add_start(file, line, klass_id, parent_id, ref);
162 if (eo_isa(ret, EVAS_TEXTBLOCK_CLASS))
163 {
164 tracked = eina_list_append(tracked, ret);
165 eo_do(ret, eo_event_callback_add(EVAS_OBJECT_EVENT_DEL, _on_obj_del, NULL));
166 }
167 return ret;
168}
169
170EAPI void
171elm_run()
172{
173 void (*f)() = dlsym(RTLD_NEXT, __func__);
174 _init_colors();
175 ecore_timer_add(0.1, _timer_cb, NULL);
176 f();
177}