diff options
author | Erik Walthinsen <omega@temple-baptist.org> | 2001-05-25 21:00:07 +0000 |
---|---|---|
committer | Erik Walthinsen <omega@temple-baptist.org> | 2001-05-25 21:00:07 +0000 |
commit | 4a583683e5cdf35d6f059952cbae4416120f8749 (patch) | |
tree | ae6079f992bebb3fb51ac8b97f2a16d8ea0ef64c /gst/gstinfo.h | |
parent | 54271eca8ec659e79199f587de00fcbff0dea826 (diff) |
Merged from INCSCHED on 200505251!!!INCSCHED1-200105251
Original commit message from CVS:
Merged from INCSCHED on 200505251!!!
Diffstat (limited to 'gst/gstinfo.h')
-rw-r--r-- | gst/gstinfo.h | 232 |
1 files changed, 114 insertions, 118 deletions
diff --git a/gst/gstinfo.h b/gst/gstinfo.h index 620d809dd..71fdba9f4 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -34,6 +34,14 @@ #include "cothreads.h" +/***** are we in the core or not? *****/ +#ifdef __GST_PRIVATE_H__ + #define _GST_DEBUG_INCORE TRUE +#else + #define _GST_DEBUG_INCORE FALSE +#endif + + /* colorization stuff */ #ifdef GST_DEBUG_COLOR #ifdef __GST_PRIVATE_H__ /* FIXME this should be some libgst.la -specific thing */ @@ -47,13 +55,51 @@ gint _gst_debug_stringhash_color(gchar *file); +/********************************************************************** + * Categories + **********************************************************************/ + +const gchar * gst_get_category_name (gint category); + +enum { + GST_CAT_GST_INIT = 0, // Library initialization + GST_CAT_COTHREADS, // Cothread creation, etc. + GST_CAT_COTHREAD_SWITCH, // Cothread switching + GST_CAT_AUTOPLUG, // Successful autoplug results + GST_CAT_AUTOPLUG_ATTEMPT, // Attempted autoplug operations + GST_CAT_PARENTAGE, // GstBin parentage issues + GST_CAT_STATES, // State changes and such + GST_CAT_PLANNING, // Plan generation + GST_CAT_SCHEDULING, // Schedule construction + GST_CAT_DATAFLOW, // Events during actual data movement + GST_CAT_BUFFER, // Buffer creation/destruction + GST_CAT_CAPS, // Capabilities matching + GST_CAT_CLOCK, // Clocking + GST_CAT_ELEMENT_PADS, // Element pad management + GST_CAT_ELEMENTFACTORY, // Elementfactory stuff + GST_CAT_PADS, // Pad creation/connection + GST_CAT_PIPELINE, // Pipeline stuff + GST_CAT_PLUGIN_LOADING, // Plugin loading + GST_CAT_PLUGIN_ERRORS, // Errors during plugin loading + GST_CAT_PLUGIN_INFO, // Plugin state information + GST_CAT_PROPERTIES, // Properties + GST_CAT_THREAD, // Thread creation/management + GST_CAT_TYPES, // Typing + GST_CAT_XML, // XML load/save of everything + GST_CAT_NEGOTIATION, // Caps Negotiation stuff + GST_CAT_REFCOUNTING, // Ref Counting stuff + + GST_CAT_MAX_CATEGORY = 31 +}; + +extern const gchar *_gst_category_colors[32]; + + /********************************************************************** * DEBUG system **********************************************************************/ -extern guint32 _gst_debug_categories; - /* for include files that make too much noise normally */ #ifdef GST_DEBUG_FORCE_DISABLE #undef GST_DEBUG_ENABLED @@ -69,109 +115,69 @@ extern guint32 _gst_debug_categories; //#define GST_DEBUG_ENABLE_CATEGORIES 0x00000000 //#endif -/* fallback, this should probably be a 'weak' symbol or something */ -G_GNUC_UNUSED static gchar *_debug_string = NULL; -#ifdef GST_DEBUG_COLOR - #ifdef _GST_COLOR_CODE -#warning have a coded debug - #define GST_DEBUG_PREFIX(cat,format,args...) \ -"DEBUG(%d:%d)\033[" _GST_COLOR_CODE "m" __PRETTY_FUNCTION__ ":%d\033[00m" format , \ -getpid() , cothread_getcurrent() , __LINE__ , ## args - #else - #define GST_DEBUG_PREFIX(cat,format,args...) \ -"DEBUG(%d:%d)\033[" GST_DEBUG_CHAR_MODE ";%sm" __PRETTY_FUNCTION__ ":%d\033[00m" format , \ -getpid() , cothread_getcurrent() , _gst_category_colors[cat] , __LINE__ , ## args - #endif /* _GST_COLOR_CODE */ -#else - #define GST_DEBUG_PREFIX(cat,format,args...) \ -"DEBUG(%d:%d)" __PRETTY_FUNCTION__ ":%d" format , getpid() ,cothread_getcurrent() , __LINE__ , ## args -#endif +typedef void (*GstDebugHandler) (gint category,gboolean core,gchar *file,gchar *function, + gint line,gchar *debug_string, + void *element,gchar *string); +void gst_default_debug_handler (gint category,gboolean incore,gchar *file,gchar *function, + gint line,gchar *debug_string, + void *element,gchar *string); -#ifdef GST_DEBUG_ENABLED -#define GST_DEBUG(cat,format,args...) G_STMT_START{ \ - if (((1<<cat) & GST_DEBUG_ENABLE_CATEGORIES) && \ - ((1<<cat) & _gst_debug_categories)) \ - (_debug_string != NULL) ? \ - fprintf(stderr,GST_DEBUG_PREFIX(cat,"%s: "format , _debug_string , ## args )) : \ - fprintf(stderr,GST_DEBUG_PREFIX(cat,": "format , ## args )); \ -}G_STMT_END +extern guint32 _gst_debug_categories; +extern GstDebugHandler _gst_debug_handler; -#define GST_DEBUG_NOPREFIX(cat,format,args...) G_STMT_START{ \ - if (((1<<cat) & GST_DEBUG_ENABLE_CATEGORIES) && \ - ((1<<cat) & _gst_debug_categories)) \ - fprintf(stderr,format , ## args ); \ -}G_STMT_END +/* fallback, this should probably be a 'weak' symbol or something */ +G_GNUC_UNUSED static gchar *_debug_string = NULL; -#define GST_DEBUG_ENTER(format, args...) G_STMT_START{ \ - if (((1<<31) & GST_DEBUG_ENABLE_CATEGORIES) && \ - ((1<<31) & _gst_debug_categories)) \ - fprintf(stderr,GST_DEBUG_PREFIX(31,format": entering\n" , ## args )); \ -}G_STMT_END -// FIXME FIXME FIXME this leaks like crazy -#define GST_DEBUG_SET_STRING(format, args...) \ - gchar *_debug_string = g_strdup_printf(format , ## args ) -#define GST_DEBUG_ENTER_STRING GST_DEBUG_ENTER("%s",_debug_string) -#define GST_DEBUG_LEAVE(format, args...) G_STMT_START{ \ - if (((1<<31) & GST_DEBUG_ENABLE_CATEGORIES) && \ - ((1<<31) & _gst_debug_categories)) \ - if (_debug_string != NULL) g_free(_debug_string),\ - fprintf(stderr,GST_DEBUG_PREFIX(31,format": leaving\n" , ## args )); \ +#ifdef GST_DEBUG_ENABLED +#define GST_DEBUG(cat,format,args...) G_STMT_START{ \ + if ((1<<cat) & _gst_debug_categories) \ + _gst_debug_handler(cat,_GST_DEBUG_INCORE,__FILE__,__PRETTY_FUNCTION__,__LINE__,_debug_string, \ + NULL,g_strdup_printf( format , ## args )); \ }G_STMT_END -#define GST_DEBUG_LEAVE_STRING GST_DEBUG_LEAVE("%s",_debug_string) +#define GST_DEBUG_ELEMENT(cat,element,format,args...) G_STMT_START{ \ + if ((1<<cat) & _gst_debug_categories) \ + _gst_debug_handler(cat,_GST_DEBUG_INCORE,__FILE__,__PRETTY_FUNCTION__,__LINE__,_debug_string, \ + element,g_strdup_printf( format , ## args )); \ +}G_STMT_END #else -#define GST_DEBUG(format, args...) -#define GST_DEBUG_NOPREFIX(format, args...) -#define GST_DEBUG_ENTER(format, args...) -#define GST_DEBUG_LEAVE(format, args...) -#define GST_DEBUG_SET_STRING(format, args...) -#define GST_DEBUG_ENTER_STRING +#define GST_DEBUG(cat,format,args...) +#define GST_DEBUG_ELEMENT(cat,element,format,args...) #endif + /********** some convenience macros for debugging **********/ #define GST_DEBUG_PAD_NAME(pad) \ (GST_OBJECT_PARENT(pad) != NULL) ? \ GST_OBJECT_NAME (GST_OBJECT_PARENT(pad)) : \ "''", GST_OBJECT_NAME (pad) +#ifdef GST_DEBUG_COLOR + #define GST_DEBUG_ENTER(format, args...) GST_DEBUG( 31 , format ": \033[01;37mentering\033[00m\n" , ##args ) + #define GST_DEBUG_LEAVE(format, args...) GST_DEBUG( 31 , format ": \033[01;37mleaving\033[00m\n" , ##args ) +#else + #define GST_DEBUG_ENTER(format, args...) GST_DEBUG( 31 , format ": entering\n" , ##args ) + #define GST_DEBUG_LEAVE(format, args...) GST_DEBUG( 31 , format ": leaving\n" , ##args ) +#endif -/********** function pointer stuff **********/ -extern GHashTable *__gst_function_pointers; - -#ifdef GST_DEBUG_ENABLED -#define GST_DEBUG_FUNCPTR(ptr) _gst_debug_register_funcptr((void *)(ptr), #ptr) -#define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr) +/***** Colorized debug for thread ids *****/ +#ifdef GST_DEBUG_COLOR + #define GST_DEBUG_THREAD_FORMAT "\033[00;%dm%d\033[00m" + #define GST_DEBUG_THREAD_ARGS(id) ( ((id) < 0) ? 37 : ((id) % 6 + 31) ), (id) #else -#define GST_DEBUG_FUNCPTR(ptr) (ptr) -#define GST_DEBUG_FUNCPTR_NAME(ptr) "" + #define GST_DEBUG_THREAD_FORMAT "%d" + #define GST_DEBUG_THREAD_ARGS(id) (id) #endif -static inline void * -_gst_debug_register_funcptr (void *ptr, gchar *ptrname) -{ - if (!__gst_function_pointers) __gst_function_pointers = g_hash_table_new(g_direct_hash,g_direct_equal); - if (!g_hash_table_lookup(__gst_function_pointers,ptr)) - g_hash_table_insert(__gst_function_pointers,ptr,ptrname); - return ptr; -} - -static inline gchar * -_gst_debug_nameof_funcptr (void *ptr) -{ - gchar *ptrname = (gchar*)( __gst_function_pointers ? g_hash_table_lookup(__gst_function_pointers,ptr) : NULL ); -// FIXME this must go away, it's a major leak - if (!ptrname) return g_strdup_printf("%p",ptr); - else return ptrname; -} /********************************************************************** @@ -227,11 +233,11 @@ G_GNUC_UNUSED static GModule *_debug_self_module = NULL; * INFO system **********************************************************************/ -typedef void (*GstInfoHandler) (gint category,gchar *file,gchar *function, +typedef void (*GstInfoHandler) (gint category,gboolean incore,gchar *file,gchar *function, gint line,gchar *debug_string, void *element,gchar *string); -void gst_default_info_handler (gint category,gchar *file,gchar *function, +void gst_default_info_handler (gint category,gboolean incore,gchar *file,gchar *function, gint line,gchar *debug_string, void *element,gchar *string); @@ -250,13 +256,13 @@ extern guint32 _gst_info_categories; #ifdef GST_INFO_ENABLED #define GST_INFO(cat,format,args...) G_STMT_START{ \ if ((1<<cat) & _gst_info_categories) \ - _gst_info_handler(cat,__FILE__,__PRETTY_FUNCTION__,__LINE__,_debug_string, \ + _gst_info_handler(cat,_GST_DEBUG_INCORE,__FILE__,__PRETTY_FUNCTION__,__LINE__,_debug_string, \ NULL,g_strdup_printf( format , ## args )); \ }G_STMT_END #define GST_INFO_ELEMENT(cat,element,format,args...) G_STMT_START{ \ if ((1<<cat) & _gst_info_categories) \ - _gst_info_handler(cat,__FILE__,__PRETTY_FUNCTION__,__LINE__,_debug_string, \ + _gst_info_handler(cat,_GST_DEBUG_INCORE,__FILE__,__PRETTY_FUNCTION__,__LINE__,_debug_string, \ element,g_strdup_printf( format , ## args )); \ }G_STMT_END @@ -276,42 +282,6 @@ guint32 gst_debug_get_categories (void); void gst_debug_enable_category (gint category); void gst_debug_disable_category (gint category); -const gchar * gst_get_category_name (gint category); - - -enum { - GST_CAT_GST_INIT = 0, // Library initialization - GST_CAT_COTHREADS, // Cothread creation, etc. - GST_CAT_COTHREAD_SWITCH, // Cothread switching - GST_CAT_AUTOPLUG, // Successful autoplug results - GST_CAT_AUTOPLUG_ATTEMPT, // Attempted autoplug operations - GST_CAT_PARENTAGE, // GstBin parentage issues - GST_CAT_STATES, // State changes and such - GST_CAT_PLANNING, // Plan generation - GST_CAT_SCHEDULING, // Schedule construction - GST_CAT_DATAFLOW, // Events during actual data movement - GST_CAT_BUFFER, // Buffer creation/destruction - GST_CAT_CAPS, // Capabilities matching - GST_CAT_CLOCK, // Clocking - GST_CAT_ELEMENT_PADS, // Element pad management - GST_CAT_ELEMENTFACTORY, // Elementfactory stuff - GST_CAT_PADS, // Pad creation/connection - GST_CAT_PIPELINE, // Pipeline stuff - GST_CAT_PLUGIN_LOADING, // Plugin loading - GST_CAT_PLUGIN_ERRORS, // Errors during plugin loading - GST_CAT_PLUGIN_INFO, // Plugin state information - GST_CAT_PROPERTIES, // Properties - GST_CAT_THREAD, // Thread creation/management - GST_CAT_TYPES, // Typing - GST_CAT_XML, // XML load/save of everything - GST_CAT_NEGOTIATION, // Caps Negotiation stuff - - GST_CAT_MAX_CATEGORY, -}; - - -extern const gchar *_gst_category_colors[GST_CAT_MAX_CATEGORY]; - @@ -339,4 +309,30 @@ extern GstErrorHandler _gst_error_handler; + +/********** function pointer stuff **********/ +extern GHashTable *__gst_function_pointers; + + +#if GST_DEBUG_ENABLED +#define GST_DEBUG_FUNCPTR(ptr) _gst_debug_register_funcptr((void *)(ptr), #ptr) +#define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr) +#else +#define GST_DEBUG_FUNCPTR(ptr) (ptr) +#define GST_DEBUG_FUNCPTR_NAME(ptr) "" +#endif + +static inline void * +_gst_debug_register_funcptr (void *ptr, gchar *ptrname) +{ + if (!__gst_function_pointers) __gst_function_pointers = g_hash_table_new(g_direct_hash,g_direct_equal); + if (!g_hash_table_lookup(__gst_function_pointers,ptr)) + g_hash_table_insert(__gst_function_pointers,ptr,ptrname); + return ptr; +} + +gchar *_gst_debug_nameof_funcptr (void *ptr); + + + #endif /* __GSTINFO_H__ */ |