jackdanielz pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=758bb0557c45353a8afffebb69d93f969e1ea4b6
commit 758bb0557c45353a8afffebb69d93f969e1ea4b6 Author: Daniel Zaoui <[email protected]> Date: Fri Jun 2 12:13:31 2017 +0300 Support opcodes registration for Windows A standard static array with symbols whose addresses are only known at runtime is not supported in Windows. --- src/bin/efl/efl_debug.c | 27 +++++++++++++-------------- src/lib/eina/eina_debug.h | 19 +++++++++++++++++++ src/lib/eina/eina_debug_bt.c | 13 ++++++------- src/lib/eina/eina_debug_cpu.c | 13 ++++++------- src/lib/eina/eina_evlog.c | 15 +++++++-------- 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) } } -static const Eina_Debug_Opcode ops[] = -{ - {"Daemon/Client/register_observer", &_cl_stat_reg_opcode, NULL}, - {"Daemon/Client/added", NULL, &_clients_info_added_cb}, - {"Daemon/Client/deleted", NULL, &_clients_info_deleted_cb}, - {"Daemon/Client/cid_from_pid", &_cid_from_pid_opcode, &_cid_get_cb}, - {"Profiler/on", &_prof_on_opcode, NULL}, - {"Profiler/off", &_prof_off_opcode, NULL}, - {"CPU/Freq/on", &_cpufreq_on_opcode, NULL}, - {"CPU/Freq/off", &_cpufreq_off_opcode, NULL}, - {"EvLog/get", &_evlog_get_opcode, _evlog_get_cb}, - {NULL, NULL, NULL} -}; +EINA_DEBUG_OPCODES_ARRAY_DEFINE(ops, + {"Daemon/Client/register_observer", &_cl_stat_reg_opcode, NULL}, + {"Daemon/Client/added", NULL, &_clients_info_added_cb}, + {"Daemon/Client/deleted", NULL, &_clients_info_deleted_cb}, + {"Daemon/Client/cid_from_pid", &_cid_from_pid_opcode, &_cid_get_cb}, + {"Profiler/on", &_prof_on_opcode, NULL}, + {"Profiler/off", &_prof_off_opcode, NULL}, + {"CPU/Freq/on", &_cpufreq_on_opcode, NULL}, + {"CPU/Freq/off", &_cpufreq_off_opcode, NULL}, + {"EvLog/get", &_evlog_get_opcode, _evlog_get_cb}, + {NULL, NULL, NULL} +); int main(int argc EINA_UNUSED, char **argv EINA_UNUSED) @@ -254,7 +253,7 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED) fprintf(stderr, "ERROR: Cannot connect to debug daemon.\n"); return -1; } - eina_debug_opcodes_register(_session, ops, _args_handle, NULL); + eina_debug_opcodes_register(_session, ops(), _args_handle, NULL); ecore_main_loop_begin(); 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 } Eina_Debug_Packet_Header; /** + * Helper for creating global opcodes arrays. + * The problem is on windows where you can't declare a static array with + * external symbols in it, because the addresses are only known at runtime. + */ +#define EINA_DEBUG_OPCODES_ARRAY_DEFINE(Name, ...) \ + static Eina_Debug_Opcode * \ + Name(void) \ + { \ + Eina_Debug_Opcode tmp[] = { __VA_ARGS__ }; \ + static Eina_Debug_Opcode internal[EINA_C_ARRAY_LENGTH(tmp) + 1] = \ + { { 0, 0, 0 } }; \ + if (internal[0].opcode_name == NULL) \ + { \ + memcpy(internal, tmp, sizeof(tmp)); \ + } \ + return internal; \ + } + +/** * @typedef Eina_Debug_Opcode * * 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 return EINA_TRUE; } -static const Eina_Debug_Opcode _OPS[] = -{ - {"Profiler/on", NULL, &_prof_on_cb}, - {"Profiler/off", NULL, &_prof_off_cb}, - {NULL, NULL, NULL} -}; +EINA_DEBUG_OPCODES_ARRAY_DEFINE(_OPS, + {"Profiler/on", NULL, &_prof_on_cb}, + {"Profiler/off", NULL, &_prof_off_cb}, + {NULL, NULL, NULL} +); Eina_Bool _eina_debug_bt_init(void) { _signal_init(); eina_semaphore_new(&_wait_for_bts_sem, 0); - eina_debug_opcodes_register(NULL, _OPS, NULL, NULL); + eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL); return EINA_TRUE; } 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 return EINA_TRUE; } -static const Eina_Debug_Opcode _OPS[] = -{ - {"CPU/Freq/on", NULL, &_cpufreq_on_cb}, - {"CPU/Freq/off", NULL, &_cpufreq_off_cb}, - {NULL, NULL, NULL} -}; +EINA_DEBUG_OPCODES_ARRAY_DEFINE(_OPS, + {"CPU/Freq/on", NULL, &_cpufreq_on_cb}, + {"CPU/Freq/off", NULL, &_cpufreq_off_cb}, + {NULL, NULL, NULL} +); Eina_Bool _eina_debug_cpu_init(void) @@ -296,7 +295,7 @@ _eina_debug_cpu_init(void) } _sysmon_thread_runs = EINA_TRUE; } - eina_debug_opcodes_register(NULL, _OPS, NULL, NULL); + eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL); return EINA_TRUE; } 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 return EINA_TRUE; } -static const Eina_Debug_Opcode _EINA_DEBUG_EVLOG_OPS[] = -{ - {"EvLog/on", NULL, &_start_cb}, - {"EvLog/off", NULL, &_stop_cb}, - {"EvLog/get", &_evlog_get_opcode, &_get_cb}, - {NULL, NULL, NULL} -}; +EINA_DEBUG_OPCODES_ARRAY_DEFINE(_EINA_DEBUG_EVLOG_OPS, + {"EvLog/on", NULL, &_start_cb}, + {"EvLog/off", NULL, &_stop_cb}, + {"EvLog/get", &_evlog_get_opcode, &_get_cb}, + {NULL, NULL, NULL} +); Eina_Bool eina_evlog_init(void) @@ -273,7 +272,7 @@ eina_evlog_init(void) } #endif eina_evlog("+eina_init", NULL, 0.0, NULL); - eina_debug_opcodes_register(NULL, _EINA_DEBUG_EVLOG_OPS, NULL, NULL); + eina_debug_opcodes_register(NULL, _EINA_DEBUG_EVLOG_OPS(), NULL, NULL); return EINA_TRUE; } --
