From: Vladimir Nadvornik Date: Wed, 29 Aug 2012 21:27:52 +0000 (+0200) Subject: better filedata ref debug messages X-Git-Tag: v1.2~93 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=f5e2bc6ad3ec9876532a6904c706fbc1f29fc31f better filedata ref debug messages The idea is this: with --debug=2 geeqie writes log with pointers. If it crashes on fd->magick, it writes the invalid pointer as a hex value before the crash. Then the log can be grepped for this value to see what happened with this fd in the past. --- diff --git a/src/filedata.c b/src/filedata.c index 0038d0ec..60ad9523 100644 --- a/src/filedata.c +++ b/src/filedata.c @@ -515,17 +515,19 @@ FileData *file_data_ref(FileData *fd) #endif { if (fd == NULL) return NULL; -#ifdef DEBUG_FILEDATA if (fd->magick != 0x12345678) - DEBUG_0("fd magick mismatch at %s:%d", file, line); +#ifdef DEBUG_FILEDATA + DEBUG_0("fd magick mismatch @ %s:%d fd=%p", file, line, fd); +#else + DEBUG_0("fd magick mismatch fd=%p", fd); #endif g_assert(fd->magick == 0x12345678); fd->ref++; #ifdef DEBUG_FILEDATA - DEBUG_2("file_data_ref (%d): '%s' @ %s:%d", fd->ref, fd->path, file, line); + DEBUG_2("file_data_ref fd=%p (%d): '%s' @ %s:%d", fd, fd->ref, fd->path, file, line); #else - DEBUG_2("file_data_ref (%d): '%s'", fd->ref, fd->path); + DEBUG_2("file_data_ref fd=%p (%d): '%s'", fd, fd->ref, fd->path); #endif return fd; } @@ -558,17 +560,19 @@ void file_data_unref(FileData *fd) #endif { if (fd == NULL) return; -#ifdef DEBUG_FILEDATA if (fd->magick != 0x12345678) - DEBUG_0("fd magick mismatch @ %s:%d", file, line); +#ifdef DEBUG_FILEDATA + DEBUG_0("fd magick mismatch @ %s:%d fd=%p", file, line, fd); +#else + DEBUG_0("fd magick mismatch fd=%p", fd); #endif g_assert(fd->magick == 0x12345678); fd->ref--; #ifdef DEBUG_FILEDATA - DEBUG_2("file_data_unref (%d): '%s' @ %s:%d", fd->ref, fd->path, file, line); + DEBUG_2("file_data_unref fd=%p (%d): '%s' @ %s:%d", fd, fd->ref, fd->path, file, line); #else - DEBUG_2("file_data_unref (%d): '%s'", fd->ref, fd->path); + DEBUG_2("file_data_unref fd=%p (%d): '%s'", fd, fd->ref, fd->path); #endif if (fd->ref == 0) {