summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2017-06-02 12:13:31 +0300
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2017-06-05 08:55:38 +0300
commit758bb0557c45353a8afffebb69d93f969e1ea4b6 (patch)
tree2d6e501bb541318d75487996cbdd9ee314ae807e
parentab01f3f696d8fe40d319c2d0e9867634d7c87d7b (diff)
Support opcodes registration for Windows
A standard static array with symbols whose addresses are only known at runtime is not supported in Windows.
-rw-r--r--src/bin/efl/efl_debug.c27
-rw-r--r--src/lib/eina/eina_debug.h19
-rw-r--r--src/lib/eina/eina_debug_bt.c13
-rw-r--r--src/lib/eina/eina_debug_cpu.c13
-rw-r--r--src/lib/eina/eina_evlog.c15
5 files changed, 51 insertions, 36 deletions
diff --git a/src/bin/efl/efl_debug.c b/src/bin/efl/efl_debug.c
index be96b04d8d..1ebe8c8564 100644
--- a/src/bin/efl/efl_debug.c
+++ b/src/bin/efl/efl_debug.c
@@ -225,19 +225,18 @@ _args_handle(void *data EINA_UNUSED, Eina_Bool flag)
225 } 225 }
226} 226}
227 227
228static const Eina_Debug_Opcode ops[] = 228EINA_DEBUG_OPCODES_ARRAY_DEFINE(ops,
229{ 229 {"Daemon/Client/register_observer", &_cl_stat_reg_opcode, NULL},
230 {"Daemon/Client/register_observer", &_cl_stat_reg_opcode, NULL}, 230 {"Daemon/Client/added", NULL, &_clients_info_added_cb},
231 {"Daemon/Client/added", NULL, &_clients_info_added_cb}, 231 {"Daemon/Client/deleted", NULL, &_clients_info_deleted_cb},
232 {"Daemon/Client/deleted", NULL, &_clients_info_deleted_cb}, 232 {"Daemon/Client/cid_from_pid", &_cid_from_pid_opcode, &_cid_get_cb},
233 {"Daemon/Client/cid_from_pid", &_cid_from_pid_opcode, &_cid_get_cb}, 233 {"Profiler/on", &_prof_on_opcode, NULL},
234 {"Profiler/on", &_prof_on_opcode, NULL}, 234 {"Profiler/off", &_prof_off_opcode, NULL},
235 {"Profiler/off", &_prof_off_opcode, NULL}, 235 {"CPU/Freq/on", &_cpufreq_on_opcode, NULL},
236 {"CPU/Freq/on", &_cpufreq_on_opcode, NULL}, 236 {"CPU/Freq/off", &_cpufreq_off_opcode, NULL},
237 {"CPU/Freq/off", &_cpufreq_off_opcode, NULL}, 237 {"EvLog/get", &_evlog_get_opcode, _evlog_get_cb},
238 {"EvLog/get", &_evlog_get_opcode, _evlog_get_cb}, 238 {NULL, NULL, NULL}
239 {NULL, NULL, NULL} 239);
240};
241 240
242int 241int
243main(int argc EINA_UNUSED, char **argv EINA_UNUSED) 242main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
@@ -254,7 +253,7 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
254 fprintf(stderr, "ERROR: Cannot connect to debug daemon.\n"); 253 fprintf(stderr, "ERROR: Cannot connect to debug daemon.\n");
255 return -1; 254 return -1;
256 } 255 }
257 eina_debug_opcodes_register(_session, ops, _args_handle, NULL); 256 eina_debug_opcodes_register(_session, ops(), _args_handle, NULL);
258 257
259 ecore_main_loop_begin(); 258 ecore_main_loop_begin();
260 259
diff --git a/src/lib/eina/eina_debug.h b/src/lib/eina/eina_debug.h
index 6f7eee1207..8fb797d7b4 100644
--- a/src/lib/eina/eina_debug.h
+++ b/src/lib/eina/eina_debug.h
@@ -122,6 +122,25 @@ typedef struct
122} Eina_Debug_Packet_Header; 122} Eina_Debug_Packet_Header;
123 123
124/** 124/**
125 * Helper for creating global opcodes arrays.
126 * The problem is on windows where you can't declare a static array with
127 * external symbols in it, because the addresses are only known at runtime.
128 */
129#define EINA_DEBUG_OPCODES_ARRAY_DEFINE(Name, ...) \
130 static Eina_Debug_Opcode * \
131 Name(void) \
132 { \
133 Eina_Debug_Opcode tmp[] = { __VA_ARGS__ }; \
134 static Eina_Debug_Opcode internal[EINA_C_ARRAY_LENGTH(tmp) + 1] = \
135 { { 0, 0, 0 } }; \
136 if (internal[0].opcode_name == NULL) \
137 { \
138 memcpy(internal, tmp, sizeof(tmp)); \
139 } \
140 return internal; \
141 }
142
143/**
125 * @typedef Eina_Debug_Opcode 144 * @typedef Eina_Debug_Opcode
126 * 145 *
127 * Structure to describe information for an opcode. It is used to register new 146 * Structure to describe information for an opcode. It is used to register new
diff --git a/src/lib/eina/eina_debug_bt.c b/src/lib/eina/eina_debug_bt.c
index 157fe545d4..69fe6b4034 100644
--- a/src/lib/eina/eina_debug_bt.c
+++ b/src/lib/eina/eina_debug_bt.c
@@ -256,19 +256,18 @@ _prof_off_cb(Eina_Debug_Session *session EINA_UNUSED, int cid EINA_UNUSED, void
256 return EINA_TRUE; 256 return EINA_TRUE;
257} 257}
258 258
259static const Eina_Debug_Opcode _OPS[] = 259EINA_DEBUG_OPCODES_ARRAY_DEFINE(_OPS,
260{ 260 {"Profiler/on", NULL, &_prof_on_cb},
261 {"Profiler/on", NULL, &_prof_on_cb}, 261 {"Profiler/off", NULL, &_prof_off_cb},
262 {"Profiler/off", NULL, &_prof_off_cb}, 262 {NULL, NULL, NULL}
263 {NULL, NULL, NULL} 263);
264};
265 264
266Eina_Bool 265Eina_Bool
267_eina_debug_bt_init(void) 266_eina_debug_bt_init(void)
268{ 267{
269 _signal_init(); 268 _signal_init();
270 eina_semaphore_new(&_wait_for_bts_sem, 0); 269 eina_semaphore_new(&_wait_for_bts_sem, 0);
271 eina_debug_opcodes_register(NULL, _OPS, NULL, NULL); 270 eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL);
272 return EINA_TRUE; 271 return EINA_TRUE;
273} 272}
274 273
diff --git a/src/lib/eina/eina_debug_cpu.c b/src/lib/eina/eina_debug_cpu.c
index 505bed0ae3..060bde3b2e 100644
--- a/src/lib/eina/eina_debug_cpu.c
+++ b/src/lib/eina/eina_debug_cpu.c
@@ -272,12 +272,11 @@ _cpufreq_off_cb(Eina_Debug_Session *session EINA_UNUSED, int cid EINA_UNUSED, vo
272 return EINA_TRUE; 272 return EINA_TRUE;
273} 273}
274 274
275static const Eina_Debug_Opcode _OPS[] = 275EINA_DEBUG_OPCODES_ARRAY_DEFINE(_OPS,
276{ 276 {"CPU/Freq/on", NULL, &_cpufreq_on_cb},
277 {"CPU/Freq/on", NULL, &_cpufreq_on_cb}, 277 {"CPU/Freq/off", NULL, &_cpufreq_off_cb},
278 {"CPU/Freq/off", NULL, &_cpufreq_off_cb}, 278 {NULL, NULL, NULL}
279 {NULL, NULL, NULL} 279);
280};
281 280
282Eina_Bool 281Eina_Bool
283_eina_debug_cpu_init(void) 282_eina_debug_cpu_init(void)
@@ -296,7 +295,7 @@ _eina_debug_cpu_init(void)
296 } 295 }
297 _sysmon_thread_runs = EINA_TRUE; 296 _sysmon_thread_runs = EINA_TRUE;
298 } 297 }
299 eina_debug_opcodes_register(NULL, _OPS, NULL, NULL); 298 eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL);
300 return EINA_TRUE; 299 return EINA_TRUE;
301} 300}
302 301
diff --git a/src/lib/eina/eina_evlog.c b/src/lib/eina/eina_evlog.c
index c078beef75..0c2fda480b 100644
--- a/src/lib/eina/eina_evlog.c
+++ b/src/lib/eina/eina_evlog.c
@@ -249,13 +249,12 @@ _stop_cb(Eina_Debug_Session *session EINA_UNUSED, int cid EINA_UNUSED, void *buf
249 return EINA_TRUE; 249 return EINA_TRUE;
250} 250}
251 251
252static const Eina_Debug_Opcode _EINA_DEBUG_EVLOG_OPS[] = 252EINA_DEBUG_OPCODES_ARRAY_DEFINE(_EINA_DEBUG_EVLOG_OPS,
253{ 253 {"EvLog/on", NULL, &_start_cb},
254 {"EvLog/on", NULL, &_start_cb}, 254 {"EvLog/off", NULL, &_stop_cb},
255 {"EvLog/off", NULL, &_stop_cb}, 255 {"EvLog/get", &_evlog_get_opcode, &_get_cb},
256 {"EvLog/get", &_evlog_get_opcode, &_get_cb}, 256 {NULL, NULL, NULL}
257 {NULL, NULL, NULL} 257);
258};
259 258
260Eina_Bool 259Eina_Bool
261eina_evlog_init(void) 260eina_evlog_init(void)
@@ -273,7 +272,7 @@ eina_evlog_init(void)
273 } 272 }
274#endif 273#endif
275 eina_evlog("+eina_init", NULL, 0.0, NULL); 274 eina_evlog("+eina_init", NULL, 0.0, NULL);
276 eina_debug_opcodes_register(NULL, _EINA_DEBUG_EVLOG_OPS, NULL, NULL); 275 eina_debug_opcodes_register(NULL, _EINA_DEBUG_EVLOG_OPS(), NULL, NULL);
277 return EINA_TRUE; 276 return EINA_TRUE;
278} 277}
279 278