diff --git a/ChangeLog b/ChangeLog
index 41d0f83a30ad5fecd1b37e16e62033085cca191d..967ab80d2419d7f70cf481fe377207f88c4fad72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-15	Benedikt Meurer <benny@xfce.org>
+
+	* thunar/thunar-debug.{c,h}, thunar/Makefile.am: Add THUNAR_DEBUG_MARK()
+	  which can be used to easily profile parts of Thunar.
+
 2006-03-15	Benedikt Meurer <benny@xfce.org>
 
 	* acinclude.m4(BM_THUNAR_VFS_VOLUME_IMPL): Handle "none" properly.
diff --git a/thunar/Makefile.am b/thunar/Makefile.am
index e7b901d9471b7932990b9c10ed1c97b6fc270b50..a8fe2984e27f821f08961ee644ef689614a28650 100644
--- a/thunar/Makefile.am
+++ b/thunar/Makefile.am
@@ -46,6 +46,8 @@ Thunar_SOURCES =							\
 	thunar-component.h						\
 	thunar-create-dialog.c						\
 	thunar-create-dialog.h						\
+	thunar-debug.h							\
+	thunar-debug.c							\
 	thunar-details-view-ui.h					\
 	thunar-details-view.c						\
 	thunar-details-view.h						\
diff --git a/thunar/thunar-debug.c b/thunar/thunar-debug.c
new file mode 100644
index 0000000000000000000000000000000000000000..c7bd22e3383f3dbdef8a22ae4e142ac79764b5af
--- /dev/null
+++ b/thunar/thunar-debug.c
@@ -0,0 +1,74 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <thunar/thunar-debug.h>
+
+#if GLIB_CHECK_VERSION(2,8,0)
+#include <glib/gstdio.h>
+#else
+#define g_access(filename, mode) access((filename),(mode))
+#endif
+
+
+
+/**
+ * thunar_debug_mark:
+ * @file   : the filename.
+ * @line   : the line in @file.
+ * @format : the message format.
+ * @...    : the @format parameters.
+ *
+ * Sets a profile mark.
+ **/
+void
+thunar_debug_mark (const gchar *file,
+                   const gint   line,
+                   const gchar *format,
+                   ...)
+{
+#ifdef G_ENABLE_DEBUG
+  va_list args;
+  gchar  *formatted;
+  gchar  *message;
+
+  va_start (args, format);
+  formatted = g_strdup_vprintf (format, args);
+  va_end (args);
+
+  message = g_strdup_printf ("MARK: %s: %s:%d: %s", g_get_prgname(), file, line, formatted);
+
+  g_access (message, F_OK);
+
+  g_free (formatted);
+  g_free (message);
+#endif
+}
+
+
diff --git a/thunar/thunar-debug.h b/thunar/thunar-debug.h
new file mode 100644
index 0000000000000000000000000000000000000000..7b0c64ca717c64f2b00265578832bdab6b5cca97
--- /dev/null
+++ b/thunar/thunar-debug.h
@@ -0,0 +1,50 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __THUNAR_DEBUG_H__
+#define __THUNAR_DEBUG_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS;
+
+#if defined(G_ENABLE_DEBUG) && defined(G_HAVE_ISO_VARARGS)
+
+#define THUNAR_DEBUG_MARK(...)                          \
+G_STMT_START{                                           \
+  thunar_debug_mark (__FILE__, __LINE__, __VA_ARGS__);  \
+}G_STMT_END
+
+#else
+
+#define THUNAR_DEBUG_MARK(...)  \
+G_STMT_START{                   \
+  (void)0;                      \
+}G_STMT_END
+
+#endif
+
+void thunar_debug_mark (const gchar *file,
+                        const gint   line,
+                        const gchar *format,
+                        ...);
+
+G_END_DECLS;
+
+#endif /* !__THUNAR_DEBUG_H__ */