X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fmain.c;h=eca23438b09cd6dc21eda2503598a777c65e705d;hb=235c78f0716f71ac54fb6ffe7f9803e86d96bdaa;hp=c1b2324226054f781fa661b44d97143480ff1ba5;hpb=a43d67bae425508678e5ae2ffe5dd1e84286b915;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/main.c b/ltt/branches/poly/lttv/lttv/main.c index c1b23242..eca23438 100644 --- a/ltt/branches/poly/lttv/lttv/main.c +++ b/ltt/branches/poly/lttv/lttv/main.c @@ -16,6 +16,9 @@ * MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include @@ -26,6 +29,7 @@ #include #include #include +#include /* The main program maintains a few central data structures and relies @@ -46,7 +50,8 @@ static char static gboolean a_verbose, - a_debug; + a_debug, + a_fatal; gboolean lttv_profile_memory; @@ -62,20 +67,26 @@ static void lttv_verbose(void *hook_data); static void lttv_debug(void *hook_data); +static void lttv_event_debug(void *hook_data); + +static void lttv_fatal(void *hook_data); + static void lttv_help(void *hook_data); /* This is the handler to specify when we dont need all the debugging messages. It receives the message and does nothing. */ void ignore_and_drop_message(const gchar *log_domain, GLogLevelFlags log_level, - const gchar *message, gpointer user_data) { + const gchar *message, gpointer user_data) +{ } /* Since everything is done in modules, the main program only takes care of the infrastructure. */ -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ int i; @@ -108,9 +119,9 @@ int main(int argc, char **argv) { /* Initialize glib and by default ignore info and debug messages */ g_type_init(); - g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS); - //g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL); - //g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL); + //g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | G_TYPE_DEBUG_SIGNALS); + g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL); + g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL); /* Have an attributes subtree to store hooks to be registered by modules. */ @@ -144,9 +155,9 @@ int main(int argc, char **argv) { GError *error = NULL; LttvModule *module_module = lttv_module_require("module", &error); - if(error != NULL) g_error(error->message); + if(error != NULL) g_error("%s", error->message); LttvModule *module_option = lttv_module_require("option", &error); - if(error != NULL) g_error(error->message); + if(error != NULL) g_error("%s", error->message); /* Initialize the module loading */ @@ -173,6 +184,16 @@ int main(int argc, char **argv) { a_debug = FALSE; lttv_option_add("debug",'d', "print debugging messages", "none", LTTV_OPT_NONE, NULL, lttv_debug, NULL); + + /* use --edebug, -e conflicts with filter. Problem with option parsing when we + * reparse the options with different number of arguments. */ + lttv_option_add("edebug",'e', "print event debugging", "none", + LTTV_OPT_NONE, NULL, lttv_event_debug, NULL); + + a_fatal = FALSE; + lttv_option_add("fatal",'f', "make critical messages fatal", + "none", + LTTV_OPT_NONE, NULL, lttv_fatal, NULL); lttv_profile_memory = FALSE; lttv_option_add(profile_memory_long_option + 2, @@ -225,11 +246,11 @@ LttvAttribute *lttv_global_attributes() void lttv_module_option(void *hook_data) -{ +{ GError *error = NULL; lttv_module_require(a_module, &error); - if(error != NULL) g_error(error->message); + if(error != NULL) g_error("%s", error->message); } @@ -251,12 +272,25 @@ void lttv_debug(void *hook_data) g_info("Logging set to include DEBUG level messages"); } +void lttv_event_debug(void *hook_data) +{ + ltt_event_debug(1); + g_info("Output event detailed debug"); +} + +void lttv_fatal(void *hook_data) +{ + g_log_set_always_fatal(G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL); + //g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL); + g_info("Critical log from glib will abort execution"); +} + void lttv_help(void *hook_data) { - printf("Linux Trace Toolkit Visualizer\n"); - printf("\n"); - lttv_option_show_help(); - printf("\n"); + printf("Linux Trace Toolkit Visualizer " VERSION "\n"); + printf("\n"); + lttv_option_show_help(); + printf("\n"); } /*