summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2015-06-17 11:50:56 +0300
committerDaniel Hirt <daniel.hirt@samsung.com>2015-06-17 11:50:56 +0300
commite6535a074d24033ba6a74764fea4f451fafb5a53 (patch)
tree74806a695cb2599b2b7c095fb18c621149f2e20b
parent33891ccbf92ecb23f5cb070b04ac2f392ecb8ed5 (diff)
dot: add preliminary graph generation codeHEADmaster
Program now captures 'message_process' and 'emit' functions, and create nodes and edges. Still needs more work, but produces a .dot file which can be turned to .svg (see inline comments).
-rw-r--r--src/include/edje_private.h8
-rw-r--r--src/lib/edje_sniffer.c113
2 files changed, 111 insertions, 10 deletions
diff --git a/src/include/edje_private.h b/src/include/edje_private.h
index b9ddac8..94359c1 100644
--- a/src/include/edje_private.h
+++ b/src/include/edje_private.h
@@ -2260,9 +2260,9 @@ void _edje_program_end(Edje *ed, Edje_Running_Program *runp);
2260void _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc); 2260void _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc);
2261void _edje_programs_patterns_clean(Edje_Part_Collection *ed); 2261void _edje_programs_patterns_clean(Edje_Part_Collection *ed);
2262void _edje_programs_patterns_init(Edje_Part_Collection *ed); 2262void _edje_programs_patterns_init(Edje_Part_Collection *ed);
2263void _edje_emit(Edje *ed, const char *sig, const char *src); 2263EAPI void _edje_emit(Edje *ed, const char *sig, const char *src);
2264void _edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*free_func)(void *)); 2264EAPI void _edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*free_func)(void *));
2265void _edje_emit_handle(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop); 2265EAPI void _edje_emit_handle(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop);
2266void _edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp); 2266void _edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp);
2267 2267
2268const Edje_Signals_Sources_Patterns *_edje_signal_callback_patterns_ref(const Edje_Signal_Callback_Group *gp); 2268const Edje_Signals_Sources_Patterns *_edje_signal_callback_patterns_ref(const Edje_Signal_Callback_Group *gp);
@@ -2407,7 +2407,7 @@ void _edje_message_free (Edje_Message *em);
2407void _edje_message_propornot_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg, Eina_Bool prop); 2407void _edje_message_propornot_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg, Eina_Bool prop);
2408void _edje_util_message_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg); 2408void _edje_util_message_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg);
2409void _edje_message_parameters_push (Edje_Message *em); 2409void _edje_message_parameters_push (Edje_Message *em);
2410void _edje_message_process (Edje_Message *em); 2410EAPI void _edje_message_process (Edje_Message *em);
2411EAPI void _edje_message_queue_process (void); 2411EAPI void _edje_message_queue_process (void);
2412void _edje_message_queue_clear (void); 2412void _edje_message_queue_clear (void);
2413void _edje_message_del (Edje *ed); 2413void _edje_message_del (Edje *ed);
diff --git a/src/lib/edje_sniffer.c b/src/lib/edje_sniffer.c
index f18043c..544c2fd 100644
--- a/src/lib/edje_sniffer.c
+++ b/src/lib/edje_sniffer.c
@@ -1,9 +1,13 @@
1// usage after program end:
2// dot -Tsvg output.dot -o test.svg
3
1#define _GNU_SOURCE 4#define _GNU_SOURCE
2#include <dlfcn.h> 5#include <dlfcn.h>
3 6
4#define EFL_EO_API_SUPPORT 7#define EFL_EO_API_SUPPORT
5#include <Edje.h> 8#include <Edje.h>
6#include <Evas.h> 9#include <Evas.h>
10#include <Eina.h>
7#include "edje_private.h" 11#include "edje_private.h"
8 12
9#ifdef EAPI 13#ifdef EAPI
@@ -11,17 +15,97 @@
11#endif 15#endif
12#define EAPI __attribute__ ((visibility("default"))) 16#define EAPI __attribute__ ((visibility("default")))
13 17
18static FILE *_file = NULL;
19static const char *_path = "output.dot";
20static Eina_Bool _capturing = EINA_TRUE;
21
22static char _cur[256];
23
24static unsigned int timeslot = 0;
25
26static void
27_graph_init(FILE *f)
28{
29 fprintf(f, "digraph \"Output\" { \n\
30 fontname = \"Bitstream Vera Sans\" \n\
31 fontsize = 8 \n\
32 \n\
33 node [ \n\
34 fontname = \"Bitstream Vera Sans\"\n \
35 fontsize = 8\n \
36 shape = \"record\"\n \
37 ]\n \
38 \n\
39 edge [\n\
40 arrowtail = \"empty\" \n\
41 ]\n");
42}
43
44static void
45_graph_done(FILE *f)
46{
47 fprintf(f, "\n}\n");
48}
49
50static void
51_graph_edge_add(FILE *f, const char *n1, const char *n2)
52{
53 fprintf(f, "\"%s\" -> \"%s\"\n", n1, n2);
54}
55
56static void
57_graph_node_add(FILE *f, const char *n)
58{
59 fprintf(f, "\"%s\"\n", n);
60}
61
14EAPI void 62EAPI void
15_edje_message_queue_process(void) 63_edje_message_process(Edje_Message *em)
16{ 64{
17 static void (*_edje_foo)(void) = NULL; 65 static void (*_edje_foo)(Edje_Message *) = NULL;
66 const char *sig = ((Edje_Message_Signal *)em->msg)->sig;
67
18 if (!_edje_foo) _edje_foo = dlsym(RTLD_NEXT, __func__); 68 if (!_edje_foo) _edje_foo = dlsym(RTLD_NEXT, __func__);
19 static unsigned int timeslot = 0; 69
20 printf("Start timeslot %d\n", timeslot); 70 if (_capturing && !_file)
21 _edje_foo(); 71 {
22 printf("Finish timeslot %d\n", timeslot++); 72 if (!(_file = fopen(_path, "w")))
73 {
74 ERR("Error opening file\n");
75 _capturing = EINA_FALSE;
76 }
77 else
78 {
79 _graph_init(_file);
80 }
81 }
82
83 if (_capturing)
84 {
85 sprintf(_cur, "%s-%d", sig, timeslot);
86 _graph_node_add(_file, _cur);
87 }
88
89 _edje_foo(em);
90 timeslot++;
23} 91}
24 92
93EAPI void
94_edje_emit(Edje *ed, const char *sig, const char *src)
95{
96 static void (*_edje_emit_foo)(Edje *ed, const char *sig, const char *src) = NULL;
97 if (!_edje_emit_foo) _edje_emit_foo = dlsym(RTLD_NEXT, __func__);
98
99 if (_file)
100 {
101 char str[256];
102 sprintf(str, "%s-%d", sig, timeslot);
103 _graph_edge_add(_file, _cur, str);
104 }
105
106 _edje_emit_foo(ed, sig, src);
107
108}
25EAPI int 109EAPI int
26elm_init(int argc, char **argv) 110elm_init(int argc, char **argv)
27{ 111{
@@ -29,3 +113,20 @@ elm_init(int argc, char **argv)
29 int (*_elm_init)(int, char **) = dlsym(RTLD_NEXT, __func__); 113 int (*_elm_init)(int, char **) = dlsym(RTLD_NEXT, __func__);
30 return _elm_init(argc, argv); 114 return _elm_init(argc, argv);
31} 115}
116
117EAPI int
118elm_shutdown(int argc, char **argv)
119{
120 printf("Elm_Shutdown\n");
121 if (_file)
122 {
123 if (_file)
124 {
125 _graph_done(_file);
126 fclose(_file);
127 }
128 _capturing = EINA_FALSE;
129 }
130 int (*func)(int, char **) = dlsym(RTLD_NEXT, __func__);
131 return func(argc, argv);
132}