Adapt to EFL changes

This commit is contained in:
Daniel Zaoui 2017-05-30 14:24:49 +03:00
parent 8f52887d57
commit 0baf933727
4 changed files with 109 additions and 83 deletions

View File

@ -104,8 +104,8 @@ static Eina_List *_extensions = NULL;
static int _selected_port = -1;
static Eina_Debug_Error _clients_info_added_cb(Eina_Debug_Session *, int, void *, int);
static Eina_Debug_Error _clients_info_deleted_cb(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _clients_info_added_cb(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _clients_info_deleted_cb(Eina_Debug_Session *, int, void *, int);
static const Eina_Debug_Opcode _ops[] =
{
@ -378,7 +378,7 @@ _menu_selected_app(void *data,
EINA_LIST_FOREACH(_extensions, itr, ext) _app_populate();
}
static Eina_Debug_Error
static Eina_Bool
_clients_info_added_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED, void *buffer, int size)
{
char *buf = buffer;
@ -403,10 +403,10 @@ _clients_info_added_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNU
buf += len;
size -= (2 * sizeof(int) + len);
}
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static Eina_Debug_Error
static Eina_Bool
_clients_info_deleted_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED, void *buffer, int size)
{
char *buf = buffer;
@ -417,7 +417,7 @@ _clients_info_deleted_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_U
if (_selected_app && cid == _selected_app->cid) _selected_app = NULL;
_app_del(cid);
}
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static void
@ -429,21 +429,21 @@ _ecore_thread_dispatcher(void *data)
free(data);
}
Eina_Debug_Error
Eina_Bool
_disp_cb(Eina_Debug_Session *session, void *buffer)
{
Eina_Debug_Packet_Header *hdr = (Eina_Debug_Packet_Header *)buffer;
if (hdr->cid && (!_selected_app || _selected_app->cid != hdr->cid))
{
free(buffer);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
Dispatcher_Info *info = calloc(1, sizeof(*info));
info->session = session;
info->buffer = buffer;
ecore_main_loop_thread_safe_call_async(_ecore_thread_dispatcher, info);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static void

View File

@ -51,12 +51,36 @@
_buf += sz; \
}
#define WRAPPER_TO_XFER_MAIN_LOOP(foo) \
static void \
_intern_main_loop ## foo(void *data) \
{ \
Main_Loop_Info *info = data; \
_main_loop ## foo(info->session, info->srcid, info->buffer, info->size); \
free(info->buffer); \
free(info); \
} \
static Eina_Bool \
foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \
{ \
Main_Loop_Info *info = calloc(1, sizeof(*info)); \
info->session = session; \
info->srcid = srcid; \
info->size = size; \
if (info->size) \
{ \
info->buffer = malloc(info->size); \
memcpy(info->buffer, buffer, info->size); \
} \
ecore_main_loop_thread_safe_call_async(_intern_main_loop ## foo, info); \
return EINA_TRUE; \
}
static int _snapshot_start_op = EINA_DEBUG_OPCODE_INVALID;
static int _snapshot_done_op = EINA_DEBUG_OPCODE_INVALID;
static int _klids_get_op = EINA_DEBUG_OPCODE_INVALID;
static int _eoids_get_op = EINA_DEBUG_OPCODE_INVALID;
static int _obj_info_op = EINA_DEBUG_OPCODE_INVALID;
static int _snapshot_objs_get_op = EINA_DEBUG_OPCODE_INVALID;
static int _obj_highlight_op = EINA_DEBUG_OPCODE_INVALID;
static int _win_screenshot_op = EINA_DEBUG_OPCODE_INVALID;
@ -67,6 +91,14 @@ enum {
HIGHLIGHT_A = 255
};
typedef struct
{
Eina_Debug_Session *session;
int srcid;
void *buffer;
unsigned int size;
} Main_Loop_Info;
typedef struct
{
/* Buffer to fill with all the classes ids/names */
@ -497,7 +529,7 @@ _class_buffer_fill(Eo *obj, const Eolian_Class *ekl, char *buf)
return size;
}
static Eina_Debug_Error
static Eina_Bool
_obj_info_req_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size EINA_UNUSED)
{
uint64_t ptr64;
@ -540,10 +572,10 @@ _obj_info_req_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size
eina_debug_session_send(session, srcid, _obj_info_op, buf, size_curr);
end:
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static Eina_Debug_Error
static Eina_Bool
_snapshot_objs_get_req_cb(Eina_Debug_Session *session, int srcid, void *filters, int size)
{
static Eina_Bool (*foo)(Eo_Debug_Object_Iterator_Cb, void *) = NULL;
@ -551,7 +583,6 @@ _snapshot_objs_get_req_cb(Eina_Debug_Session *session, int srcid, void *filters,
Eo *obj;
Eina_List *itr;
_EoIds_Walk_Data data;
int thread_id = eina_debug_thread_id_get();
data.objs_to_fetch = NULL;
data.kls = filters;
@ -559,9 +590,8 @@ _snapshot_objs_get_req_cb(Eina_Debug_Session *session, int srcid, void *filters,
if (!foo) foo = dlsym(RTLD_DEFAULT, "eo_debug_objects_iterate");
foo(_eoids_walk_cb, &data);
size = sizeof(int) + eina_list_count(data.objs_to_fetch) * 3 * sizeof(uint64_t);
size = eina_list_count(data.objs_to_fetch) * 3 * sizeof(uint64_t);
buf = tmp = malloc(size);
STORE(tmp, &thread_id, sizeof(int));
EINA_LIST_FOREACH(data.objs_to_fetch, itr, obj)
{
Eo *parent;
@ -587,19 +617,17 @@ _snapshot_objs_get_req_cb(Eina_Debug_Session *session, int srcid, void *filters,
_obj_info_req_cb(session, srcid, &u64, sizeof(uint64_t));
}
eina_list_free(data.objs_to_fetch);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static Eina_Debug_Error
_snapshot_start_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size)
static void
_main_loop_snapshot_start_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size)
{
static Eina_Bool (*foo)(Eo_Debug_Class_Iterator_Cb, void *) = NULL;
char *buf = alloca(sizeof(Eina_Debug_Packet_Header) + size);
char *all_kls_buf = malloc(10000);
Eina_Debug_Packet_Header *hdr = (Eina_Debug_Packet_Header *)buf;
char *all_kls_buf;
char *tmp;
_KlIds_Walk_Data data;
data.kls_strs = NULL;
tmp = buffer;
while (size > 0)
@ -610,26 +638,27 @@ _snapshot_start_cb(Eina_Debug_Session *session, int srcid, void *buffer, int siz
}
data.nb_kls = eina_list_count(data.kls_strs);
size = data.nb_kls * sizeof(uint64_t);
data.kls = alloca(size);
memset(data.kls, 0, size);
data.current = all_kls_buf;
if (size)
{
data.kls = alloca(size);
memset(data.kls, 0, size);
}
else data.kls = NULL;
data.current = all_kls_buf = malloc(10000);
if (!foo) foo = dlsym(RTLD_DEFAULT, "eo_debug_classes_iterate");
foo(_klids_walk_cb, &data);
eina_debug_session_send(session, srcid, _klids_get_op, all_kls_buf, data.current - all_kls_buf);
eina_debug_session_send(session, srcid,
_klids_get_op, all_kls_buf, data.current - all_kls_buf);
free(all_kls_buf);
hdr->size = sizeof(Eina_Debug_Packet_Header) + size;
hdr->cid = srcid;
if (size) memcpy(buf + sizeof(Eina_Debug_Packet_Header), data.kls, size);
hdr->thread_id = 0xFFFFFFFF;
hdr->opcode = _snapshot_objs_get_op;
eina_debug_dispatch(session, buf);
_snapshot_objs_get_req_cb(session, srcid, data.kls, size);
eina_debug_session_send(session, srcid, _snapshot_done_op, NULL, 0);
return EINA_DEBUG_OK;
}
WRAPPER_TO_XFER_MAIN_LOOP(_snapshot_start_cb)
/* Highlight functions. */
static Eina_Bool
_obj_highlight_fade(void *_rect)
@ -664,14 +693,14 @@ _obj_highlight_del(void *data,
ecore_animator_del(data);
}
static Eina_Debug_Error
_obj_highlight_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size)
static void
_main_loop_obj_highlight_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size)
{
if (size <= 0) return EINA_DEBUG_ERROR;
uint64_t ptr64;
if (size != sizeof(uint64_t)) return;
memcpy(&ptr64, buffer, sizeof(ptr64));
Eo *obj = (Eo *)ptr64;
if (!efl_isa(obj, EFL_CANVAS_OBJECT_CLASS) && !efl_isa(obj, EVAS_CANVAS_CLASS)) return EINA_DEBUG_OK;
if (!efl_isa(obj, EFL_CANVAS_OBJECT_CLASS) && !efl_isa(obj, EVAS_CANVAS_CLASS)) return;
Evas *e = evas_object_evas_get(obj);
Eo *rect = evas_object_polygon_add(e);
evas_object_move(rect, 0, 0);
@ -705,11 +734,12 @@ _obj_highlight_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED
/* Add Timer for fade and a callback to delete timer on obj del */
Ecore_Animator *t = ecore_animator_add(_obj_highlight_fade, rect);
evas_object_event_callback_add(rect, EVAS_CALLBACK_DEL, _obj_highlight_del, t);
return EINA_DEBUG_OK;
}
static Eina_Debug_Error
_win_screenshot_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size)
WRAPPER_TO_XFER_MAIN_LOOP(_obj_highlight_cb)
static void
_main_loop_win_screenshot_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size)
{
struct tm *t = NULL;
time_t now = time(NULL);
@ -723,7 +753,7 @@ _win_screenshot_cb(Eina_Debug_Session *session, int srcid, void *buffer, int siz
int w, h;
unsigned int hdr_size = sizeof(uint64_t) + 5 * sizeof(int);
if (size <= 0) return EINA_DEBUG_ERROR;
if (size != sizeof(uint64_t)) return;
memcpy(&ptr64, buffer, sizeof(ptr64));
Eo *e = (Eo *)ptr64;
if (!efl_isa(e, EVAS_CANVAS_CLASS)) goto end;
@ -775,13 +805,13 @@ _win_screenshot_cb(Eina_Debug_Session *session, int srcid, void *buffer, int siz
end:
if (resp) free(resp);
return EINA_DEBUG_OK;
}
WRAPPER_TO_XFER_MAIN_LOOP(_win_screenshot_cb)
static const Eina_Debug_Opcode _debug_ops[] =
{
{"Clouseau/Snapshot/start", &_snapshot_start_op, &_snapshot_start_cb},
{"Clouseau/Snapshot/fetch_all_objects", &_snapshot_objs_get_op, &_snapshot_objs_get_req_cb},
{"Clouseau/Snapshot/done", &_snapshot_done_op, NULL},
{"Eo/classes_ids_get", &_klids_get_op, NULL},
{"Eo/objects_ids_get", &_eoids_get_op, NULL},
@ -842,12 +872,10 @@ eo_debug_eoids_request_prepare(int *size, ...)
}
EAPI void
eo_debug_eoids_extract(void *buffer, int size, Eo_Debug_Object_Extract_Cb cb, void *data, int *thread_id)
eo_debug_eoids_extract(void *buffer, int size, Eo_Debug_Object_Extract_Cb cb, void *data)
{
if (!buffer || !size || !cb) return;
char *buf = buffer;
EXTRACT(buf, thread_id, sizeof(int));
size -= sizeof(int);
while (size > 0)
{

View File

@ -110,7 +110,7 @@ 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_Debug_Error _record_get_cb(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _record_get_cb(Eina_Debug_Session *, int, void *, int);
static const Eina_Debug_Opcode _ops[] = {
{"cpufreq/on", &_record_on_op, NULL},
@ -1397,12 +1397,12 @@ _evlog_import(Clouseau_Extension *ext, void *buffer, int size, int version EINA_
else _fill_log_table(inf);
}
static Eina_Debug_Error
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);
_evlog_import(ext, buffer, size, -1);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static Eina_Bool

View File

@ -8,6 +8,12 @@
#define _EET_ENTRY "config"
#define STORE(_buf, pval, sz) \
{ \
memcpy(_buf, pval, sz); \
_buf += sz; \
}
static int _eoids_get_op = EINA_DEBUG_OPCODE_INVALID;
static int _klids_get_op = EINA_DEBUG_OPCODE_INVALID;
static int _obj_info_op = EINA_DEBUG_OPCODE_INVALID;
@ -27,7 +33,6 @@ typedef struct
uint64_t obj;
uint64_t parent;
uint64_t kl_id;
int thread_id;
Eina_List *children;
Eina_List *screenshots;
Eo *glitem;
@ -80,11 +85,11 @@ static Elm_Genlist_Item_Class *_obj_func_info_itc = NULL;
static Evas_Object * _obj_info_tootip(void *, Evas_Object *, Evas_Object *, void *);
static Eina_Debug_Error _eoids_get(Eina_Debug_Session *, int, void *, int);
static Eina_Debug_Error _klids_get(Eina_Debug_Session *, int, void *, int);
static Eina_Debug_Error _obj_info_get(Eina_Debug_Session *, int, void *, int);
static Eina_Debug_Error _snapshot_done_cb(Eina_Debug_Session *, int, void *, int);
static Eina_Debug_Error _win_screenshot_get(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _eoids_get(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _klids_get(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _obj_info_get(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _snapshot_done_cb(Eina_Debug_Session *, int, void *, int);
static Eina_Bool _win_screenshot_get(Eina_Debug_Session *, int, void *, int);
static const Eina_Debug_Opcode _ops[] =
{
@ -231,11 +236,11 @@ _snapshot_buffer_append(Snapshot_Buffer *sb, void *buffer)
sb->cur_len += size;
}
Eina_Debug_Error
Eina_Bool
_disp_cb(Eina_Debug_Session *session, void *buffer)
{
Clouseau_Extension *ext = eina_debug_session_data_get(session);
if (!ext) return EINA_DEBUG_OK;
if (!ext) return EINA_TRUE;
Instance *inst = ext->data;
if (inst)
{
@ -529,7 +534,7 @@ _obj_info_realize(Clouseau_Extension *ext, Eolian_Debug_Object_Information *e_in
}
}
static Eina_Debug_Error
static Eina_Bool
_obj_info_get(Eina_Debug_Session *session, int src, void *buffer, int size)
{
Clouseau_Extension *ext = NULL;
@ -547,7 +552,7 @@ _obj_info_get(Eina_Debug_Session *session, int src, void *buffer, int size)
Eolian_Debug_Object_Information *e_info =
eolian_debug_object_information_decode(buffer, size);
Obj_Info *o_info = eina_hash_find(inst->objs_hash, &(e_info->obj));
if (!o_info) return EINA_DEBUG_OK;
if (!o_info) return EINA_TRUE;
if (o_info->eolian_info)
eolian_debug_object_information_free(o_info->eolian_info);
@ -555,7 +560,7 @@ _obj_info_get(Eina_Debug_Session *session, int src, void *buffer, int size)
if (o_info == inst->selected_obj) _obj_info_realize(ext, e_info);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static void
@ -587,7 +592,7 @@ _objs_sel_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
elm_genlist_clear(inst->wdgs->object_infos_list);
if (_config->highlight)
{
eina_debug_session_send_to_thread(ext->session, ext->app_id, info->thread_id,
eina_debug_session_send(ext->session, ext->app_id,
_obj_highlight_op, &(info->obj), sizeof(uint64_t));
}
if (info->eolian_info) _obj_info_realize(ext, info->eolian_info);
@ -632,7 +637,7 @@ _objs_item_label_get(void *data, Evas_Object *obj,
return strdup(buf);
}
static Eina_Debug_Error
static Eina_Bool
_win_screenshot_get(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED,
void *buffer, int size)
{
@ -649,13 +654,13 @@ _win_screenshot_get(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNUSED
}
inst = ext->data;
Evas_Debug_Screenshot *s = evas_debug_screenshot_decode(buffer, size);
if (!s) return EINA_DEBUG_ERROR;
if (!s) return EINA_FALSE;
Obj_Info *info = eina_hash_find(inst->objs_hash, &(s->obj));
if (!info) return EINA_DEBUG_OK;
if (!info) return EINA_TRUE;
info->screenshots = eina_list_append(info->screenshots, s);
inst->screenshots = eina_list_append(inst->screenshots, s);
if (info->glitem) elm_genlist_item_update(info->glitem);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
void
@ -663,9 +668,10 @@ take_screenshot_button_clicked(void *data EINA_UNUSED, const Efl_Event *event)
{
Obj_Info *info = efl_key_data_get(event->object, "__info_node");
Clouseau_Extension *ext = _ext_get(event->object);
if (!ext || !ext->app_id) return;
eina_debug_session_send_to_thread(ext->session, ext->app_id, info->thread_id,
eina_debug_session_send(ext->session, ext->app_id,
_win_screenshot_op, &(info->obj), sizeof(uint64_t));
}
@ -732,13 +738,13 @@ show_screenshot_button_clicked(void *data EINA_UNUSED, const Efl_Event *event)
}
}
static Eina_Debug_Error
static Eina_Bool
_snapshot_done_cb(Eina_Debug_Session *session, int src EINA_UNUSED,
void *buffer EINA_UNUSED, int size EINA_UNUSED)
{
Clouseau_Extension *ext = eina_debug_session_data_get(session);
ext->ui_freeze_cb(ext, EINA_FALSE);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static void *
@ -751,11 +757,6 @@ _snapshot_save(Clouseau_Extension *ext, int *size, int *version)
s->obj_infos_buf.cur_len + s->screenshots_buf.cur_len);
char *tmp = buffer;
#define STORE(_buf, pval, sz) \
{ \
memcpy(_buf, pval, sz); \
_buf += sz; \
}
STORE(tmp, &_klids_get_op, sizeof(int));
STORE(tmp, &_eoids_get_op, sizeof(int));
STORE(tmp, &_obj_info_op, sizeof(int));
@ -764,7 +765,6 @@ _snapshot_save(Clouseau_Extension *ext, int *size, int *version)
STORE(tmp, s->eoids_buf.buffer, s->eoids_buf.cur_len);
STORE(tmp, s->obj_infos_buf.buffer, s->obj_infos_buf.cur_len);
STORE(tmp, s->screenshots_buf.buffer, s->screenshots_buf.cur_len);
#undef STORE
*version = 1;
*size = tmp - (char *)buffer;
@ -853,7 +853,7 @@ _klid_walk(void *data, uint64_t kl, char *name)
eina_hash_add(inst->classes_hash_by_name, info->name, info);
}
static Eina_Debug_Error
static Eina_Bool
_klids_get(Eina_Debug_Session *session, int src, void *buffer, int size)
{
Clouseau_Extension *ext = NULL;
@ -870,7 +870,7 @@ _klids_get(Eina_Debug_Session *session, int src, void *buffer, int size)
inst = ext->data;
eo_debug_klids_extract(buffer, size, _klid_walk, inst);
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static void
@ -884,14 +884,13 @@ _eoid_walk(void *data, uint64_t obj, uint64_t kl_id, uint64_t parent)
*objs = eina_list_append(*objs, info);
}
static Eina_Debug_Error
static Eina_Bool
_eoids_get(Eina_Debug_Session *session, int src, void *buffer, int size)
{
Eina_List *objs = NULL, *l;
Clouseau_Extension *ext = NULL;
Instance *inst = NULL;
Obj_Info *info;
int thread_id;
if (src == -1)
{
ext = (Clouseau_Extension *)session;
@ -903,11 +902,10 @@ _eoids_get(Eina_Debug_Session *session, int src, void *buffer, int size)
}
inst = ext->data;
eo_debug_eoids_extract(buffer, size, _eoid_walk, &objs, &thread_id);
eo_debug_eoids_extract(buffer, size, _eoid_walk, &objs);
EINA_LIST_FOREACH(objs, l, info)
{
info->thread_id = thread_id;
eina_hash_add(inst->objs_hash, &(info->obj), info);
}
@ -937,7 +935,7 @@ _eoids_get(Eina_Debug_Session *session, int src, void *buffer, int size)
}
}
return EINA_DEBUG_OK;
return EINA_TRUE;
}
static void