aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-debug.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-03-30 13:04:54 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-03-30 13:04:54 +0800
commit37c97d8b096f588ba4d8fbc7182dae0a35719768 (patch)
tree8da1d45359fa5bb3157445c890818ce29c0b0ffe /camel/camel-debug.c
parent71c5ee30a81ea870329f1c2573cdf6f22cfc7d75 (diff)
downloadgsoc2013-evolution-37c97d8b096f588ba4d8fbc7182dae0a35719768.tar.gz
gsoc2013-evolution-37c97d8b096f588ba4d8fbc7182dae0a35719768.tar.zst
gsoc2013-evolution-37c97d8b096f588ba4d8fbc7182dae0a35719768.zip
added some debug to dump the whole folderinfo tree if store:folder_info is
2004-03-30 Not Zed <NotZed@Ximian.com> * camel-store.c (camel_store_get_folder_info): added some debug to dump the whole folderinfo tree if store:folder_info is set. * providers/imapp/camel-imapp-driver.c: #if 0 out some code, to kill warnings. * camel-url-scanner.c: include ctype.h for isspace (wonder if it should use utf8 funcs?). 2004-03-29 Not Zed <NotZed@Ximian.com> ** See #56146. * providers/imap/camel-imap-store.c (get_folders): check the top-level folders list for duplicates as well. (get_folders_add_folders): split out the folder return merging code from get_folders. Absolute mess of crap to deal with more busted servers. * camel-debug.c (camel_debug_start, camel_debug_end): some helpers to wrap debug output for atomicicity. svn path=/trunk/; revision=25238
Diffstat (limited to 'camel/camel-debug.c')
-rw-r--r--camel/camel-debug.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/camel/camel-debug.c b/camel/camel-debug.c
index 7c16c9a614..77a5d1cf8b 100644
--- a/camel/camel-debug.c
+++ b/camel/camel-debug.c
@@ -21,6 +21,9 @@
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
+
+#include <pthread.h>
#include "camel-debug.h"
@@ -113,3 +116,143 @@ gboolean camel_debug(const char *mode)
return FALSE;
}
+
+static pthread_mutex_t debug_lock = PTHREAD_MUTEX_INITIALIZER;
+/**
+ * camel_debug_start:
+ * @mode:
+ *
+ * Start debug output for a given mode, used to make sure debug output
+ * is output atomically and not interspersed with unrelated stuff.
+ *
+ * Return value: Returns true if mode is set, and in which case, you must
+ * call debug_end when finished any screen output.
+ **/
+gboolean
+camel_debug_start(const char *mode)
+{
+ if (camel_debug(mode)) {
+ pthread_mutex_lock(&debug_lock);
+ printf("Thread %lx >\n", pthread_self());
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * camel_debug_end:
+ *
+ * Call this when you're done with your debug output. If and only if
+ * you called camel_debug_start, and if it returns TRUE.
+ **/
+void
+camel_debug_end(void)
+{
+ printf("< %lx >\n", pthread_self());
+ pthread_mutex_unlock(&debug_lock);
+}
+
+#include <sys/debugreg.h>
+
+#if 0
+static unsigned
+i386_length_and_rw_bits (int len, enum target_hw_bp_type type)
+{
+ unsigned rw;
+
+ switch (type)
+ {
+ case hw_execute:
+ rw = DR_RW_EXECUTE;
+ break;
+ case hw_write:
+ rw = DR_RW_WRITE;
+ break;
+ case hw_read: /* x86 doesn't support data-read watchpoints */
+ case hw_access:
+ rw = DR_RW_READ;
+ break;
+#if 0
+ case hw_io_access: /* not yet supported */
+ rw = DR_RW_IORW;
+ break;
+#endif
+ default:
+ internal_error (__FILE__, __LINE__, "\
+Invalid hw breakpoint type %d in i386_length_and_rw_bits.\n", (int)type);
+ }
+
+ switch (len)
+ {
+ case 1:
+ return (DR_LEN_1 | rw);
+ case 2:
+ return (DR_LEN_2 | rw);
+ case 4:
+ return (DR_LEN_4 | rw);
+ case 8:
+ if (TARGET_HAS_DR_LEN_8)
+ return (DR_LEN_8 | rw);
+ default:
+ internal_error (__FILE__, __LINE__, "\
+Invalid hw breakpoint length %d in i386_length_and_rw_bits.\n", len);
+ }
+}
+
+#define I386_DR_SET_RW_LEN(i,rwlen) \
+ do { \
+ dr_control_mirror &= ~(0x0f << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \
+ dr_control_mirror |= ((rwlen) << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \
+ } while (0)
+
+#define I386_DR_LOCAL_ENABLE(i) \
+ dr_control_mirror |= (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
+
+
+#define set_dr(regnum, val) \
+ __asm__("movl %0,%%db" #regnum \
+ : /* no output */ \
+ :"r" (val))
+
+#define get_dr(regnum, val) \
+ __asm__("movl %%db" #regnum ", %0" \
+ :"=r" (val))
+
+/* fine idea, but it doesn't work, crashes in get_dr :-/ */
+void
+camel_debug_hwatch(int wp, void *addr)
+{
+ guint32 control, rw;
+
+ g_assert(wp <= DR_LASTADDR);
+ g_assert(sizeof(addr) == 4);
+
+ get_dr(7, control);
+ /* set watch mode + size */
+ rw = DR_RW_WRITE | DR_LEN_4;
+ control &= ~(((1<<DR_CONTROL_SIZE)-1) << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE * wp));
+ control |= rw << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE*wp);
+ /* set watch enable */
+ control |= ( 1<< (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * wp));
+ control |= DR_LOCAL_SLOWDOWN;
+ control &= ~DR_CONTROL_RESERVED;
+
+ switch (wp) {
+ case 0:
+ set_dr(0, addr);
+ break;
+ case 1:
+ set_dr(1, addr);
+ break;
+ case 2:
+ set_dr(2, addr);
+ break;
+ case 3:
+ set_dr(3, addr);
+ break;
+ }
+ set_dr(7, control);
+}
+
+#endif