1 | /* $Id: tstVMStructDTrace.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * tstVMMStructDTrace - Generates the DTrace test scripts for check that C/C++
|
---|
4 | * and DTrace has the same understand of the VM, VMCPU and
|
---|
5 | * other structures.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox base platform packages, as
|
---|
12 | * available from https://www.virtualbox.org.
|
---|
13 | *
|
---|
14 | * This program is free software; you can redistribute it and/or
|
---|
15 | * modify it under the terms of the GNU General Public License
|
---|
16 | * as published by the Free Software Foundation, in version 3 of the
|
---|
17 | * License.
|
---|
18 | *
|
---|
19 | * This program is distributed in the hope that it will be useful, but
|
---|
20 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
22 | * General Public License for more details.
|
---|
23 | *
|
---|
24 | * You should have received a copy of the GNU General Public License
|
---|
25 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
26 | *
|
---|
27 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
28 | */
|
---|
29 |
|
---|
30 |
|
---|
31 | /*********************************************************************************************************************************
|
---|
32 | * Header Files *
|
---|
33 | *********************************************************************************************************************************/
|
---|
34 | #define IN_TSTVMSTRUCT 1
|
---|
35 | #define IN_TSTVMSTRUCTGC 1
|
---|
36 | #include <VBox/vmm/cfgm.h>
|
---|
37 | #include <VBox/vmm/cpum.h>
|
---|
38 | #include <VBox/vmm/mm.h>
|
---|
39 | #include <VBox/vmm/pgm.h>
|
---|
40 | #include <VBox/vmm/selm.h>
|
---|
41 | #include <VBox/vmm/trpm.h>
|
---|
42 | #include <VBox/vmm/vmm.h>
|
---|
43 | #include <VBox/vmm/stam.h>
|
---|
44 | #include "PDMInternal.h"
|
---|
45 | #include <VBox/vmm/pdm.h>
|
---|
46 | #include "CFGMInternal.h"
|
---|
47 | #include "CPUMInternal.h"
|
---|
48 | #include "MMInternal.h"
|
---|
49 | #include "PGMInternal.h"
|
---|
50 | #include "SELMInternal.h"
|
---|
51 | #include "TRPMInternal.h"
|
---|
52 | #include "TMInternal.h"
|
---|
53 | #include "IOMInternal.h"
|
---|
54 | #include "HMInternal.h"
|
---|
55 | #include "APICInternal.h"
|
---|
56 | #include "VMMInternal.h"
|
---|
57 | #include "DBGFInternal.h"
|
---|
58 | #include "GIMInternal.h"
|
---|
59 | #include "STAMInternal.h"
|
---|
60 | #include "EMInternal.h"
|
---|
61 | #include "IEMInternal.h"
|
---|
62 | #include "NEMInternal.h"
|
---|
63 | #ifdef VBOX_WITH_RAW_MODE
|
---|
64 | # include "CSAMInternal.h"
|
---|
65 | # include "PATMInternal.h"
|
---|
66 | #endif
|
---|
67 | #include <VBox/vmm/vm.h>
|
---|
68 | #include <VBox/param.h>
|
---|
69 | #include <iprt/x86.h>
|
---|
70 | #include <iprt/assert.h>
|
---|
71 | #include <iprt/stream.h>
|
---|
72 |
|
---|
73 |
|
---|
74 | int main()
|
---|
75 | {
|
---|
76 | /*
|
---|
77 | * File header and pragmas.
|
---|
78 | */
|
---|
79 | RTPrintf("#pragma D option quiet\n");
|
---|
80 | // RTPrintf("#pragma D depends_on library x86.d\n");
|
---|
81 | // RTPrintf("#pragma D depends_on library cpumctx.d\n");
|
---|
82 | // RTPrintf("#pragma D depends_on library CPUMInternal.d\n");
|
---|
83 | // RTPrintf("#pragma D depends_on library vm.d\n");
|
---|
84 |
|
---|
85 | RTPrintf("int g_cErrors;\n"
|
---|
86 | "\n"
|
---|
87 | "dtrace:::BEGIN\n"
|
---|
88 | "{\n"
|
---|
89 | " g_cErrors = 0;\n"
|
---|
90 | "}\n"
|
---|
91 | "\n"
|
---|
92 | );
|
---|
93 |
|
---|
94 | /*
|
---|
95 | * Test generator macros.
|
---|
96 | */
|
---|
97 | #define GEN_CHECK_SIZE(s) \
|
---|
98 | RTPrintf("dtrace:::BEGIN\n" \
|
---|
99 | "/sizeof(" #s ") != %u/\n" \
|
---|
100 | "{\n" \
|
---|
101 | " printf(\"error: sizeof(" #s ") should be %u, not %%u\\n\", sizeof(" #s "));\n" \
|
---|
102 | " g_cErrors++;\n" \
|
---|
103 | "}\n" \
|
---|
104 | "\n", \
|
---|
105 | (unsigned)sizeof(s), (unsigned)sizeof(s))
|
---|
106 |
|
---|
107 | #if 1
|
---|
108 | # define GEN_CHECK_OFF(s, m) \
|
---|
109 | RTPrintf("dtrace:::BEGIN\n" \
|
---|
110 | "/offsetof(" #s ", " #m ") != %u/\n" \
|
---|
111 | "{\n" \
|
---|
112 | " printf(\"error: offsetof(" #s ", " #m ") should be %u, not %%u\\n\", offsetof(" #s ", " #m "));\n" \
|
---|
113 | " g_cErrors++;\n" \
|
---|
114 | "}\n" \
|
---|
115 | "\n", \
|
---|
116 | (unsigned)RT_OFFSETOF(s, m), (unsigned)RT_OFFSETOF(s, m))
|
---|
117 |
|
---|
118 | #else
|
---|
119 | # define GEN_CHECK_OFF(s, m) do { } while (0)
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | #define GEN_CHECK_OFF_DOT(s, m) do { } while (0)
|
---|
123 |
|
---|
124 |
|
---|
125 | /*
|
---|
126 | * Body.
|
---|
127 | */
|
---|
128 | #define VBOX_FOR_DTRACE_LIB
|
---|
129 | #include "tstVMStruct.h"
|
---|
130 |
|
---|
131 | /*
|
---|
132 | * Footer.
|
---|
133 | */
|
---|
134 | RTPrintf("dtrace:::BEGIN\n"
|
---|
135 | "/g_cErrors != 0/\n"
|
---|
136 | "{\n"
|
---|
137 | " printf(\"%%u errors!\\n\", g_cErrors);\n"
|
---|
138 | " exit(1);\n"
|
---|
139 | "}\n"
|
---|
140 | "\n"
|
---|
141 | "dtrace:::BEGIN\n"
|
---|
142 | "{\n"
|
---|
143 | " printf(\"Success!\\n\");\n"
|
---|
144 | " exit(0);\n"
|
---|
145 | "}\n"
|
---|
146 | "\n"
|
---|
147 | );
|
---|
148 |
|
---|
149 |
|
---|
150 | return (0);
|
---|
151 | }
|
---|
152 |
|
---|