aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-09-20 13:14:16 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-09-20 13:14:16 +0000
commitdb1b76de7229926515ceba67fb9f5543883bd3e8 (patch)
tree38d55475c8669fcd8bf2eb4ec157144b5d312bb7
parentb027b933a923bdd0baf1847f9884b2b551f5a611 (diff)
debugging levels
svn path=/trunk/externals/iem/iemnet/; revision=14160
-rw-r--r--iemnet.c8
-rw-r--r--iemnet.h6
-rw-r--r--iemnet_data.c2
-rw-r--r--iemnet_receiver.c2
-rw-r--r--iemnet_sender.c6
-rw-r--r--tcpclient.c3
-rw-r--r--tcpreceive.c4
-rw-r--r--tcpsend.c4
-rw-r--r--tcpserver.c5
-rw-r--r--udpclient.c4
-rw-r--r--udpreceive.c6
-rw-r--r--udpsend.c3
-rw-r--r--udpserver.c4
13 files changed, 42 insertions, 15 deletions
diff --git a/iemnet.c b/iemnet.c
index fb97a61..7675dbc 100644
--- a/iemnet.c
+++ b/iemnet.c
@@ -2,7 +2,7 @@
* copyright (c) 2010 IOhannes m zmlnig, IEM
*/
-//#define DEBUG
+#define DEBUGLEVEL
#include "iemnet.h"
#include <stdlib.h>
@@ -111,6 +111,12 @@ void udpsend_setup(void);
void udpserver_setup(void);
#endif
+int debuglevel=0;
+void iemnet_debuglevel(void*x, t_float f) {
+ post("setting debuglevel from %d to %d", debuglevel, (int)f);
+ debuglevel=(int)f;
+}
+
IEMNET_EXTERN void iemnet_setup(void) {
diff --git a/iemnet.h b/iemnet.h
index bc04840..7e3d76c 100644
--- a/iemnet.h
+++ b/iemnet.h
@@ -238,9 +238,13 @@ int iemnet__register(const char*name);
#ifdef IEMNET_HAVE_DEBUG
# undef IEMNET_HAVE_DEBUG
#endif
+int debuglevel;
+void iemnet_debuglevel(void*,t_float);
+#define DEBUGMETHOD(c) class_addmethod(c, (t_method)iemnet_debuglevel, gensym("debug"), A_FLOAT, 0)
+
#ifdef DEBUG
# undef DEBUG
-# define DEBUG startpost("[%s:%d]", __FUNCTION__, __LINE__); post
+# define DEBUG if(debuglevel&DEBUGLEVEL)startpost("[%s:%d]", __FUNCTION__, __LINE__); if(debuglevel&DEBUGLEVEL)post
# define IEMNET_HAVE_DEBUG 1
#else
static void debug_dummy(const char *format, ...) {;}
diff --git a/iemnet_data.c b/iemnet_data.c
index 7ccc5b0..0fceed9 100644
--- a/iemnet_data.c
+++ b/iemnet_data.c
@@ -6,7 +6,7 @@
* copyright (c) 2010 IOhannes m zmlnig, IEM
*/
-//#define DEBUG
+#define DEBUGLEVEL 8
#include "iemnet.h"
#include "iemnet_data.h"
diff --git a/iemnet_receiver.c b/iemnet_receiver.c
index 160de17..0345400 100644
--- a/iemnet_receiver.c
+++ b/iemnet_receiver.c
@@ -2,7 +2,7 @@
* copyright (c) 2010 IOhannes m zmlnig, IEM
*/
-//#define DEBUG
+#define DEBUGLEVEL 4
#include "iemnet.h"
#include "iemnet_data.h"
diff --git a/iemnet_sender.c b/iemnet_sender.c
index ef2b70a..715bdff 100644
--- a/iemnet_sender.c
+++ b/iemnet_sender.c
@@ -7,7 +7,7 @@
* copyright (c) 2010 IOhannes m zmlnig, IEM
*/
-//#define DEBUG
+#define DEBUGLEVEL 2
#include "iemnet.h"
#include "iemnet_data.h"
@@ -31,8 +31,8 @@
#if IEMNET_HAVE_DEBUG
static int debug_lockcount=0;
-# define LOCK(x) do {pthread_mutex_lock(x); debug_lockcount++; post(" LOCK %d (@%d)", debug_lockcount, __LINE__); } while(0)
-# define UNLOCK(x) do {debug_lockcount--;post("UNLOCK %d (@%d)", debug_lockcount, __LINE__);pthread_mutex_unlock(x);}while(0)
+# define LOCK(x) do {pthread_mutex_lock(x);debug_lockcount++; if(debuglevel&DEBUGLEVEL)post(" LOCK %d (@%s:%d)", debug_lockcount, __FILE__, __LINE__); } while(0)
+# define UNLOCK(x) do {debug_lockcount--;if(debuglevel&DEBUGLEVEL)post("UNLOCK %d (@%s:%d)", debug_lockcount, __FILE__, __LINE__);pthread_mutex_unlock(x);}while(0)
#else
# define LOCK(x) pthread_mutex_lock(x)
# define UNLOCK(x) pthread_mutex_unlock(x)
diff --git a/tcpclient.c b/tcpclient.c
index 7a37c53..c613d34 100644
--- a/tcpclient.c
+++ b/tcpclient.c
@@ -23,7 +23,7 @@
/* */
/* ---------------------------------------------------------------------------- */
-//#define DEBUG
+#define DEBUGLEVEL 1
#include "iemnet.h"
#include <string.h>
@@ -292,6 +292,7 @@ IEMNET_EXTERN void tcpclient_setup(void)
class_addlist(tcpclient_class, (t_method)tcpclient_send);
class_addbang(tcpclient_class, (t_method)tcpclient_info);
+ DEBUGMETHOD(tcpclient_class);
}
diff --git a/tcpreceive.c b/tcpreceive.c
index 3bd73a8..56d758c 100644
--- a/tcpreceive.c
+++ b/tcpreceive.c
@@ -22,6 +22,8 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* */
+#define DEBUGLEVEL 1
+
static const char*objName="tcpreceive";
#include "iemnet.h"
@@ -351,7 +353,7 @@ IEMNET_EXTERN void tcpreceive_setup(void)
class_addmethod(tcpreceive_class, (t_method)tcpreceive_port, gensym("port"), A_DEFFLOAT, 0);
class_addmethod(tcpreceive_class, (t_method)tcpreceive_serialize, gensym("serialize"), A_FLOAT, 0);
-
+ DEBUGMETHOD(tcpreceive_class);
}
IEMNET_INITIALIZER(tcpreceive_setup);
diff --git a/tcpsend.c b/tcpsend.c
index 38e3fae..9c94c19 100644
--- a/tcpsend.c
+++ b/tcpsend.c
@@ -22,6 +22,8 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* */
+#define DEBUGLEVEL 1
+
static const char objName[] = "tcpsend";
#include "iemnet.h"
@@ -151,6 +153,8 @@ IEMNET_EXTERN void tcpsend_setup(void)
class_addmethod(tcpsend_class, (t_method)tcpsend_send, gensym("send"),
A_GIMME, 0);
class_addlist(tcpsend_class, (t_method)tcpsend_send);
+
+ DEBUGMETHOD(tcpsend_class);
}
IEMNET_INITIALIZER(tcpsend_setup);
diff --git a/tcpserver.c b/tcpserver.c
index 3cc2d0e..ad4387d 100644
--- a/tcpserver.c
+++ b/tcpserver.c
@@ -24,7 +24,8 @@
/* */
/* ---------------------------------------------------------------------------- */
-//#define DEBUG
+#define DEBUGLEVEL 1
+
#include "iemnet.h"
#include "iemnet_data.h"
#include <stdio.h>
@@ -658,6 +659,8 @@ IEMNET_EXTERN void tcpserver_setup(void)
class_addmethod(tcpserver_class, (t_method)tcpserver_port, gensym("port"), A_DEFFLOAT, 0);
class_addbang (tcpserver_class, (t_method)tcpserver_info);
+
+ DEBUGMETHOD(tcpserver_class);
}
IEMNET_INITIALIZER(tcpserver_setup);
diff --git a/udpclient.c b/udpclient.c
index 253f983..153fbe0 100644
--- a/udpclient.c
+++ b/udpclient.c
@@ -22,7 +22,7 @@
/* ---------------------------------------------------------------------------- */
-//#define DEBUG
+#define DEBUGLEVEL 1
#include "iemnet.h"
#include <string.h>
@@ -254,6 +254,8 @@ IEMNET_EXTERN void udpclient_setup(void)
class_addmethod(udpclient_class, (t_method)udpclient_disconnect, gensym("disconnect"), 0);
class_addmethod(udpclient_class, (t_method)udpclient_send, gensym("send"), A_GIMME, 0);
class_addlist(udpclient_class, (t_method)udpclient_send);
+
+ DEBUGMETHOD(udpclient_class);
}
diff --git a/udpreceive.c b/udpreceive.c
index a00b382..2338cec 100644
--- a/udpreceive.c
+++ b/udpreceive.c
@@ -5,7 +5,7 @@
*/
/* */
-/* A server for unidirectional communication from within Pd. */
+/* A server for unidirectional communication from within Pd. */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
@@ -20,7 +20,8 @@
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* */
+
+#define DEBUGLEVEL 1
static const char objName[] = "udpreceive";
@@ -162,6 +163,7 @@ IEMNET_EXTERN void udpreceive_setup(void)
class_addmethod(udpreceive_class, (t_method)udpreceive_port,
gensym("port"), A_DEFFLOAT, 0);
+ DEBUGMETHOD(udpreceive_class);
}
IEMNET_INITIALIZER(udpreceive_setup);
diff --git a/udpsend.c b/udpsend.c
index 37442a9..b5b26b1 100644
--- a/udpsend.c
+++ b/udpsend.c
@@ -22,7 +22,7 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* */
-//#define DEBUG
+#define DEBUGLEVEL 1
static const char objName[] = "udpsend";
@@ -162,6 +162,7 @@ IEMNET_EXTERN void udpsend_setup(void)
class_addmethod(udpsend_class, (t_method)udpsend_send, gensym("send"),
A_GIMME, 0);
class_addlist(udpsend_class, (t_method)udpsend_send);
+ DEBUGMETHOD(udpsend_class);
}
IEMNET_INITIALIZER(udpsend_setup);
diff --git a/udpserver.c b/udpserver.c
index e147b00..389a1a1 100644
--- a/udpserver.c
+++ b/udpserver.c
@@ -24,7 +24,7 @@
/* */
/* ---------------------------------------------------------------------------- */
-//#define DEBUG
+#define DEBUGLEVEL 1
#include "iemnet.h"
#include <stdio.h>
#include <stdlib.h>
@@ -747,6 +747,8 @@ IEMNET_EXTERN void udpserver_setup(void)
class_addmethod(udpserver_class, (t_method)udpserver_port, gensym("port"), A_DEFFLOAT, 0);
class_addbang (udpserver_class, (t_method)udpserver_info);
+
+ DEBUGMETHOD(udpserver_class);
}
IEMNET_INITIALIZER(udpserver_setup);