1 | /* $Id: bs3-cmn-TestCheckExtCtx.c 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Bs3TestCheckExtCtx
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2022 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 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 |
|
---|
38 | /*********************************************************************************************************************************
|
---|
39 | * Header Files *
|
---|
40 | *********************************************************************************************************************************/
|
---|
41 | #include "bs3kit-template-header.h"
|
---|
42 |
|
---|
43 |
|
---|
44 | /*********************************************************************************************************************************
|
---|
45 | * Global Variables *
|
---|
46 | *********************************************************************************************************************************/
|
---|
47 | /** Field descriptors. */
|
---|
48 | static struct
|
---|
49 | {
|
---|
50 | uint8_t enmMethod;
|
---|
51 | uint8_t cb;
|
---|
52 | uint16_t off;
|
---|
53 | const char BS3_FAR *pszName;
|
---|
54 | } const g_aFields[] =
|
---|
55 | {
|
---|
56 | #define BS3EXTCTX_FIELD_ENTRY(a_enmMethod, a_Member) \
|
---|
57 | { a_enmMethod, RT_SIZEOFMEMB(BS3EXTCTX, a_Member), RT_OFFSETOF(BS3EXTCTX, a_Member), #a_Member }
|
---|
58 | BS3EXTCTX_FIELD_ENTRY(BS3EXTCTXMETHOD_END, fXcr0Saved),
|
---|
59 |
|
---|
60 | #define BS3EXTCTX_FIELD_ENTRY_CTX(a_enmMethod, a_Member) \
|
---|
61 | { a_enmMethod, RT_SIZEOFMEMB(BS3EXTCTX, Ctx.a_Member), RT_OFFSETOF(BS3EXTCTX, Ctx.a_Member), #a_Member }
|
---|
62 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.FCW),
|
---|
63 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.Dummy1),
|
---|
64 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.FSW),
|
---|
65 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.Dummy2),
|
---|
66 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.FTW),
|
---|
67 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.Dummy3),
|
---|
68 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.FPUIP),
|
---|
69 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.CS),
|
---|
70 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.FOP),
|
---|
71 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.FPUOO),
|
---|
72 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.FPUOS),
|
---|
73 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[0]),
|
---|
74 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[1]),
|
---|
75 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[2]),
|
---|
76 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[3]),
|
---|
77 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[4]),
|
---|
78 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[5]),
|
---|
79 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[6]),
|
---|
80 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_ANCIENT, Ancient.regs[7]),
|
---|
81 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.FCW),
|
---|
82 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.FSW),
|
---|
83 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.FTW),
|
---|
84 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.FOP),
|
---|
85 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.FPUIP),
|
---|
86 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.CS),
|
---|
87 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.Rsrvd1),
|
---|
88 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.FPUDP),
|
---|
89 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.DS),
|
---|
90 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.Rsrvd2),
|
---|
91 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.MXCSR),
|
---|
92 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.MXCSR_MASK),
|
---|
93 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[0]),
|
---|
94 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[1]),
|
---|
95 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[2]),
|
---|
96 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[3]),
|
---|
97 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[4]),
|
---|
98 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[5]),
|
---|
99 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[6]),
|
---|
100 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aRegs[7]),
|
---|
101 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[0]),
|
---|
102 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[1]),
|
---|
103 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[2]),
|
---|
104 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[3]),
|
---|
105 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[4]),
|
---|
106 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[5]),
|
---|
107 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[6]),
|
---|
108 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[7]),
|
---|
109 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[8]),
|
---|
110 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[9]),
|
---|
111 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[10]),
|
---|
112 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[11]),
|
---|
113 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[12]),
|
---|
114 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[13]),
|
---|
115 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[14]),
|
---|
116 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_FXSAVE, x87.aXMM[15]),
|
---|
117 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.FCW),
|
---|
118 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.FSW),
|
---|
119 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.FTW),
|
---|
120 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.FOP),
|
---|
121 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.FPUIP),
|
---|
122 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.CS),
|
---|
123 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.Rsrvd1),
|
---|
124 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.FPUDP),
|
---|
125 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.DS),
|
---|
126 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.Rsrvd2),
|
---|
127 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.MXCSR),
|
---|
128 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.MXCSR_MASK),
|
---|
129 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[0]),
|
---|
130 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[1]),
|
---|
131 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[2]),
|
---|
132 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[3]),
|
---|
133 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[4]),
|
---|
134 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[5]),
|
---|
135 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[6]),
|
---|
136 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aRegs[7]),
|
---|
137 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[0]),
|
---|
138 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[1]),
|
---|
139 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[2]),
|
---|
140 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[3]),
|
---|
141 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[4]),
|
---|
142 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[5]),
|
---|
143 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[6]),
|
---|
144 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[7]),
|
---|
145 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[8]),
|
---|
146 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[9]),
|
---|
147 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[10]),
|
---|
148 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[11]),
|
---|
149 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[12]),
|
---|
150 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[13]),
|
---|
151 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[14]),
|
---|
152 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.x87.aXMM[15]),
|
---|
153 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.Hdr.bmXState),
|
---|
154 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.Hdr.bmXComp),
|
---|
155 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[0]),
|
---|
156 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[1]),
|
---|
157 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[2]),
|
---|
158 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[3]),
|
---|
159 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[4]),
|
---|
160 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[5]),
|
---|
161 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[6]),
|
---|
162 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[7]),
|
---|
163 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[8]),
|
---|
164 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[9]),
|
---|
165 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[10]),
|
---|
166 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[11]),
|
---|
167 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[12]),
|
---|
168 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[13]),
|
---|
169 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[14]),
|
---|
170 | BS3EXTCTX_FIELD_ENTRY_CTX(BS3EXTCTXMETHOD_XSAVE, x.u.YmmHi.aYmmHi[15]),
|
---|
171 | };
|
---|
172 |
|
---|
173 |
|
---|
174 | #undef Bs3TestCheckExtCtx
|
---|
175 | BS3_CMN_DEF(bool, Bs3TestCheckExtCtx,(PCBS3EXTCTX pActualExtCtx, PCBS3EXTCTX pExpectedExtCtx, uint16_t fFlags,
|
---|
176 | const char BS3_FAR *pszMode, uint16_t idTestStep))
|
---|
177 | {
|
---|
178 | /*
|
---|
179 | * Make sure the context of a similar and valid before starting.
|
---|
180 | */
|
---|
181 | if (!pActualExtCtx || pActualExtCtx->u16Magic != BS3EXTCTX_MAGIC)
|
---|
182 | return Bs3TestFailedF("%u - %s: invalid actual context pointer: %p", idTestStep, pszMode, pActualExtCtx);
|
---|
183 | if (!pExpectedExtCtx || pExpectedExtCtx->u16Magic != BS3EXTCTX_MAGIC)
|
---|
184 | return Bs3TestFailedF("%u - %s: invalid expected context pointer: %p", idTestStep, pszMode, pExpectedExtCtx);
|
---|
185 | if ( pActualExtCtx->enmMethod != pExpectedExtCtx->enmMethod
|
---|
186 | || pActualExtCtx->enmMethod == BS3EXTCTXMETHOD_INVALID
|
---|
187 | || pActualExtCtx->enmMethod >= BS3EXTCTXMETHOD_END)
|
---|
188 | return Bs3TestFailedF("%u - %s: mismatching or/and invalid context methods: %d vs %d",
|
---|
189 | idTestStep, pszMode, pActualExtCtx->enmMethod, pExpectedExtCtx->enmMethod);
|
---|
190 | if (pActualExtCtx->cb != pExpectedExtCtx->cb)
|
---|
191 | return Bs3TestFailedF("%u - %s: mismatching context sizes: %#x vs %#x",
|
---|
192 | idTestStep, pszMode, pActualExtCtx->cb, pExpectedExtCtx->cb);
|
---|
193 |
|
---|
194 | /*
|
---|
195 | * Try get the job done quickly with a memory compare.
|
---|
196 | */
|
---|
197 | if (Bs3MemCmp(pActualExtCtx, pExpectedExtCtx, pActualExtCtx->cb) == 0)
|
---|
198 | return true;
|
---|
199 |
|
---|
200 | Bs3TestFailedF("%u - %s: context memory differs", idTestStep, pszMode); // debug
|
---|
201 | {
|
---|
202 | uint8_t const BS3_FAR *pb1 = (uint8_t const BS3_FAR *)pActualExtCtx;
|
---|
203 | uint8_t const BS3_FAR *pb2 = (uint8_t const BS3_FAR *)pExpectedExtCtx;
|
---|
204 | unsigned const cb = pActualExtCtx->cb;
|
---|
205 | unsigned off;
|
---|
206 | for (off = 0; off < cb; off++)
|
---|
207 | if (pb1[off] != pb2[off])
|
---|
208 | {
|
---|
209 | unsigned offStart = off++;
|
---|
210 | const char BS3_FAR *pszName = NULL;
|
---|
211 | unsigned cbDiff = 0;
|
---|
212 | unsigned idxField;
|
---|
213 | for (idxField = 0; idxField < RT_ELEMENTS(g_aFields); idxField++)
|
---|
214 | if ( offStart - g_aFields[idxField].off < g_aFields[idxField].cb
|
---|
215 | && ( g_aFields[idxField].enmMethod == BS3EXTCTXMETHOD_END
|
---|
216 | || g_aFields[idxField].enmMethod == pActualExtCtx->enmMethod))
|
---|
217 | {
|
---|
218 | pszName = g_aFields[idxField].pszName;
|
---|
219 | cbDiff = g_aFields[idxField].cb;
|
---|
220 | offStart = g_aFields[idxField].off;
|
---|
221 | off = offStart + cbDiff;
|
---|
222 | break;
|
---|
223 | }
|
---|
224 | if (!pszName)
|
---|
225 | {
|
---|
226 | while (off < cb && pb1[off] != pb2[off])
|
---|
227 | off++;
|
---|
228 | cbDiff = off - offStart;
|
---|
229 | pszName = "unknown";
|
---|
230 | }
|
---|
231 | switch (cbDiff)
|
---|
232 | {
|
---|
233 | case 1:
|
---|
234 | Bs3TestFailedF("%u - %s: Byte difference at %#x (%s): %#04x, expected %#04x",
|
---|
235 | idTestStep, pszMode, offStart, pszName, pb1[offStart], pb2[offStart]);
|
---|
236 | break;
|
---|
237 | case 2:
|
---|
238 | Bs3TestFailedF("%u - %s: Word difference at %#x (%s): %#06x, expected %#06x",
|
---|
239 | idTestStep, pszMode, offStart, pszName,
|
---|
240 | RT_MAKE_U16(pb1[offStart], pb1[offStart + 1]),
|
---|
241 | RT_MAKE_U16(pb2[offStart], pb2[offStart + 1]));
|
---|
242 | break;
|
---|
243 | case 4:
|
---|
244 | Bs3TestFailedF("%u - %s: DWord difference at %#x (%s): %#010RX32, expected %#010RX32",
|
---|
245 | idTestStep, pszMode, offStart, pszName,
|
---|
246 | RT_MAKE_U32_FROM_U8(pb1[offStart], pb1[offStart + 1], pb1[offStart + 2], pb1[offStart + 3]),
|
---|
247 | RT_MAKE_U32_FROM_U8(pb2[offStart], pb2[offStart + 1], pb2[offStart + 2], pb2[offStart + 3]));
|
---|
248 | break;
|
---|
249 | case 8:
|
---|
250 | Bs3TestFailedF("%u - %s: QWord difference at %#x (%s): %#018RX64, expected %#018RX64",
|
---|
251 | idTestStep, pszMode, offStart, pszName,
|
---|
252 | RT_MAKE_U64_FROM_U8(pb1[offStart], pb1[offStart + 1], pb1[offStart + 2], pb1[offStart + 3],
|
---|
253 | pb1[offStart + 4], pb1[offStart + 5], pb1[offStart + 6], pb1[offStart + 7]),
|
---|
254 | RT_MAKE_U64_FROM_U8(pb2[offStart], pb2[offStart + 1], pb2[offStart + 2], pb2[offStart + 3],
|
---|
255 | pb2[offStart + 4], pb2[offStart + 5], pb2[offStart + 6], pb2[offStart + 7]));
|
---|
256 | break;
|
---|
257 | case 16:
|
---|
258 | Bs3TestFailedF("%u - %s: DQword difference at %#x (%s): \n"
|
---|
259 | "got %#018RX64'%#018RX64\n"
|
---|
260 | "expected %#018RX64'%#018RX64",
|
---|
261 | idTestStep, pszMode, offStart, pszName,
|
---|
262 | RT_MAKE_U64_FROM_U8(pb1[offStart + 8], pb1[offStart + 9], pb1[offStart + 10], pb1[offStart + 11],
|
---|
263 | pb1[offStart + 12], pb1[offStart + 13], pb1[offStart + 14], pb1[offStart + 15]),
|
---|
264 | RT_MAKE_U64_FROM_U8(pb1[offStart], pb1[offStart + 1], pb1[offStart + 2], pb1[offStart + 3],
|
---|
265 | pb1[offStart + 4], pb1[offStart + 5], pb1[offStart + 6], pb1[offStart + 7]),
|
---|
266 |
|
---|
267 | RT_MAKE_U64_FROM_U8(pb2[offStart + 8], pb2[offStart + 9], pb2[offStart + 10], pb2[offStart + 11],
|
---|
268 | pb2[offStart + 12], pb2[offStart + 13], pb2[offStart + 14], pb2[offStart + 15]),
|
---|
269 | RT_MAKE_U64_FROM_U8(pb2[offStart], pb2[offStart + 1], pb2[offStart + 2], pb2[offStart + 3],
|
---|
270 | pb2[offStart + 4], pb2[offStart + 5], pb2[offStart + 6], pb2[offStart + 7])
|
---|
271 | );
|
---|
272 | break;
|
---|
273 |
|
---|
274 | default:
|
---|
275 | Bs3TestFailedF("%u - %s: %#x..%#x differs (%s)\n"
|
---|
276 | "got %.*Rhxs\n"
|
---|
277 | "expected %.*Rhxs",
|
---|
278 | idTestStep, pszMode, offStart, off - 1, pszName,
|
---|
279 | off - offStart, &pb1[offStart],
|
---|
280 | off - offStart, &pb2[offStart]);
|
---|
281 | break;
|
---|
282 | }
|
---|
283 | }
|
---|
284 | }
|
---|
285 | return false;
|
---|
286 | }
|
---|
287 |
|
---|