VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstRTR0DbgKrnlInfo.cpp@ 53019

Last change on this file since 53019 was 41947, checked in by vboxsync, 12 years ago

Runtime/testcases: DbgKrnlInfo. OS specific info. querying is a todo.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: tstRTR0DbgKrnlInfo.cpp 41947 2012-06-28 06:29:36Z vboxsync $ */
2/** @file
3 * IPRT R0 Testcase - Debug kernel information.
4 */
5
6/*
7 * Copyright (C) 2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27/*******************************************************************************
28* Header Files *
29*******************************************************************************/
30#include <iprt/thread.h>
31
32#include <iprt/asm-amd64-x86.h>
33#include <iprt/err.h>
34#include <iprt/time.h>
35#include <iprt/string.h>
36#include <VBox/sup.h>
37#include <iprt/dbg.h>
38#include "tstRTR0DbgKrnlInfo.h"
39#include "tstRTR0Common.h"
40
41
42/**
43 * Service request callback function.
44 *
45 * @returns VBox status code.
46 * @param pSession The caller's session.
47 * @param u64Arg 64-bit integer argument.
48 * @param pReqHdr The request header. Input / Output. Optional.
49 */
50DECLEXPORT(int) TSTR0DbgKrnlInfoSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
51 uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr)
52{
53 NOREF(pSession);
54 if (u64Arg)
55 return VERR_INVALID_PARAMETER;
56 if (!VALID_PTR(pReqHdr))
57 return VERR_INVALID_PARAMETER;
58 char *pszErr = (char *)(pReqHdr + 1);
59 size_t cchErr = pReqHdr->cbReq - sizeof(*pReqHdr);
60 if (cchErr < 32 || cchErr >= 0x10000)
61 return VERR_INVALID_PARAMETER;
62 *pszErr = '\0';
63
64 /*
65 * The big switch.
66 */
67 switch (uOperation)
68 {
69 case TSTRTR0DBGKRNLINFO_SANITY_OK:
70 break;
71
72 case TSTRTR0DBGKRNLINFO_SANITY_FAILURE:
73 RTStrPrintf(pszErr, cchErr, "!42failure42%1024s", "");
74 break;
75
76 case TSTRTR0DBGKRNLINFO_BASIC:
77 {
78 RTDBGKRNLINFO hKrnlInfo;
79 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(&hKrnlInfo, 1), VERR_INVALID_PARAMETER);
80 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(NULL, 0), VERR_INVALID_PARAMETER);
81 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0), VINF_SUCCESS);
82
83 size_t offMemb;
84 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(NULL, "Test", "Test", &offMemb), VERR_INVALID_HANDLE);
85 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, NULL, "Test", &offMemb), VERR_INVALID_PARAMETER);
86 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, "Test", NULL, &offMemb), VERR_INVALID_PARAMETER);
87 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, "Test", "Test", NULL), VERR_INVALID_PARAMETER);
88
89 void *pvSymbol;
90 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(NULL, "Test", "Test", &pvSymbol), VERR_INVALID_HANDLE);
91 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "TestModule", "Test", &pvSymbol), VERR_MODULE_NOT_FOUND);
92 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, NULL, &pvSymbol), VERR_INVALID_PARAMETER);
93 break;
94 }
95
96 /** @todo check member retreival based on target platform. */
97 /** @todo check symbol lookups based on target platform. */
98
99 default:
100 RTStrPrintf(pszErr, cchErr, "!Unknown test #%d", uOperation);
101 break;
102 }
103
104 /* The error indicator is the '!' in the message buffer. */
105 return VINF_SUCCESS;
106}
107
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette