Index: /trunk/include/iprt/mem.h
===================================================================
--- /trunk/include/iprt/mem.h	(revision 31156)
+++ /trunk/include/iprt/mem.h	(revision 31157)
@@ -56,6 +56,20 @@
 #define RTMEM_ALIGNMENT    8
 
-/**
- * Allocates temporary memory.
+/** @def RTMEM_TAG
+ * The default allocation tag used by the RTMem allocation APIs.
+ *
+ * When not defined before the inclusion of iprt/mem.h or iprt/memobj.h, this
+ * will default to the pointer to the current file name.  The memory API will
+ * make of use of this as pointer to a volatile but read-only string.
+ */
+#ifndef RTMEM_TAG
+# define RTMEM_TAG   (__FILE__)
+#endif
+
+
+/** @name Allocate temporary memory.
+ * @{ */
+/**
+ * Allocates temporary memory with default tag.
  *
  * Temporary memory blocks are used for not too large memory blocks which
@@ -65,19 +79,46 @@
  *
  * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
+ * @returns NULL on failure, assertion raised in strict builds.
  * @param   cb      Size in bytes of the memory block to allocated.
  */
-RTDECL(void *)  RTMemTmpAlloc(size_t cb) RT_NO_THROW;
-
-/**
- * Allocates zero'ed temporary memory.
+#define RTMemTmpAlloc(cb)               RTMemTmpAllocTag((cb), RTMEM_TAG)
+
+/**
+ * Allocates temporary memory with custom tag.
+ *
+ * Temporary memory blocks are used for not too large memory blocks which
+ * are believed not to stick around for too long. Using this API instead
+ * of RTMemAlloc() not only gives the heap manager room for optimization
+ * but makes the code easier to read.
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL on failure, assertion raised in strict builds.
+ * @param   cb      Size in bytes of the memory block to allocated.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Allocates zero'ed temporary memory with default tag.
  *
  * Same as RTMemTmpAlloc() but the memory will be zero'ed.
  *
  * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
+ * @returns NULL on failure, assertion raised in strict builds.
  * @param   cb      Size in bytes of the memory block to allocated.
  */
-RTDECL(void *)  RTMemTmpAllocZ(size_t cb) RT_NO_THROW;
+#define RTMemTmpAllocZ(cb)              RTMemTmpAllocZTag((cb), RTMEM_TAG)
+
+/**
+ * Allocates zero'ed temporary memory with custom tag.
+ *
+ * Same as RTMemTmpAlloc() but the memory will be zero'ed.
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL on failure, assertion raised in strict builds.
+ * @param   cb      Size in bytes of the memory block to allocated.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
 
 /**
@@ -88,16 +129,29 @@
 RTDECL(void)    RTMemTmpFree(void *pv) RT_NO_THROW;
 
-
-/**
- * Allocates memory.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
+/** @}  */
+
+
+/**
+ * Allocates memory with default tag.
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL on failure, assertion raised in strict builds.
  * @param   cb      Size in bytes of the memory block to allocated.
- */
-RTDECL(void *)  RTMemAlloc(size_t cb) RT_NO_THROW;
-
-/**
- * Allocates zero'ed memory.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+#define RTMemAlloc(cb)                  RTMemAllocTag((cb), RTMEM_TAG)
+
+/**
+ * Allocates memory with custom tag.
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL on failure, assertion raised in strict builds.
+ * @param   cb      Size in bytes of the memory block to allocated.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Allocates zero'ed memory with default tag.
  *
  * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
@@ -109,5 +163,19 @@
  * @param   cb      Size in bytes of the memory block to allocated.
  */
-RTDECL(void *)  RTMemAllocZ(size_t cb) RT_NO_THROW;
+#define RTMemAllocZ(cb)                 RTMemAllocZTag((cb), RTMEM_TAG)
+
+/**
+ * Allocates zero'ed memory with custom tag.
+ *
+ * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
+ * memory. This keeps the code smaller and the heap can skip the memset
+ * in about 0.42% of calls :-).
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL on failure.
+ * @param   cb      Size in bytes of the memory block to allocated.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
 
 /**
@@ -118,5 +186,15 @@
  * @param   cbUnaligned         The unaligned size.
  */
-RTDECL(void *) RTMemAllocVar(size_t cbUnaligned);
+#define RTMemAllocVar(cbUnaligned)      RTMemAllocVarTag((cbUnaligned), RTMEM_TAG)
+
+/**
+ * Wrapper around RTMemAllocTag for automatically aligning variable sized
+ * allocations so that the various electric fence heaps works correctly.
+ *
+ * @returns See RTMemAlloc.
+ * @param   cbUnaligned         The unaligned size.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
 
 /**
@@ -127,8 +205,18 @@
  * @param   cbUnaligned         The unaligned size.
  */
-RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned);
-
-/**
- * Duplicates a chunk of memory into a new heap block.
+#define RTMemAllocZVar(cbUnaligned)     RTMemAllocZVarTag((cbUnaligned), RTMEM_TAG)
+
+/**
+ * Wrapper around RTMemAllocZTag for automatically aligning variable sized
+ * allocations so that the various electric fence heaps works correctly.
+ *
+ * @returns See RTMemAllocZ.
+ * @param   cbUnaligned         The unaligned size.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Duplicates a chunk of memory into a new heap block (default tag).
  *
  * @returns New heap block with the duplicate data.
@@ -137,9 +225,20 @@
  * @param   cb      The amount of memory to duplicate.
  */
-RTDECL(void *) RTMemDup(const void *pvSrc, size_t cb) RT_NO_THROW;
-
-/**
- * Duplicates a chunk of memory into a new heap block with some
- * additional zeroed memory.
+#define RTMemDup(pvSrc, cb)             RTMemDupTag((pvSrc), (cb), RTMEM_TAG)
+
+/**
+ * Duplicates a chunk of memory into a new heap block (custom tag).
+ *
+ * @returns New heap block with the duplicate data.
+ * @returns NULL if we're out of memory.
+ * @param   pvSrc   The memory to duplicate.
+ * @param   cb      The amount of memory to duplicate.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Duplicates a chunk of memory into a new heap block with some additional
+ * zeroed memory (default tag).
  *
  * @returns New heap block with the duplicate data.
@@ -149,8 +248,21 @@
  * @param   cbExtra The amount of extra memory to allocate and zero.
  */
-RTDECL(void *) RTMemDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW;
-
-/**
- * Reallocates memory.
+#define RTMemDupEx(pvSrc, cbSrc, cbExtra)   RTMemDupExTag((pvSrc), (cbSrc), (cbExtra), RTMEM_TAG)
+
+/**
+ * Duplicates a chunk of memory into a new heap block with some additional
+ * zeroed memory (default tag).
+ *
+ * @returns New heap block with the duplicate data.
+ * @returns NULL if we're out of memory.
+ * @param   pvSrc   The memory to duplicate.
+ * @param   cbSrc   The amount of memory to duplicate.
+ * @param   cbExtra The amount of extra memory to allocate and zero.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Reallocates memory with default tag.
  *
  * @returns Pointer to the allocated memory.
@@ -159,5 +271,16 @@
  * @param   cbNew   The new block size (in bytes).
  */
-RTDECL(void *)  RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW;
+#define RTMemRealloc(pvOld, cbNew)          RTMemReallocTag((pvOld), (cbNew), RTMEM_TAG)
+
+/**
+ * Reallocates memory with custom tag.
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL on failure.
+ * @param   pvOld   The memory block to reallocate.
+ * @param   cbNew   The new block size (in bytes).
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW;
 
 /**
@@ -168,6 +291,8 @@
 RTDECL(void)    RTMemFree(void *pv) RT_NO_THROW;
 
-/**
- * Allocates memory which may contain code.
+
+
+/**
+ * Allocates memory which may contain code (default tag).
  *
  * @returns Pointer to the allocated memory.
@@ -175,5 +300,15 @@
  * @param   cb      Size in bytes of the memory block to allocate.
  */
-RTDECL(void *)  RTMemExecAlloc(size_t cb) RT_NO_THROW;
+#define RTMemExecAlloc(cb)              RTMemExecAllocTag((cb), RTMEM_TAG)
+
+/**
+ * Allocates memory which may contain code (custom tag).
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL on failure.
+ * @param   cb      Size in bytes of the memory block to allocate.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
 
 /**
@@ -204,5 +339,5 @@
 
 /**
- * Allocate page aligned memory.
+ * Allocate page aligned memory with default tag.
  *
  * @returns Pointer to the allocated memory.
@@ -210,14 +345,34 @@
  * @param   cb  Size of the memory block. Will be rounded up to page size.
  */
-RTDECL(void *) RTMemPageAlloc(size_t cb) RT_NO_THROW;
-
-/**
- * Allocate zero'ed page aligned memory.
+#define RTMemPageAlloc(cb)              RTMemPageAllocTag((cb), RTMEM_TAG)
+
+/**
+ * Allocate page aligned memory with custom tag.
  *
  * @returns Pointer to the allocated memory.
  * @returns NULL if we're out of memory.
  * @param   cb  Size of the memory block. Will be rounded up to page size.
- */
-RTDECL(void *) RTMemPageAllocZ(size_t cb) RT_NO_THROW;
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Allocate zero'ed page aligned memory with default tag.
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL if we're out of memory.
+ * @param   cb  Size of the memory block. Will be rounded up to page size.
+ */
+#define RTMemPageAllocZ(cb)             RTMemPageAllocZTag((cb), RTMEM_TAG)
+
+/**
+ * Allocate zero'ed page aligned memory with custom tag.
+ *
+ * @returns Pointer to the allocated memory.
+ * @returns NULL if we're out of memory.
+ * @param   cb  Size of the memory block. Will be rounded up to page size.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW;
 
 /**
@@ -360,20 +515,22 @@
 
 /**
- * Same as RTMemTmpAlloc() except that it's fenced.
+ * Same as RTMemTmpAllocTag() except that it's fenced.
  *
  * @returns Pointer to the allocated memory.
  * @returns NULL on failure.
  * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
-
-/**
- * Same as RTMemTmpAllocZ() except that it's fenced.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+
+/**
+ * Same as RTMemTmpAllocZTag() except that it's fenced.
  *
  * @returns Pointer to the allocated memory.
  * @returns NULL on failure.
  * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
 
 /**
@@ -385,41 +542,45 @@
 
 /**
- * Same as RTMemAlloc() except that it's fenced.
+ * Same as RTMemAllocTag() except that it's fenced.
  *
  * @returns Pointer to the allocated memory. Free with RTMemEfFree().
  * @returns NULL on failure.
  * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
-
-/**
- * Same as RTMemAllocZ() except that it's fenced.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+
+/**
+ * Same as RTMemAllocZTag() except that it's fenced.
  *
  * @returns Pointer to the allocated memory.
  * @returns NULL on failure.
  * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
-
-/**
- * Same as RTMemAllocVar() except that it's fenced.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+
+/**
+ * Same as RTMemAllocVarTag() except that it's fenced.
  *
  * @returns Pointer to the allocated memory. Free with RTMemEfFree().
  * @returns NULL on failure.
  * @param   cbUnaligned Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW;
-
-/**
- * Same as RTMemAllocZVar() except that it's fenced.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+
+/**
+ * Same as RTMemAllocZVarTag() except that it's fenced.
  *
  * @returns Pointer to the allocated memory.
  * @returns NULL on failure.
  * @param   cbUnaligned Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW;
-
-/**
- * Same as RTMemRealloc() except that it's fenced.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+
+/**
+ * Same as RTMemReallocTag() except that it's fenced.
  *
  * @returns Pointer to the allocated memory.
@@ -427,6 +588,7 @@
  * @param   pvOld   The memory block to reallocate.
  * @param   cbNew   The new block size (in bytes).
- */
-RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, RT_SRC_POS_DECL) RT_NO_THROW;
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
 
 /**
@@ -438,5 +600,5 @@
 
 /**
- * Same as RTMemDup() except that it's fenced.
+ * Same as RTMemDupTag() except that it's fenced.
  *
  * @returns New heap block with the duplicate data.
@@ -444,9 +606,10 @@
  * @param   pvSrc   The memory to duplicate.
  * @param   cb      The amount of memory to duplicate.
- */
-RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW;
-
-/**
- * Same as RTMemEfDupEx except that it's fenced.
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
+
+/**
+ * Same as RTMemEfDupExTag except that it's fenced.
  *
  * @returns New heap block with the duplicate data.
@@ -455,6 +618,7 @@
  * @param   cbSrc   The amount of memory to duplicate.
  * @param   cbExtra The amount of extra memory to allocate and zero.
- */
-RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, RT_SRC_POS_DECL) RT_NO_THROW;
+ * @param   pszTag  Allocation tag used for statistics and such.
+ */
+RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW;
 
 /** @def RTMEM_WRAP_TO_EF_APIS
@@ -462,15 +626,15 @@
  */
 #if defined(RTMEM_WRAP_TO_EF_APIS) && defined(IN_RING3) && !defined(RTMEM_NO_WRAP_TO_EF_APIS)
-# define RTMemTmpAlloc(cb)                  RTMemEfTmpAlloc((cb), RT_SRC_POS)
-# define RTMemTmpAllocZ(cb)                 RTMemEfTmpAllocZ((cb), RT_SRC_POS)
-# define RTMemTmpFree(pv)                   RTMemEfTmpFree((pv), RT_SRC_POS)
-# define RTMemAlloc(cb)                     RTMemEfAlloc((cb), RT_SRC_POS)
-# define RTMemAllocZ(cb)                    RTMemEfAllocZ((cb), RT_SRC_POS)
-# define RTMemAllocVar(cbUnaligned)         RTMemEfAllocVar((cbUnaligned), RT_SRC_POS)
-# define RTMemAllocZVar(cbUnaligned)        RTMemEfAllocZVar((cbUnaligned), RT_SRC_POS)
-# define RTMemRealloc(pvOld, cbNew)         RTMemEfRealloc((pvOld), (cbNew), RT_SRC_POS)
-# define RTMemFree(pv)                      RTMemEfFree((pv), RT_SRC_POS)
-# define RTMemDup(pvSrc, cb)                RTMemEfDup((pvSrc), (cb), RT_SRC_POS)
-# define RTMemDupEx(pvSrc, cbSrc, cbExtra)  RTMemEfDupEx((pvSrc), (cbSrc), (cbExtra), RT_SRC_POS)
+# define RTMemTmpAllocTag(cb, pszTag)                   RTMemEfTmpAlloc((cb), (pszTag), RT_SRC_POS)
+# define RTMemTmpAllocZTag(cb, pszTag)                  RTMemEfTmpAllocZ((cb), (pszTag), RT_SRC_POS)
+# define RTMemTmpFree(pv)                               RTMemEfTmpFree((pv), RT_SRC_POS)
+# define RTMemAllocTag(cb, pszTag)                      RTMemEfAlloc((cb), (pszTag), RT_SRC_POS)
+# define RTMemAllocZTag(cb, pszTag)                     RTMemEfAllocZ((cb), (pszTag), RT_SRC_POS)
+# define RTMemAllocVarTag(cbUnaligned, pszTag)          RTMemEfAllocVar((cbUnaligned), (pszTag), RT_SRC_POS)
+# define RTMemAllocZVarTag(cbUnaligned, pszTag)         RTMemEfAllocZVar((cbUnaligned), (pszTag), RT_SRC_POS)
+# define RTMemReallocTag(pvOld, cbNew, pszTag)          RTMemEfRealloc((pvOld), (cbNew), (pszTag), RT_SRC_POS)
+# define RTMemFree(pv)                                  RTMemEfFree((pv), RT_SRC_POS)
+# define RTMemDupTag(pvSrc, cb, pszTag)                 RTMemEfDup((pvSrc), (cb), (pszTag), RT_SRC_POS)
+# define RTMemDupExTag(pvSrc, cbSrc, cbExtra, pszTag)   RTMemEfDupEx((pvSrc), (cbSrc), (cbExtra), (pszTag), RT_SRC_POS)
 #endif
 #ifdef DOXYGEN_RUNNING
@@ -479,50 +643,50 @@
 
 /**
- * Fenced drop-in replacement for RTMemTmpAlloc.
- * @copydoc RTMemTmpAlloc
- */
-RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb) RT_NO_THROW;
-
-/**
- * Fenced drop-in replacement for RTMemTmpAllocZ.
- * @copydoc RTMemTmpAllocZ
- */
-RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb) RT_NO_THROW;
-
-/**
- * Fenced drop-in replacement for RTMemTmpFree.
- * @copydoc RTMemTmpFree
+ * Fenced drop-in replacement for RTMemTmpAllocTag.
+ * @copydoc RTMemTmpAllocTag
+ */
+RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Fenced drop-in replacement for RTMemTmpAllocZTag.
+ * @copydoc RTMemTmpAllocZTag
+ */
+RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Fenced drop-in replacement for RTMemTmpFreeTag.
+ * @copydoc RTMemTmpFreeTag
  */
 RTDECL(void)    RTMemEfTmpFreeNP(void *pv) RT_NO_THROW;
 
 /**
- * Fenced drop-in replacement for RTMemAlloc.
- * @copydoc RTMemAlloc
- */
-RTDECL(void *)  RTMemEfAllocNP(size_t cb) RT_NO_THROW;
-
-/**
- * Fenced drop-in replacement for RTMemAllocZ.
- * @copydoc RTMemAllocZ
- */
-RTDECL(void *)  RTMemEfAllocZNP(size_t cb) RT_NO_THROW;
-
-/**
- * Fenced drop-in replacement for RTMemAllocVar
- * @copydoc RTMemAllocVar
- */
-RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned) RT_NO_THROW;
-
-/**
- * Fenced drop-in replacement for RTMemAllocZVar.
- * @copydoc RTMemAllocZVar
- */
-RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned) RT_NO_THROW;
-
-/**
- * Fenced drop-in replacement for RTMemRealloc.
- * @copydoc RTMemRealloc
- */
-RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew) RT_NO_THROW;
+ * Fenced drop-in replacement for RTMemAllocTag.
+ * @copydoc RTMemAllocTag
+ */
+RTDECL(void *)  RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Fenced drop-in replacement for RTMemAllocZTag.
+ * @copydoc RTMemAllocZTag
+ */
+RTDECL(void *)  RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Fenced drop-in replacement for RTMemAllocVarTag
+ * @copydoc RTMemAllocVarTag
+ */
+RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Fenced drop-in replacement for RTMemAllocZVarTag.
+ * @copydoc RTMemAllocZVarTag
+ */
+RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Fenced drop-in replacement for RTMemReallocTag.
+ * @copydoc RTMemReallocTag
+ */
+RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW;
 
 /**
@@ -533,14 +697,14 @@
 
 /**
- * Fenced drop-in replacement for RTMemDupEx.
- * @copydoc RTMemDupEx
- */
-RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb) RT_NO_THROW;
-
-/**
- * Fenced drop-in replacement for RTMemDupEx.
- * @copydoc RTMemDupEx
- */
-RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW;
+ * Fenced drop-in replacement for RTMemDupExTag.
+ * @copydoc RTMemDupExTag
+ */
+RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW;
+
+/**
+ * Fenced drop-in replacement for RTMemDupExTag.
+ * @copydoc RTMemDupExTag
+ */
+RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW;
 
 /** @} */
@@ -655,7 +819,7 @@
           void Destruct(T *) = RTMemAutoDestructor<T>,
 # ifdef RTMEM_WRAP_TO_EF_APIS
-          void *Allocator(void *, size_t) = RTMemEfReallocNP
+          void *Allocator(void *, size_t, const char *) = RTMemEfReallocNP
 # else
-          void *Allocator(void *, size_t) = RTMemRealloc
+          void *Allocator(void *, size_t, const char *) = RTMemReallocTag
 # endif
           >
@@ -682,5 +846,5 @@
      */
     RTMemAutoPtr(size_t a_cElements, bool a_fZeroed = false)
-        : RTAutoRes<T *, Destruct, RTMemAutoNil<T> >((T *)Allocator(NULL, a_cElements * sizeof(T)))
+        : RTAutoRes<T *, Destruct, RTMemAutoNil<T> >((T *)Allocator(NULL, a_cElements * sizeof(T), RTMEM_TAG))
     {
         if (a_fZeroed && RT_LIKELY(this->get() != NULL))
@@ -744,5 +908,5 @@
     {
         this->reset(NULL);
-        T *pNewMem = (T *)Allocator(NULL, a_cElements * sizeof(T));
+        T *pNewMem = (T *)Allocator(NULL, a_cElements * sizeof(T), RTMEM_TAG);
         if (a_fZeroed && RT_LIKELY(pNewMem != NULL))
             memset(pNewMem, '\0', a_cElements * sizeof(T));
@@ -771,5 +935,5 @@
     bool realloc(size_t a_cElements = 1)
     {
-        T *aNewValue = (T *)Allocator(this->get(), a_cElements * sizeof(T));
+        T *aNewValue = (T *)Allocator(this->get(), a_cElements * sizeof(T), RTMEM_TAG);
         if (RT_LIKELY(aNewValue != NULL))
             this->release();
Index: /trunk/include/iprt/memobj.h
===================================================================
--- /trunk/include/iprt/memobj.h	(revision 31156)
+++ /trunk/include/iprt/memobj.h	(revision 31157)
@@ -4,5 +4,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -37,4 +37,15 @@
  */
 
+/** @def RTMEM_TAG
+ * The default allocation tag used by the RTMem allocation APIs.
+ *
+ * When not defined before the inclusion of iprt/memobj.h or iprt/mem.h, this
+ * will default to the pointer to the current file name.  The memory API will
+ * make of use of this as pointer to a volatile but read-only string.
+ */
+#ifndef RTMEM_TAG
+# define RTMEM_TAG   (__FILE__)
+#endif
+
 #ifdef IN_RING0
 
@@ -102,5 +113,5 @@
 
 /**
- * Allocates page aligned virtual kernel memory.
+ * Allocates page aligned virtual kernel memory (default tag).
  *
  * The memory is taken from a non paged (= fixed physical memory backing) pool.
@@ -111,8 +122,23 @@
  * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
  */
-RTR0DECL(int) RTR0MemObjAllocPage(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable);
-
-/**
- * Allocates page aligned virtual kernel memory with physical backing below 4GB.
+#define RTR0MemObjAllocPage(pMemObj, cb, fExecutable) \
+    RTR0MemObjAllocPageTag((pMemObj), (cb), (fExecutable), RTMEM_TAG)
+
+/**
+ * Allocates page aligned virtual kernel memory (custom tag).
+ *
+ * The memory is taken from a non paged (= fixed physical memory backing) pool.
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
+ * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjAllocPageTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag);
+
+/**
+ * Allocates page aligned virtual kernel memory with physical backing below 4GB
+ * (default tag).
  *
  * The physical memory backing the allocation is fixed.
@@ -123,8 +149,10 @@
  * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
  */
-RTR0DECL(int) RTR0MemObjAllocLow(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable);
-
-/**
- * Allocates page aligned virtual kernel memory with contiguous physical backing below 4GB.
+#define RTR0MemObjAllocLow(pMemObj, cb, fExecutable) \
+    RTR0MemObjAllocLowTag((pMemObj), (cb), (fExecutable), RTMEM_TAG)
+
+/**
+ * Allocates page aligned virtual kernel memory with physical backing below 4GB
+ * (custom tag).
  *
  * The physical memory backing the allocation is fixed.
@@ -134,9 +162,38 @@
  * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
  * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
- */
-RTR0DECL(int) RTR0MemObjAllocCont(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable);
-
-/**
- * Locks a range of user virtual memory.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjAllocLowTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag);
+
+/**
+ * Allocates page aligned virtual kernel memory with contiguous physical backing
+ * below 4GB (default tag).
+ *
+ * The physical memory backing the allocation is fixed.
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
+ * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
+ */
+#define RTR0MemObjAllocCont(pMemObj, cb, fExecutable) \
+    RTR0MemObjAllocContTag((pMemObj), (cb), (fExecutable), RTMEM_TAG)
+
+/**
+ * Allocates page aligned virtual kernel memory with contiguous physical backing
+ * below 4GB (custom tag).
+ *
+ * The physical memory backing the allocation is fixed.
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
+ * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjAllocContTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag);
+
+/**
+ * Locks a range of user virtual memory (default tag).
  *
  * @returns IPRT status code.
@@ -159,8 +216,35 @@
  *          lifting it.
  */
-RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process);
-
-/**
- * Locks a range of kernel virtual memory.
+#define RTR0MemObjLockUser(pMemObj, R3Ptr, cb, fAccess, R0Process) \
+    RTR0MemObjLockUserTag((pMemObj), (R3Ptr), (cb), (fAccess), (R0Process), RTMEM_TAG)
+
+/**
+ * Locks a range of user virtual memory (custom tag).
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   R3Ptr           User virtual address. This is rounded down to a page
+ *                          boundrary.
+ * @param   cb              Number of bytes to lock. This is rounded up to
+ *                          nearest page boundrary.
+ * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
+ *                          and RTMEM_PROT_WRITE.
+ * @param   R0Process       The process to lock pages in. NIL_R0PROCESS is an
+ *                          alias for the current one.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ *
+ * @remarks RTR0MemGetAddressR3() and RTR0MemGetAddress() will return therounded
+ *          down address.
+ *
+ * @remarks Linux: This API requires that the memory begin locked is in a memory
+ *          mapping that is not required in any forked off child process. This
+ *          is not intented as permanent restriction, feel free to help out
+ *          lifting it.
+ */
+RTR0DECL(int) RTR0MemObjLockUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess,
+                                    RTR0PROCESS R0Process, const char *pszTag);
+
+/**
+ * Locks a range of kernel virtual memory (default tag).
  *
  * @returns IPRT status code.
@@ -173,8 +257,25 @@
  * @remark  RTR0MemGetAddress() will return the rounded down address.
  */
-RTR0DECL(int) RTR0MemObjLockKernel(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess);
-
-/**
- * Allocates contiguous page aligned physical memory without (necessarily) any kernel mapping.
+#define RTR0MemObjLockKernel(pMemObj, pv, cb, fAccess) \
+    RTR0MemObjLockKernelTag((pMemObj), (pv), (cb), (fAccess), RTMEM_TAG)
+
+/**
+ * Locks a range of kernel virtual memory (custom tag).
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   pv              Kernel virtual address. This is rounded down to a page boundrary.
+ * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
+ * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
+ *                          and RTMEM_PROT_WRITE.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ *
+ * @remark  RTR0MemGetAddress() will return the rounded down address.
+ */
+RTR0DECL(int) RTR0MemObjLockKernelTag(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess, const char *pszTag);
+
+/**
+ * Allocates contiguous page aligned physical memory without (necessarily) any
+ * kernel mapping (default tag).
  *
  * @returns IPRT status code.
@@ -184,8 +285,10 @@
  *                          Pass NIL_RTHCPHYS if any address is acceptable.
  */
-RTR0DECL(int) RTR0MemObjAllocPhys(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest);
-
-/**
- * Allocates contiguous physical memory without (necessarily) any kernel mapping.
+#define RTR0MemObjAllocPhys(pMemObj, cb, PhysHighest) \
+    RTR0MemObjAllocPhysTag((pMemObj), (cb), (PhysHighest), RTMEM_TAG)
+
+/**
+ * Allocates contiguous page aligned physical memory without (necessarily) any
+ * kernel mapping (custom tag).
  *
  * @returns IPRT status code.
@@ -194,11 +297,41 @@
  * @param   PhysHighest     The highest permittable address (inclusive).
  *                          Pass NIL_RTHCPHYS if any address is acceptable.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjAllocPhysTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag);
+
+/**
+ * Allocates contiguous physical memory without (necessarily) any kernel mapping
+ * (default tag).
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
+ * @param   PhysHighest     The highest permittable address (inclusive).
+ *                          Pass NIL_RTHCPHYS if any address is acceptable.
  * @param   uAlignment      The alignment of the reserved memory.
  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
  */
-RTR0DECL(int) RTR0MemObjAllocPhysEx(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment);
-
-/**
- * Allocates non-contiguous page aligned physical memory without (necessarily) any kernel mapping.
+#define RTR0MemObjAllocPhysEx(pMemObj, cb, PhysHighest, uAlignment) \
+    RTR0MemObjAllocPhysExTag((pMemObj), (cb), (PhysHighest), (uAlignment), RTMEM_TAG)
+
+/**
+ * Allocates contiguous physical memory without (necessarily) any kernel mapping
+ * (custom tag).
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
+ * @param   PhysHighest     The highest permittable address (inclusive).
+ *                          Pass NIL_RTHCPHYS if any address is acceptable.
+ * @param   uAlignment      The alignment of the reserved memory.
+ *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjAllocPhysExTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment, const char *pszTag);
+
+/**
+ * Allocates non-contiguous page aligned physical memory without (necessarily)
+ * any kernel mapping (default tag).
  *
  * This API is for allocating huge amounts of pages and will return
@@ -216,5 +349,27 @@
  *                          Pass NIL_RTHCPHYS if any address is acceptable.
  */
-RTR0DECL(int) RTR0MemObjAllocPhysNC(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest);
+#define RTR0MemObjAllocPhysNC(pMemObj, cb, PhysHighest) \
+    RTR0MemObjAllocPhysNCTag((pMemObj), (cb), (PhysHighest), RTMEM_TAG)
+
+/**
+ * Allocates non-contiguous page aligned physical memory without (necessarily)
+ * any kernel mapping (custom tag).
+ *
+ * This API is for allocating huge amounts of pages and will return
+ * VERR_NOT_SUPPORTED if this cannot be implemented in a satisfactory
+ * manner.
+ *
+ * @returns IPRT status code.
+ * @retval  VERR_NOT_SUPPORTED if it's not possible to allocated unmapped
+ *          physical memory on this platform. The caller should expect
+ *          this error and have a fallback strategy for it.
+ *
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
+ * @param   PhysHighest     The highest permittable address (inclusive).
+ *                          Pass NIL_RTHCPHYS if any address is acceptable.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjAllocPhysNCTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag);
 
 /** Memory cache policy for RTR0MemObjEnterPhys.
@@ -228,5 +383,5 @@
 
 /**
- * Creates a page aligned, contiguous, physical memory object.
+ * Creates a page aligned, contiguous, physical memory object (default tag).
  *
  * No physical memory is allocated, we trust you do know what you're doing.
@@ -239,8 +394,24 @@
  * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
  */
-RTR0DECL(int) RTR0MemObjEnterPhys(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy);
-
-/**
- * Reserves kernel virtual address space.
+#define RTR0MemObjEnterPhys(pMemObj, Phys, cb, uCachePolicy) \
+    RTR0MemObjEnterPhysTag((pMemObj), (Phys), (cb), (uCachePolicy), RTMEM_TAG)
+
+/**
+ * Creates a page aligned, contiguous, physical memory object (custom tag).
+ *
+ * No physical memory is allocated, we trust you do know what you're doing.
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   Phys            The physical address to start at. This is rounded down to the
+ *                          nearest page boundrary.
+ * @param   cb              The size of the object in bytes. This is rounded up to nearest page boundrary.
+ * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjEnterPhysTag(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy, const char *pszTag);
+
+/**
+ * Reserves kernel virtual address space (default tag).
  *
  * If this function fails with VERR_NOT_SUPPORTED, the idea is that you
@@ -255,8 +426,26 @@
  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
  */
-RTR0DECL(int) RTR0MemObjReserveKernel(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment);
-
-/**
- * Reserves user virtual address space in the current process.
+#define RTR0MemObjReserveKernel(pMemObj, pvFixed, cb, uAlignment) \
+    RTR0MemObjReserveKernelTag((pMemObj), (pvFixed), (cb), (uAlignment), RTMEM_TAG)
+
+/**
+ * Reserves kernel virtual address space (custom tag).
+ *
+ * If this function fails with VERR_NOT_SUPPORTED, the idea is that you
+ * can use RTR0MemObjEnterPhys() + RTR0MemObjMapKernel() as a fallback if
+ * you have a safe physical address range to make use of...
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
+ * @param   cb              The number of bytes to reserve. This is rounded up to nearest page.
+ * @param   uAlignment      The alignment of the reserved memory.
+ *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjReserveKernelTag(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, const char *pszTag);
+
+/**
+ * Reserves user virtual address space in the current process (default tag).
  *
  * @returns IPRT status code.
@@ -268,8 +457,24 @@
  * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
  */
-RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
-
-/**
- * Maps a memory object into kernel virtual address space.
+#define RTR0MemObjReserveUser(pMemObj, R3PtrFixed, cb, uAlignment, R0Process) \
+    RTR0MemObjReserveUserTag((pMemObj), (R3PtrFixed), (cb), (uAlignment), (R0Process), RTMEM_TAG)
+
+/**
+ * Reserves user virtual address space in the current process (custom tag).
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle.
+ * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
+ * @param   cb              The number of bytes to reserve. This is rounded up to nearest PAGE_SIZE.
+ * @param   uAlignment      The alignment of the reserved memory.
+ *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
+ * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjReserveUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment,
+                                       RTR0PROCESS R0Process, const char *pszTag);
+
+/**
+ * Maps a memory object into kernel virtual address space (default tag).
  *
  * This is the same as calling RTR0MemObjMapKernelEx with cbSub and offSub set
@@ -284,8 +489,27 @@
  * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
  */
-RTR0DECL(int) RTR0MemObjMapKernel(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt);
-
-/**
- * Maps a memory object into kernel virtual address space.
+#define RTR0MemObjMapKernel(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt) \
+    RTR0MemObjMapKernelTag((pMemObj), (MemObjToMap), (pvFixed), (uAlignment), (fProt), RTMEM_TAG)
+
+/**
+ * Maps a memory object into kernel virtual address space (custom tag).
+ *
+ * This is the same as calling RTR0MemObjMapKernelEx with cbSub and offSub set
+ * to zero.
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
+ * @param   MemObjToMap     The object to be map.
+ * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
+ * @param   uAlignment      The alignment of the reserved memory.
+ *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
+ * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjMapKernelTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed,
+                                     size_t uAlignment, unsigned fProt, const char *pszTag);
+
+/**
+ * Maps a memory object into kernel virtual address space (default tag).
  *
  * The ability to map subsections of the object into kernel space is currently
@@ -310,9 +534,38 @@
  *                          page aligned.
  */
-RTR0DECL(int) RTR0MemObjMapKernelEx(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
-                                    unsigned fProt, size_t offSub, size_t cbSub);
-
-/**
- * Maps a memory object into user virtual address space in the current process.
+#define RTR0MemObjMapKernelEx(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt, offSub, cbSub) \
+    RTR0MemObjMapKernelExTag((pMemObj), (MemObjToMap), (pvFixed), (uAlignment), (fProt), (offSub), (cbSub), RTMEM_TAG)
+
+/**
+ * Maps a memory object into kernel virtual address space (custom tag).
+ *
+ * The ability to map subsections of the object into kernel space is currently
+ * not implemented on all platforms. All/Most of platforms supports mapping the
+ * whole object into  kernel space.
+ *
+ * @returns IPRT status code.
+ * @retval  VERR_NOT_SUPPORTED if it's not possible to map a subsection of a
+ *          memory object on this platform. When you hit this, try implement it.
+ *
+ * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
+ * @param   MemObjToMap     The object to be map.
+ * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
+ * @param   uAlignment      The alignment of the reserved memory.
+ *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
+ * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
+ * @param   offSub          Where in the object to start mapping. If non-zero
+ *                          the value must be page aligned and cbSub must be
+ *                          non-zero as well.
+ * @param   cbSub           The size of the part of the object to be mapped. If
+ *                          zero the entire object is mapped. The value must be
+ *                          page aligned.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjMapKernelExTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
+                                       unsigned fProt, size_t offSub, size_t cbSub, const char *pszTag);
+
+/**
+ * Maps a memory object into user virtual address space in the current process
+ * (default tag).
  *
  * @returns IPRT status code.
@@ -325,5 +578,23 @@
  * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
  */
-RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
+#define RTR0MemObjMapUser(pMemObj, MemObjToMap, R3PtrFixed, uAlignment, fProt, R0Process) \
+    RTR0MemObjMapUserTag((pMemObj), (MemObjToMap), (R3PtrFixed), (uAlignment), (fProt), (R0Process), RTMEM_TAG)
+
+/**
+ * Maps a memory object into user virtual address space in the current process
+ * (custom tag).
+ *
+ * @returns IPRT status code.
+ * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
+ * @param   MemObjToMap     The object to be map.
+ * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
+ * @param   uAlignment      The alignment of the reserved memory.
+ *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
+ * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
+ * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR0DECL(int) RTR0MemObjMapUserTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed,
+                                   size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process, const char *pszTag);
 
 /**
Index: /trunk/include/iprt/string.h
===================================================================
--- /trunk/include/iprt/string.h	(revision 31156)
+++ /trunk/include/iprt/string.h	(revision 31157)
@@ -4,5 +4,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -115,8 +115,21 @@
 
 
+/** @def RTMEM_TAG
+ * The default allocation tag used by the RTStr allocation APIs.
+ *
+ * When not defined before the inclusion of iprt/string.h, this will default to
+ * the pointer to the current file name.  The string API will make of use of
+ * this as pointer to a volatile but read-only string.
+ */
+#ifndef RTSTR_TAG
+# define RTSTR_TAG      (__FILE__)
+#endif
+
+
 #ifdef IN_RING3
 
 /**
- * Allocates tmp buffer, translates pszString from UTF8 to current codepage.
+ * Allocates tmp buffer with default tag, translates pszString from UTF8 to
+ * current codepage.
  *
  * @returns iprt status code.
@@ -125,5 +138,18 @@
  * @param   pszString       UTF-8 string to convert.
  */
-RTR3DECL(int)  RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString);
+#define RTStrUtf8ToCurrentCP(ppszString, pszString)     RTStrUtf8ToCurrentCPTag((ppszString), (pszString), RTSTR_TAG)
+
+/**
+ * Allocates tmp buffer with custom tag, translates pszString from UTF8 to
+ * current codepage.
+ *
+ * @returns iprt status code.
+ * @param   ppszString      Receives pointer of allocated native CP string.
+ *                          The returned pointer must be freed using
+ *                          RTStrFree()., const char *pszTag
+ * @param   pszString       UTF-8 string to convert.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR3DECL(int)  RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag);
 
 /**
@@ -135,7 +161,18 @@
  * @param   pszString       Native string to convert.
  */
-RTR3DECL(int)  RTStrCurrentCPToUtf8(char **ppszString, const char *pszString);
-
-#endif
+#define RTStrCurrentCPToUtf8(ppszString, pszString)     RTStrCurrentCPToUtf8Tag((ppszString), (pszString), RTSTR_TAG)
+
+/**
+ * Allocates tmp buffer, translates pszString from current codepage to UTF-8.
+ *
+ * @returns iprt status code.
+ * @param   ppszString      Receives pointer of allocated UTF-8 string.
+ *                          The returned pointer must be freed using RTStrFree().
+ * @param   pszString       Native string to convert.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag);
+
+#endif /* IN_RING3 */
 
 /**
@@ -149,13 +186,22 @@
 
 /**
- * Allocates a new copy of the given UTF-8 string.
+ * Allocates a new copy of the given UTF-8 string (default tag).
  *
  * @returns Pointer to the allocated UTF-8 string.
  * @param   pszString       UTF-8 string to duplicate.
  */
-RTDECL(char *) RTStrDup(const char *pszString);
-
-/**
- * Allocates a new copy of the given UTF-8 string.
+#define RTStrDup(pszString)             RTStrDupTag((pszString), RTSTR_TAG)
+
+/**
+ * Allocates a new copy of the given UTF-8 string (custom tag).
+ *
+ * @returns Pointer to the allocated UTF-8 string.
+ * @param   pszString       UTF-8 string to duplicate.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(char *) RTStrDupTag(const char *pszString, const char *pszTag);
+
+/**
+ * Allocates a new copy of the given UTF-8 string (default tag).
  *
  * @returns iprt status code.
@@ -164,8 +210,19 @@
  * @param   pszString       UTF-8 string to duplicate.
  */
-RTDECL(int)  RTStrDupEx(char **ppszString, const char *pszString);
-
-/**
- * Allocates a new copy of the given UTF-8 substring.
+#define RTStrDupEx(ppszString, pszString)   RTStrDupExTag((ppszString), (pszString), RTSTR_TAG)
+
+/**
+ * Allocates a new copy of the given UTF-8 string (custom tag).
+ *
+ * @returns iprt status code.
+ * @param   ppszString      Receives pointer of the allocated UTF-8 string.
+ *                          The returned pointer must be freed using RTStrFree().
+ * @param   pszString       UTF-8 string to duplicate.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int)  RTStrDupExTag(char **ppszString, const char *pszString, const char *pszTag);
+
+/**
+ * Allocates a new copy of the given UTF-8 substring (default tag).
  *
  * @returns Pointer to the allocated UTF-8 substring.
@@ -174,8 +231,19 @@
  *                          the terminator.
  */
-RTDECL(char *) RTStrDupN(const char *pszString, size_t cchMax);
-
-/**
- * Appends a string onto an existing IPRT allocated string.
+#define RTStrDupN(pszString, cchMax)        RTStrDupNTag((pszString), (cchMax), RTSTR_TAG)
+
+/**
+ * Allocates a new copy of the given UTF-8 substring (custom tag).
+ *
+ * @returns Pointer to the allocated UTF-8 substring.
+ * @param   pszString       UTF-8 string to duplicate.
+ * @param   cchMax          The max number of chars to duplicate, not counting
+ *                          the terminator.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(char *) RTStrDupNTag(const char *pszString, size_t cchMax, const char *pszTag);
+
+/**
+ * Appends a string onto an existing IPRT allocated string (defaul tag).
  *
  * @retval  VINF_SUCCESS
@@ -189,8 +257,25 @@
  *                              are quietly ignored.
  */
-RTDECL(int) RTStrAAppend(char **ppsz, const char *pszAppend);
-
-/**
- * Appends N bytes from a strings onto an existing IPRT allocated string.
+#define RTStrAAppend(ppsz, pszAppend)   RTStrAAppendTag((ppsz), (pszAppend), RTSTR_TAG)
+
+/**
+ * Appends a string onto an existing IPRT allocated string (custom tag).
+ *
+ * @retval  VINF_SUCCESS
+ * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
+ *          remains unchanged.
+ *
+ * @param   ppsz                Pointer to the string pointer.  The string
+ *                              pointer must either be NULL or point to a string
+ *                              returned by an IPRT string API.  (In/Out)
+ * @param   pszAppend           The string to append.  NULL and empty strings
+ *                              are quietly ignored.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrAAppendTag(char **ppsz, const char *pszAppend, const char *pszTag);
+
+/**
+ * Appends N bytes from a strings onto an existing IPRT allocated string
+ * (default tag).
  *
  * @retval  VINF_SUCCESS
@@ -209,5 +294,27 @@
  *                              of @a pszAppend without having to strlen it.
  */
-RTDECL(int) RTStrAAppendN(char **ppsz, const char *pszAppend, size_t cchAppend);
+#define RTStrAAppendN(ppsz, pszAppend, cchAppend)   RTStrAAppendNTag((ppsz), (pszAppend), (cchAppend), RTSTR_TAG)
+
+/**
+ * Appends N bytes from a strings onto an existing IPRT allocated string (custom
+ * tag).
+ *
+ * @retval  VINF_SUCCESS
+ * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
+ *          remains unchanged.
+ *
+ * @param   ppsz                Pointer to the string pointer.  The string
+ *                              pointer must either be NULL or point to a string
+ *                              returned by an IPRT string API.  (In/Out)
+ * @param   pszAppend           The string to append.  Can be NULL if cchAppend
+ *                              is NULL.
+ * @param   cchAppend           The number of chars (not code points) to append
+ *                              from pszAppend.   Must not be more than
+ *                              @a pszAppend contains, except for the special
+ *                              value RTSTR_MAX that can be used to indicate all
+ *                              of @a pszAppend without having to strlen it.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrAAppendNTag(char **ppsz, const char *pszAppend, size_t cchAppend, const char *pszTag);
 
 /**
@@ -230,8 +337,31 @@
  *                              the string in the first argument.
  */
-RTDECL(int) RTStrAAppendExNV(char **ppsz, size_t cPairs, va_list va);
+#define RTStrAAppendExNV(ppsz, cPairs, va)  RTStrAAppendExNVTag((ppsz), (cPairs), (va), RTSTR_TAG)
 
 /**
  * Appends one or more strings onto an existing IPRT allocated string.
+ *
+ * This is a very flexible and efficient alternative to using RTStrAPrintf to
+ * combine several strings together.
+ *
+ * @retval  VINF_SUCCESS
+ * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
+ *          remains unchanged.
+ *
+ * @param   ppsz                Pointer to the string pointer.  The string
+ *                              pointer must either be NULL or point to a string
+ *                              returned by an IPRT string API.  (In/Out)
+ * @param   cPairs              The number of string / length pairs in the
+ *                              @a va.
+ * @param   va                  List of string (const char *) and length
+ *                              (size_t) pairs.  The strings will be appended to
+ *                              the string in the first argument.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrAAppendExNVTag(char **ppsz, size_t cPairs, va_list va, const char *pszTag);
+
+/**
+ * Appends one or more strings onto an existing IPRT allocated string
+ * (untagged).
  *
  * This is a very flexible and efficient alternative to using RTStrAPrintf to
@@ -251,8 +381,47 @@
  *                              the string in the first argument.
  */
-RTDECL(int) RTStrAAppendExN(char **ppsz, size_t cPairs, ...);
-
-/**
- * Truncates an IPRT allocated string.
+DECLINLINE(int) RTStrAAppendExN(char **ppsz, size_t cPairs, ...)
+{
+    int     rc;
+    va_list va;
+    va_start(va, cPairs);
+    rc = RTStrAAppendExNVTag(ppsz, cPairs, va, RTSTR_TAG);
+    va_end(va);
+    return rc;
+}
+
+/**
+ * Appends one or more strings onto an existing IPRT allocated string (custom
+ * tag).
+ *
+ * This is a very flexible and efficient alternative to using RTStrAPrintf to
+ * combine several strings together.
+ *
+ * @retval  VINF_SUCCESS
+ * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
+ *          remains unchanged.
+ *
+ * @param   ppsz                Pointer to the string pointer.  The string
+ *                              pointer must either be NULL or point to a string
+ *                              returned by an IPRT string API.  (In/Out)
+ * @param   pszTag              Allocation tag used for statistics and such.
+ * @param   cPairs              The number of string / length pairs in the
+ *                              ellipsis.
+ * @param   ...                 List of string (const char *) and length
+ *                              (size_t) pairs.  The strings will be appended to
+ *                              the string in the first argument.
+ */
+DECLINLINE(int) RTStrAAppendExNTag(char **ppsz, const char *pszTag, size_t cPairs, ...)
+{
+    int     rc;
+    va_list va;
+    va_start(va, cPairs);
+    rc = RTStrAAppendExNVTag(ppsz, cPairs, va, pszTag);
+    va_end(va);
+    return rc;
+}
+
+/**
+ * Truncates an IPRT allocated string (default tag).
  *
  * @retval  VINF_SUCCESS.
@@ -269,8 +438,27 @@
  *                              assert on you.
  */
-RTDECL(int) RTStrATruncate(char **ppsz, size_t cchNew);
-
-/**
- * Allocates memory for string storage.
+#define RTStrATruncate(ppsz, cchNew)    RTStrATruncateTag((ppsz), (cchNew), RTSTR_TAG)
+
+/**
+ * Truncates an IPRT allocated string.
+ *
+ * @retval  VINF_SUCCESS.
+ * @retval  VERR_OUT_OF_RANGE if cchNew is too long.  Nothing is done.
+ *
+ * @param   ppsz                Pointer to the string pointer.  The string
+ *                              pointer can be NULL if @a cchNew is 0, no change
+ *                              is made then.  If we actually reallocate the
+ *                              string, the string pointer might be changed by
+ *                              this call.  (In/Out)
+ * @param   cchNew              The new string length (excluding the
+ *                              terminator).  The string must be at least this
+ *                              long or we'll return VERR_OUT_OF_RANGE and
+ *                              assert on you.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrATruncateTag(char **ppsz, size_t cchNew, const char *pszTag);
+
+/**
+ * Allocates memory for string storage (default tag).
  *
  * You should normally not use this function, except if there is some very
@@ -289,8 +477,29 @@
  *                              will allocate a terminator byte anyway.
  */
-RTDECL(char *) RTStrAlloc(size_t cb);
-
-/**
- * Allocates memory for string storage, with status code.
+#define RTStrAlloc(cb)                  RTStrAllocTag((cb), RTSTR_TAG)
+
+/**
+ * Allocates memory for string storage (custom tag).
+ *
+ * You should normally not use this function, except if there is some very
+ * custom string handling you need doing that isn't covered by any of the other
+ * APIs.
+ *
+ * @returns Pointer to the allocated string.  The first byte is always set
+ *          to the string terminator char, the contents of the remainder of the
+ *          memory is undefined.  The string must be freed by calling RTStrFree.
+ *
+ *          NULL is returned if the allocation failed.  Please translate this to
+ *          VERR_NO_STR_MEMORY and not VERR_NO_MEMORY.  Also consider
+ *          RTStrAllocEx if an IPRT status code is required.
+ *
+ * @param   cb                  How many bytes to allocate.  If this is zero, we
+ *                              will allocate a terminator byte anyway.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(char *) RTStrAllocTag(size_t cb, const char *pszTag);
+
+/**
+ * Allocates memory for string storage, with status code (default tag).
  *
  * You should normally not use this function, except if there is some very
@@ -310,8 +519,30 @@
  *                              will allocate a terminator byte anyway.
  */
-RTDECL(int) RTStrAllocEx(char **ppsz, size_t cb);
-
-/**
- * Reallocates the specifed string.
+#define RTStrAllocEx(ppsz, cb)      RTStrAllocExTag((ppsz), (cb), RTSTR_TAG)
+
+/**
+ * Allocates memory for string storage, with status code (custom tag).
+ *
+ * You should normally not use this function, except if there is some very
+ * custom string handling you need doing that isn't covered by any of the other
+ * APIs.
+ *
+ * @retval  VINF_SUCCESS
+ * @retval  VERR_NO_STR_MEMORY
+ *
+ * @param   ppsz                Where to return the allocated string.  This will
+ *                              be set to NULL on failure.  On success, the
+ *                              returned memory will always start with a
+ *                              terminator char so that it is considered a valid
+ *                              C string, the contents of rest of the memory is
+ *                              undefined.
+ * @param   cb                  How many bytes to allocate.  If this is zero, we
+ *                              will allocate a terminator byte anyway.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrAllocExTag(char **ppsz, size_t cb, const char *pszTag);
+
+/**
+ * Reallocates the specified string (default tag).
  *
  * You should normally not have use this function, except perhaps to truncate a
@@ -344,5 +575,40 @@
  *                              terminator char.
  */
-RTDECL(int) RTStrRealloc(char **ppsz, size_t cbNew);
+#define RTStrRealloc(ppsz, cbNew)       RTStrReallocTag((ppsz), (cbNew), RTSTR_TAG)
+
+/**
+ * Reallocates the specified string (custom tag).
+ *
+ * You should normally not have use this function, except perhaps to truncate a
+ * really long string you've got from some IPRT string API, but then you should
+ * use RTStrATruncate.
+ *
+ * @returns VINF_SUCCESS.
+ * @retval  VERR_NO_STR_MEMORY if we failed to reallocate the string, @a *ppsz
+ *          remains unchanged.
+ *
+ * @param   ppsz                Pointer to the string variable containing the
+ *                              input and output string.
+ *
+ *                              When not freeing the string, the result will
+ *                              always have the last byte set to the terminator
+ *                              character so that when used for string
+ *                              truncation the result will be a valid C string
+ *                              (your job to keep it a valid UTF-8 string).
+ *
+ *                              When the input string is NULL and we're supposed
+ *                              to reallocate, the returned string will also
+ *                              have the first byte set to the terminator char
+ *                              so it will be a valid C string.
+ *
+ * @param   cbNew               When @a cbNew is zero, we'll behave like
+ *                              RTStrFree and @a *ppsz will be set to NULL.
+ *
+ *                              When not zero, this will be the new size of the
+ *                              memory backing the string, i.e. it includes the
+ *                              terminator char.
+ * @param   pszTag              Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrReallocTag(char **ppsz, size_t cbNew, const char *pszTag);
 
 /**
@@ -477,5 +743,6 @@
 
 /**
- * Translate a UTF-8 string into a UTF-16 allocating the result buffer.
+ * Translate a UTF-8 string into a UTF-16 allocating the result buffer (default
+ * tag).
  *
  * @returns iprt status code.
@@ -484,5 +751,17 @@
  *                          The returned string must be freed using RTUtf16Free().
  */
-RTDECL(int) RTStrToUtf16(const char *pszString, PRTUTF16 *ppwszString);
+#define RTStrToUtf16(pszString, ppwszString)    RTStrToUtf16Tag((pszString), (ppwszString), RTSTR_TAG)
+
+/**
+ * Translate a UTF-8 string into a UTF-16 allocating the result buffer (custom
+ * tag).
+ *
+ * @returns iprt status code.
+ * @param   pszString       UTF-8 string to convert.
+ * @param   ppwszString     Receives pointer to the allocated UTF-16 string.
+ *                          The returned string must be freed using RTUtf16Free().
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag);
 
 /**
@@ -508,5 +787,32 @@
  *                          length that can be used to resize the buffer.
  */
-RTDECL(int)  RTStrToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc);
+#define RTStrToUtf16Ex(pszString, cchString, ppwsz, cwc, pcwc) \
+    RTStrToUtf16ExTag((pszString), (cchString), (ppwsz), (cwc), (pcwc), RTSTR_TAG)
+
+/**
+ * Translates pszString from UTF-8 to UTF-16, allocating the result buffer if
+ * requested (custom tag).
+ *
+ * @returns iprt status code.
+ * @param   pszString       UTF-8 string to convert.
+ * @param   cchString       The maximum size in chars (the type) to convert. The conversion stop
+ *                          when it reaches cchString or the string terminator ('\\0').
+ *                          Use RTSTR_MAX to translate the entire string.
+ * @param   ppwsz           If cwc is non-zero, this must either be pointing to pointer to
+ *                          a buffer of the specified size, or pointer to a NULL pointer.
+ *                          If *ppwsz is NULL or cwc is zero a buffer of at least cwc items
+ *                          will be allocated to hold the translated string.
+ *                          If a buffer was requested it must be freed using RTUtf16Free().
+ * @param   cwc             The buffer size in RTUTF16s. This includes the terminator.
+ * @param   pcwc            Where to store the length of the translated string,
+ *                          excluding the terminator. (Optional)
+ *
+ *                          This may be set under some error conditions,
+ *                          however, only for VERR_BUFFER_OVERFLOW and
+ *                          VERR_NO_STR_MEMORY will it contain a valid string
+ *                          length that can be used to resize the buffer.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int)  RTStrToUtf16ExTag(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
 
 
@@ -948,5 +1254,5 @@
 
 /**
- * Allocating string printf.
+ * Allocating string printf (default tag).
  *
  * @returns The length of the string in the returned *ppszBuffer.
@@ -958,5 +1264,19 @@
  * @param   args        The format argument.
  */
-RTDECL(int) RTStrAPrintfV(char **ppszBuffer, const char *pszFormat, va_list args);
+#define RTStrAPrintfV(ppszBuffer, pszFormat, args)      RTStrAPrintfVTag((ppszBuffer), (pszFormat), (args), RTSTR_TAG)
+
+/**
+ * Allocating string printf (custom tag).
+ *
+ * @returns The length of the string in the returned *ppszBuffer.
+ * @returns -1 on failure.
+ * @param   ppszBuffer  Where to store the pointer to the allocated output buffer.
+ *                      The buffer should be freed using RTStrFree().
+ *                      On failure *ppszBuffer will be set to NULL.
+ * @param   pszFormat   The format string.
+ * @param   args        The format argument.
+ * @param   pszTag      Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag);
 
 /**
@@ -971,5 +1291,35 @@
  * @param   ...         The format argument.
  */
-RTDECL(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...);
+DECLINLINE(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...)
+{
+    int     cbRet;
+    va_list va;
+    va_start(va, pszFormat);
+    cbRet = RTStrAPrintfVTag(ppszBuffer, pszFormat, va, RTSTR_TAG);
+    va_end(va);
+    return cbRet;
+}
+
+/**
+ * Allocating string printf (custom tag).
+ *
+ * @returns The length of the string in the returned *ppszBuffer.
+ * @returns -1 on failure.
+ * @param   ppszBuffer  Where to store the pointer to the allocated output buffer.
+ *                      The buffer should be freed using RTStrFree().
+ *                      On failure *ppszBuffer will be set to NULL.
+ * @param   pszTag      Allocation tag used for statistics and such.
+ * @param   pszFormat   The format string.
+ * @param   ...         The format argument.
+ */
+DECLINLINE(int) RTStrAPrintfTag(char **ppszBuffer, const char *pszTag, const char *pszFormat, ...)
+{
+    int     cbRet;
+    va_list va;
+    va_start(va, pszFormat);
+    cbRet = RTStrAPrintfVTag(ppszBuffer, pszFormat, va, pszTag);
+    va_end(va);
+    return cbRet;
+}
 
 /**
@@ -981,8 +1331,19 @@
  * @param   args        The format argument.
  */
-RTDECL(char *) RTStrAPrintf2V(const char *pszFormat, va_list args);
-
-/**
- * Allocating string printf, version2.
+#define RTStrAPrintf2V(pszFormat, args)     RTStrAPrintf2VTag((pszFormat), (args), RTSTR_TAG)
+
+/**
+ * Allocating string printf, version 2.
+ *
+ * @returns Formatted string. Use RTStrFree() to free it. NULL when out of
+ *          memory.
+ * @param   pszFormat   The format string.
+ * @param   args        The format argument.
+ * @param   pszTag      Allocation tag used for statistics and such.
+ */
+RTDECL(char *) RTStrAPrintf2VTag(const char *pszFormat, va_list args, const char *pszTag);
+
+/**
+ * Allocating string printf, version 2 (default tag).
  *
  * @returns Formatted string. Use RTStrFree() to free it. NULL when out of
@@ -991,5 +1352,32 @@
  * @param   ...         The format argument.
  */
-RTDECL(char *) RTStrAPrintf2(const char *pszFormat, ...);
+DECLINLINE(char *) RTStrAPrintf2(const char *pszFormat, ...)
+{
+    char   *pszRet;
+    va_list va;
+    va_start(va, pszFormat);
+    pszRet = RTStrAPrintf2VTag(pszFormat, va, RTSTR_TAG);
+    va_end(va);
+    return pszRet;
+}
+
+/**
+ * Allocating string printf, version 2 (custom tag).
+ *
+ * @returns Formatted string. Use RTStrFree() to free it. NULL when out of
+ *          memory.
+ * @param   pszTag      Allocation tag used for statistics and such.
+ * @param   pszFormat   The format string.
+ * @param   ...         The format argument.
+ */
+DECLINLINE(char *) RTStrAPrintf2Tag(const char *pszTag, const char *pszFormat, ...)
+{
+    char   *pszRet;
+    va_list va;
+    va_start(va, pszFormat);
+    pszRet = RTStrAPrintf2VTag(pszFormat, va, pszTag);
+    va_end(va);
+    return pszRet;
+}
 
 /**
@@ -1887,5 +2275,5 @@
 
 /**
- * Allocates a new copy of the specified UTF-16 string.
+ * Allocates a new copy of the specified UTF-16 string (default tag).
  *
  * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
@@ -1894,8 +2282,19 @@
  * @remark  This function will not make any attempt to validate the encoding.
  */
-RTDECL(PRTUTF16) RTUtf16Dup(PCRTUTF16 pwszString);
-
-/**
- * Allocates a new copy of the specified UTF-16 string.
+#define RTUtf16Dup(pwszString)          RTUtf16DupTag((pwszString), RTSTR_TAG)
+
+/**
+ * Allocates a new copy of the specified UTF-16 string (custom tag).
+ *
+ * @returns Pointer to the allocated string copy. Use RTUtf16Free() to free it.
+ * @returns NULL when out of memory.
+ * @param   pwszString      UTF-16 string to duplicate.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ * @remark  This function will not make any attempt to validate the encoding.
+ */
+RTDECL(PRTUTF16) RTUtf16DupTag(PCRTUTF16 pwszString, const char *pszTag);
+
+/**
+ * Allocates a new copy of the specified UTF-16 string (default tag).
  *
  * @returns iprt status code.
@@ -1906,5 +2305,19 @@
  * @remark  This function will not make any attempt to validate the encoding.
  */
-RTDECL(int) RTUtf16DupEx(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra);
+#define RTUtf16DupEx(ppwszString, pwszString, cwcExtra) \
+    RTUtf16DupExTag((ppwszString), (pwszString), (cwcExtra), RTSTR_TAG)
+
+/**
+ * Allocates a new copy of the specified UTF-16 string (custom tag).
+ *
+ * @returns iprt status code.
+ * @param   ppwszString     Receives pointer of the allocated UTF-16 string.
+ *                          The returned pointer must be freed using RTUtf16Free().
+ * @param   pwszString      UTF-16 string to duplicate.
+ * @param   cwcExtra        Number of extra RTUTF16 items to allocate.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ * @remark  This function will not make any attempt to validate the encoding.
+ */
+RTDECL(int) RTUtf16DupExTag(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra, const char *pszTag);
 
 /**
@@ -1991,5 +2404,6 @@
 
 /**
- * Translate a UTF-16 string into a UTF-8 allocating the result buffer.
+ * Translate a UTF-16 string into a UTF-8 allocating the result buffer (default
+ * tag).
  *
  * @returns iprt status code.
@@ -1999,9 +2413,21 @@
  *                          The returned pointer must be freed using RTStrFree().
  */
-RTDECL(int)  RTUtf16ToUtf8(PCRTUTF16 pwszString, char **ppszString);
-
-/**
- * Translates UTF-16 to UTF-8 using buffer provided by the caller or
- * a fittingly sized buffer allocated by the function.
+#define RTUtf16ToUtf8(pwszString, ppszString)       RTUtf16ToUtf8Tag((pwszString), (ppszString), RTSTR_TAG)
+
+/**
+ * Translate a UTF-16 string into a UTF-8 allocating the result buffer.
+ *
+ * @returns iprt status code.
+ * @param   pwszString      UTF-16 string to convert.
+ * @param   ppszString      Receives pointer of allocated UTF-8 string on
+ *                          success, and is always set to NULL on failure.
+ *                          The returned pointer must be freed using RTStrFree().
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int)  RTUtf16ToUtf8Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
+
+/**
+ * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
+ * sized buffer allocated by the function (default tag).
  *
  * @returns iprt status code.
@@ -2024,5 +2450,32 @@
  *                          length that can be used to resize the buffer.
  */
-RTDECL(int)  RTUtf16ToUtf8Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch);
+#define RTUtf16ToUtf8Ex(pwszString, cwcString, ppsz, cch, pcch) \
+    RTUtf16ToUtf8ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
+
+/**
+ * Translates UTF-16 to UTF-8 using buffer provided by the caller or a fittingly
+ * sized buffer allocated by the function (custom tag).
+ *
+ * @returns iprt status code.
+ * @param   pwszString      The UTF-16 string to convert.
+ * @param   cwcString       The number of RTUTF16 items to translate from pwszString.
+ *                          The translation will stop when reaching cwcString or the terminator ('\\0').
+ *                          Use RTSTR_MAX to translate the entire string.
+ * @param   ppsz            If cch is non-zero, this must either be pointing to a pointer to
+ *                          a buffer of the specified size, or pointer to a NULL pointer.
+ *                          If *ppsz is NULL or cch is zero a buffer of at least cch chars
+ *                          will be allocated to hold the translated string.
+ *                          If a buffer was requested it must be freed using RTStrFree().
+ * @param   cch             The buffer size in chars (the type). This includes the terminator.
+ * @param   pcch            Where to store the length of the translated string,
+ *                          excluding the terminator. (Optional)
+ *
+ *                          This may be set under some error conditions,
+ *                          however, only for VERR_BUFFER_OVERFLOW and
+ *                          VERR_NO_STR_MEMORY will it contain a valid string
+ *                          length that can be used to resize the buffer.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int)  RTUtf16ToUtf8ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
 
 /**
@@ -2056,5 +2509,5 @@
 /**
  * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
- * buffer.
+ * buffer (default tag).
  *
  * @returns iprt status code.
@@ -2064,9 +2517,22 @@
  *                          The returned pointer must be freed using RTStrFree().
  */
-RTDECL(int)  RTUtf16ToLatin1(PCRTUTF16 pwszString, char **ppszString);
+#define RTUtf16ToLatin1(pwszString, ppszString)     RTUtf16ToLatin1Tag((pwszString), (ppszString), RTSTR_TAG)
+
+/**
+ * Translate a UTF-16 string into a Latin-1 (ISO-8859-1) allocating the result
+ * buffer (custom tag).
+ *
+ * @returns iprt status code.
+ * @param   pwszString      UTF-16 string to convert.
+ * @param   ppszString      Receives pointer of allocated Latin1 string on
+ *                          success, and is always set to NULL on failure.
+ *                          The returned pointer must be freed using RTStrFree().
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int)  RTUtf16ToLatin1Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag);
 
 /**
  * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
- * or a fittingly sized buffer allocated by the function.
+ * or a fittingly sized buffer allocated by the function (default tag).
  *
  * @returns iprt status code.
@@ -2101,5 +2567,44 @@
  *                          length that can be used to resize the buffer.
  */
-RTDECL(int)  RTUtf16ToLatin1Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch);
+#define RTUtf16ToLatin1Ex(pwszString, cwcString, ppsz, cch, pcch) \
+    RTUtf16ToLatin1ExTag((pwszString), (cwcString), (ppsz), (cch), (pcch), RTSTR_TAG)
+
+/**
+ * Translates UTF-16 to Latin-1 (ISO-8859-1) using buffer provided by the caller
+ * or a fittingly sized buffer allocated by the function (custom tag).
+ *
+ * @returns iprt status code.
+ * @param   pwszString      The UTF-16 string to convert.
+ * @param   cwcString       The number of RTUTF16 items to translate from
+ *                          pwszString. The translation will stop when reaching
+ *                          cwcString or the terminator ('\\0'). Use RTSTR_MAX
+ *                          to translate the entire string.
+ * @param   ppsz            Pointer to the pointer to the Latin-1 string. The
+ *                          buffer can optionally be preallocated by the caller.
+ *
+ *                          If cch is zero, *ppsz is undefined.
+ *
+ *                          If cch is non-zero and *ppsz is not NULL, then this
+ *                          will be used as the output buffer.
+ *                          VERR_BUFFER_OVERFLOW will be returned if this is
+ *                          insufficient.
+ *
+ *                          If cch is zero or *ppsz is NULL, then a buffer of
+ *                          sufficent size is allocated. cch can be used to
+ *                          specify a minimum size of this buffer. Use
+ *                          RTUtf16Free() to free the result.
+ *
+ * @param   cch             The buffer size in chars (the type). This includes
+ *                          the terminator.
+ * @param   pcch            Where to store the length of the translated string,
+ *                          excluding the terminator. (Optional)
+ *
+ *                          This may be set under some error conditions,
+ *                          however, only for VERR_BUFFER_OVERFLOW and
+ *                          VERR_NO_STR_MEMORY will it contain a valid string
+ *                          length that can be used to resize the buffer.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int)  RTUtf16ToLatin1ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag);
 
 /**
@@ -2338,5 +2843,5 @@
 /**
  * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
- * buffer.
+ * buffer (default tag).
  *
  * @returns iprt status code.
@@ -2345,9 +2850,21 @@
  *                          returned string must be freed using RTUtf16Free().
  */
-RTDECL(int) RTLatin1ToUtf16(const char *pszString, PRTUTF16 *ppwszString);
+#define RTLatin1ToUtf16(pszString, ppwszString)     RTLatin1ToUtf16Tag((pszString), (ppwszString), RTSTR_TAG)
+
+/**
+ * Translate a Latin-1 (ISO-8859-1) string into a UTF-16 allocating the result
+ * buffer (custom tag).
+ *
+ * @returns iprt status code.
+ * @param   pszString       The Latin-1 string to convert.
+ * @param   ppwszString     Receives pointer to the allocated UTF-16 string. The
+ *                          returned string must be freed using RTUtf16Free().
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTLatin1ToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag);
 
 /**
  * Translates pszString from Latin-1 (ISO-8859-1) to UTF-16, allocating the
- * result buffer if requested.
+ * result buffer if requested (default tag).
  *
  * @returns iprt status code.
@@ -2374,5 +2891,37 @@
  *                          length that can be used to resize the buffer.
  */
-RTDECL(int) RTLatin1ToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc);
+#define RTLatin1ToUtf16Ex(pszString, cchString, ppwsz, cwc, pcwc) \
+    RTLatin1ToUtf16ExTag((pszString), (cchString), (ppwsz), (cwc), (pcwc), RTSTR_TAG)
+
+/**
+ * Translates pszString from Latin-1 (ISO-8859-1) to UTF-16, allocating the
+ * result buffer if requested.
+ *
+ * @returns iprt status code.
+ * @param   pszString       The Latin-1 string to convert.
+ * @param   cchString       The maximum size in chars (the type) to convert.
+ *                          The conversion stops when it reaches cchString or
+ *                          the string terminator ('\\0').
+ *                          Use RTSTR_MAX to translate the entire string.
+ * @param   ppwsz           If cwc is non-zero, this must either be pointing
+ *                          to pointer to a buffer of the specified size, or
+ *                          pointer to a NULL pointer.
+ *                          If *ppwsz is NULL or cwc is zero a buffer of at
+ *                          least cwc items will be allocated to hold the
+ *                          translated string. If a buffer was requested it
+ *                          must be freed using RTUtf16Free().
+ * @param   cwc             The buffer size in RTUTF16s. This includes the
+ *                          terminator.
+ * @param   pcwc            Where to store the length of the translated string,
+ *                          excluding the terminator. (Optional)
+ *
+ *                          This may be set under some error conditions,
+ *                          however, only for VERR_BUFFER_OVERFLOW and
+ *                          VERR_NO_STR_MEMORY will it contain a valid string
+ *                          length that can be used to resize the buffer.
+ * @param   pszTag          Allocation tag used for statistics and such.
+ */
+RTDECL(int) RTLatin1ToUtf16ExTag(const char *pszString, size_t cchString,
+                                 PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag);
 
 /** @} */
Index: /trunk/src/VBox/HostDrivers/Support/SUPDrv.c
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPDrv.c	(revision 31156)
+++ /trunk/src/VBox/HostDrivers/Support/SUPDrv.c	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -181,21 +181,23 @@
     { "SUPGetGIP",                              (void *)SUPGetGIP },
     { "g_pSUPGlobalInfoPage",                   (void *)&g_pSUPGlobalInfoPage },
-    { "RTMemAlloc",                             (void *)RTMemAlloc },
-    { "RTMemAllocZ",                            (void *)RTMemAllocZ },
+    { "RTMemAllocTag",                          (void *)RTMemAllocTag },
+    { "RTMemAllocZTag",                         (void *)RTMemAllocZTag },
+    { "RTMemAllocVarTag",                       (void *)RTMemAllocVarTag },
+    { "RTMemAllocZVarTag",                      (void *)RTMemAllocZVarTag },
     { "RTMemFree",                              (void *)RTMemFree },
-    /*{ "RTMemDup",                               (void *)RTMemDup },
-    { "RTMemDupEx",                             (void *)RTMemDupEx },*/
-    { "RTMemRealloc",                           (void *)RTMemRealloc },
-    { "RTR0MemObjAllocLow",                     (void *)RTR0MemObjAllocLow },
-    { "RTR0MemObjAllocPage",                    (void *)RTR0MemObjAllocPage },
-    { "RTR0MemObjAllocPhys",                    (void *)RTR0MemObjAllocPhys },
-    { "RTR0MemObjAllocPhysEx",                  (void *)RTR0MemObjAllocPhysEx },
-    { "RTR0MemObjAllocPhysNC",                  (void *)RTR0MemObjAllocPhysNC },
-    { "RTR0MemObjAllocCont",                    (void *)RTR0MemObjAllocCont },
-    { "RTR0MemObjEnterPhys",                    (void *)RTR0MemObjEnterPhys },
-    { "RTR0MemObjLockUser",                     (void *)RTR0MemObjLockUser },
-    { "RTR0MemObjMapKernel",                    (void *)RTR0MemObjMapKernel },
-    { "RTR0MemObjMapKernelEx",                  (void *)RTR0MemObjMapKernelEx },
-    { "RTR0MemObjMapUser",                      (void *)RTR0MemObjMapUser },
+    { "RTMemDupTag",                            (void *)RTMemDupTag },
+    { "RTMemDupExTag",                          (void *)RTMemDupExTag },
+    { "RTMemReallocTag",                        (void *)RTMemReallocTag },
+    { "RTR0MemObjAllocLowTag",                  (void *)RTR0MemObjAllocLowTag },
+    { "RTR0MemObjAllocPageTag",                 (void *)RTR0MemObjAllocPageTag },
+    { "RTR0MemObjAllocPhysTag",                 (void *)RTR0MemObjAllocPhysTag },
+    { "RTR0MemObjAllocPhysExTag",               (void *)RTR0MemObjAllocPhysExTag },
+    { "RTR0MemObjAllocPhysNCTag",               (void *)RTR0MemObjAllocPhysNCTag },
+    { "RTR0MemObjAllocContTag",                 (void *)RTR0MemObjAllocContTag },
+    { "RTR0MemObjEnterPhysTag",                 (void *)RTR0MemObjEnterPhysTag },
+    { "RTR0MemObjLockUserTag",                  (void *)RTR0MemObjLockUserTag },
+    { "RTR0MemObjMapKernelTag",                 (void *)RTR0MemObjMapKernelTag },
+    { "RTR0MemObjMapKernelExTag",               (void *)RTR0MemObjMapKernelExTag },
+    { "RTR0MemObjMapUserTag",                   (void *)RTR0MemObjMapUserTag },
     { "RTR0MemObjProtect",                      (void *)RTR0MemObjProtect },
     { "RTR0MemObjAddress",                      (void *)RTR0MemObjAddress },
@@ -359,5 +361,5 @@
     (PFNRT)RTUuidCompareStr,
     (PFNRT)RTUuidFromStr,
-    (PFNRT)RTStrDup,
+    (PFNRT)RTStrDupTag,
     (PFNRT)RTStrFree,
     /* VBoxNetAdp */
@@ -1256,5 +1258,6 @@
                     REQ_CHECK_EXPR_FMT(paSyms[i].offName < pReq->u.In.cbStrTab,
                                        ("SUP_IOCTL_LDR_LOAD: sym #%ld: name off %#lx (max=%#lx)\n", (long)i, (long)paSyms[i].offName, (long)pReq->u.In.cbImageWithTabs));
-                    REQ_CHECK_EXPR_FMT(RTStrEnd(&pReq->u.In.abImage[pReq->u.In.offStrTab + paSyms[i].offName], pReq->u.In.cbStrTab - paSyms[i].offName),
+                    REQ_CHECK_EXPR_FMT(RTStrEnd((char const *)&pReq->u.In.abImage[pReq->u.In.offStrTab + paSyms[i].offName],
+                                                pReq->u.In.cbStrTab - paSyms[i].offName),
                                        ("SUP_IOCTL_LDR_LOAD: sym #%ld: unterminated name! (%#lx / %#lx)\n", (long)i, (long)paSyms[i].offName, (long)pReq->u.In.cbImageWithTabs));
                 }
Index: /trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h	(revision 31156)
+++ /trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -193,5 +193,5 @@
  *          - Nothing.
  */
-#define SUPDRV_IOC_VERSION                              0x00140001
+#define SUPDRV_IOC_VERSION                              0x00150000
 
 /** SUP_IOCTL_COOKIE. */
Index: /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp	(revision 31156)
+++ /trunk/src/VBox/HostDrivers/Support/SUPLib.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -268,7 +268,7 @@
         strcpy(CookieReq.u.In.szMagic, SUPCOOKIE_MAGIC);
         CookieReq.u.In.u32ReqVersion = SUPDRV_IOC_VERSION;
-        const uint32_t uMinVersion = (SUPDRV_IOC_VERSION & 0xffff0000) == 0x00140000
-                                   ?  0x00140001
-                                   :  SUPDRV_IOC_VERSION & 0xffff0000;
+        const uint32_t uMinVersion = /*(SUPDRV_IOC_VERSION & 0xffff0000) == 0x00150000
+                                   ?  0x00150001
+                                   :*/ SUPDRV_IOC_VERSION & 0xffff0000;
         CookieReq.u.In.u32MinVersion = uMinVersion;
         rc = suplibOsIOCtl(&g_supLibData, SUP_IOCTL_COOKIE, &CookieReq, SUP_IOCTL_COOKIE_SIZE);
Index: /trunk/src/VBox/Runtime/common/alloc/alloc.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/alloc/alloc.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/common/alloc/alloc.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -36,39 +36,23 @@
 
 #undef RTMemDup
+#undef RTMemDupTag
 #undef RTMemDupEx
+#undef RTMemDupExTag
 
 
 
-/**
- * Duplicates a chunk of memory into a new heap block.
- *
- * @returns New heap block with the duplicate data.
- * @returns NULL if we're out of memory.
- * @param   pvSrc   The memory to duplicate.
- * @param   cb      The amount of memory to duplicate.
- */
-RTDECL(void *) RTMemDup(const void *pvSrc, size_t cb) RT_NO_THROW
+RTDECL(void *) RTMemDupTag(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW
 {
-    void *pvDst = RTMemAlloc(cb);
+    void *pvDst = RTMemAllocTag(cb, pszTag);
     if (pvDst)
         memcpy(pvDst, pvSrc, cb);
     return pvDst;
 }
-RT_EXPORT_SYMBOL(RTMemDup);
+RT_EXPORT_SYMBOL(RTMemDupTag);
 
 
-/**
- * Duplicates a chunk of memory into a new heap block with some
- * additional zeroed memory.
- *
- * @returns New heap block with the duplicate data.
- * @returns NULL if we're out of memory.
- * @param   pvSrc   The memory to duplicate.
- * @param   cbSrc   The amount of memory to duplicate.
- * @param   cbExtra The amount of extra memory to allocate and zero.
- */
-RTDECL(void *) RTMemDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW
+RTDECL(void *) RTMemDupExTag(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW
 {
-    void *pvDst = RTMemAlloc(cbSrc + cbExtra);
+    void *pvDst = RTMemAllocTag(cbSrc + cbExtra, pszTag);
     if (pvDst)
     {
@@ -78,4 +62,4 @@
     return pvDst;
 }
-RT_EXPORT_SYMBOL(RTMemDupEx);
+RT_EXPORT_SYMBOL(RTMemDupExTag);
 
Index: /trunk/src/VBox/Runtime/common/string/straprintf.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/straprintf.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/common/string/straprintf.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -43,14 +43,16 @@
 {
     /** Pointer to current buffer position. */
-    char   *psz;
+    char       *psz;
     /** Number of bytes left in the buffer - not including the trailing zero. */
-    size_t  cch;
+    size_t      cch;
     /** Pointer to the start of the buffer. */
-    char   *pszBuffer;
+    char       *pszBuffer;
     /** The number of bytes in the buffer. */
-    size_t  cchBuffer;
+    size_t      cchBuffer;
     /** Set if the buffer was allocated using RTMemRealloc(). If clear
      * pszBuffer points to the initial stack buffer. */
-    bool    fAllocated;
+    bool        fAllocated;
+    /** Allocation tag used for statistics and such. */
+    const char *pszTag;
 } STRALLOCARG;
 /** Pointer to a strallocoutput() argument structure. */
@@ -100,5 +102,6 @@
         if (cbAdded <= _1G)
         {
-            char *pszBuffer = (char *)RTMemRealloc(pArg->fAllocated ? pArg->pszBuffer : NULL, cbAdded + pArg->cchBuffer);
+            char *pszBuffer = (char *)RTMemReallocTag(pArg->fAllocated ? pArg->pszBuffer : NULL,
+                                                      cbAdded + pArg->cchBuffer, pArg->pszTag);
             if (pszBuffer)
             {
@@ -135,5 +138,5 @@
 
 
-RTDECL(int) RTStrAPrintfV(char **ppszBuffer, const char *pszFormat, va_list args)
+RTDECL(int) RTStrAPrintfVTag(char **ppszBuffer, const char *pszFormat, va_list args, const char *pszTag)
 {
     char            szBuf[2048];
@@ -144,4 +147,5 @@
     Arg.cch         = sizeof(szBuf) - 1;
     Arg.psz         = szBuf;
+    Arg.pszTag      = pszTag;
     szBuf[0] = '\0';
     int cbRet = (int)RTStrFormatV(strallocoutput, &Arg, NULL, NULL, pszFormat, args);
@@ -152,5 +156,5 @@
             /* duplicate the string in szBuf */
             Assert(Arg.pszBuffer == szBuf);
-            char *psz = (char *)RTMemAlloc(cbRet + 1);
+            char *psz = (char *)RTMemAllocTag(cbRet + 1, pszTag);
             if (psz)
                 memcpy(psz, szBuf, cbRet + 1);
@@ -160,5 +164,5 @@
         {
             /* adjust the allocated buffer */
-            char *psz = (char *)RTMemRealloc(Arg.pszBuffer, cbRet + 1);
+            char *psz = (char *)RTMemReallocTag(Arg.pszBuffer, cbRet + 1, pszTag);
             *ppszBuffer = psz ? psz : Arg.pszBuffer;
         }
@@ -177,38 +181,13 @@
     return cbRet;
 }
-RT_EXPORT_SYMBOL(RTStrAPrintfV);
+RT_EXPORT_SYMBOL(RTStrAPrintfVTag);
 
 
-RTDECL(int) RTStrAPrintf(char **ppszBuffer, const char *pszFormat, ...)
-{
-    va_list args;
-    va_start(args, pszFormat);
-    int cbRet = RTStrAPrintfV(ppszBuffer, pszFormat, args);
-    va_end(args);
-    return cbRet;
-}
-RT_EXPORT_SYMBOL(RTStrAPrintf);
-
-
-RTDECL(char *) RTStrAPrintf2V(const char *pszFormat, va_list args)
+RTDECL(char *) RTStrAPrintf2VTag(const char *pszFormat, va_list args, const char *pszTag)
 {
     char *pszBuffer;
-    RTStrAPrintfV(&pszBuffer, pszFormat, args);
+    RTStrAPrintfVTag(&pszBuffer, pszFormat, args, pszTag);
     return pszBuffer;
 }
-RT_EXPORT_SYMBOL(RTStrAPrintf2V);
+RT_EXPORT_SYMBOL(RTStrAPrintf2VTag);
 
-
-RTDECL(char *) RTStrAPrintf2(const char *pszFormat, ...)
-{
-    va_list va;
-    char   *pszBuffer;
-
-    va_start(va, pszFormat);
-    RTStrAPrintfV(&pszBuffer, pszFormat, va);
-    va_end(va);
-
-    return pszBuffer;
-}
-RT_EXPORT_SYMBOL(RTStrAPrintf2);
-
Index: /trunk/src/VBox/Runtime/common/string/stringalloc.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/stringalloc.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/common/string/stringalloc.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -40,17 +40,17 @@
 
 
-RTDECL(char *) RTStrAlloc(size_t cb)
-{
-    char *psz = (char *)RTMemAlloc(RT_MAX(cb, 1));
+RTDECL(char *) RTStrAllocTag(size_t cb, const char *pszTag)
+{
+    char *psz = (char *)RTMemAllocTag(RT_MAX(cb, 1), pszTag);
     if (psz)
         *psz = '\0';
     return psz;
 }
-RT_EXPORT_SYMBOL(RTStrAlloc);
-
-
-RTDECL(int) RTStrAllocEx(char **ppsz, size_t cb)
-{
-    char *psz = *ppsz = (char *)RTMemAlloc(RT_MAX(cb, 1));
+RT_EXPORT_SYMBOL(RTStrAllocTag);
+
+
+RTDECL(int) RTStrAllocExTag(char **ppsz, size_t cb, const char *pszTag)
+{
+    char *psz = *ppsz = (char *)RTMemAllocTag(RT_MAX(cb, 1), pszTag);
     if (psz)
     {
@@ -60,8 +60,8 @@
     return VERR_NO_STR_MEMORY;
 }
-RT_EXPORT_SYMBOL(RTStrAlloc);
-
-
-RTDECL(int) RTStrRealloc(char **ppsz, size_t cbNew)
+RT_EXPORT_SYMBOL(RTStrAllocTag);
+
+
+RTDECL(int) RTStrReallocTag(char **ppsz, size_t cbNew, const char *pszTag)
 {
     char *pszOld = *ppsz;
@@ -73,5 +73,5 @@
     else if (pszOld)
     {
-        char *pszNew = (char *)RTMemRealloc(pszOld, cbNew);
+        char *pszNew = (char *)RTMemReallocTag(pszOld, cbNew, pszTag);
         if (!pszNew)
             return VERR_NO_STR_MEMORY;
@@ -81,5 +81,5 @@
     else
     {
-        char *pszNew = (char *)RTMemAlloc(cbNew);
+        char *pszNew = (char *)RTMemAllocTag(cbNew, pszTag);
         if (!pszNew)
             return VERR_NO_STR_MEMORY;
@@ -90,4 +90,5 @@
     return VINF_SUCCESS;
 }
+RT_EXPORT_SYMBOL(RTStrReallocTag);
 
 RTDECL(void)  RTStrFree(char *pszString)
@@ -99,17 +100,17 @@
 
 
-RTDECL(char *) RTStrDup(const char *pszString)
+RTDECL(char *) RTStrDupTag(const char *pszString, const char *pszTag)
 {
     AssertPtr(pszString);
     size_t cch = strlen(pszString) + 1;
-    char *psz = (char *)RTMemAlloc(cch);
+    char *psz = (char *)RTMemAllocTag(cch, pszTag);
     if (psz)
         memcpy(psz, pszString, cch);
     return psz;
 }
-RT_EXPORT_SYMBOL(RTStrDup);
-
-
-RTDECL(int)  RTStrDupEx(char **ppszString, const char *pszString)
+RT_EXPORT_SYMBOL(RTStrDupTag);
+
+
+RTDECL(int)  RTStrDupExTag(char **ppszString, const char *pszString, const char *pszTag)
 {
     AssertPtr(ppszString);
@@ -117,5 +118,5 @@
 
     size_t cch = strlen(pszString) + 1;
-    char *psz = (char *)RTMemAlloc(cch);
+    char *psz = (char *)RTMemAllocTag(cch, pszTag);
     if (psz)
     {
@@ -126,13 +127,13 @@
     return VERR_NO_MEMORY;
 }
-RT_EXPORT_SYMBOL(RTStrDupEx);
-
-
-RTDECL(char *) RTStrDupN(const char *pszString, size_t cchMax)
+RT_EXPORT_SYMBOL(RTStrDupExTag);
+
+
+RTDECL(char *) RTStrDupNTag(const char *pszString, size_t cchMax, const char *pszTag)
 {
     AssertPtr(pszString);
     char const *pszEnd = RTStrEnd(pszString, cchMax);
     size_t      cch    = pszEnd ? (uintptr_t)pszEnd - (uintptr_t)pszString : cchMax;
-    char       *pszDst = (char *)RTMemAlloc(cch + 1);
+    char       *pszDst = (char *)RTMemAllocTag(cch + 1, pszTag);
     if (pszDst)
     {
@@ -142,16 +143,16 @@
     return pszDst;
 }
-RT_EXPORT_SYMBOL(RTStrDupN);
-
-
-RTDECL(int) RTStrAAppend(char **ppsz, const char *pszAppend)
+RT_EXPORT_SYMBOL(RTStrDupNTag);
+
+
+RTDECL(int) RTStrAAppendTag(char **ppsz, const char *pszAppend, const char *pszTag)
 {
     if (!pszAppend)
         return VINF_SUCCESS;
-    return RTStrAAppendN(ppsz, pszAppend, RTSTR_MAX);
-}
-
-
-RTDECL(int) RTStrAAppendN(char **ppsz, const char *pszAppend, size_t cchAppend)
+    return RTStrAAppendNTag(ppsz, pszAppend, RTSTR_MAX, pszTag);
+}
+
+
+RTDECL(int) RTStrAAppendNTag(char **ppsz, const char *pszAppend, size_t cchAppend, const char *pszTag)
 {
     if (!cchAppend)
@@ -163,5 +164,5 @@
 
     size_t const cchOrg = *ppsz ? strlen(*ppsz) : 0;
-    char *pszNew = (char *)RTMemRealloc(*ppsz, cchOrg + cchAppend + 1);
+    char *pszNew = (char *)RTMemReallocTag(*ppsz, cchOrg + cchAppend + 1, pszTag);
     if (!pszNew)
         return VERR_NO_STR_MEMORY;
@@ -175,5 +176,5 @@
 
 
-RTDECL(int) RTStrAAppendExNV(char **ppsz, size_t cPairs, va_list va)
+RTDECL(int) RTStrAAppendExNVTag(char **ppsz, size_t cPairs, va_list va, const char *pszTag)
 {
     AssertPtr(ppsz);
@@ -212,5 +213,5 @@
      * Try reallocate the string.
      */
-    char *pszNew = (char *)RTMemRealloc(*ppsz, cchNewTotal);
+    char *pszNew = (char *)RTMemReallocTag(*ppsz, cchNewTotal, pszTag);
     if (!pszNew)
         return VERR_NO_STR_MEMORY;
@@ -232,19 +233,8 @@
     return VINF_SUCCESS;
 }
-RT_EXPORT_SYMBOL(RTStrAAppendExNV);
-
-
-RTDECL(int) RTStrAAppendExN(char **ppsz, size_t cPairs, ...)
-{
-    va_list va;
-    va_start(va, cPairs);
-    int rc = RTStrAAppendExNV(ppsz, cPairs, va);
-    va_end(va);
-    return rc;
-}
-RT_EXPORT_SYMBOL(RTStrAAppendExN);
-
-
-RTDECL(int) RTStrATruncate(char **ppsz, size_t cchNew)
+RT_EXPORT_SYMBOL(RTStrAAppendExNVTag);
+
+
+RTDECL(int) RTStrATruncateTag(char **ppsz, size_t cchNew, const char *pszTag)
 {
     char *pszOld = *ppsz;
@@ -254,5 +244,5 @@
         {
             *pszOld = '\0';
-            char *pszNew = (char *)RTMemRealloc(pszOld, 1);
+            char *pszNew = (char *)RTMemReallocTag(pszOld, 1, pszTag);
             if (pszNew)
                 *ppsz = pszNew;
@@ -268,5 +258,5 @@
         if (!pszZero)
         {
-            char *pszNew = (char *)RTMemRealloc(pszOld,  cchNew + 1);
+            char *pszNew = (char *)RTMemReallocTag(pszOld,  cchNew + 1, pszTag);
             if (pszNew)
                 *ppsz = pszNew;
@@ -275,4 +265,4 @@
     return VINF_SUCCESS;
 }
-RT_EXPORT_SYMBOL(RTStrATruncate);
-
+RT_EXPORT_SYMBOL(RTStrATruncateTag);
+
Index: /trunk/src/VBox/Runtime/common/string/utf-16.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/utf-16.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/common/string/utf-16.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -48,21 +48,21 @@
 
 
-RTDECL(PRTUTF16) RTUtf16Dup(PCRTUTF16 pwszString)
+RTDECL(PRTUTF16) RTUtf16DupTag(PCRTUTF16 pwszString, const char *pszTag)
 {
     Assert(pwszString);
     size_t cb = (RTUtf16Len(pwszString) + 1) * sizeof(RTUTF16);
-    PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc(cb);
+    PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag(cb, pszTag);
     if (pwsz)
         memcpy(pwsz, pwszString, cb);
     return pwsz;
 }
-RT_EXPORT_SYMBOL(RTUtf16Dup);
-
-
-RTDECL(int) RTUtf16DupEx(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra)
+RT_EXPORT_SYMBOL(RTUtf16DupTag);
+
+
+RTDECL(int) RTUtf16DupExTag(PRTUTF16 *ppwszString, PCRTUTF16 pwszString, size_t cwcExtra, const char *pszTag)
 {
     Assert(pwszString);
     size_t cb = (RTUtf16Len(pwszString) + 1) * sizeof(RTUTF16);
-    PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc(cb + cwcExtra * sizeof(RTUTF16));
+    PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag(cb + cwcExtra * sizeof(RTUTF16), pszTag);
     if (pwsz)
     {
@@ -73,5 +73,5 @@
     return VERR_NO_MEMORY;
 }
-RT_EXPORT_SYMBOL(RTUtf16DupEx);
+RT_EXPORT_SYMBOL(RTUtf16DupExTag);
 
 
@@ -425,5 +425,5 @@
 
 
-RTDECL(int)  RTUtf16ToUtf8(PCRTUTF16 pwszString, char **ppszString)
+RTDECL(int)  RTUtf16ToUtf8Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag)
 {
     /*
@@ -444,5 +444,5 @@
          * Allocate buffer and recode it.
          */
-        char *pszResult = (char *)RTMemAlloc(cch + 1);
+        char *pszResult = (char *)RTMemAllocTag(cch + 1, pszTag);
         if (pszResult)
         {
@@ -461,8 +461,8 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTUtf16ToUtf8);
-
-
-RTDECL(int)  RTUtf16ToUtf8Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch)
+RT_EXPORT_SYMBOL(RTUtf16ToUtf8Tag);
+
+
+RTDECL(int)  RTUtf16ToUtf8ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag)
 {
     /*
@@ -500,5 +500,5 @@
             fShouldFree = true;
             cch = RT_MAX(cch, cchResult + 1);
-            pszResult = (char *)RTStrAlloc(cch);
+            pszResult = (char *)RTStrAllocTag(cch, pszTag);
         }
         if (pszResult)
@@ -519,5 +519,5 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTUtf16ToUtf8Ex);
+RT_EXPORT_SYMBOL(RTUtf16ToUtf8ExTag);
 
 
@@ -785,5 +785,5 @@
 
 
-RTDECL(int)  RTUtf16ToLatin1(PCRTUTF16 pwszString, char **ppszString)
+RTDECL(int)  RTUtf16ToLatin1Tag(PCRTUTF16 pwszString, char **ppszString, const char *pszTag)
 {
     /*
@@ -804,5 +804,5 @@
          * Allocate buffer and recode it.
          */
-        char *pszResult = (char *)RTMemAlloc(cch + 1);
+        char *pszResult = (char *)RTMemAllocTag(cch + 1, pszTag);
         if (pszResult)
         {
@@ -821,8 +821,8 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTUtf16ToLatin1);
-
-
-RTDECL(int)  RTUtf16ToLatin1Ex(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch)
+RT_EXPORT_SYMBOL(RTUtf16ToLatin1Tag);
+
+
+RTDECL(int)  RTUtf16ToLatin1ExTag(PCRTUTF16 pwszString, size_t cwcString, char **ppsz, size_t cch, size_t *pcch, const char *pszTag)
 {
     /*
@@ -860,5 +860,5 @@
             fShouldFree = true;
             cch = RT_MAX(cch, cchResult + 1);
-            pszResult = (char *)RTMemAlloc(cch);
+            pszResult = (char *)RTMemAllocTag(cch, pszTag);
         }
         if (pszResult)
@@ -879,5 +879,5 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTUtf16ToLatin1Ex);
+RT_EXPORT_SYMBOL(RTUtf16ToLatin1ExTag);
 
 
@@ -964,5 +964,5 @@
 
 
-RTDECL(int) RTLatin1ToUtf16(const char *pszString, PRTUTF16 *ppwszString)
+RTDECL(int) RTLatin1ToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag)
 {
     /*
@@ -983,5 +983,5 @@
          * Allocate buffer.
          */
-        PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc((cwc + 1) * sizeof(RTUTF16));
+        PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag((cwc + 1) * sizeof(RTUTF16), pszTag);
         if (pwsz)
         {
@@ -1002,8 +1002,9 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTLatin1ToUtf16);
-
-
-RTDECL(int)  RTLatin1ToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc)
+RT_EXPORT_SYMBOL(RTLatin1ToUtf16Tag);
+
+
+RTDECL(int)  RTLatin1ToUtf16ExTag(const char *pszString, size_t cchString,
+                                  PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag)
 {
     /*
@@ -1041,5 +1042,5 @@
             fShouldFree = true;
             cwc = RT_MAX(cwcResult + 1, cwc);
-            pwszResult = (PRTUTF16)RTMemAlloc(cwc * sizeof(RTUTF16));
+            pwszResult = (PRTUTF16)RTMemAllocTag(cwc * sizeof(RTUTF16), pszTag);
         }
         if (pwszResult)
@@ -1062,5 +1063,5 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTLatin1ToUtf16Ex);
+RT_EXPORT_SYMBOL(RTLatin1ToUtf16ExTag);
 
 
Index: /trunk/src/VBox/Runtime/common/string/utf-8.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/utf-8.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/common/string/utf-8.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -672,5 +672,5 @@
 
 
-RTDECL(int) RTStrToUtf16(const char *pszString, PRTUTF16 *ppwszString)
+RTDECL(int) RTStrToUtf16Tag(const char *pszString, PRTUTF16 *ppwszString, const char *pszTag)
 {
     /*
@@ -691,5 +691,5 @@
          * Allocate buffer.
          */
-        PRTUTF16 pwsz = (PRTUTF16)RTMemAlloc((cwc + 1) * sizeof(RTUTF16));
+        PRTUTF16 pwsz = (PRTUTF16)RTMemAllocTag((cwc + 1) * sizeof(RTUTF16), pszTag);
         if (pwsz)
         {
@@ -710,8 +710,9 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTStrToUtf16);
-
-
-RTDECL(int)  RTStrToUtf16Ex(const char *pszString, size_t cchString, PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc)
+RT_EXPORT_SYMBOL(RTStrToUtf16Tag);
+
+
+RTDECL(int)  RTStrToUtf16ExTag(const char *pszString, size_t cchString,
+                               PRTUTF16 *ppwsz, size_t cwc, size_t *pcwc, const char *pszTag)
 {
     /*
@@ -749,5 +750,5 @@
             fShouldFree = true;
             cwc = RT_MAX(cwcResult + 1, cwc);
-            pwszResult = (PRTUTF16)RTMemAlloc(cwc * sizeof(RTUTF16));
+            pwszResult = (PRTUTF16)RTMemAllocTag(cwc * sizeof(RTUTF16), pszTag);
         }
         if (pwszResult)
@@ -770,5 +771,5 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTStrToUtf16Ex);
+RT_EXPORT_SYMBOL(RTStrToUtf16ExTag);
 
 
Index: /trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -81,45 +81,41 @@
 
 
-
-/**
- * Allocates temporary memory.
- *
- * Temporary memory blocks are used for not too large memory blocks which
- * are believed not to stick around for too long. Using this API instead
- * of RTMemAlloc() not only gives the heap manager room for optimization
- * but makes the code easier to read.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocated.
- */
-RTDECL(void *)  RTMemTmpAlloc(size_t cb) RT_NO_THROW
-{
-    return RTMemAlloc(cb);
-}
-RT_EXPORT_SYMBOL(RTMemTmpAlloc);
-
-
-/**
- * Allocates zero'ed temporary memory.
- *
- * Same as RTMemTmpAlloc() but the memory will be zero'ed.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocated.
- */
-RTDECL(void *)  RTMemTmpAllocZ(size_t cb) RT_NO_THROW
-{
-    return RTMemAllocZ(cb);
-}
-RT_EXPORT_SYMBOL(RTMemTmpAllocZ);
-
-
-/**
- * Free temporary memory.
- *
- * @param   pv      Pointer to memory block.
- */
+#undef RTMemTmpAlloc
+#undef RTMemTmpAllocTag
+#undef RTMemTmpAllocZ
+#undef RTMemTmpAllocZTag
+#undef RTMemTmpFree
+#undef RTMemAlloc
+#undef RTMemAllocTag
+#undef RTMemAllocZ
+#undef RTMemAllocZTag
+#undef RTMemAllocVar
+#undef RTMemAllocVarTag
+#undef RTMemAllocZVar
+#undef RTMemAllocZVarTag
+#undef RTMemRealloc
+#undef RTMemReallocTag
+#undef RTMemFree
+#undef RTMemDup
+#undef RTMemDupTag
+#undef RTMemDupEx
+#undef RTMemDupExTag
+
+
+
+RTDECL(void *)  RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
+{
+    return RTMemAllocTag(cb, pszTag);
+}
+RT_EXPORT_SYMBOL(RTMemTmpAllocTag);
+
+
+RTDECL(void *)  RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
+{
+    return RTMemAllocZTag(cb, pszTag);
+}
+RT_EXPORT_SYMBOL(RTMemTmpAllocZTag);
+
+
 RTDECL(void)    RTMemTmpFree(void *pv) RT_NO_THROW
 {
@@ -129,12 +125,8 @@
 
 
-/**
- * Allocates memory.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocated.
- */
-RTDECL(void *)  RTMemAlloc(size_t cb) RT_NO_THROW
+
+
+
+RTDECL(void *)  RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
     PRTMEMHDR pHdr;
@@ -152,19 +144,8 @@
     return NULL;
 }
-RT_EXPORT_SYMBOL(RTMemAlloc);
-
-
-/**
- * Allocates zero'ed memory.
- *
- * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
- * memory. This keeps the code smaller and the heap can skip the memset
- * in about 0.42% of calls :-).
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocated.
- */
-RTDECL(void *)  RTMemAllocZ(size_t cb) RT_NO_THROW
+RT_EXPORT_SYMBOL(RTMemAllocTag);
+
+
+RTDECL(void *)  RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
     PRTMEMHDR pHdr;
@@ -184,15 +165,8 @@
     return NULL;
 }
-RT_EXPORT_SYMBOL(RTMemAllocZ);
-
-
-/**
- * Wrapper around RTMemAlloc for automatically aligning variable sized
- * allocations so that the various electric fence heaps works correctly.
- *
- * @returns See RTMemAlloc.
- * @param   cbUnaligned         The unaligned size.
- */
-RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
+RT_EXPORT_SYMBOL(RTMemAllocZTag);
+
+
+RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag)
 {
     size_t cbAligned;
@@ -201,17 +175,10 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return RTMemAlloc(cbAligned);
-}
-RT_EXPORT_SYMBOL(RTMemAllocVar);
-
-
-/**
- * Wrapper around RTMemAllocZ for automatically aligning variable sized
- * allocations so that the various electric fence heaps works correctly.
- *
- * @returns See RTMemAllocZ.
- * @param   cbUnaligned         The unaligned size.
- */
-RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
+    return RTMemAllocTag(cbAligned, pszTag);
+}
+RT_EXPORT_SYMBOL(RTMemAllocVarTag);
+
+
+RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag)
 {
     size_t cbAligned;
@@ -220,23 +187,15 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return RTMemAllocZ(cbAligned);
-}
-RT_EXPORT_SYMBOL(RTMemAllocZVar);
-
-
-/**
- * Reallocates memory.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   pvOld   The memory block to reallocate.
- * @param   cbNew   The new block size (in bytes).
- */
-RTDECL(void *) RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW
+    return RTMemAllocZTag(cbAligned, pszTag);
+}
+RT_EXPORT_SYMBOL(RTMemAllocZVarTag);
+
+
+RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW
 {
     if (!cbNew)
         RTMemFree(pvOld);
     else if (!pvOld)
-        return RTMemAlloc(cbNew);
+        return RTMemAllocTag(cbNew, pszTag);
     else
     {
@@ -275,12 +234,7 @@
     return NULL;
 }
-RT_EXPORT_SYMBOL(RTMemRealloc);
-
-
-/**
- * Free memory related to an virtual machine
- *
- * @param   pv      Pointer to memory block.
- */
+RT_EXPORT_SYMBOL(RTMemReallocTag);
+
+
 RTDECL(void) RTMemFree(void *pv) RT_NO_THROW
 {
@@ -311,12 +265,9 @@
 
 
-/**
- * Allocates memory which may contain code.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)    RTMemExecAlloc(size_t cb) RT_NO_THROW
+
+
+
+
+RTDECL(void *)    RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
     PRTMEMHDR pHdr;
@@ -338,12 +289,7 @@
     return NULL;
 }
-RT_EXPORT_SYMBOL(RTMemExecAlloc);
-
-
-/**
- * Free executable/read/write memory allocated by RTMemExecAlloc().
- *
- * @param   pv      Pointer to memory block.
- */
+RT_EXPORT_SYMBOL(RTMemExecAllocTag);
+
+
 RTDECL(void)      RTMemExecFree(void *pv) RT_NO_THROW
 {
Index: /trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -405,15 +405,5 @@
 
 
-/**
- * Allocates page aligned virtual kernel memory.
- *
- * The memory is taken from a non paged (= fixed physical memory backing) pool.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
- * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
- */
-RTR0DECL(int) RTR0MemObjAllocPage(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable)
+RTR0DECL(int) RTR0MemObjAllocPageTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag)
 {
     /* sanity checks. */
@@ -428,18 +418,8 @@
     return rtR0MemObjNativeAllocPage(pMemObj, cbAligned, fExecutable);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjAllocPage);
-
-
-/**
- * Allocates page aligned virtual kernel memory with physical backing below 4GB.
- *
- * The physical memory backing the allocation is fixed.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
- * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
- */
-RTR0DECL(int) RTR0MemObjAllocLow(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable)
+RT_EXPORT_SYMBOL(RTR0MemObjAllocPageTag);
+
+
+RTR0DECL(int) RTR0MemObjAllocLowTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag)
 {
     /* sanity checks. */
@@ -454,18 +434,8 @@
     return rtR0MemObjNativeAllocLow(pMemObj, cbAligned, fExecutable);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjAllocLow);
-
-
-/**
- * Allocates page aligned virtual kernel memory with contiguous physical backing below 4GB.
- *
- * The physical memory backing the allocation is fixed.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
- * @param   fExecutable     Flag indicating whether it should be permitted to executed code in the memory object.
- */
-RTR0DECL(int) RTR0MemObjAllocCont(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable)
+RT_EXPORT_SYMBOL(RTR0MemObjAllocLowTag);
+
+
+RTR0DECL(int) RTR0MemObjAllocContTag(PRTR0MEMOBJ pMemObj, size_t cb, bool fExecutable, const char *pszTag)
 {
     /* sanity checks. */
@@ -480,30 +450,9 @@
     return rtR0MemObjNativeAllocCont(pMemObj, cbAligned, fExecutable);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjAllocCont);
-
-
-/**
- * Locks a range of user virtual memory.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   R3Ptr           User virtual address. This is rounded down to a page
- *                          boundrary.
- * @param   cb              Number of bytes to lock. This is rounded up to
- *                          nearest page boundrary.
- * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
- *                          and RTMEM_PROT_WRITE.
- * @param   R0Process       The process to lock pages in. NIL_RTR0PROCESS is an
- *                          alias for the current one.
- *
- * @remarks RTR0MemGetAddressR3() and RTR0MemGetAddress() will return therounded
- *          down address.
- *
- * @remarks Linux: This API requires that the memory begin locked is in a memory
- *          mapping that is not required in any forked off child process. This
- *          is not intented as permanent restriction, feel free to help out
- *          lifting it.
- */
-RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process)
+RT_EXPORT_SYMBOL(RTR0MemObjAllocContTag);
+
+
+RTR0DECL(int) RTR0MemObjLockUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3Ptr, size_t cb,
+                                    uint32_t fAccess, RTR0PROCESS R0Process, const char *pszTag)
 {
     /* sanity checks. */
@@ -523,20 +472,8 @@
     return rtR0MemObjNativeLockUser(pMemObj, R3PtrAligned, cbAligned, fAccess, R0Process);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjLockUser);
-
-
-/**
- * Locks a range of kernel virtual memory.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   pv              Kernel virtual address. This is rounded down to a page boundrary.
- * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
- * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
- *                          and RTMEM_PROT_WRITE.
- *
- * @remark  RTR0MemGetAddress() will return the rounded down address.
- */
-RTR0DECL(int) RTR0MemObjLockKernel(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess)
+RT_EXPORT_SYMBOL(RTR0MemObjLockUserTag);
+
+
+RTR0DECL(int) RTR0MemObjLockKernelTag(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, uint32_t fAccess, const char *pszTag)
 {
     /* sanity checks. */
@@ -555,17 +492,8 @@
     return rtR0MemObjNativeLockKernel(pMemObj, pvAligned, cbAligned, fAccess);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjLockKernel);
-
-
-/**
- * Allocates contiguous page aligned physical memory without (necessarily) any kernel mapping.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
- * @param   PhysHighest     The highest permittable address (inclusive).
- *                          Pass NIL_RTHCPHYS if any address is acceptable.
- */
-RTR0DECL(int) RTR0MemObjAllocPhys(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest)
+RT_EXPORT_SYMBOL(RTR0MemObjLockKernelTag);
+
+
+RTR0DECL(int) RTR0MemObjAllocPhysTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag)
 {
     /* sanity checks. */
@@ -581,19 +509,8 @@
     return rtR0MemObjNativeAllocPhys(pMemObj, cbAligned, PhysHighest, PAGE_SIZE /* page aligned */);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjAllocPhys);
-
-
-/**
- * Allocates contiguous physical memory without (necessarily) any kernel mapping.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
- * @param   PhysHighest     The highest permittable address (inclusive).
- *                          Pass NIL_RTHCPHYS if any address is acceptable.
- * @param   uAlignment      The alignment of the physical memory to allocate.
- *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M, _4M and _1G.
- */
-RTR0DECL(int) RTR0MemObjAllocPhysEx(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
+RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysTag);
+
+
+RTR0DECL(int) RTR0MemObjAllocPhysExTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment, const char *pszTag)
 {
     /* sanity checks. */
@@ -622,17 +539,8 @@
     return rtR0MemObjNativeAllocPhys(pMemObj, cbAligned, PhysHighest, uAlignment);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysEx);
-
-
-/**
- * Allocates non-contiguous page aligned physical memory without (necessarily) any kernel mapping.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   cb              Number of bytes to allocate. This is rounded up to nearest page.
- * @param   PhysHighest     The highest permittable address (inclusive).
- *                          Pass NIL_RTHCPHYS if any address is acceptable.
- */
-RTR0DECL(int) RTR0MemObjAllocPhysNC(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest)
+RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysExTag);
+
+
+RTR0DECL(int) RTR0MemObjAllocPhysNCTag(PRTR0MEMOBJ pMemObj, size_t cb, RTHCPHYS PhysHighest, const char *pszTag)
 {
     /* sanity checks. */
@@ -648,20 +556,8 @@
     return rtR0MemObjNativeAllocPhysNC(pMemObj, cbAligned, PhysHighest);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysNC);
-
-
-/**
- * Creates a page aligned, contiguous, physical memory object.
- *
- * No physical memory is allocated, we trust you do know what you're doing.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   Phys            The physical address to start at. This is rounded down to the
- *                          nearest page boundrary.
- * @param   cb              The size of the object in bytes. This is rounded up to nearest page boundrary.
- * @param   uCachePolicy    One of the RTMEM_CACHE_XXX modes.
- */
-RTR0DECL(int) RTR0MemObjEnterPhys(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
+RT_EXPORT_SYMBOL(RTR0MemObjAllocPhysNCTag);
+
+
+RTR0DECL(int) RTR0MemObjEnterPhysTag(PRTR0MEMOBJ pMemObj, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy, const char *pszTag)
 {
     /* sanity checks. */
@@ -681,18 +577,8 @@
     return rtR0MemObjNativeEnterPhys(pMemObj, PhysAligned, cbAligned, uCachePolicy);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjEnterPhys);
-
-
-/**
- * Reserves kernel virtual address space.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
- * @param   cb              The number of bytes to reserve. This is rounded up to nearest page.
- * @param   uAlignment      The alignment of the reserved memory.
- *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
- */
-RTR0DECL(int) RTR0MemObjReserveKernel(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment)
+RT_EXPORT_SYMBOL(RTR0MemObjEnterPhysTag);
+
+
+RTR0DECL(int) RTR0MemObjReserveKernelTag(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, const char *pszTag)
 {
     /* sanity checks. */
@@ -712,19 +598,9 @@
     return rtR0MemObjNativeReserveKernel(pMemObj, pvFixed, cbAligned, uAlignment);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjReserveKernel);
-
-
-/**
- * Reserves user virtual address space in the current process.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle.
- * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
- * @param   cb              The number of bytes to reserve. This is rounded up to nearest PAGE_SIZE.
- * @param   uAlignment      The alignment of the reserved memory.
- *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
- * @param   R0Process       The process to reserve the memory in. NIL_RTR0PROCESS is an alias for the current one.
- */
-RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
+RT_EXPORT_SYMBOL(RTR0MemObjReserveKernelTag);
+
+
+RTR0DECL(int) RTR0MemObjReserveUserTag(PRTR0MEMOBJ pMemObj, RTR3PTR R3PtrFixed, size_t cb,
+                                       size_t uAlignment, RTR0PROCESS R0Process, const char *pszTag)
 {
     /* sanity checks. */
@@ -746,51 +622,17 @@
     return rtR0MemObjNativeReserveUser(pMemObj, R3PtrFixed, cbAligned, uAlignment, R0Process);
 }
-RT_EXPORT_SYMBOL(RTR0MemObjReserveUser);
-
-
-/**
- * Maps a memory object into kernel virtual address space.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
- * @param   MemObjToMap     The object to be map.
- * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
- * @param   uAlignment      The alignment of the reserved memory.
- *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
- * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
- */
-RTR0DECL(int) RTR0MemObjMapKernel(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
-{
-    return RTR0MemObjMapKernelEx(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt, 0, 0);
-}
-RT_EXPORT_SYMBOL(RTR0MemObjMapKernel);
-
-
-/**
- * Maps a memory object into kernel virtual address space.
- *
- * The ability to map subsections of the object into kernel space is currently
- * not implemented on all platforms. All/Most of platforms supports mapping the
- * whole object into  kernel space.
- *
- * @returns IPRT status code.
- * @retval  VERR_NOT_SUPPORTED if it's not possible to map a subsection of a
- *          memory object on this platform. When you hit this, try implement it.
- *
- * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
- * @param   MemObjToMap     The object to be map.
- * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
- * @param   uAlignment      The alignment of the reserved memory.
- *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
- * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
- * @param   offSub          Where in the object to start mapping. If non-zero
- *                          the value must be page aligned and cbSub must be
- *                          non-zero as well.
- * @param   cbSub           The size of the part of the object to be mapped. If
- *                          zero the entire object is mapped. The value must be
- *                          page aligned.
- */
-RTR0DECL(int) RTR0MemObjMapKernelEx(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
-                                    unsigned fProt, size_t offSub, size_t cbSub)
+RT_EXPORT_SYMBOL(RTR0MemObjReserveUserTag);
+
+
+RTR0DECL(int) RTR0MemObjMapKernelTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed,
+                                     size_t uAlignment, unsigned fProt, const char *pszTag)
+{
+    return RTR0MemObjMapKernelExTag(pMemObj, MemObjToMap, pvFixed, uAlignment, fProt, 0, 0, pszTag);
+}
+RT_EXPORT_SYMBOL(RTR0MemObjMapKernelTag);
+
+
+RTR0DECL(int) RTR0MemObjMapKernelExTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment,
+                                       unsigned fProt, size_t offSub, size_t cbSub, const char *pszTag)
 {
     PRTR0MEMOBJINTERNAL pMemToMap;
@@ -846,20 +688,9 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTR0MemObjMapKernelEx);
-
-
-/**
- * Maps a memory object into user virtual address space in the current process.
- *
- * @returns IPRT status code.
- * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
- * @param   MemObjToMap     The object to be map.
- * @param   R3PtrFixed      Requested address. (RTR3PTR)-1 means any address. This must match the alignment.
- * @param   uAlignment      The alignment of the reserved memory.
- *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
- * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
- * @param   R0Process       The process to map the memory into. NIL_RTR0PROCESS is an alias for the current one.
- */
-RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
+RT_EXPORT_SYMBOL(RTR0MemObjMapKernelExTag);
+
+
+RTR0DECL(int) RTR0MemObjMapUserTag(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, RTR3PTR R3PtrFixed,
+                                   size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process, const char *pszTag)
 {
     /* sanity checks. */
@@ -907,5 +738,5 @@
     return rc;
 }
-RT_EXPORT_SYMBOL(RTR0MemObjMapUser);
+RT_EXPORT_SYMBOL(RTR0MemObjMapUserTag);
 
 
Index: /trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp	(revision 31157)
@@ -58,5 +58,5 @@
 void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb) throw(std::bad_alloc)
 {
-    void *pv = rtR3MemAlloc("new", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("new", RTMEMTYPE_NEW, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
     if (!pv)
         throw std::bad_alloc();
@@ -67,5 +67,5 @@
 void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb, const std::nothrow_t &) throw()
 {
-    void *pv = rtR3MemAlloc("new nothrow", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("new nothrow", RTMEMTYPE_NEW, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
     return pv;
 }
@@ -94,5 +94,5 @@
 void *RT_EF_CDECL operator new[](RT_EF_SIZE_T cb) throw(std::bad_alloc)
 {
-    void *pv = rtR3MemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
     if (!pv)
         throw std::bad_alloc();
@@ -103,5 +103,5 @@
 void * RT_EF_CDECL operator new[](RT_EF_SIZE_T cb, const std::nothrow_t &) throw()
 {
-    void *pv = rtR3MemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL);
     return pv;
 }
Index: /trunk/src/VBox/Runtime/r3/alloc-ef.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/alloc-ef.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r3/alloc-ef.cpp	(revision 31157)
@@ -127,5 +127,5 @@
  */
 DECLINLINE(PRTMEMBLOCK) rtmemBlockCreate(RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
-                                         void *pvCaller, RT_SRC_POS_DECL)
+                                         const char *pszTag, void *pvCaller, RT_SRC_POS_DECL)
 {
     PRTMEMBLOCK pBlock = (PRTMEMBLOCK)malloc(sizeof(*pBlock));
@@ -135,4 +135,5 @@
         pBlock->cbUnaligned = cbUnaligned;
         pBlock->cbAligned   = cbAligned;
+        pBlock->pszTag      = pszTag;
         pBlock->pvCaller    = pvCaller;
         pBlock->iLine       = iLine;
@@ -273,5 +274,5 @@
  */
 RTDECL(void *) rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
-                            void *pvCaller, RT_SRC_POS_DECL)
+                            const char *pszTag, void *pvCaller, RT_SRC_POS_DECL)
 {
     /*
@@ -305,5 +306,5 @@
      * Allocate the trace block.
      */
-    PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cbUnaligned, cbAligned, pvCaller, RT_SRC_POS_ARGS);
+    PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cbUnaligned, cbAligned, pszTag, pvCaller, RT_SRC_POS_ARGS);
     if (!pBlock)
     {
@@ -503,5 +504,6 @@
  * Internal realloc.
  */
-RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL)
+RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew,
+                              const char *pszTag, void *pvCaller, RT_SRC_POS_DECL)
 {
     /*
@@ -509,5 +511,5 @@
      */
     if (!pvOld)
-        return rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pvCaller, RT_SRC_POS_ARGS);
+        return rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pszTag, pvCaller, RT_SRC_POS_ARGS);
     if (!cbNew)
     {
@@ -524,5 +526,5 @@
     if (pBlock)
     {
-        void *pvRet = rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pvCaller, RT_SRC_POS_ARGS);
+        void *pvRet = rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pszTag, pvCaller, RT_SRC_POS_ARGS);
         if (pvRet)
         {
@@ -547,13 +549,13 @@
 
 
-RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
-{
-    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
-}
-
-
-RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
-{
-    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
+RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
 }
 
@@ -566,17 +568,17 @@
 
 
-RTDECL(void *)  RTMemEfAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
-{
-    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
-}
-
-
-RTDECL(void *)  RTMemEfAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
-{
-    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
-}
-
-
-RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW
+RTDECL(void *)  RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
 {
     size_t cbAligned;
@@ -585,9 +587,9 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);
-}
-
-
-RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
 {
     size_t cbAligned;
@@ -596,11 +598,11 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);
-}
-
-
-RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, RT_SRC_POS_DECL) RT_NO_THROW
-{
-    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), RT_SRC_POS_ARGS);
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS);
 }
 
@@ -613,7 +615,7 @@
 
 
-RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
-{
-    void *pvDst = RTMemEfAlloc(cb, RT_SRC_POS_ARGS);
+RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cb, pszTag, RT_SRC_POS_ARGS);
     if (pvDst)
         memcpy(pvDst, pvSrc, cb);
@@ -622,7 +624,7 @@
 
 
-RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, RT_SRC_POS_DECL) RT_NO_THROW
-{
-    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, RT_SRC_POS_ARGS);
+RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, pszTag, RT_SRC_POS_ARGS);
     if (pvDst)
     {
@@ -644,13 +646,13 @@
 
 
-RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb) RT_NO_THROW
-{
-    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
-}
-
-
-RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb) RT_NO_THROW
-{
-    return rtR3MemAlloc("TmpAllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
 }
 
@@ -663,17 +665,17 @@
 
 
-RTDECL(void *)  RTMemEfAllocNP(size_t cb) RT_NO_THROW
-{
-    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
-}
-
-
-RTDECL(void *)  RTMemEfAllocZNP(size_t cb) RT_NO_THROW
-{
-    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
-}
-
-
-RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned) RT_NO_THROW
+RTDECL(void *)  RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW
+{
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW
+{
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
 {
     size_t cbAligned;
@@ -682,9 +684,9 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
-}
-
-
-RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned) RT_NO_THROW
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
 {
     size_t cbAligned;
@@ -693,11 +695,11 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
-}
-
-
-RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew) RT_NO_THROW
-{
-    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW
+{
+    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), NULL, 0, NULL);
 }
 
@@ -710,7 +712,7 @@
 
 
-RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb) RT_NO_THROW
-{
-    void *pvDst = RTMemEfAlloc(cb, NULL, 0, NULL);
+RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cb, pszTag, NULL, 0, NULL);
     if (pvDst)
         memcpy(pvDst, pvSrc, cb);
@@ -719,7 +721,7 @@
 
 
-RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW
-{
-    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, NULL, 0, NULL);
+RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, pszTag, NULL, 0, NULL);
     if (pvDst)
     {
Index: /trunk/src/VBox/Runtime/r3/alloc-ef.h
===================================================================
--- /trunk/src/VBox/Runtime/r3/alloc-ef.h	(revision 31156)
+++ /trunk/src/VBox/Runtime/r3/alloc-ef.h	(revision 31157)
@@ -166,4 +166,6 @@
     /** The aligned size of the block. */
     size_t          cbAligned;
+    /** The allocation tag (read-only string). */
+    const char     *pszTag;
     /** The return address of the allocator function. */
     void           *pvCaller;
@@ -184,6 +186,7 @@
 RT_C_DECLS_BEGIN
 RTDECL(void *)  rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
-                             void *pvCaller, RT_SRC_POS_DECL);
-RTDECL(void *)  rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL);
+                             const char *pszTag, void *pvCaller, RT_SRC_POS_DECL);
+RTDECL(void *)  rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew,
+                               const char *pszTag, void *pvCaller, RT_SRC_POS_DECL);
 RTDECL(void)    rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL);
 RT_C_DECLS_END
Index: /trunk/src/VBox/Runtime/r3/alloc.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/alloc.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r3/alloc.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -48,55 +48,38 @@
 
 #undef RTMemTmpAlloc
+#undef RTMemTmpAllocTag
 #undef RTMemTmpAllocZ
+#undef RTMemTmpAllocZTag
 #undef RTMemTmpFree
 #undef RTMemAlloc
+#undef RTMemAllocTag
 #undef RTMemAllocZ
+#undef RTMemAllocZTag
 #undef RTMemAllocVar
+#undef RTMemAllocVarTag
 #undef RTMemAllocZVar
+#undef RTMemAllocZVarTag
 #undef RTMemRealloc
+#undef RTMemReallocTag
 #undef RTMemFree
 #undef RTMemDup
+#undef RTMemDupTag
 #undef RTMemDupEx
+#undef RTMemDupExTag
 
 
-/**
- * Allocates temporary memory.
- *
- * Temporary memory blocks are used for not too large memory blocks which
- * are believed not to stick around for too long. Using this API instead
- * of RTMemAlloc() not only gives the heap manager room for optimization
- * but makes the code easier to read.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemTmpAlloc(size_t cb) RT_NO_THROW
+RTDECL(void *)  RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
-    return RTMemAlloc(cb);
+    return RTMemAllocTag(cb, pszTag);
 }
 
 
-/**
- * Allocates zero'ed temporary memory.
- *
- * Same as RTMemTmpAlloc() but the memory will be zero'ed.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemTmpAllocZ(size_t cb) RT_NO_THROW
+RTDECL(void *)  RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
-    return RTMemAllocZ(cb);
+    return RTMemAllocZTag(cb, pszTag);
 }
 
 
-/**
- * Free temporary memory.
- *
- * @param   pv      Pointer to memory block.
- */
-RTDECL(void)    RTMemTmpFree(void *pv) RT_NO_THROW
+RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW
 {
     RTMemFree(pv);
@@ -104,15 +87,8 @@
 
 
-/**
- * Allocates memory.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemAlloc(size_t cb) RT_NO_THROW
+RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
 
 #else /* !RTALLOC_USE_EFENCE */
@@ -130,19 +106,8 @@
 
 
-/**
- * Allocates zero'ed memory.
- *
- * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed
- * memory. This keeps the code smaller and the heap can skip the memset
- * in about 0.42% of the calls :-).
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemAllocZ(size_t cb) RT_NO_THROW
+RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL);
 
 #else /* !RTALLOC_USE_EFENCE */
@@ -161,12 +126,5 @@
 
 
-/**
- * Wrapper around RTMemAlloc for automatically aligning variable sized
- * allocations so that the various electric fence heaps works correctly.
- *
- * @returns See RTMemAlloc.
- * @param   cbUnaligned         The unaligned size.
- */
-RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
+RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
 {
     size_t cbAligned;
@@ -176,7 +134,7 @@
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtR3MemAlloc("AllocVar", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("AllocVar", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
 #else
-    void *pv = RTMemAlloc(cbAligned);
+    void *pv = RTMemAllocTag(cbAligned, pszTag);
 #endif
     return pv;
@@ -184,12 +142,5 @@
 
 
-/**
- * Wrapper around RTMemAllocZ for automatically aligning variable sized
- * allocations so that the various electric fence heaps works correctly.
- *
- * @returns See RTMemAllocZ.
- * @param   cbUnaligned         The unaligned size.
- */
-RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
+RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW
 {
     size_t cbAligned;
@@ -199,7 +150,7 @@
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtR3MemAlloc("AllocZVar", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemAlloc("AllocZVar", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL);
 #else
-    void *pv = RTMemAllocZ(cbAligned);
+    void *pv = RTMemAllocZTag(cbAligned, pszTag);
 #endif
     return pv;
@@ -207,16 +158,8 @@
 
 
-/**
- * Reallocates memory.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   pvOld   The memory block to reallocate.
- * @param   cbNew   The new block size (in bytes).
- */
-RTDECL(void *)  RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW
+RTDECL(void *)  RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW
 {
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);
+    void *pv = rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), NULL, 0, NULL);
 
 #else /* !RTALLOC_USE_EFENCE */
@@ -233,10 +176,5 @@
 
 
-/**
- * Free memory related to a virtual machine
- *
- * @param   pv      Pointer to memory block.
- */
-RTDECL(void)    RTMemFree(void *pv) RT_NO_THROW
+RTDECL(void) RTMemFree(void *pv) RT_NO_THROW
 {
     if (pv)
Index: /trunk/src/VBox/Runtime/r3/darwin/alloc-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/darwin/alloc-darwin.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r3/darwin/alloc-darwin.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -40,12 +40,5 @@
 
 
-/**
- * Allocates memory which may contain code.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *) RTMemExecAlloc(size_t cb) RT_NO_THROW
+RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
     /*
@@ -74,9 +67,4 @@
 
 
-/**
- * Free executable/read/write memory allocated by RTMemExecAlloc().
- *
- * @param   pv      Pointer to memory block.
- */
 RTDECL(void)    RTMemExecFree(void *pv) RT_NO_THROW
 {
@@ -86,12 +74,5 @@
 
 
-/**
- * Allocate page aligned memory.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL if we're out of memory.
- * @param   cb  Size of the memory block. Will be rounded up to page size.
- */
-RTDECL(void *) RTMemPageAlloc(size_t cb) RT_NO_THROW
+RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
     return valloc(RT_ALIGN_Z(cb, PAGE_SIZE));
@@ -99,12 +80,5 @@
 
 
-/**
- * Allocate zero'ed page aligned memory.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL if we're out of memory.
- * @param   cb  Size of the memory block. Will be rounded up to page size.
- */
-RTDECL(void *) RTMemPageAllocZ(size_t cb) RT_NO_THROW
+RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW
 {
     cb = RT_ALIGN_Z(cb, PAGE_SIZE);
@@ -116,10 +90,4 @@
 
 
-/**
- * Free a memory block allocated with RTMemPageAlloc() or RTMemPageAllocZ().
- *
- * @param   pv      Pointer to the block as it was returned by the allocation function.
- *                  NULL will be ignored.
- */
 RTDECL(void) RTMemPageFree(void *pv, size_t cb) RT_NO_THROW
 {
@@ -129,12 +97,4 @@
 
 
-/**
- * Change the page level protection of a memory region.
- *
- * @returns iprt status code.
- * @param   pv          Start of the region. Will be rounded down to nearest page boundary.
- * @param   cb          Size of the region. Will be rounded up to the nearest page boundary.
- * @param   fProtect    The new protection, a combination of the RTMEM_PROT_* defines.
- */
 RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW
 {
Index: /trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp	(revision 31157)
@@ -413,13 +413,5 @@
 
 
-/**
- * Allocates tmp buffer, translates pszString from UTF8 to current codepage.
- *
- * @returns iprt status code.
- * @param   ppszString      Receives pointer of allocated native CP string.
- *                          The returned pointer must be freed using RTStrFree().
- * @param   pszString       UTF-8 string to convert.
- */
-RTR3DECL(int)  RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString)
+RTR3DECL(int)  RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag)
 {
     Assert(ppszString);
@@ -434,5 +426,5 @@
     {
         /* zero length string passed. */
-        *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
+        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
         if (*ppszString)
             return VINF_SUCCESS;
@@ -443,13 +435,5 @@
 
 
-/**
- * Allocates tmp buffer, translates pszString from current codepage to UTF-8.
- *
- * @returns iprt status code.
- * @param   ppszString      Receives pointer of allocated UTF-8 string.
- *                          The returned pointer must be freed using RTStrFree().
- * @param   pszString       Native string to convert.
- */
-RTR3DECL(int)  RTStrCurrentCPToUtf8(char **ppszString, const char *pszString)
+RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag)
 {
     Assert(ppszString);
@@ -464,5 +448,5 @@
     {
         /* zero length string passed. */
-        *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
+        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
         if (*ppszString)
             return VINF_SUCCESS;
Index: /trunk/src/VBox/Runtime/r3/win/utf8-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/utf8-win.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/r3/win/utf8-win.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -38,13 +38,5 @@
 
 
-/**
- * Allocates tmp buffer, translates pszString from UTF8 to current codepage.
- *
- * @returns iprt status code.
- * @param   ppszString      Receives pointer of allocated native CP string.
- *                          The returned pointer must be freed using RTStrFree().
- * @param   pszString       UTF-8 string to convert.
- */
-RTR3DECL(int)  RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString)
+RTR3DECL(int)  RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag)
 {
     Assert(ppszString);
@@ -56,5 +48,5 @@
     if (!*pszString)
     {
-        *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
+        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
         if (*ppszString)
             return VINF_SUCCESS;
@@ -81,5 +73,5 @@
          * Alloc space for result buffer.
          */
-        LPSTR lpString = (LPSTR)RTMemTmpAlloc(cbResult);
+        LPSTR lpString = (LPSTR)RTMemTmpAllocTag(cbResult, pszTag);
         if (lpString)
         {
@@ -115,13 +107,6 @@
 }
 
-/**
- * Allocates tmp buffer, translates pszString from current codepage to UTF-8.
- *
- * @returns iprt status code.
- * @param   ppszString      Receives pointer of allocated UTF-8 string.
- *                          The returned pointer must be freed using RTStrFree().
- * @param   pszString       Native string to convert.
- */
-RTR3DECL(int)  RTStrCurrentCPToUtf8(char **ppszString, const char *pszString)
+
+RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag)
 {
     Assert(ppszString);
@@ -135,5 +120,5 @@
     {
         /* zero length string passed. */
-        *ppszString = (char *)RTMemTmpAllocZ(sizeof(char));
+        *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag);
         if (*ppszString)
             return VINF_SUCCESS;
Index: /trunk/src/VBox/Runtime/testcase/tstMemAutoPtr.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstMemAutoPtr.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/testcase/tstMemAutoPtr.cpp	(revision 31157)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -114,7 +114,7 @@
 
 
-void *tstMemAutoPtrAllocatorNoZero(void *pvOld, size_t cbNew)
-{
-    void *pvNew = RTMemRealloc(pvOld, cbNew);
+void *tstMemAutoPtrAllocatorNoZero(void *pvOld, size_t cbNew, const char *pszTag)
+{
+    void *pvNew = RTMemReallocTag(pvOld, cbNew, pszTag);
     if (pvNew)
         memset(pvNew, 0xfe, cbNew);
Index: /trunk/src/VBox/Runtime/testcase/tstRTMemEf.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstRTMemEf.cpp	(revision 31156)
+++ /trunk/src/VBox/Runtime/testcase/tstRTMemEf.cpp	(revision 31157)
@@ -47,5 +47,5 @@
      * the word after the allocated block and the word before. One of them
      * will crash no matter whether the fence is at the bottom or on top. */
-    int32_t *p = (int32_t *)RTMemEfAllocNP(sizeof(int32_t));
+    int32_t *p = (int32_t *)RTMemEfAllocNP(sizeof(int32_t), RTMEM_TAG);
     RTPrintf("tstRTMemAllocEfAccess: allocated int32_t at %#p\n", p);
     RTPrintf("tstRTMemAllocEfAccess: triggering buffer overrun...\n");
