1 | /* $Id: tstIEMN8veProfiling.cpp 106212 2024-10-03 02:42:55Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PDM Queue Testcase.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2022-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP LOG_GROUP_PDM_QUEUE
|
---|
33 | #define VBOX_IN_VMM
|
---|
34 |
|
---|
35 | #include <VBox/vmm/iem.h>
|
---|
36 |
|
---|
37 | #include <VBox/vmm/vm.h>
|
---|
38 | #include <VBox/vmm/uvm.h>
|
---|
39 | #include <VBox/vmm/vmm.h>
|
---|
40 |
|
---|
41 | #include <iprt/errcore.h>
|
---|
42 | #include <iprt/assert.h>
|
---|
43 | #include <iprt/getopt.h>
|
---|
44 | #include <iprt/initterm.h>
|
---|
45 | #include <iprt/message.h>
|
---|
46 | #include <iprt/stream.h>
|
---|
47 | #include <iprt/string.h>
|
---|
48 |
|
---|
49 |
|
---|
50 | int main(int argc, char **argv)
|
---|
51 | {
|
---|
52 | /*
|
---|
53 | * We run the VMM in driverless mode to avoid needing to hardened the testcase.
|
---|
54 | */
|
---|
55 | RTEXITCODE rcExit;
|
---|
56 | int rc = RTR3InitExe(argc, &argv, SUPR3INIT_F_DRIVERLESS << RTR3INIT_FLAGS_SUPLIB_SHIFT);
|
---|
57 | if (RT_SUCCESS(rc))
|
---|
58 | {
|
---|
59 | /* Don't do anything unless we've been given some input. */
|
---|
60 | if (argc > 1)
|
---|
61 | {
|
---|
62 | /*
|
---|
63 | * Parse arguments.
|
---|
64 | */
|
---|
65 | PVM pVM = NULL;
|
---|
66 | PUVM pUVM = NULL;
|
---|
67 | unsigned cVerbosity = 0;
|
---|
68 | uint32_t cMinTbs = 0;
|
---|
69 | static const RTGETOPTDEF s_aOptions[] =
|
---|
70 | {
|
---|
71 | { "--verbose", 'v', RTGETOPT_REQ_NOTHING },
|
---|
72 | { "--min-tbs", 'm', RTGETOPT_REQ_UINT32 },
|
---|
73 | };
|
---|
74 | RTGETOPTSTATE GetState;
|
---|
75 | rc = RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
|
---|
76 | AssertRC(rc);
|
---|
77 |
|
---|
78 | rcExit = RTEXITCODE_SUCCESS;
|
---|
79 | RTGETOPTUNION ValueUnion;
|
---|
80 | while ((rc = RTGetOpt(&GetState, &ValueUnion)))
|
---|
81 | {
|
---|
82 | switch (rc)
|
---|
83 | {
|
---|
84 | case 'm':
|
---|
85 | cMinTbs = ValueUnion.u32;
|
---|
86 | break;
|
---|
87 |
|
---|
88 | case 'v':
|
---|
89 | cVerbosity++;
|
---|
90 | break;
|
---|
91 |
|
---|
92 | case 'q':
|
---|
93 | cVerbosity = 0;
|
---|
94 | break;
|
---|
95 |
|
---|
96 | case 'h':
|
---|
97 | RTPrintf("Usage: %Rbn [options] <ThreadedTBsForRecompilerProfiling.sav>\n"
|
---|
98 | "\n"
|
---|
99 | "Options:\n"
|
---|
100 | " --min-tbs=<count>, -m<count>\n"
|
---|
101 | " Duplicate TBs till we have at least the specific count.\n"
|
---|
102 | , argv[0]);
|
---|
103 | return RTEXITCODE_SUCCESS;
|
---|
104 |
|
---|
105 | case VINF_GETOPT_NOT_OPTION:
|
---|
106 | /*
|
---|
107 | * Create the VM the first time thru here.
|
---|
108 | */
|
---|
109 | if (!pVM)
|
---|
110 | {
|
---|
111 | rc = VMR3Create(1 /*cCpus*/, NULL, VMCREATE_F_DRIVERLESS, NULL, NULL, NULL, NULL, &pVM, &pUVM);
|
---|
112 | if (RT_FAILURE(rc))
|
---|
113 | {
|
---|
114 | RTMsgError("VMR3Create failed: %Rrc", rc);
|
---|
115 | return RTEXITCODE_FAILURE;
|
---|
116 | }
|
---|
117 | }
|
---|
118 | rc = VMR3ReqCallWaitU(pUVM, 0, (PFNRT)IEMR3ThreadedProfileRecompilingSavedTbs,
|
---|
119 | 3, pVM, ValueUnion.psz, cMinTbs);
|
---|
120 | if (RT_FAILURE(rc))
|
---|
121 | rcExit = RTEXITCODE_FAILURE;
|
---|
122 | break;
|
---|
123 |
|
---|
124 | default:
|
---|
125 | return RTGetOptPrintError(rc, &ValueUnion);
|
---|
126 | }
|
---|
127 | }
|
---|
128 | }
|
---|
129 | else
|
---|
130 | {
|
---|
131 | RTMsgInfo("Nothing to do. Try --help.\n");
|
---|
132 | rcExit = RTEXITCODE_SUCCESS;
|
---|
133 | }
|
---|
134 | }
|
---|
135 | else
|
---|
136 | rcExit = RTMsgInitFailure(rc);
|
---|
137 | return rcExit;
|
---|
138 | }
|
---|
139 |
|
---|