}
}
-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)
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();
} 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
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;
}
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)
}
_sysmon_thread_runs = EINA_TRUE;
}
- eina_debug_opcodes_register(NULL, _OPS, NULL, NULL);
+ eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL);
return EINA_TRUE;
}
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)
}
#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;
}