Thread: [gq-commit] gq/src browse-dnd.c,1.7,1.8 debug.c,1.4,1.5 debug.h,1.3,1.4 encode.c,1.18,1.19 errorchai
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2002-07-15 18:36:54
|
Update of /cvsroot/gqclient/gq/src In directory usw-pr-cvs1:/tmp/cvs-serv18058/src Modified Files: browse-dnd.c debug.c debug.h encode.c errorchain.c errorchain.h gq.c mainwin.c Log Message: * New debugging code. Now there is a commandline option -d <flags> where flags is a bitmask to select various debugging information. The meaning of the bits is defined in src/debug.h. * Also introduced a way to get rid of all debugging related code by adding the --disable-debugging configure option. Index: browse-dnd.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/browse-dnd.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** browse-dnd.c 13 Jul 2002 07:06:32 -0000 1.7 --- browse-dnd.c 15 Jul 2002 18:36:51 -0000 1.8 *************** *** 27,31 **** /* $Id$ */ - /* #define DEBUG_DND */ /* typedef unsigned long ulong; */ --- 27,30 ---- *************** *** 46,49 **** --- 45,49 ---- #include "util.h" #include "i18n.h" + #include "debug.h" typedef struct _dnd_refresh { *************** *** 114,119 **** int answer; ! #ifdef DEBUG_DND ! printf("dropped %08lx at x=%d, y=%d\n", (ulong) drag_context, x, y); #endif --- 114,121 ---- int answer; ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSE_DND) { ! printf("dropped %08lx at x=%d, y=%d\n", (ulong) drag_context, x, y); ! } #endif *************** *** 299,306 **** ctree_node); ! #ifdef DEBUG_DND ! printf("drag_begin start node=%08lx entry=%08lx\n", ! (ulong) ctree_node, ! (ulong) entry); #endif --- 301,310 ---- ctree_node); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("drag_begin start node=%08lx entry=%08lx\n", ! (ulong) ctree_node, ! (ulong) entry); ! } #endif *************** *** 325,331 **** (GtkDestroyNotify) drag_and_select_data_free); ! #ifdef DEBUG_DND printf("drag_begin %08lx %08lx\n", (ulong) ctreeroot, (ulong) seldata); #endif } --- 329,337 ---- (GtkDestroyNotify) drag_and_select_data_free); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { printf("drag_begin %08lx %08lx\n", (ulong) ctreeroot, (ulong) seldata); + } #endif } *************** *** 390,395 **** gpointer user_data) { ! #ifdef DEBUG_DND ! printf("drag_end %08lx\n", (ulong) drag_context); #endif /* kill any motion timer ... */ --- 396,403 ---- gpointer user_data) { ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("drag_end %08lx\n", (ulong) drag_context); ! } #endif /* kill any motion timer ... */ *************** *** 440,446 **** g_byte_array_append(buf, &nul, 1); ! #ifdef DEBUG_DND ! printf("drag_data_get ctx=%08lx data=%08lx\n", (ulong) drag_context, ! (ulong) data); #endif --- 448,456 ---- g_byte_array_append(buf, &nul, 1); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("drag_data_get ctx=%08lx data=%08lx\n", (ulong) drag_context, ! (ulong) data); ! } #endif *************** *** 453,459 **** g_byte_array_free(buf, TRUE); ! #ifdef DEBUG_DND ! printf("data->data=%08lx data=%08lxx\n", ! (ulong)(data->data), (ulong) data); #endif } --- 463,471 ---- g_byte_array_free(buf, TRUE); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("data->data=%08lx data=%08lxx\n", ! (ulong)(data->data), (ulong) data); ! } #endif } *************** *** 497,502 **** value[n] = 0; ! #ifdef DEBUG_DND ! printf("key=%s value=%s\n", key, value); #endif g_hash_table_insert(selhash, key, value); --- 509,516 ---- value[n] = 0; ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("key=%s value=%s\n", key, value); ! } #endif g_hash_table_insert(selhash, key, value); *************** *** 519,525 **** char *newdn = NULL; ! #ifdef DEBUG_DND ! printf("do_move_after_reception selhash=%08lx server=%s dn=%s\n", ! (ulong) selhash, (char*)g_hash_table_lookup(selhash, "nickname"), dn); #endif --- 533,542 ---- char *newdn = NULL; ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("do_move_after_reception selhash=%08lx server=%s dn=%s\n", ! (ulong) selhash, ! (char*)g_hash_table_lookup(selhash, "nickname"), dn); ! } #endif *************** *** 597,605 **** ! #ifdef DEBUG_DND ! printf("moved %s below %s, became %s\n", ! dn, ! target_entry->dn, ! newdn); #endif g_free(newdn); --- 614,624 ---- ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("moved %s below %s, became %s\n", ! dn, ! target_entry->dn, ! newdn); ! } #endif g_free(newdn); *************** *** 630,636 **** } ! #ifdef DEBUG_DND ! printf("drag_data_received ctx=%08lx seldata=%08lx\n", ! (ulong) drag_context, (ulong) data); #endif --- 649,657 ---- } ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("drag_data_received ctx=%08lx seldata=%08lx\n", ! (ulong) drag_context, (ulong) data); ! } #endif *************** *** 679,684 **** } } ! #ifdef DEBUG_DND ! printf("dragged to %d/%d\n", x, y); #endif } --- 700,707 ---- } } ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("dragged to %d/%d\n", x, y); ! } #endif } *************** *** 709,719 **** dn = g_hash_table_lookup(selhash, "dn"); ! #ifdef DEBUG_DND ! printf("drag_data_delete ctx=%08lx suggested=%d action=%d server=%s dn=%s\n", ! (ulong) drag_context, ! drag_context->suggested_action, ! drag_context->action, ! server, dn ! ); #endif --- 732,744 ---- dn = g_hash_table_lookup(selhash, "dn"); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("drag_data_delete ctx=%08lx suggested=%d action=%d server=%s dn=%s\n", ! (ulong) drag_context, ! drag_context->suggested_action, ! drag_context->action, ! server, dn ! ); ! } #endif *************** *** 734,739 **** } } ! #ifdef DEBUG_DND ! printf("drag_data_delete done\n"); #endif gtk_object_remove_data(GTK_OBJECT(widget), --- 759,766 ---- } } ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("drag_data_delete done\n"); ! } #endif gtk_object_remove_data(GTK_OBJECT(widget), *************** *** 791,796 **** GDK_CURRENT_TIME); ! #ifdef DEBUG_DND ! printf("copy_entry %08lx %d\n", (ulong) ctree, have_sel); #endif } --- 818,825 ---- GDK_CURRENT_TIME); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("copy_entry %08lx %d\n", (ulong) ctree, have_sel); ! } #endif } *************** *** 810,815 **** g_hash_table_insert(selhash, g_strdup("recursively"), g_strdup("TRUE")); ! #ifdef DEBUG_DND ! printf("copy_entry_all %08lx\n", (ulong) widget); #endif } --- 839,846 ---- g_hash_table_insert(selhash, g_strdup("recursively"), g_strdup("TRUE")); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("copy_entry_all %08lx\n", (ulong) widget); ! } #endif } *************** *** 831,836 **** char *attrs[] = { "*", "+", NULL }; ! #ifdef DEBUG_DND ! printf("get_selection_string\n"); #endif --- 862,869 ---- char *attrs[] = { "*", "+", NULL }; ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("get_selection_string\n"); ! } #endif *************** *** 891,896 **** g_byte_array_append(buf, &nul, 1); ! #ifdef DEBUG_DND ! printf("get_selection_gq data=%08lx\n", (ulong) data); #endif --- 924,931 ---- g_byte_array_append(buf, &nul, 1); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("get_selection_gq data=%08lx\n", (ulong) data); ! } #endif *************** *** 901,907 **** buf->len); ! #ifdef DEBUG_DND ! printf("data->data=%08lx data=%08lxx\n", ! (ulong)(data->data), (ulong) data); #endif --- 936,944 ---- buf->len); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("data->data=%08lx data=%08lxx\n", ! (ulong)(data->data), (ulong) data); ! } #endif *************** *** 931,936 **** GtkWidget *ctree = g_hash_table_lookup(hash, "ctreeroot"); ! #ifdef DEBUG_DND ! printf("paste_entry %08lx\n", (ulong) ctree); #endif gtk_selection_convert(ctree, --- 968,975 ---- GtkWidget *ctree = g_hash_table_lookup(hash, "ctreeroot"); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("paste_entry %08lx\n", (ulong) ctree); ! } #endif gtk_selection_convert(ctree, *************** *** 955,961 **** GHashTable *selhash = NULL; ! #ifdef DEBUG_DND ! printf("selection_received seldata=%08lx\n", ! (ulong) data); #endif --- 994,1002 ---- GHashTable *selhash = NULL; ! #ifdef DEBUG ! if (debug & GQ_DEBUG_BROWSER_DND) { ! printf("selection_received seldata=%08lx\n", ! (ulong) data); ! } #endif Index: debug.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/debug.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** debug.c 9 Jun 2002 15:24:20 -0000 1.4 --- debug.c 15 Jul 2002 18:36:51 -0000 1.5 *************** *** 32,48 **** int max_mallocs = 0; void *gq_malloc(size_t size, char *msg) { - void *newmem; ! newmem = malloc(size); ! printf("+ gq_malloc: %s (%d bytes @ 0x%x)\n", msg, size, ! (unsigned int) newmem); ! ! num_mallocs++; ! max_mallocs++; ! return(newmem); } --- 32,53 ---- int max_mallocs = 0; + #ifdef DEBUG + int debug = 0; + #endif void *gq_malloc(size_t size, char *msg) { void *newmem; ! newmem = malloc(size); ! #ifdef DEBUG ! if (debug & GQ_DEBUG_MALLOC) { ! printf("+ gq_malloc: %s (%d bytes @ 0x%x)\n", msg, size, ! (unsigned int) newmem); ! ! num_mallocs++; ! max_mallocs++; ! } ! #endif return(newmem); } *************** *** 51,60 **** void gq_free(void *mem, char *msg) { ! ! printf("- gq_free: %s (0x%x)\n", msg, (unsigned int) mem); ! num_mallocs--; ! free(mem); - } --- 56,66 ---- void gq_free(void *mem, char *msg) { ! #ifdef DEBUG ! if (debug & GQ_DEBUG_MALLOC) { ! printf("- gq_free: %s (0x%x)\n", msg, (unsigned int) mem); ! num_mallocs--; ! } ! #endif free(mem); } *************** *** 128,132 **** #endif ! #ifdef MEMDEBUG #ifdef HAVE_MALLINFO static int memstat_timeout_id = -1; --- 134,138 ---- #endif ! #ifdef DEBUG #ifdef HAVE_MALLINFO static int memstat_timeout_id = -1; *************** *** 154,156 **** } #endif /* HAVE_MALLINFO */ ! #endif /* MEMDEBUG */ --- 160,168 ---- } #endif /* HAVE_MALLINFO */ ! #endif /* DEBUG */ ! ! /* ! Local Variables: ! c-basic-offset: 5 ! End: ! */ Index: debug.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/debug.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** debug.h 5 Jun 2002 15:49:49 -0000 1.3 --- debug.h 15 Jul 2002 18:36:51 -0000 1.4 *************** *** 32,35 **** --- 32,47 ---- #ifdef DEBUG + extern int debug; + + #define GQ_DEBUG_ERROR_LINE 1 + #define GQ_DEBUG_MALLOC 2 + #define GQ_DEBUG_MEM 4 + #define GQ_DEBUG_BROWSER_DND 8 + #define GQ_DEBUG_ENCODE 16 + + #endif + + #ifdef DEBUG + #define MALLOC(size, msg) gq_malloc(size, msg) #define FREE(mem, msg) gq_free(mem, msg) *************** *** 42,47 **** #endif ! ! #ifdef MEMDEBUG # ifdef HAVE_MALLINFO # include <malloc.h> --- 54,58 ---- #endif ! #ifdef DEBUG # ifdef HAVE_MALLINFO # include <malloc.h> *************** *** 51,55 **** # endif /* HAVE_MALLINFO */ ! #endif /* MEMDEBUG */ void *gq_malloc(size_t size, char *msg); --- 62,66 ---- # endif /* HAVE_MALLINFO */ ! #endif /* DEBUG */ void *gq_malloc(size_t size, char *msg); Index: encode.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/encode.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** encode.c 18 Jun 2002 22:02:17 -0000 1.18 --- encode.c 15 Jul 2002 18:36:51 -0000 1.19 *************** *** 46,49 **** --- 46,50 ---- #include "ldif.h" #include "encode.h" + #include "debug.h" char *gq_codeset = GQ_CODESET; *************** *** 83,90 **** #ifdef DEBUG ! fprintf(stderr, "decode_string \"%s\" (%d) -> \"%s\"\n", ! ldap_string, strlen(ldap_string), native_string); ! #endif /* DEBUG */ ! return native_string; } --- 84,92 ---- #ifdef DEBUG ! if (debug & GQ_DEBUG_ENCODE) { ! fprintf(stderr, "decode_string \"%s\" (%d) -> \"%s\"\n", ! ldap_string, strlen(ldap_string), native_string); ! } ! #endif return native_string; } *************** *** 125,131 **** #ifdef DEBUG ! fprintf(stderr, "encode_string \"%s\" -> \"%s\"\n", ! native_string, ldap_string); ! #endif /* DEBUG */ return ldap_string; --- 127,135 ---- #ifdef DEBUG ! if (debug & GQ_DEBUG_ENCODE) { ! fprintf(stderr, "encode_string \"%s\" -> \"%s\"\n", ! native_string, ldap_string); ! } ! #endif return ldap_string; Index: errorchain.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/errorchain.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** errorchain.c 27 Jun 2002 08:39:15 -0000 1.9 --- errorchain.c 15 Jul 2002 18:36:51 -0000 1.10 *************** *** 91,102 **** } ! #ifdef ERROR_SHOW_LINE void error_push_debug(int context, char *msg, char *file, int line) { ! int len = strlen(msg) + strlen(file) + 100; ! char *s = g_malloc(len); ! snprintf(s, len, "%s:%d %s", file, line, msg); ! error_push_production(context, s); ! g_free(s); } #endif --- 91,106 ---- } ! #ifdef DEBUG void error_push_debug(int context, char *msg, char *file, int line) { ! if (debug & GQ_DEBUG_ERROR_LINE) { ! int len = strlen(msg) + strlen(file) + 100; ! char *s = g_malloc(len); ! snprintf(s, len, "%s:%d %s", file, line, msg); ! error_push_production(context, s); ! g_free(s); ! } else { ! error_push_production(context, msg); ! } } #endif Index: errorchain.h =================================================================== RCS file: /cvsroot/gqclient/gq/src/errorchain.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** errorchain.h 27 Jun 2002 08:21:20 -0000 1.5 --- errorchain.h 15 Jul 2002 18:36:51 -0000 1.6 *************** *** 28,36 **** #include <ldap.h> /* LDAP */ int error_new_context(char *title); void error_push_production(int context, char *msg); ! #ifdef ERROR_SHOW_LINE void error_push_debug(int context, char *msg, char *file, int line); --- 28,37 ---- #include <ldap.h> /* LDAP */ + #include "config.h" int error_new_context(char *title); void error_push_production(int context, char *msg); ! #ifdef DEBUG void error_push_debug(int context, char *msg, char *file, int line); Index: gq.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/gq.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** gq.c 12 Jul 2002 20:27:52 -0000 1.12 --- gq.c 15 Jul 2002 18:36:51 -0000 1.13 *************** *** 22,37 **** */ #include <signal.h> ! #ifdef MEMDEBUG # include "debug.h" # ifdef HAVE_MCHECK # include <mcheck.h> # endif /* HAVE_MCHECK */ ! #endif /* MEMDEBUG */ ! ! #include <gtk/gtk.h> - #include <string.h> #include "gq.h" --- 22,39 ---- */ + #include <gtk/gtk.h> + #include <string.h> #include <signal.h> + #include <unistd.h> ! #include "config.h" ! ! #ifdef DEBUG # include "debug.h" # ifdef HAVE_MCHECK # include <mcheck.h> # endif /* HAVE_MCHECK */ ! #endif /* DEBUG */ #include "gq.h" *************** *** 41,44 **** --- 43,47 ---- #include "syntax.h" #include "encode.h" + #include "debug.h" GdkFont *big_fixed; *************** *** 47,55 **** int main(int argc, char *argv[]) { ! #ifdef MEMDEBUG # ifdef HAVE_MCHECK ! mcheck(NULL); # endif /* HAVE_MCHECK */ ! #endif /* MEMDEBUG */ #if ENABLE_NLS --- 50,61 ---- int main(int argc, char *argv[]) { ! int c; ! #ifdef DEBUG # ifdef HAVE_MCHECK ! if (debug & GQ_DEBUG_MEM) { ! mcheck(NULL); ! } # endif /* HAVE_MCHECK */ ! #endif /* DEBUG */ #if ENABLE_NLS *************** *** 82,85 **** --- 88,111 ---- gtk_init(&argc, &argv); + /* parse command line... */ + while ((c = getopt(argc, argv, "d:")) != EOF) { + switch (c) { + case 'd': { + #ifdef DEBUG + char *ep; + debug = strtoul(optarg, &ep, 0); + #else + fprintf(stderr, _("gq was build without debugging support\n")); + return 1; + #endif + break; + } + default: { + fprintf(stderr, _("Unknown option %c\n"), c); + return 2; + } + } + } + init_config(); *************** *** 91,99 **** g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); ! #ifdef MEMDEBUG # ifdef HAVE_MALLINFO ! init_memstat_timer(); # endif /* HAVE_MALLINFO */ ! #endif /* MEMDEBUG */ /* Avoids getting killed if an LDAP server we are connected to --- 117,127 ---- g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL); ! #ifdef DEBUG # ifdef HAVE_MALLINFO ! if (debug & GQ_DEBUG_MEM) { ! init_memstat_timer(); ! } # endif /* HAVE_MALLINFO */ ! #endif /* DEBUG */ /* Avoids getting killed if an LDAP server we are connected to Index: mainwin.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/mainwin.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** mainwin.c 13 Jul 2002 16:53:41 -0000 1.25 --- mainwin.c 15 Jul 2002 18:36:51 -0000 1.26 *************** *** 156,162 **** #ifdef DEBUG ! report_num_mallocs(); #endif - } --- 156,163 ---- #ifdef DEBUG ! if (debug & GQ_DEBUG_MALLOC) { ! report_num_mallocs(); ! } #endif } |