Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_debug.h ewl_misc.c Log Message: - you can pass a --ewl-backtrace flag and when ewl spits out a developer warning it will give a backtrace at that point. only works for system that are using glibc tho. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_debug.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_debug.h 22 Nov 2005 17:28:15 -0000 1.10 +++ ewl_debug.h 1 Dec 2005 01:23:58 -0000 1.11 @@ -13,6 +13,7 @@ inline void ewl_print_warning(void); inline void ewl_segv(void); +inline void ewl_backtrace(void); #define DEBUG 1 @@ -109,6 +110,7 @@ fprintf(stderr, "\tIn function:\n\n" \ "\t%s();\n\n", __FUNCTION__); \ fprintf(stderr, fmt); \ + ewl_backtrace(); \ ewl_segv(); \ } @@ -123,6 +125,7 @@ "\t%s\n\n" \ "\tbeing NULL. Please fix your program.\n", \ __FUNCTION__, str); \ + ewl_backtrace(); \ ewl_segv(); \ return; \ } \ @@ -139,6 +142,7 @@ "\t%s\n\n" \ "\tbeing NULL. Please fix your program.\n", \ __FUNCTION__, str); \ + ewl_backtrace(); \ ewl_segv(); \ return ret; \ } \ @@ -156,6 +160,7 @@ "\tas the wrong type. (%s) instead of (%s).\n" \ "\tPlease fix your program.\n", \ __FUNCTION__, str, EWL_WIDGET(ptr)->inheritance, type); \ + ewl_backtrace(); \ ewl_segv(); \ } \ } @@ -172,6 +177,7 @@ "\tas the wrong type. (%s) instead of (%s).\n" \ "\tPlease fix your program.\n", \ __FUNCTION__, str, EWL_WIDGET(ptr)->inheritance, type); \ + ewl_backtrace(); \ ewl_segv(); \ return ret; \ } \ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_misc.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -3 -r1.30 -r1.31 --- ewl_misc.c 28 Nov 2005 00:52:41 -0000 1.30 +++ ewl_misc.c 1 Dec 2005 01:23:58 -0000 1.31 @@ -3,21 +3,26 @@ #include "ewl_macros.h" #include "ewl_private.h" +#ifdef __GLIBC__ +#include <execinfo.h> +#endif + extern Ecore_List *ewl_embed_list; extern Ecore_List *ewl_window_list; /* * Configuration and option related flags. */ -static unsigned int debug_segv = 0; -static unsigned int use_engine = EWL_ENGINE_ALL; -static unsigned int phase_status = 0; -static unsigned int print_theme_keys = 0; -static unsigned int print_gc_reap = 0; -static unsigned int debug_level = 0; +static unsigned int debug_segv = 0; +static unsigned int debug_bt = 0; +static unsigned int use_engine = EWL_ENGINE_ALL; +static unsigned int phase_status = 0; +static unsigned int print_theme_keys = 0; +static unsigned int print_gc_reap = 0; +static unsigned int debug_level = 0; static Ecore_Idle_Enterer *idle_enterer = NULL; -static Ecore_Idler *ewl_garbage_collect = NULL; +static Ecore_Idler *ewl_garbage_collect = NULL; static int _ewl_init_count = 0; /* @@ -36,10 +41,10 @@ static Ecore_List *free_evas_list = NULL; static Ecore_List *free_evas_object_list = NULL; -int ewl_idle_render(void *data); -static void ewl_init_parse_options(int *argc, char **argv); -static void ewl_init_remove_option(int *argc, char **argv, int i); -int ewl_ecore_exit(void *data, int type, void *event); +int ewl_idle_render(void *data); +static void ewl_init_parse_options(int *argc, char **argv); +static void ewl_init_remove_option(int *argc, char **argv, int i); +int ewl_ecore_exit(void *data, int type, void *event); /** * @return Returns no value. @@ -51,7 +56,7 @@ inline void ewl_print_warning(void) { - fprintf(stderr, "***** Ewl Developer Warning ***** :\n" + fprintf(stderr, "\n***** Ewl Developer Warning ***** :\n" " To find where this is occurring set a breakpoint\n" " for the function %s.\n", __FUNCTION__); } @@ -70,6 +75,33 @@ } /** + * @returns Returns no value. + * @brief This will print a backtrace at the given point. + */ +inline void +ewl_backtrace(void) +{ +#ifdef __GLIBC__ + void *array[128]; + size_t size; + char **strings; + size_t i; + + if (!debug_bt) return; + + fprintf(stderr, "\n***** Backtrace *****\n"); + size = backtrace(array, 128); + strings = backtrace_symbols(array, size); + for (i = 0; i < size; i++) + fprintf(stderr, "%s\n", strings[i]); + + FREE(strings); +#else + fprintf(stderr, "Your system dosen't have glibc. Backtraces disabled.\n"); +#endif +} + +/** * @param argc: the argc passed into the main function * @param argv: the argv passed into the main function * @return Returns 1 or greater on success, 0 otherwise. @@ -464,7 +496,11 @@ debug_segv = 1; matched++; } - if (!strcmp(argv[i], "--ewl-theme")) { + else if (!strcmp(argv[i], "--ewl-backtrace")) { + debug_bt = 1; + matched++; + } + else if (!strcmp(argv[i], "--ewl-theme")) { if (i + 1 < *argc) { ewl_theme_name_set(argv[i + 1]); matched++; ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs