Index: trunk/include/iprt/avl.h
===================================================================
--- trunk/include/iprt/avl.h	(revision 20739)
+++ trunk/include/iprt/avl.h	(revision 20740)
@@ -615,4 +615,52 @@
 
 
+/** AVL tree of RTUINTPTR.
+ * @{
+ */
+
+/**
+ * AVL RTUINTPTR node core.
+ */
+typedef struct _AVLUIntPtrNodeCore
+{
+    /** Key value. */
+    RTUINTPTR                   Key;
+    /** Offset to the left leaf node, relative to this field. */
+    struct _AVLUIntPtrNodeCore *pLeft;
+    /** Offset to the right leaf node, relative to this field. */
+    struct _AVLUIntPtrNodeCore *pRight;
+    /** Height of this tree: max(height(left), height(right)) + 1 */
+    unsigned char               uchHeight;
+} AVLUINTPTRNODECORE;
+/** Pointer to a RTUINTPTR AVL node core.*/
+typedef AVLUINTPTRNODECORE *PAVLUINTPTRNODECORE;
+
+/** A pointer based tree with RTUINTPTR keys. */
+typedef PAVLUINTPTRNODECORE AVLUINTPTRTREE;
+/** Pointer to a offset base tree with RTUINTPTR keys. */
+typedef AVLUINTPTRTREE     *PAVLUINTPTRTREE;
+
+/** Pointer to an internal tree pointer.
+ * In this case it's a pointer to a pointer. */
+typedef AVLUINTPTRTREE     *PPAVLUINTPTRNODECORE;
+
+/** Callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy(). */
+typedef DECLCALLBACK(int)    AVLUINTPTRCALLBACK(PAVLUINTPTRNODECORE pNode, void *pvUser);
+/** Pointer to callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy(). */
+typedef AVLUINTPTRCALLBACK *PAVLUINTPTRCALLBACK;
+
+RTDECL(bool)                    RTAvlUIntPtrInsert(    PAVLUINTPTRTREE pTree, PAVLUINTPTRNODECORE pNode);
+RTDECL(PAVLUINTPTRNODECORE)     RTAvlUIntPtrRemove(    PAVLUINTPTRTREE pTree, RTUINTPTR Key);
+RTDECL(PAVLUINTPTRNODECORE)     RTAvlUIntPtrGet(       PAVLUINTPTRTREE pTree, RTUINTPTR Key);
+RTDECL(PAVLUINTPTRNODECORE)     RTAvlUIntPtrGetBestFit(PAVLUINTPTRTREE pTree, RTUINTPTR Key, bool fAbove);
+RTDECL(int)                     RTAvlUIntPtrDoWithAll( PAVLUINTPTRTREE pTree, int fFromLeft, PAVLUINTPTRCALLBACK pfnCallBack, void *pvParam);
+RTDECL(int)                     RTAvlUIntPtrDestroy(   PAVLUINTPTRTREE pTree, PAVLUINTPTRCALLBACK pfnCallBack, void *pvParam);
+RTDECL(PAVLUINTPTRNODECORE)     RTAvlUIntPtrGetRoot(   PAVLUINTPTRTREE pTree);
+RTDECL(PAVLUINTPTRNODECORE)     RTAvlUIntPtrGetLeft(   PAVLUINTPTRNODECORE pNode);
+RTDECL(PAVLUINTPTRNODECORE)     RTAvlUIntPtrGetRight(  PAVLUINTPTRNODECORE pNode);
+
+/** @} */
+
+
 /** AVL tree of RTUINTPTR ranges.
  * @{
@@ -620,27 +668,29 @@
 
 /**
- * AVL Core node.
+ * AVL RTUINTPTR range node core.
  */
 typedef struct _AVLRUIntPtrNodeCore
 {
     /** First key value in the range (inclusive). */
-    RTUINTPTR           Key;
+    RTUINTPTR                       Key;
     /** Last key value in the range (inclusive). */
-    RTUINTPTR           KeyLast;
-    /** Offset to the left leaf node, relative to this field. */
-    struct _AVLRUIntPtrNodeCore *pLeft;
-    /** Offset to the right leaf node, relative to this field. */
-    struct _AVLRUIntPtrNodeCore *pRight;
-    /** Height of this tree: max(height(left), height(right)) + 1 */
-    unsigned char       uchHeight;
-} AVLRUINTPTRNODECORE, *PAVLRUINTPTRNODECORE;
-
-/** A offset base tree with RTUINTPTR keys. */
+    RTUINTPTR                       KeyLast;
+    /** Offset to the left leaf node, relative to this field. */
+    struct _AVLRUIntPtrNodeCore    *pLeft;
+    /** Offset to the right leaf node, relative to this field. */
+    struct _AVLRUIntPtrNodeCore    *pRight;
+    /** Height of this tree: max(height(left), height(right)) + 1 */
+    unsigned char                   uchHeight;
+} AVLRUINTPTRNODECORE;
+/** Pointer to an AVL RTUINTPTR range node code. */
+typedef AVLRUINTPTRNODECORE *PAVLRUINTPTRNODECORE;
+
+/** A pointer based tree with RTUINTPTR ranges. */
 typedef PAVLRUINTPTRNODECORE AVLRUINTPTRTREE;
-/** Pointer to a offset base tree with RTUINTPTR keys. */
+/** Pointer to a pointer based tree with RTUINTPTR ranges. */
 typedef AVLRUINTPTRTREE     *PAVLRUINTPTRTREE;
 
 /** Pointer to an internal tree pointer.
- * In this case it's a pointer to a relative offset. */
+ * In this case it's a pointer to a pointer. */
 typedef AVLRUINTPTRTREE     *PPAVLRUINTPTRNODECORE;
 
Index: trunk/include/iprt/dbg.h
===================================================================
--- trunk/include/iprt/dbg.h	(revision 20739)
+++ trunk/include/iprt/dbg.h	(revision 20740)
@@ -71,7 +71,11 @@
 typedef struct RTDBGSYMBOL
 {
-    /** Symbol value (address). */
+    /** Symbol value (address).
+     * This depends a bit who you ask. It will be the same as offSeg when you
+     * as RTDbgMod, but the mapping address if you ask RTDbgAs. */
     RTUINTPTR           Value;
-    /** Segment number when applicable or NIL_RTDBGSEGIDX. */
+    /** Offset into the segment specified by iSeg. */
+    RTUINTPTR           offSeg;
+    /** Segment number. */
     RTDBGSEGIDX         iSeg;
     /** Symbol size. */
@@ -87,7 +91,30 @@
 typedef const RTDBGSYMBOL *PCRTDBGSYMBOL;
 
+/**
+ * Allocate a new symbol structure.
+ *
+ * @returns Pointer to a new structure on success, NULL on failure.
+ */
 RTDECL(PRTDBGSYMBOL) RTDbgSymbolAlloc(void);
+
+/**
+ * Duplicates a symbol structure.
+ *
+ * @returns Pointer to duplicate on success, NULL on failure.
+ *
+ * @param   pSymbol         The symbol to duplicate.
+ */
 RTDECL(PRTDBGSYMBOL) RTDbgSymbolDup(PCRTDBGSYMBOL pSymbol);
-RTDECL(void)         RTDbgSymbolFree(PRTDBGSYMBOL pSymbol);
+
+/**
+ * Free a symbol structure previously allocated by a RTDbg method.
+ *
+ * @param   pSymbol         The symbol to free. NULL is ignored.
+ */
+RTDECL(void) RTDbgSymbolFree(PRTDBGSYMBOL pSymbol);
+
+
+/** Max length (including '\\0') of a debug info file name. */
+#define RTDBG_FILE_NAME_LENGTH   (260)
 
 
@@ -97,12 +124,16 @@
 typedef struct RTDBGLINE
 {
-    /** Address. */
+    /** Address.
+     * This depends a bit who you ask. It will be the same as offSeg when you
+     * as RTDbgMod, but the mapping address if you ask RTDbgAs. */
     RTUINTPTR           Address;
-    /** Segment number when applicable or NIL_RTDBGSEGIDX. */
+    /** Offset into the segment specified by iSeg. */
+    RTUINTPTR           offSeg;
+    /** Segment number. */
     RTDBGSEGIDX         iSeg;
     /** Line number. */
     uint32_t            uLineNo;
     /** Filename. */
-    char                szFilename[260];
+    char                szFilename[RTDBG_FILE_NAME_LENGTH];
 } RTDBGLINE;
 /** Pointer to debug line number. */
@@ -360,4 +391,6 @@
  * @retval  VERR_INVALID_HANDLE if hDbgAs is invalid.
  * @retval  VERR_NOT_FOUND if no module was found at the specified address.
+ * @retval  VERR_NOT_SUPPORTED if the module interpret doesn't support adding
+ *          custom symbols.
  *
  * @param   hDbgAs          The address space handle.
@@ -365,6 +398,7 @@
  * @param   Addr            The address of the symbol.
  * @param   cb              The size of the symbol.
- */
-RTDECL(int) RTDbgAsSymbolAdd(RTDBGAS hDbgAs, const char *pszSymbol, RTUINTPTR Addr, uint32_t cb);
+ * @param   fFlags          Symbol flags.
+ */
+RTDECL(int) RTDbgAsSymbolAdd(RTDBGAS hDbgAs, const char *pszSymbol, RTUINTPTR Addr, RTUINTPTR cb, uint32_t fFlags);
 
 /**
@@ -472,7 +506,8 @@
 RTDECL(RTUINTPTR)   RTDbgModImageSize(RTDBGMOD hDbgMod);
 RTDECL(RTUINTPTR)   RTDbgModSegmentSize(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg);
+RTDECL(RTUINTPTR)   RTDbgModSegmentRva(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg);
 RTDECL(RTDBGSEGIDX) RTDbgModSegmentCount(RTDBGMOD hDbgMod);
 
-RTDECL(int)         RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t cb);
+RTDECL(int)         RTDbgModSymbolAdd(RTDBGMOD hDbgMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags);
 RTDECL(uint32_t)    RTDbgModSymbolCount(RTDBGMOD hDbgMod);
 RTDECL(int)         RTDbgModSymbolByIndex(RTDBGMOD hDbgMod, uint32_t iSymbol, PRTDBGSYMBOL pSymbol);
@@ -482,4 +517,5 @@
 RTDECL(int)         RTDbgModSymbolByNameA(RTDBGMOD hDbgMod, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol);
 
+RTDECL(int)         RTDbgModLineAdd(RTDBGMOD hDbgMod, const char *pszFile, uint32_t uLineNo, RTDBGSEGIDX iSeg, RTUINTPTR off);
 RTDECL(int)         RTDbgModLineByAddr(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE pLine);
 RTDECL(int)         RTDbgModLineByAddrA(RTDBGMOD hDbgMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE *ppLine);
Index: trunk/include/iprt/err.h
===================================================================
--- trunk/include/iprt/err.h	(revision 20739)
+++ trunk/include/iprt/err.h	(revision 20740)
@@ -946,6 +946,22 @@
 /** Invalid segment offset. */
 #define VERR_DBG_INVALID_SEGMENT_OFFSET         (-652)
+/** Invalid image relative virtual address. */
+#define VERR_DBG_INVALID_RVA                    (-653)
 /** The module contains no line number information. */
-#define VERR_DBG_NO_LINE_NUMBERS                (-653)
+#define VERR_DBG_NO_LINE_NUMBERS                (-654)
+/** Address conflict within a module/segment.
+ * Attempted to add a symbol or line number that fully or partially overlaps with an existing one.  */
+#define VERR_DBG_ADDRESS_CONFLICT               (-655)
+/** Duplicate symbol within the module.
+ * Attempted to add a symbol which name already exists within the module.  */
+#define VERR_DBG_DUPLICATE_SYMBOL               (-656)
+/** The length of the symbol name is out of range.
+ * This means it is an empty string or that it's greater or equal to
+ * RTDBG_SYMBOL_NAME_LENGTH. */
+#define VERR_DBG_SYMBOL_NAME_OUT_OF_RANGE       (-657)
+/** The length of the file name is out of range.
+ * This means it is an empty string or that it's greater or equal to
+ * RTDBG_FILE_NAME_LENGTH. */
+#define VERR_DBG_FILE_NAME_OUT_OF_RANGE         (-658)
 /** @} */
 
Index: trunk/include/iprt/types.h
===================================================================
--- trunk/include/iprt/types.h	(revision 20739)
+++ trunk/include/iprt/types.h	(revision 20740)
@@ -388,4 +388,12 @@
 /** Pointer const to unsigned integer which can contain both GC and HC pointers. */
 typedef const RTUINTPTR *PCRTUINTPTR;
+/** The maximum value the RTUINTPTR type can hold. */
+#if (HC_ARCH_BITS == 32 && GC_ARCH_BITS == 32)
+# define RTUINTPTR_MAX  UINT32_MAX
+#elif (HC_ARCH_BITS == 64 || GC_ARCH_BITS == 64)
+# define RTUINTPTR_MAX  UINT64_MAX
+#else
+#  error Unsupported HC_ARCH_BITS and/or GC_ARCH_BITS values.
+#endif
 
 /** Signed integer. */
