diff --git a/.gitattributes b/.gitattributes
index 52e9b6c8a2605bf6e7f80dca344014b6dcfdc175..9070bc6c7e59bc551dee116cb41159ceee7b1176 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -395,7 +395,6 @@ testfont binary
 /src/fsort_template.h foreign_ident
 /src/gc.c foreign_ident
 /src/gc.h foreign_ident
-/src/global.h foreign_ident
 /src/hashtable.c foreign_ident
 /src/hashtable.h foreign_ident
 /src/install-sh foreign_ident
@@ -786,7 +785,6 @@ testfont binary
 /src/pike_dlfcn.h foreign_ident
 /src/pike_embed.c foreign_ident
 /src/pike_embed.h foreign_ident
-/src/pike_error.h foreign_ident
 /src/pike_float.c foreign_ident
 /src/pike_float.h foreign_ident
 /src/pike_int_types.h foreign_ident
diff --git a/src/global.h b/src/global.h
index 2dda73d2ccadfb93ba25d3970a4154c3750434fa..7b7dbcf429d6a5c48e179b91376b5941fb2c9c66 100644
--- a/src/global.h
+++ b/src/global.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: global.h,v 1.120 2010/05/29 23:58:08 mast Exp $
+|| $Id$
 */
 
 #ifndef GLOBAL_H
@@ -505,12 +505,40 @@ typedef struct p_wchar_p
 #endif
 
 #ifdef PIKE_DEBUG
+
 #define DO_IF_DEBUG(X) X
+#define DO_IF_DEBUG_ELSE(DEBUG, NO_DEBUG) DEBUG
+
 #undef NDEBUG
-#else
+
+/* Set of macros to simplify passing __FILE__ and __LINE__ to
+ * functions only in debug mode. */
+#define DLOC			__FILE__, __LINE__
+#define COMMA_DLOC		, __FILE__, __LINE__
+#define DLOC_DECL		const char *dloc_file, int dloc_line
+#define COMMA_DLOC_DECL		, const char *dloc_file, int dloc_line
+#define DLOC_ARGS		dloc_file, dloc_line
+#define DLOC_PF(PRE, SUF)	PRE "%s:%d" SUF
+#define DLOC_ARGS_OPT		dloc_file, dloc_line
+#define COMMA_DLOC_ARGS_OPT	, dloc_file, dloc_line
+#define DLOC_ENABLED
+
+#else  /* !PIKE_DEBUG */
+
 #define DO_IF_DEBUG(X)
+#define DO_IF_DEBUG_ELSE(DEBUG, NO_DEBUG) NO_DEBUG
 #define NDEBUG
-#endif
+
+#define DLOC
+#define COMMA_DLOC
+#define DLOC_DECL
+#define COMMA_DLOC_DECL
+#define DLOC_ARGS		__FILE__, __LINE__
+#define DLOC_PF(PRE, SUF)
+#define DLOC_ARGS_OPT
+#define COMMA_DLOC_ARGS_OPT
+
+#endif	/* !PIKE_DEBUG */
 
 #if defined (PIKE_DEBUG) || defined (DO_PIKE_CLEANUP)
 #define DO_IF_DEBUG_OR_CLEANUP(X) X
diff --git a/src/pike_error.h b/src/pike_error.h
index 570981da926717668b8b1908a6015cf41f4b0891..adf606d202b0e6c8e04734fa091a5a0e858d14f0 100644
--- a/src/pike_error.h
+++ b/src/pike_error.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: pike_error.h,v 1.56 2010/09/27 17:05:57 grubba Exp $
+|| $Id$
 */
 
 #ifndef PIKE_ERROR_H
@@ -59,6 +59,9 @@ PMOD_EXPORT extern const char msg_fatal_error[];
  (fprintf(stderr,"%s: Fatal error:\n",__FILE__ ":" DEFINETOSTR(__LINE__) ),debug_fatal)
 #endif
 
+#define pike_fatal_dloc							\
+ (fprintf (stderr, msg_fatal_error, DLOC_ARGS), debug_fatal)
+
 #ifndef NO_PIKE_SHORTHAND
 #define fatal Pike_fatal
 #endif