redmine

Debugging support had been made optional

... ... @@ -87,10 +87,20 @@ AM_CONDITIONAL([LIBCLSYNC], [test "x$enable_socket_library" = "xyes"])
dnl --enable-debug
AC_ARG_ENABLE(debug,
AS_HELP_STRING(--enable-debug,
[enable debugging, default: no]))
[enable debugging support, default: yes; value: no, yes, force]),
[case "${enableval}" in
(0|"no") debug=0 ;;
(1|"yes") debug=1 ;;
(2|"force") debug=2 ;;
(*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],
[debug=1])
AS_IF([ test "$debug" -ge 1 ],
[CFLAGS="${CFLAGS} -pipe -Wall -O0 -ggdb3" CPPFLAGS="${CPPFLAGS} -D_DEBUG_SUPPORT"])
AS_IF([test "x$enable_debug" = "xyes"],
[CFLAGS="${CFLAGS} -pipe -Wall -O0 -ggdb3" CPPFLAGS="${CPPFLAGS} -D_DEBUG"])
AS_IF([ test "$debug" -ge 2 ],
[CPPFLAGS="${CPPFLAGS} -D_DEBUG_FORCE"])
dnl --paranoid
AC_ARG_ENABLE(paranoid,
... ... @@ -100,7 +110,7 @@ AS_HELP_STRING([--enable-paranoid],
(0|"no") paranoid=0 ;;
(1|"yes") paranoid=1 ;;
(2) paranoid=2 ;;
(*) AC_MSG_ERROR([bad value ${enableval} for --paranoid]) ;;
(*) AC_MSG_ERROR([bad value ${enableval} for --enable-paranoid]) ;;
esac],
[paranoid=1])
... ...
... ... @@ -287,6 +287,7 @@ void _warning(const char *const function_name, const char *fmt, ...) {
return;
}
#ifdef _DEBUG_SUPPORT
void _debug(int debug_level, const char *const function_name, const char *fmt, ...) {
va_list args;
... ... @@ -310,6 +311,7 @@ void _debug(int debug_level, const char *const function_name, const char *fmt, .
pthread_mutex_unlock(&error_mutex);
return;
}
#endif
void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug) {
outputmethod = _outputmethod;
... ...
... ... @@ -34,10 +34,15 @@ extern void _warning(const char *const function_name, const char *fmt, ...);
extern void _info(const char *const function_name, const char *fmt, ...);
#define info(...) _info(__FUNCTION__, __VA_ARGS__)
extern void _debug(int debug_level, const char *const function_name, const char *fmt, ...);
#define debug(debug_level, ...) _debug(debug_level, __FUNCTION__, __VA_ARGS__)
#ifdef _DEBUG_SUPPORT
extern void _debug(int debug_level, const char *const function_name, const char *fmt, ...);
# define debug(debug_level, ...) _debug(debug_level, __FUNCTION__, __VA_ARGS__)
# define error_or_debug(debug_level, ...) ((debug_level)<0 ? _error(__FUNCTION__, __VA_ARGS__) : _debug(debug_level, __FUNCTION__, __VA_ARGS__))
#else
# define debug(debug_level, ...) {}
# define error_or_debug(debug_level, ...) ((debug_level)<0 ? _error(__FUNCTION__, __VA_ARGS__) : (void)0)
#endif
#define error_or_debug(debug_level, ...) ((debug_level)<0 ? _error(__FUNCTION__, __VA_ARGS__) : _debug(debug_level, __FUNCTION__, __VA_ARGS__))
extern void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug);
... ...
... ... @@ -527,7 +527,7 @@ static inline int synchandler_arg(char *arg, size_t arg_len, void *_ctx_p, enum
return errno;
}
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(14, "ctx_p->synchandler_args[%u].v[%u] = %p", shargsid, ctx_p->synchandler_args[shargsid].c, arg);
#endif
ctx_p->synchandler_args[shargsid].v[ctx_p->synchandler_args[shargsid].c++] = arg;
... ... @@ -562,7 +562,7 @@ int parse_customsignals(ctx_t *ctx_p, char *arg) {
}
i++;
}
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
fprintf(stderr, "Force-Debug: parse_parameter(): Reset custom signals.\n");
#endif
} else {
... ... @@ -598,7 +598,7 @@ int parse_customsignals(ctx_t *ctx_p, char *arg) {
ch = *end; *end = 0;
ctx_p->customsignal[signal] = strdup(ptr);
*end = ch;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
fprintf(stderr, "Force-Debug: parse_parameter(): Adding custom signal %u.\n", signal);
#endif
ptr = end;
... ... @@ -619,7 +619,7 @@ int parse_customsignals(ctx_t *ctx_p, char *arg) {
}
int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t paramsource) {
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
fprintf(stderr, "Force-Debug: parse_parameter(): %i: %i = \"%s\"\n", paramsource, param_id, arg);
#endif
switch (paramsource) {
... ... @@ -1080,12 +1080,12 @@ int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t pa
int i = 0;
while (i < 256)
ctx_p->isignoredexitcode[i++] = 0;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
fprintf(stderr, "Force-Debug: parse_parameter(): Reset ignored exitcodes.\n");
#endif
} else {
ctx_p->isignoredexitcode[exitcode] = 1;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
fprintf(stderr, "Force-Debug: parse_parameter(): Adding ignored exitcode %u.\n", exitcode);
#endif
}
... ... @@ -1243,7 +1243,7 @@ int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t pa
ctx_p->flags[param_id]++;
else
ctx_p->flags[param_id] = atoi(arg);
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
fprintf(stderr, "Force-Debug: flag %i is set to %i\n", param_id&0xff, ctx_p->flags[param_id]);
#endif
break;
... ... @@ -1275,7 +1275,7 @@ int arguments_parse(int argc, char *argv[], struct ctx *ctx_p) {
lo_ptr++;
}
*optstring_ptr = 0;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
fprintf(stderr, "Force-Debug: %s\n", optstring);
#endif
... ... @@ -1560,7 +1560,7 @@ int ctx_check(ctx_t *ctx_p) {
ctx_p->cluster_mcastipaddr = DEFAULT_CLUSTERIPADDR;
if (ctx_p->cluster_iface != NULL) {
#ifndef _DEBUG
#ifndef _DEBUG_FORCE
ret = errno = EINVAL;
error("Cluster subsystem is not implemented, yet. Sorry.");
#endif
... ... @@ -1765,7 +1765,7 @@ void ctx_cleanup(ctx_t *ctx_p) {
while (n < SHARGS_MAX) {
int i = 0, e = ctx_p->synchandler_args[n].c;
while (i < e) {
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(14, "synchandler args: %u, %u: free(%p)", n, i, ctx_p->synchandler_args[n].v[i]);
#endif
free(ctx_p->synchandler_args[n].v[i]);
... ... @@ -2021,7 +2021,7 @@ l_parse_rules_fromfile_end:
rules[i].perm = DEFAULT_RULES_PERM;
g_hash_table_destroy(autowrules_ht);
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(3, "Total (p == %p):", rules);
i=0;
do {
... ...
... ... @@ -167,7 +167,7 @@ ruleaction_t rules_search_getperm(const char *fpath, mode_t st_mode, rule_t *rul
rule_t *rule_p = rules_p;
mode_t ftype = st_mode & S_IFMT;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(3, "Rules (p == %p):", rules_p);
i=0;
do {
... ... @@ -625,7 +625,7 @@ static inline int thread_exit(threadinfo_t *threadinfo_p, int exitcode ) {
int err=0;
threadinfo_p->exitcode = exitcode;
#if _DEBUG | VERYPARANOID
#if _DEBUG_FORCE | VERYPARANOID
if (threadinfo_p->pthread != pthread_self()) {
error("pthread id mismatch! (i_p->p) %p != (p) %p""", threadinfo_p->pthread, pthread_self() );
return EINVAL;
... ... @@ -953,7 +953,7 @@ static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char *
argv_dump(level, argv)
static inline void argv_dump(int debug_level, char **argv) {
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(19, "(%u, %p)", debug_level, argv);
#endif
char **argv_p = argv;
... ... @@ -1474,7 +1474,7 @@ const char *sync_parameter_get(const char *variable_name, void *_dosync_arg_p) {
struct dosync_arg *dosync_arg_p = _dosync_arg_p;
ctx_t *ctx_p = dosync_arg_p->ctx_p;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(15, "(\"%s\", %p): 0x%x", variable_name, _dosync_arg_p, ctx_p == NULL ? 0 : ctx_p->synchandler_argf);
#endif
... ... @@ -1505,12 +1505,12 @@ static char **sync_customargv(ctx_t *ctx_p, struct dosync_arg *dosync_arg_p, syn
char *arg = args_p->v[s];
char isexpanded = args_p->isexpanded[s];
s++;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(30, "\"%s\" [%p]", arg, arg);
#endif
if (isexpanded) {
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(19, "\"%s\" [%p] is already expanded, just strdup()-ing it", arg, arg);
#endif
argv[d++] = strdup(arg);
... ... @@ -1520,7 +1520,7 @@ static char **sync_customargv(ctx_t *ctx_p, struct dosync_arg *dosync_arg_p, syn
if (!strcmp(arg, "%INCLUDE-LIST%")) {
int i = 0, e = dosync_arg_p->include_list_count;
const char **include_list = dosync_arg_p->include_list;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(19, "INCLUDE-LIST: e == %u; d,s: %u,%u", e, d, s);
#endif
while (i < e) {
... ... @@ -1531,7 +1531,7 @@ static char **sync_customargv(ctx_t *ctx_p, struct dosync_arg *dosync_arg_p, syn
}
#endif
argv[d++] = parameter_expand(ctx_p, strdup(include_list[i++]), 0, NULL, NULL, sync_parameter_get, dosync_arg_p);
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(19, "include-list: argv[%u] == %p", d-1, argv[d-1]);
#endif
}
... ... @@ -1546,14 +1546,14 @@ static char **sync_customargv(ctx_t *ctx_p, struct dosync_arg *dosync_arg_p, syn
#endif
argv[d] = parameter_expand(ctx_p, strdup(arg), 0, NULL, NULL, sync_parameter_get, dosync_arg_p);
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(19, "argv[%u] == %p \"%s\"", d, argv[d], argv[d]);
#endif
d++;
}
argv[d] = NULL;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(18, "return %p", argv);
#endif
return argv;
... ... @@ -1561,7 +1561,7 @@ static char **sync_customargv(ctx_t *ctx_p, struct dosync_arg *dosync_arg_p, syn
static void argv_free(char **argv) {
char **argv_p;
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(18, "(%p)", argv);
#endif
#ifdef VERYPARANOID
... ... @@ -1570,7 +1570,7 @@ static void argv_free(char **argv) {
#endif
argv_p = argv;
while (*argv_p != NULL) {
#ifdef _DEBUG
#ifdef _DEBUG_FORCE
debug(25, "free(%p)", *argv_p);
#endif
free(*(argv_p++));
... ...