1 | /* $Id: tstDBGCParser.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DBGC Testcase - Command Parser.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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 | #include <VBox/dbg.h>
|
---|
33 | #include "../DBGCInternal.h"
|
---|
34 |
|
---|
35 | #include <iprt/string.h>
|
---|
36 | #include <iprt/test.h>
|
---|
37 | #include <VBox/err.h>
|
---|
38 |
|
---|
39 |
|
---|
40 | /*********************************************************************************************************************************
|
---|
41 | * Internal Functions *
|
---|
42 | *********************************************************************************************************************************/
|
---|
43 | static DECLCALLBACK(bool) tstDBGCBackInput(PCDBGCIO pBack, uint32_t cMillies);
|
---|
44 | static DECLCALLBACK(int) tstDBGCBackRead(PCDBGCIO pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead);
|
---|
45 | static DECLCALLBACK(int) tstDBGCBackWrite(PCDBGCIO pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten);
|
---|
46 | static DECLCALLBACK(void) tstDBGCBackSetReady(PCDBGCIO pBack, bool fReady);
|
---|
47 |
|
---|
48 |
|
---|
49 | /*********************************************************************************************************************************
|
---|
50 | * Global Variables *
|
---|
51 | *********************************************************************************************************************************/
|
---|
52 | /** The test handle. */
|
---|
53 | static RTTEST g_hTest = NIL_RTTEST;
|
---|
54 |
|
---|
55 | /** The DBGC I/O structure for use in this testcase. */
|
---|
56 | static DBGCIO g_tstBack =
|
---|
57 | {
|
---|
58 | NULL, /**pfnDestroy*/
|
---|
59 | tstDBGCBackInput,
|
---|
60 | tstDBGCBackRead,
|
---|
61 | tstDBGCBackWrite,
|
---|
62 | NULL, /**pfnPktBegin*/
|
---|
63 | NULL, /**pfnPktEnd*/
|
---|
64 | tstDBGCBackSetReady
|
---|
65 | };
|
---|
66 | /** For keeping track of output prefixing. */
|
---|
67 | static bool g_fPendingPrefix = true;
|
---|
68 | /** Pointer to the current input position. */
|
---|
69 | const char *g_pszInput = NULL;
|
---|
70 | /** The output of the last command. */
|
---|
71 | static char g_szOutput[1024];
|
---|
72 | /** The current offset into g_szOutput. */
|
---|
73 | static size_t g_offOutput = 0;
|
---|
74 |
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Checks if there is input.
|
---|
78 | *
|
---|
79 | * @returns true if there is input ready.
|
---|
80 | * @returns false if there not input ready.
|
---|
81 | * @param pBack Pointer to the backend structure supplied by
|
---|
82 | * the backend. The backend can use this to find
|
---|
83 | * it's instance data.
|
---|
84 | * @param cMillies Number of milliseconds to wait on input data.
|
---|
85 | */
|
---|
86 | static DECLCALLBACK(bool) tstDBGCBackInput(PCDBGCIO pBack, uint32_t cMillies)
|
---|
87 | {
|
---|
88 | return g_pszInput != NULL
|
---|
89 | && *g_pszInput != '\0';
|
---|
90 | }
|
---|
91 |
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Read input.
|
---|
95 | *
|
---|
96 | * @returns VBox status code.
|
---|
97 | * @param pBack Pointer to the backend structure supplied by
|
---|
98 | * the backend. The backend can use this to find
|
---|
99 | * it's instance data.
|
---|
100 | * @param pvBuf Where to put the bytes we read.
|
---|
101 | * @param cbBuf Maximum nymber of bytes to read.
|
---|
102 | * @param pcbRead Where to store the number of bytes actually read.
|
---|
103 | * If NULL the entire buffer must be filled for a
|
---|
104 | * successful return.
|
---|
105 | */
|
---|
106 | static DECLCALLBACK(int) tstDBGCBackRead(PCDBGCIO pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead)
|
---|
107 | {
|
---|
108 | if (g_pszInput && *g_pszInput)
|
---|
109 | {
|
---|
110 | size_t cb = strlen(g_pszInput);
|
---|
111 | if (cb > cbBuf)
|
---|
112 | cb = cbBuf;
|
---|
113 | *pcbRead = cb;
|
---|
114 | memcpy(pvBuf, g_pszInput, cb);
|
---|
115 | g_pszInput += cb;
|
---|
116 | }
|
---|
117 | else
|
---|
118 | *pcbRead = 0;
|
---|
119 | return VINF_SUCCESS;
|
---|
120 | }
|
---|
121 |
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * Write (output).
|
---|
125 | *
|
---|
126 | * @returns VBox status code.
|
---|
127 | * @param pBack Pointer to the backend structure supplied by
|
---|
128 | * the backend. The backend can use this to find
|
---|
129 | * it's instance data.
|
---|
130 | * @param pvBuf What to write.
|
---|
131 | * @param cbBuf Number of bytes to write.
|
---|
132 | * @param pcbWritten Where to store the number of bytes actually written.
|
---|
133 | * If NULL the entire buffer must be successfully written.
|
---|
134 | */
|
---|
135 | static DECLCALLBACK(int) tstDBGCBackWrite(PCDBGCIO pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten)
|
---|
136 | {
|
---|
137 | const char *pch = (const char *)pvBuf;
|
---|
138 | if (pcbWritten)
|
---|
139 | *pcbWritten = cbBuf;
|
---|
140 | while (cbBuf-- > 0)
|
---|
141 | {
|
---|
142 | /* screen/log output */
|
---|
143 | if (g_fPendingPrefix)
|
---|
144 | {
|
---|
145 | RTTestPrintfNl(g_hTest, RTTESTLVL_ALWAYS, "OUTPUT: ");
|
---|
146 | g_fPendingPrefix = false;
|
---|
147 | }
|
---|
148 | if (*pch == '\n')
|
---|
149 | g_fPendingPrefix = true;
|
---|
150 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "%c", *pch);
|
---|
151 |
|
---|
152 | /* buffer output */
|
---|
153 | if (g_offOutput < sizeof(g_szOutput) - 1)
|
---|
154 | {
|
---|
155 | g_szOutput[g_offOutput++] = *pch;
|
---|
156 | g_szOutput[g_offOutput] = '\0';
|
---|
157 | }
|
---|
158 |
|
---|
159 | /* advance */
|
---|
160 | pch++;
|
---|
161 | }
|
---|
162 | return VINF_SUCCESS;
|
---|
163 | }
|
---|
164 |
|
---|
165 |
|
---|
166 | /**
|
---|
167 | * Ready / busy notification.
|
---|
168 | *
|
---|
169 | * @param pBack Pointer to the backend structure supplied by
|
---|
170 | * the backend. The backend can use this to find
|
---|
171 | * it's instance data.
|
---|
172 | * @param fReady Whether it's ready (true) or busy (false).
|
---|
173 | */
|
---|
174 | static DECLCALLBACK(void) tstDBGCBackSetReady(PCDBGCIO pBack, bool fReady)
|
---|
175 | {
|
---|
176 | }
|
---|
177 |
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Completes the output, making sure that we're in
|
---|
181 | * the 1 position of a new line.
|
---|
182 | */
|
---|
183 | static void tstCompleteOutput(void)
|
---|
184 | {
|
---|
185 | if (!g_fPendingPrefix)
|
---|
186 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "\n");
|
---|
187 | g_fPendingPrefix = true;
|
---|
188 | }
|
---|
189 |
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Checks if two DBGC variables are identical
|
---|
193 | *
|
---|
194 | * @returns
|
---|
195 | * @param pVar1 .
|
---|
196 | * @param pVar2 .
|
---|
197 | */
|
---|
198 | bool DBGCVarAreIdentical(PCDBGCVAR pVar1, PCDBGCVAR pVar2)
|
---|
199 | {
|
---|
200 | if (!pVar1)
|
---|
201 | return false;
|
---|
202 | if (pVar1 == pVar2)
|
---|
203 | return true;
|
---|
204 |
|
---|
205 | if (pVar1->enmType != pVar2->enmType)
|
---|
206 | return false;
|
---|
207 | switch (pVar1->enmType)
|
---|
208 | {
|
---|
209 | case DBGCVAR_TYPE_GC_FLAT:
|
---|
210 | if (pVar1->u.GCFlat != pVar2->u.GCFlat)
|
---|
211 | return false;
|
---|
212 | break;
|
---|
213 | case DBGCVAR_TYPE_GC_FAR:
|
---|
214 | if (pVar1->u.GCFar.off != pVar2->u.GCFar.off)
|
---|
215 | return false;
|
---|
216 | if (pVar1->u.GCFar.sel != pVar2->u.GCFar.sel)
|
---|
217 | return false;
|
---|
218 | break;
|
---|
219 | case DBGCVAR_TYPE_GC_PHYS:
|
---|
220 | if (pVar1->u.GCPhys != pVar2->u.GCPhys)
|
---|
221 | return false;
|
---|
222 | break;
|
---|
223 | case DBGCVAR_TYPE_HC_FLAT:
|
---|
224 | if (pVar1->u.pvHCFlat != pVar2->u.pvHCFlat)
|
---|
225 | return false;
|
---|
226 | break;
|
---|
227 | case DBGCVAR_TYPE_HC_PHYS:
|
---|
228 | if (pVar1->u.HCPhys != pVar2->u.HCPhys)
|
---|
229 | return false;
|
---|
230 | break;
|
---|
231 | case DBGCVAR_TYPE_NUMBER:
|
---|
232 | if (pVar1->u.u64Number != pVar2->u.u64Number)
|
---|
233 | return false;
|
---|
234 | break;
|
---|
235 | case DBGCVAR_TYPE_STRING:
|
---|
236 | case DBGCVAR_TYPE_SYMBOL:
|
---|
237 | if (RTStrCmp(pVar1->u.pszString, pVar2->u.pszString) != 0)
|
---|
238 | return false;
|
---|
239 | break;
|
---|
240 | default:
|
---|
241 | AssertFailedReturn(false);
|
---|
242 | }
|
---|
243 |
|
---|
244 | if (pVar1->enmRangeType != pVar2->enmRangeType)
|
---|
245 | return false;
|
---|
246 | switch (pVar1->enmRangeType)
|
---|
247 | {
|
---|
248 | case DBGCVAR_RANGE_NONE:
|
---|
249 | break;
|
---|
250 |
|
---|
251 | case DBGCVAR_RANGE_ELEMENTS:
|
---|
252 | case DBGCVAR_RANGE_BYTES:
|
---|
253 | if (pVar1->u64Range != pVar2->u64Range)
|
---|
254 | return false;
|
---|
255 | break;
|
---|
256 | default:
|
---|
257 | AssertFailedReturn(false);
|
---|
258 | }
|
---|
259 |
|
---|
260 | return true;
|
---|
261 | }
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Tries one command string.
|
---|
265 | * @param pDbgc Pointer to the debugger instance.
|
---|
266 | * @param pszCmds The command to test.
|
---|
267 | * @param rcCmd The expected result.
|
---|
268 | * @param fNoExecute When set, the command is not executed.
|
---|
269 | * @param pszExpected Expected output. This does not need to include all
|
---|
270 | * of the output, just the start of it. Thus the
|
---|
271 | * prompt can be omitted.
|
---|
272 | * @param cArgs The number of expected arguments. -1 if we don't
|
---|
273 | * want to check the parsed arguments.
|
---|
274 | * @param va Info about expected parsed arguments. For each
|
---|
275 | * argument a DBGCVARTYPE, value (depends on type),
|
---|
276 | * DBGCVARRANGETYPE and optionally range value.
|
---|
277 | */
|
---|
278 | static void tstTryExV(PDBGC pDbgc, const char *pszCmds, int rcCmd, bool fNoExecute, const char *pszExpected,
|
---|
279 | int32_t cArgs, va_list va)
|
---|
280 | {
|
---|
281 | RT_ZERO(g_szOutput);
|
---|
282 | g_offOutput = 0;
|
---|
283 | g_pszInput = pszCmds;
|
---|
284 | if (strchr(pszCmds, '\0')[-1] == '\n')
|
---|
285 | RTTestPrintfNl(g_hTest, RTTESTLVL_ALWAYS, "RUNNING: %s", pszCmds);
|
---|
286 | else
|
---|
287 | RTTestPrintfNl(g_hTest, RTTESTLVL_ALWAYS, "RUNNING: %s\n", pszCmds);
|
---|
288 |
|
---|
289 | pDbgc->rcCmd = VERR_INTERNAL_ERROR;
|
---|
290 | dbgcProcessInput(pDbgc, fNoExecute);
|
---|
291 | tstCompleteOutput();
|
---|
292 |
|
---|
293 | if (pDbgc->rcCmd != rcCmd)
|
---|
294 | RTTestFailed(g_hTest, "rcCmd=%Rrc expected =%Rrc\n", pDbgc->rcCmd, rcCmd);
|
---|
295 | else if ( !fNoExecute
|
---|
296 | && pszExpected
|
---|
297 | && strncmp(pszExpected, g_szOutput, strlen(pszExpected)))
|
---|
298 | RTTestFailed(g_hTest, "Wrong output - expected \"%s\"", pszExpected);
|
---|
299 |
|
---|
300 | if (cArgs >= 0)
|
---|
301 | {
|
---|
302 | PCDBGCVAR paArgs = pDbgc->aArgs;
|
---|
303 | for (int32_t iArg = 0; iArg < cArgs; iArg++)
|
---|
304 | {
|
---|
305 | DBGCVAR ExpectedArg;
|
---|
306 | ExpectedArg.enmType = (DBGCVARTYPE)va_arg(va, int/*DBGCVARTYPE*/);
|
---|
307 | switch (ExpectedArg.enmType)
|
---|
308 | {
|
---|
309 | case DBGCVAR_TYPE_GC_FLAT: ExpectedArg.u.GCFlat = va_arg(va, RTGCPTR); break;
|
---|
310 | case DBGCVAR_TYPE_GC_FAR: ExpectedArg.u.GCFar.sel = va_arg(va, int /*RTSEL*/);
|
---|
311 | ExpectedArg.u.GCFar.off = va_arg(va, uint32_t); break;
|
---|
312 | case DBGCVAR_TYPE_GC_PHYS: ExpectedArg.u.GCPhys = va_arg(va, RTGCPHYS); break;
|
---|
313 | case DBGCVAR_TYPE_HC_FLAT: ExpectedArg.u.pvHCFlat = va_arg(va, void *); break;
|
---|
314 | case DBGCVAR_TYPE_HC_PHYS: ExpectedArg.u.HCPhys = va_arg(va, RTHCPHYS); break;
|
---|
315 | case DBGCVAR_TYPE_NUMBER: ExpectedArg.u.u64Number = va_arg(va, uint64_t); break;
|
---|
316 | case DBGCVAR_TYPE_STRING: ExpectedArg.u.pszString = va_arg(va, const char *); break;
|
---|
317 | case DBGCVAR_TYPE_SYMBOL: ExpectedArg.u.pszString = va_arg(va, const char *); break;
|
---|
318 | default:
|
---|
319 | RTTestFailed(g_hTest, "enmType=%u iArg=%u\n", ExpectedArg.enmType, iArg);
|
---|
320 | ExpectedArg.u.u64Number = 0;
|
---|
321 | break;
|
---|
322 | }
|
---|
323 | ExpectedArg.enmRangeType = (DBGCVARRANGETYPE)va_arg(va, int /*DBGCVARRANGETYPE*/);
|
---|
324 | switch (ExpectedArg.enmRangeType)
|
---|
325 | {
|
---|
326 | case DBGCVAR_RANGE_NONE: ExpectedArg.u64Range = 0; break;
|
---|
327 | case DBGCVAR_RANGE_ELEMENTS: ExpectedArg.u64Range = va_arg(va, uint64_t); break;
|
---|
328 | case DBGCVAR_RANGE_BYTES: ExpectedArg.u64Range = va_arg(va, uint64_t); break;
|
---|
329 | default:
|
---|
330 | RTTestFailed(g_hTest, "enmRangeType=%u iArg=%u\n", ExpectedArg.enmRangeType, iArg);
|
---|
331 | ExpectedArg.u64Range = 0;
|
---|
332 | break;
|
---|
333 | }
|
---|
334 |
|
---|
335 | if (!DBGCVarAreIdentical(&ExpectedArg, &paArgs[iArg]))
|
---|
336 | RTTestFailed(g_hTest,
|
---|
337 | "Arg #%u\n"
|
---|
338 | "actual: enmType=%u u64=%#RX64 enmRangeType=%u u64Range=%#RX64\n"
|
---|
339 | "expected: enmType=%u u64=%#RX64 enmRangeType=%u u64Range=%#RX64\n",
|
---|
340 | iArg,
|
---|
341 | paArgs[iArg].enmType, paArgs[iArg].u.u64Number, paArgs[iArg].enmRangeType, paArgs[iArg].u64Range,
|
---|
342 | ExpectedArg.enmType, ExpectedArg.u.u64Number, ExpectedArg.enmRangeType, ExpectedArg.u64Range);
|
---|
343 | }
|
---|
344 | }
|
---|
345 | }
|
---|
346 |
|
---|
347 | /**
|
---|
348 | * Tries one command string.
|
---|
349 | *
|
---|
350 | * @param pDbgc Pointer to the debugger instance.
|
---|
351 | * @param pszCmds The command to test.
|
---|
352 | * @param rcCmd The expected result.
|
---|
353 | * @param fNoExecute When set, the command is not executed.
|
---|
354 | * @param pszExpected Expected output. This does not need to include all
|
---|
355 | * of the output, just the start of it. Thus the
|
---|
356 | * prompt can be omitted.
|
---|
357 | * @param cArgs The number of expected arguments. -1 if we don't
|
---|
358 | * want to check the parsed arguments.
|
---|
359 | * @param ... Info about expected parsed arguments. For each
|
---|
360 | * argument a DBGCVARTYPE, value (depends on type),
|
---|
361 | * DBGCVARRANGETYPE and optionally range value.
|
---|
362 | */
|
---|
363 | static void tstTryEx(PDBGC pDbgc, const char *pszCmds, int rcCmd, bool fNoExecute, const char *pszExpected, int32_t cArgs, ...)
|
---|
364 | {
|
---|
365 | va_list va;
|
---|
366 | va_start(va, cArgs);
|
---|
367 | tstTryExV(pDbgc, pszCmds, rcCmd, fNoExecute, pszExpected, cArgs, va);
|
---|
368 | va_end(va);
|
---|
369 | }
|
---|
370 |
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Tries one command string without executing it.
|
---|
374 | *
|
---|
375 | * @param pDbgc Pointer to the debugger instance.
|
---|
376 | * @param pszCmds The command to test.
|
---|
377 | * @param rcCmd The expected result.
|
---|
378 | */
|
---|
379 | static void tstTry(PDBGC pDbgc, const char *pszCmds, int rcCmd)
|
---|
380 | {
|
---|
381 | return tstTryEx(pDbgc, pszCmds, rcCmd, true /*fNoExecute*/, NULL, -1);
|
---|
382 | }
|
---|
383 |
|
---|
384 |
|
---|
385 | #ifdef SOME_UNUSED_FUNCTION
|
---|
386 | /**
|
---|
387 | * Tries to execute one command string.
|
---|
388 | * @param pDbgc Pointer to the debugger instance.
|
---|
389 | * @param pszCmds The command to test.
|
---|
390 | * @param rcCmd The expected result.
|
---|
391 | * @param pszExpected Expected output. This does not need to include all
|
---|
392 | * of the output, just the start of it. Thus the
|
---|
393 | * prompt can be omitted.
|
---|
394 | */
|
---|
395 | static void tstTryExec(PDBGC pDbgc, const char *pszCmds, int rcCmd, const char *pszExpected)
|
---|
396 | {
|
---|
397 | return tstTryEx(pDbgc, pszCmds, rcCmd, false /*fNoExecute*/, pszExpected, -1);
|
---|
398 | }
|
---|
399 | #endif
|
---|
400 |
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Test an operator on an expression resulting a plain number.
|
---|
404 | *
|
---|
405 | * @param pDbgc Pointer to the debugger instance.
|
---|
406 | * @param pszExpr The express to test.
|
---|
407 | * @param u64Expect The expected result.
|
---|
408 | */
|
---|
409 | static void tstNumOp(PDBGC pDbgc, const char *pszExpr, uint64_t u64Expect)
|
---|
410 | {
|
---|
411 | char szCmd[80];
|
---|
412 | RTStrPrintf(szCmd, sizeof(szCmd), "format %s\n", pszExpr);
|
---|
413 |
|
---|
414 | char szExpected[80];
|
---|
415 | RTStrPrintf(szExpected, sizeof(szExpected),
|
---|
416 | "Number: hex %llx dec 0i%lld oct 0t%llo", u64Expect, u64Expect, u64Expect);
|
---|
417 |
|
---|
418 | return tstTryEx(pDbgc, szCmd, VINF_SUCCESS, false /*fNoExecute*/, szExpected, -1);
|
---|
419 | }
|
---|
420 |
|
---|
421 |
|
---|
422 | /*
|
---|
423 | *
|
---|
424 | * CodeView emulation commands.
|
---|
425 | * CodeView emulation commands.
|
---|
426 | * CodeView emulation commands.
|
---|
427 | *
|
---|
428 | */
|
---|
429 |
|
---|
430 |
|
---|
431 | static void testCodeView_ba(PDBGC pDbgc)
|
---|
432 | {
|
---|
433 | RTTestISub("codeview - ba");
|
---|
434 | tstTry(pDbgc, "ba x 1 0f000:0000\n", VINF_SUCCESS);
|
---|
435 | tstTry(pDbgc, "ba x 1 0f000:0000 0\n", VINF_SUCCESS);
|
---|
436 | tstTry(pDbgc, "ba x 1 0f000:0000 0 ~0\n", VINF_SUCCESS);
|
---|
437 | tstTry(pDbgc, "ba x 1 0f000:0000 0 ~0 \"command\"\n", VINF_SUCCESS);
|
---|
438 | tstTry(pDbgc, "ba x 1 0f000:0000 0 ~0 \"command\" too_many\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
439 | tstTry(pDbgc, "ba x 1\n", VERR_DBGC_PARSE_TOO_FEW_ARGUMENTS);
|
---|
440 |
|
---|
441 | tstTryEx(pDbgc, "ba x 1 0f000:1234 5 1000 \"command\"\n", VINF_SUCCESS,
|
---|
442 | true /*fNoExecute*/, NULL /*pszExpected*/, 6 /*cArgs*/,
|
---|
443 | DBGCVAR_TYPE_STRING, "x", DBGCVAR_RANGE_BYTES, UINT64_C(1),
|
---|
444 | DBGCVAR_TYPE_NUMBER, UINT64_C(1), DBGCVAR_RANGE_NONE,
|
---|
445 | DBGCVAR_TYPE_GC_FAR, 0xf000, UINT32_C(0x1234), DBGCVAR_RANGE_NONE,
|
---|
446 | DBGCVAR_TYPE_NUMBER, UINT64_C(0x5), DBGCVAR_RANGE_NONE,
|
---|
447 | DBGCVAR_TYPE_NUMBER, UINT64_C(0x1000), DBGCVAR_RANGE_NONE,
|
---|
448 | DBGCVAR_TYPE_STRING, "command", DBGCVAR_RANGE_BYTES, UINT64_C(7));
|
---|
449 |
|
---|
450 | tstTryEx(pDbgc, "ba x 1 %0f000:1234 5 1000 \"command\"\n", VINF_SUCCESS,
|
---|
451 | true /*fNoExecute*/, NULL /*pszExpected*/, 6 /*cArgs*/,
|
---|
452 | DBGCVAR_TYPE_STRING, "x", DBGCVAR_RANGE_BYTES, UINT64_C(1),
|
---|
453 | DBGCVAR_TYPE_NUMBER, UINT64_C(1), DBGCVAR_RANGE_NONE,
|
---|
454 | DBGCVAR_TYPE_GC_FLAT, UINT64_C(0xf1234), DBGCVAR_RANGE_NONE,
|
---|
455 | DBGCVAR_TYPE_NUMBER, UINT64_C(0x5), DBGCVAR_RANGE_NONE,
|
---|
456 | DBGCVAR_TYPE_NUMBER, UINT64_C(0x1000), DBGCVAR_RANGE_NONE,
|
---|
457 | DBGCVAR_TYPE_STRING, "command", DBGCVAR_RANGE_BYTES, UINT64_C(7));
|
---|
458 |
|
---|
459 | tstTry(pDbgc, "ba x 1 bad:bad 5 1000 \"command\"\n", VINF_SUCCESS);
|
---|
460 | tstTry(pDbgc, "ba x 1 %bad:bad 5 1000 \"command\"\n", VERR_DBGC_PARSE_CONVERSION_FAILED);
|
---|
461 |
|
---|
462 | tstTryEx(pDbgc, "ba f 1 0f000:1234 5 1000 \"command\"\n", VINF_SUCCESS,
|
---|
463 | true /*fNoExecute*/, NULL /*pszExpected*/, 6 /*cArgs*/,
|
---|
464 | DBGCVAR_TYPE_STRING, "f", DBGCVAR_RANGE_BYTES, UINT64_C(1),
|
---|
465 | DBGCVAR_TYPE_NUMBER, UINT64_C(1), DBGCVAR_RANGE_NONE,
|
---|
466 | DBGCVAR_TYPE_GC_FAR, 0xf000, UINT32_C(0x1234), DBGCVAR_RANGE_NONE,
|
---|
467 | DBGCVAR_TYPE_NUMBER, UINT64_C(0x5), DBGCVAR_RANGE_NONE,
|
---|
468 | DBGCVAR_TYPE_NUMBER, UINT64_C(0x1000), DBGCVAR_RANGE_NONE,
|
---|
469 | DBGCVAR_TYPE_STRING, "command", DBGCVAR_RANGE_BYTES, UINT64_C(7));
|
---|
470 |
|
---|
471 | tstTry(pDbgc, "ba x 1 0f000:1234 qnx 1000 \"command\"\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
472 | tstTry(pDbgc, "ba x 1 0f000:1234 5 qnx \"command\"\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
473 | tstTry(pDbgc, "ba x qnx 0f000:1234 5 1000 \"command\"\n", VERR_DBGC_PARSE_INVALID_NUMBER);
|
---|
474 | tstTry(pDbgc, "ba x 1 qnx 5 1000 \"command\"\n", VERR_DBGC_PARSE_INVALID_NUMBER);
|
---|
475 | }
|
---|
476 |
|
---|
477 |
|
---|
478 | static void testCodeView_bc(PDBGC pDbgc)
|
---|
479 | {
|
---|
480 | RTTestISub("codeview - bc");
|
---|
481 | }
|
---|
482 |
|
---|
483 |
|
---|
484 | static void testCodeView_bd(PDBGC pDbgc)
|
---|
485 | {
|
---|
486 | RTTestISub("codeview - bc");
|
---|
487 | }
|
---|
488 |
|
---|
489 |
|
---|
490 | static void testCodeView_be(PDBGC pDbgc)
|
---|
491 | {
|
---|
492 | RTTestISub("codeview - be");
|
---|
493 | }
|
---|
494 |
|
---|
495 |
|
---|
496 | static void testCodeView_bl(PDBGC pDbgc)
|
---|
497 | {
|
---|
498 | RTTestISub("codeview - bl");
|
---|
499 | }
|
---|
500 |
|
---|
501 |
|
---|
502 | static void testCodeView_bp(PDBGC pDbgc)
|
---|
503 | {
|
---|
504 | RTTestISub("codeview - bp");
|
---|
505 | }
|
---|
506 |
|
---|
507 |
|
---|
508 | static void testCodeView_br(PDBGC pDbgc)
|
---|
509 | {
|
---|
510 | RTTestISub("codeview - br");
|
---|
511 | }
|
---|
512 |
|
---|
513 |
|
---|
514 | static void testCodeView_d(PDBGC pDbgc)
|
---|
515 | {
|
---|
516 | RTTestISub("codeview - d");
|
---|
517 | }
|
---|
518 |
|
---|
519 |
|
---|
520 | static void testCodeView_da(PDBGC pDbgc)
|
---|
521 | {
|
---|
522 | RTTestISub("codeview - da");
|
---|
523 | }
|
---|
524 |
|
---|
525 |
|
---|
526 | static void testCodeView_db(PDBGC pDbgc)
|
---|
527 | {
|
---|
528 | RTTestISub("codeview - db");
|
---|
529 | }
|
---|
530 |
|
---|
531 |
|
---|
532 | static void testCodeView_dd(PDBGC pDbgc)
|
---|
533 | {
|
---|
534 | RTTestISub("codeview - dd");
|
---|
535 | }
|
---|
536 |
|
---|
537 |
|
---|
538 | static void testCodeView_dg(PDBGC pDbgc)
|
---|
539 | {
|
---|
540 | RTTestISub("codeview - dg");
|
---|
541 | }
|
---|
542 |
|
---|
543 |
|
---|
544 | static void testCodeView_dga(PDBGC pDbgc)
|
---|
545 | {
|
---|
546 | RTTestISub("codeview - dga");
|
---|
547 | }
|
---|
548 |
|
---|
549 |
|
---|
550 | static void testCodeView_di(PDBGC pDbgc)
|
---|
551 | {
|
---|
552 | RTTestISub("codeview - di");
|
---|
553 | }
|
---|
554 |
|
---|
555 |
|
---|
556 | static void testCodeView_dia(PDBGC pDbgc)
|
---|
557 | {
|
---|
558 | RTTestISub("codeview - dia");
|
---|
559 | }
|
---|
560 |
|
---|
561 |
|
---|
562 | static void testCodeView_dl(PDBGC pDbgc)
|
---|
563 | {
|
---|
564 | RTTestISub("codeview - dl");
|
---|
565 | }
|
---|
566 |
|
---|
567 |
|
---|
568 | static void testCodeView_dla(PDBGC pDbgc)
|
---|
569 | {
|
---|
570 | RTTestISub("codeview - dla");
|
---|
571 | }
|
---|
572 |
|
---|
573 |
|
---|
574 | static void testCodeView_dpd(PDBGC pDbgc)
|
---|
575 | {
|
---|
576 | RTTestISub("codeview - dpd");
|
---|
577 | }
|
---|
578 |
|
---|
579 |
|
---|
580 | static void testCodeView_dpda(PDBGC pDbgc)
|
---|
581 | {
|
---|
582 | RTTestISub("codeview - dpda");
|
---|
583 | }
|
---|
584 |
|
---|
585 |
|
---|
586 | static void testCodeView_dpdb(PDBGC pDbgc)
|
---|
587 | {
|
---|
588 | RTTestISub("codeview - dpdb");
|
---|
589 | }
|
---|
590 |
|
---|
591 |
|
---|
592 | static void testCodeView_dpdg(PDBGC pDbgc)
|
---|
593 | {
|
---|
594 | RTTestISub("codeview - dpdg");
|
---|
595 | }
|
---|
596 |
|
---|
597 |
|
---|
598 | static void testCodeView_dpdh(PDBGC pDbgc)
|
---|
599 | {
|
---|
600 | RTTestISub("codeview - dpdh");
|
---|
601 | }
|
---|
602 |
|
---|
603 |
|
---|
604 | static void testCodeView_dph(PDBGC pDbgc)
|
---|
605 | {
|
---|
606 | RTTestISub("codeview - dph");
|
---|
607 | }
|
---|
608 |
|
---|
609 |
|
---|
610 | static void testCodeView_dphg(PDBGC pDbgc)
|
---|
611 | {
|
---|
612 | RTTestISub("codeview - dphg");
|
---|
613 | }
|
---|
614 |
|
---|
615 |
|
---|
616 | static void testCodeView_dphh(PDBGC pDbgc)
|
---|
617 | {
|
---|
618 | RTTestISub("codeview - dphh");
|
---|
619 | }
|
---|
620 |
|
---|
621 |
|
---|
622 | static void testCodeView_dq(PDBGC pDbgc)
|
---|
623 | {
|
---|
624 | RTTestISub("codeview - dq");
|
---|
625 | }
|
---|
626 |
|
---|
627 |
|
---|
628 | static void testCodeView_dt(PDBGC pDbgc)
|
---|
629 | {
|
---|
630 | RTTestISub("codeview - dt");
|
---|
631 | }
|
---|
632 |
|
---|
633 |
|
---|
634 | static void testCodeView_dt16(PDBGC pDbgc)
|
---|
635 | {
|
---|
636 | RTTestISub("codeview - dt16");
|
---|
637 | }
|
---|
638 |
|
---|
639 |
|
---|
640 | static void testCodeView_dt32(PDBGC pDbgc)
|
---|
641 | {
|
---|
642 | RTTestISub("codeview - dt32");
|
---|
643 | }
|
---|
644 |
|
---|
645 |
|
---|
646 | static void testCodeView_dt64(PDBGC pDbgc)
|
---|
647 | {
|
---|
648 | RTTestISub("codeview - dt64");
|
---|
649 | }
|
---|
650 |
|
---|
651 |
|
---|
652 | static void testCodeView_dw(PDBGC pDbgc)
|
---|
653 | {
|
---|
654 | RTTestISub("codeview - dw");
|
---|
655 | }
|
---|
656 |
|
---|
657 |
|
---|
658 | static void testCodeView_eb(PDBGC pDbgc)
|
---|
659 | {
|
---|
660 | RTTestISub("codeview - eb");
|
---|
661 | }
|
---|
662 |
|
---|
663 |
|
---|
664 | static void testCodeView_ew(PDBGC pDbgc)
|
---|
665 | {
|
---|
666 | RTTestISub("codeview - ew");
|
---|
667 | }
|
---|
668 |
|
---|
669 |
|
---|
670 | static void testCodeView_ed(PDBGC pDbgc)
|
---|
671 | {
|
---|
672 | RTTestISub("codeview - ed");
|
---|
673 | }
|
---|
674 |
|
---|
675 |
|
---|
676 | static void testCodeView_eq(PDBGC pDbgc)
|
---|
677 | {
|
---|
678 | RTTestISub("codeview - eq");
|
---|
679 | }
|
---|
680 |
|
---|
681 |
|
---|
682 | static void testCodeView_g(PDBGC pDbgc)
|
---|
683 | {
|
---|
684 | RTTestISub("codeview - g");
|
---|
685 | }
|
---|
686 |
|
---|
687 |
|
---|
688 | static void testCodeView_k(PDBGC pDbgc)
|
---|
689 | {
|
---|
690 | RTTestISub("codeview - k");
|
---|
691 | }
|
---|
692 |
|
---|
693 |
|
---|
694 | static void testCodeView_kg(PDBGC pDbgc)
|
---|
695 | {
|
---|
696 | RTTestISub("codeview - kg");
|
---|
697 | }
|
---|
698 |
|
---|
699 |
|
---|
700 | static void testCodeView_kh(PDBGC pDbgc)
|
---|
701 | {
|
---|
702 | RTTestISub("codeview - kh");
|
---|
703 | }
|
---|
704 |
|
---|
705 |
|
---|
706 | static void testCodeView_lm(PDBGC pDbgc)
|
---|
707 | {
|
---|
708 | RTTestISub("codeview - lm");
|
---|
709 | }
|
---|
710 |
|
---|
711 |
|
---|
712 | static void testCodeView_lmo(PDBGC pDbgc)
|
---|
713 | {
|
---|
714 | RTTestISub("codeview - lmo");
|
---|
715 | }
|
---|
716 |
|
---|
717 |
|
---|
718 | static void testCodeView_ln(PDBGC pDbgc)
|
---|
719 | {
|
---|
720 | RTTestISub("codeview - ln");
|
---|
721 | }
|
---|
722 |
|
---|
723 |
|
---|
724 | static void testCodeView_ls(PDBGC pDbgc)
|
---|
725 | {
|
---|
726 | RTTestISub("codeview - ls");
|
---|
727 | }
|
---|
728 |
|
---|
729 |
|
---|
730 | static void testCodeView_m(PDBGC pDbgc)
|
---|
731 | {
|
---|
732 | RTTestISub("codeview - m");
|
---|
733 | }
|
---|
734 |
|
---|
735 |
|
---|
736 | static void testCodeView_r(PDBGC pDbgc)
|
---|
737 | {
|
---|
738 | RTTestISub("codeview - r");
|
---|
739 | }
|
---|
740 |
|
---|
741 |
|
---|
742 | static void testCodeView_rg(PDBGC pDbgc)
|
---|
743 | {
|
---|
744 | RTTestISub("codeview - rg");
|
---|
745 | }
|
---|
746 |
|
---|
747 |
|
---|
748 | static void testCodeView_rg32(PDBGC pDbgc)
|
---|
749 | {
|
---|
750 | RTTestISub("codeview - rg32");
|
---|
751 | }
|
---|
752 |
|
---|
753 |
|
---|
754 | static void testCodeView_rg64(PDBGC pDbgc)
|
---|
755 | {
|
---|
756 | RTTestISub("codeview - rg64");
|
---|
757 | }
|
---|
758 |
|
---|
759 |
|
---|
760 | static void testCodeView_rh(PDBGC pDbgc)
|
---|
761 | {
|
---|
762 | RTTestISub("codeview - rh");
|
---|
763 | }
|
---|
764 |
|
---|
765 |
|
---|
766 | static void testCodeView_rt(PDBGC pDbgc)
|
---|
767 | {
|
---|
768 | RTTestISub("codeview - rt");
|
---|
769 | }
|
---|
770 |
|
---|
771 |
|
---|
772 | static void testCodeView_s(PDBGC pDbgc)
|
---|
773 | {
|
---|
774 | RTTestISub("codeview - s");
|
---|
775 | }
|
---|
776 |
|
---|
777 |
|
---|
778 | static void testCodeView_sa(PDBGC pDbgc)
|
---|
779 | {
|
---|
780 | RTTestISub("codeview - sa");
|
---|
781 | }
|
---|
782 |
|
---|
783 |
|
---|
784 | static void testCodeView_sb(PDBGC pDbgc)
|
---|
785 | {
|
---|
786 | RTTestISub("codeview - sb");
|
---|
787 | }
|
---|
788 |
|
---|
789 |
|
---|
790 | static void testCodeView_sd(PDBGC pDbgc)
|
---|
791 | {
|
---|
792 | RTTestISub("codeview - sd");
|
---|
793 | }
|
---|
794 |
|
---|
795 |
|
---|
796 | static void testCodeView_sq(PDBGC pDbgc)
|
---|
797 | {
|
---|
798 | RTTestISub("codeview - sq");
|
---|
799 | }
|
---|
800 |
|
---|
801 |
|
---|
802 | static void testCodeView_su(PDBGC pDbgc)
|
---|
803 | {
|
---|
804 | RTTestISub("codeview - su");
|
---|
805 | }
|
---|
806 |
|
---|
807 |
|
---|
808 | static void testCodeView_sw(PDBGC pDbgc)
|
---|
809 | {
|
---|
810 | RTTestISub("codeview - sw");
|
---|
811 | }
|
---|
812 |
|
---|
813 |
|
---|
814 | static void testCodeView_t(PDBGC pDbgc)
|
---|
815 | {
|
---|
816 | RTTestISub("codeview - t");
|
---|
817 | }
|
---|
818 |
|
---|
819 |
|
---|
820 | static void testCodeView_y(PDBGC pDbgc)
|
---|
821 | {
|
---|
822 | RTTestISub("codeview - y");
|
---|
823 | }
|
---|
824 |
|
---|
825 |
|
---|
826 | static void testCodeView_u64(PDBGC pDbgc)
|
---|
827 | {
|
---|
828 | RTTestISub("codeview - u64");
|
---|
829 | }
|
---|
830 |
|
---|
831 |
|
---|
832 | static void testCodeView_u32(PDBGC pDbgc)
|
---|
833 | {
|
---|
834 | RTTestISub("codeview - u32");
|
---|
835 | }
|
---|
836 |
|
---|
837 |
|
---|
838 | static void testCodeView_u16(PDBGC pDbgc)
|
---|
839 | {
|
---|
840 | RTTestISub("codeview - u16");
|
---|
841 | }
|
---|
842 |
|
---|
843 |
|
---|
844 | static void testCodeView_uv86(PDBGC pDbgc)
|
---|
845 | {
|
---|
846 | RTTestISub("codeview - uv86");
|
---|
847 | }
|
---|
848 |
|
---|
849 |
|
---|
850 | /*
|
---|
851 | * Common commands.
|
---|
852 | */
|
---|
853 |
|
---|
854 | static void testCommon_bye_exit_quit(PDBGC pDbgc)
|
---|
855 | {
|
---|
856 | RTTestISub("common - bye/exit/quit");
|
---|
857 | /* These have the same parameter descriptor and handler, the command really
|
---|
858 | just has a couple of aliases.*/
|
---|
859 | tstTry(pDbgc, "bye\n", VINF_SUCCESS);
|
---|
860 | tstTry(pDbgc, "bye x\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
861 | tstTry(pDbgc, "bye 1\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
862 | tstTry(pDbgc, "bye %bad:bad\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
863 | tstTry(pDbgc, "exit\n", VINF_SUCCESS);
|
---|
864 | tstTry(pDbgc, "quit\n", VINF_SUCCESS);
|
---|
865 | }
|
---|
866 |
|
---|
867 |
|
---|
868 | static void testCommon_cpu(PDBGC pDbgc)
|
---|
869 | {
|
---|
870 | RTTestISub("common - cpu");
|
---|
871 | tstTry(pDbgc, "cpu\n", VINF_SUCCESS);
|
---|
872 | tstTry(pDbgc, "cpu 1\n", VINF_SUCCESS);
|
---|
873 | tstTry(pDbgc, "cpu 1 1\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
874 | tstTry(pDbgc, "cpu emt\n", VERR_DBGC_PARSE_INVALID_NUMBER);
|
---|
875 | tstTry(pDbgc, "cpu @eax\n", VINF_SUCCESS);
|
---|
876 | tstTry(pDbgc, "cpu %bad:bad\n", VERR_DBGC_PARSE_CONVERSION_FAILED);
|
---|
877 | tstTry(pDbgc, "cpu '1'\n", VERR_DBGC_PARSE_INVALID_NUMBER);
|
---|
878 | }
|
---|
879 |
|
---|
880 |
|
---|
881 | static void testCommon_echo(PDBGC pDbgc)
|
---|
882 | {
|
---|
883 | RTTestISub("common - echo");
|
---|
884 | tstTry(pDbgc, "echo\n", VERR_DBGC_PARSE_TOO_FEW_ARGUMENTS);
|
---|
885 | tstTry(pDbgc, "echo 1\n", VINF_SUCCESS);
|
---|
886 | tstTryEx(pDbgc, "echo 1 2 3 4 5 6\n", VINF_SUCCESS, false, "1 2 3 4 5 6", -1);
|
---|
887 |
|
---|
888 | /* The idea here is that since the prefered input is a string, we
|
---|
889 | definitely won't be confused by the number like beginning. */
|
---|
890 | tstTryEx(pDbgc, "echo 1234567890abcdefghijklmn\n", VINF_SUCCESS, false, "1234567890abcdefghijklmn", -1);
|
---|
891 |
|
---|
892 | /* The idea here is that we'll perform the + operation and then convert the
|
---|
893 | result to a string (hex). */
|
---|
894 | tstTryEx(pDbgc, "echo 1 + 1\n", VINF_SUCCESS, false, "2", -1);
|
---|
895 | tstTryEx(pDbgc, "echo \"1 + 1\"\n", VINF_SUCCESS, false, "1 + 1", -1);
|
---|
896 |
|
---|
897 | tstTryEx(pDbgc, "echo 0i10 + 6\n", VINF_SUCCESS, false, "10", -1);
|
---|
898 | tstTryEx(pDbgc, "echo \"0i10 + 6\"\n", VINF_SUCCESS, false, "0i10 + 6", -1);
|
---|
899 |
|
---|
900 | tstTryEx(pDbgc, "echo %f000:0010\n", VINF_SUCCESS, false, "%00000000000f0010", -1);
|
---|
901 | tstTryEx(pDbgc, "echo \"%f000:0010\"\n", VINF_SUCCESS, false, "%f000:0010", -1);
|
---|
902 |
|
---|
903 | tstTry(pDbgc, "echo %bad:bad\n", VERR_DBGC_PARSE_CONVERSION_FAILED);
|
---|
904 | }
|
---|
905 |
|
---|
906 |
|
---|
907 | static void testCommon_format(PDBGC pDbgc)
|
---|
908 | {
|
---|
909 | RTTestISub("common - format");
|
---|
910 | }
|
---|
911 |
|
---|
912 |
|
---|
913 | static void testCommon_detect(PDBGC pDbgc)
|
---|
914 | {
|
---|
915 | RTTestISub("common - detect");
|
---|
916 | }
|
---|
917 |
|
---|
918 |
|
---|
919 | static void testCommon_harakiri(PDBGC pDbgc)
|
---|
920 | {
|
---|
921 | RTTestISub("common - harakiri");
|
---|
922 | }
|
---|
923 |
|
---|
924 |
|
---|
925 | static void testCommon_help(PDBGC pDbgc)
|
---|
926 | {
|
---|
927 | RTTestISub("common - help");
|
---|
928 | }
|
---|
929 |
|
---|
930 |
|
---|
931 | static void testCommon_info(PDBGC pDbgc)
|
---|
932 | {
|
---|
933 | RTTestISub("common - info");
|
---|
934 | tstTry(pDbgc, "info 12fg\n", VINF_SUCCESS);
|
---|
935 | tstTry(pDbgc, "info fflags argument\n", VINF_SUCCESS);
|
---|
936 | }
|
---|
937 |
|
---|
938 |
|
---|
939 | static void testCommon_loadimage(PDBGC pDbgc)
|
---|
940 | {
|
---|
941 | RTTestISub("common - loadimage");
|
---|
942 | }
|
---|
943 |
|
---|
944 |
|
---|
945 | static void testCommon_loadmap(PDBGC pDbgc)
|
---|
946 | {
|
---|
947 | RTTestISub("common - loadmap");
|
---|
948 | }
|
---|
949 |
|
---|
950 |
|
---|
951 | static void testCommon_loadplugin(PDBGC pDbgc)
|
---|
952 | {
|
---|
953 | RTTestISub("common - loadplugin");
|
---|
954 | }
|
---|
955 |
|
---|
956 |
|
---|
957 | static void testCommon_loadseg(PDBGC pDbgc)
|
---|
958 | {
|
---|
959 | RTTestISub("common - loadseg");
|
---|
960 | }
|
---|
961 |
|
---|
962 |
|
---|
963 | static void testCommon_loadsyms(PDBGC pDbgc)
|
---|
964 | {
|
---|
965 | RTTestISub("common - loadsyms");
|
---|
966 | }
|
---|
967 |
|
---|
968 |
|
---|
969 | static void testCommon_loadvars(PDBGC pDbgc)
|
---|
970 | {
|
---|
971 | RTTestISub("common - loadvars");
|
---|
972 | }
|
---|
973 |
|
---|
974 |
|
---|
975 | static void testCommon_log(PDBGC pDbgc)
|
---|
976 | {
|
---|
977 | RTTestISub("common - log");
|
---|
978 | }
|
---|
979 |
|
---|
980 |
|
---|
981 | static void testCommon_logdest(PDBGC pDbgc)
|
---|
982 | {
|
---|
983 | RTTestISub("common - logdest");
|
---|
984 | }
|
---|
985 |
|
---|
986 |
|
---|
987 | static void testCommon_logflags(PDBGC pDbgc)
|
---|
988 | {
|
---|
989 | RTTestISub("common - logflags");
|
---|
990 | }
|
---|
991 |
|
---|
992 |
|
---|
993 | static void testCommon_runscript(PDBGC pDbgc)
|
---|
994 | {
|
---|
995 | RTTestISub("common - runscript");
|
---|
996 | }
|
---|
997 |
|
---|
998 |
|
---|
999 | static void testCommon_set(PDBGC pDbgc)
|
---|
1000 | {
|
---|
1001 | RTTestISub("common - set");
|
---|
1002 | }
|
---|
1003 |
|
---|
1004 |
|
---|
1005 | static void testCommon_showplugins(PDBGC pDbgc)
|
---|
1006 | {
|
---|
1007 | RTTestISub("common - showplugins");
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 |
|
---|
1011 | static void testCommon_showvars(PDBGC pDbgc)
|
---|
1012 | {
|
---|
1013 | RTTestISub("common - showvars");
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 |
|
---|
1017 | static void testCommon_stop(PDBGC pDbgc)
|
---|
1018 | {
|
---|
1019 | RTTestISub("common - stop");
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 |
|
---|
1023 | static void testCommon_unloadplugin(PDBGC pDbgc)
|
---|
1024 | {
|
---|
1025 | RTTestISub("common - unloadplugin");
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 |
|
---|
1029 | static void testCommon_unset(PDBGC pDbgc)
|
---|
1030 | {
|
---|
1031 | RTTestISub("common - unset");
|
---|
1032 | }
|
---|
1033 |
|
---|
1034 |
|
---|
1035 | static void testCommon_writecore(PDBGC pDbgc)
|
---|
1036 | {
|
---|
1037 | RTTestISub("common - writecore");
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 |
|
---|
1041 |
|
---|
1042 | /*
|
---|
1043 | * Basic tests.
|
---|
1044 | */
|
---|
1045 |
|
---|
1046 | static void testBasicsOddCases(PDBGC pDbgc)
|
---|
1047 | {
|
---|
1048 | RTTestISub("Odd cases");
|
---|
1049 | tstTry(pDbgc, "r @rax\n", VINF_SUCCESS);
|
---|
1050 | tstTry(pDbgc, "r @eax\n", VINF_SUCCESS);
|
---|
1051 | tstTry(pDbgc, "r @ah\n", VINF_SUCCESS);
|
---|
1052 | tstTry(pDbgc, "r @notavalidregister\n", VERR_DBGF_REGISTER_NOT_FOUND);
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 |
|
---|
1056 | static void testBasicsOperators(PDBGC pDbgc)
|
---|
1057 | {
|
---|
1058 | RTTestISub("Operators");
|
---|
1059 | tstNumOp(pDbgc, "1", 1);
|
---|
1060 | tstNumOp(pDbgc, "1", 1);
|
---|
1061 | tstNumOp(pDbgc, "1", 1);
|
---|
1062 |
|
---|
1063 | tstNumOp(pDbgc, "+1", 1);
|
---|
1064 | tstNumOp(pDbgc, "++++++1", 1);
|
---|
1065 |
|
---|
1066 | tstNumOp(pDbgc, "-1", UINT64_MAX);
|
---|
1067 | tstNumOp(pDbgc, "--1", 1);
|
---|
1068 | tstNumOp(pDbgc, "---1", UINT64_MAX);
|
---|
1069 | tstNumOp(pDbgc, "----1", 1);
|
---|
1070 |
|
---|
1071 | tstNumOp(pDbgc, "~0", UINT64_MAX);
|
---|
1072 | tstNumOp(pDbgc, "~1", UINT64_MAX-1);
|
---|
1073 | tstNumOp(pDbgc, "~~0", 0);
|
---|
1074 | tstNumOp(pDbgc, "~~1", 1);
|
---|
1075 |
|
---|
1076 | tstNumOp(pDbgc, "!1", 0);
|
---|
1077 | tstNumOp(pDbgc, "!0", 1);
|
---|
1078 | tstNumOp(pDbgc, "!42", 0);
|
---|
1079 | tstNumOp(pDbgc, "!!42", 1);
|
---|
1080 | tstNumOp(pDbgc, "!!!42", 0);
|
---|
1081 | tstNumOp(pDbgc, "!!!!42", 1);
|
---|
1082 |
|
---|
1083 | tstNumOp(pDbgc, "1 +1", 2);
|
---|
1084 | tstNumOp(pDbgc, "1 + 1", 2);
|
---|
1085 | tstNumOp(pDbgc, "1+1", 2);
|
---|
1086 | tstNumOp(pDbgc, "1+ 1", 2);
|
---|
1087 |
|
---|
1088 | tstNumOp(pDbgc, "1 - 1", 0);
|
---|
1089 | tstNumOp(pDbgc, "99 - 90", 9);
|
---|
1090 |
|
---|
1091 | tstNumOp(pDbgc, "2 * 2", 4);
|
---|
1092 |
|
---|
1093 | tstNumOp(pDbgc, "2 / 2", 1);
|
---|
1094 | tstNumOp(pDbgc, "2 / 0", UINT64_MAX);
|
---|
1095 | tstNumOp(pDbgc, "0i1024 / 0i4", 256);
|
---|
1096 |
|
---|
1097 | tstNumOp(pDbgc, "8 mod 7", 1);
|
---|
1098 |
|
---|
1099 | tstNumOp(pDbgc, "1<<1", 2);
|
---|
1100 | tstNumOp(pDbgc, "1<<0i32", UINT64_C(0x0000000100000000));
|
---|
1101 | tstNumOp(pDbgc, "1<<0i48", UINT64_C(0x0001000000000000));
|
---|
1102 | tstNumOp(pDbgc, "1<<0i63", UINT64_C(0x8000000000000000));
|
---|
1103 |
|
---|
1104 | tstNumOp(pDbgc, "fedcba0987654321>>0i04", UINT64_C(0x0fedcba098765432));
|
---|
1105 | tstNumOp(pDbgc, "fedcba0987654321>>0i32", UINT64_C(0xfedcba09));
|
---|
1106 | tstNumOp(pDbgc, "fedcba0987654321>>0i48", UINT64_C(0x0000fedc));
|
---|
1107 |
|
---|
1108 | tstNumOp(pDbgc, "0ef & 4", 4);
|
---|
1109 | tstNumOp(pDbgc, "01234567891 & fff", UINT64_C(0x00000000891));
|
---|
1110 | tstNumOp(pDbgc, "01234567891 & ~fff", UINT64_C(0x01234567000));
|
---|
1111 |
|
---|
1112 | tstNumOp(pDbgc, "1 | 1", 1);
|
---|
1113 | tstNumOp(pDbgc, "0 | 4", 4);
|
---|
1114 | tstNumOp(pDbgc, "4 | 0", 4);
|
---|
1115 | tstNumOp(pDbgc, "4 | 4", 4);
|
---|
1116 | tstNumOp(pDbgc, "1 | 4 | 2", 7);
|
---|
1117 |
|
---|
1118 | tstNumOp(pDbgc, "1 ^ 1", 0);
|
---|
1119 | tstNumOp(pDbgc, "1 ^ 0", 1);
|
---|
1120 | tstNumOp(pDbgc, "0 ^ 1", 1);
|
---|
1121 | tstNumOp(pDbgc, "3 ^ 1", 2);
|
---|
1122 | tstNumOp(pDbgc, "7 ^ 3", 4);
|
---|
1123 |
|
---|
1124 | tstNumOp(pDbgc, "7 || 3", 1);
|
---|
1125 | tstNumOp(pDbgc, "1 || 0", 1);
|
---|
1126 | tstNumOp(pDbgc, "0 || 1", 1);
|
---|
1127 | tstNumOp(pDbgc, "0 || 0", 0);
|
---|
1128 |
|
---|
1129 | tstNumOp(pDbgc, "0 && 0", 0);
|
---|
1130 | tstNumOp(pDbgc, "1 && 0", 0);
|
---|
1131 | tstNumOp(pDbgc, "0 && 1", 0);
|
---|
1132 | tstNumOp(pDbgc, "1 && 1", 1);
|
---|
1133 | tstNumOp(pDbgc, "4 && 1", 1);
|
---|
1134 | }
|
---|
1135 |
|
---|
1136 |
|
---|
1137 | static void testBasicsFundametalParsing(PDBGC pDbgc)
|
---|
1138 | {
|
---|
1139 | RTTestISub("Fundamental parsing");
|
---|
1140 | tstTry(pDbgc, "stop\n", VINF_SUCCESS);
|
---|
1141 | tstTry(pDbgc, "format 1\n", VINF_SUCCESS);
|
---|
1142 | tstTry(pDbgc, "format \n", VERR_DBGC_PARSE_TOO_FEW_ARGUMENTS);
|
---|
1143 | tstTry(pDbgc, "format 0 1 23 4\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
1144 | tstTry(pDbgc, "format 'x'\n", VINF_SUCCESS);
|
---|
1145 | tstTry(pDbgc, "format 'x' 'x'\n", VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS);
|
---|
1146 | tstTry(pDbgc, "format 'x''x'\n", VINF_SUCCESS);
|
---|
1147 | tstTry(pDbgc, "format 'x'\"x\"\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP);
|
---|
1148 | tstTry(pDbgc, "format 'x'1\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP);
|
---|
1149 | tstTry(pDbgc, "format (1)1\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP);
|
---|
1150 | tstTry(pDbgc, "format (1)(1)\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP);
|
---|
1151 | tstTry(pDbgc, "format (1)''\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP);
|
---|
1152 | tstTry(pDbgc, "format nosuchfunction(1)\n", VERR_DBGC_PARSE_FUNCTION_NOT_FOUND);
|
---|
1153 | tstTry(pDbgc, "format nosuchfunction(1,2,3)\n", VERR_DBGC_PARSE_FUNCTION_NOT_FOUND);
|
---|
1154 | tstTry(pDbgc, "format nosuchfunction()\n", VERR_DBGC_PARSE_FUNCTION_NOT_FOUND);
|
---|
1155 | tstTry(pDbgc, "format randu32()\n", VINF_SUCCESS);
|
---|
1156 | tstTryEx(pDbgc, "format %0\n", VINF_SUCCESS, false, "Guest flat address: %00000000", -1);
|
---|
1157 | tstTryEx(pDbgc, "format %eax\n", VINF_SUCCESS, false, "Guest flat address: %cafebabe", -1);
|
---|
1158 | tstTry(pDbgc, "sa 3 23 4 'q' \"21123123\" 'b' \n", VINF_SUCCESS);
|
---|
1159 | tstTry(pDbgc, "sa 3,23, 4,'q' ,\"21123123\" , 'b' \n", VINF_SUCCESS);
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 |
|
---|
1163 | int main()
|
---|
1164 | {
|
---|
1165 | /*
|
---|
1166 | * Init.
|
---|
1167 | */
|
---|
1168 | int rc = RTTestInitAndCreate("tstDBGCParser", &g_hTest);
|
---|
1169 | if (rc)
|
---|
1170 | return rc;
|
---|
1171 | RTTestBanner(g_hTest);
|
---|
1172 |
|
---|
1173 | /*
|
---|
1174 | * Create a DBGC instance.
|
---|
1175 | */
|
---|
1176 | RTTestSub(g_hTest, "dbgcCreate");
|
---|
1177 | PDBGC pDbgc;
|
---|
1178 | rc = dbgcCreate(&pDbgc, &g_tstBack, 0);
|
---|
1179 | if (RT_SUCCESS(rc))
|
---|
1180 | {
|
---|
1181 | pDbgc->pVM = (PVM)pDbgc;
|
---|
1182 | pDbgc->pUVM = (PUVM)pDbgc;
|
---|
1183 | rc = dbgcProcessInput(pDbgc, true /* fNoExecute */);
|
---|
1184 | tstCompleteOutput();
|
---|
1185 | if (RT_SUCCESS(rc))
|
---|
1186 | {
|
---|
1187 | /*
|
---|
1188 | * Perform basic tests first.
|
---|
1189 | */
|
---|
1190 | testBasicsFundametalParsing(pDbgc);
|
---|
1191 | if (RTTestErrorCount(g_hTest) == 0)
|
---|
1192 | testBasicsOperators(pDbgc);
|
---|
1193 | if (RTTestErrorCount(g_hTest) == 0)
|
---|
1194 | testBasicsOddCases(pDbgc);
|
---|
1195 |
|
---|
1196 | /*
|
---|
1197 | * Test commands.
|
---|
1198 | */
|
---|
1199 | if (RTTestErrorCount(g_hTest) == 0)
|
---|
1200 | {
|
---|
1201 | testCodeView_ba(pDbgc);
|
---|
1202 | testCodeView_bc(pDbgc);
|
---|
1203 | testCodeView_bd(pDbgc);
|
---|
1204 | testCodeView_be(pDbgc);
|
---|
1205 | testCodeView_bl(pDbgc);
|
---|
1206 | testCodeView_bp(pDbgc);
|
---|
1207 | testCodeView_br(pDbgc);
|
---|
1208 | testCodeView_d(pDbgc);
|
---|
1209 | testCodeView_da(pDbgc);
|
---|
1210 | testCodeView_db(pDbgc);
|
---|
1211 | testCodeView_dd(pDbgc);
|
---|
1212 | testCodeView_dg(pDbgc);
|
---|
1213 | testCodeView_dga(pDbgc);
|
---|
1214 | testCodeView_di(pDbgc);
|
---|
1215 | testCodeView_dia(pDbgc);
|
---|
1216 | testCodeView_dl(pDbgc);
|
---|
1217 | testCodeView_dla(pDbgc);
|
---|
1218 | testCodeView_dpd(pDbgc);
|
---|
1219 | testCodeView_dpda(pDbgc);
|
---|
1220 | testCodeView_dpdb(pDbgc);
|
---|
1221 | testCodeView_dpdg(pDbgc);
|
---|
1222 | testCodeView_dpdh(pDbgc);
|
---|
1223 | testCodeView_dph(pDbgc);
|
---|
1224 | testCodeView_dphg(pDbgc);
|
---|
1225 | testCodeView_dphh(pDbgc);
|
---|
1226 | testCodeView_dq(pDbgc);
|
---|
1227 | testCodeView_dt(pDbgc);
|
---|
1228 | testCodeView_dt16(pDbgc);
|
---|
1229 | testCodeView_dt32(pDbgc);
|
---|
1230 | testCodeView_dt64(pDbgc);
|
---|
1231 | testCodeView_dw(pDbgc);
|
---|
1232 | testCodeView_eb(pDbgc);
|
---|
1233 | testCodeView_ew(pDbgc);
|
---|
1234 | testCodeView_ed(pDbgc);
|
---|
1235 | testCodeView_eq(pDbgc);
|
---|
1236 | testCodeView_g(pDbgc);
|
---|
1237 | testCodeView_k(pDbgc);
|
---|
1238 | testCodeView_kg(pDbgc);
|
---|
1239 | testCodeView_kh(pDbgc);
|
---|
1240 | testCodeView_lm(pDbgc);
|
---|
1241 | testCodeView_lmo(pDbgc);
|
---|
1242 | testCodeView_ln(pDbgc);
|
---|
1243 | testCodeView_ls(pDbgc);
|
---|
1244 | testCodeView_m(pDbgc);
|
---|
1245 | testCodeView_r(pDbgc);
|
---|
1246 | testCodeView_rg(pDbgc);
|
---|
1247 | testCodeView_rg32(pDbgc);
|
---|
1248 | testCodeView_rg64(pDbgc);
|
---|
1249 | testCodeView_rh(pDbgc);
|
---|
1250 | testCodeView_rt(pDbgc);
|
---|
1251 | testCodeView_s(pDbgc);
|
---|
1252 | testCodeView_sa(pDbgc);
|
---|
1253 | testCodeView_sb(pDbgc);
|
---|
1254 | testCodeView_sd(pDbgc);
|
---|
1255 | testCodeView_sq(pDbgc);
|
---|
1256 | testCodeView_su(pDbgc);
|
---|
1257 | testCodeView_sw(pDbgc);
|
---|
1258 | testCodeView_t(pDbgc);
|
---|
1259 | testCodeView_y(pDbgc);
|
---|
1260 | testCodeView_u64(pDbgc);
|
---|
1261 | testCodeView_u32(pDbgc);
|
---|
1262 | testCodeView_u16(pDbgc);
|
---|
1263 | testCodeView_uv86(pDbgc);
|
---|
1264 |
|
---|
1265 | testCommon_bye_exit_quit(pDbgc);
|
---|
1266 | testCommon_cpu(pDbgc);
|
---|
1267 | testCommon_echo(pDbgc);
|
---|
1268 | testCommon_format(pDbgc);
|
---|
1269 | testCommon_detect(pDbgc);
|
---|
1270 | testCommon_harakiri(pDbgc);
|
---|
1271 | testCommon_help(pDbgc);
|
---|
1272 | testCommon_info(pDbgc);
|
---|
1273 | testCommon_loadimage(pDbgc);
|
---|
1274 | testCommon_loadmap(pDbgc);
|
---|
1275 | testCommon_loadplugin(pDbgc);
|
---|
1276 | testCommon_loadseg(pDbgc);
|
---|
1277 | testCommon_loadsyms(pDbgc);
|
---|
1278 | testCommon_loadvars(pDbgc);
|
---|
1279 | testCommon_log(pDbgc);
|
---|
1280 | testCommon_logdest(pDbgc);
|
---|
1281 | testCommon_logflags(pDbgc);
|
---|
1282 | testCommon_runscript(pDbgc);
|
---|
1283 | testCommon_set(pDbgc);
|
---|
1284 | testCommon_showplugins(pDbgc);
|
---|
1285 | testCommon_showvars(pDbgc);
|
---|
1286 | testCommon_stop(pDbgc);
|
---|
1287 | testCommon_unloadplugin(pDbgc);
|
---|
1288 | testCommon_unset(pDbgc);
|
---|
1289 | testCommon_writecore(pDbgc);
|
---|
1290 | }
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 | dbgcDestroy(pDbgc);
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | /*
|
---|
1297 | * Summary
|
---|
1298 | */
|
---|
1299 | return RTTestSummaryAndDestroy(g_hTest);
|
---|
1300 | }
|
---|