changeset 2113:cd964ad91212

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.
author Vladimir Nadvornik <nadvornik@suse.cz>
date Wed, 29 Aug 2012 23:27:52 +0200
parents 61a8f2feee49
children 8f1a6f05903c
files src/filedata.c
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Wed Aug 29 23:27:06 2012 +0200
+++ b/src/filedata.c	Wed Aug 29 23:27:52 2012 +0200
@@ -515,17 +515,19 @@
 #endif
 {
 	if (fd == NULL) return NULL;
+	if (fd->magick != 0x12345678)
 #ifdef DEBUG_FILEDATA
-	if (fd->magick != 0x12345678)
-		DEBUG_0("fd magick mismatch at %s:%d", file, line);
+		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 @@
 #endif
 {
 	if (fd == NULL) return;
+	if (fd->magick != 0x12345678)
 #ifdef DEBUG_FILEDATA
-	if (fd->magick != 0x12345678)
-		DEBUG_0("fd magick mismatch @ %s:%d", file, line);
+		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)
 		{