From: Pierre-Marc Fournier Date: Tue, 8 Sep 2009 17:55:42 +0000 (-0400) Subject: update error system X-Git-Tag: v0.1~157 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2028e7fd97170e430b55b8c0e1a6ca1edca7680c;p=ust.git update error system --- diff --git a/libust/Makefile.am b/libust/Makefile.am index e3d4541..1f18f8b 100644 --- a/libust/Makefile.am +++ b/libust/Makefile.am @@ -5,3 +5,4 @@ lib_LTLIBRARIES = libust.la libust_la_SOURCES = marker.c marker.h tracepoint.c tracepoint.h immediate.h channels.c channels.h marker-control.c marker-control.h relay.c relay.h tracer.c tracer.h tracercore.c tracercore.h serialize.c tracectl.c $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/share/usterr.h localerr.h libust_la_LDFLAGS = -no-undefined -version-info 0:0:0 libust_la_LIBADD = $(URCU_LIBS) -lpthread +libust_la_CFLAGS = -DUST_COMPONENT="libust" diff --git a/libust/localerr.h b/libust/localerr.h deleted file mode 100644 index eef0d4f..0000000 --- a/libust/localerr.h +++ /dev/null @@ -1 +0,0 @@ -#include "usterr.h" diff --git a/share/localerr.h b/share/localerr.h new file mode 100644 index 0000000..eef0d4f --- /dev/null +++ b/share/localerr.h @@ -0,0 +1 @@ +#include "usterr.h" diff --git a/share/usterr.h b/share/usterr.h index 9c4be7e..a96a36f 100644 --- a/share/usterr.h +++ b/share/usterr.h @@ -1,15 +1,26 @@ #ifndef USTERR_H #define USTERR_H -//#define DEBUG +#ifndef UST_COMPONENT +//#error UST_COMPONENT is undefined +#define UST_COMPONENT libust +#endif + +/* To stringify the expansion of a define */ +#define XSTR(d) STR(d) +#define STR(s) #s + +#define UST_STR_COMPONENT XSTR(UST_COMPONENT) + +#define DEBUG #ifdef DEBUG -# define DBG(fmt, args...) do { fprintf(stderr, fmt "\n", ## args); fflush(stderr); } while(0) +# define DBG(fmt, args...) do { fprintf(stderr, UST_STR_COMPONENT ": " fmt "(" __FILE__ ":" XSTR(__LINE__) ")\n", ## args); fflush(stderr); } while(0) #else # define DBG(fmt, args...) do {} while(0) #endif -#define WARN(fmt, args...) fprintf(stderr, "libust: WARNING: " fmt "\n", ## args); fflush(stderr) -#define ERR(fmt, args...) fprintf(stderr, "libust: ERROR: " fmt "\n", ## args); fflush(stderr) -#define BUG(fmt, args...) fprintf(stderr, "libust: BUG: " fmt "\n", ## args); fflush(stderr) +#define WARN(fmt, args...) fprintf(stderr, UST_STR_COMPONENT ": Warning: " fmt "\n", ## args); fflush(stderr) +#define ERR(fmt, args...) fprintf(stderr, UST_STR_COMPONENT ": Error: " fmt "\n", ## args); fflush(stderr) +#define BUG(fmt, args...) fprintf(stderr, UST_STR_COMPONENT ": BUG: " fmt "\n", ## args); fflush(stderr) #define PERROR(call) perror("ust: ERROR: " call) #define BUG_ON(condition) do { if (unlikely(condition)) ERR("condition not respected (BUG)"); } while(0) diff --git a/ust/Makefile.am b/ust/Makefile.am index e353751..f6a6e9c 100644 --- a/ust/Makefile.am +++ b/ust/Makefile.am @@ -1,10 +1,8 @@ bin_PROGRAMS = ust ust_SOURCES = ust.c $(top_builddir)/libustcomm/ustcomm.c $(top_builddir)/libustcomm/ustcomm.h $(top_builddir)/libustcmd/ustcmd.c $(top_builddir)/libustcmd/ustcmd.h localerr.h +ust_CFLAGS = -DUST_COMPONENT=ust -#INCLUDES = -I$(top_builddir)/share -#INCLUDES += -I@URCU_PATH@ INCLUDES = $(KCOMPAT_CFLAGS) -#INCLUDES += -I$(top_builddir)/libust INCLUDES += -I$(top_builddir)/libustcomm INCLUDES += -I$(top_builddir)/libustcmd - +INCLUDES += -I$(top_builddir)/share diff --git a/ust/localerr.h b/ust/localerr.h deleted file mode 100644 index bfb9527..0000000 --- a/ust/localerr.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef LOCALERR_H -#define LOCALERR_H - -#include - -#define DBG(fmt, args...) fprintf(stderr, "ust: " fmt "\n", ## args); fflush(stderr) -#define WARN(fmt, args...) fprintf(stderr, "ust: WARNING: " fmt "\n", ## args); fflush(stderr) -#define ERR(fmt, args...) fprintf(stderr, "ust: ERROR: " fmt "\n", ## args); fflush(stderr) -#define PERROR(a) perror(a) - -#endif /* LOCALERR_H */ diff --git a/ust/ust.c b/ust/ust.c index d891665..53ede09 100644 --- a/ust/ust.c +++ b/ust/ust.c @@ -25,6 +25,7 @@ #include "ustcomm.h" #include "ustcmd.h" +#include "usterr.h" enum command { START_TRACE, diff --git a/ustd/localerr.h b/ustd/localerr.h deleted file mode 100644 index d4276eb..0000000 --- a/ustd/localerr.h +++ /dev/null @@ -1,12 +0,0 @@ -#include - -//#define DEBUG -#ifdef DEBUG -# define DBG(fmt, args...) fprintf(stderr, "ustd: " fmt "\n", ## args); fflush(stderr) -#else -# define DBG(fmt, args...) do {} while(0) -#endif - -#define WARN(fmt, args...) fprintf(stderr, "ustd: WARNING: " fmt "\n", ## args); fflush(stderr) -#define ERR(fmt, args...) fprintf(stderr, "ustd: ERROR: " fmt "\n", ## args); fflush(stderr) -#define PERROR(a) perror(a)