summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2015-08-16 16:51:15 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2015-08-16 16:51:15 +0300
commit0233ee38662228e0ef97c189c369137755791d55 (patch)
tree661e143bc2de6f64f8d37c8af556839fbb20a871
parent0aaf51c01effbc35b12230f1eca8ef12520e438e (diff)
Add invocation to efl functions
dlsym and libffi are used to achieve this.
-rw-r--r--src/lib/CMakeLists.txt1
-rw-r--r--src/lib/debug_eolian.c58
2 files changed, 54 insertions, 5 deletions
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 6079349..153f19a 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -36,5 +36,6 @@ target_link_libraries(edbg_common
36 ${EINA_LIBRARIES} 36 ${EINA_LIBRARIES}
37 ${EO_LIBRARIES} 37 ${EO_LIBRARIES}
38 ${EOLIAN_LIBRARIES} 38 ${EOLIAN_LIBRARIES}
39 -ldl
39 ) 40 )
40 41
diff --git a/src/lib/debug_eolian.c b/src/lib/debug_eolian.c
index 3dfa26f..174b3f0 100644
--- a/src/lib/debug_eolian.c
+++ b/src/lib/debug_eolian.c
@@ -1,3 +1,8 @@
1#define _GNU_SOURCE
2#include <ffi.h>
3#include <dlfcn.h>
4
5#include <Eo.h>
1#include <Eet.h> 6#include <Eet.h>
2#include <Eolian.h> 7#include <Eolian.h>
3 8
@@ -115,12 +120,55 @@ _eolian_req_handle(const void *buf, int size, void **buf_ret, int *size_ret)
115 const Eolian_Function *foo = debug_eolian_function_find_by_name(req->function_name, req->function_type); 120 const Eolian_Function *foo = debug_eolian_function_find_by_name(req->function_name, req->function_type);
116 if (foo) 121 if (foo)
117 { 122 {
118 Eina_List *list = NULL; 123 int argnum = 0, maxargs = 10;
124 Eina_List *pitr;
125 _Debug_Eolian_Parameter *param;
126
127 ffi_type **types = calloc (maxargs, sizeof(*types));
128 void **values = calloc(maxargs, sizeof(*values));
129 void **pointers = calloc(maxargs, sizeof(*pointers));
130
131 EINA_LIST_FOREACH(req->params, pitr, param)
132 {
133 if (param->type == EOLIAN_EXPR_INT) types[argnum] = &ffi_type_sint;
134 values[argnum++] = param->value.value;
135 }
136 if (req->function_type == EOLIAN_PROP_GET)
137 {
138 Eolian_Function_Parameter *eo_param;
139 Eina_Iterator *itr = eolian_property_values_get(foo, EOLIAN_PROP_GET);
140 EINA_ITERATOR_FOREACH(itr, eo_param)
141 {
142 const Eolian_Type *type = eolian_parameter_type_get(eo_param);
143 const char *type_str = eolian_type_c_type_get(type);
144 if (!strcmp(type_str, "int"))
145 {
146 param = (_Debug_Eolian_Parameter *)debug_eolian_param_int_new(0);
147 types[argnum] = &ffi_type_pointer;
148 pointers[argnum] = &(param->value.value);
149 values[argnum] = &pointers[argnum];
150 argnum++;
151 req->params = eina_list_append(req->params, param);
152 }
153 }
154 eina_iterator_free(itr);
155 }
119 printf("dlsym %s\n", eolian_function_full_c_name_get(foo, req->function_type, EINA_FALSE)); 156 printf("dlsym %s\n", eolian_function_full_c_name_get(foo, req->function_type, EINA_FALSE));
120 list = eina_list_append(list, debug_eolian_param_int_new(300)); 157 void *eo_func = dlsym(RTLD_DEFAULT, eolian_function_full_c_name_get(foo, req->function_type, EINA_FALSE));
121 list = eina_list_append(list, debug_eolian_param_int_new(400)); 158 if (_eo_do_start((Eo *)req->ptr, NULL, EINA_FALSE, __FILE__, __FUNCTION__, __LINE__))
122 req->params = list; 159 {
123 *buf_ret = eet_data_descriptor_encode(_foo_req_edd, req, size_ret); 160 ffi_cif cif;
161 if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, argnum, &ffi_type_uint, types) == FFI_OK)
162 {
163 unsigned int result;
164 ffi_call(&cif, eo_func, &result, values);
165 *buf_ret = eet_data_descriptor_encode(_foo_req_edd, req, size_ret);
166 }
167 _eo_do_end();
168 }
169 free(types);
170 free(values);
171 free(pointers);
124 } 172 }
125 return EINA_TRUE; 173 return EINA_TRUE;
126} 174}