[ltt-dev] [PATCH] Fix match between state dump and quark
Mathieu Desnoyers
compudj at krystal.dyndns.org
Thu Nov 25 20:08:49 EST 2010
* francis.giraldeau at usherbrooke.ca (francis.giraldeau at usherbrooke.ca) wrote:
> From: Francis Giraldeau <francis.giraldeau at usherbrooke.ca>
>
> This patch fixes the association between lttng state dump enum values and the
> right lttv state quark.
>
> The patch adds string tables that matches the enums sequence in lttng-modules,
> to convert enum value in the state dump to quark.
>
> Update :
> * static inline replaces macro
> * more specific function name ltt_enum_quark
> * move static string tables to state.c
> * copy corresponding state dump enum from lttng-modules
> * remove strings duplication in module_init
> * revert double state change
> ---
> lttv/lttv/state.c | 83 +++++++++++++++++++++++++++++++++++++---------------
> lttv/lttv/state.h | 31 ++++++++++++++++++++
> 2 files changed, 90 insertions(+), 24 deletions(-)
>
> diff --git a/lttv/lttv/state.c b/lttv/lttv/state.c
> index bd3f64d..720a34c 100644
> --- a/lttv/lttv/state.c
> +++ b/lttv/lttv/state.c
> @@ -46,6 +46,43 @@
>
> #define PREALLOCATED_EXECUTION_STACK 10
>
> +/* get a given quark from lttng module enum value */
> +#define ltt_enum_quark(e, f, names) (g_quark_from_string(names[ltt_event_get_unsigned(e, f)]))
Almost there!
Please change this #define for a static inline function.
Thanks,
Mathieu
> +
> +/*
> + * Quark strings that matches lttng module enums found in statedump
> + * Matching enums are from lttng-modules/ltt-statedump.c
> + */
> +static const char *const lttng_thread_type_names[] = {
> + "USER_THREAD", // LTTNG_USER_THREAD
> + "KERNEL_THREAD" // LTTNG_KERNEL_THREAD
> +};
> +
> +static const char *const lttng_execution_mode_names[] = {
> + "USER_MODE", // LTTNG_USER_MODE
> + "SYSCALL", // LTTNG_SYSCALL
> + "TRAP", // LTTNG_TRAP
> + "IRQ", // LTTNG_IRQ
> + "SOFTIRQ", // LTTNG_SOFTIRQ
> + "UNKNOWN" // LTTNG_MODE_UNKNOWN
> +};
> +
> +static const char *const lttng_execution_submode_names[] = {
> + "UNKNOWN", // LTTNG_NONE
> + "NONE" // LTTNG_UNKNOWN
> +};
> +
> +static const char *const lttng_process_status_names[] = {
> + "", // LTTNG_UNNAMED
> + "WAIT_FORK", // LTTNG_WAIT_FORK
> + "WAIT_CPU", // LTTNG_WAIT_CPU
> + "EXIT", // LTTNG_EXIT
> + "ZOMBIE", // LTTNG_ZOMBIE
> + "WAIT", // LTTNG_WAIT
> + "RUN", // LTTNG_RUN
> + "DEAD" // LTTNG_DEAD
> +};
> +
> /* Channel Quarks */
>
> GQuark
> @@ -3440,21 +3477,19 @@ static gboolean enum_process_state(void *hook_data, void *call_data)
>
> /* type */
> f = lttv_trace_get_hook_field(th, 3);
> - type = ltt_enum_string_get(f, ltt_event_get_unsigned(e, f));
> -
> - //FIXME: type is rarely used, enum must match possible types.
> + type = ltt_enum_quark(e, f, lttng_thread_type_names);
>
> /* mode */
> f = lttv_trace_get_hook_field(th, 4);
> - mode = ltt_enum_string_get(f,ltt_event_get_unsigned(e, f));
> + mode = ltt_enum_quark(e, f, lttng_execution_mode_names);
>
> /* submode */
> f = lttv_trace_get_hook_field(th, 5);
> - submode = ltt_enum_string_get(f, ltt_event_get_unsigned(e, f));
> + submode = ltt_enum_quark(e, f, lttng_execution_submode_names);
>
> /* status */
> f = lttv_trace_get_hook_field(th, 6);
> - status = ltt_enum_string_get(f, ltt_event_get_unsigned(e, f));
> + status = ltt_enum_quark(e, f, lttng_process_status_names);
>
> /* TGID */
> f = lttv_trace_get_hook_field(th, 7);
> @@ -4412,25 +4447,25 @@ GType lttv_tracefile_state_get_type(void)
>
> static void module_init()
> {
> - LTTV_STATE_UNNAMED = g_quark_from_string("");
> LTTV_STATE_UNBRANDED = g_quark_from_string("");
> - LTTV_STATE_MODE_UNKNOWN = g_quark_from_string("MODE_UNKNOWN");
> - LTTV_STATE_USER_MODE = g_quark_from_string("USER_MODE");
> - LTTV_STATE_SYSCALL = g_quark_from_string("SYSCALL");
> - LTTV_STATE_TRAP = g_quark_from_string("TRAP");
> - LTTV_STATE_IRQ = g_quark_from_string("IRQ");
> - LTTV_STATE_SOFT_IRQ = g_quark_from_string("SOFTIRQ");
> - LTTV_STATE_SUBMODE_UNKNOWN = g_quark_from_string("UNKNOWN");
> - LTTV_STATE_SUBMODE_NONE = g_quark_from_string("NONE");
> - LTTV_STATE_WAIT_FORK = g_quark_from_string("WAIT_FORK");
> - LTTV_STATE_WAIT_CPU = g_quark_from_string("WAIT_CPU");
> - LTTV_STATE_EXIT = g_quark_from_string("EXIT");
> - LTTV_STATE_ZOMBIE = g_quark_from_string("ZOMBIE");
> - LTTV_STATE_WAIT = g_quark_from_string("WAIT");
> - LTTV_STATE_RUN = g_quark_from_string("RUN");
> - LTTV_STATE_DEAD = g_quark_from_string("DEAD");
> - LTTV_STATE_USER_THREAD = g_quark_from_string("USER_THREAD");
> - LTTV_STATE_KERNEL_THREAD = g_quark_from_string("KERNEL_THREAD");
> + LTTV_STATE_MODE_UNKNOWN = g_quark_from_string(lttng_execution_mode_names[LTTNG_MODE_UNKNOWN]);
> + LTTV_STATE_USER_MODE = g_quark_from_string(lttng_execution_mode_names[LTTNG_USER_MODE]);
> + LTTV_STATE_SYSCALL = g_quark_from_string(lttng_execution_mode_names[LTTNG_SYSCALL]);
> + LTTV_STATE_TRAP = g_quark_from_string(lttng_execution_mode_names[LTTNG_TRAP]);
> + LTTV_STATE_IRQ = g_quark_from_string(lttng_execution_mode_names[LTTNG_IRQ]);
> + LTTV_STATE_SOFT_IRQ = g_quark_from_string(lttng_execution_mode_names[LTTNG_SOFTIRQ]);
> + LTTV_STATE_SUBMODE_UNKNOWN = g_quark_from_string(lttng_execution_submode_names[LTTNG_NONE]);
> + LTTV_STATE_SUBMODE_NONE = g_quark_from_string(lttng_execution_submode_names[LTTNG_NONE]);
> + LTTV_STATE_UNNAMED = g_quark_from_string(lttng_process_status_names[LTTNG_UNNAMED]);
> + LTTV_STATE_WAIT_FORK = g_quark_from_string(lttng_process_status_names[LTTNG_WAIT_FORK]);
> + LTTV_STATE_WAIT_CPU = g_quark_from_string(lttng_process_status_names[LTTNG_WAIT_CPU]);
> + LTTV_STATE_EXIT = g_quark_from_string(lttng_process_status_names[LTTNG_EXIT]);
> + LTTV_STATE_ZOMBIE = g_quark_from_string(lttng_process_status_names[LTTNG_ZOMBIE]);
> + LTTV_STATE_WAIT = g_quark_from_string(lttng_process_status_names[LTTNG_WAIT]);
> + LTTV_STATE_RUN = g_quark_from_string(lttng_process_status_names[LTTNG_RUN]);
> + LTTV_STATE_DEAD = g_quark_from_string(lttng_process_status_names[LTTNG_DEAD]);
> + LTTV_STATE_USER_THREAD = g_quark_from_string(lttng_thread_type_names[LTTNG_USER_THREAD]);
> + LTTV_STATE_KERNEL_THREAD = g_quark_from_string(lttng_thread_type_names[LTTNG_KERNEL_THREAD]);
> LTTV_STATE_TRACEFILES = g_quark_from_string("tracefiles");
> LTTV_STATE_PROCESSES = g_quark_from_string("processes");
> LTTV_STATE_PROCESS = g_quark_from_string("process");
> diff --git a/lttv/lttv/state.h b/lttv/lttv/state.h
> index 0ae7e5c..9450c7c 100644
> --- a/lttv/lttv/state.h
> +++ b/lttv/lttv/state.h
> @@ -53,6 +53,37 @@
>
> #define LTTV_STATE_SAVE_INTERVAL 50000
>
> +/* lttng module enums from ltt-statedump.c */
> +enum lttng_thread_type {
> + LTTNG_USER_THREAD = 0,
> + LTTNG_KERNEL_THREAD = 1,
> +};
> +
> +enum lttng_execution_mode {
> + LTTNG_USER_MODE = 0,
> + LTTNG_SYSCALL = 1,
> + LTTNG_TRAP = 2,
> + LTTNG_IRQ = 3,
> + LTTNG_SOFTIRQ = 4,
> + LTTNG_MODE_UNKNOWN = 5,
> +};
> +
> +enum lttng_execution_submode {
> + LTTNG_NONE = 0,
> + LTTNG_UNKNOWN = 1,
> +};
> +
> +enum lttng_process_status {
> + LTTNG_UNNAMED = 0,
> + LTTNG_WAIT_FORK = 1,
> + LTTNG_WAIT_CPU = 2,
> + LTTNG_EXIT = 3,
> + LTTNG_ZOMBIE = 4,
> + LTTNG_WAIT = 5,
> + LTTNG_RUN = 6,
> + LTTNG_DEAD = 7,
> +};
> +
> /* Channel Quarks */
>
> extern GQuark
> --
> 1.7.1
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list