summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2017-06-03 22:17:56 +0300
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2017-06-06 10:30:17 +0300
commitc982cb868584d05963c1c39fb86e121430adb4da (patch)
tree5ee64aea5f15f66aebb67a4a8a3d49e1ad7482aa
parent73a790e331e0c93bf63a473ae1e645d5420219f2 (diff)
Support endianness
-rw-r--r--src/bin/clouseau_client.c15
-rw-r--r--src/lib/clouseau_debug.c103
-rw-r--r--src/lib/extensions/evlog/main.c20
3 files changed, 111 insertions, 27 deletions
diff --git a/src/bin/clouseau_client.c b/src/bin/clouseau_client.c
index d20fbe3..aea24f5 100644
--- a/src/bin/clouseau_client.c
+++ b/src/bin/clouseau_client.c
@@ -16,6 +16,18 @@
16#include "gui.h" 16#include "gui.h"
17#include "Clouseau.h" 17#include "Clouseau.h"
18 18
19#if __BYTE_ORDER == __LITTLE_ENDIAN
20#define SWAP_64(x) x
21#define SWAP_32(x) x
22#define SWAP_16(x) x
23#define SWAP_DBL(x) x
24#else
25#define SWAP_64(x) eina_swap64(x)
26#define SWAP_32(x) eina_swap32(x)
27#define SWAP_16(x) eina_swap16(x)
28#define SWAP_DBL(x) SWAP_64(x)
29#endif
30
19#define EXTRACT(_buf, pval, sz) \ 31#define EXTRACT(_buf, pval, sz) \
20{ \ 32{ \
21 memcpy(pval, _buf, sz); \ 33 memcpy(pval, _buf, sz); \
@@ -385,6 +397,8 @@ _clients_info_added_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_UNU
385 int cid, pid, len; 397 int cid, pid, len;
386 EXTRACT(buf, &cid, sizeof(int)); 398 EXTRACT(buf, &cid, sizeof(int));
387 EXTRACT(buf, &pid, sizeof(int)); 399 EXTRACT(buf, &pid, sizeof(int));
400 cid = SWAP_32(cid);
401 pid = SWAP_32(pid);
388 if(pid != getpid()) 402 if(pid != getpid())
389 { 403 {
390 char name[100]; 404 char name[100];
@@ -412,6 +426,7 @@ _clients_info_deleted_cb(Eina_Debug_Session *session EINA_UNUSED, int src EINA_U
412 { 426 {
413 int cid; 427 int cid;
414 EXTRACT(buf, &cid, sizeof(int)); 428 EXTRACT(buf, &cid, sizeof(int));
429 cid = SWAP_32(cid);
415 if (_selected_app && cid == _selected_app->cid) _selected_app = NULL; 430 if (_selected_app && cid == _selected_app->cid) _selected_app = NULL;
416 _app_del(cid); 431 _app_del(cid);
417 } 432 }
diff --git a/src/lib/clouseau_debug.c b/src/lib/clouseau_debug.c
index e0d54ce..f1def96 100644
--- a/src/lib/clouseau_debug.c
+++ b/src/lib/clouseau_debug.c
@@ -39,6 +39,18 @@
39# endif 39# endif
40#endif /* ! _WIN32 */ 40#endif /* ! _WIN32 */
41 41
42#if __BYTE_ORDER == __LITTLE_ENDIAN
43#define SWAP_64(x) x
44#define SWAP_32(x) x
45#define SWAP_16(x) x
46#define SWAP_DBL(x) x
47#else
48#define SWAP_64(x) eina_swap64(x)
49#define SWAP_32(x) eina_swap32(x)
50#define SWAP_16(x) eina_swap16(x)
51#define SWAP_DBL(x) SWAP_64(x)
52#endif
53
42#define STORE(_buf, pval, sz) \ 54#define STORE(_buf, pval, sz) \
43{ \ 55{ \
44 memcpy(_buf, pval, sz); \ 56 memcpy(_buf, pval, sz); \
@@ -423,8 +435,21 @@ _class_buffer_fill(Eo *obj, const Eolian_Unit *unit, const Eolian_Class *ekl, ch
423 } 435 }
424 else 436 else
425 { 437 {
426 memcpy(buf + size, &(params[i].value.value.value), 438 if (param_types[params[i].value.type].size == 8)
427 param_types[params[i].value.type].size); 439 {
440 uint64_t value = SWAP_64(params[i].value.value.value);
441 memcpy(buf + size, &value, 8);
442 }
443 else if (param_types[params[i].value.type].size == 4)
444 {
445 int value = SWAP_32(params[i].value.value.value);
446 memcpy(buf + size, &value, 4);
447 }
448 else
449 {
450 memcpy(buf + size, &(params[i].value.value.value),
451 param_types[params[i].value.type].size);
452 }
428 size += param_types[params[i].value.type].size; 453 size += param_types[params[i].value.type].size;
429 } 454 }
430 } 455 }
@@ -448,8 +473,21 @@ _class_buffer_fill(Eo *obj, const Eolian_Unit *unit, const Eolian_Class *ekl, ch
448 } 473 }
449 else 474 else
450 { 475 {
451 memcpy(buf + size, &(ret.value.value.value), 476 if (param_types[ret.value.type].size == 8)
452 param_types[ret.value.type].size); 477 {
478 uint64_t value = SWAP_64(ret.value.value.value);
479 memcpy(buf + size, &value, 8);
480 }
481 else if (param_types[ret.value.type].size == 4)
482 {
483 int value = SWAP_32(ret.value.value.value);
484 memcpy(buf + size, &value, 4);
485 }
486 else
487 {
488 memcpy(buf + size, &(ret.value.value.value),
489 param_types[ret.value.type].size);
490 }
453 size += param_types[ret.value.type].size; 491 size += param_types[ret.value.type].size;
454 } 492 }
455 } 493 }
@@ -464,7 +502,7 @@ _obj_info_req_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size
464{ 502{
465 uint64_t ptr64; 503 uint64_t ptr64;
466 memcpy(&ptr64, buffer, sizeof(ptr64)); 504 memcpy(&ptr64, buffer, sizeof(ptr64));
467 Eo *obj = (Eo *)ptr64; 505 Eo *obj = (Eo *)SWAP_64(ptr64);
468 506
469 const char *class_name = efl_class_name_get(obj); 507 const char *class_name = efl_class_name_get(obj);
470 const Eolian_Unit *unit = NULL; 508 const Eolian_Unit *unit = NULL;
@@ -515,12 +553,12 @@ _snapshot_objs_get_req_cb(Eina_Debug_Session *session, int srcid, void *buffer,
515 Eo *obj; 553 Eo *obj;
516 Eina_List *objs = NULL; 554 Eina_List *objs = NULL;
517 uint64_t *kls = buffer; 555 uint64_t *kls = buffer;
518 int nb_kls = size / sizeof(uint64_t); 556 int nb_kls = size / sizeof(uint64_t), i;
519 557
558 for (i = 0; i < nb_kls; i++) kls[i] = SWAP_64(kls[i]);
520 iter = eo_objects_iterator_new(); 559 iter = eo_objects_iterator_new();
521 EINA_ITERATOR_FOREACH(iter, obj) 560 EINA_ITERATOR_FOREACH(iter, obj)
522 { 561 {
523 int i;
524 Eina_Bool klass_ok = EINA_FALSE; 562 Eina_Bool klass_ok = EINA_FALSE;
525 for (i = 0; i < nb_kls && !klass_ok; i++) 563 for (i = 0; i < nb_kls && !klass_ok; i++)
526 { 564 {
@@ -535,9 +573,9 @@ _snapshot_objs_get_req_cb(Eina_Debug_Session *session, int srcid, void *buffer,
535 EINA_LIST_FOREACH(objs, itr, obj) 573 EINA_LIST_FOREACH(objs, itr, obj)
536 { 574 {
537 Eo *parent; 575 Eo *parent;
538 uint64_t u64 = (uint64_t)obj; 576 uint64_t u64 = SWAP_64((uint64_t)obj);
539 STORE(tmp, &u64, sizeof(u64)); 577 STORE(tmp, &u64, sizeof(u64));
540 u64 = (uint64_t)efl_class_get(obj); 578 u64 = SWAP_64((uint64_t)efl_class_get(obj));
541 STORE(tmp, &u64, sizeof(u64)); 579 STORE(tmp, &u64, sizeof(u64));
542 parent = elm_object_parent_widget_get(obj); 580 parent = elm_object_parent_widget_get(obj);
543 if (!parent && efl_isa(obj, EFL_CANVAS_OBJECT_CLASS)) 581 if (!parent && efl_isa(obj, EFL_CANVAS_OBJECT_CLASS))
@@ -546,14 +584,14 @@ _snapshot_objs_get_req_cb(Eina_Debug_Session *session, int srcid, void *buffer,
546 if (!parent) parent = evas_object_smart_parent_get(obj); 584 if (!parent) parent = evas_object_smart_parent_get(obj);
547 } 585 }
548 if (!parent) parent = efl_parent_get(obj); 586 if (!parent) parent = efl_parent_get(obj);
549 u64 = (uint64_t)parent; 587 u64 = SWAP_64((uint64_t)parent);
550 STORE(tmp, &u64, sizeof(u64)); 588 STORE(tmp, &u64, sizeof(u64));
551 } 589 }
552 eina_debug_session_send(session, srcid, _eoids_get_op, buf, size); 590 eina_debug_session_send(session, srcid, _eoids_get_op, buf, size);
553 591
554 EINA_LIST_FREE(objs, obj) 592 EINA_LIST_FREE(objs, obj)
555 { 593 {
556 uint64_t u64 = (uint64_t)obj; 594 uint64_t u64 = SWAP_64((uint64_t)obj);
557 _obj_info_req_cb(session, srcid, &u64, sizeof(uint64_t)); 595 _obj_info_req_cb(session, srcid, &u64, sizeof(uint64_t));
558 } 596 }
559 return EINA_TRUE; 597 return EINA_TRUE;
@@ -593,7 +631,7 @@ _main_loop_snapshot_start_cb(Eina_Debug_Session *session, int srcid, void *buffe
593 Eina_List *itr; 631 Eina_List *itr;
594 const char *kl_name = efl_class_name_get(kl), *kl_str; 632 const char *kl_name = efl_class_name_get(kl), *kl_str;
595 int len = strlen(kl_name) + 1; 633 int len = strlen(kl_name) + 1;
596 uint64_t u64 = (uint64_t)kl; 634 uint64_t u64 = SWAP_64((uint64_t)kl);
597 Eina_Bool found = EINA_FALSE; 635 Eina_Bool found = EINA_FALSE;
598 636
599 /* Fill the buffer with class id/name */ 637 /* Fill the buffer with class id/name */
@@ -672,7 +710,7 @@ _main_loop_obj_highlight_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid E
672 uint64_t ptr64; 710 uint64_t ptr64;
673 if (size != sizeof(uint64_t)) return; 711 if (size != sizeof(uint64_t)) return;
674 memcpy(&ptr64, buffer, sizeof(ptr64)); 712 memcpy(&ptr64, buffer, sizeof(ptr64));
675 Eo *obj = (Eo *)ptr64; 713 Eo *obj = (Eo *)SWAP_64(ptr64);
676 if (!efl_isa(obj, EFL_CANVAS_OBJECT_CLASS) && !efl_isa(obj, EVAS_CANVAS_CLASS)) return; 714 if (!efl_isa(obj, EFL_CANVAS_OBJECT_CLASS) && !efl_isa(obj, EVAS_CANVAS_CLASS)) return;
677 Evas *e = evas_object_evas_get(obj); 715 Evas *e = evas_object_evas_get(obj);
678 Eo *rect = evas_object_polygon_add(e); 716 Eo *rect = evas_object_polygon_add(e);
@@ -723,12 +761,12 @@ _main_loop_win_screenshot_cb(Eina_Debug_Session *session, int srcid, void *buffe
723 unsigned char *img_src; 761 unsigned char *img_src;
724 unsigned char *resp = NULL, *tmp; 762 unsigned char *resp = NULL, *tmp;
725 int bpl = 0, rows = 0, bpp = 0; 763 int bpl = 0, rows = 0, bpp = 0;
726 int w, h; 764 int w, h, val;
727 unsigned int hdr_size = sizeof(uint64_t) + 5 * sizeof(int); 765 unsigned int hdr_size = sizeof(uint64_t) + 5 * sizeof(int);
728 766
729 if (size != sizeof(uint64_t)) return; 767 if (size != sizeof(uint64_t)) return;
730 memcpy(&ptr64, buffer, sizeof(ptr64)); 768 memcpy(&ptr64, buffer, sizeof(ptr64));
731 Eo *e = (Eo *)ptr64; 769 Eo *e = (Eo *)SWAP_64(ptr64);
732 if (!efl_isa(e, EVAS_CANVAS_CLASS)) goto end; 770 if (!efl_isa(e, EVAS_CANVAS_CLASS)) goto end;
733 771
734 ee = ecore_evas_ecore_evas_get(e); 772 ee = ecore_evas_ecore_evas_get(e);
@@ -753,12 +791,17 @@ _main_loop_win_screenshot_cb(Eina_Debug_Session *session, int srcid, void *buffe
753 ecore_x_image_get(img, win, 0, 0, 0, 0, w, h); 791 ecore_x_image_get(img, win, 0, 0, 0, 0, w, h);
754 img_src = ecore_x_image_data_get(img, &bpl, &rows, &bpp); 792 img_src = ecore_x_image_data_get(img, &bpl, &rows, &bpp);
755 resp = tmp = malloc(hdr_size + (w * h * sizeof(int))); 793 resp = tmp = malloc(hdr_size + (w * h * sizeof(int)));
794 t->tm_sec = SWAP_32(t->tm_sec);
795 t->tm_min = SWAP_32(t->tm_min);
796 t->tm_hour = SWAP_32(t->tm_hour);
756 STORE(tmp, &ptr64, sizeof(ptr64)); 797 STORE(tmp, &ptr64, sizeof(ptr64));
757 STORE(tmp, &t->tm_sec, sizeof(int)); 798 STORE(tmp, &t->tm_sec, sizeof(int));
758 STORE(tmp, &t->tm_min, sizeof(int)); 799 STORE(tmp, &t->tm_min, sizeof(int));
759 STORE(tmp, &t->tm_hour, sizeof(int)); 800 STORE(tmp, &t->tm_hour, sizeof(int));
760 STORE(tmp, &w, sizeof(int)); 801 val = SWAP_32(w);
761 STORE(tmp, &h, sizeof(int)); 802 STORE(tmp, &val, sizeof(int));
803 val = SWAP_32(h);
804 STORE(tmp, &val, sizeof(int));
762 if (!ecore_x_image_is_argb32_get(img)) 805 if (!ecore_x_image_is_argb32_get(img))
763 { /* Fill resp buffer with image convert */ 806 { /* Fill resp buffer with image convert */
764 ecore_x_image_to_argb_convert(img_src, bpp, bpl, att.colormap, att.visual, 807 ecore_x_image_to_argb_convert(img_src, bpp, bpl, att.colormap, att.visual,
@@ -837,6 +880,7 @@ eo_debug_eoids_request_prepare(int *size, ...)
837 buf = realloc(buf, max_kls * sizeof(uint64_t)); 880 buf = realloc(buf, max_kls * sizeof(uint64_t));
838 } 881 }
839 char *tmp = buf + (nb_kls-1) * sizeof(uint64_t); 882 char *tmp = buf + (nb_kls-1) * sizeof(uint64_t);
883 kl = SWAP_64(kl);
840 STORE(tmp, &kl, sizeof(uint64_t)); 884 STORE(tmp, &kl, sizeof(uint64_t));
841 kl = va_arg(list, uint64_t); 885 kl = va_arg(list, uint64_t);
842 } 886 }
@@ -857,7 +901,7 @@ eo_debug_eoids_extract(void *buffer, int size, Eo_Debug_Object_Extract_Cb cb, vo
857 EXTRACT(buf, &obj, sizeof(uint64_t)); 901 EXTRACT(buf, &obj, sizeof(uint64_t));
858 EXTRACT(buf, &kl, sizeof(uint64_t)); 902 EXTRACT(buf, &kl, sizeof(uint64_t));
859 EXTRACT(buf, &parent, sizeof(uint64_t)); 903 EXTRACT(buf, &parent, sizeof(uint64_t));
860 cb(data, obj, kl, parent); 904 cb(data, SWAP_64(obj), SWAP_64(kl), SWAP_64(parent));
861 size -= (3 * sizeof(uint64_t)); 905 size -= (3 * sizeof(uint64_t));
862 } 906 }
863} 907}
@@ -873,7 +917,7 @@ eo_debug_klids_extract(void *buffer, int size, Eo_Debug_Class_Extract_Cb cb, voi
873 char *name; 917 char *name;
874 EXTRACT(buf, &kl, sizeof(uint64_t)); 918 EXTRACT(buf, &kl, sizeof(uint64_t));
875 name = buf; 919 name = buf;
876 cb(data, kl, buf); 920 cb(data, SWAP_64(kl), buf);
877 buf += (strlen(name) + 1); 921 buf += (strlen(name) + 1);
878 size -= (strlen(name) + 1 + sizeof(uint64_t)); 922 size -= (strlen(name) + 1 + sizeof(uint64_t));
879 } 923 }
@@ -918,6 +962,7 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
918 962
919 //get the Eo* pointer 963 //get the Eo* pointer
920 EXTRACT(buffer, &(ret->obj), sizeof(uint64_t)); 964 EXTRACT(buffer, &(ret->obj), sizeof(uint64_t));
965 ret->obj = SWAP_64(ret->obj);
921 size -= sizeof(uint64_t); 966 size -= sizeof(uint64_t);
922 967
923 while (size > 0) 968 while (size > 0)
@@ -970,7 +1015,9 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
970 } 1015 }
971 else 1016 else
972 { 1017 {
973 EXTRACT(buffer, &(p->value.value), param_types[type].size); 1018 uint64_t value;
1019 EXTRACT(buffer, &value, param_types[type].size);
1020 p->value.value.value = SWAP_64(value);
974 size -= param_types[type].size; 1021 size -= param_types[type].size;
975 } 1022 }
976 func->params = eina_list_append(func->params, p); 1023 func->params = eina_list_append(func->params, p);
@@ -994,7 +1041,9 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
994 } 1041 }
995 else 1042 else
996 { 1043 {
997 EXTRACT(buffer, &(func->ret.value.value), param_types[type].size); 1044 uint64_t value;
1045 EXTRACT(buffer, &value, param_types[type].size);
1046 func->ret.value.value.value = SWAP_64(value);
998 size -= param_types[type].size; 1047 size -= param_types[type].size;
999 } 1048 }
1000 } 1049 }
@@ -1027,12 +1076,12 @@ evas_debug_screenshot_decode(char *buffer, unsigned int size)
1027 if (size != (w * h * sizeof(int))) return NULL; 1076 if (size != (w * h * sizeof(int))) return NULL;
1028 1077
1029 s = calloc(1, sizeof(*s)); 1078 s = calloc(1, sizeof(*s));
1030 s->obj = obj; 1079 s->obj = SWAP_64(obj);
1031 s->w = w; 1080 s->w = SWAP_32(w);
1032 s->h = h; 1081 s->h = SWAP_32(h);
1033 s->tm_sec = tm_sec; 1082 s->tm_sec = SWAP_32(tm_sec);
1034 s->tm_min = tm_min; 1083 s->tm_min = SWAP_32(tm_min);
1035 s->tm_hour = tm_hour; 1084 s->tm_hour = SWAP_32(tm_hour);
1036 s->img = malloc(size); 1085 s->img = malloc(size);
1037 s->img_size = size; 1086 s->img_size = size;
1038 memcpy(s->img, buffer, size); 1087 memcpy(s->img, buffer, size);
diff --git a/src/lib/extensions/evlog/main.c b/src/lib/extensions/evlog/main.c
index 3212cb1..265faba 100644
--- a/src/lib/extensions/evlog/main.c
+++ b/src/lib/extensions/evlog/main.c
@@ -8,6 +8,18 @@
8#define RES 500000.0 8#define RES 500000.0
9#define LEN 5.0 9#define LEN 5.0
10 10
11#if __BYTE_ORDER == __LITTLE_ENDIAN
12#define SWAP_64(x) x
13#define SWAP_32(x) x
14#define SWAP_16(x) x
15#define SWAP_DBL(x) x
16#else
17#define SWAP_64(x) eina_swap64(x)
18#define SWAP_32(x) eina_swap32(x)
19#define SWAP_16(x) eina_swap16(x)
20#define SWAP_DBL(x) SWAP_64(x)
21#endif
22
11typedef struct _Evlog Evlog; 23typedef struct _Evlog Evlog;
12typedef struct _Evlog_Thread Evlog_Thread; 24typedef struct _Evlog_Thread Evlog_Thread;
13typedef struct _Evlog_Event Evlog_Event; 25typedef struct _Evlog_Event Evlog_Event;
@@ -316,6 +328,14 @@ _evlog_event_read(Evlog *evlog, void *ptr, void *end)
316 328
317 memcpy(&item, data, sizeof(Eina_Evlog_Item)); 329 memcpy(&item, data, sizeof(Eina_Evlog_Item));
318 330
331 item.tim = SWAP_DBL(item.tim);
332 item.srctim = SWAP_DBL(item.srctim);
333 item.thread = SWAP_64(item.thread);
334 item.obj = SWAP_64(item.obj);
335 item.event_offset = SWAP_16(item.event_offset);
336 item.detail_offset = SWAP_16(item.detail_offset);
337 item.event_next = SWAP_16(item.event_next);
338
319 if (item.event_offset >= sizeof(Eina_Evlog_Item)) 339 if (item.event_offset >= sizeof(Eina_Evlog_Item))
320 eventstr = data + item.event_offset; 340 eventstr = data + item.event_offset;
321 if (item.detail_offset >= sizeof(Eina_Evlog_Item)) 341 if (item.detail_offset >= sizeof(Eina_Evlog_Item))