VirtualBox

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

Last change on this file since 94130 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: tstRTR0DbgKrnlInfo.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * IPRT R0 Testcase - Debug kernel information.
4 */
5
6/*
7 * Copyright (C) 2012-2022 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/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include <iprt/thread.h>
32
33#include <iprt/asm-amd64-x86.h>
34#include <iprt/err.h>
35#include <iprt/time.h>
36#include <iprt/string.h>
37#include <VBox/sup.h>
38#include <iprt/dbg.h>
39#include "tstRTR0DbgKrnlInfo.h"
40#include "tstRTR0Common.h"
41
42
43/**
44 * Service request callback function.
45 *
46 * @returns VBox status code.
47 * @param pSession The caller's session.
48 * @param u64Arg 64-bit integer argument.
49 * @param pReqHdr The request header. Input / Output. Optional.
50 */
51DECLEXPORT(int) TSTR0DbgKrnlInfoSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
52 uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr)
53{
54 NOREF(pSession);
55 if (u64Arg)
56 return VERR_INVALID_PARAMETER;
57 if (!RT_VALID_PTR(pReqHdr))
58 return VERR_INVALID_PARAMETER;
59 char *pszErr = (char *)(pReqHdr + 1);
60 size_t cchErr = pReqHdr->cbReq - sizeof(*pReqHdr);
61 if (cchErr < 32 || cchErr >= 0x10000)
62 return VERR_INVALID_PARAMETER;
63 *pszErr = '\0';
64
65 /*
66 * The big switch.
67 */
68 bool fSavedMayPanic = RTAssertSetMayPanic(false); /* Don't crash the host with strict builds! */
69 RTDBGKRNLINFO hKrnlInfo = NIL_RTDBGKRNLINFO;
70 switch (uOperation)
71 {
72 case TSTRTR0DBGKRNLINFO_SANITY_OK:
73 break;
74
75 case TSTRTR0DBGKRNLINFO_SANITY_FAILURE:
76 RTStrPrintf(pszErr, cchErr, "!42failure42%1024s", "");
77 break;
78
79 case TSTRTR0DBGKRNLINFO_BASIC:
80 {
81 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(&hKrnlInfo, 1), VERR_INVALID_PARAMETER);
82 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(NULL, 0), VERR_INVALID_PARAMETER);
83 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0), VINF_SUCCESS);
84
85 size_t offMemb;
86 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(NULL, NULL, "Test", "Test", &offMemb), VERR_INVALID_HANDLE);
87 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, NULL, NULL, "Test", &offMemb), VERR_INVALID_PARAMETER);
88 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, NULL, "Test", NULL, &offMemb), VERR_INVALID_PARAMETER);
89 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQueryMember(hKrnlInfo, NULL, "Test", "Test", NULL), VERR_INVALID_PARAMETER);
90
91 void *pvSymbol;
92 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(NULL, "Test", "Test", &pvSymbol), VERR_INVALID_HANDLE);
93 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, "TestModule", "Test", &pvSymbol), VERR_MODULE_NOT_FOUND);
94 RTR0TESTR0_CHECK_RC_BREAK(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, NULL, &pvSymbol), VERR_INVALID_PARAMETER);
95
96 RTR0DbgKrnlInfoRelease(hKrnlInfo);
97 hKrnlInfo = NIL_RTDBGKRNLINFO;
98 uint32_t cRefs;
99 RTR0TESTR0_CHECK_MSG((cRefs = RTR0DbgKrnlInfoRelease(NIL_RTDBGKRNLINFO)) == 0, ("cRefs=%#x", cRefs));
100 break;
101 }
102
103 /** @todo check member retreival based on target platform. */
104 /** @todo check symbol lookups based on target platform. */
105
106 default:
107 RTStrPrintf(pszErr, cchErr, "!Unknown test #%d", uOperation);
108 break;
109 }
110 if (hKrnlInfo != NIL_RTDBGKRNLINFO)
111 RTR0DbgKrnlInfoRelease(hKrnlInfo);
112 RTAssertSetMayPanic(fSavedMayPanic);
113
114 /* The error indicator is the '!' in the message buffer. */
115 return VINF_SUCCESS;
116}
117
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