summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2017-06-18 10:10:40 +0300
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2017-06-21 09:35:18 +0300
commitcdd91eb12c6fd5af918275f089769491d5c3d59d (patch)
tree59863e5cf5e414cfe8988f5a67137cde1947250e
parent07474f14b7022fe0caecfcbbfa9cdb61f7a768f3 (diff)
Show elements of lists
Elements of lists of Eo functions are now displayed. Iterators are converted to lists before packing.
-rw-r--r--src/lib/Clouseau_Debug.h4
-rw-r--r--src/lib/clouseau_debug.c191
-rw-r--r--src/lib/extensions/objects_introspection/main.c14
3 files changed, 163 insertions, 46 deletions
diff --git a/src/lib/Clouseau_Debug.h b/src/lib/Clouseau_Debug.h
index 1ee0e59..6d06613 100644
--- a/src/lib/Clouseau_Debug.h
+++ b/src/lib/Clouseau_Debug.h
@@ -1,5 +1,5 @@
1#ifndef _CLOUSEAU_DEBUG_H 1#ifndef _CLOUSEAU_DEBUG_H
2#define _CLOUSEAUEO_DEBUG_H 2#define _CLOUSEAU_DEBUG_H
3 3
4#ifdef EAPI 4#ifdef EAPI
5# undef EAPI 5# undef EAPI
@@ -48,6 +48,7 @@ typedef enum
48 EOLIAN_DEBUG_BOOLEAN, 48 EOLIAN_DEBUG_BOOLEAN,
49 EOLIAN_DEBUG_LONG, 49 EOLIAN_DEBUG_LONG,
50 EOLIAN_DEBUG_UINT, 50 EOLIAN_DEBUG_UINT,
51 EOLIAN_DEBUG_LIST,
51 EOLIAN_DEBUG_VOID 52 EOLIAN_DEBUG_VOID
52} Eolian_Debug_Basic_Type; 53} Eolian_Debug_Basic_Type;
53 54
@@ -58,6 +59,7 @@ typedef struct
58 { 59 {
59 uint64_t value; 60 uint64_t value;
60 } value; 61 } value;
62 Eina_List *complex_type_values;
61} Eolian_Debug_Value; 63} Eolian_Debug_Value;
62 64
63typedef struct 65typedef struct
diff --git a/src/lib/clouseau_debug.c b/src/lib/clouseau_debug.c
index 54e1cb9..4de553b 100644
--- a/src/lib/clouseau_debug.c
+++ b/src/lib/clouseau_debug.c
@@ -142,11 +142,8 @@ _eolian_type_resolve(const Eolian_Unit *unit, const Eolian_Type *eo_type)
142 Eolian_Type_Type type = eolian_type_type_get(eo_type); 142 Eolian_Type_Type type = eolian_type_type_get(eo_type);
143 Eolian_Type_Type type_base = type; 143 Eolian_Type_Type type_base = type;
144 144
145 if(type == EOLIAN_TYPE_COMPLEX) 145 if (type == EOLIAN_TYPE_COMPLEX || type == EOLIAN_TYPE_CLASS)
146 { 146 return EOLIAN_DEBUG_POINTER;
147 eo_type = eolian_type_base_type_get(eo_type);
148 type_base = eolian_type_type_get(eo_type);
149 }
150 147
151 if (type_base == EOLIAN_TYPE_REGULAR) 148 if (type_base == EOLIAN_TYPE_REGULAR)
152 { 149 {
@@ -168,9 +165,6 @@ _eolian_type_resolve(const Eolian_Unit *unit, const Eolian_Type *eo_type)
168 } 165 }
169 } 166 }
170 167
171 if (type == EOLIAN_TYPE_COMPLEX)
172 return EOLIAN_DEBUG_POINTER;
173
174 return EOLIAN_DEBUG_INVALID_TYPE; 168 return EOLIAN_DEBUG_INVALID_TYPE;
175 169
176} 170}
@@ -240,6 +234,7 @@ _function_invoke(Eo *ptr, const Eolian_Unit *unit, const Eolian_Function *foo, E
240 234
241 types[ffi_argc] = param_types[ed_type].ffi_type_p; 235 types[ffi_argc] = param_types[ed_type].ffi_type_p;
242 values[ffi_argc] = &(params[argc].value.value.value); 236 values[ffi_argc] = &(params[argc].value.value.value);
237 params[argc].eparam = eo_param;
243 ffi_argc++; 238 ffi_argc++;
244 argc++; 239 argc++;
245 } 240 }
@@ -250,6 +245,7 @@ _function_invoke(Eo *ptr, const Eolian_Unit *unit, const Eolian_Function *foo, E
250 { 245 {
251 ed_type = _eolian_type_resolve(unit, eolian_parameter_type_get(eo_param)); 246 ed_type = _eolian_type_resolve(unit, eolian_parameter_type_get(eo_param));
252 if (!ed_type) goto error; 247 if (!ed_type) goto error;
248 params[argc].eparam = eo_param;
253 249
254 if (foo_type == EOLIAN_PROP_GET || 250 if (foo_type == EOLIAN_PROP_GET ||
255 (foo_type == EOLIAN_METHOD && eolian_parameter_direction_get(eo_param) == EOLIAN_OUT_PARAM)) 251 (foo_type == EOLIAN_METHOD && eolian_parameter_direction_get(eo_param) == EOLIAN_OUT_PARAM))
@@ -306,6 +302,7 @@ _function_invoke(Eo *ptr, const Eolian_Unit *unit, const Eolian_Function *foo, E
306 { 302 {
307 ret->value.value.value = (uint64_t) result; 303 ret->value.value.value = (uint64_t) result;
308 ret->value.type = ed_type; 304 ret->value.type = ed_type;
305 ret->etype = eo_type;
309 } 306 }
310 } 307 }
311 else if (argc == 1 && foo_type == EOLIAN_PROP_GET) 308 else if (argc == 1 && foo_type == EOLIAN_PROP_GET)
@@ -383,6 +380,72 @@ end:
383 return found; 380 return found;
384} 381}
385 382
383static int
384_param_buffer_fill(char *buf, uint64_t v, int size)
385{
386 if (size == 8)
387 {
388 uint64_t value = SWAP_64(v);
389 memcpy(buf, &value, 8);
390 }
391 else if (size == 4)
392 {
393 int value = SWAP_32(v);
394 memcpy(buf, &value, 4);
395 }
396 else
397 {
398 memcpy(buf, &v, size);
399 }
400 return size;
401}
402
403static int
404_complex_buffer_fill(const Eolian_Unit *unit, char *buf, const Eolian_Type *eo_type, uint64_t value)
405{
406 Eina_List *l = NULL;
407 const char *eo_tname = eolian_type_name_get(eo_type);
408 void *data;
409 int size = 0, count = -1;
410 Eolian_Debug_Basic_Type type;
411 if (!strcmp(eo_tname, "iterator"))
412 {
413 Eina_Iterator *iter = (Eina_Iterator *)value;
414 EINA_ITERATOR_FOREACH(iter, data)
415 {
416 l = eina_list_append(l, data);
417 }
418 eina_iterator_free(iter);
419 }
420 else if (!strcmp(eo_tname, "list"))
421 {
422 Eina_List *int_l = (Eina_List *)value;
423 Eina_Stringshare *free_foo_str = eolian_type_free_func_get(eo_type);
424 l = eina_list_clone(int_l);
425 if (free_foo_str)
426 {
427 void (*func)(Eina_List *) = dlsym(RTLD_DEFAULT, free_foo_str);
428 if (func) func(int_l);
429 else
430 printf("Function %s not found", free_foo_str);
431 }
432 }
433
434 type = _eolian_type_resolve(unit, eolian_type_base_type_get(eo_type));
435
436 if (type != EOLIAN_DEBUG_INVALID_TYPE) count = SWAP_32(eina_list_count(l));
437
438 memcpy(buf + size, &count, 4);
439 size += 4;
440
441 EINA_LIST_FREE(l, data)
442 {
443 if (count == -1) continue;
444 size += _param_buffer_fill(buf+size, (uint64_t)data, param_types[type].size);
445 }
446 return size;
447}
448
386static unsigned int 449static unsigned int
387_class_buffer_fill(Eo *obj, const Eolian_Unit *unit, const Eolian_Class *ekl, char *buf) 450_class_buffer_fill(Eo *obj, const Eolian_Unit *unit, const Eolian_Class *ekl, char *buf)
388{ 451{
@@ -435,22 +498,14 @@ _class_buffer_fill(Eo *obj, const Eolian_Unit *unit, const Eolian_Class *ekl, ch
435 } 498 }
436 else 499 else
437 { 500 {
438 if (param_types[params[i].value.type].size == 8) 501 const Eolian_Type *eo_type = eolian_parameter_type_get(params[i].eparam);
439 { 502 size += _param_buffer_fill(buf+size, params[i].value.value.value,
440 uint64_t value = SWAP_64(params[i].value.value.value); 503 param_types[params[i].value.type].size);
441 memcpy(buf + size, &value, 8); 504 if (eolian_type_type_get(eo_type) == EOLIAN_TYPE_COMPLEX)
442 }
443 else if (param_types[params[i].value.type].size == 4)
444 { 505 {
445 int value = SWAP_32(params[i].value.value.value); 506 size += _complex_buffer_fill(unit, buf+size, eo_type,
446 memcpy(buf + size, &value, 4); 507 params[i].value.value.value);
447 } 508 }
448 else
449 {
450 memcpy(buf + size, &(params[i].value.value.value),
451 param_types[params[i].value.type].size);
452 }
453 size += param_types[params[i].value.type].size;
454 } 509 }
455 } 510 }
456 /* 511 /*
@@ -473,22 +528,13 @@ _class_buffer_fill(Eo *obj, const Eolian_Unit *unit, const Eolian_Class *ekl, ch
473 } 528 }
474 else 529 else
475 { 530 {
476 if (param_types[ret.value.type].size == 8) 531 size += _param_buffer_fill(buf+size, ret.value.value.value,
477 { 532 param_types[ret.value.type].size);
478 uint64_t value = SWAP_64(ret.value.value.value); 533 if (eolian_type_type_get(ret.etype) == EOLIAN_TYPE_COMPLEX)
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 { 534 {
488 memcpy(buf + size, &(ret.value.value.value), 535 size += _complex_buffer_fill(unit, buf+size,
489 param_types[ret.value.type].size); 536 ret.etype, ret.value.value.value);
490 } 537 }
491 size += param_types[ret.value.type].size;
492 } 538 }
493 } 539 }
494 540
@@ -948,6 +994,36 @@ eolian_debug_object_information_free(Eolian_Debug_Object_Information *main)
948 free(main); 994 free(main);
949} 995}
950 996
997static int
998_complex_buffer_decode(const Eolian_Unit *unit, char *buffer, const Eolian_Type *eo_type,
999 Eolian_Debug_Value *v)
1000{
1001 Eina_List *l = NULL;
1002 int size = 0, count;
1003 Eolian_Debug_Basic_Type type;
1004
1005 v->type = EOLIAN_DEBUG_LIST;
1006 memcpy(&count, buffer, 4);
1007 count = SWAP_32(count);
1008 buffer += 4;
1009 size += 4;
1010
1011 type = _eolian_type_resolve(unit, eolian_type_base_type_get(eo_type));
1012
1013 while (count > 0)
1014 {
1015 Eolian_Debug_Value *v2 = calloc(1, sizeof(*v2));
1016 v2->type = type;
1017 EXTRACT(buffer, &(v2->value), param_types[type].size);
1018 v2->value = SWAP_64(v2->value);
1019 size += param_types[type].size;
1020 l = eina_list_append(l, v2);
1021 count--;
1022 }
1023 v->complex_type_values = l;
1024 return size;
1025}
1026
951/* 1027/*
952 * receive buffer of the following format: 1028 * receive buffer of the following format:
953 * Eo *pointer (uint64_t) 1029 * Eo *pointer (uint64_t)
@@ -971,6 +1047,7 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
971 Eolian_Debug_Function *func; 1047 Eolian_Debug_Function *func;
972 Eolian_Function_Parameter *eo_param; 1048 Eolian_Function_Parameter *eo_param;
973 Eina_Iterator *itr; 1049 Eina_Iterator *itr;
1050 const Eolian_Type *eo_type;
974 int len = strlen(buffer) + 1; 1051 int len = strlen(buffer) + 1;
975 if (len > 1) // if class_name is not NULL, we begin a new class 1052 if (len > 1) // if class_name is not NULL, we begin a new class
976 { 1053 {
@@ -978,9 +1055,13 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
978 kl->ekl = _class_find_by_name(buffer, &(kl->unit)); 1055 kl->ekl = _class_find_by_name(buffer, &(kl->unit));
979 ret->classes = eina_list_append(ret->classes, kl); 1056 ret->classes = eina_list_append(ret->classes, kl);
980 } 1057 }
1058 if (!kl)
1059 {
1060 printf("Class %s not found!\n", buffer);
1061 goto error;
1062 }
981 buffer += len; 1063 buffer += len;
982 size -= len; 1064 size -= len;
983 if (!kl) goto error;
984 1065
985 func = calloc(1, sizeof(*func)); 1066 func = calloc(1, sizeof(*func));
986 printf("Class name = %s function = %s\n", eolian_class_name_get(kl->ekl), buffer); 1067 printf("Class name = %s function = %s\n", eolian_class_name_get(kl->ekl), buffer);
@@ -999,8 +1080,8 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
999 itr = eolian_property_values_get(func->efunc, EOLIAN_PROP_GET); 1080 itr = eolian_property_values_get(func->efunc, EOLIAN_PROP_GET);
1000 EINA_ITERATOR_FOREACH(itr, eo_param) 1081 EINA_ITERATOR_FOREACH(itr, eo_param)
1001 { 1082 {
1002 Eolian_Debug_Basic_Type type = _eolian_type_resolve(kl->unit, 1083 eo_type = eolian_parameter_type_get(eo_param);
1003 eolian_parameter_type_get(eo_param)); 1084 Eolian_Debug_Basic_Type type = _eolian_type_resolve(kl->unit, eo_type);
1004 1085
1005 if (type) 1086 if (type)
1006 { 1087 {
@@ -1016,20 +1097,30 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
1016 } 1097 }
1017 else 1098 else
1018 { 1099 {
1019 uint64_t value; 1100 uint64_t value = 0;;
1020 EXTRACT(buffer, &value, param_types[type].size); 1101 EXTRACT(buffer, &value, param_types[type].size);
1021 p->value.value.value = SWAP_64(value); 1102 p->value.value.value = SWAP_64(value);
1022 size -= param_types[type].size; 1103 size -= param_types[type].size;
1104 if (eolian_type_type_get(eo_type) == EOLIAN_TYPE_COMPLEX)
1105 {
1106 len = _complex_buffer_decode(kl->unit, buffer, eo_type, &(p->value));
1107 buffer += len;
1108 size -= len;
1109 }
1023 } 1110 }
1024 func->params = eina_list_append(func->params, p); 1111 func->params = eina_list_append(func->params, p);
1025 } 1112 }
1026 else goto error; 1113 else
1114 {
1115 printf("Unknown parameter type %s\n", eolian_type_full_name_get(eo_type));
1116 goto error;
1117 }
1027 } 1118 }
1028 func->ret.etype = eolian_function_return_type_get( 1119 func->ret.etype = eo_type = eolian_function_return_type_get(
1029 func->efunc, EOLIAN_PROP_GET); 1120 func->efunc, EOLIAN_PROP_GET);
1030 if(func->ret.etype) 1121 if(eo_type)
1031 { 1122 {
1032 Eolian_Debug_Basic_Type type = _eolian_type_resolve(kl->unit, func->ret.etype); 1123 Eolian_Debug_Basic_Type type = _eolian_type_resolve(kl->unit, eo_type);
1033 if (type) 1124 if (type)
1034 { 1125 {
1035 func->ret.value.type = type; 1126 func->ret.value.type = type;
@@ -1046,9 +1137,19 @@ eolian_debug_object_information_decode(char *buffer, unsigned int size)
1046 EXTRACT(buffer, &value, param_types[type].size); 1137 EXTRACT(buffer, &value, param_types[type].size);
1047 func->ret.value.value.value = SWAP_64(value); 1138 func->ret.value.value.value = SWAP_64(value);
1048 size -= param_types[type].size; 1139 size -= param_types[type].size;
1140 if (eolian_type_type_get(eo_type) == EOLIAN_TYPE_COMPLEX)
1141 {
1142 len = _complex_buffer_decode(kl->unit, buffer, eo_type, &(func->ret.value));
1143 buffer += len;
1144 size -= len;
1145 }
1049 } 1146 }
1050 } 1147 }
1051 else goto error; 1148 else
1149 {
1150 printf("Unknown parameter type %s\n", eolian_type_full_name_get(eo_type));
1151 goto error;
1152 }
1052 } 1153 }
1053 eina_iterator_free(itr); 1154 eina_iterator_free(itr);
1054 } 1155 }
diff --git a/src/lib/extensions/objects_introspection/main.c b/src/lib/extensions/objects_introspection/main.c
index 134b6d8..a35fac8 100644
--- a/src/lib/extensions/objects_introspection/main.c
+++ b/src/lib/extensions/objects_introspection/main.c
@@ -428,6 +428,20 @@ _eolian_value_to_string(Eolian_Debug_Value *value, char *buffer, int max)
428 (long)value->value.value); 428 (long)value->value.value);
429 case EOLIAN_DEBUG_UINT: return snprintf(buffer, max, "%u ", 429 case EOLIAN_DEBUG_UINT: return snprintf(buffer, max, "%u ",
430 (unsigned int)value->value.value); 430 (unsigned int)value->value.value);
431 case EOLIAN_DEBUG_LIST:
432 {
433 Eina_List *l = value->complex_type_values, *itr;
434 int len = 0;
435 len += snprintf(buffer+len, max-len, "%lX [", value->value.value);
436 EINA_LIST_FOREACH(l, itr, value)
437 {
438 len += snprintf(buffer+len, max-len, "%s%lX",
439 l != itr ? ", " : "",
440 value->value.value);
441 }
442 len += snprintf(buffer+len, max-len, "]");
443 return len;
444 }
431 default: return snprintf(buffer, max, "%lX ", value->value.value); 445 default: return snprintf(buffer, max, "%lX ", value->value.value);
432 } 446 }
433} 447}