diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c
index b3935fb187d00583740ce18dfac2661210a563ea..6c01809390add6a179b4642af36741f158aa2bc1 100644
--- a/servers/slapd/back-bdb/add.c
+++ b/servers/slapd/back-bdb/add.c
@@ -52,7 +52,7 @@ bdb_add(Operation *op, SlapReply *rs )
 	LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
 	int num_ctrls = 0;
 
-	Debug(LDAP_DEBUG_ARGS, "==> bdb_add: %s\n",
+	Debug(LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(bdb_add) ": %s\n",
 		op->oq_add.rs_e->e_name.bv_val, 0, 0);
 
 	ctrls[num_ctrls] = 0;
@@ -62,8 +62,8 @@ bdb_add(Operation *op, SlapReply *rs )
 		NULL, &rs->sr_text, textbuf, textlen );
 	if ( rs->sr_err != LDAP_SUCCESS ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_add: entry failed schema check: %s (%d)\n",
-			rs->sr_text, rs->sr_err, 0 );
+			LDAP_XSTRING(bdb_add) ": entry failed schema check: "
+			"%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
 		goto return_results;
 	}
 
@@ -78,7 +78,8 @@ bdb_add(Operation *op, SlapReply *rs )
 	rs->sr_err = bdb_next_id( op->o_bd, NULL, &op->oq_add.rs_e->e_id );
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_add: next_id failed (%d)\n", rs->sr_err, 0, 0 );
+			LDAP_XSTRING(bdb_add) ": next_id failed (%d)\n",
+			rs->sr_err, 0, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
 		goto return_results;
@@ -110,7 +111,7 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_add: txn_begin failed: %s (%d)\n",
+			LDAP_XSTRING(bdb_add) ": txn_begin failed: %s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
@@ -166,8 +167,9 @@ retry:	/* transaction retry */
 				: NULL;
 			bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
 			p = NULL;
-			Debug( LDAP_DEBUG_TRACE, "bdb_add: parent does not exist\n",
-				0, 0, 0 );
+			Debug( LDAP_DEBUG_TRACE,
+				LDAP_XSTRING(bdb_add) ": parent "
+				"does not exist\n", 0, 0, 0 );
 
 			rs->sr_err = LDAP_REFERRAL;
 			send_ldap_result( op, rs );
@@ -191,7 +193,8 @@ retry:	/* transaction retry */
 			}
 
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_add: no write access to parent\n", 0, 0, 0 );
+				LDAP_XSTRING(bdb_add) ": no write access "
+				"to parent\n", 0, 0, 0 );
 			rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 			rs->sr_text = "no write access to parent";
 			goto return_results;;
@@ -200,7 +203,8 @@ retry:	/* transaction retry */
 #ifdef BDB_SUBENTRIES
 		if ( is_entry_subentry( p ) ) {
 			/* parent is a subentry, don't allow add */
-			Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is subentry\n",
+			Debug( LDAP_DEBUG_TRACE,
+				LDAP_XSTRING(bdb_add) ": parent is subentry\n",
 				0, 0, 0 );
 			rs->sr_err = LDAP_OBJECT_CLASS_VIOLATION;
 			rs->sr_text = "parent is a subentry";
@@ -209,7 +213,8 @@ retry:	/* transaction retry */
 #endif
 		if ( is_entry_alias( p ) ) {
 			/* parent is an alias, don't allow add */
-			Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is alias\n",
+			Debug( LDAP_DEBUG_TRACE,
+				LDAP_XSTRING(bdb_add) ": parent is alias\n",
 				0, 0, 0 );
 			rs->sr_err = LDAP_ALIAS_PROBLEM;
 			rs->sr_text = "parent is an alias";
@@ -221,7 +226,8 @@ retry:	/* transaction retry */
 			rs->sr_matched = p->e_name.bv_val;
 			rs->sr_ref = get_entry_referrals( op, p );
 
-			Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is referral\n",
+			Debug( LDAP_DEBUG_TRACE,
+				LDAP_XSTRING(bdb_add) ": parent is referral\n",
 				0, 0, 0 );
 
 			rs->sr_err = LDAP_REFERRAL;
@@ -254,7 +260,8 @@ retry:	/* transaction retry */
 		if ((( !be_isroot( op ) && !be_shadow_update(op) )
 			|| pdn.bv_len > 0 ) && !is_entry_glue( op->oq_add.rs_e ))
 		{
-			Debug( LDAP_DEBUG_TRACE, "bdb_add: %s denied\n",
+			Debug( LDAP_DEBUG_TRACE,
+				LDAP_XSTRING(bdb_add) ": %s denied\n",
 				pdn.bv_len == 0 ? "suffix" : "entry at root",
 				0, 0 );
 			rs->sr_err = LDAP_NO_SUCH_OBJECT;
@@ -280,7 +287,8 @@ retry:	/* transaction retry */
 			goto retry;
 		}
 
-		Debug( LDAP_DEBUG_TRACE, "bdb_add: no write access to entry\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_add) ": no write access to entry\n",
 			0, 0, 0 );
 		rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 		rs->sr_text = "no write access to entry";
@@ -293,8 +301,8 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_add: txn_begin(2) failed: %s (%d)\n",
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			LDAP_XSTRING(bdb_add) ": txn_begin(2) failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
 		goto return_results;
@@ -303,7 +311,8 @@ retry:	/* transaction retry */
 	/* dn2id index */
 	rs->sr_err = bdb_dn2id_add( op, lt2, ei, op->oq_add.rs_e );
 	if ( rs->sr_err != 0 ) {
-		Debug( LDAP_DEBUG_TRACE, "bdb_add: dn2id_add failed: %s (%d)\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_add) ": dn2id_add failed: %s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 
 		switch( rs->sr_err ) {
@@ -322,7 +331,8 @@ retry:	/* transaction retry */
 	/* id2entry index */
 	rs->sr_err = bdb_id2entry_add( op->o_bd, lt2, op->oq_add.rs_e );
 	if ( rs->sr_err != 0 ) {
-		Debug( LDAP_DEBUG_TRACE, "bdb_add: id2entry_add failed\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_add) ": id2entry_add failed\n",
 			0, 0, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
@@ -338,7 +348,8 @@ retry:	/* transaction retry */
 	/* attribute indexes */
 	rs->sr_err = bdb_index_entry_add( op, lt2, op->oq_add.rs_e );
 	if ( rs->sr_err != LDAP_SUCCESS ) {
-		Debug( LDAP_DEBUG_TRACE, "bdb_add: index_entry_add failed\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_add) ": index_entry_add failed\n",
 			0, 0, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
@@ -377,7 +388,8 @@ retry:	/* transaction retry */
 			&slap_post_read_bv, postread_ctrl ) )
 		{
 			Debug( LDAP_DEBUG_TRACE,
-				"<=- bdb_add: post-read failed!\n", 0, 0, 0 );
+				"<=- " LDAP_XSTRING(bdb_add) ": post-read "
+				"failed!\n", 0, 0, 0 );
 			goto return_results;
 		}
 	}
@@ -421,7 +433,9 @@ retry:	/* transaction retry */
 				rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_ADD );
 				if ( rc ) {
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_add: persistent search failed (%d,%d)\n",
+						LDAP_XSTRING(bdb_add)
+						": persistent search failed "
+						"(%d,%d)\n",
 						rc, rs->sr_err, 0 );
 				}
 			}
@@ -439,13 +453,15 @@ retry:	/* transaction retry */
 	op->o_private = NULL;
 
 	if ( rs->sr_err != LDAP_SUCCESS ) {
-		Debug( LDAP_DEBUG_TRACE, "bdb_add: %s : %s (%d)\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_add) ": %s : %s (%d)\n",
 			rs->sr_text, db_strerror(rs->sr_err), rs->sr_err );
 		rs->sr_err = LDAP_OTHER;
 		goto return_results;
 	}
 
-	Debug(LDAP_DEBUG_TRACE, "bdb_add: added%s id=%08lx dn=\"%s\"\n",
+	Debug(LDAP_DEBUG_TRACE,
+		LDAP_XSTRING(bdb_add) ": added%s id=%08lx dn=\"%s\"\n",
 		op->o_noop ? " (no-op)" : "",
 		op->oq_add.rs_e->e_id, op->oq_add.rs_e->e_dn );
 
diff --git a/servers/slapd/back-bdb/bind.c b/servers/slapd/back-bdb/bind.c
index 3f4c558c852905eeb648b584d7a1aa13802200f7..9ebdfe7a86c5a55147f494f589baccff8db7fb4b 100644
--- a/servers/slapd/back-bdb/bind.c
+++ b/servers/slapd/back-bdb/bind.c
@@ -43,7 +43,8 @@ bdb_bind( Operation *op, SlapReply *rs )
 	DB_LOCK		lock;
 
 	Debug( LDAP_DEBUG_ARGS,
-		"==> bdb_bind: dn: %s\n", op->o_req_dn.bv_val, 0, 0);
+		"==> " LDAP_XSTRING(bdb_bind) ": dn: %s\n",
+		op->o_req_dn.bv_val, 0, 0);
 
 	/* allow noauth binds */
 	if ( op->oq_bind.rb_method == LDAP_AUTH_SIMPLE && be_isroot_pw( op )) {
diff --git a/servers/slapd/back-bdb/ctxcsn.c b/servers/slapd/back-bdb/ctxcsn.c
index 82e1f53259ae7983c53fce16c0483e9e0030324d..716ce8edbceb9fd7d2ca0949018dabf8f30b5593 100644
--- a/servers/slapd/back-bdb/ctxcsn.c
+++ b/servers/slapd/back-bdb/ctxcsn.c
@@ -157,7 +157,8 @@ bdb_csn_commit(
 		rs->sr_err = bdb_next_id( op->o_bd, tid, &ctxcsn_id );
 		if ( rs->sr_err != 0 ) {
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_add: next_id failed (%d)\n", rs->sr_err, 0, 0 );
+				"bdb_csn_commit: next_id failed (%d)\n",
+				rs->sr_err, 0, 0 );
 			rs->sr_err = LDAP_OTHER;
 			rs->sr_text = "internal error";
 			return BDB_CSN_ABORT;
diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c
index 0eb82f9304cb0a2b85168d76cbab7f6503496822..ef4c584d203a33a5c14c5ae2769e07a09a777acd 100644
--- a/servers/slapd/back-bdb/delete.c
+++ b/servers/slapd/back-bdb/delete.c
@@ -59,7 +59,7 @@ bdb_delete( Operation *op, SlapReply *rs )
 
 	ctrls[num_ctrls] = 0;
 
-	Debug( LDAP_DEBUG_ARGS, "==> bdb_delete: %s\n",
+	Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(bdb_delete) ": %s\n",
 		op->o_req_dn.bv_val, 0, 0 );
 
 	build_new_dn( &ctxcsn_ndn, &op->o_bd->be_nsuffix[0],
@@ -75,7 +75,8 @@ retry:	/* transaction retry */
 			bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p);
 			p = NULL;
 		}
-		Debug( LDAP_DEBUG_TRACE, "==> bdb_delete: retrying...\n",
+		Debug( LDAP_DEBUG_TRACE,
+			"==> " LDAP_XSTRING(bdb_delete) ": retrying...\n",
 			0, 0, 0 );
 		rs->sr_err = TXN_ABORT( ltid );
 		ltid = NULL;
@@ -98,8 +99,8 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_delete: txn_begin failed: %s (%d)\n",
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			LDAP_XSTRING(bdb_delete) ": txn_begin failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
 		goto return_results;
@@ -150,7 +151,7 @@ retry:	/* transaction retry */
 		BerVarray deref = NULL;
 
 		Debug( LDAP_DEBUG_ARGS,
-			"<=- bdb_delete: no such object %s\n",
+			"<=- " LDAP_XSTRING(bdb_delete) ": no such object %s\n",
 			op->o_req_dn.bv_val, 0, 0);
 
 		if ( matched != NULL ) {
@@ -211,8 +212,8 @@ retry:	/* transaction retry */
 	if ( pdn.bv_len != 0 ) {
 		if( p == NULL || !bvmatch( &pdn, &p->e_nname )) {
 			Debug( LDAP_DEBUG_TRACE,
-				"<=- bdb_delete: parent does not exist\n",
-				0, 0, 0);
+				"<=- " LDAP_XSTRING(bdb_delete) ": parent "
+				"does not exist\n", 0, 0, 0 );
 			rs->sr_err = LDAP_OTHER;
 			rs->sr_text = "could not locate parent of entry";
 			goto return_results;
@@ -230,8 +231,8 @@ retry:	/* transaction retry */
 			}
 
 			Debug( LDAP_DEBUG_TRACE,
-				"<=- bdb_delete: no write access to parent\n",
-				0, 0, 0 );
+				"<=- " LDAP_XSTRING(bdb_delete) ": no write "
+				"access to parent\n", 0, 0, 0 );
 			rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 			rs->sr_text = "no write access to parent";
 			goto return_results;
@@ -258,8 +259,9 @@ retry:	/* transaction retry */
 					}
 
 					Debug( LDAP_DEBUG_TRACE,
-						"<=- bdb_delete: no access "
-						"to parent\n", 0, 0, 0 );
+						"<=- " LDAP_XSTRING(bdb_delete)
+						": no access to parent\n",
+						0, 0, 0 );
 					rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 					rs->sr_text = "no write access to parent";
 					goto return_results;
@@ -267,8 +269,8 @@ retry:	/* transaction retry */
 
 			} else {
 				Debug( LDAP_DEBUG_TRACE,
-					"<=- bdb_delete: no parent "
-					"and not root\n", 0, 0, 0);
+					"<=- " LDAP_XSTRING(bdb_delete)
+					": no parent and not root\n", 0, 0, 0 );
 				rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 				goto return_results;
 			}
@@ -293,8 +295,8 @@ retry:	/* transaction retry */
 		}
 
 		Debug( LDAP_DEBUG_TRACE,
-			"<=- bdb_delete: no write access to entry\n",
-			0, 0, 0 );
+			"<=- " LDAP_XSTRING(bdb_delete) ": no write access "
+			"to entry\n", 0, 0, 0 );
 		rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 		rs->sr_text = "no write access to entry";
 		goto return_results;
@@ -305,7 +307,8 @@ retry:	/* transaction retry */
 		rs->sr_ref = get_entry_referrals( op, e );
 
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_delete: entry is referral\n", 0, 0, 0 );
+			LDAP_XSTRING(bdb_delete) ": entry is referral\n",
+			0, 0, 0 );
 
 		rs->sr_err = LDAP_REFERRAL;
 		rs->sr_matched = e->e_name.bv_val;
@@ -329,7 +332,8 @@ retry:	/* transaction retry */
 			&slap_pre_read_bv, preread_ctrl ) )
 		{
 			Debug( LDAP_DEBUG_TRACE,
-				"<=- bdb_delete: pre-read failed!\n", 0, 0, 0 );
+				"<=- " LDAP_XSTRING(bdb_delete) ": pre-read "
+				"failed!\n", 0, 0, 0 );
 			goto return_results;
 		}
 	}
@@ -340,8 +344,8 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_delete: txn_begin(2) failed: %s (%d)\n",
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			LDAP_XSTRING(bdb_delete) ": txn_begin(2) failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
 		goto return_results;
@@ -356,14 +360,16 @@ retry:	/* transaction retry */
 			goto retry;
 		case 0:
 			Debug(LDAP_DEBUG_ARGS,
-				"<=- bdb_delete: non-leaf %s\n",
+				"<=- " LDAP_XSTRING(bdb_delete)
+				": non-leaf %s\n",
 				op->o_req_dn.bv_val, 0, 0);
 			rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
 			rs->sr_text = "subtree delete not supported";
 			break;
 		default:
 			Debug(LDAP_DEBUG_ARGS,
-				"<=- bdb_delete: has_children failed: %s (%d)\n",
+				"<=- " LDAP_XSTRING(bdb_delete)
+				": has_children failed: %s (%d)\n",
 				db_strerror(rs->sr_err), rs->sr_err, 0 );
 			rs->sr_err = LDAP_OTHER;
 			rs->sr_text = "internal error";
@@ -379,8 +385,8 @@ retry:	/* transaction retry */
 			goto retry;
 		} else if ( rc ) {
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_delete: persistent search failed (%d,%d)\n",
-				rc, rs->sr_err, 0 );
+				LDAP_XSTRING(bdb_delete) ": persistent search "
+				"failed (%d,%d)\n", rc, rs->sr_err, 0 );
 		}
 	}
 	ldap_pvt_thread_rdwr_wunlock( &bdb->bi_pslist_rwlock );
@@ -389,8 +395,8 @@ retry:	/* transaction retry */
 	rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e );
 	if ( rs->sr_err != 0 ) {
 		Debug(LDAP_DEBUG_TRACE,
-			"<=- bdb_delete: dn2id failed: %s (%d)\n",
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			"<=- " LDAP_XSTRING(bdb_delete) ": dn2id failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
 		case DB_LOCK_NOTGRANTED:
@@ -405,8 +411,8 @@ retry:	/* transaction retry */
 	rs->sr_err = bdb_id2entry_delete( op->o_bd, lt2, e );
 	if ( rs->sr_err != 0 ) {
 		Debug(LDAP_DEBUG_TRACE,
-			"<=- bdb_delete: id2entry failed: %s (%d)\n",
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			"<=- " LDAP_XSTRING(bdb_delete) ": id2entry failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
 		case DB_LOCK_NOTGRANTED:
@@ -421,8 +427,8 @@ retry:	/* transaction retry */
 	rs->sr_err = bdb_index_entry_del( op, lt2, e );
 	if ( rs->sr_err != LDAP_SUCCESS ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"<=- bdb_delete: index failed: %s (%d)\n", 
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			"<=- " LDAP_XSTRING(bdb_delete) ": index failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
 		case DB_LOCK_NOTGRANTED:
@@ -445,7 +451,8 @@ retry:	/* transaction retry */
 				break;
 			default:
 				Debug(LDAP_DEBUG_ARGS,
-					"<=- bdb_delete: has_children failed: %s (%d)\n",
+					"<=- " LDAP_XSTRING(bdb_delete)
+					": has_children failed: %s (%d)\n",
 					db_strerror(rs->sr_err), rs->sr_err, 0 );
 				rs->sr_err = LDAP_OTHER;
 				rs->sr_text = "internal error";
@@ -528,7 +535,9 @@ retry:	/* transaction retry */
 				rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_DELETE );
 				if ( rc ) {
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_delete: persistent search failed (%d,%d)\n",
+						LDAP_XSTRING(bdb_delete)
+						": persistent search failed "
+						"(%d,%d)\n",
 						rc, rs->sr_err, 0 );
 				}
 			}
@@ -542,7 +551,7 @@ retry:	/* transaction retry */
 
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_delete: txn_%s failed: %s (%d)\n",
+			LDAP_XSTRING(bdb_delete) ": txn_%s failed: %s (%d)\n",
 			op->o_noop ? "abort (no-op)" : "commit",
 			db_strerror(rs->sr_err), rs->sr_err );
 		rs->sr_err = LDAP_OTHER;
@@ -552,7 +561,7 @@ retry:	/* transaction retry */
 	}
 
 	Debug( LDAP_DEBUG_TRACE,
-		"bdb_delete: deleted%s id=%08lx dn=\"%s\"\n",
+		LDAP_XSTRING(bdb_delete) ": deleted%s id=%08lx dn=\"%s\"\n",
 		op->o_noop ? " (no-op)" : "",
 		eid, op->o_req_dn.bv_val );
 	rs->sr_err = LDAP_SUCCESS;
diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c
index 5042bfa3d5680904ad766f5028f0da500749981d..e60bc0262b6bc4b1b985491bdab424d087e463bf 100644
--- a/servers/slapd/back-bdb/init.c
+++ b/servers/slapd/back-bdb/init.c
@@ -67,8 +67,8 @@ bdb_db_init( BackendDB *be )
 	struct bdb_info	*bdb;
 
 	Debug( LDAP_DEBUG_ANY,
-		"bdb_db_init: Initializing %s database\n",
-		be->bd_info->bi_type, 0, 0 );
+		LDAP_XSTRING(bdb_db_init) ": Initializing "
+		BDB_UCTYPE " database\n", 0, 0, 0 );
 
 	/* allocate backend-database-specific stuff */
 	bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
@@ -545,8 +545,9 @@ bdb_back_initialize(
 	};
 
 	/* initialize the underlying database system */
-	Debug( LDAP_DEBUG_TRACE, "bdb_back_initialize: initialize BDB backend\n",
-		0, 0, 0 );
+	Debug( LDAP_DEBUG_TRACE,
+		LDAP_XSTRING(bdb_back_initialize) ": initialize " 
+		BDB_UCTYPE " backend\n", 0, 0, 0 );
 
 	bi->bi_flags |=
 		SLAP_BFLAG_INCREMENT |
@@ -577,13 +578,14 @@ bdb_back_initialize(
 		if( ver < DB_VERSION_FULL )
 		{
 			Debug( LDAP_DEBUG_ANY,
-				"bdb_back_initialize: BDB library version mismatch:"
+				LDAP_XSTRING(bdb_back_initialize) ": "
+				"BDB library version mismatch:"
 				" expected " DB_VERSION_STRING ","
 				" got %s\n", version, 0, 0 );
 		}
 
-		Debug( LDAP_DEBUG_ANY, "bdb_back_initialize: %s\n",
-			version, 0, 0 );
+		Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_back_initialize)
+			": %s\n", version, 0, 0 );
 	}
 
 	db_env_set_func_free( ber_memfree );
diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c
index 07a9740813c522040997da9a5516b6c13e3e8e0e..a50bbea983b57b15b9d422e186f96b8f76b607ba 100644
--- a/servers/slapd/back-bdb/modify.c
+++ b/servers/slapd/back-bdb/modify.c
@@ -289,7 +289,7 @@ bdb_modify( Operation *op, SlapReply *rs )
 	Entry		*ctxcsn_e;
 	int			ctxcsn_added = 0;
 
-	Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n",
+	Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(bdb_modify) ": %s\n",
 		op->o_req_dn.bv_val, 0, 0 );
 
 	ctrls[num_ctrls] = NULL;
@@ -305,7 +305,7 @@ retry:	/* transaction retry */
 			e = NULL;
 		}
 		Debug(LDAP_DEBUG_TRACE,
-			"bdb_modify: retrying...\n", 0, 0, 0);
+			LDAP_XSTRING(bdb_modify) ": retrying...\n", 0, 0, 0);
 
 		pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
 		while ( pm_list != NULL ) {
@@ -334,8 +334,8 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modify: txn_begin failed: %s (%d)\n",
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			LDAP_XSTRING(bdb_modify) ": txn_begin failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
 		goto return_results;
@@ -356,7 +356,7 @@ retry:	/* transaction retry */
 
 	if ( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modify: dn2entry failed (%d)\n",
+			LDAP_XSTRING(bdb_modify) ": dn2entry failed (%d)\n",
 			rs->sr_err, 0, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
@@ -425,7 +425,7 @@ retry:	/* transaction retry */
 		rs->sr_ref = get_entry_referrals( op, e );
 
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modify: entry is referral\n",
+			LDAP_XSTRING(bdb_modify) ": entry is referral\n",
 			0, 0, 0 );
 
 		rs->sr_err = LDAP_REFERRAL;
@@ -454,7 +454,8 @@ retry:	/* transaction retry */
 				goto retry;
 			} else if ( rc ) {
 				Debug( LDAP_DEBUG_TRACE,
-					"bdb_modify: persistent search failed (%d,%d)\n",
+					LDAP_XSTRING(bdb_modify)
+					": persistent search failed (%d,%d)\n",
 					rc, rs->sr_err, 0 );
 			}
 		}
@@ -470,7 +471,8 @@ retry:	/* transaction retry */
 			&slap_pre_read_bv, preread_ctrl ) )
 		{
 			Debug( LDAP_DEBUG_TRACE,
-				"<=- bdb_modify: pre-read failed!\n", 0, 0, 0 );
+				"<=- " LDAP_XSTRING(bdb_modify)
+				": pre-read failed!\n", 0, 0, 0 );
 			goto return_results;
 		}
 	}
@@ -481,7 +483,8 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modify: txn_begin(2) failed: %s (%d)\n",
+			LDAP_XSTRING(bdb_modify) ": txn_begin(2) failed: "
+			"%s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
@@ -494,7 +497,7 @@ retry:	/* transaction retry */
 
 	if( rs->sr_err != LDAP_SUCCESS ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modify: modify failed (%d)\n",
+			LDAP_XSTRING(bdb_modify) ": modify failed (%d)\n",
 			rs->sr_err, 0, 0 );
 		if ( (rs->sr_err == LDAP_INSUFFICIENT_ACCESS) && opinfo.boi_err ) {
 			rs->sr_err = opinfo.boi_err;
@@ -513,8 +516,8 @@ retry:	/* transaction retry */
 	rs->sr_err = bdb_id2entry_update( op->o_bd, lt2, &dummy );
 	if ( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modify: id2entry update failed (%d)\n",
-			rs->sr_err, 0, 0 );
+			LDAP_XSTRING(bdb_modify) ": id2entry update failed "
+			"(%d)\n", rs->sr_err, 0, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
 		case DB_LOCK_NOTGRANTED:
@@ -550,7 +553,8 @@ retry:	/* transaction retry */
 			&slap_post_read_bv, postread_ctrl ) )
 		{
 			Debug( LDAP_DEBUG_TRACE,
-				"<=- bdb_modify: post-read failed!\n", 0, 0, 0 );
+				"<=- " LDAP_XSTRING(bdb_modify)
+				": post-read failed!\n", 0, 0, 0 );
 			goto return_results;
 		}
 	}
@@ -585,7 +589,9 @@ retry:	/* transaction retry */
 				rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
 				if ( rc ) {
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_modify: persistent search failed (%d,%d)\n",
+						LDAP_XSTRING(bdb_modify)
+						": persistent search failed "
+						"(%d,%d)\n",
 						rc, rs->sr_err, 0 );
 				}
 			}
@@ -595,7 +601,9 @@ retry:	/* transaction retry */
 							e, LDAP_PSEARCH_BY_SCOPEOUT);
 				if ( rc ) {
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_modify: persistent search failed (%d,%d)\n",
+						LDAP_XSTRING(bdb_modify)
+						": persistent search failed "
+						"(%d,%d)\n",
 						rc, rs->sr_err, 0 );
 				}
 				LDAP_LIST_REMOVE ( pm_list, ps_link );
@@ -613,7 +621,7 @@ retry:	/* transaction retry */
 
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modify: txn_%s failed: %s (%d)\n",
+			LDAP_XSTRING(bdb_modify) ": txn_%s failed: %s (%d)\n",
 			op->o_noop ? "abort (no-op)" : "commit",
 			db_strerror(rs->sr_err), rs->sr_err );
 		rs->sr_err = LDAP_OTHER;
@@ -623,7 +631,7 @@ retry:	/* transaction retry */
 	}
 
 	Debug( LDAP_DEBUG_TRACE,
-		"bdb_modify: updated%s id=%08lx dn=\"%s\"\n",
+		LDAP_XSTRING(bdb_modify) ": updated%s id=%08lx dn=\"%s\"\n",
 		op->o_noop ? " (no-op)" : "",
 		dummy.e_id, op->o_req_dn.bv_val );
 
diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c
index a85ca3faef147779f86bf78d225fde0c763bc436..bd63b054d0b37897a3c200f271fad0e44ce00481 100644
--- a/servers/slapd/back-bdb/modrdn.c
+++ b/servers/slapd/back-bdb/modrdn.c
@@ -76,7 +76,7 @@ bdb_modrdn( Operation	*op, SlapReply *rs )
 
 	ctrls[num_ctrls] = NULL;
 
-	Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn(%s,%s,%s)\n",
+	Debug( LDAP_DEBUG_TRACE, "==>" LDAP_XSTRING(bdb_modrdn) "(%s,%s,%s)\n",
 		op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
 		op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" );
 
@@ -98,7 +98,8 @@ retry:	/* transaction retry */
 			bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, np);
 			np = NULL;
 		}
-		Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 );
+		Debug( LDAP_DEBUG_TRACE, "==>" LDAP_XSTRING(bdb_modrdn)
+				": retrying...\n", 0, 0, 0 );
 		pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
 		while ( pm_list != NULL ) {
 			LDAP_LIST_REMOVE ( pm_list, ps_link );
@@ -128,8 +129,8 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_delete: txn_begin failed: %s (%d)\n",
-			db_strerror(rs->sr_err), rs->sr_err, 0 );
+			LDAP_XSTRING(bdb_modrdn) ": txn_begin failed: "
+			"%s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
 		goto return_results;
@@ -239,14 +240,16 @@ retry:	/* transaction retry */
 			goto retry;
 		case 0:
 			Debug(LDAP_DEBUG_ARGS,
-				"<=- bdb_modrdn: non-leaf %s\n",
+				"<=- " LDAP_XSTRING(bdb_modrdn)
+				": non-leaf %s\n",
 				op->o_req_dn.bv_val, 0, 0);
 			rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
 			rs->sr_text = "subtree rename not supported";
 			break;
 		default:
 			Debug(LDAP_DEBUG_ARGS,
-				"<=- bdb_modrdn: has_children failed: %s (%d)\n",
+				"<=- " LDAP_XSTRING(bdb_modrdn)
+				": has_children failed: %s (%d)\n",
 				db_strerror(rs->sr_err), rs->sr_err, 0 );
 			rs->sr_err = LDAP_OTHER;
 			rs->sr_text = "internal error";
@@ -260,8 +263,8 @@ retry:	/* transaction retry */
 		/* parent is a referral, don't allow add */
 		rs->sr_ref = get_entry_referrals( op, e );
 
-		Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
-			e->e_dn, 0, 0 );
+		Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn)
+			": entry %s is referral\n", e->e_dn, 0, 0 );
 
 		rs->sr_err = LDAP_REFERRAL,
 		rs->sr_matched = e->e_name.bv_val;
@@ -305,8 +308,8 @@ retry:	/* transaction retry */
 
 		p = eip->bei_e;
 		if( p == NULL) {
-			Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: parent does not exist\n",
-				0, 0, 0);
+			Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn)
+				": parent does not exist\n", 0, 0, 0);
 			rs->sr_err = LDAP_OTHER;
 			rs->sr_text = "old entry's parent does not exist";
 			goto return_results;
@@ -331,8 +334,8 @@ retry:	/* transaction retry */
 		}
 
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modrdn: wr to children of entry %s OK\n",
-			p_ndn.bv_val, 0, 0 );
+			LDAP_XSTRING(bdb_modrdn) ": wr to children "
+			"of entry %s OK\n", p_ndn.bv_val, 0, 0 );
 		
 		if ( p_ndn.bv_val == slap_empty_bv.bv_val ) {
 			p_dn = slap_empty_bv;
@@ -341,7 +344,7 @@ retry:	/* transaction retry */
 		}
 
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modrdn: parent dn=%s\n",
+			LDAP_XSTRING(bdb_modrdn) ": parent dn=%s\n",
 			p_dn.bv_val, 0, 0 );
 
 	} else {
@@ -375,19 +378,22 @@ retry:	/* transaction retry */
 				}
 
 				Debug( LDAP_DEBUG_TRACE,
-					"bdb_modrdn: wr to children of entry \"\" OK\n",
+					LDAP_XSTRING(bdb_modrdn)
+					": wr to children of entry \"\" OK\n",
 					0, 0, 0 );
 		
 				p_dn.bv_val = "";
 				p_dn.bv_len = 0;
 
 				Debug( LDAP_DEBUG_TRACE,
-					"bdb_modrdn: parent dn=\"\"\n",
+					LDAP_XSTRING(bdb_modrdn)
+					": parent dn=\"\"\n",
 					0, 0, 0 );
 
 			} else {
 				Debug( LDAP_DEBUG_TRACE,
-					"bdb_modrdn: no parent, not root "
+					LDAP_XSTRING(bdb_modrdn)
+					": no parent, not root "
 					"& \"\" is not suffix\n",
 					0, 0, 0);
 				rs->sr_text = "no write access to old parent";
@@ -401,7 +407,8 @@ retry:	/* transaction retry */
 
 	if ( op->oq_modrdn.rs_newSup != NULL ) {
 		Debug( LDAP_DEBUG_TRACE, 
-			"bdb_modrdn: new parent \"%s\" requested...\n",
+			LDAP_XSTRING(bdb_modrdn)
+			": new parent \"%s\" requested...\n",
 			op->oq_modrdn.rs_newSup->bv_val, 0, 0 );
 
 		/*  newSuperior == oldParent? */
@@ -443,7 +450,8 @@ retry:	/* transaction retry */
 
 			if( np == NULL) {
 				Debug( LDAP_DEBUG_TRACE,
-					"bdb_modrdn: newSup(ndn=%s) not here!\n",
+					LDAP_XSTRING(bdb_modrdn)
+					": newSup(ndn=%s) not here!\n",
 					np_ndn->bv_val, 0, 0);
 				rs->sr_text = "new superior not found";
 				rs->sr_err = LDAP_OTHER;
@@ -451,7 +459,8 @@ retry:	/* transaction retry */
 			}
 
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_modrdn: wr to new parent OK np=%p, id=%ld\n",
+				LDAP_XSTRING(bdb_modrdn)
+				": wr to new parent OK np=%p, id=%ld\n",
 				(void *) np, (long) np->e_id, 0 );
 
 			/* check newSuperior for "children" acl */
@@ -466,7 +475,8 @@ retry:	/* transaction retry */
 				}
 
 				Debug( LDAP_DEBUG_TRACE,
-					"bdb_modrdn: no wr to newSup children\n",
+					LDAP_XSTRING(bdb_modrdn)
+					": no wr to newSup children\n",
 					0, 0, 0 );
 				rs->sr_text = "no write access to new superior's children";
 				rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
@@ -475,7 +485,9 @@ retry:	/* transaction retry */
 
 			if ( is_entry_alias( np ) ) {
 				/* parent is an alias, don't allow add */
-				Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is alias\n",
+				Debug( LDAP_DEBUG_TRACE,
+					LDAP_XSTRING(bdb_modrdn)
+					": entry is alias\n",
 					0, 0, 0 );
 				rs->sr_text = "new superior is an alias";
 				rs->sr_err = LDAP_ALIAS_PROBLEM;
@@ -484,7 +496,9 @@ retry:	/* transaction retry */
 
 			if ( is_entry_referral( np ) ) {
 				/* parent is a referral, don't allow add */
-				Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry is referral\n",
+				Debug( LDAP_DEBUG_TRACE,
+					LDAP_XSTRING(bdb_modrdn)
+					": entry is referral\n",
 					0, 0, 0 );
 				rs->sr_text = "new superior is a referral";
 				rs->sr_err = LDAP_OTHER;
@@ -527,14 +541,17 @@ retry:	/* transaction retry */
 					}
 
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_modrdn: wr to children of entry \"\" OK\n",
+						LDAP_XSTRING(bdb_modrdn)
+						": wr to children "
+						"of entry \"\" OK\n",
 						0, 0, 0 );
 		
 				} else {
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_modrdn: new superior=\"\", not root "
+						LDAP_XSTRING(bdb_modrdn)
+						": new superior=\"\", not root "
 						"& \"\" is not suffix\n",
-						0, 0, 0);
+						0, 0, 0 );
 					rs->sr_text = "no write access to new superior's children";
 					rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
 					goto return_results;
@@ -542,12 +559,14 @@ retry:	/* transaction retry */
 			}
 
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_modrdn: new superior=\"\"\n",
+				LDAP_XSTRING(bdb_modrdn)
+				": new superior=\"\"\n",
 				0, 0, 0 );
 		}
 
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modrdn: wr to new parent's children OK\n",
+			LDAP_XSTRING(bdb_modrdn)
+			": wr to new parent's children OK\n",
 			0, 0, 0 );
 
 		new_parent_dn = np_dn;
@@ -564,7 +583,7 @@ retry:	/* transaction retry */
 		ber_dupbv( &new_ndn, &bv );
 	}
 
-	Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new ndn=%s\n",
+	Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_modrdn) ": new ndn=%s\n",
 		new_ndn.bv_val, 0, 0 );
 
 	/* Shortcut the search */
@@ -593,7 +612,7 @@ retry:	/* transaction retry */
 		(char **)&rs->sr_text, LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
 	{
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modrdn: can't figure out "
+			LDAP_XSTRING(bdb_modrdn) ": can't figure out "
 			"type(s)/values(s) of newrdn\n", 
 			0, 0, 0 );
 		rs->sr_err = LDAP_INVALID_DN_SYNTAX;
@@ -602,15 +621,17 @@ retry:	/* transaction retry */
 	}
 
 	Debug( LDAP_DEBUG_TRACE,
-		"bdb_modrdn: new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
-		new_rdn[ 0 ]->la_attr.bv_val, new_rdn[ 0 ]->la_value.bv_val, 0 );
+		LDAP_XSTRING(bdb_modrdn)
+		": new_rdn_type=\"%s\", new_rdn_val=\"%s\"\n",
+		new_rdn[ 0 ]->la_attr.bv_val,
+		new_rdn[ 0 ]->la_value.bv_val, 0 );
 
 	if ( op->oq_modrdn.rs_deleteoldrdn ) {
 		if ( !old_rdn && ldap_bv2rdn_x( &op->o_req_dn, &old_rdn,
 			(char **)&rs->sr_text, LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) )
 		{
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_modrdn: can't figure out "
+				LDAP_XSTRING(bdb_modrdn) ": can't figure out "
 				"the old_rdn type(s)/value(s)\n", 
 				0, 0, 0 );
 			rs->sr_err = LDAP_OTHER;
@@ -636,7 +657,8 @@ retry:	/* transaction retry */
 			&slap_pre_read_bv, preread_ctrl ) )
 		{
 			Debug( LDAP_DEBUG_TRACE,        
-				"<=- bdb_modrdn: post-read failed!\n", 0, 0, 0 );
+				"<=- " LDAP_XSTRING(bdb_modrdn)
+				": post-read failed!\n", 0, 0, 0 );
 			goto return_results;
 		}                   
 	}
@@ -646,7 +668,8 @@ retry:	/* transaction retry */
 	rs->sr_text = NULL;
 	if( rs->sr_err != 0 ) {
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_modrdn: txn_begin(2) failed: %s (%d)\n",
+			LDAP_XSTRING(bdb_modrdn)
+			": txn_begin(2) failed: %s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 		rs->sr_err = LDAP_OTHER;
 		rs->sr_text = "internal error";
@@ -657,7 +680,8 @@ retry:	/* transaction retry */
 	rs->sr_err = bdb_dn2id_delete( op, lt2, eip, e );
 	if ( rs->sr_err != 0 ) {
 		Debug(LDAP_DEBUG_TRACE,
-			"<=- bdb_modrdn: dn2id del failed: %s (%d)\n",
+			"<=- " LDAP_XSTRING(bdb_modrdn)
+			": dn2id del failed: %s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
@@ -679,7 +703,8 @@ retry:	/* transaction retry */
 	rs->sr_err = bdb_dn2id_add( op, lt2, neip ? neip : eip, &dummy );
 	if ( rs->sr_err != 0 ) {
 		Debug(LDAP_DEBUG_TRACE,
-			"<=- bdb_modrdn: dn2id add failed: %s (%d)\n",
+			"<=- " LDAP_XSTRING(bdb_modrdn)
+			": dn2id add failed: %s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
@@ -699,7 +724,8 @@ retry:	/* transaction retry */
 			rc = bdb_psearch( op, rs, ps_list, &dummy, LDAP_PSEARCH_BY_PREMODIFY );
 			if ( rc ) {
 				Debug( LDAP_DEBUG_TRACE,
-					"bdb_modrdn: persistent search failed (%d,%d)\n",
+					LDAP_XSTRING(bdb_modrdn)
+					": persistent search failed (%d,%d)\n",
 					rc, rs->sr_err, 0 );
 			}
 		}
@@ -712,7 +738,8 @@ retry:	/* transaction retry */
 		&rs->sr_text, textbuf, textlen );
 	if( rs->sr_err != LDAP_SUCCESS ) {
 		Debug(LDAP_DEBUG_TRACE,
-			"<=- bdb_modrdn: modify failed: %s (%d)\n",
+			"<=- " LDAP_XSTRING(bdb_modrdn)
+			": modify failed: %s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 		if ( ( rs->sr_err == LDAP_INSUFFICIENT_ACCESS ) && opinfo.boi_err ) {
 			rs->sr_err = opinfo.boi_err;
@@ -730,7 +757,8 @@ retry:	/* transaction retry */
 	rs->sr_err = bdb_id2entry_update( op->o_bd, lt2, &dummy );
 	if ( rs->sr_err != 0 ) {
 		Debug(LDAP_DEBUG_TRACE,
-			"<=- bdb_modrdn: id2entry failed: %s (%d)\n",
+			"<=- " LDAP_XSTRING(bdb_modrdn)
+			": id2entry failed: %s (%d)\n",
 			db_strerror(rs->sr_err), rs->sr_err, 0 );
 		switch( rs->sr_err ) {
 		case DB_LOCK_DEADLOCK:
@@ -754,7 +782,8 @@ retry:	/* transaction retry */
 				break;
 			default:
 				Debug(LDAP_DEBUG_ARGS,
-					"<=- bdb_modrdn: has_children failed: %s (%d)\n",
+					"<=- " LDAP_XSTRING(bdb_modrdn)
+					": has_children failed: %s (%d)\n",
 					db_strerror(rs->sr_err), rs->sr_err, 0 );
 				rs->sr_err = LDAP_OTHER;
 				rs->sr_text = "internal error";
@@ -792,7 +821,8 @@ retry:	/* transaction retry */
 			&slap_post_read_bv, postread_ctrl ) )
 		{
 			Debug( LDAP_DEBUG_TRACE,        
-				"<=- bdb_modrdn: post-read failed!\n", 0, 0, 0 );
+				"<=- " LDAP_XSTRING(bdb_modrdn)
+				": post-read failed!\n", 0, 0, 0 );
 			goto return_results;
 		}                   
 	}
@@ -831,7 +861,9 @@ retry:	/* transaction retry */
 				rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
 				if ( rc ) {
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_modrdn: persistent search failed (%d,%d)\n",
+						LDAP_XSTRING(bdb_modrdn)
+						": persistent search failed "
+						"(%d,%d)\n",
 						rc, rs->sr_err, 0 );
 			}
 			}
@@ -841,7 +873,9 @@ retry:	/* transaction retry */
 							e, LDAP_PSEARCH_BY_SCOPEOUT);
 				if ( rc ) {
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_modrdn: persistent search failed (%d,%d)\n",
+						LDAP_XSTRING(bdb_modrdn)
+						": persistent search failed "
+						"(%d,%d)\n",
 						rc, rs->sr_err, 0 );
 				}
 				pm_prev = pm_list;
@@ -863,7 +897,8 @@ retry:	/* transaction retry */
 	op->o_private = NULL;
  
 	if( rs->sr_err != LDAP_SUCCESS ) {
-		Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: %s : %s (%d)\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_modrdn) ": %s : %s (%d)\n",
 			rs->sr_text, db_strerror(rs->sr_err), rs->sr_err );
 		rs->sr_err = LDAP_OTHER;
 
@@ -871,7 +906,8 @@ retry:	/* transaction retry */
 	}
 
 	Debug(LDAP_DEBUG_TRACE,
-		"bdb_modrdn: rdn modified%s id=%08lx dn=\"%s\"\n",
+		LDAP_XSTRING(bdb_modrdn)
+		": rdn modified%s id=%08lx dn=\"%s\"\n",
 		op->o_noop ? " (no-op)" : "",
 		dummy.e_id, op->o_req_dn.bv_val );
 	rs->sr_text = NULL;
diff --git a/servers/slapd/back-bdb/operational.c b/servers/slapd/back-bdb/operational.c
index 5707cf4dbf840dfa90c6b3d0eb8633e5c5bf7fdb..7c4590e6c203aecfe72b3a3e78573217b36ffa06 100644
--- a/servers/slapd/back-bdb/operational.c
+++ b/servers/slapd/back-bdb/operational.c
@@ -70,7 +70,8 @@ retry:
 
 	default:
 		Debug(LDAP_DEBUG_ARGS, 
-			"<=- bdb_hasSubordinates: has_children failed: %s (%d)\n", 
+			"<=- " LDAP_XSTRING(bdb_hasSubordinates)
+			": has_children failed: %s (%d)\n", 
 			db_strerror(rc), rc, 0 );
 		rc = LDAP_OTHER;
 	}
diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h
index 980de38dbdb3e357499eb0108862a68eab0e55f8..7cc491647899d1e8d455001cb0b0e6f5dbeaca03 100644
--- a/servers/slapd/back-bdb/proto-bdb.h
+++ b/servers/slapd/back-bdb/proto-bdb.h
@@ -20,8 +20,10 @@ LDAP_BEGIN_DECL
 
 #ifdef BDB_HIER
 #define	BDB_SYMBOL(x)	LDAP_CONCAT(hdb_,x)
+#define BDB_UCTYPE	"HDB"
 #else
 #define BDB_SYMBOL(x)	LDAP_CONCAT(bdb_,x)
+#define BDB_UCTYPE	"BDB"
 #endif
 
 /*
diff --git a/servers/slapd/back-bdb/referral.c b/servers/slapd/back-bdb/referral.c
index aab9fe6dcfb8e2b776e20e2ad4e29b71911792ce..382feca3612339e2e314779246a6284905492a72 100644
--- a/servers/slapd/back-bdb/referral.c
+++ b/servers/slapd/back-bdb/referral.c
@@ -67,7 +67,8 @@ dn2entry_retry:
 		goto dn2entry_retry;
 	default:
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_referrals: dn2entry failed: %s (%d)\n",
+			LDAP_XSTRING(bdb_referrals)
+			": dn2entry failed: %s (%d)\n",
 			db_strerror(rc), rc, 0 ); 
 		send_ldap_error( op, rs, LDAP_OTHER, "internal error" );
 		LOCK_ID_FREE ( bdb->bi_dbenv, locker );
@@ -79,7 +80,8 @@ dn2entry_retry:
 		rs->sr_matched = NULL;
 		if ( e != NULL ) {
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
+				LDAP_XSTRING(bdb_referrals)
+				": op=%ld target=\"%s\" matched=\"%s\"\n",
 				(long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val );
 
 			if( is_entry_referral( e ) ) {
@@ -126,7 +128,8 @@ dn2entry_retry:
 			refs, &e->e_name, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
 
 		Debug( LDAP_DEBUG_TRACE,
-			"bdb_referrals: op=%ld target=\"%s\" matched=\"%s\"\n",
+			LDAP_XSTRING(bdb_referrals)
+			": op=%ld target=\"%s\" matched=\"%s\"\n",
 			(long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val );
 
 		rs->sr_matched = e->e_name.bv_val;
diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c
index e765b3a2de83006c3a639a3ba1e2fd39cb4a7ec6..182cbbd6732707568215c2854040a1bf5bb38f68 100644
--- a/servers/slapd/back-bdb/search.c
+++ b/servers/slapd/back-bdb/search.c
@@ -647,7 +647,7 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
 	struct	bdb_op_info	*opinfo = NULL;
 	DB_TXN			*ltid = NULL;
 
-	Debug( LDAP_DEBUG_TRACE, "=> bdb_search\n", 0, 0, 0);
+	Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_search) "\n", 0, 0, 0);
 	attrs = sop->oq_search.rs_attrs;
 
 	opinfo = (struct bdb_op_info *) op->o_private;
@@ -874,7 +874,8 @@ dn2entry_retry:
 			ber_bvarray_free( erefs );
 		}
 
-		Debug( LDAP_DEBUG_TRACE, "bdb_search: entry is referral\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_search) ": entry is referral\n",
 			0, 0, 0 );
 
 		if (!rs->sr_ref) rs->sr_text = "bad_referral object";
@@ -975,7 +976,8 @@ dn2entry_retry:
 	}
 
 	if ( candidates[0] == 0 ) {
-		Debug( LDAP_DEBUG_TRACE, "bdb_search: no candidates\n",
+		Debug( LDAP_DEBUG_TRACE,
+			LDAP_XSTRING(bdb_search) ": no candidates\n",
 			0, 0, 0 );
 
 		goto nochange;
@@ -1027,7 +1029,8 @@ dn2entry_retry:
 
 		if ( cursor == NOID ) {
 			Debug( LDAP_DEBUG_TRACE, 
-				"bdb_search: no paged results candidates\n",
+				LDAP_XSTRING(bdb_search)
+				": no paged results candidates\n",
 				0, 0, 0 );
 			send_paged_response( sop, rs, &lastid, 0 );
 
@@ -1219,7 +1222,8 @@ id2entry_retry:
 				} else if( !BDB_IDL_IS_RANGE(candidates) ) {
 					/* only complain for non-range IDLs */
 					Debug( LDAP_DEBUG_TRACE,
-						"bdb_search: candidate %ld not found\n",
+						LDAP_XSTRING(bdb_search)
+						": candidate %ld not found\n",
 						(long) id, 0, 0 );
 				}
 
@@ -1328,7 +1332,8 @@ id2entry_retry:
 		/* Not in scope, ignore it */
 		if ( !IS_POST_SEARCH && !scopeok ) {
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_search: %ld scope not okay\n",
+				LDAP_XSTRING(bdb_search)
+				": %ld scope not okay\n",
 				(long) id, 0, 0 );
 			goto loop_continue;
 		}
@@ -1377,7 +1382,7 @@ id2entry_retry:
 						if ( rc_sync == LDAP_COMPARE_TRUE ) {
 							if ( no_sync_state_change ) {
 								Debug( LDAP_DEBUG_TRACE,
-									"bdb_search: "
+									LDAP_XSTRING(bdb_search) ": "
 									"error in context csn management\n",
 									0, 0, 0 );
 							}
@@ -1528,7 +1533,8 @@ post_search_no_entry:
 
 					} else {
 						Debug( LDAP_DEBUG_TRACE,
-							"bdb_search: invalid ps_type (%d) \n",
+							LDAP_XSTRING(bdb_search)
+							": invalid ps_type (%d) \n",
 							ps_type, 0, 0);
 					}
 
@@ -1613,7 +1619,8 @@ post_search_no_entry:
 
 		} else {
 			Debug( LDAP_DEBUG_TRACE,
-				"bdb_search: %ld does not match filter\n",
+				LDAP_XSTRING(bdb_search)
+				": %ld does not match filter\n",
 				(long) id, 0, 0 );
 		}
 
diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c
index 0f4dcfcfd6667514a68cff700e938aa28d29cb00..54e0959407c2f21044aafb529a35e3f81891a38d 100644
--- a/servers/slapd/back-bdb/tools.c
+++ b/servers/slapd/back-bdb/tools.c
@@ -158,7 +158,8 @@ ID bdb_tool_dn2id_get(
 	rc = db->get( db, NULL, &key, &data, bdb->bi_db_opflags );
 
     if( rc != 0 ) {
-		Debug( LDAP_DEBUG_TRACE, "bdb_tool_dn2id_get: get failed: %s (%d)\n",
+		Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_tool_dn2id_get)
+				": get failed: %s (%d)\n",
 				db_strerror( rc ), rc, 0 );
 		id = NOID;
 	}
@@ -309,8 +310,8 @@ ID bdb_tool_entry_put(
 	assert( text->bv_val );
 	assert( text->bv_val[0] == '\0' );	/* overconservative? */
 
-	Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
-		(long) e->e_id, e->e_dn, 0 );
+	Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(bdb_tool_entry_put)
+		"( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 );
 
 	rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid, 
 		bdb->bi_db_opflags );
@@ -319,7 +320,7 @@ ID bdb_tool_entry_put(
 			"txn_begin failed: %s (%d)",
 			db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n",
+			"=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n",
 			 text->bv_val, 0, 0 );
 		return NOID;
 	}
@@ -341,7 +342,8 @@ ID bdb_tool_entry_put(
 				"id2entry_add failed: %s (%d)",
 				db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
+			"=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n",
+			text->bv_val, 0, 0 );
 		goto done;
 	}
 
@@ -352,7 +354,8 @@ ID bdb_tool_entry_put(
 				"index_entry_add failed: %s (%d)",
 				db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
+			"=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n",
+			text->bv_val, 0, 0 );
 		goto done;
 	}
 
@@ -364,7 +367,7 @@ done:
 					"txn_commit failed: %s (%d)",
 					db_strerror(rc), rc );
 			Debug( LDAP_DEBUG_ANY,
-				"=> bdb_tool_entry_put: %s\n",
+				"=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n",
 				text->bv_val, 0, 0 );
 			e->e_id = NOID;
 		}
@@ -375,7 +378,7 @@ done:
 			"txn_aborted! %s (%d)",
 			db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n",
+			"=> " LDAP_XSTRING(bdb_tool_entry_put) ": %s\n",
 			text->bv_val, 0, 0 );
 		e->e_id = NOID;
 	}
@@ -393,7 +396,8 @@ int bdb_tool_entry_reindex(
 	DB_TXN *tid = NULL;
 	Operation op = {0};
 
-	Debug( LDAP_DEBUG_ARGS, "=> bdb_tool_entry_reindex( %ld )\n",
+	Debug( LDAP_DEBUG_ARGS,
+		"=> " LDAP_XSTRING(bdb_tool_entry_reindex) "( %ld )\n",
 		(long) id, 0, 0 );
 
 	/* No indexes configured, nothing to do. Could return an
@@ -414,7 +418,8 @@ int bdb_tool_entry_reindex(
 
 	if( e == NULL ) {
 		Debug( LDAP_DEBUG_ANY,
-			"bdb_tool_entry_reindex:: could not locate id=%ld\n",
+			LDAP_XSTRING(bdb_tool_entry_reindex)
+			": could not locate id=%ld\n",
 			(long) id, 0, 0 );
 		return -1;
 	}
@@ -422,7 +427,8 @@ int bdb_tool_entry_reindex(
 	rc = TXN_BEGIN( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
 	if( rc != 0 ) {
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
+			"=> " LDAP_XSTRING(bdb_tool_entry_reindex) ": "
+			"txn_begin failed: %s (%d)\n",
 			db_strerror(rc), rc, 0 );
 		goto done;
 	}
@@ -434,7 +440,8 @@ int bdb_tool_entry_reindex(
 	 *
 	 */
 
-	Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n",
+	Debug( LDAP_DEBUG_TRACE,
+		"=> " LDAP_XSTRING(bdb_tool_entry_reindex) "( %ld, \"%s\" )\n",
 		(long) id, e->e_dn, 0 );
 
 	op.o_bd = be;
@@ -446,7 +453,8 @@ int bdb_tool_entry_reindex(
 	rc = bdb_dn2id_add( &op, tid, NULL, e );
 	if( rc != 0 && rc != DB_KEYEXIST ) {
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n",
+			"=> " LDAP_XSTRING(bdb_tool_entry_reindex)
+			": dn2id_add failed: %s (%d)\n",
 			db_strerror(rc), rc, 0 );
 		goto done;
 	}
@@ -459,7 +467,8 @@ done:
 		rc = TXN_COMMIT( tid, 0 );
 		if( rc != 0 ) {
 			Debug( LDAP_DEBUG_ANY,
-				"=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
+				"=> " LDAP_XSTRING(bdb_tool_entry_reindex)
+				": txn_commit failed: %s (%d)\n",
 				db_strerror(rc), rc, 0 );
 			e->e_id = NOID;
 		}
@@ -467,7 +476,8 @@ done:
 	} else {
 		TXN_ABORT( tid );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
+			"=> " LDAP_XSTRING(bdb_tool_entry_reindex)
+			": txn_aborted! %s (%d)\n",
 			db_strerror(rc), rc, 0 );
 		e->e_id = NOID;
 	}
@@ -496,7 +506,8 @@ ID bdb_tool_entry_modify(
 	assert ( e->e_id != NOID );
 	assert ( e->e_id != 0 );
 
-	Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
+	Debug( LDAP_DEBUG_TRACE,
+		"=> " LDAP_XSTRING(bdb_tool_entry_modify) "( %ld, \"%s\" )\n",
 		(long) e->e_id, e->e_dn, 0 );
 
 	rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid, 
@@ -506,7 +517,7 @@ ID bdb_tool_entry_modify(
 			"txn_begin failed: %s (%d)",
 			db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n",
+			"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
 			 text->bv_val, 0, 0 );
 		return NOID;
 	}
@@ -522,7 +533,8 @@ ID bdb_tool_entry_modify(
 				"id2entry_add failed: %s (%d)",
 				db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
+			"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
+			text->bv_val, 0, 0 );
 		goto done;
 	}
 
@@ -532,7 +544,8 @@ ID bdb_tool_entry_modify(
 				"index_entry_del failed: %s (%d)",
 				db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
+			"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
+			text->bv_val, 0, 0 );
 		goto done;
 	}
 
@@ -542,7 +555,8 @@ ID bdb_tool_entry_modify(
 				"index_entry_add failed: %s (%d)",
 				db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
+			"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
+			text->bv_val, 0, 0 );
 		goto done;
 	}
 
@@ -554,8 +568,8 @@ done:
 					"txn_commit failed: %s (%d)",
 					db_strerror(rc), rc );
 			Debug( LDAP_DEBUG_ANY,
-				"=> bdb_tool_entry_put: %s\n",
-				text->bv_val, 0, 0 );
+				"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": "
+				"%s\n", text->bv_val, 0, 0 );
 			e->e_id = NOID;
 		}
 
@@ -565,7 +579,7 @@ done:
 			"txn_aborted! %s (%d)",
 			db_strerror(rc), rc );
 		Debug( LDAP_DEBUG_ANY,
-			"=> bdb_tool_entry_put: %s\n",
+			"=> " LDAP_XSTRING(bdb_tool_entry_modify) ": %s\n",
 			text->bv_val, 0, 0 );
 		e->e_id = NOID;
 	}