Index: trunk/src/VBox/Runtime/testcase/Makefile.kmk
===================================================================
--- trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 41946)
+++ trunk/src/VBox/Runtime/testcase/Makefile.kmk	(revision 41947)
@@ -162,4 +162,5 @@
  	tstLdr-4 \
  	tstNoCrt-1 \
+	tstRTR0DbgKrnlInfoDriver \
 	tstRTR0MemUserKernelDriver \
 	tstRTR0SemMutexDriver \
@@ -169,4 +170,5 @@
  SYSMODS += \
  	tstLdrObjR0 \
+ 	tstRTR0DbgKrnlInfo \
  	tstRTR0MemUserKernel \
  	tstRTR0SemMutex \
@@ -590,4 +592,17 @@
 
 ## @todo create a template for compiling the ring-0 part.
+tstRTR0DbgKrnlInfo_TEMPLATE = VBoxR0
+tstRTR0DbgKrnlInfo_INST = $(INST_TESTCASE)
+tstRTR0DbgKrnlInfo_DEFS = IN_RT_R0
+tstRTR0DbgKrnlInfo_SYSSUFF = .r0
+tstRTR0DbgKrnlInfo_SOURCES = tstRTR0DbgKrnlInfo.cpp
+tstRTR0DbgKrnlInfo_LIBS = $(PATH_STAGE_LIB)/RuntimeR0$(VBOX_SUFF_LIB)
+if1of ($(VBOX_LDR_FMT), pe lx)
+ tstRTR0DbgKrnlInfo_LIBS += $(PATH_STAGE_LIB)/SUPR0$(VBOX_SUFF_LIB)
+endif
+tstRTR0DbgKrnlInfoDriver_TEMPLATE = VBOXR3TSTEXE
+tstRTR0DbgKrnlInfoDriver_SOURCES = tstRTR0DbgKrnlInfoDriver.cpp
+
+
 tstRTR0MemUserKernel_TEMPLATE = VBoxR0
 tstRTR0MemUserKernel_INST = $(INST_TESTCASE)
Index: trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfo.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfo.cpp	(revision 41947)
+++ trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfo.cpp	(revision 41947)
@@ -0,0 +1,107 @@
+/* $Id$ */
+/** @file
+ * IPRT R0 Testcase - Debug kernel information.
+ */
+
+/*
+ * Copyright (C) 2012 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <iprt/thread.h>
+
+#include <iprt/asm-amd64-x86.h>
+#include <iprt/err.h>
+#include <iprt/time.h>
+#include <iprt/string.h>
+#include <VBox/sup.h>
+#include <iprt/dbg.h>
+#include "tstRTR0DbgKrnlInfo.h"
+#include "tstRTR0Common.h"
+
+
+/**
+ * Service request callback function.
+ *
+ * @returns VBox status code.
+ * @param   pSession    The caller's session.
+ * @param   u64Arg      64-bit integer argument.
+ * @param   pReqHdr     The request header. Input / Output. Optional.
+ */
+DECLEXPORT(int) TSTR0DbgKrnlInfoSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
+                                                   uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr)
+{
+    NOREF(pSession);
+    if (u64Arg)
+        return VERR_INVALID_PARAMETER;
+    if (!VALID_PTR(pReqHdr))
+        return VERR_INVALID_PARAMETER;
+    char   *pszErr = (char *)(pReqHdr + 1);
+    size_t  cchErr = pReqHdr->cbReq - sizeof(*pReqHdr);
+    if (cchErr < 32 || cchErr >= 0x10000)
+        return VERR_INVALID_PARAMETER;
+    *pszErr = '\0';
+
+    /*
+     * The big switch.
+     */
+    switch (uOperation)
+    {
+        case TSTRTR0DBGKRNLINFO_SANITY_OK:
+            break;
+
+        case TSTRTR0DBGKRNLINFO_SANITY_FAILURE:
+            RTStrPrintf(pszErr, cchErr, "!42failure42%1024s", "");
+            break;
+
+        case TSTRTR0DBGKRNLINFO_BASIC:
+        {
+            RTDBGKRNLINFO hKrnlInfo;
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(&hKrnlInfo, 1), VERR_INVALID_PARAMETER);
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(NULL, 0), VERR_INVALID_PARAMETER);
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0), VINF_SUCCESS);
+
+            size_t offMemb;
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(NULL, "Test", "Test", &offMemb), VERR_INVALID_HANDLE);
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, NULL, "Test", &offMemb), VERR_INVALID_PARAMETER);
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, "Test", NULL, &offMemb), VERR_INVALID_PARAMETER);
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, "Test", "Test", NULL), VERR_INVALID_PARAMETER);
+
+            void *pvSymbol;
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(NULL, "Test", "Test", &pvSymbol), VERR_INVALID_HANDLE);
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "TestModule", "Test", &pvSymbol), VERR_MODULE_NOT_FOUND);
+            RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, NULL, &pvSymbol), VERR_INVALID_PARAMETER);
+            break;
+        }
+
+        /** @todo check member retreival based on target platform. */
+        /** @todo check symbol lookups based on target platform. */
+
+        default:
+            RTStrPrintf(pszErr, cchErr, "!Unknown test #%d", uOperation);
+            break;
+    }
+
+    /* The error indicator is the '!' in the message buffer. */
+    return VINF_SUCCESS;
+}
+
Index: trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfo.h
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfo.h	(revision 41947)
+++ trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfo.h	(revision 41947)
@@ -0,0 +1,40 @@
+/* $Id$ */
+/** @file
+ * IPRT R0 Testcase - Debug kernel information, common header.
+ */
+
+/*
+ * Copyright (C) 2012 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifdef IN_RING0
+RT_C_DECLS_BEGIN
+DECLEXPORT(int) TSTR0DbgKrnlInfoSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
+                                              uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
+RT_C_DECLS_END
+#endif
+
+typedef enum TSTR0DBGKRNLINFO
+{
+    TSTRTR0DBGKRNLINFO_SANITY_OK = 1,
+    TSTRTR0DBGKRNLINFO_SANITY_FAILURE,
+    TSTRTR0DBGKRNLINFO_BASIC
+} TSTR0DBGKRNLINFO;
+
Index: trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfoDriver.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfoDriver.cpp	(revision 41947)
+++ trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfoDriver.cpp	(revision 41947)
@@ -0,0 +1,152 @@
+/* $Id$ */
+/** @file
+ * IPRT R0 Testcase - Debug kernel information, driver program.
+ */
+
+/*
+ * Copyright (C) 2012 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include <iprt/initterm.h>
+
+#include <iprt/err.h>
+#include <iprt/path.h>
+#include <iprt/param.h>
+#include <iprt/stream.h>
+#include <iprt/string.h>
+#include <iprt/test.h>
+#ifdef VBOX
+# include <VBox/sup.h>
+# include "tstRTR0DbgKrnlInfo.h"
+#endif
+
+
+int main (int argc, char **argv)
+{
+#ifndef VBOX
+    RTPrintf("tstSup: SKIPPED\n");
+    return 0;
+#else
+    /*
+     * Init.
+     */
+    RTTEST hTest;
+    int rc = RTTestInitAndCreate("tstRTR0DbgKrnlInfo", &hTest);
+    if (rc)
+        return rc;
+    RTTestBanner(hTest);
+
+    uint8_t *pbPage = (uint8_t *)RTTestGuardedAllocTail(hTest, PAGE_SIZE);
+    if (!pbPage)
+    {
+        RTTestFailed(hTest, "RTTestGuardedAllocTail failed with rc=%Rrc\n", rc);
+        return RTTestSummaryAndDestroy(hTest);
+    }
+
+    PSUPDRVSESSION pSession;
+    rc = SUPR3Init(&pSession);
+    if (RT_FAILURE(rc))
+    {
+        RTTestFailed(hTest, "SUPR3Init failed with rc=%Rrc\n", rc);
+        return RTTestSummaryAndDestroy(hTest);
+    }
+
+    char szPath[RTPATH_MAX];
+    rc = RTPathExecDir(szPath, sizeof(szPath));
+    if (RT_SUCCESS(rc))
+        rc = RTPathAppend(szPath, sizeof(szPath), "tstRTR0DbgKrnlInfo.r0");
+    if (RT_FAILURE(rc))
+    {
+        RTTestFailed(hTest, "Failed constructing .r0 filename (rc=%Rrc)", rc);
+        return RTTestSummaryAndDestroy(hTest);
+    }
+
+    void *pvImageBase;
+    rc = SUPR3LoadServiceModule(szPath, "tstRTR0DbgKrnlInfo",
+                                "tstRTR0DbgKrnlInfoSrvReqHandler",
+                                &pvImageBase);
+    if (RT_FAILURE(rc))
+    {
+        RTTestFailed(hTest, "SUPR3LoadServiceModule(%s,,,) failed with rc=%Rrc\n", szPath, rc);
+        return RTTestSummaryAndDestroy(hTest);
+    }
+
+    /* test request */
+    struct
+    {
+        SUPR0SERVICEREQHDR  Hdr;
+        char                szMsg[256];
+    } Req;
+
+    /*
+     * Sanity checks.
+     */
+    RTTestSub(hTest, "Sanity");
+    Req.Hdr.u32Magic = SUPR0SERVICEREQHDR_MAGIC;
+    Req.Hdr.cbReq = sizeof(Req);
+    Req.szMsg[0] = '\0';
+    RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstRTR0DbgKrnlInfo", sizeof("tstRTR0DbgKrnlInfo") - 1,
+                                             TSTRTR0DBGKRNLINFO_SANITY_OK, 0, &Req.Hdr), VINF_SUCCESS);
+    if (RT_FAILURE(rc))
+        return RTTestSummaryAndDestroy(hTest);
+    RTTESTI_CHECK_MSG(Req.szMsg[0] == '\0', ("%s", Req.szMsg));
+    if (Req.szMsg[0] != '\0')
+        return RTTestSummaryAndDestroy(hTest);
+
+    Req.Hdr.u32Magic = SUPR0SERVICEREQHDR_MAGIC;
+    Req.Hdr.cbReq = sizeof(Req);
+    Req.szMsg[0] = '\0';
+    RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstRTR0DbgKrnlInfo", sizeof("tstRTR0DbgKrnlInfo") - 1,
+                                             TSTRTR0DBGKRNLINFO_SANITY_FAILURE, 0, &Req.Hdr), VINF_SUCCESS);
+    if (RT_FAILURE(rc))
+        return RTTestSummaryAndDestroy(hTest);
+    RTTESTI_CHECK_MSG(!strncmp(Req.szMsg, "!42failure42", sizeof("!42failure42") - 1), ("%s", Req.szMsg));
+    if (strncmp(Req.szMsg, "!42failure42", sizeof("!42failure42") - 1))
+        return RTTestSummaryAndDestroy(hTest);
+
+    /*
+     * Basic tests, bail out on failure.
+     */
+    RTTestSub(hTest, "Basics");
+    Req.Hdr.u32Magic = SUPR0SERVICEREQHDR_MAGIC;
+    Req.Hdr.cbReq = sizeof(Req);
+    Req.szMsg[0] = '\0';
+    RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstRTR0DbgKrnlInfo", sizeof("tstRTR0DbgKrnlInfo") - 1,
+                                             TSTRTR0DBGKRNLINFO_BASIC, 0, &Req.Hdr), VINF_SUCCESS);
+    if (RT_FAILURE(rc))
+        return RTTestSummaryAndDestroy(hTest);
+    if (Req.szMsg[0] == '!')
+    {
+        RTTestIFailed("%s", &Req.szMsg[1]);
+        return RTTestSummaryAndDestroy(hTest);
+    }
+    if (Req.szMsg[0])
+        RTTestIPrintf(RTTESTLVL_ALWAYS, "%s", Req.szMsg);
+
+    /*
+     * Done.
+     */
+    return RTTestSummaryAndDestroy(hTest);
+#endif
+}
+
