1 | /* $Id: DBGCEmulateCodeView.cpp 62480 2016-07-22 18:29:41Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DBGC - Debugger Console, CodeView / WinDbg Emulation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 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 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_DBGC
|
---|
23 | #include <VBox/dbg.h>
|
---|
24 | #include <VBox/vmm/dbgf.h>
|
---|
25 | #include <VBox/vmm/pgm.h>
|
---|
26 | #include <VBox/vmm/cpum.h>
|
---|
27 | #include <VBox/dis.h>
|
---|
28 | #include <VBox/param.h>
|
---|
29 | #include <VBox/err.h>
|
---|
30 | #include <VBox/log.h>
|
---|
31 |
|
---|
32 | #include <iprt/asm.h>
|
---|
33 | #include <iprt/mem.h>
|
---|
34 | #include <iprt/string.h>
|
---|
35 | #include <iprt/assert.h>
|
---|
36 | #include <iprt/ctype.h>
|
---|
37 |
|
---|
38 | #include <stdlib.h>
|
---|
39 | #include <stdio.h>
|
---|
40 |
|
---|
41 | #include "DBGCInternal.h"
|
---|
42 |
|
---|
43 |
|
---|
44 | /*********************************************************************************************************************************
|
---|
45 | * Internal Functions *
|
---|
46 | *********************************************************************************************************************************/
|
---|
47 | static FNDBGCCMD dbgcCmdBrkAccess;
|
---|
48 | static FNDBGCCMD dbgcCmdBrkClear;
|
---|
49 | static FNDBGCCMD dbgcCmdBrkDisable;
|
---|
50 | static FNDBGCCMD dbgcCmdBrkEnable;
|
---|
51 | static FNDBGCCMD dbgcCmdBrkList;
|
---|
52 | static FNDBGCCMD dbgcCmdBrkSet;
|
---|
53 | static FNDBGCCMD dbgcCmdBrkREM;
|
---|
54 | static FNDBGCCMD dbgcCmdDumpMem;
|
---|
55 | static FNDBGCCMD dbgcCmdDumpDT;
|
---|
56 | static FNDBGCCMD dbgcCmdDumpIDT;
|
---|
57 | static FNDBGCCMD dbgcCmdDumpPageDir;
|
---|
58 | static FNDBGCCMD dbgcCmdDumpPageDirBoth;
|
---|
59 | static FNDBGCCMD dbgcCmdDumpPageHierarchy;
|
---|
60 | static FNDBGCCMD dbgcCmdDumpPageTable;
|
---|
61 | static FNDBGCCMD dbgcCmdDumpPageTableBoth;
|
---|
62 | static FNDBGCCMD dbgcCmdDumpTSS;
|
---|
63 | static FNDBGCCMD dbgcCmdDumpTypeInfo;
|
---|
64 | static FNDBGCCMD dbgcCmdDumpTypedVal;
|
---|
65 | static FNDBGCCMD dbgcCmdEditMem;
|
---|
66 | static FNDBGCCMD dbgcCmdGo;
|
---|
67 | static FNDBGCCMD dbgcCmdListModules;
|
---|
68 | static FNDBGCCMD dbgcCmdListNear;
|
---|
69 | static FNDBGCCMD dbgcCmdListSource;
|
---|
70 | static FNDBGCCMD dbgcCmdMemoryInfo;
|
---|
71 | static FNDBGCCMD dbgcCmdReg;
|
---|
72 | static FNDBGCCMD dbgcCmdRegGuest;
|
---|
73 | static FNDBGCCMD dbgcCmdRegHyper;
|
---|
74 | static FNDBGCCMD dbgcCmdRegTerse;
|
---|
75 | static FNDBGCCMD dbgcCmdSearchMem;
|
---|
76 | static FNDBGCCMD dbgcCmdSearchMemType;
|
---|
77 | static FNDBGCCMD dbgcCmdEventCtrl;
|
---|
78 | static FNDBGCCMD dbgcCmdEventCtrlList;
|
---|
79 | static FNDBGCCMD dbgcCmdEventCtrlReset;
|
---|
80 | static FNDBGCCMD dbgcCmdStack;
|
---|
81 | static FNDBGCCMD dbgcCmdTrace;
|
---|
82 | static FNDBGCCMD dbgcCmdUnassemble;
|
---|
83 |
|
---|
84 |
|
---|
85 | /*********************************************************************************************************************************
|
---|
86 | * Global Variables *
|
---|
87 | *********************************************************************************************************************************/
|
---|
88 | /** 'ba' arguments. */
|
---|
89 | static const DBGCVARDESC g_aArgBrkAcc[] =
|
---|
90 | {
|
---|
91 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
92 | { 1, 1, DBGCVAR_CAT_STRING, 0, "access", "The access type: x=execute, rw=read/write (alias r), w=write, i=not implemented." },
|
---|
93 | { 1, 1, DBGCVAR_CAT_NUMBER, 0, "size", "The access size: 1, 2, 4, or 8. 'x' access requires 1, and 8 requires amd64 long mode." },
|
---|
94 | { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "The address." },
|
---|
95 | { 0, 1, DBGCVAR_CAT_NUMBER, 0, "passes", "The number of passes before we trigger the breakpoint. (0 is default)" },
|
---|
96 | { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "max passes", "The number of passes after which we stop triggering the breakpoint. (~0 is default)" },
|
---|
97 | { 0, 1, DBGCVAR_CAT_STRING, 0, "cmds", "String of commands to be executed when the breakpoint is hit. Quote it!" },
|
---|
98 | };
|
---|
99 |
|
---|
100 |
|
---|
101 | /** 'bc', 'bd', 'be' arguments. */
|
---|
102 | static const DBGCVARDESC g_aArgBrks[] =
|
---|
103 | {
|
---|
104 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
105 | { 0, ~0U, DBGCVAR_CAT_NUMBER, 0, "#bp", "Breakpoint number." },
|
---|
106 | { 0, 1, DBGCVAR_CAT_STRING, 0, "all", "All breakpoints." },
|
---|
107 | };
|
---|
108 |
|
---|
109 |
|
---|
110 | /** 'bp' arguments. */
|
---|
111 | static const DBGCVARDESC g_aArgBrkSet[] =
|
---|
112 | {
|
---|
113 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
114 | { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "The address." },
|
---|
115 | { 0, 1, DBGCVAR_CAT_NUMBER, 0, "passes", "The number of passes before we trigger the breakpoint. (0 is default)" },
|
---|
116 | { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "max passes", "The number of passes after which we stop triggering the breakpoint. (~0 is default)" },
|
---|
117 | { 0, 1, DBGCVAR_CAT_STRING, 0, "cmds", "String of commands to be executed when the breakpoint is hit. Quote it!" },
|
---|
118 | };
|
---|
119 |
|
---|
120 |
|
---|
121 | /** 'br' arguments. */
|
---|
122 | static const DBGCVARDESC g_aArgBrkREM[] =
|
---|
123 | {
|
---|
124 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
125 | { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "The address." },
|
---|
126 | { 0, 1, DBGCVAR_CAT_NUMBER, 0, "passes", "The number of passes before we trigger the breakpoint. (0 is default)" },
|
---|
127 | { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "max passes", "The number of passes after which we stop triggering the breakpoint. (~0 is default)" },
|
---|
128 | { 0, 1, DBGCVAR_CAT_STRING, 0, "cmds", "String of commands to be executed when the breakpoint is hit. Quote it!" },
|
---|
129 | };
|
---|
130 |
|
---|
131 |
|
---|
132 | /** 'd?' arguments. */
|
---|
133 | static const DBGCVARDESC g_aArgDumpMem[] =
|
---|
134 | {
|
---|
135 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
136 | { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to start dumping memory." },
|
---|
137 | };
|
---|
138 |
|
---|
139 |
|
---|
140 | /** 'dg', 'dga', 'dl', 'dla' arguments. */
|
---|
141 | static const DBGCVARDESC g_aArgDumpDT[] =
|
---|
142 | {
|
---|
143 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
144 | { 0, ~0U, DBGCVAR_CAT_NUMBER, 0, "sel", "Selector or selector range." },
|
---|
145 | { 0, ~0U, DBGCVAR_CAT_POINTER, 0, "address", "Far address which selector should be dumped." },
|
---|
146 | };
|
---|
147 |
|
---|
148 |
|
---|
149 | /** 'di', 'dia' arguments. */
|
---|
150 | static const DBGCVARDESC g_aArgDumpIDT[] =
|
---|
151 | {
|
---|
152 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
153 | { 0, ~0U, DBGCVAR_CAT_NUMBER, 0, "int", "The interrupt vector or interrupt vector range." },
|
---|
154 | };
|
---|
155 |
|
---|
156 |
|
---|
157 | /** 'dpd*' arguments. */
|
---|
158 | static const DBGCVARDESC g_aArgDumpPD[] =
|
---|
159 | {
|
---|
160 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
161 | { 0, 1, DBGCVAR_CAT_NUMBER, 0, "index", "Index into the page directory." },
|
---|
162 | { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address which page directory entry to start dumping from. Range is applied to the page directory." },
|
---|
163 | };
|
---|
164 |
|
---|
165 |
|
---|
166 | /** 'dpda' arguments. */
|
---|
167 | static const DBGCVARDESC g_aArgDumpPDAddr[] =
|
---|
168 | {
|
---|
169 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
170 | { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address of the page directory entry to start dumping from." },
|
---|
171 | };
|
---|
172 |
|
---|
173 |
|
---|
174 | /** 'dph*' arguments. */
|
---|
175 | static const DBGCVARDESC g_aArgDumpPH[] =
|
---|
176 | {
|
---|
177 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
178 | { 0, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "Where in the address space to start dumping and for how long (range). The default address/range will be used if omitted." },
|
---|
179 | { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "cr3", "The CR3 value to use. The current CR3 of the context will be used if omitted." },
|
---|
180 | { 0, 1, DBGCVAR_CAT_STRING, DBGCVD_FLAGS_DEP_PREV, "mode", "The paging mode: legacy, pse, pae, long, ept. Append '-np' for nested paging and '-nx' for no-execute. The current mode will be used if omitted." },
|
---|
181 | };
|
---|
182 |
|
---|
183 |
|
---|
184 | /** 'dpt?' arguments. */
|
---|
185 | static const DBGCVARDESC g_aArgDumpPT[] =
|
---|
186 | {
|
---|
187 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
188 | { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address which page directory entry to start dumping from." },
|
---|
189 | };
|
---|
190 |
|
---|
191 |
|
---|
192 | /** 'dpta' arguments. */
|
---|
193 | static const DBGCVARDESC g_aArgDumpPTAddr[] =
|
---|
194 | {
|
---|
195 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
196 | { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address of the page table entry to start dumping from." },
|
---|
197 | };
|
---|
198 |
|
---|
199 |
|
---|
200 | /** 'dt' arguments. */
|
---|
201 | static const DBGCVARDESC g_aArgDumpTSS[] =
|
---|
202 | {
|
---|
203 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
204 | { 0, 1, DBGCVAR_CAT_NUMBER, 0, "tss", "TSS selector number." },
|
---|
205 | { 0, 1, DBGCVAR_CAT_POINTER, 0, "tss:ign|addr", "TSS address. If the selector is a TSS selector, the offset will be ignored." }
|
---|
206 | };
|
---|
207 |
|
---|
208 |
|
---|
209 | /** 'dti' arguments. */
|
---|
210 | static const DBGCVARDESC g_aArgDumpTypeInfo[] =
|
---|
211 | {
|
---|
212 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
213 | { 1, 1, DBGCVAR_CAT_STRING, 0, "type", "The type to dump" },
|
---|
214 | { 0, 1, DBGCVAR_CAT_NUMBER, 0, "levels", "How many levels to dump the type information" }
|
---|
215 | };
|
---|
216 |
|
---|
217 |
|
---|
218 | /** 'dtv' arguments. */
|
---|
219 | static const DBGCVARDESC g_aArgDumpTypedVal[] =
|
---|
220 | {
|
---|
221 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
222 | { 1, 1, DBGCVAR_CAT_STRING, 0, "type", "The type to use" },
|
---|
223 | { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address to start dumping from." },
|
---|
224 | { 0, 1, DBGCVAR_CAT_NUMBER, 0, "levels", "How many levels to dump" }
|
---|
225 | };
|
---|
226 |
|
---|
227 |
|
---|
228 | /** 'e?' arguments. */
|
---|
229 | static const DBGCVARDESC g_aArgEditMem[] =
|
---|
230 | {
|
---|
231 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
232 | { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to write." },
|
---|
233 | { 1, ~0U, DBGCVAR_CAT_NUMBER, 0, "value", "Value to write." },
|
---|
234 | };
|
---|
235 |
|
---|
236 |
|
---|
237 | /** 'lm' arguments. */
|
---|
238 | static const DBGCVARDESC g_aArgListMods[] =
|
---|
239 | {
|
---|
240 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
241 | { 0, ~0U, DBGCVAR_CAT_STRING, 0, "module", "Module name." },
|
---|
242 | };
|
---|
243 |
|
---|
244 |
|
---|
245 | /** 'ln' arguments. */
|
---|
246 | static const DBGCVARDESC g_aArgListNear[] =
|
---|
247 | {
|
---|
248 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
249 | { 0, ~0U, DBGCVAR_CAT_POINTER, 0, "address", "Address of the symbol to look up." },
|
---|
250 | { 0, ~0U, DBGCVAR_CAT_SYMBOL, 0, "symbol", "Symbol to lookup." },
|
---|
251 | };
|
---|
252 |
|
---|
253 |
|
---|
254 | /** 'ls' arguments. */
|
---|
255 | static const DBGCVARDESC g_aArgListSource[] =
|
---|
256 | {
|
---|
257 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
258 | { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to start looking for source lines." },
|
---|
259 | };
|
---|
260 |
|
---|
261 |
|
---|
262 | /** 'm' argument. */
|
---|
263 | static const DBGCVARDESC g_aArgMemoryInfo[] =
|
---|
264 | {
|
---|
265 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
266 | { 1, 1, DBGCVAR_CAT_POINTER, 0, "address", "Pointer to obtain info about." },
|
---|
267 | };
|
---|
268 |
|
---|
269 |
|
---|
270 | /** 'r' arguments. */
|
---|
271 | static const DBGCVARDESC g_aArgReg[] =
|
---|
272 | {
|
---|
273 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
274 | { 0, 1, DBGCVAR_CAT_SYMBOL, 0, "register", "Register to show or set." },
|
---|
275 | { 0, 1, DBGCVAR_CAT_STRING, DBGCVD_FLAGS_DEP_PREV, "=", "Equal sign." },
|
---|
276 | { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "value", "New register value." },
|
---|
277 | };
|
---|
278 |
|
---|
279 |
|
---|
280 | /** 's' arguments. */
|
---|
281 | static const DBGCVARDESC g_aArgSearchMem[] =
|
---|
282 | {
|
---|
283 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
284 | { 0, 1, DBGCVAR_CAT_OPTION, 0, "-b", "Byte string." },
|
---|
285 | { 0, 1, DBGCVAR_CAT_OPTION, 0, "-w", "Word string." },
|
---|
286 | { 0, 1, DBGCVAR_CAT_OPTION, 0, "-d", "DWord string." },
|
---|
287 | { 0, 1, DBGCVAR_CAT_OPTION, 0, "-q", "QWord string." },
|
---|
288 | { 0, 1, DBGCVAR_CAT_OPTION, 0, "-a", "ASCII string." },
|
---|
289 | { 0, 1, DBGCVAR_CAT_OPTION, 0, "-u", "Unicode string." },
|
---|
290 | { 0, 1, DBGCVAR_CAT_OPTION_NUMBER, 0, "-n <Hits>", "Maximum number of hits." },
|
---|
291 | { 0, 1, DBGCVAR_CAT_GC_POINTER, 0, "range", "Register to show or set." },
|
---|
292 | { 0, ~0U, DBGCVAR_CAT_ANY, 0, "pattern", "Pattern to search for." },
|
---|
293 | };
|
---|
294 |
|
---|
295 |
|
---|
296 | /** 's?' arguments. */
|
---|
297 | static const DBGCVARDESC g_aArgSearchMemType[] =
|
---|
298 | {
|
---|
299 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
300 | { 1, 1, DBGCVAR_CAT_GC_POINTER, 0, "range", "Register to show or set." },
|
---|
301 | { 1, ~0U, DBGCVAR_CAT_ANY, 0, "pattern", "Pattern to search for." },
|
---|
302 | };
|
---|
303 |
|
---|
304 |
|
---|
305 | /** 'sxe', 'sxn', 'sxi', 'sx-' arguments. */
|
---|
306 | static const DBGCVARDESC g_aArgEventCtrl[] =
|
---|
307 | {
|
---|
308 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
309 | { 0, 1, DBGCVAR_CAT_STRING, 0, "-c", "The -c option, requires <cmds>." },
|
---|
310 | { 0, 1, DBGCVAR_CAT_STRING, DBGCVD_FLAGS_DEP_PREV, "cmds", "Command to execute on this event." },
|
---|
311 | { 0 /*weird*/, ~0U, DBGCVAR_CAT_STRING, 0, "event", "One or more events, 'all' refering to all events." },
|
---|
312 | };
|
---|
313 |
|
---|
314 | /** 'sx' and 'sr' arguments. */
|
---|
315 | static const DBGCVARDESC g_aArgEventCtrlOpt[] =
|
---|
316 | {
|
---|
317 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
318 | { 0, ~0U, DBGCVAR_CAT_STRING, 0, "event", "Zero or more events, 'all' refering to all events and being the default." },
|
---|
319 | };
|
---|
320 |
|
---|
321 | /** 'u' arguments. */
|
---|
322 | static const DBGCVARDESC g_aArgUnassemble[] =
|
---|
323 | {
|
---|
324 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
325 | { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address where to start disassembling." },
|
---|
326 | };
|
---|
327 |
|
---|
328 |
|
---|
329 | /** Command descriptors for the CodeView / WinDbg emulation.
|
---|
330 | * The emulation isn't attempting to be identical, only somewhat similar.
|
---|
331 | */
|
---|
332 | const DBGCCMD g_aCmdsCodeView[] =
|
---|
333 | {
|
---|
334 | /* pszCmd, cArgsMin, cArgsMax, paArgDescs, cArgDescs, fFlags, pfnHandler pszSyntax, ....pszDescription */
|
---|
335 | { "ba", 3, 6, &g_aArgBrkAcc[0], RT_ELEMENTS(g_aArgBrkAcc), 0, dbgcCmdBrkAccess, "<access> <size> <address> [passes [max passes]] [cmds]",
|
---|
336 | "Sets a data access breakpoint." },
|
---|
337 | { "bc", 1, ~0U, &g_aArgBrks[0], RT_ELEMENTS(g_aArgBrks), 0, dbgcCmdBrkClear, "all | <bp#> [bp# []]", "Deletes a set of breakpoints." },
|
---|
338 | { "bd", 1, ~0U, &g_aArgBrks[0], RT_ELEMENTS(g_aArgBrks), 0, dbgcCmdBrkDisable, "all | <bp#> [bp# []]", "Disables a set of breakpoints." },
|
---|
339 | { "be", 1, ~0U, &g_aArgBrks[0], RT_ELEMENTS(g_aArgBrks), 0, dbgcCmdBrkEnable, "all | <bp#> [bp# []]", "Enables a set of breakpoints." },
|
---|
340 | { "bl", 0, 0, NULL, 0, 0, dbgcCmdBrkList, "", "Lists all the breakpoints." },
|
---|
341 | { "bp", 1, 4, &g_aArgBrkSet[0], RT_ELEMENTS(g_aArgBrkSet), 0, dbgcCmdBrkSet, "<address> [passes [max passes]] [cmds]",
|
---|
342 | "Sets a breakpoint (int 3)." },
|
---|
343 | { "br", 1, 4, &g_aArgBrkREM[0], RT_ELEMENTS(g_aArgBrkREM), 0, dbgcCmdBrkREM, "<address> [passes [max passes]] [cmds]",
|
---|
344 | "Sets a recompiler specific breakpoint." },
|
---|
345 | { "d", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory using last element size." },
|
---|
346 | { "da", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as ascii string." },
|
---|
347 | { "db", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in bytes." },
|
---|
348 | { "dd", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in double words." },
|
---|
349 | { "da", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as ascii string." },
|
---|
350 | { "dg", 0, ~0U, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the global descriptor table (GDT)." },
|
---|
351 | { "dga", 0, ~0U, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the global descriptor table (GDT) including not-present entries." },
|
---|
352 | { "di", 0, ~0U, &g_aArgDumpIDT[0], RT_ELEMENTS(g_aArgDumpIDT), 0, dbgcCmdDumpIDT, "[int [..]]", "Dump the interrupt descriptor table (IDT)." },
|
---|
353 | { "dia", 0, ~0U, &g_aArgDumpIDT[0], RT_ELEMENTS(g_aArgDumpIDT), 0, dbgcCmdDumpIDT, "[int [..]]", "Dump the interrupt descriptor table (IDT) including not-present entries." },
|
---|
354 | { "dl", 0, ~0U, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the local descriptor table (LDT)." },
|
---|
355 | { "dla", 0, ~0U, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the local descriptor table (LDT) including not-present entries." },
|
---|
356 | { "dpd", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), 0, dbgcCmdDumpPageDir, "[addr|index]", "Dumps page directory entries of the default context." },
|
---|
357 | { "dpda", 0, 1, &g_aArgDumpPDAddr[0],RT_ELEMENTS(g_aArgDumpPDAddr), 0, dbgcCmdDumpPageDir, "[addr]", "Dumps memory at given address as a page directory." },
|
---|
358 | { "dpdb", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), 0, dbgcCmdDumpPageDirBoth, "[addr|index]", "Dumps page directory entries of the guest and the hypervisor. " },
|
---|
359 | { "dpdg", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), 0, dbgcCmdDumpPageDir, "[addr|index]", "Dumps page directory entries of the guest." },
|
---|
360 | { "dpdh", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), 0, dbgcCmdDumpPageDir, "[addr|index]", "Dumps page directory entries of the hypervisor. " },
|
---|
361 | { "dph", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Default context." },
|
---|
362 | { "dphg", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Guest context." },
|
---|
363 | { "dphh", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Hypervisor context." },
|
---|
364 | { "dpt", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the default context." },
|
---|
365 | { "dpta", 1, 1, &g_aArgDumpPTAddr[0],RT_ELEMENTS(g_aArgDumpPTAddr), 0, dbgcCmdDumpPageTable,"<addr>", "Dumps memory at given address as a page table." },
|
---|
366 | { "dptb", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), 0, dbgcCmdDumpPageTableBoth,"<addr>", "Dumps page table entries of the guest and the hypervisor." },
|
---|
367 | { "dptg", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the guest." },
|
---|
368 | { "dpth", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the hypervisor." },
|
---|
369 | { "dq", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in quad words." },
|
---|
370 | { "dt", 0, 1, &g_aArgDumpTSS[0], RT_ELEMENTS(g_aArgDumpTSS), 0, dbgcCmdDumpTSS, "[tss|tss:ign|addr]", "Dump the task state segment (TSS)." },
|
---|
371 | { "dt16", 0, 1, &g_aArgDumpTSS[0], RT_ELEMENTS(g_aArgDumpTSS), 0, dbgcCmdDumpTSS, "[tss|tss:ign|addr]", "Dump the 16-bit task state segment (TSS)." },
|
---|
372 | { "dt32", 0, 1, &g_aArgDumpTSS[0], RT_ELEMENTS(g_aArgDumpTSS), 0, dbgcCmdDumpTSS, "[tss|tss:ign|addr]", "Dump the 32-bit task state segment (TSS)." },
|
---|
373 | { "dt64", 0, 1, &g_aArgDumpTSS[0], RT_ELEMENTS(g_aArgDumpTSS), 0, dbgcCmdDumpTSS, "[tss|tss:ign|addr]", "Dump the 64-bit task state segment (TSS)." },
|
---|
374 | { "dti", 1, 2, &g_aArgDumpTypeInfo[0],RT_ELEMENTS(g_aArgDumpTypeInfo), 0, dbgcCmdDumpTypeInfo,"<type> [levels]", "Dump type information." },
|
---|
375 | { "dtv", 2, 3, &g_aArgDumpTypedVal[0],RT_ELEMENTS(g_aArgDumpTypedVal), 0, dbgcCmdDumpTypedVal,"<type> <addr> [levels]", "Dump a memory buffer using the information in the given type." },
|
---|
376 | { "dw", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in words." },
|
---|
377 | /** @todo add 'e', 'ea str', 'eza str', 'eu str' and 'ezu str'. See also
|
---|
378 | * dbgcCmdSearchMem and its dbgcVarsToBytes usage. */
|
---|
379 | { "eb", 2, 2, &g_aArgEditMem[0], RT_ELEMENTS(g_aArgEditMem), 0, dbgcCmdEditMem, "<addr> <value>", "Write a 1-byte value to memory." },
|
---|
380 | { "ew", 2, 2, &g_aArgEditMem[0], RT_ELEMENTS(g_aArgEditMem), 0, dbgcCmdEditMem, "<addr> <value>", "Write a 2-byte value to memory." },
|
---|
381 | { "ed", 2, 2, &g_aArgEditMem[0], RT_ELEMENTS(g_aArgEditMem), 0, dbgcCmdEditMem, "<addr> <value>", "Write a 4-byte value to memory." },
|
---|
382 | { "eq", 2, 2, &g_aArgEditMem[0], RT_ELEMENTS(g_aArgEditMem), 0, dbgcCmdEditMem, "<addr> <value>", "Write a 8-byte value to memory." },
|
---|
383 | { "g", 0, 0, NULL, 0, 0, dbgcCmdGo, "", "Continue execution." },
|
---|
384 | { "k", 0, 0, NULL, 0, 0, dbgcCmdStack, "", "Callstack." },
|
---|
385 | { "kg", 0, 0, NULL, 0, 0, dbgcCmdStack, "", "Callstack - guest." },
|
---|
386 | { "kh", 0, 0, NULL, 0, 0, dbgcCmdStack, "", "Callstack - hypervisor." },
|
---|
387 | { "lm", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules." },
|
---|
388 | { "lmv", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules, verbose." },
|
---|
389 | { "lmo", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules and their segments." },
|
---|
390 | { "lmov", 0, ~0U, &g_aArgListMods[0], RT_ELEMENTS(g_aArgListMods), 0, dbgcCmdListModules, "[module [..]]", "List modules and their segments, verbose." },
|
---|
391 | { "ln", 0, ~0U, &g_aArgListNear[0], RT_ELEMENTS(g_aArgListNear), 0, dbgcCmdListNear, "[addr/sym [..]]", "List symbols near to the address. Default address is CS:EIP." },
|
---|
392 | { "ls", 0, 1, &g_aArgListSource[0],RT_ELEMENTS(g_aArgListSource), 0, dbgcCmdListSource, "[addr]", "Source." },
|
---|
393 | { "m", 1, 1, &g_aArgMemoryInfo[0],RT_ELEMENTS(g_aArgMemoryInfo), 0, dbgcCmdMemoryInfo, "<addr>", "Display information about that piece of memory." },
|
---|
394 | { "r", 0, 3, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdReg, "[reg [[=] newval]]", "Show or set register(s) - active reg set." },
|
---|
395 | { "rg", 0, 3, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdRegGuest, "[reg [[=] newval]]", "Show or set register(s) - guest reg set." },
|
---|
396 | { "rg32", 0, 0, NULL, 0, 0, dbgcCmdRegGuest, "", "Show 32-bit guest registers." },
|
---|
397 | { "rg64", 0, 0, NULL, 0, 0, dbgcCmdRegGuest, "", "Show 64-bit guest registers." },
|
---|
398 | { "rh", 0, 3, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), 0, dbgcCmdRegHyper, "[reg [[=] newval]]", "Show or set register(s) - hypervisor reg set." },
|
---|
399 | { "rt", 0, 0, NULL, 0, 0, dbgcCmdRegTerse, "", "Toggles terse / verbose register info." },
|
---|
400 | { "s", 0, ~0U, &g_aArgSearchMem[0], RT_ELEMENTS(g_aArgSearchMem), 0, dbgcCmdSearchMem, "[options] <range> <pattern>", "Continue last search." },
|
---|
401 | { "sa", 2, ~0U, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType),0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for an ascii string." },
|
---|
402 | { "sb", 2, ~0U, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType),0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more bytes." },
|
---|
403 | { "sd", 2, ~0U, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType),0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more double words." },
|
---|
404 | { "sq", 2, ~0U, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType),0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more quad words." },
|
---|
405 | { "su", 2, ~0U, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType),0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for an unicode string." },
|
---|
406 | { "sw", 2, ~0U, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType),0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more words." },
|
---|
407 | { "sx", 0, ~0U, &g_aArgEventCtrlOpt[0], RT_ELEMENTS(g_aArgEventCtrlOpt), 0, dbgcCmdEventCtrlList, "[<event> [..]]", "Lists settings for exceptions, exits and other events. All if no filter is specified." },
|
---|
408 | { "sx-", 3, ~0U, &g_aArgEventCtrl[0], RT_ELEMENTS(g_aArgEventCtrl), 0, dbgcCmdEventCtrl, "-c <cmd> <event> [..]", "Modifies the command for one or more exceptions, exits or other event. 'all' addresses all." },
|
---|
409 | { "sxe", 1, ~0U, &g_aArgEventCtrl[0], RT_ELEMENTS(g_aArgEventCtrl), 0, dbgcCmdEventCtrl, "[-c <cmd>] <event> [..]", "Enable: Break into the debugger on the specified exceptions, exits and other events. 'all' addresses all." },
|
---|
410 | { "sxn", 1, ~0U, &g_aArgEventCtrl[0], RT_ELEMENTS(g_aArgEventCtrl), 0, dbgcCmdEventCtrl, "[-c <cmd>] <event> [..]", "Notify: Display info in the debugger and continue on the specified exceptions, exits and other events. 'all' addresses all." },
|
---|
411 | { "sxi", 1, ~0U, &g_aArgEventCtrl[0], RT_ELEMENTS(g_aArgEventCtrl), 0, dbgcCmdEventCtrl, "[-c <cmd>] <event> [..]", "Ignore: Ignore the specified exceptions, exits and other events ('all' = all of them). Without the -c option, the guest runs like normal." },
|
---|
412 | { "sxr", 0, 0, &g_aArgEventCtrlOpt[0], RT_ELEMENTS(g_aArgEventCtrlOpt), 0, dbgcCmdEventCtrlReset, "", "Reset the settings to default for exceptions, exits and other events. All if no filter is specified." },
|
---|
413 | { "t", 0, 0, NULL, 0, 0, dbgcCmdTrace, "", "Instruction trace (step into)." },
|
---|
414 | { "u", 0, 1, &g_aArgUnassemble[0],RT_ELEMENTS(g_aArgUnassemble), 0, dbgcCmdUnassemble, "[addr]", "Unassemble." },
|
---|
415 | { "u64", 0, 1, &g_aArgUnassemble[0],RT_ELEMENTS(g_aArgUnassemble), 0, dbgcCmdUnassemble, "[addr]", "Unassemble 64-bit code." },
|
---|
416 | { "u32", 0, 1, &g_aArgUnassemble[0],RT_ELEMENTS(g_aArgUnassemble), 0, dbgcCmdUnassemble, "[addr]", "Unassemble 32-bit code." },
|
---|
417 | { "u16", 0, 1, &g_aArgUnassemble[0],RT_ELEMENTS(g_aArgUnassemble), 0, dbgcCmdUnassemble, "[addr]", "Unassemble 16-bit code." },
|
---|
418 | { "uv86", 0, 1, &g_aArgUnassemble[0],RT_ELEMENTS(g_aArgUnassemble), 0, dbgcCmdUnassemble, "[addr]", "Unassemble 16-bit code with v8086/real mode addressing." },
|
---|
419 | };
|
---|
420 |
|
---|
421 | /** The number of commands in the CodeView/WinDbg emulation. */
|
---|
422 | const uint32_t g_cCmdsCodeView = RT_ELEMENTS(g_aCmdsCodeView);
|
---|
423 |
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * Selectable debug event descriptors.
|
---|
427 | *
|
---|
428 | * @remarks Sorted by DBGCSXEVT::enmType value.
|
---|
429 | */
|
---|
430 | const DBGCSXEVT g_aDbgcSxEvents[] =
|
---|
431 | {
|
---|
432 | { DBGFEVENT_INTERRUPT_HARDWARE, "hwint", NULL, kDbgcSxEventKind_Interrupt, kDbgcEvtState_Disabled, 0, "Hardware interrupt" },
|
---|
433 | { DBGFEVENT_INTERRUPT_SOFTWARE, "swint", NULL, kDbgcSxEventKind_Interrupt, kDbgcEvtState_Disabled, 0, "Software interrupt" },
|
---|
434 | { DBGFEVENT_TRIPLE_FAULT, "triplefault", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Enabled, 0, "Triple fault "},
|
---|
435 | { DBGFEVENT_XCPT_DE, "xcpt_de", "de", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#DE (integer divide error)" },
|
---|
436 | { DBGFEVENT_XCPT_DB, "xcpt_db", "db", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#DB (debug)" },
|
---|
437 | { DBGFEVENT_XCPT_02, "xcpt_02", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
438 | { DBGFEVENT_XCPT_BP, "xcpt_bp", "bp", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#BP (breakpoint)" },
|
---|
439 | { DBGFEVENT_XCPT_OF, "xcpt_of", "of", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#OF (overflow (INTO))" },
|
---|
440 | { DBGFEVENT_XCPT_BR, "xcpt_br", "br", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#BR (bound range exceeded)" },
|
---|
441 | { DBGFEVENT_XCPT_UD, "xcpt_ud", "ud", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#UD (undefined opcode)" },
|
---|
442 | { DBGFEVENT_XCPT_NM, "xcpt_nm", "nm", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#NM (FPU not available)" },
|
---|
443 | { DBGFEVENT_XCPT_DF, "xcpt_df", "df", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#DF (double fault)" },
|
---|
444 | { DBGFEVENT_XCPT_09, "xcpt_09", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "Coprocessor segment overrun" },
|
---|
445 | { DBGFEVENT_XCPT_TS, "xcpt_ts", "ts", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, "#TS (task switch)" },
|
---|
446 | { DBGFEVENT_XCPT_NP, "xcpt_np", "np", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, "#NP (segment not present)" },
|
---|
447 | { DBGFEVENT_XCPT_SS, "xcpt_ss", "ss", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, "#SS (stack segment fault)" },
|
---|
448 | { DBGFEVENT_XCPT_GP, "xcpt_gp", "gp", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, "#GP (general protection fault)" },
|
---|
449 | { DBGFEVENT_XCPT_PF, "xcpt_pf", "pf", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, "#PF (page fault)" },
|
---|
450 | { DBGFEVENT_XCPT_0f, "xcpt_0f", "xcpt0f", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
451 | { DBGFEVENT_XCPT_MF, "xcpt_mf", "mf", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#MF (math fault)" },
|
---|
452 | { DBGFEVENT_XCPT_AC, "xcpt_ac", "ac", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#AC (alignment check)" },
|
---|
453 | { DBGFEVENT_XCPT_MC, "xcpt_mc", "mc", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#MC (machine check)" },
|
---|
454 | { DBGFEVENT_XCPT_XF, "xcpt_xf", "xf", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#XF (SIMD floating-point exception)" },
|
---|
455 | { DBGFEVENT_XCPT_VE, "xcpt_vd", "ve", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, "#VE (virtualization exception)" },
|
---|
456 | { DBGFEVENT_XCPT_15, "xcpt_15", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
457 | { DBGFEVENT_XCPT_16, "xcpt_16", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
458 | { DBGFEVENT_XCPT_17, "xcpt_17", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
459 | { DBGFEVENT_XCPT_18, "xcpt_18", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
460 | { DBGFEVENT_XCPT_19, "xcpt_19", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
461 | { DBGFEVENT_XCPT_1a, "xcpt_1a", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
462 | { DBGFEVENT_XCPT_1b, "xcpt_1b", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
463 | { DBGFEVENT_XCPT_1c, "xcpt_1c", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
464 | { DBGFEVENT_XCPT_1d, "xcpt_1d", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
465 | { DBGFEVENT_XCPT_SX, "xcpt_sx", "sx", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, "#SX (security exception)" },
|
---|
466 | { DBGFEVENT_XCPT_1f, "xcpt_1f", "xcpt1f", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
467 | { DBGFEVENT_INSTR_HALT, "instr_halt", "hlt", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
468 | { DBGFEVENT_INSTR_MWAIT, "instr_mwait", "mwait", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
469 | { DBGFEVENT_INSTR_MONITOR, "instr_monitor", "monitor", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
470 | { DBGFEVENT_INSTR_CPUID, "instr_cpuid", "cpuid", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
471 | { DBGFEVENT_INSTR_INVD, "instr_invd", "invd", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
472 | { DBGFEVENT_INSTR_WBINVD, "instr_wbinvd", "wbinvd", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
473 | { DBGFEVENT_INSTR_INVLPG, "instr_invlpg", "invlpg", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
474 | { DBGFEVENT_INSTR_RDTSC, "instr_rdtsc", "rdtsc", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
475 | { DBGFEVENT_INSTR_RDTSCP, "instr_rdtscp", "rdtscp", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
476 | { DBGFEVENT_INSTR_RDPMC, "instr_rdpmc", "rdpmc", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
477 | { DBGFEVENT_INSTR_RDMSR, "instr_rdmsr", "rdmsr", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
478 | { DBGFEVENT_INSTR_WRMSR, "instr_wrmsr", "wrmsr", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
479 | { DBGFEVENT_INSTR_CRX_READ, "instr_crx_read", "crx_read", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, NULL },
|
---|
480 | { DBGFEVENT_INSTR_CRX_WRITE, "instr_crx_write", "crx_write",kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, NULL },
|
---|
481 | { DBGFEVENT_INSTR_DRX_READ, "instr_drx_read", "drx_read", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, NULL },
|
---|
482 | { DBGFEVENT_INSTR_DRX_WRITE, "instr_drx_write", "drx_write",kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, DBGCSXEVT_F_TAKE_ARG, NULL },
|
---|
483 | { DBGFEVENT_INSTR_PAUSE, "instr_pause", "pause", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
484 | { DBGFEVENT_INSTR_XSETBV, "instr_xsetbv", "xsetbv", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
485 | { DBGFEVENT_INSTR_SIDT, "instr_sidt", "sidt", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
486 | { DBGFEVENT_INSTR_LIDT, "instr_lidt", "lidt", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
487 | { DBGFEVENT_INSTR_SGDT, "instr_sgdt", "sgdt", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
488 | { DBGFEVENT_INSTR_LGDT, "instr_lgdt", "lgdt", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
489 | { DBGFEVENT_INSTR_SLDT, "instr_sldt", "sldt", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
490 | { DBGFEVENT_INSTR_LLDT, "instr_lldt", "lldt", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
491 | { DBGFEVENT_INSTR_STR, "instr_str", "str", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
492 | { DBGFEVENT_INSTR_LTR, "instr_ltr", "ltr", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
493 | { DBGFEVENT_INSTR_GETSEC, "instr_getsec", "getsec", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
494 | { DBGFEVENT_INSTR_RSM, "instr_rsm", "rsm", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
495 | { DBGFEVENT_INSTR_RDRAND, "instr_rdrand", "rdrand", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
496 | { DBGFEVENT_INSTR_RDSEED, "instr_rdseed", "rdseed", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
497 | { DBGFEVENT_INSTR_XSAVES, "instr_xsaves", "xsaves", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
498 | { DBGFEVENT_INSTR_XRSTORS, "instr_xrstors", "xrstors", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
499 | { DBGFEVENT_INSTR_VMM_CALL, "instr_vmm_call", "vmm_call", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
500 | { DBGFEVENT_INSTR_VMX_VMCLEAR, "instr_vmx_vmclear", "vmclear", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
501 | { DBGFEVENT_INSTR_VMX_VMLAUNCH, "instr_vmx_vmlaunch", "vmlaunch", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
502 | { DBGFEVENT_INSTR_VMX_VMPTRLD, "instr_vmx_vmptrld", "vmptrld", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
503 | { DBGFEVENT_INSTR_VMX_VMPTRST, "instr_vmx_vmptrst", "vmptrst", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
504 | { DBGFEVENT_INSTR_VMX_VMREAD, "instr_vmx_vmread", "vmread", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
505 | { DBGFEVENT_INSTR_VMX_VMRESUME, "instr_vmx_vmresume", "vmresume", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
506 | { DBGFEVENT_INSTR_VMX_VMWRITE, "instr_vmx_vmwrite", "vmwrite", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
507 | { DBGFEVENT_INSTR_VMX_VMXOFF, "instr_vmx_vmxoff", "vmxoff", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
508 | { DBGFEVENT_INSTR_VMX_VMXON, "instr_vmx_vmxon", "vmxon", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
509 | { DBGFEVENT_INSTR_VMX_VMFUNC, "instr_vmx_vmfunc", "vmfunc", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
510 | { DBGFEVENT_INSTR_VMX_INVEPT, "instr_vmx_invept", "invept", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
511 | { DBGFEVENT_INSTR_VMX_INVVPID, "instr_vmx_invvpid", "invvpid", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
512 | { DBGFEVENT_INSTR_VMX_INVPCID, "instr_vmx_invpcid", "invpcid", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
513 | { DBGFEVENT_INSTR_SVM_VMRUN, "instr_svm_vmrun", "vmrun", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
514 | { DBGFEVENT_INSTR_SVM_VMLOAD, "instr_svm_vmload", "vmload", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
515 | { DBGFEVENT_INSTR_SVM_VMSAVE, "instr_svm_vmsave", "vmsave", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
516 | { DBGFEVENT_INSTR_SVM_STGI, "instr_svm_stgi", "stgi", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
517 | { DBGFEVENT_INSTR_SVM_CLGI, "instr_svm_clgi", "clgi", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
518 | { DBGFEVENT_EXIT_TASK_SWITCH, "exit_task_switch", "task_switch", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
519 | { DBGFEVENT_EXIT_HALT, "exit_halt", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
520 | { DBGFEVENT_EXIT_MWAIT, "exit_mwait", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
521 | { DBGFEVENT_EXIT_MONITOR, "exit_monitor", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
522 | { DBGFEVENT_EXIT_CPUID, "exit_cpuid", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
523 | { DBGFEVENT_EXIT_INVD, "exit_invd", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
524 | { DBGFEVENT_EXIT_WBINVD, "exit_wbinvd", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
525 | { DBGFEVENT_EXIT_INVLPG, "exit_invlpg", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
526 | { DBGFEVENT_EXIT_RDTSC, "exit_rdtsc", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
527 | { DBGFEVENT_EXIT_RDTSCP, "exit_rdtscp", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
528 | { DBGFEVENT_EXIT_RDPMC, "exit_rdpmc", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
529 | { DBGFEVENT_EXIT_RDMSR, "exit_rdmsr", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
530 | { DBGFEVENT_EXIT_WRMSR, "exit_wrmsr", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
531 | { DBGFEVENT_EXIT_CRX_READ, "exit_crx_read", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
532 | { DBGFEVENT_EXIT_CRX_WRITE, "exit_crx_write", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
533 | { DBGFEVENT_EXIT_DRX_READ, "exit_drx_read", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
534 | { DBGFEVENT_EXIT_DRX_WRITE, "exit_drx_write", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
535 | { DBGFEVENT_EXIT_PAUSE, "exit_pause", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
536 | { DBGFEVENT_EXIT_XSETBV, "exit_xsetbv", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
537 | { DBGFEVENT_EXIT_SIDT, "exit_sidt", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
538 | { DBGFEVENT_EXIT_LIDT, "exit_lidt", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
539 | { DBGFEVENT_EXIT_SGDT, "exit_sgdt", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
540 | { DBGFEVENT_EXIT_LGDT, "exit_lgdt", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
541 | { DBGFEVENT_EXIT_SLDT, "exit_sldt", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
542 | { DBGFEVENT_EXIT_LLDT, "exit_lldt", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
543 | { DBGFEVENT_EXIT_STR, "exit_str", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
544 | { DBGFEVENT_EXIT_LTR, "exit_ltr", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
545 | { DBGFEVENT_EXIT_GETSEC, "exit_getsec", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
546 | { DBGFEVENT_EXIT_RSM, "exit_rsm", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
547 | { DBGFEVENT_EXIT_RDRAND, "exit_rdrand", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
548 | { DBGFEVENT_EXIT_RDSEED, "exit_rdseed", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
549 | { DBGFEVENT_EXIT_XSAVES, "exit_xsaves", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
550 | { DBGFEVENT_EXIT_XRSTORS, "exit_xrstors", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
551 | { DBGFEVENT_EXIT_VMM_CALL, "exit_vmm_call", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
552 | { DBGFEVENT_EXIT_VMX_VMCLEAR, "exit_vmx_vmclear", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
553 | { DBGFEVENT_EXIT_VMX_VMLAUNCH, "exit_vmx_vmlaunch", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
554 | { DBGFEVENT_EXIT_VMX_VMPTRLD, "exit_vmx_vmptrld", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
555 | { DBGFEVENT_EXIT_VMX_VMPTRST, "exit_vmx_vmptrst", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
556 | { DBGFEVENT_EXIT_VMX_VMREAD, "exit_vmx_vmread", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
557 | { DBGFEVENT_EXIT_VMX_VMRESUME, "exit_vmx_vmresume", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
558 | { DBGFEVENT_EXIT_VMX_VMWRITE, "exit_vmx_vmwrite", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
559 | { DBGFEVENT_EXIT_VMX_VMXOFF, "exit_vmx_vmxoff", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
560 | { DBGFEVENT_EXIT_VMX_VMXON, "exit_vmx_vmxon", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
561 | { DBGFEVENT_EXIT_VMX_VMFUNC, "exit_vmx_vmfunc", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
562 | { DBGFEVENT_EXIT_VMX_INVEPT, "exit_vmx_invept", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
563 | { DBGFEVENT_EXIT_VMX_INVVPID, "exit_vmx_invvpid", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
564 | { DBGFEVENT_EXIT_VMX_INVPCID, "exit_vmx_invpcid", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
565 | { DBGFEVENT_EXIT_VMX_EPT_VIOLATION, "exit_vmx_ept_violation", "eptvio", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
566 | { DBGFEVENT_EXIT_VMX_EPT_MISCONFIG, "exit_vmx_ept_misconfig", "eptmis", kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
567 | { DBGFEVENT_EXIT_VMX_VAPIC_ACCESS, "exit_vmx_vapic_access", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
568 | { DBGFEVENT_EXIT_VMX_VAPIC_WRITE, "exit_vmx_vapic_write", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
569 | { DBGFEVENT_EXIT_SVM_VMRUN, "exit_svm_vmrun", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
570 | { DBGFEVENT_EXIT_SVM_VMLOAD, "exit_svm_vmload", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
571 | { DBGFEVENT_EXIT_SVM_VMSAVE, "exit_svm_vmsave", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
572 | { DBGFEVENT_EXIT_SVM_STGI, "exit_svm_stgi", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
573 | { DBGFEVENT_EXIT_SVM_CLGI, "exit_svm_clgi", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
574 | { DBGFEVENT_IOPORT_UNASSIGNED, "pio_unassigned", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
575 | { DBGFEVENT_IOPORT_UNUSED, "pio_unused", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
576 | { DBGFEVENT_MEMORY_UNASSIGNED, "mmio_unassigned", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
577 | { DBGFEVENT_MEMORY_ROM_WRITE, "rom_write", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
578 | { DBGFEVENT_BSOD_MSR, "bsod_msr", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
579 | { DBGFEVENT_BSOD_EFI, "bsod_efi", NULL, kDbgcSxEventKind_Plain, kDbgcEvtState_Disabled, 0, NULL },
|
---|
580 | };
|
---|
581 | /** Number of entries in g_aDbgcSxEvents. */
|
---|
582 | const uint32_t g_cDbgcSxEvents = RT_ELEMENTS(g_aDbgcSxEvents);
|
---|
583 |
|
---|
584 |
|
---|
585 |
|
---|
586 | /**
|
---|
587 | * @callback_method_impl{FNDBGCCMD, The 'go' command.}
|
---|
588 | */
|
---|
589 | static DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
590 | {
|
---|
591 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
592 |
|
---|
593 | /*
|
---|
594 | * Check if the VM is halted or not before trying to resume it.
|
---|
595 | */
|
---|
596 | if (!DBGFR3IsHalted(pUVM))
|
---|
597 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "The VM is already running");
|
---|
598 |
|
---|
599 | int rc = DBGFR3Resume(pUVM);
|
---|
600 | if (RT_FAILURE(rc))
|
---|
601 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3Resume");
|
---|
602 |
|
---|
603 | NOREF(paArgs); NOREF(cArgs);
|
---|
604 | return VINF_SUCCESS;
|
---|
605 | }
|
---|
606 |
|
---|
607 |
|
---|
608 | /**
|
---|
609 | * @callback_method_impl{FNDBGCCMD, The 'ba' command.}
|
---|
610 | */
|
---|
611 | static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
612 | {
|
---|
613 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
614 |
|
---|
615 | /*
|
---|
616 | * Interpret access type.
|
---|
617 | */
|
---|
618 | if ( !strchr("xrwi", paArgs[0].u.pszString[0])
|
---|
619 | || paArgs[0].u.pszString[1])
|
---|
620 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access type '%s' for '%s'. Valid types are 'e', 'r', 'w' and 'i'",
|
---|
621 | paArgs[0].u.pszString, pCmd->pszCmd);
|
---|
622 | uint8_t fType = 0;
|
---|
623 | switch (paArgs[0].u.pszString[0])
|
---|
624 | {
|
---|
625 | case 'x': fType = X86_DR7_RW_EO; break;
|
---|
626 | case 'r': fType = X86_DR7_RW_RW; break;
|
---|
627 | case 'w': fType = X86_DR7_RW_WO; break;
|
---|
628 | case 'i': fType = X86_DR7_RW_IO; break;
|
---|
629 | }
|
---|
630 |
|
---|
631 | /*
|
---|
632 | * Validate size.
|
---|
633 | */
|
---|
634 | if (fType == X86_DR7_RW_EO && paArgs[1].u.u64Number != 1)
|
---|
635 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access size %RX64 for '%s'. 'x' access type requires size 1!",
|
---|
636 | paArgs[1].u.u64Number, pCmd->pszCmd);
|
---|
637 | switch (paArgs[1].u.u64Number)
|
---|
638 | {
|
---|
639 | case 1:
|
---|
640 | case 2:
|
---|
641 | case 4:
|
---|
642 | break;
|
---|
643 | /*case 8: - later*/
|
---|
644 | default:
|
---|
645 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access size %RX64 for '%s'. 1, 2 or 4!",
|
---|
646 | paArgs[1].u.u64Number, pCmd->pszCmd);
|
---|
647 | }
|
---|
648 | uint8_t cb = (uint8_t)paArgs[1].u.u64Number;
|
---|
649 |
|
---|
650 | /*
|
---|
651 | * Convert the pointer to a DBGF address.
|
---|
652 | */
|
---|
653 | DBGFADDRESS Address;
|
---|
654 | int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[2], &Address);
|
---|
655 | if (RT_FAILURE(rc))
|
---|
656 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,%DV,)", &paArgs[2]);
|
---|
657 |
|
---|
658 | /*
|
---|
659 | * Pick out the optional arguments.
|
---|
660 | */
|
---|
661 | uint64_t iHitTrigger = 0;
|
---|
662 | uint64_t iHitDisable = ~0;
|
---|
663 | const char *pszCmds = NULL;
|
---|
664 | unsigned iArg = 3;
|
---|
665 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
666 | {
|
---|
667 | iHitTrigger = paArgs[iArg].u.u64Number;
|
---|
668 | iArg++;
|
---|
669 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
670 | {
|
---|
671 | iHitDisable = paArgs[iArg].u.u64Number;
|
---|
672 | iArg++;
|
---|
673 | }
|
---|
674 | }
|
---|
675 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_STRING)
|
---|
676 | {
|
---|
677 | pszCmds = paArgs[iArg].u.pszString;
|
---|
678 | iArg++;
|
---|
679 | }
|
---|
680 |
|
---|
681 | /*
|
---|
682 | * Try set the breakpoint.
|
---|
683 | */
|
---|
684 | uint32_t iBp;
|
---|
685 | rc = DBGFR3BpSetReg(pUVM, &Address, iHitTrigger, iHitDisable, fType, cb, &iBp);
|
---|
686 | if (RT_SUCCESS(rc))
|
---|
687 | {
|
---|
688 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
689 | rc = dbgcBpAdd(pDbgc, iBp, pszCmds);
|
---|
690 | if (RT_SUCCESS(rc))
|
---|
691 | return DBGCCmdHlpPrintf(pCmdHlp, "Set access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
|
---|
692 | if (rc == VERR_DBGC_BP_EXISTS)
|
---|
693 | {
|
---|
694 | rc = dbgcBpUpdate(pDbgc, iBp, pszCmds);
|
---|
695 | if (RT_SUCCESS(rc))
|
---|
696 | return DBGCCmdHlpPrintf(pCmdHlp, "Updated access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
|
---|
697 | }
|
---|
698 | int rc2 = DBGFR3BpClear(pDbgc->pUVM, iBp);
|
---|
699 | AssertRC(rc2);
|
---|
700 | }
|
---|
701 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set access breakpoint at %RGv", Address.FlatPtr);
|
---|
702 | }
|
---|
703 |
|
---|
704 |
|
---|
705 | /**
|
---|
706 | * @callback_method_impl{FNDBGCCMD, The 'bc' command.}
|
---|
707 | */
|
---|
708 | static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
709 | {
|
---|
710 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
711 |
|
---|
712 | /*
|
---|
713 | * Enumerate the arguments.
|
---|
714 | */
|
---|
715 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
716 | int rc = VINF_SUCCESS;
|
---|
717 | for (unsigned iArg = 0; iArg < cArgs && RT_SUCCESS(rc); iArg++)
|
---|
718 | {
|
---|
719 | if (paArgs[iArg].enmType != DBGCVAR_TYPE_STRING)
|
---|
720 | {
|
---|
721 | /* one */
|
---|
722 | uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number;
|
---|
723 | if (iBp == paArgs[iArg].u.u64Number)
|
---|
724 | {
|
---|
725 | int rc2 = DBGFR3BpClear(pUVM, iBp);
|
---|
726 | if (RT_FAILURE(rc2))
|
---|
727 | rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp);
|
---|
728 | if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND)
|
---|
729 | dbgcBpDelete(pDbgc, iBp);
|
---|
730 | }
|
---|
731 | else
|
---|
732 | rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number);
|
---|
733 | }
|
---|
734 | else if (!strcmp(paArgs[iArg].u.pszString, "all"))
|
---|
735 | {
|
---|
736 | /* all */
|
---|
737 | PDBGCBP pBp = pDbgc->pFirstBp;
|
---|
738 | while (pBp)
|
---|
739 | {
|
---|
740 | uint32_t iBp = pBp->iBp;
|
---|
741 | pBp = pBp->pNext;
|
---|
742 |
|
---|
743 | int rc2 = DBGFR3BpClear(pUVM, iBp);
|
---|
744 | if (RT_FAILURE(rc2))
|
---|
745 | rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp);
|
---|
746 | if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND)
|
---|
747 | dbgcBpDelete(pDbgc, iBp);
|
---|
748 | }
|
---|
749 | }
|
---|
750 | else
|
---|
751 | rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString);
|
---|
752 | }
|
---|
753 | return rc;
|
---|
754 | }
|
---|
755 |
|
---|
756 |
|
---|
757 | /**
|
---|
758 | * @callback_method_impl{FNDBGCCMD, The 'bd' command.}
|
---|
759 | */
|
---|
760 | static DECLCALLBACK(int) dbgcCmdBrkDisable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
761 | {
|
---|
762 | /*
|
---|
763 | * Enumerate the arguments.
|
---|
764 | */
|
---|
765 | int rc = VINF_SUCCESS;
|
---|
766 | for (unsigned iArg = 0; iArg < cArgs && RT_SUCCESS(rc); iArg++)
|
---|
767 | {
|
---|
768 | if (paArgs[iArg].enmType != DBGCVAR_TYPE_STRING)
|
---|
769 | {
|
---|
770 | /* one */
|
---|
771 | uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number;
|
---|
772 | if (iBp == paArgs[iArg].u.u64Number)
|
---|
773 | {
|
---|
774 | rc = DBGFR3BpDisable(pUVM, iBp);
|
---|
775 | if (RT_FAILURE(rc))
|
---|
776 | rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpDisable failed for breakpoint %#x", iBp);
|
---|
777 | }
|
---|
778 | else
|
---|
779 | rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number);
|
---|
780 | }
|
---|
781 | else if (!strcmp(paArgs[iArg].u.pszString, "all"))
|
---|
782 | {
|
---|
783 | /* all */
|
---|
784 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
785 | for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext)
|
---|
786 | {
|
---|
787 | int rc2 = DBGFR3BpDisable(pUVM, pBp->iBp);
|
---|
788 | if (RT_FAILURE(rc2))
|
---|
789 | rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpDisable failed for breakpoint %#x", pBp->iBp);
|
---|
790 | }
|
---|
791 | }
|
---|
792 | else
|
---|
793 | rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString);
|
---|
794 | }
|
---|
795 | return rc;
|
---|
796 | }
|
---|
797 |
|
---|
798 |
|
---|
799 | /**
|
---|
800 | * @callback_method_impl{FNDBGCCMD, The 'be' command.}
|
---|
801 | */
|
---|
802 | static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
803 | {
|
---|
804 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
805 |
|
---|
806 | /*
|
---|
807 | * Enumerate the arguments.
|
---|
808 | */
|
---|
809 | int rc = VINF_SUCCESS;
|
---|
810 | for (unsigned iArg = 0; iArg < cArgs && RT_SUCCESS(rc); iArg++)
|
---|
811 | {
|
---|
812 | if (paArgs[iArg].enmType != DBGCVAR_TYPE_STRING)
|
---|
813 | {
|
---|
814 | /* one */
|
---|
815 | uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number;
|
---|
816 | if (iBp == paArgs[iArg].u.u64Number)
|
---|
817 | {
|
---|
818 | rc = DBGFR3BpEnable(pUVM, iBp);
|
---|
819 | if (RT_FAILURE(rc))
|
---|
820 | rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnable failed for breakpoint %#x", iBp);
|
---|
821 | }
|
---|
822 | else
|
---|
823 | rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number);
|
---|
824 | }
|
---|
825 | else if (!strcmp(paArgs[iArg].u.pszString, "all"))
|
---|
826 | {
|
---|
827 | /* all */
|
---|
828 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
829 | for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext)
|
---|
830 | {
|
---|
831 | int rc2 = DBGFR3BpEnable(pUVM, pBp->iBp);
|
---|
832 | if (RT_FAILURE(rc2))
|
---|
833 | rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpEnable failed for breakpoint %#x", pBp->iBp);
|
---|
834 | }
|
---|
835 | }
|
---|
836 | else
|
---|
837 | rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString);
|
---|
838 | }
|
---|
839 | return rc;
|
---|
840 | }
|
---|
841 |
|
---|
842 |
|
---|
843 | /**
|
---|
844 | * Breakpoint enumeration callback function.
|
---|
845 | *
|
---|
846 | * @returns VBox status code. Any failure will stop the enumeration.
|
---|
847 | * @param pUVM The user mode VM handle.
|
---|
848 | * @param pvUser The user argument.
|
---|
849 | * @param pBp Pointer to the breakpoint information. (readonly)
|
---|
850 | */
|
---|
851 | static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PUVM pUVM, void *pvUser, PCDBGFBP pBp)
|
---|
852 | {
|
---|
853 | PDBGC pDbgc = (PDBGC)pvUser;
|
---|
854 | PDBGCBP pDbgcBp = dbgcBpGet(pDbgc, pBp->iBp);
|
---|
855 |
|
---|
856 | /*
|
---|
857 | * BP type and size.
|
---|
858 | */
|
---|
859 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%#4x %c ", pBp->iBp, pBp->fEnabled ? 'e' : 'd');
|
---|
860 | bool fHasAddress = false;
|
---|
861 | switch (pBp->enmType)
|
---|
862 | {
|
---|
863 | case DBGFBPTYPE_INT3:
|
---|
864 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " p %RGv", pBp->u.Int3.GCPtr);
|
---|
865 | fHasAddress = true;
|
---|
866 | break;
|
---|
867 | case DBGFBPTYPE_REG:
|
---|
868 | {
|
---|
869 | char chType;
|
---|
870 | switch (pBp->u.Reg.fType)
|
---|
871 | {
|
---|
872 | case X86_DR7_RW_EO: chType = 'x'; break;
|
---|
873 | case X86_DR7_RW_WO: chType = 'w'; break;
|
---|
874 | case X86_DR7_RW_IO: chType = 'i'; break;
|
---|
875 | case X86_DR7_RW_RW: chType = 'r'; break;
|
---|
876 | default: chType = '?'; break;
|
---|
877 |
|
---|
878 | }
|
---|
879 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%d %c %RGv", pBp->u.Reg.cb, chType, pBp->u.Reg.GCPtr);
|
---|
880 | fHasAddress = true;
|
---|
881 | break;
|
---|
882 | }
|
---|
883 |
|
---|
884 | case DBGFBPTYPE_REM:
|
---|
885 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " r %RGv", pBp->u.Rem.GCPtr);
|
---|
886 | fHasAddress = true;
|
---|
887 | break;
|
---|
888 |
|
---|
889 | /** @todo realign the list when I/O and MMIO breakpoint command have been added and it's possible to test this code. */
|
---|
890 | case DBGFBPTYPE_PORT_IO:
|
---|
891 | case DBGFBPTYPE_MMIO:
|
---|
892 | {
|
---|
893 | uint32_t fAccess = pBp->enmType == DBGFBPTYPE_PORT_IO ? pBp->u.PortIo.fAccess : pBp->u.Mmio.fAccess;
|
---|
894 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, pBp->enmType == DBGFBPTYPE_PORT_IO ? " i" : " m");
|
---|
895 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " %c%c%c%c%c%c",
|
---|
896 | fAccess & DBGFBPIOACCESS_READ_MASK ? 'r' : '-',
|
---|
897 | fAccess & DBGFBPIOACCESS_READ_BYTE ? '1' : '-',
|
---|
898 | fAccess & DBGFBPIOACCESS_READ_WORD ? '2' : '-',
|
---|
899 | fAccess & DBGFBPIOACCESS_READ_DWORD ? '4' : '-',
|
---|
900 | fAccess & DBGFBPIOACCESS_READ_QWORD ? '8' : '-',
|
---|
901 | fAccess & DBGFBPIOACCESS_READ_OTHER ? '+' : '-');
|
---|
902 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " %c%c%c%c%c%c",
|
---|
903 | fAccess & DBGFBPIOACCESS_WRITE_MASK ? 'w' : '-',
|
---|
904 | fAccess & DBGFBPIOACCESS_WRITE_BYTE ? '1' : '-',
|
---|
905 | fAccess & DBGFBPIOACCESS_WRITE_WORD ? '2' : '-',
|
---|
906 | fAccess & DBGFBPIOACCESS_WRITE_DWORD ? '4' : '-',
|
---|
907 | fAccess & DBGFBPIOACCESS_WRITE_QWORD ? '8' : '-',
|
---|
908 | fAccess & DBGFBPIOACCESS_WRITE_OTHER ? '+' : '-');
|
---|
909 | if (pBp->enmType == DBGFBPTYPE_PORT_IO)
|
---|
910 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " %04x-%04x",
|
---|
911 | pBp->u.PortIo.uPort, pBp->u.PortIo.uPort + pBp->u.PortIo.cPorts - 1);
|
---|
912 | else
|
---|
913 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%RGp LB %03x", pBp->u.Mmio.PhysAddr, pBp->u.Mmio.cb);
|
---|
914 | break;
|
---|
915 | }
|
---|
916 |
|
---|
917 | default:
|
---|
918 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " unknown type %d!!", pBp->enmType);
|
---|
919 | AssertFailed();
|
---|
920 | break;
|
---|
921 |
|
---|
922 | }
|
---|
923 | if (pBp->iHitDisable == ~(uint64_t)0)
|
---|
924 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " %04RX64 (%04RX64 to ~0) ", pBp->cHits, pBp->iHitTrigger);
|
---|
925 | else
|
---|
926 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " %04RX64 (%04RX64 to %04RX64)", pBp->cHits, pBp->iHitTrigger, pBp->iHitDisable);
|
---|
927 |
|
---|
928 | /*
|
---|
929 | * Try resolve the address if it has one.
|
---|
930 | */
|
---|
931 | if (fHasAddress)
|
---|
932 | {
|
---|
933 | RTDBGSYMBOL Sym;
|
---|
934 | RTINTPTR off;
|
---|
935 | DBGFADDRESS Addr;
|
---|
936 | int rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, pBp->u.GCPtr),
|
---|
937 | RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &off, &Sym, NULL);
|
---|
938 | if (RT_SUCCESS(rc))
|
---|
939 | {
|
---|
940 | if (!off)
|
---|
941 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s", Sym.szName);
|
---|
942 | else if (off > 0)
|
---|
943 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, off);
|
---|
944 | else
|
---|
945 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s-%RGv", Sym.szName, -off);
|
---|
946 | }
|
---|
947 | }
|
---|
948 |
|
---|
949 | /*
|
---|
950 | * The commands.
|
---|
951 | */
|
---|
952 | if (pDbgcBp)
|
---|
953 | {
|
---|
954 | if (pDbgcBp->cchCmd)
|
---|
955 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "\n cmds: '%s'\n", pDbgcBp->szCmd);
|
---|
956 | else
|
---|
957 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "\n");
|
---|
958 | }
|
---|
959 | else
|
---|
960 | DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " [unknown bp]\n");
|
---|
961 |
|
---|
962 | return VINF_SUCCESS;
|
---|
963 | }
|
---|
964 |
|
---|
965 |
|
---|
966 | /**
|
---|
967 | * @callback_method_impl{FNDBGCCMD, The 'bl' command.}
|
---|
968 | */
|
---|
969 | static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
970 | {
|
---|
971 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
972 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs == 0);
|
---|
973 | NOREF(paArgs);
|
---|
974 |
|
---|
975 | /*
|
---|
976 | * Enumerate the breakpoints.
|
---|
977 | */
|
---|
978 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
979 | int rc = DBGFR3BpEnum(pUVM, dbgcEnumBreakpointsCallback, pDbgc);
|
---|
980 | if (RT_FAILURE(rc))
|
---|
981 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnum");
|
---|
982 | return rc;
|
---|
983 | }
|
---|
984 |
|
---|
985 |
|
---|
986 | /**
|
---|
987 | * @callback_method_impl{FNDBGCCMD, The 'bp' command.}
|
---|
988 | */
|
---|
989 | static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
990 | {
|
---|
991 | /*
|
---|
992 | * Convert the pointer to a DBGF address.
|
---|
993 | */
|
---|
994 | DBGFADDRESS Address;
|
---|
995 | int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
|
---|
996 | if (RT_FAILURE(rc))
|
---|
997 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,'%DV',)", &paArgs[0]);
|
---|
998 |
|
---|
999 | /*
|
---|
1000 | * Pick out the optional arguments.
|
---|
1001 | */
|
---|
1002 | uint64_t iHitTrigger = 0;
|
---|
1003 | uint64_t iHitDisable = ~0;
|
---|
1004 | const char *pszCmds = NULL;
|
---|
1005 | unsigned iArg = 1;
|
---|
1006 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
1007 | {
|
---|
1008 | iHitTrigger = paArgs[iArg].u.u64Number;
|
---|
1009 | iArg++;
|
---|
1010 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
1011 | {
|
---|
1012 | iHitDisable = paArgs[iArg].u.u64Number;
|
---|
1013 | iArg++;
|
---|
1014 | }
|
---|
1015 | }
|
---|
1016 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_STRING)
|
---|
1017 | {
|
---|
1018 | pszCmds = paArgs[iArg].u.pszString;
|
---|
1019 | iArg++;
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | /*
|
---|
1023 | * Try set the breakpoint.
|
---|
1024 | */
|
---|
1025 | uint32_t iBp;
|
---|
1026 | rc = DBGFR3BpSet(pUVM, &Address, iHitTrigger, iHitDisable, &iBp);
|
---|
1027 | if (RT_SUCCESS(rc))
|
---|
1028 | {
|
---|
1029 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1030 | rc = dbgcBpAdd(pDbgc, iBp, pszCmds);
|
---|
1031 | if (RT_SUCCESS(rc))
|
---|
1032 | return DBGCCmdHlpPrintf(pCmdHlp, "Set breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
|
---|
1033 | if (rc == VERR_DBGC_BP_EXISTS)
|
---|
1034 | {
|
---|
1035 | rc = dbgcBpUpdate(pDbgc, iBp, pszCmds);
|
---|
1036 | if (RT_SUCCESS(rc))
|
---|
1037 | return DBGCCmdHlpPrintf(pCmdHlp, "Updated breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
|
---|
1038 | }
|
---|
1039 | int rc2 = DBGFR3BpClear(pDbgc->pUVM, iBp);
|
---|
1040 | AssertRC(rc2);
|
---|
1041 | }
|
---|
1042 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set breakpoint at %RGv", Address.FlatPtr);
|
---|
1043 | }
|
---|
1044 |
|
---|
1045 |
|
---|
1046 | /**
|
---|
1047 | * @callback_method_impl{FNDBGCCMD, The 'br' command.}
|
---|
1048 | */
|
---|
1049 | static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1050 | {
|
---|
1051 | /*
|
---|
1052 | * Convert the pointer to a DBGF address.
|
---|
1053 | */
|
---|
1054 | DBGFADDRESS Address;
|
---|
1055 | int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);
|
---|
1056 | if (RT_FAILURE(rc))
|
---|
1057 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,'%DV',)", &paArgs[0]);
|
---|
1058 |
|
---|
1059 | /*
|
---|
1060 | * Pick out the optional arguments.
|
---|
1061 | */
|
---|
1062 | uint64_t iHitTrigger = 0;
|
---|
1063 | uint64_t iHitDisable = ~0;
|
---|
1064 | const char *pszCmds = NULL;
|
---|
1065 | unsigned iArg = 1;
|
---|
1066 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
1067 | {
|
---|
1068 | iHitTrigger = paArgs[iArg].u.u64Number;
|
---|
1069 | iArg++;
|
---|
1070 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
1071 | {
|
---|
1072 | iHitDisable = paArgs[iArg].u.u64Number;
|
---|
1073 | iArg++;
|
---|
1074 | }
|
---|
1075 | }
|
---|
1076 | if (iArg < cArgs && paArgs[iArg].enmType == DBGCVAR_TYPE_STRING)
|
---|
1077 | {
|
---|
1078 | pszCmds = paArgs[iArg].u.pszString;
|
---|
1079 | iArg++;
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 | /*
|
---|
1083 | * Try set the breakpoint.
|
---|
1084 | */
|
---|
1085 | uint32_t iBp;
|
---|
1086 | rc = DBGFR3BpSetREM(pUVM, &Address, iHitTrigger, iHitDisable, &iBp);
|
---|
1087 | if (RT_SUCCESS(rc))
|
---|
1088 | {
|
---|
1089 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1090 | rc = dbgcBpAdd(pDbgc, iBp, pszCmds);
|
---|
1091 | if (RT_SUCCESS(rc))
|
---|
1092 | return DBGCCmdHlpPrintf(pCmdHlp, "Set REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
|
---|
1093 | if (rc == VERR_DBGC_BP_EXISTS)
|
---|
1094 | {
|
---|
1095 | rc = dbgcBpUpdate(pDbgc, iBp, pszCmds);
|
---|
1096 | if (RT_SUCCESS(rc))
|
---|
1097 | return DBGCCmdHlpPrintf(pCmdHlp, "Updated REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);
|
---|
1098 | }
|
---|
1099 | int rc2 = DBGFR3BpClear(pDbgc->pUVM, iBp);
|
---|
1100 | AssertRC(rc2);
|
---|
1101 | }
|
---|
1102 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set REM breakpoint at %RGv", Address.FlatPtr);
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 |
|
---|
1106 | /**
|
---|
1107 | * Helps the unassmble ('u') command display symbols it starts at and passes.
|
---|
1108 | *
|
---|
1109 | * @param pUVM The user mode VM handle.
|
---|
1110 | * @param pCmdHlp The command helpers for printing via.
|
---|
1111 | * @param hDbgAs The address space to look up addresses in.
|
---|
1112 | * @param pAddress The current address.
|
---|
1113 | * @param pcbCallAgain Where to return the distance to the next check (in
|
---|
1114 | * instruction bytes).
|
---|
1115 | */
|
---|
1116 | static void dbgcCmdUnassambleHelpListNear(PUVM pUVM, PDBGCCMDHLP pCmdHlp, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
|
---|
1117 | PRTUINTPTR pcbCallAgain)
|
---|
1118 | {
|
---|
1119 | RTDBGSYMBOL Symbol;
|
---|
1120 | RTGCINTPTR offDispSym;
|
---|
1121 | int rc = DBGFR3AsSymbolByAddr(pUVM, hDbgAs, pAddress, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDispSym, &Symbol, NULL);
|
---|
1122 | if (RT_FAILURE(rc) || offDispSym > _1G)
|
---|
1123 | rc = DBGFR3AsSymbolByAddr(pUVM, hDbgAs, pAddress, RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL, &offDispSym, &Symbol, NULL);
|
---|
1124 | if (RT_SUCCESS(rc) && offDispSym < _1G)
|
---|
1125 | {
|
---|
1126 | if (!offDispSym)
|
---|
1127 | {
|
---|
1128 | DBGCCmdHlpPrintf(pCmdHlp, "%s:\n", Symbol.szName);
|
---|
1129 | *pcbCallAgain = !Symbol.cb ? 64 : Symbol.cb;
|
---|
1130 | }
|
---|
1131 | else if (offDispSym > 0)
|
---|
1132 | {
|
---|
1133 | DBGCCmdHlpPrintf(pCmdHlp, "%s+%#llx:\n", Symbol.szName, (uint64_t)offDispSym);
|
---|
1134 | *pcbCallAgain = !Symbol.cb ? 64 : Symbol.cb > (RTGCUINTPTR)offDispSym ? Symbol.cb - (RTGCUINTPTR)offDispSym : 1;
|
---|
1135 | }
|
---|
1136 | else
|
---|
1137 | {
|
---|
1138 | DBGCCmdHlpPrintf(pCmdHlp, "%s-%#llx:\n", Symbol.szName, (uint64_t)-offDispSym);
|
---|
1139 | *pcbCallAgain = !Symbol.cb ? 64 : (RTGCUINTPTR)-offDispSym + Symbol.cb;
|
---|
1140 | }
|
---|
1141 | }
|
---|
1142 | else
|
---|
1143 | *pcbCallAgain = UINT32_MAX;
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 |
|
---|
1147 | /**
|
---|
1148 | * @callback_method_impl{FNDBGCCMD, The 'u' command.}
|
---|
1149 | */
|
---|
1150 | static DECLCALLBACK(int) dbgcCmdUnassemble(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1151 | {
|
---|
1152 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1153 |
|
---|
1154 | /*
|
---|
1155 | * Validate input.
|
---|
1156 | */
|
---|
1157 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
1158 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs <= 1);
|
---|
1159 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 0 || DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
1160 |
|
---|
1161 | if (!cArgs && !DBGCVAR_ISPOINTER(pDbgc->DisasmPos.enmType))
|
---|
1162 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Don't know where to start disassembling");
|
---|
1163 |
|
---|
1164 | /*
|
---|
1165 | * Check the desired mode.
|
---|
1166 | */
|
---|
1167 | unsigned fFlags = DBGF_DISAS_FLAGS_NO_ADDRESS | DBGF_DISAS_FLAGS_UNPATCHED_BYTES | DBGF_DISAS_FLAGS_ANNOTATE_PATCHED;
|
---|
1168 | switch (pCmd->pszCmd[1])
|
---|
1169 | {
|
---|
1170 | default: AssertFailed();
|
---|
1171 | case '\0': fFlags |= DBGF_DISAS_FLAGS_DEFAULT_MODE; break;
|
---|
1172 | case '6': fFlags |= DBGF_DISAS_FLAGS_64BIT_MODE; break;
|
---|
1173 | case '3': fFlags |= DBGF_DISAS_FLAGS_32BIT_MODE; break;
|
---|
1174 | case '1': fFlags |= DBGF_DISAS_FLAGS_16BIT_MODE; break;
|
---|
1175 | case 'v': fFlags |= DBGF_DISAS_FLAGS_16BIT_REAL_MODE; break;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | /** @todo should use DBGFADDRESS for everything */
|
---|
1179 |
|
---|
1180 | /*
|
---|
1181 | * Find address.
|
---|
1182 | */
|
---|
1183 | if (!cArgs)
|
---|
1184 | {
|
---|
1185 | if (!DBGCVAR_ISPOINTER(pDbgc->DisasmPos.enmType))
|
---|
1186 | {
|
---|
1187 | /** @todo Batch query CS, RIP, CPU mode and flags. */
|
---|
1188 | PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu);
|
---|
1189 | if ( pDbgc->fRegCtxGuest
|
---|
1190 | && CPUMIsGuestIn64BitCode(pVCpu))
|
---|
1191 | {
|
---|
1192 | pDbgc->DisasmPos.enmType = DBGCVAR_TYPE_GC_FLAT;
|
---|
1193 | pDbgc->SourcePos.u.GCFlat = CPUMGetGuestRIP(pVCpu);
|
---|
1194 | }
|
---|
1195 | else
|
---|
1196 | {
|
---|
1197 | pDbgc->DisasmPos.enmType = DBGCVAR_TYPE_GC_FAR;
|
---|
1198 | pDbgc->SourcePos.u.GCFar.off = pDbgc->fRegCtxGuest ? CPUMGetGuestEIP(pVCpu) : CPUMGetHyperEIP(pVCpu);
|
---|
1199 | pDbgc->SourcePos.u.GCFar.sel = pDbgc->fRegCtxGuest ? CPUMGetGuestCS(pVCpu) : CPUMGetHyperCS(pVCpu);
|
---|
1200 | if ( (fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_DEFAULT_MODE
|
---|
1201 | && pDbgc->fRegCtxGuest
|
---|
1202 | && (CPUMGetGuestEFlags(pVCpu) & X86_EFL_VM))
|
---|
1203 | {
|
---|
1204 | fFlags &= ~DBGF_DISAS_FLAGS_MODE_MASK;
|
---|
1205 | fFlags |= DBGF_DISAS_FLAGS_16BIT_REAL_MODE;
|
---|
1206 | }
|
---|
1207 | }
|
---|
1208 |
|
---|
1209 | if (pDbgc->fRegCtxGuest)
|
---|
1210 | fFlags |= DBGF_DISAS_FLAGS_CURRENT_GUEST;
|
---|
1211 | else
|
---|
1212 | fFlags |= DBGF_DISAS_FLAGS_CURRENT_HYPER | DBGF_DISAS_FLAGS_HYPER;
|
---|
1213 | }
|
---|
1214 | else if ((fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_DEFAULT_MODE && pDbgc->fDisasm)
|
---|
1215 | {
|
---|
1216 | fFlags &= ~DBGF_DISAS_FLAGS_MODE_MASK;
|
---|
1217 | fFlags |= pDbgc->fDisasm & (DBGF_DISAS_FLAGS_MODE_MASK | DBGF_DISAS_FLAGS_HYPER);
|
---|
1218 | }
|
---|
1219 | pDbgc->DisasmPos.enmRangeType = DBGCVAR_RANGE_NONE;
|
---|
1220 | }
|
---|
1221 | else
|
---|
1222 | pDbgc->DisasmPos = paArgs[0];
|
---|
1223 | pDbgc->pLastPos = &pDbgc->DisasmPos;
|
---|
1224 |
|
---|
1225 | /*
|
---|
1226 | * Range.
|
---|
1227 | */
|
---|
1228 | switch (pDbgc->DisasmPos.enmRangeType)
|
---|
1229 | {
|
---|
1230 | case DBGCVAR_RANGE_NONE:
|
---|
1231 | pDbgc->DisasmPos.enmRangeType = DBGCVAR_RANGE_ELEMENTS;
|
---|
1232 | pDbgc->DisasmPos.u64Range = 10;
|
---|
1233 | break;
|
---|
1234 |
|
---|
1235 | case DBGCVAR_RANGE_ELEMENTS:
|
---|
1236 | if (pDbgc->DisasmPos.u64Range > 2048)
|
---|
1237 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Too many lines requested. Max is 2048 lines");
|
---|
1238 | break;
|
---|
1239 |
|
---|
1240 | case DBGCVAR_RANGE_BYTES:
|
---|
1241 | if (pDbgc->DisasmPos.u64Range > 65536)
|
---|
1242 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "The requested range is too big. Max is 64KB");
|
---|
1243 | break;
|
---|
1244 |
|
---|
1245 | default:
|
---|
1246 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Unknown range type %d", pDbgc->DisasmPos.enmRangeType);
|
---|
1247 | }
|
---|
1248 |
|
---|
1249 | /*
|
---|
1250 | * Convert physical and host addresses to guest addresses.
|
---|
1251 | */
|
---|
1252 | RTDBGAS hDbgAs = pDbgc->hDbgAs;
|
---|
1253 | int rc;
|
---|
1254 | switch (pDbgc->DisasmPos.enmType)
|
---|
1255 | {
|
---|
1256 | case DBGCVAR_TYPE_GC_FLAT:
|
---|
1257 | case DBGCVAR_TYPE_GC_FAR:
|
---|
1258 | break;
|
---|
1259 | case DBGCVAR_TYPE_GC_PHYS:
|
---|
1260 | hDbgAs = DBGF_AS_PHYS;
|
---|
1261 | case DBGCVAR_TYPE_HC_FLAT:
|
---|
1262 | case DBGCVAR_TYPE_HC_PHYS:
|
---|
1263 | {
|
---|
1264 | DBGCVAR VarTmp;
|
---|
1265 | rc = DBGCCmdHlpEval(pCmdHlp, &VarTmp, "%%(%Dv)", &pDbgc->DisasmPos);
|
---|
1266 | if (RT_FAILURE(rc))
|
---|
1267 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "failed to evaluate '%%(%Dv)'", &pDbgc->DisasmPos);
|
---|
1268 | pDbgc->DisasmPos = VarTmp;
|
---|
1269 | break;
|
---|
1270 | }
|
---|
1271 | default: AssertFailed(); break;
|
---|
1272 | }
|
---|
1273 |
|
---|
1274 | DBGFADDRESS CurAddr;
|
---|
1275 | if ( (fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_16BIT_REAL_MODE
|
---|
1276 | && pDbgc->DisasmPos.enmType == DBGCVAR_TYPE_GC_FAR)
|
---|
1277 | DBGFR3AddrFromFlat(pUVM, &CurAddr, ((uint32_t)pDbgc->DisasmPos.u.GCFar.sel << 4) + pDbgc->DisasmPos.u.GCFar.off);
|
---|
1278 | else
|
---|
1279 | {
|
---|
1280 | rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->DisasmPos, &CurAddr);
|
---|
1281 | if (RT_FAILURE(rc))
|
---|
1282 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr failed on '%Dv'", &pDbgc->DisasmPos);
|
---|
1283 | }
|
---|
1284 |
|
---|
1285 | if (CurAddr.fFlags & DBGFADDRESS_FLAGS_HMA)
|
---|
1286 | fFlags |= DBGF_DISAS_FLAGS_HYPER; /* This crap is due to not using DBGFADDRESS as DBGFR3Disas* input. */
|
---|
1287 | pDbgc->fDisasm = fFlags;
|
---|
1288 |
|
---|
1289 | /*
|
---|
1290 | * Figure out where we are and display it. Also calculate when we need to
|
---|
1291 | * check for a new symbol if possible.
|
---|
1292 | */
|
---|
1293 | RTGCUINTPTR cbCheckSymbol;
|
---|
1294 | dbgcCmdUnassambleHelpListNear(pUVM, pCmdHlp, hDbgAs, &CurAddr, &cbCheckSymbol);
|
---|
1295 |
|
---|
1296 | /*
|
---|
1297 | * Do the disassembling.
|
---|
1298 | */
|
---|
1299 | unsigned cTries = 32;
|
---|
1300 | int iRangeLeft = (int)pDbgc->DisasmPos.u64Range;
|
---|
1301 | if (iRangeLeft == 0) /* kludge for 'r'. */
|
---|
1302 | iRangeLeft = -1;
|
---|
1303 | for (;;)
|
---|
1304 | {
|
---|
1305 | /*
|
---|
1306 | * Disassemble the instruction.
|
---|
1307 | */
|
---|
1308 | char szDis[256];
|
---|
1309 | uint32_t cbInstr = 1;
|
---|
1310 | if (pDbgc->DisasmPos.enmType == DBGCVAR_TYPE_GC_FLAT)
|
---|
1311 | rc = DBGFR3DisasInstrEx(pUVM, pDbgc->idCpu, DBGF_SEL_FLAT, pDbgc->DisasmPos.u.GCFlat, fFlags,
|
---|
1312 | &szDis[0], sizeof(szDis), &cbInstr);
|
---|
1313 | else
|
---|
1314 | rc = DBGFR3DisasInstrEx(pUVM, pDbgc->idCpu, pDbgc->DisasmPos.u.GCFar.sel, pDbgc->DisasmPos.u.GCFar.off, fFlags,
|
---|
1315 | &szDis[0], sizeof(szDis), &cbInstr);
|
---|
1316 | if (RT_SUCCESS(rc))
|
---|
1317 | {
|
---|
1318 | /* print it */
|
---|
1319 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%-16DV %s\n", &pDbgc->DisasmPos, &szDis[0]);
|
---|
1320 | if (RT_FAILURE(rc))
|
---|
1321 | return rc;
|
---|
1322 | }
|
---|
1323 | else
|
---|
1324 | {
|
---|
1325 | /* bitch. */
|
---|
1326 | int rc2 = DBGCCmdHlpPrintf(pCmdHlp, "Failed to disassemble instruction, skipping one byte.\n");
|
---|
1327 | if (RT_FAILURE(rc2))
|
---|
1328 | return rc2;
|
---|
1329 | if (cTries-- > 0)
|
---|
1330 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Too many disassembly failures. Giving up");
|
---|
1331 | cbInstr = 1;
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | /* advance */
|
---|
1335 | if (iRangeLeft < 0) /* 'r' */
|
---|
1336 | break;
|
---|
1337 | if (pDbgc->DisasmPos.enmRangeType == DBGCVAR_RANGE_ELEMENTS)
|
---|
1338 | iRangeLeft--;
|
---|
1339 | else
|
---|
1340 | iRangeLeft -= cbInstr;
|
---|
1341 | rc = DBGCCmdHlpEval(pCmdHlp, &pDbgc->DisasmPos, "(%Dv) + %x", &pDbgc->DisasmPos, cbInstr);
|
---|
1342 | if (RT_FAILURE(rc))
|
---|
1343 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpEval(,,'(%Dv) + %x')", &pDbgc->DisasmPos, cbInstr);
|
---|
1344 | if (iRangeLeft <= 0)
|
---|
1345 | break;
|
---|
1346 | fFlags &= ~(DBGF_DISAS_FLAGS_CURRENT_GUEST | DBGF_DISAS_FLAGS_CURRENT_HYPER);
|
---|
1347 |
|
---|
1348 | /* Print next symbol? */
|
---|
1349 | if (cbCheckSymbol <= cbInstr)
|
---|
1350 | {
|
---|
1351 | if ( (fFlags & DBGF_DISAS_FLAGS_MODE_MASK) == DBGF_DISAS_FLAGS_16BIT_REAL_MODE
|
---|
1352 | && pDbgc->DisasmPos.enmType == DBGCVAR_TYPE_GC_FAR)
|
---|
1353 | DBGFR3AddrFromFlat(pUVM, &CurAddr, ((uint32_t)pDbgc->DisasmPos.u.GCFar.sel << 4) + pDbgc->DisasmPos.u.GCFar.off);
|
---|
1354 | else
|
---|
1355 | rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->DisasmPos, &CurAddr);
|
---|
1356 | if (RT_SUCCESS(rc))
|
---|
1357 | dbgcCmdUnassambleHelpListNear(pUVM, pCmdHlp, hDbgAs, &CurAddr, &cbCheckSymbol);
|
---|
1358 | else
|
---|
1359 | cbCheckSymbol = UINT32_MAX;
|
---|
1360 | }
|
---|
1361 | else
|
---|
1362 | cbCheckSymbol -= cbInstr;
|
---|
1363 | }
|
---|
1364 |
|
---|
1365 | NOREF(pCmd);
|
---|
1366 | return VINF_SUCCESS;
|
---|
1367 | }
|
---|
1368 |
|
---|
1369 |
|
---|
1370 | /**
|
---|
1371 | * @callback_method_impl{FNDBGCCMD, The 'ls' command.}
|
---|
1372 | */
|
---|
1373 | static DECLCALLBACK(int) dbgcCmdListSource(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1374 | {
|
---|
1375 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1376 |
|
---|
1377 | /*
|
---|
1378 | * Validate input.
|
---|
1379 | */
|
---|
1380 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1);
|
---|
1381 | if (cArgs == 1)
|
---|
1382 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
1383 | if (!pUVM && !cArgs && !DBGCVAR_ISPOINTER(pDbgc->SourcePos.enmType))
|
---|
1384 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Don't know where to start listing...");
|
---|
1385 | if (!pUVM && cArgs && DBGCVAR_ISGCPOINTER(paArgs[0].enmType))
|
---|
1386 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "GC address but no VM");
|
---|
1387 |
|
---|
1388 | /*
|
---|
1389 | * Find address.
|
---|
1390 | */
|
---|
1391 | if (!cArgs)
|
---|
1392 | {
|
---|
1393 | if (!DBGCVAR_ISPOINTER(pDbgc->SourcePos.enmType))
|
---|
1394 | {
|
---|
1395 | PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu);
|
---|
1396 | pDbgc->SourcePos.enmType = DBGCVAR_TYPE_GC_FAR;
|
---|
1397 | pDbgc->SourcePos.u.GCFar.off = pDbgc->fRegCtxGuest ? CPUMGetGuestEIP(pVCpu) : CPUMGetHyperEIP(pVCpu);
|
---|
1398 | pDbgc->SourcePos.u.GCFar.sel = pDbgc->fRegCtxGuest ? CPUMGetGuestCS(pVCpu) : CPUMGetHyperCS(pVCpu);
|
---|
1399 | }
|
---|
1400 | pDbgc->SourcePos.enmRangeType = DBGCVAR_RANGE_NONE;
|
---|
1401 | }
|
---|
1402 | else
|
---|
1403 | pDbgc->SourcePos = paArgs[0];
|
---|
1404 | pDbgc->pLastPos = &pDbgc->SourcePos;
|
---|
1405 |
|
---|
1406 | /*
|
---|
1407 | * Ensure the source address is flat GC.
|
---|
1408 | */
|
---|
1409 | switch (pDbgc->SourcePos.enmType)
|
---|
1410 | {
|
---|
1411 | case DBGCVAR_TYPE_GC_FLAT:
|
---|
1412 | break;
|
---|
1413 | case DBGCVAR_TYPE_GC_PHYS:
|
---|
1414 | case DBGCVAR_TYPE_GC_FAR:
|
---|
1415 | case DBGCVAR_TYPE_HC_FLAT:
|
---|
1416 | case DBGCVAR_TYPE_HC_PHYS:
|
---|
1417 | {
|
---|
1418 | int rc = DBGCCmdHlpEval(pCmdHlp, &pDbgc->SourcePos, "%%(%Dv)", &pDbgc->SourcePos);
|
---|
1419 | if (RT_FAILURE(rc))
|
---|
1420 | return DBGCCmdHlpPrintf(pCmdHlp, "error: Invalid address or address type. (rc=%d)\n", rc);
|
---|
1421 | break;
|
---|
1422 | }
|
---|
1423 | default: AssertFailed(); break;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | /*
|
---|
1427 | * Range.
|
---|
1428 | */
|
---|
1429 | switch (pDbgc->SourcePos.enmRangeType)
|
---|
1430 | {
|
---|
1431 | case DBGCVAR_RANGE_NONE:
|
---|
1432 | pDbgc->SourcePos.enmRangeType = DBGCVAR_RANGE_ELEMENTS;
|
---|
1433 | pDbgc->SourcePos.u64Range = 10;
|
---|
1434 | break;
|
---|
1435 |
|
---|
1436 | case DBGCVAR_RANGE_ELEMENTS:
|
---|
1437 | if (pDbgc->SourcePos.u64Range > 2048)
|
---|
1438 | return DBGCCmdHlpPrintf(pCmdHlp, "error: Too many lines requested. Max is 2048 lines.\n");
|
---|
1439 | break;
|
---|
1440 |
|
---|
1441 | case DBGCVAR_RANGE_BYTES:
|
---|
1442 | if (pDbgc->SourcePos.u64Range > 65536)
|
---|
1443 | return DBGCCmdHlpPrintf(pCmdHlp, "error: The requested range is too big. Max is 64KB.\n");
|
---|
1444 | break;
|
---|
1445 |
|
---|
1446 | default:
|
---|
1447 | return DBGCCmdHlpPrintf(pCmdHlp, "internal error: Unknown range type %d.\n", pDbgc->SourcePos.enmRangeType);
|
---|
1448 | }
|
---|
1449 |
|
---|
1450 | /*
|
---|
1451 | * Do the disassembling.
|
---|
1452 | */
|
---|
1453 | bool fFirst = 1;
|
---|
1454 | RTDBGLINE LinePrev = { 0, 0, 0, 0, 0, "" };
|
---|
1455 | int iRangeLeft = (int)pDbgc->SourcePos.u64Range;
|
---|
1456 | if (iRangeLeft == 0) /* kludge for 'r'. */
|
---|
1457 | iRangeLeft = -1;
|
---|
1458 | for (;;)
|
---|
1459 | {
|
---|
1460 | /*
|
---|
1461 | * Get line info.
|
---|
1462 | */
|
---|
1463 | RTDBGLINE Line;
|
---|
1464 | RTGCINTPTR off;
|
---|
1465 | DBGFADDRESS SourcePosAddr;
|
---|
1466 | int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &pDbgc->SourcePos, &SourcePosAddr);
|
---|
1467 | if (RT_FAILURE(rc))
|
---|
1468 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,%Dv)", &pDbgc->SourcePos);
|
---|
1469 | rc = DBGFR3AsLineByAddr(pUVM, pDbgc->hDbgAs, &SourcePosAddr, &off, &Line, NULL);
|
---|
1470 | if (RT_FAILURE(rc))
|
---|
1471 | return VINF_SUCCESS;
|
---|
1472 |
|
---|
1473 | unsigned cLines = 0;
|
---|
1474 | if (memcmp(&Line, &LinePrev, sizeof(Line)))
|
---|
1475 | {
|
---|
1476 | /*
|
---|
1477 | * Print filenamename
|
---|
1478 | */
|
---|
1479 | if (!fFirst && strcmp(Line.szFilename, LinePrev.szFilename))
|
---|
1480 | fFirst = true;
|
---|
1481 | if (fFirst)
|
---|
1482 | {
|
---|
1483 | rc = DBGCCmdHlpPrintf(pCmdHlp, "[%s @ %d]\n", Line.szFilename, Line.uLineNo);
|
---|
1484 | if (RT_FAILURE(rc))
|
---|
1485 | return rc;
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 | /*
|
---|
1489 | * Try open the file and read the line.
|
---|
1490 | */
|
---|
1491 | FILE *phFile = fopen(Line.szFilename, "r");
|
---|
1492 | if (phFile)
|
---|
1493 | {
|
---|
1494 | /* Skip ahead to the desired line. */
|
---|
1495 | char szLine[4096];
|
---|
1496 | unsigned cBefore = fFirst ? RT_MIN(2, Line.uLineNo - 1) : Line.uLineNo - LinePrev.uLineNo - 1;
|
---|
1497 | if (cBefore > 7)
|
---|
1498 | cBefore = 0;
|
---|
1499 | unsigned cLeft = Line.uLineNo - cBefore;
|
---|
1500 | while (cLeft > 0)
|
---|
1501 | {
|
---|
1502 | szLine[0] = '\0';
|
---|
1503 | if (!fgets(szLine, sizeof(szLine), phFile))
|
---|
1504 | break;
|
---|
1505 | cLeft--;
|
---|
1506 | }
|
---|
1507 | if (!cLeft)
|
---|
1508 | {
|
---|
1509 | /* print the before lines */
|
---|
1510 | for (;;)
|
---|
1511 | {
|
---|
1512 | size_t cch = strlen(szLine);
|
---|
1513 | while (cch > 0 && (szLine[cch - 1] == '\r' || szLine[cch - 1] == '\n' || RT_C_IS_SPACE(szLine[cch - 1])) )
|
---|
1514 | szLine[--cch] = '\0';
|
---|
1515 | if (cBefore-- <= 0)
|
---|
1516 | break;
|
---|
1517 |
|
---|
1518 | rc = DBGCCmdHlpPrintf(pCmdHlp, " %4d: %s\n", Line.uLineNo - cBefore - 1, szLine);
|
---|
1519 | szLine[0] = '\0';
|
---|
1520 | (void)fgets(szLine, sizeof(szLine), phFile);
|
---|
1521 | cLines++;
|
---|
1522 | }
|
---|
1523 | /* print the actual line */
|
---|
1524 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%08llx %4d: %s\n", Line.Address, Line.uLineNo, szLine);
|
---|
1525 | }
|
---|
1526 | fclose(phFile);
|
---|
1527 | if (RT_FAILURE(rc))
|
---|
1528 | return rc;
|
---|
1529 | fFirst = false;
|
---|
1530 | }
|
---|
1531 | else
|
---|
1532 | return DBGCCmdHlpPrintf(pCmdHlp, "Warning: couldn't open source file '%s'\n", Line.szFilename);
|
---|
1533 |
|
---|
1534 | LinePrev = Line;
|
---|
1535 | }
|
---|
1536 |
|
---|
1537 |
|
---|
1538 | /*
|
---|
1539 | * Advance
|
---|
1540 | */
|
---|
1541 | if (iRangeLeft < 0) /* 'r' */
|
---|
1542 | break;
|
---|
1543 | if (pDbgc->SourcePos.enmRangeType == DBGCVAR_RANGE_ELEMENTS)
|
---|
1544 | iRangeLeft -= cLines;
|
---|
1545 | else
|
---|
1546 | iRangeLeft -= 1;
|
---|
1547 | rc = DBGCCmdHlpEval(pCmdHlp, &pDbgc->SourcePos, "(%Dv) + %x", &pDbgc->SourcePos, 1);
|
---|
1548 | if (RT_FAILURE(rc))
|
---|
1549 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Expression: (%Dv) + %x\n", &pDbgc->SourcePos, 1);
|
---|
1550 | if (iRangeLeft <= 0)
|
---|
1551 | break;
|
---|
1552 | }
|
---|
1553 |
|
---|
1554 | NOREF(pCmd);
|
---|
1555 | return 0;
|
---|
1556 | }
|
---|
1557 |
|
---|
1558 |
|
---|
1559 | /**
|
---|
1560 | * @callback_method_impl{FNDBGCCMD, The 'r' command.}
|
---|
1561 | */
|
---|
1562 | static DECLCALLBACK(int) dbgcCmdReg(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1563 | {
|
---|
1564 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1565 | if (!pDbgc->fRegCtxGuest)
|
---|
1566 | return dbgcCmdRegHyper(pCmd, pCmdHlp, pUVM, paArgs, cArgs);
|
---|
1567 | return dbgcCmdRegGuest(pCmd, pCmdHlp, pUVM, paArgs, cArgs);
|
---|
1568 | }
|
---|
1569 |
|
---|
1570 |
|
---|
1571 | /**
|
---|
1572 | * @callback_method_impl{FNDBGCCMD, Common worker for the dbgcCmdReg*()
|
---|
1573 | * commands.}
|
---|
1574 | */
|
---|
1575 | static DECLCALLBACK(int) dbgcCmdRegCommon(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs,
|
---|
1576 | const char *pszPrefix)
|
---|
1577 | {
|
---|
1578 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1579 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 1 || cArgs == 2 || cArgs == 3);
|
---|
1580 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_STRING
|
---|
1581 | || paArgs[0].enmType == DBGCVAR_TYPE_SYMBOL);
|
---|
1582 |
|
---|
1583 | /*
|
---|
1584 | * Parse the register name and kind.
|
---|
1585 | */
|
---|
1586 | const char *pszReg = paArgs[0].u.pszString;
|
---|
1587 | if (*pszReg == '@')
|
---|
1588 | pszReg++;
|
---|
1589 | VMCPUID idCpu = pDbgc->idCpu;
|
---|
1590 | if (*pszPrefix)
|
---|
1591 | idCpu |= DBGFREG_HYPER_VMCPUID;
|
---|
1592 | if (*pszReg == '.')
|
---|
1593 | {
|
---|
1594 | pszReg++;
|
---|
1595 | idCpu |= DBGFREG_HYPER_VMCPUID;
|
---|
1596 | }
|
---|
1597 | const char * const pszActualPrefix = idCpu & DBGFREG_HYPER_VMCPUID ? "." : "";
|
---|
1598 |
|
---|
1599 | /*
|
---|
1600 | * Query the register type & value (the setter needs the type).
|
---|
1601 | */
|
---|
1602 | DBGFREGVALTYPE enmType;
|
---|
1603 | DBGFREGVAL Value;
|
---|
1604 | int rc = DBGFR3RegNmQuery(pUVM, idCpu, pszReg, &Value, &enmType);
|
---|
1605 | if (RT_FAILURE(rc))
|
---|
1606 | {
|
---|
1607 | if (rc == VERR_DBGF_REGISTER_NOT_FOUND)
|
---|
1608 | return DBGCCmdHlpVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "Unknown register: '%s%s'.\n",
|
---|
1609 | pszActualPrefix, pszReg);
|
---|
1610 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegNmQuery failed querying '%s%s': %Rrc.\n",
|
---|
1611 | pszActualPrefix, pszReg, rc);
|
---|
1612 | }
|
---|
1613 | if (cArgs == 1)
|
---|
1614 | {
|
---|
1615 | /*
|
---|
1616 | * Show the register.
|
---|
1617 | */
|
---|
1618 | char szValue[160];
|
---|
1619 | rc = DBGFR3RegFormatValue(szValue, sizeof(szValue), &Value, enmType, true /*fSpecial*/);
|
---|
1620 | if (RT_SUCCESS(rc))
|
---|
1621 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%s%s=%s\n", pszActualPrefix, pszReg, szValue);
|
---|
1622 | else
|
---|
1623 | rc = DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegFormatValue failed: %Rrc.\n", rc);
|
---|
1624 | }
|
---|
1625 | else
|
---|
1626 | {
|
---|
1627 | DBGCVAR NewValueTmp;
|
---|
1628 | PCDBGCVAR pNewValue;
|
---|
1629 | if (cArgs == 3)
|
---|
1630 | {
|
---|
1631 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 1, paArgs[1].enmType == DBGCVAR_TYPE_STRING);
|
---|
1632 | if (strcmp(paArgs[1].u.pszString, "="))
|
---|
1633 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Second argument must be '='.");
|
---|
1634 | pNewValue = &paArgs[2];
|
---|
1635 | }
|
---|
1636 | else
|
---|
1637 | {
|
---|
1638 | /* Not possible to convince the parser to support both codeview and
|
---|
1639 | windbg syntax and make the equal sign optional. Try help it. */
|
---|
1640 | /** @todo make DBGCCmdHlpConvert do more with strings. */
|
---|
1641 | rc = DBGCCmdHlpConvert(pCmdHlp, &paArgs[1], DBGCVAR_TYPE_NUMBER, true /*fConvSyms*/, &NewValueTmp);
|
---|
1642 | if (RT_FAILURE(rc))
|
---|
1643 | return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "The last argument must be a value or valid symbol.");
|
---|
1644 | pNewValue = &NewValueTmp;
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 | /*
|
---|
1648 | * Modify the register.
|
---|
1649 | */
|
---|
1650 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 1, pNewValue->enmType == DBGCVAR_TYPE_NUMBER);
|
---|
1651 | if (enmType != DBGFREGVALTYPE_DTR)
|
---|
1652 | {
|
---|
1653 | enmType = DBGFREGVALTYPE_U64;
|
---|
1654 | rc = DBGCCmdHlpVarToNumber(pCmdHlp, pNewValue, &Value.u64);
|
---|
1655 | }
|
---|
1656 | else
|
---|
1657 | {
|
---|
1658 | enmType = DBGFREGVALTYPE_DTR;
|
---|
1659 | rc = DBGCCmdHlpVarToNumber(pCmdHlp, pNewValue, &Value.dtr.u64Base);
|
---|
1660 | if (RT_SUCCESS(rc) && pNewValue->enmRangeType != DBGCVAR_RANGE_NONE)
|
---|
1661 | Value.dtr.u32Limit = (uint32_t)pNewValue->u64Range;
|
---|
1662 | }
|
---|
1663 | if (RT_SUCCESS(rc))
|
---|
1664 | {
|
---|
1665 | rc = DBGFR3RegNmSet(pUVM, idCpu, pszReg, &Value, enmType);
|
---|
1666 | if (RT_FAILURE(rc))
|
---|
1667 | rc = DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegNmSet failed settings '%s%s': %Rrc\n",
|
---|
1668 | pszActualPrefix, pszReg, rc);
|
---|
1669 | if (rc != VINF_SUCCESS)
|
---|
1670 | DBGCCmdHlpPrintf(pCmdHlp, "%s: warning: %Rrc\n", pCmd->pszCmd, rc);
|
---|
1671 | }
|
---|
1672 | else
|
---|
1673 | rc = DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegFormatValue failed: %Rrc.\n", rc);
|
---|
1674 | }
|
---|
1675 | return rc;
|
---|
1676 | }
|
---|
1677 |
|
---|
1678 |
|
---|
1679 | /**
|
---|
1680 | * @callback_method_impl{FNDBGCCMD,
|
---|
1681 | * The 'rg'\, 'rg64' and 'rg32' commands\, worker for 'r'.}
|
---|
1682 | */
|
---|
1683 | static DECLCALLBACK(int) dbgcCmdRegGuest(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1684 | {
|
---|
1685 | /*
|
---|
1686 | * Show all registers our selves.
|
---|
1687 | */
|
---|
1688 | if (cArgs == 0)
|
---|
1689 | {
|
---|
1690 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1691 | bool const f64BitMode = !strcmp(pCmd->pszCmd, "rg64")
|
---|
1692 | || ( strcmp(pCmd->pszCmd, "rg32") != 0
|
---|
1693 | && DBGFR3CpuIsIn64BitCode(pUVM, pDbgc->idCpu));
|
---|
1694 | char szDisAndRegs[8192];
|
---|
1695 | int rc;
|
---|
1696 |
|
---|
1697 | if (pDbgc->fRegTerse)
|
---|
1698 | {
|
---|
1699 | if (f64BitMode)
|
---|
1700 | rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, &szDisAndRegs[0], sizeof(szDisAndRegs),
|
---|
1701 | "u %016VR{rip} L 0\n"
|
---|
1702 | "rax=%016VR{rax} rbx=%016VR{rbx} rcx=%016VR{rcx} rdx=%016VR{rdx}\n"
|
---|
1703 | "rsi=%016VR{rsi} rdi=%016VR{rdi} r8 =%016VR{r8} r9 =%016VR{r9}\n"
|
---|
1704 | "r10=%016VR{r10} r11=%016VR{r11} r12=%016VR{r12} r13=%016VR{r13}\n"
|
---|
1705 | "r14=%016VR{r14} r15=%016VR{r15} %VRF{rflags}\n"
|
---|
1706 | "rip=%016VR{rip} rsp=%016VR{rsp} rbp=%016VR{rbp}\n"
|
---|
1707 | "cs=%04VR{cs} ds=%04VR{ds} es=%04VR{es} fs=%04VR{fs} gs=%04VR{gs} ss=%04VR{ss} rflags=%08VR{rflags}\n");
|
---|
1708 | else
|
---|
1709 | rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, szDisAndRegs, sizeof(szDisAndRegs),
|
---|
1710 | "u %04VR{cs}:%08VR{eip} L 0\n"
|
---|
1711 | "eax=%08VR{eax} ebx=%08VR{ebx} ecx=%08VR{ecx} edx=%08VR{edx} esi=%08VR{esi} edi=%08VR{edi}\n"
|
---|
1712 | "eip=%08VR{eip} esp=%08VR{esp} ebp=%08VR{ebp} %VRF{eflags}\n"
|
---|
1713 | "cs=%04VR{cs} ds=%04VR{ds} es=%04VR{es} fs=%04VR{fs} gs=%04VR{gs} ss=%04VR{ss} eflags=%08VR{eflags}\n");
|
---|
1714 | }
|
---|
1715 | else
|
---|
1716 | {
|
---|
1717 | if (f64BitMode)
|
---|
1718 | rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, &szDisAndRegs[0], sizeof(szDisAndRegs),
|
---|
1719 | "u %016VR{rip} L 0\n"
|
---|
1720 | "rax=%016VR{rax} rbx=%016VR{rbx} rcx=%016VR{rcx} rdx=%016VR{rdx}\n"
|
---|
1721 | "rsi=%016VR{rsi} rdi=%016VR{rdi} r8 =%016VR{r8} r9 =%016VR{r9}\n"
|
---|
1722 | "r10=%016VR{r10} r11=%016VR{r11} r12=%016VR{r12} r13=%016VR{r13}\n"
|
---|
1723 | "r14=%016VR{r14} r15=%016VR{r15} %VRF{rflags}\n"
|
---|
1724 | "rip=%016VR{rip} rsp=%016VR{rsp} rbp=%016VR{rbp}\n"
|
---|
1725 | "cs={%04VR{cs} base=%016VR{cs_base} limit=%08VR{cs_lim} flags=%04VR{cs_attr}} cr0=%016VR{cr0}\n"
|
---|
1726 | "ds={%04VR{ds} base=%016VR{ds_base} limit=%08VR{ds_lim} flags=%04VR{ds_attr}} cr2=%016VR{cr2}\n"
|
---|
1727 | "es={%04VR{es} base=%016VR{es_base} limit=%08VR{es_lim} flags=%04VR{es_attr}} cr3=%016VR{cr3}\n"
|
---|
1728 | "fs={%04VR{fs} base=%016VR{fs_base} limit=%08VR{fs_lim} flags=%04VR{fs_attr}} cr4=%016VR{cr4}\n"
|
---|
1729 | "gs={%04VR{gs} base=%016VR{gs_base} limit=%08VR{gs_lim} flags=%04VR{gs_attr}} cr8=%016VR{cr8}\n"
|
---|
1730 | "ss={%04VR{ss} base=%016VR{ss_base} limit=%08VR{ss_lim} flags=%04VR{ss_attr}}\n"
|
---|
1731 | "dr0=%016VR{dr0} dr1=%016VR{dr1} dr2=%016VR{dr2} dr3=%016VR{dr3}\n"
|
---|
1732 | "dr6=%016VR{dr6} dr7=%016VR{dr7}\n"
|
---|
1733 | "gdtr=%016VR{gdtr_base}:%04VR{gdtr_lim} idtr=%016VR{idtr_base}:%04VR{idtr_lim} rflags=%08VR{rflags}\n"
|
---|
1734 | "ldtr={%04VR{ldtr} base=%016VR{ldtr_base} limit=%08VR{ldtr_lim} flags=%08VR{ldtr_attr}}\n"
|
---|
1735 | "tr ={%04VR{tr} base=%016VR{tr_base} limit=%08VR{tr_lim} flags=%08VR{tr_attr}}\n"
|
---|
1736 | " sysenter={cs=%04VR{sysenter_cs} eip=%08VR{sysenter_eip} esp=%08VR{sysenter_esp}}\n"
|
---|
1737 | " efer=%016VR{efer}\n"
|
---|
1738 | " pat=%016VR{pat}\n"
|
---|
1739 | " sf_mask=%016VR{sf_mask}\n"
|
---|
1740 | "krnl_gs_base=%016VR{krnl_gs_base}\n"
|
---|
1741 | " lstar=%016VR{lstar}\n"
|
---|
1742 | " star=%016VR{star} cstar=%016VR{cstar}\n"
|
---|
1743 | "fcw=%04VR{fcw} fsw=%04VR{fsw} ftw=%04VR{ftw} mxcsr=%04VR{mxcsr} mxcsr_mask=%04VR{mxcsr_mask}\n"
|
---|
1744 | );
|
---|
1745 | else
|
---|
1746 | rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu, szDisAndRegs, sizeof(szDisAndRegs),
|
---|
1747 | "u %04VR{cs}:%08VR{eip} L 0\n"
|
---|
1748 | "eax=%08VR{eax} ebx=%08VR{ebx} ecx=%08VR{ecx} edx=%08VR{edx} esi=%08VR{esi} edi=%08VR{edi}\n"
|
---|
1749 | "eip=%08VR{eip} esp=%08VR{esp} ebp=%08VR{ebp} %VRF{eflags}\n"
|
---|
1750 | "cs={%04VR{cs} base=%08VR{cs_base} limit=%08VR{cs_lim} flags=%04VR{cs_attr}} dr0=%08VR{dr0} dr1=%08VR{dr1}\n"
|
---|
1751 | "ds={%04VR{ds} base=%08VR{ds_base} limit=%08VR{ds_lim} flags=%04VR{ds_attr}} dr2=%08VR{dr2} dr3=%08VR{dr3}\n"
|
---|
1752 | "es={%04VR{es} base=%08VR{es_base} limit=%08VR{es_lim} flags=%04VR{es_attr}} dr6=%08VR{dr6} dr7=%08VR{dr7}\n"
|
---|
1753 | "fs={%04VR{fs} base=%08VR{fs_base} limit=%08VR{fs_lim} flags=%04VR{fs_attr}} cr0=%08VR{cr0} cr2=%08VR{cr2}\n"
|
---|
1754 | "gs={%04VR{gs} base=%08VR{gs_base} limit=%08VR{gs_lim} flags=%04VR{gs_attr}} cr3=%08VR{cr3} cr4=%08VR{cr4}\n"
|
---|
1755 | "ss={%04VR{ss} base=%08VR{ss_base} limit=%08VR{ss_lim} flags=%04VR{ss_attr}} cr8=%08VR{cr8}\n"
|
---|
1756 | "gdtr=%08VR{gdtr_base}:%04VR{gdtr_lim} idtr=%08VR{idtr_base}:%04VR{idtr_lim} eflags=%08VR{eflags}\n"
|
---|
1757 | "ldtr={%04VR{ldtr} base=%08VR{ldtr_base} limit=%08VR{ldtr_lim} flags=%04VR{ldtr_attr}}\n"
|
---|
1758 | "tr ={%04VR{tr} base=%08VR{tr_base} limit=%08VR{tr_lim} flags=%04VR{tr_attr}}\n"
|
---|
1759 | "sysenter={cs=%04VR{sysenter_cs} eip=%08VR{sysenter_eip} esp=%08VR{sysenter_esp}}\n"
|
---|
1760 | "fcw=%04VR{fcw} fsw=%04VR{fsw} ftw=%04VR{ftw} mxcsr=%04VR{mxcsr} mxcsr_mask=%04VR{mxcsr_mask}\n"
|
---|
1761 | );
|
---|
1762 | }
|
---|
1763 | if (RT_FAILURE(rc))
|
---|
1764 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegPrintf failed");
|
---|
1765 | char *pszRegs = strchr(szDisAndRegs, '\n');
|
---|
1766 | *pszRegs++ = '\0';
|
---|
1767 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%s", pszRegs);
|
---|
1768 |
|
---|
1769 | /*
|
---|
1770 | * Disassemble one instruction at cs:[r|e]ip.
|
---|
1771 | */
|
---|
1772 | if (!f64BitMode && strstr(pszRegs, " vm ")) /* a big ugly... */
|
---|
1773 | return pCmdHlp->pfnExec(pCmdHlp, "uv86 %s", szDisAndRegs + 2);
|
---|
1774 | return pCmdHlp->pfnExec(pCmdHlp, "%s", szDisAndRegs);
|
---|
1775 | }
|
---|
1776 | return dbgcCmdRegCommon(pCmd, pCmdHlp, pUVM, paArgs, cArgs, "");
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 |
|
---|
1780 | /**
|
---|
1781 | * @callback_method_impl{FNDBGCCMD, The 'rh' command.}
|
---|
1782 | */
|
---|
1783 | static DECLCALLBACK(int) dbgcCmdRegHyper(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1784 | {
|
---|
1785 | /*
|
---|
1786 | * Show all registers our selves.
|
---|
1787 | */
|
---|
1788 | if (cArgs == 0)
|
---|
1789 | {
|
---|
1790 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1791 | char szDisAndRegs[8192];
|
---|
1792 | int rc;
|
---|
1793 |
|
---|
1794 | if (pDbgc->fRegTerse)
|
---|
1795 | rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu | DBGFREG_HYPER_VMCPUID, szDisAndRegs, sizeof(szDisAndRegs),
|
---|
1796 | "u %VR{cs}:%VR{eip} L 0\n"
|
---|
1797 | ".eax=%08VR{eax} .ebx=%08VR{ebx} .ecx=%08VR{ecx} .edx=%08VR{edx} .esi=%08VR{esi} .edi=%08VR{edi}\n"
|
---|
1798 | ".eip=%08VR{eip} .esp=%08VR{esp} .ebp=%08VR{ebp} .%VRF{eflags}\n"
|
---|
1799 | ".cs=%04VR{cs} .ds=%04VR{ds} .es=%04VR{es} .fs=%04VR{fs} .gs=%04VR{gs} .ss=%04VR{ss} .eflags=%08VR{eflags}\n");
|
---|
1800 | else
|
---|
1801 | rc = DBGFR3RegPrintf(pUVM, pDbgc->idCpu | DBGFREG_HYPER_VMCPUID, szDisAndRegs, sizeof(szDisAndRegs),
|
---|
1802 | "u %04VR{cs}:%08VR{eip} L 0\n"
|
---|
1803 | ".eax=%08VR{eax} .ebx=%08VR{ebx} .ecx=%08VR{ecx} .edx=%08VR{edx} .esi=%08VR{esi} .edi=%08VR{edi}\n"
|
---|
1804 | ".eip=%08VR{eip} .esp=%08VR{esp} .ebp=%08VR{ebp} .%VRF{eflags}\n"
|
---|
1805 | ".cs={%04VR{cs} base=%08VR{cs_base} limit=%08VR{cs_lim} flags=%04VR{cs_attr}} .dr0=%08VR{dr0} .dr1=%08VR{dr1}\n"
|
---|
1806 | ".ds={%04VR{ds} base=%08VR{ds_base} limit=%08VR{ds_lim} flags=%04VR{ds_attr}} .dr2=%08VR{dr2} .dr3=%08VR{dr3}\n"
|
---|
1807 | ".es={%04VR{es} base=%08VR{es_base} limit=%08VR{es_lim} flags=%04VR{es_attr}} .dr6=%08VR{dr6} .dr6=%08VR{dr6}\n"
|
---|
1808 | ".fs={%04VR{fs} base=%08VR{fs_base} limit=%08VR{fs_lim} flags=%04VR{fs_attr}} .cr3=%016VR{cr3}\n"
|
---|
1809 | ".gs={%04VR{gs} base=%08VR{gs_base} limit=%08VR{gs_lim} flags=%04VR{gs_attr}}\n"
|
---|
1810 | ".ss={%04VR{ss} base=%08VR{ss_base} limit=%08VR{ss_lim} flags=%04VR{ss_attr}}\n"
|
---|
1811 | ".gdtr=%08VR{gdtr_base}:%04VR{gdtr_lim} .idtr=%08VR{idtr_base}:%04VR{idtr_lim} .eflags=%08VR{eflags}\n"
|
---|
1812 | ".ldtr={%04VR{ldtr} base=%08VR{ldtr_base} limit=%08VR{ldtr_lim} flags=%04VR{ldtr_attr}}\n"
|
---|
1813 | ".tr ={%04VR{tr} base=%08VR{tr_base} limit=%08VR{tr_lim} flags=%04VR{tr_attr}}\n"
|
---|
1814 | );
|
---|
1815 | if (RT_FAILURE(rc))
|
---|
1816 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3RegPrintf failed");
|
---|
1817 | char *pszRegs = strchr(szDisAndRegs, '\n');
|
---|
1818 | *pszRegs++ = '\0';
|
---|
1819 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%s", pszRegs);
|
---|
1820 |
|
---|
1821 | /*
|
---|
1822 | * Disassemble one instruction at cs:[r|e]ip.
|
---|
1823 | */
|
---|
1824 | return pCmdHlp->pfnExec(pCmdHlp, "%s", szDisAndRegs);
|
---|
1825 | }
|
---|
1826 | return dbgcCmdRegCommon(pCmd, pCmdHlp, pUVM, paArgs, cArgs, ".");
|
---|
1827 | }
|
---|
1828 |
|
---|
1829 |
|
---|
1830 | /**
|
---|
1831 | * @callback_method_impl{FNDBGCCMD, The 'rt' command.}
|
---|
1832 | */
|
---|
1833 | static DECLCALLBACK(int) dbgcCmdRegTerse(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1834 | {
|
---|
1835 | NOREF(pCmd); NOREF(pUVM); NOREF(paArgs); NOREF(cArgs);
|
---|
1836 |
|
---|
1837 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1838 | pDbgc->fRegTerse = !pDbgc->fRegTerse;
|
---|
1839 | return DBGCCmdHlpPrintf(pCmdHlp, pDbgc->fRegTerse ? "info: Terse register info.\n" : "info: Verbose register info.\n");
|
---|
1840 | }
|
---|
1841 |
|
---|
1842 |
|
---|
1843 | /**
|
---|
1844 | * @callback_method_impl{FNDBGCCMD, The 't' command.}
|
---|
1845 | */
|
---|
1846 | static DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1847 | {
|
---|
1848 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1849 |
|
---|
1850 | int rc = DBGFR3Step(pUVM, pDbgc->idCpu);
|
---|
1851 | if (RT_SUCCESS(rc))
|
---|
1852 | pDbgc->fReady = false;
|
---|
1853 | else
|
---|
1854 | rc = pDbgc->CmdHlp.pfnVBoxError(&pDbgc->CmdHlp, rc, "When trying to single step VM %p\n", pDbgc->pVM);
|
---|
1855 |
|
---|
1856 | NOREF(pCmd); NOREF(paArgs); NOREF(cArgs);
|
---|
1857 | return rc;
|
---|
1858 | }
|
---|
1859 |
|
---|
1860 |
|
---|
1861 | /**
|
---|
1862 | * @callback_method_impl{FNDBGCCMD, The 'k'\, 'kg' and 'kh' commands.}
|
---|
1863 | */
|
---|
1864 | static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
1865 | {
|
---|
1866 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
1867 |
|
---|
1868 | /*
|
---|
1869 | * Figure which context we're called for and start walking that stack.
|
---|
1870 | */
|
---|
1871 | int rc;
|
---|
1872 | PCDBGFSTACKFRAME pFirstFrame;
|
---|
1873 | bool const fGuest = pCmd->pszCmd[1] == 'g'
|
---|
1874 | || (!pCmd->pszCmd[1] && pDbgc->fRegCtxGuest);
|
---|
1875 | rc = DBGFR3StackWalkBegin(pUVM, pDbgc->idCpu, fGuest ? DBGFCODETYPE_GUEST : DBGFCODETYPE_HYPER, &pFirstFrame);
|
---|
1876 | if (RT_FAILURE(rc))
|
---|
1877 | return DBGCCmdHlpPrintf(pCmdHlp, "Failed to begin stack walk, rc=%Rrc\n", rc);
|
---|
1878 |
|
---|
1879 | /*
|
---|
1880 | * Print header.
|
---|
1881 | * 12345678 12345678 0023:87654321 12345678 87654321 12345678 87654321 symbol
|
---|
1882 | */
|
---|
1883 | uint32_t fBitFlags = 0;
|
---|
1884 | for (PCDBGFSTACKFRAME pFrame = pFirstFrame;
|
---|
1885 | pFrame;
|
---|
1886 | pFrame = DBGFR3StackWalkNext(pFrame))
|
---|
1887 | {
|
---|
1888 | uint32_t const fCurBitFlags = pFrame->fFlags & (DBGFSTACKFRAME_FLAGS_16BIT | DBGFSTACKFRAME_FLAGS_32BIT | DBGFSTACKFRAME_FLAGS_64BIT);
|
---|
1889 | if (fCurBitFlags & DBGFSTACKFRAME_FLAGS_16BIT)
|
---|
1890 | {
|
---|
1891 | if (fCurBitFlags != fBitFlags)
|
---|
1892 | pCmdHlp->pfnPrintf(pCmdHlp, NULL, "SS:BP Ret SS:BP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP / Symbol [line]\n");
|
---|
1893 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04RX16:%04RX16 %04RX16:%04RX16 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
|
---|
1894 | pFrame->AddrFrame.Sel,
|
---|
1895 | (uint16_t)pFrame->AddrFrame.off,
|
---|
1896 | pFrame->AddrReturnFrame.Sel,
|
---|
1897 | (uint16_t)pFrame->AddrReturnFrame.off,
|
---|
1898 | (uint32_t)pFrame->AddrReturnPC.Sel,
|
---|
1899 | (uint32_t)pFrame->AddrReturnPC.off,
|
---|
1900 | pFrame->Args.au32[0],
|
---|
1901 | pFrame->Args.au32[1],
|
---|
1902 | pFrame->Args.au32[2],
|
---|
1903 | pFrame->Args.au32[3]);
|
---|
1904 | }
|
---|
1905 | else if (fCurBitFlags & DBGFSTACKFRAME_FLAGS_32BIT)
|
---|
1906 | {
|
---|
1907 | if (fCurBitFlags != fBitFlags)
|
---|
1908 | pCmdHlp->pfnPrintf(pCmdHlp, NULL, "EBP Ret EBP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP / Symbol [line]\n");
|
---|
1909 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%08RX32 %08RX32 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
|
---|
1910 | (uint32_t)pFrame->AddrFrame.off,
|
---|
1911 | (uint32_t)pFrame->AddrReturnFrame.off,
|
---|
1912 | (uint32_t)pFrame->AddrReturnPC.Sel,
|
---|
1913 | (uint32_t)pFrame->AddrReturnPC.off,
|
---|
1914 | pFrame->Args.au32[0],
|
---|
1915 | pFrame->Args.au32[1],
|
---|
1916 | pFrame->Args.au32[2],
|
---|
1917 | pFrame->Args.au32[3]);
|
---|
1918 | }
|
---|
1919 | else if (fCurBitFlags & DBGFSTACKFRAME_FLAGS_64BIT)
|
---|
1920 | {
|
---|
1921 | if (fCurBitFlags != fBitFlags)
|
---|
1922 | pCmdHlp->pfnPrintf(pCmdHlp, NULL, "RBP Ret SS:RBP Ret RIP CS:RIP / Symbol [line]\n");
|
---|
1923 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%016RX64 %04RX16:%016RX64 %016RX64",
|
---|
1924 | (uint64_t)pFrame->AddrFrame.off,
|
---|
1925 | pFrame->AddrReturnFrame.Sel,
|
---|
1926 | (uint64_t)pFrame->AddrReturnFrame.off,
|
---|
1927 | (uint64_t)pFrame->AddrReturnPC.off);
|
---|
1928 | }
|
---|
1929 | if (RT_FAILURE(rc))
|
---|
1930 | break;
|
---|
1931 | if (!pFrame->pSymPC)
|
---|
1932 | rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL,
|
---|
1933 | fCurBitFlags & DBGFSTACKFRAME_FLAGS_64BIT
|
---|
1934 | ? " %RTsel:%016RGv"
|
---|
1935 | : fCurBitFlags & DBGFSTACKFRAME_FLAGS_32BIT
|
---|
1936 | ? " %RTsel:%08RGv"
|
---|
1937 | : " %RTsel:%04RGv"
|
---|
1938 | , pFrame->AddrPC.Sel, pFrame->AddrPC.off);
|
---|
1939 | else
|
---|
1940 | {
|
---|
1941 | RTGCINTPTR offDisp = pFrame->AddrPC.FlatPtr - pFrame->pSymPC->Value; /** @todo this isn't 100% correct for segmented stuff. */
|
---|
1942 | if (offDisp > 0)
|
---|
1943 | rc = DBGCCmdHlpPrintf(pCmdHlp, " %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp);
|
---|
1944 | else if (offDisp < 0)
|
---|
1945 | rc = DBGCCmdHlpPrintf(pCmdHlp, " %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp);
|
---|
1946 | else
|
---|
1947 | rc = DBGCCmdHlpPrintf(pCmdHlp, " %s", pFrame->pSymPC->szName);
|
---|
1948 | }
|
---|
1949 | if (RT_SUCCESS(rc) && pFrame->pLinePC)
|
---|
1950 | rc = DBGCCmdHlpPrintf(pCmdHlp, " [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo);
|
---|
1951 | if (RT_SUCCESS(rc))
|
---|
1952 | rc = DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
1953 | if (RT_FAILURE(rc))
|
---|
1954 | break;
|
---|
1955 |
|
---|
1956 | fBitFlags = fCurBitFlags;
|
---|
1957 | }
|
---|
1958 |
|
---|
1959 | DBGFR3StackWalkEnd(pFirstFrame);
|
---|
1960 |
|
---|
1961 | NOREF(paArgs); NOREF(cArgs);
|
---|
1962 | return rc;
|
---|
1963 | }
|
---|
1964 |
|
---|
1965 |
|
---|
1966 | static int dbgcCmdDumpDTWorker64(PDBGCCMDHLP pCmdHlp, PCX86DESC64 pDesc, unsigned iEntry, bool fHyper, bool *pfDblEntry)
|
---|
1967 | {
|
---|
1968 | /* GUEST64 */
|
---|
1969 | int rc;
|
---|
1970 |
|
---|
1971 | const char *pszHyper = fHyper ? " HYPER" : "";
|
---|
1972 | const char *pszPresent = pDesc->Gen.u1Present ? "P " : "NP";
|
---|
1973 | if (pDesc->Gen.u1DescType)
|
---|
1974 | {
|
---|
1975 | static const char * const s_apszTypes[] =
|
---|
1976 | {
|
---|
1977 | "DataRO", /* 0 Read-Only */
|
---|
1978 | "DataRO", /* 1 Read-Only - Accessed */
|
---|
1979 | "DataRW", /* 2 Read/Write */
|
---|
1980 | "DataRW", /* 3 Read/Write - Accessed */
|
---|
1981 | "DownRO", /* 4 Expand-down, Read-Only */
|
---|
1982 | "DownRO", /* 5 Expand-down, Read-Only - Accessed */
|
---|
1983 | "DownRW", /* 6 Expand-down, Read/Write */
|
---|
1984 | "DownRW", /* 7 Expand-down, Read/Write - Accessed */
|
---|
1985 | "CodeEO", /* 8 Execute-Only */
|
---|
1986 | "CodeEO", /* 9 Execute-Only - Accessed */
|
---|
1987 | "CodeER", /* A Execute/Readable */
|
---|
1988 | "CodeER", /* B Execute/Readable - Accessed */
|
---|
1989 | "ConfE0", /* C Conforming, Execute-Only */
|
---|
1990 | "ConfE0", /* D Conforming, Execute-Only - Accessed */
|
---|
1991 | "ConfER", /* E Conforming, Execute/Readable */
|
---|
1992 | "ConfER" /* F Conforming, Execute/Readable - Accessed */
|
---|
1993 | };
|
---|
1994 | const char *pszAccessed = pDesc->Gen.u4Type & RT_BIT(0) ? "A " : "NA";
|
---|
1995 | const char *pszGranularity = pDesc->Gen.u1Granularity ? "G" : " ";
|
---|
1996 | const char *pszBig = pDesc->Gen.u1DefBig ? "BIG" : " ";
|
---|
1997 | uint32_t u32Base = X86DESC_BASE(pDesc);
|
---|
1998 | uint32_t cbLimit = X86DESC_LIMIT_G(pDesc);
|
---|
1999 |
|
---|
2000 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n",
|
---|
2001 | iEntry, s_apszTypes[pDesc->Gen.u4Type], u32Base, cbLimit,
|
---|
2002 | pDesc->Gen.u2Dpl, pszPresent, pszAccessed, pszGranularity, pszBig,
|
---|
2003 | pDesc->Gen.u1Available, pDesc->Gen.u1Long, pszHyper);
|
---|
2004 | }
|
---|
2005 | else
|
---|
2006 | {
|
---|
2007 | static const char * const s_apszTypes[] =
|
---|
2008 | {
|
---|
2009 | "Ill-0 ", /* 0 0000 Reserved (Illegal) */
|
---|
2010 | "Ill-1 ", /* 1 0001 Available 16-bit TSS */
|
---|
2011 | "LDT ", /* 2 0010 LDT */
|
---|
2012 | "Ill-3 ", /* 3 0011 Busy 16-bit TSS */
|
---|
2013 | "Ill-4 ", /* 4 0100 16-bit Call Gate */
|
---|
2014 | "Ill-5 ", /* 5 0101 Task Gate */
|
---|
2015 | "Ill-6 ", /* 6 0110 16-bit Interrupt Gate */
|
---|
2016 | "Ill-7 ", /* 7 0111 16-bit Trap Gate */
|
---|
2017 | "Ill-8 ", /* 8 1000 Reserved (Illegal) */
|
---|
2018 | "Tss64A", /* 9 1001 Available 32-bit TSS */
|
---|
2019 | "Ill-A ", /* A 1010 Reserved (Illegal) */
|
---|
2020 | "Tss64B", /* B 1011 Busy 32-bit TSS */
|
---|
2021 | "Call64", /* C 1100 32-bit Call Gate */
|
---|
2022 | "Ill-D ", /* D 1101 Reserved (Illegal) */
|
---|
2023 | "Int64 ", /* E 1110 32-bit Interrupt Gate */
|
---|
2024 | "Trap64" /* F 1111 32-bit Trap Gate */
|
---|
2025 | };
|
---|
2026 | switch (pDesc->Gen.u4Type)
|
---|
2027 | {
|
---|
2028 | /* raw */
|
---|
2029 | case X86_SEL_TYPE_SYS_UNDEFINED:
|
---|
2030 | case X86_SEL_TYPE_SYS_UNDEFINED2:
|
---|
2031 | case X86_SEL_TYPE_SYS_UNDEFINED4:
|
---|
2032 | case X86_SEL_TYPE_SYS_UNDEFINED3:
|
---|
2033 | case X86_SEL_TYPE_SYS_286_TSS_AVAIL:
|
---|
2034 | case X86_SEL_TYPE_SYS_286_TSS_BUSY:
|
---|
2035 | case X86_SEL_TYPE_SYS_286_CALL_GATE:
|
---|
2036 | case X86_SEL_TYPE_SYS_286_INT_GATE:
|
---|
2037 | case X86_SEL_TYPE_SYS_286_TRAP_GATE:
|
---|
2038 | case X86_SEL_TYPE_SYS_TASK_GATE:
|
---|
2039 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s %.8Rhxs DPL=%d %s%s\n",
|
---|
2040 | iEntry, s_apszTypes[pDesc->Gen.u4Type], pDesc,
|
---|
2041 | pDesc->Gen.u2Dpl, pszPresent, pszHyper);
|
---|
2042 | break;
|
---|
2043 |
|
---|
2044 | case X86_SEL_TYPE_SYS_386_TSS_AVAIL:
|
---|
2045 | case X86_SEL_TYPE_SYS_386_TSS_BUSY:
|
---|
2046 | case X86_SEL_TYPE_SYS_LDT:
|
---|
2047 | {
|
---|
2048 | const char *pszBusy = pDesc->Gen.u4Type & RT_BIT(1) ? "B " : "NB";
|
---|
2049 | const char *pszBig = pDesc->Gen.u1DefBig ? "BIG" : " ";
|
---|
2050 | const char *pszLong = pDesc->Gen.u1Long ? "LONG" : " ";
|
---|
2051 |
|
---|
2052 | uint64_t u64Base = X86DESC64_BASE(pDesc);
|
---|
2053 | uint32_t cbLimit = X86DESC_LIMIT_G(pDesc);
|
---|
2054 |
|
---|
2055 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%016RX64 Lim=%08x DPL=%d %s %s %s %sAVL=%d R=%d%s\n",
|
---|
2056 | iEntry, s_apszTypes[pDesc->Gen.u4Type], u64Base, cbLimit,
|
---|
2057 | pDesc->Gen.u2Dpl, pszPresent, pszBusy, pszLong, pszBig,
|
---|
2058 | pDesc->Gen.u1Available, pDesc->Gen.u1Long | (pDesc->Gen.u1DefBig << 1),
|
---|
2059 | pszHyper);
|
---|
2060 | if (pfDblEntry)
|
---|
2061 | *pfDblEntry = true;
|
---|
2062 | break;
|
---|
2063 | }
|
---|
2064 |
|
---|
2065 | case X86_SEL_TYPE_SYS_386_CALL_GATE:
|
---|
2066 | {
|
---|
2067 | unsigned cParams = pDesc->au8[4] & 0x1f;
|
---|
2068 | const char *pszCountOf = pDesc->Gen.u4Type & RT_BIT(3) ? "DC" : "WC";
|
---|
2069 | RTSEL sel = pDesc->au16[1];
|
---|
2070 | uint64_t off = pDesc->au16[0]
|
---|
2071 | | ((uint64_t)pDesc->au16[3] << 16)
|
---|
2072 | | ((uint64_t)pDesc->Gen.u32BaseHigh3 << 32);
|
---|
2073 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%016RX64 DPL=%d %s %s=%d%s\n",
|
---|
2074 | iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off,
|
---|
2075 | pDesc->Gen.u2Dpl, pszPresent, pszCountOf, cParams, pszHyper);
|
---|
2076 | if (pfDblEntry)
|
---|
2077 | *pfDblEntry = true;
|
---|
2078 | break;
|
---|
2079 | }
|
---|
2080 |
|
---|
2081 | case X86_SEL_TYPE_SYS_386_INT_GATE:
|
---|
2082 | case X86_SEL_TYPE_SYS_386_TRAP_GATE:
|
---|
2083 | {
|
---|
2084 | RTSEL sel = pDesc->Gate.u16Sel;
|
---|
2085 | uint64_t off = pDesc->Gate.u16OffsetLow
|
---|
2086 | | ((uint64_t)pDesc->Gate.u16OffsetHigh << 16)
|
---|
2087 | | ((uint64_t)pDesc->Gate.u32OffsetTop << 32);
|
---|
2088 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%016RX64 DPL=%u %s IST=%u%s\n",
|
---|
2089 | iEntry, s_apszTypes[pDesc->Gate.u4Type], sel, off,
|
---|
2090 | pDesc->Gate.u2Dpl, pszPresent, pDesc->Gate.u3IST, pszHyper);
|
---|
2091 | if (pfDblEntry)
|
---|
2092 | *pfDblEntry = true;
|
---|
2093 | break;
|
---|
2094 | }
|
---|
2095 |
|
---|
2096 | /* impossible, just it's necessary to keep gcc happy. */
|
---|
2097 | default:
|
---|
2098 | return VINF_SUCCESS;
|
---|
2099 | }
|
---|
2100 | }
|
---|
2101 | return VINF_SUCCESS;
|
---|
2102 | }
|
---|
2103 |
|
---|
2104 |
|
---|
2105 | /**
|
---|
2106 | * Worker function that displays one descriptor entry (GDT, LDT, IDT).
|
---|
2107 | *
|
---|
2108 | * @returns pfnPrintf status code.
|
---|
2109 | * @param pCmdHlp The DBGC command helpers.
|
---|
2110 | * @param pDesc The descriptor to display.
|
---|
2111 | * @param iEntry The descriptor entry number.
|
---|
2112 | * @param fHyper Whether the selector belongs to the hypervisor or not.
|
---|
2113 | */
|
---|
2114 | static int dbgcCmdDumpDTWorker32(PDBGCCMDHLP pCmdHlp, PCX86DESC pDesc, unsigned iEntry, bool fHyper)
|
---|
2115 | {
|
---|
2116 | int rc;
|
---|
2117 |
|
---|
2118 | const char *pszHyper = fHyper ? " HYPER" : "";
|
---|
2119 | const char *pszPresent = pDesc->Gen.u1Present ? "P " : "NP";
|
---|
2120 | if (pDesc->Gen.u1DescType)
|
---|
2121 | {
|
---|
2122 | static const char * const s_apszTypes[] =
|
---|
2123 | {
|
---|
2124 | "DataRO", /* 0 Read-Only */
|
---|
2125 | "DataRO", /* 1 Read-Only - Accessed */
|
---|
2126 | "DataRW", /* 2 Read/Write */
|
---|
2127 | "DataRW", /* 3 Read/Write - Accessed */
|
---|
2128 | "DownRO", /* 4 Expand-down, Read-Only */
|
---|
2129 | "DownRO", /* 5 Expand-down, Read-Only - Accessed */
|
---|
2130 | "DownRW", /* 6 Expand-down, Read/Write */
|
---|
2131 | "DownRW", /* 7 Expand-down, Read/Write - Accessed */
|
---|
2132 | "CodeEO", /* 8 Execute-Only */
|
---|
2133 | "CodeEO", /* 9 Execute-Only - Accessed */
|
---|
2134 | "CodeER", /* A Execute/Readable */
|
---|
2135 | "CodeER", /* B Execute/Readable - Accessed */
|
---|
2136 | "ConfE0", /* C Conforming, Execute-Only */
|
---|
2137 | "ConfE0", /* D Conforming, Execute-Only - Accessed */
|
---|
2138 | "ConfER", /* E Conforming, Execute/Readable */
|
---|
2139 | "ConfER" /* F Conforming, Execute/Readable - Accessed */
|
---|
2140 | };
|
---|
2141 | const char *pszAccessed = pDesc->Gen.u4Type & RT_BIT(0) ? "A " : "NA";
|
---|
2142 | const char *pszGranularity = pDesc->Gen.u1Granularity ? "G" : " ";
|
---|
2143 | const char *pszBig = pDesc->Gen.u1DefBig ? "BIG" : " ";
|
---|
2144 | uint32_t u32Base = pDesc->Gen.u16BaseLow
|
---|
2145 | | ((uint32_t)pDesc->Gen.u8BaseHigh1 << 16)
|
---|
2146 | | ((uint32_t)pDesc->Gen.u8BaseHigh2 << 24);
|
---|
2147 | uint32_t cbLimit = pDesc->Gen.u16LimitLow | (pDesc->Gen.u4LimitHigh << 16);
|
---|
2148 | if (pDesc->Gen.u1Granularity)
|
---|
2149 | cbLimit <<= PAGE_SHIFT;
|
---|
2150 |
|
---|
2151 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d L=%d%s\n",
|
---|
2152 | iEntry, s_apszTypes[pDesc->Gen.u4Type], u32Base, cbLimit,
|
---|
2153 | pDesc->Gen.u2Dpl, pszPresent, pszAccessed, pszGranularity, pszBig,
|
---|
2154 | pDesc->Gen.u1Available, pDesc->Gen.u1Long, pszHyper);
|
---|
2155 | }
|
---|
2156 | else
|
---|
2157 | {
|
---|
2158 | static const char * const s_apszTypes[] =
|
---|
2159 | {
|
---|
2160 | "Ill-0 ", /* 0 0000 Reserved (Illegal) */
|
---|
2161 | "Tss16A", /* 1 0001 Available 16-bit TSS */
|
---|
2162 | "LDT ", /* 2 0010 LDT */
|
---|
2163 | "Tss16B", /* 3 0011 Busy 16-bit TSS */
|
---|
2164 | "Call16", /* 4 0100 16-bit Call Gate */
|
---|
2165 | "TaskG ", /* 5 0101 Task Gate */
|
---|
2166 | "Int16 ", /* 6 0110 16-bit Interrupt Gate */
|
---|
2167 | "Trap16", /* 7 0111 16-bit Trap Gate */
|
---|
2168 | "Ill-8 ", /* 8 1000 Reserved (Illegal) */
|
---|
2169 | "Tss32A", /* 9 1001 Available 32-bit TSS */
|
---|
2170 | "Ill-A ", /* A 1010 Reserved (Illegal) */
|
---|
2171 | "Tss32B", /* B 1011 Busy 32-bit TSS */
|
---|
2172 | "Call32", /* C 1100 32-bit Call Gate */
|
---|
2173 | "Ill-D ", /* D 1101 Reserved (Illegal) */
|
---|
2174 | "Int32 ", /* E 1110 32-bit Interrupt Gate */
|
---|
2175 | "Trap32" /* F 1111 32-bit Trap Gate */
|
---|
2176 | };
|
---|
2177 | switch (pDesc->Gen.u4Type)
|
---|
2178 | {
|
---|
2179 | /* raw */
|
---|
2180 | case X86_SEL_TYPE_SYS_UNDEFINED:
|
---|
2181 | case X86_SEL_TYPE_SYS_UNDEFINED2:
|
---|
2182 | case X86_SEL_TYPE_SYS_UNDEFINED4:
|
---|
2183 | case X86_SEL_TYPE_SYS_UNDEFINED3:
|
---|
2184 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s %.8Rhxs DPL=%d %s%s\n",
|
---|
2185 | iEntry, s_apszTypes[pDesc->Gen.u4Type], pDesc,
|
---|
2186 | pDesc->Gen.u2Dpl, pszPresent, pszHyper);
|
---|
2187 | break;
|
---|
2188 |
|
---|
2189 | case X86_SEL_TYPE_SYS_286_TSS_AVAIL:
|
---|
2190 | case X86_SEL_TYPE_SYS_386_TSS_AVAIL:
|
---|
2191 | case X86_SEL_TYPE_SYS_286_TSS_BUSY:
|
---|
2192 | case X86_SEL_TYPE_SYS_386_TSS_BUSY:
|
---|
2193 | case X86_SEL_TYPE_SYS_LDT:
|
---|
2194 | {
|
---|
2195 | const char *pszGranularity = pDesc->Gen.u1Granularity ? "G" : " ";
|
---|
2196 | const char *pszBusy = pDesc->Gen.u4Type & RT_BIT(1) ? "B " : "NB";
|
---|
2197 | const char *pszBig = pDesc->Gen.u1DefBig ? "BIG" : " ";
|
---|
2198 | uint32_t u32Base = pDesc->Gen.u16BaseLow
|
---|
2199 | | ((uint32_t)pDesc->Gen.u8BaseHigh1 << 16)
|
---|
2200 | | ((uint32_t)pDesc->Gen.u8BaseHigh2 << 24);
|
---|
2201 | uint32_t cbLimit = pDesc->Gen.u16LimitLow | (pDesc->Gen.u4LimitHigh << 16);
|
---|
2202 | if (pDesc->Gen.u1Granularity)
|
---|
2203 | cbLimit <<= PAGE_SHIFT;
|
---|
2204 |
|
---|
2205 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Bas=%08x Lim=%08x DPL=%d %s %s %s %s AVL=%d R=%d%s\n",
|
---|
2206 | iEntry, s_apszTypes[pDesc->Gen.u4Type], u32Base, cbLimit,
|
---|
2207 | pDesc->Gen.u2Dpl, pszPresent, pszBusy, pszGranularity, pszBig,
|
---|
2208 | pDesc->Gen.u1Available, pDesc->Gen.u1Long | (pDesc->Gen.u1DefBig << 1),
|
---|
2209 | pszHyper);
|
---|
2210 | break;
|
---|
2211 | }
|
---|
2212 |
|
---|
2213 | case X86_SEL_TYPE_SYS_TASK_GATE:
|
---|
2214 | {
|
---|
2215 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s TSS=%04x DPL=%d %s%s\n",
|
---|
2216 | iEntry, s_apszTypes[pDesc->Gen.u4Type], pDesc->au16[1],
|
---|
2217 | pDesc->Gen.u2Dpl, pszPresent, pszHyper);
|
---|
2218 | break;
|
---|
2219 | }
|
---|
2220 |
|
---|
2221 | case X86_SEL_TYPE_SYS_286_CALL_GATE:
|
---|
2222 | case X86_SEL_TYPE_SYS_386_CALL_GATE:
|
---|
2223 | {
|
---|
2224 | unsigned cParams = pDesc->au8[4] & 0x1f;
|
---|
2225 | const char *pszCountOf = pDesc->Gen.u4Type & RT_BIT(3) ? "DC" : "WC";
|
---|
2226 | RTSEL sel = pDesc->au16[1];
|
---|
2227 | uint32_t off = pDesc->au16[0] | ((uint32_t)pDesc->au16[3] << 16);
|
---|
2228 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%08x DPL=%d %s %s=%d%s\n",
|
---|
2229 | iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off,
|
---|
2230 | pDesc->Gen.u2Dpl, pszPresent, pszCountOf, cParams, pszHyper);
|
---|
2231 | break;
|
---|
2232 | }
|
---|
2233 |
|
---|
2234 | case X86_SEL_TYPE_SYS_286_INT_GATE:
|
---|
2235 | case X86_SEL_TYPE_SYS_386_INT_GATE:
|
---|
2236 | case X86_SEL_TYPE_SYS_286_TRAP_GATE:
|
---|
2237 | case X86_SEL_TYPE_SYS_386_TRAP_GATE:
|
---|
2238 | {
|
---|
2239 | RTSEL sel = pDesc->au16[1];
|
---|
2240 | uint32_t off = pDesc->au16[0] | ((uint32_t)pDesc->au16[3] << 16);
|
---|
2241 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %s Sel:Off=%04x:%08x DPL=%d %s%s\n",
|
---|
2242 | iEntry, s_apszTypes[pDesc->Gen.u4Type], sel, off,
|
---|
2243 | pDesc->Gen.u2Dpl, pszPresent, pszHyper);
|
---|
2244 | break;
|
---|
2245 | }
|
---|
2246 |
|
---|
2247 | /* impossible, just it's necessary to keep gcc happy. */
|
---|
2248 | default:
|
---|
2249 | return VINF_SUCCESS;
|
---|
2250 | }
|
---|
2251 | }
|
---|
2252 | return rc;
|
---|
2253 | }
|
---|
2254 |
|
---|
2255 |
|
---|
2256 | /**
|
---|
2257 | * @callback_method_impl{FNDBGCCMD, The 'dg'\, 'dga'\, 'dl' and 'dla' commands.}
|
---|
2258 | */
|
---|
2259 | static DECLCALLBACK(int) dbgcCmdDumpDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
2260 | {
|
---|
2261 | /*
|
---|
2262 | * Validate input.
|
---|
2263 | */
|
---|
2264 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
2265 |
|
---|
2266 | /*
|
---|
2267 | * Get the CPU mode, check which command variation this is
|
---|
2268 | * and fix a default parameter if needed.
|
---|
2269 | */
|
---|
2270 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
2271 | PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu);
|
---|
2272 | CPUMMODE enmMode = CPUMGetGuestMode(pVCpu);
|
---|
2273 | bool fGdt = pCmd->pszCmd[1] == 'g';
|
---|
2274 | bool fAll = pCmd->pszCmd[2] == 'a';
|
---|
2275 | RTSEL SelTable = fGdt ? 0 : X86_SEL_LDT;
|
---|
2276 |
|
---|
2277 | DBGCVAR Var;
|
---|
2278 | if (!cArgs)
|
---|
2279 | {
|
---|
2280 | cArgs = 1;
|
---|
2281 | paArgs = &Var;
|
---|
2282 | Var.enmType = DBGCVAR_TYPE_NUMBER;
|
---|
2283 | Var.u.u64Number = 0;
|
---|
2284 | Var.enmRangeType = DBGCVAR_RANGE_ELEMENTS;
|
---|
2285 | Var.u64Range = 1024;
|
---|
2286 | }
|
---|
2287 |
|
---|
2288 | /*
|
---|
2289 | * Process the arguments.
|
---|
2290 | */
|
---|
2291 | for (unsigned i = 0; i < cArgs; i++)
|
---|
2292 | {
|
---|
2293 | /*
|
---|
2294 | * Retrieve the selector value from the argument.
|
---|
2295 | * The parser may confuse pointers and numbers if more than one
|
---|
2296 | * argument is given, that that into account.
|
---|
2297 | */
|
---|
2298 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, i, paArgs[i].enmType == DBGCVAR_TYPE_NUMBER || DBGCVAR_ISPOINTER(paArgs[i].enmType));
|
---|
2299 | uint64_t u64;
|
---|
2300 | unsigned cSels = 1;
|
---|
2301 | switch (paArgs[i].enmType)
|
---|
2302 | {
|
---|
2303 | case DBGCVAR_TYPE_NUMBER:
|
---|
2304 | u64 = paArgs[i].u.u64Number;
|
---|
2305 | if (paArgs[i].enmRangeType != DBGCVAR_RANGE_NONE)
|
---|
2306 | cSels = RT_MIN(paArgs[i].u64Range, 1024);
|
---|
2307 | break;
|
---|
2308 | case DBGCVAR_TYPE_GC_FAR: u64 = paArgs[i].u.GCFar.sel; break;
|
---|
2309 | case DBGCVAR_TYPE_GC_FLAT: u64 = paArgs[i].u.GCFlat; break;
|
---|
2310 | case DBGCVAR_TYPE_GC_PHYS: u64 = paArgs[i].u.GCPhys; break;
|
---|
2311 | case DBGCVAR_TYPE_HC_FLAT: u64 = (uintptr_t)paArgs[i].u.pvHCFlat; break;
|
---|
2312 | case DBGCVAR_TYPE_HC_PHYS: u64 = paArgs[i].u.HCPhys; break;
|
---|
2313 | default: u64 = _64K; break;
|
---|
2314 | }
|
---|
2315 | if (u64 < _64K)
|
---|
2316 | {
|
---|
2317 | unsigned Sel = (RTSEL)u64;
|
---|
2318 |
|
---|
2319 | /*
|
---|
2320 | * Dump the specified range.
|
---|
2321 | */
|
---|
2322 | bool fSingle = cSels == 1;
|
---|
2323 | while ( cSels-- > 0
|
---|
2324 | && Sel < _64K)
|
---|
2325 | {
|
---|
2326 | DBGFSELINFO SelInfo;
|
---|
2327 | int rc = DBGFR3SelQueryInfo(pUVM, pDbgc->idCpu, Sel | SelTable, DBGFSELQI_FLAGS_DT_GUEST, &SelInfo);
|
---|
2328 | if (RT_SUCCESS(rc))
|
---|
2329 | {
|
---|
2330 | if (SelInfo.fFlags & DBGFSELINFO_FLAGS_REAL_MODE)
|
---|
2331 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x RealM Bas=%04x Lim=%04x\n",
|
---|
2332 | Sel, (unsigned)SelInfo.GCPtrBase, (unsigned)SelInfo.cbLimit);
|
---|
2333 | else if ( fAll
|
---|
2334 | || fSingle
|
---|
2335 | || SelInfo.u.Raw.Gen.u1Present)
|
---|
2336 | {
|
---|
2337 | if (enmMode == CPUMMODE_PROTECTED)
|
---|
2338 | rc = dbgcCmdDumpDTWorker32(pCmdHlp, &SelInfo.u.Raw, Sel, !!(SelInfo.fFlags & DBGFSELINFO_FLAGS_HYPER));
|
---|
2339 | else
|
---|
2340 | {
|
---|
2341 | bool fDblSkip = false;
|
---|
2342 | rc = dbgcCmdDumpDTWorker64(pCmdHlp, &SelInfo.u.Raw64, Sel, !!(SelInfo.fFlags & DBGFSELINFO_FLAGS_HYPER), &fDblSkip);
|
---|
2343 | if (fDblSkip)
|
---|
2344 | Sel += 4;
|
---|
2345 | }
|
---|
2346 | }
|
---|
2347 | }
|
---|
2348 | else
|
---|
2349 | {
|
---|
2350 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %Rrc\n", Sel, rc);
|
---|
2351 | if (!fAll)
|
---|
2352 | return rc;
|
---|
2353 | }
|
---|
2354 | if (RT_FAILURE(rc))
|
---|
2355 | return rc;
|
---|
2356 |
|
---|
2357 | /* next */
|
---|
2358 | Sel += 8;
|
---|
2359 | }
|
---|
2360 | }
|
---|
2361 | else
|
---|
2362 | DBGCCmdHlpPrintf(pCmdHlp, "error: %llx is out of bounds\n", u64);
|
---|
2363 | }
|
---|
2364 |
|
---|
2365 | return VINF_SUCCESS;
|
---|
2366 | }
|
---|
2367 |
|
---|
2368 |
|
---|
2369 | /**
|
---|
2370 | * @callback_method_impl{FNDBGCCMD, The 'di' and 'dia' commands.}
|
---|
2371 | */
|
---|
2372 | static DECLCALLBACK(int) dbgcCmdDumpIDT(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
2373 | {
|
---|
2374 | /*
|
---|
2375 | * Validate input.
|
---|
2376 | */
|
---|
2377 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
2378 |
|
---|
2379 | /*
|
---|
2380 | * Establish some stuff like the current IDTR and CPU mode,
|
---|
2381 | * and fix a default parameter.
|
---|
2382 | */
|
---|
2383 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
2384 | PVMCPU pVCpu = VMMR3GetCpuByIdU(pUVM, pDbgc->idCpu);
|
---|
2385 | uint16_t cbLimit;
|
---|
2386 | RTGCUINTPTR GCPtrBase = CPUMGetGuestIDTR(pVCpu, &cbLimit);
|
---|
2387 | CPUMMODE enmMode = CPUMGetGuestMode(pVCpu);
|
---|
2388 | unsigned cbEntry;
|
---|
2389 | switch (enmMode)
|
---|
2390 | {
|
---|
2391 | case CPUMMODE_REAL: cbEntry = sizeof(RTFAR16); break;
|
---|
2392 | case CPUMMODE_PROTECTED: cbEntry = sizeof(X86DESC); break;
|
---|
2393 | case CPUMMODE_LONG: cbEntry = sizeof(X86DESC64); break;
|
---|
2394 | default:
|
---|
2395 | return DBGCCmdHlpPrintf(pCmdHlp, "error: Invalid CPU mode %d.\n", enmMode);
|
---|
2396 | }
|
---|
2397 |
|
---|
2398 | bool fAll = pCmd->pszCmd[2] == 'a';
|
---|
2399 | DBGCVAR Var;
|
---|
2400 | if (!cArgs)
|
---|
2401 | {
|
---|
2402 | cArgs = 1;
|
---|
2403 | paArgs = &Var;
|
---|
2404 | Var.enmType = DBGCVAR_TYPE_NUMBER;
|
---|
2405 | Var.u.u64Number = 0;
|
---|
2406 | Var.enmRangeType = DBGCVAR_RANGE_ELEMENTS;
|
---|
2407 | Var.u64Range = 256;
|
---|
2408 | }
|
---|
2409 |
|
---|
2410 | /*
|
---|
2411 | * Process the arguments.
|
---|
2412 | */
|
---|
2413 | for (unsigned i = 0; i < cArgs; i++)
|
---|
2414 | {
|
---|
2415 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, i, paArgs[i].enmType == DBGCVAR_TYPE_NUMBER);
|
---|
2416 | if (paArgs[i].u.u64Number < 256)
|
---|
2417 | {
|
---|
2418 | RTGCUINTPTR iInt = (RTGCUINTPTR)paArgs[i].u.u64Number;
|
---|
2419 | unsigned cInts = paArgs[i].enmRangeType != DBGCVAR_RANGE_NONE
|
---|
2420 | ? paArgs[i].u64Range
|
---|
2421 | : 1;
|
---|
2422 | bool fSingle = cInts == 1;
|
---|
2423 | while ( cInts-- > 0
|
---|
2424 | && iInt < 256)
|
---|
2425 | {
|
---|
2426 | /*
|
---|
2427 | * Try read it.
|
---|
2428 | */
|
---|
2429 | union
|
---|
2430 | {
|
---|
2431 | RTFAR16 Real;
|
---|
2432 | X86DESC Prot;
|
---|
2433 | X86DESC64 Long;
|
---|
2434 | } u;
|
---|
2435 | if (iInt * cbEntry + (cbEntry - 1) > cbLimit)
|
---|
2436 | {
|
---|
2437 | DBGCCmdHlpPrintf(pCmdHlp, "%04x not within the IDT\n", (unsigned)iInt);
|
---|
2438 | if (!fAll && !fSingle)
|
---|
2439 | return VINF_SUCCESS;
|
---|
2440 | }
|
---|
2441 | DBGCVAR AddrVar;
|
---|
2442 | AddrVar.enmType = DBGCVAR_TYPE_GC_FLAT;
|
---|
2443 | AddrVar.u.GCFlat = GCPtrBase + iInt * cbEntry;
|
---|
2444 | AddrVar.enmRangeType = DBGCVAR_RANGE_NONE;
|
---|
2445 | int rc = pCmdHlp->pfnMemRead(pCmdHlp, &u, cbEntry, &AddrVar, NULL);
|
---|
2446 | if (RT_FAILURE(rc))
|
---|
2447 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Reading IDT entry %#04x.\n", (unsigned)iInt);
|
---|
2448 |
|
---|
2449 | /*
|
---|
2450 | * Display it.
|
---|
2451 | */
|
---|
2452 | switch (enmMode)
|
---|
2453 | {
|
---|
2454 | case CPUMMODE_REAL:
|
---|
2455 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%04x %RTfp16\n", (unsigned)iInt, u.Real);
|
---|
2456 | /** @todo resolve 16:16 IDTE to a symbol */
|
---|
2457 | break;
|
---|
2458 | case CPUMMODE_PROTECTED:
|
---|
2459 | if (fAll || fSingle || u.Prot.Gen.u1Present)
|
---|
2460 | rc = dbgcCmdDumpDTWorker32(pCmdHlp, &u.Prot, iInt, false);
|
---|
2461 | break;
|
---|
2462 | case CPUMMODE_LONG:
|
---|
2463 | if (fAll || fSingle || u.Long.Gen.u1Present)
|
---|
2464 | rc = dbgcCmdDumpDTWorker64(pCmdHlp, &u.Long, iInt, false, NULL);
|
---|
2465 | break;
|
---|
2466 | default: break; /* to shut up gcc */
|
---|
2467 | }
|
---|
2468 | if (RT_FAILURE(rc))
|
---|
2469 | return rc;
|
---|
2470 |
|
---|
2471 | /* next */
|
---|
2472 | iInt++;
|
---|
2473 | }
|
---|
2474 | }
|
---|
2475 | else
|
---|
2476 | DBGCCmdHlpPrintf(pCmdHlp, "error: %llx is out of bounds (max 256)\n", paArgs[i].u.u64Number);
|
---|
2477 | }
|
---|
2478 |
|
---|
2479 | return VINF_SUCCESS;
|
---|
2480 | }
|
---|
2481 |
|
---|
2482 |
|
---|
2483 | /**
|
---|
2484 | * @callback_method_impl{FNDBGCCMD,
|
---|
2485 | * The 'da'\, 'dq'\, 'dd'\, 'dw' and 'db' commands.}
|
---|
2486 | */
|
---|
2487 | static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
2488 | {
|
---|
2489 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
2490 |
|
---|
2491 | /*
|
---|
2492 | * Validate input.
|
---|
2493 | */
|
---|
2494 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1);
|
---|
2495 | if (cArgs == 1)
|
---|
2496 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
2497 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
2498 |
|
---|
2499 | /*
|
---|
2500 | * Figure out the element size.
|
---|
2501 | */
|
---|
2502 | unsigned cbElement;
|
---|
2503 | bool fAscii = false;
|
---|
2504 | switch (pCmd->pszCmd[1])
|
---|
2505 | {
|
---|
2506 | default:
|
---|
2507 | case 'b': cbElement = 1; break;
|
---|
2508 | case 'w': cbElement = 2; break;
|
---|
2509 | case 'd': cbElement = 4; break;
|
---|
2510 | case 'q': cbElement = 8; break;
|
---|
2511 | case 'a':
|
---|
2512 | cbElement = 1;
|
---|
2513 | fAscii = true;
|
---|
2514 | break;
|
---|
2515 | case '\0':
|
---|
2516 | fAscii = !!(pDbgc->cbDumpElement & 0x80000000);
|
---|
2517 | cbElement = pDbgc->cbDumpElement & 0x7fffffff;
|
---|
2518 | if (!cbElement)
|
---|
2519 | cbElement = 1;
|
---|
2520 | break;
|
---|
2521 | }
|
---|
2522 |
|
---|
2523 | /*
|
---|
2524 | * Find address.
|
---|
2525 | */
|
---|
2526 | if (!cArgs)
|
---|
2527 | pDbgc->DumpPos.enmRangeType = DBGCVAR_RANGE_NONE;
|
---|
2528 | else
|
---|
2529 | pDbgc->DumpPos = paArgs[0];
|
---|
2530 |
|
---|
2531 | /*
|
---|
2532 | * Range.
|
---|
2533 | */
|
---|
2534 | switch (pDbgc->DumpPos.enmRangeType)
|
---|
2535 | {
|
---|
2536 | case DBGCVAR_RANGE_NONE:
|
---|
2537 | pDbgc->DumpPos.enmRangeType = DBGCVAR_RANGE_BYTES;
|
---|
2538 | pDbgc->DumpPos.u64Range = 0x60;
|
---|
2539 | break;
|
---|
2540 |
|
---|
2541 | case DBGCVAR_RANGE_ELEMENTS:
|
---|
2542 | if (pDbgc->DumpPos.u64Range > 2048)
|
---|
2543 | return DBGCCmdHlpPrintf(pCmdHlp, "error: Too many elements requested. Max is 2048 elements.\n");
|
---|
2544 | pDbgc->DumpPos.enmRangeType = DBGCVAR_RANGE_BYTES;
|
---|
2545 | pDbgc->DumpPos.u64Range = (cbElement ? cbElement : 1) * pDbgc->DumpPos.u64Range;
|
---|
2546 | break;
|
---|
2547 |
|
---|
2548 | case DBGCVAR_RANGE_BYTES:
|
---|
2549 | if (pDbgc->DumpPos.u64Range > 65536)
|
---|
2550 | return DBGCCmdHlpPrintf(pCmdHlp, "error: The requested range is too big. Max is 64KB.\n");
|
---|
2551 | break;
|
---|
2552 |
|
---|
2553 | default:
|
---|
2554 | return DBGCCmdHlpPrintf(pCmdHlp, "internal error: Unknown range type %d.\n", pDbgc->DumpPos.enmRangeType);
|
---|
2555 | }
|
---|
2556 |
|
---|
2557 | pDbgc->pLastPos = &pDbgc->DumpPos;
|
---|
2558 |
|
---|
2559 | /*
|
---|
2560 | * Do the dumping.
|
---|
2561 | */
|
---|
2562 | pDbgc->cbDumpElement = cbElement | (fAscii << 31);
|
---|
2563 | int cbLeft = (int)pDbgc->DumpPos.u64Range;
|
---|
2564 | uint8_t u8Prev = '\0';
|
---|
2565 | for (;;)
|
---|
2566 | {
|
---|
2567 | /*
|
---|
2568 | * Read memory.
|
---|
2569 | */
|
---|
2570 | char achBuffer[16];
|
---|
2571 | size_t cbReq = RT_MIN((int)sizeof(achBuffer), cbLeft);
|
---|
2572 | size_t cb = RT_MIN((int)sizeof(achBuffer), cbLeft);
|
---|
2573 | int rc = pCmdHlp->pfnMemRead(pCmdHlp, &achBuffer, cbReq, &pDbgc->DumpPos, &cb);
|
---|
2574 | if (RT_FAILURE(rc))
|
---|
2575 | {
|
---|
2576 | if (u8Prev && u8Prev != '\n')
|
---|
2577 | DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
2578 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Reading memory at %DV.\n", &pDbgc->DumpPos);
|
---|
2579 | }
|
---|
2580 |
|
---|
2581 | /*
|
---|
2582 | * Display it.
|
---|
2583 | */
|
---|
2584 | memset(&achBuffer[cb], 0, sizeof(achBuffer) - cb);
|
---|
2585 | if (!fAscii)
|
---|
2586 | {
|
---|
2587 | DBGCCmdHlpPrintf(pCmdHlp, "%DV:", &pDbgc->DumpPos);
|
---|
2588 | unsigned i;
|
---|
2589 | for (i = 0; i < cb; i += cbElement)
|
---|
2590 | {
|
---|
2591 | const char *pszSpace = " ";
|
---|
2592 | if (cbElement <= 2 && i == 8 && !fAscii)
|
---|
2593 | pszSpace = "-";
|
---|
2594 | switch (cbElement)
|
---|
2595 | {
|
---|
2596 | case 1: DBGCCmdHlpPrintf(pCmdHlp, "%s%02x", pszSpace, *(uint8_t *)&achBuffer[i]); break;
|
---|
2597 | case 2: DBGCCmdHlpPrintf(pCmdHlp, "%s%04x", pszSpace, *(uint16_t *)&achBuffer[i]); break;
|
---|
2598 | case 4: DBGCCmdHlpPrintf(pCmdHlp, "%s%08x", pszSpace, *(uint32_t *)&achBuffer[i]); break;
|
---|
2599 | case 8: DBGCCmdHlpPrintf(pCmdHlp, "%s%016llx", pszSpace, *(uint64_t *)&achBuffer[i]); break;
|
---|
2600 | }
|
---|
2601 | }
|
---|
2602 |
|
---|
2603 | /* chars column */
|
---|
2604 | if (pDbgc->cbDumpElement == 1)
|
---|
2605 | {
|
---|
2606 | while (i++ < sizeof(achBuffer))
|
---|
2607 | DBGCCmdHlpPrintf(pCmdHlp, " ");
|
---|
2608 | DBGCCmdHlpPrintf(pCmdHlp, " ");
|
---|
2609 | for (i = 0; i < cb; i += cbElement)
|
---|
2610 | {
|
---|
2611 | uint8_t u8 = *(uint8_t *)&achBuffer[i];
|
---|
2612 | if (RT_C_IS_PRINT(u8) && u8 < 127 && u8 >= 32)
|
---|
2613 | DBGCCmdHlpPrintf(pCmdHlp, "%c", u8);
|
---|
2614 | else
|
---|
2615 | DBGCCmdHlpPrintf(pCmdHlp, ".");
|
---|
2616 | }
|
---|
2617 | }
|
---|
2618 | rc = DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
2619 | }
|
---|
2620 | else
|
---|
2621 | {
|
---|
2622 | /*
|
---|
2623 | * We print up to the first zero and stop there.
|
---|
2624 | * Only printables + '\t' and '\n' are printed.
|
---|
2625 | */
|
---|
2626 | if (!u8Prev)
|
---|
2627 | DBGCCmdHlpPrintf(pCmdHlp, "%DV:\n", &pDbgc->DumpPos);
|
---|
2628 | uint8_t u8 = '\0';
|
---|
2629 | unsigned i;
|
---|
2630 | for (i = 0; i < cb; i++)
|
---|
2631 | {
|
---|
2632 | u8Prev = u8;
|
---|
2633 | u8 = *(uint8_t *)&achBuffer[i];
|
---|
2634 | if ( u8 < 127
|
---|
2635 | && ( (RT_C_IS_PRINT(u8) && u8 >= 32)
|
---|
2636 | || u8 == '\t'
|
---|
2637 | || u8 == '\n'))
|
---|
2638 | DBGCCmdHlpPrintf(pCmdHlp, "%c", u8);
|
---|
2639 | else if (!u8)
|
---|
2640 | break;
|
---|
2641 | else
|
---|
2642 | DBGCCmdHlpPrintf(pCmdHlp, "\\x%x", u8);
|
---|
2643 | }
|
---|
2644 | if (u8 == '\0')
|
---|
2645 | cb = cbLeft = i + 1;
|
---|
2646 | if (cbLeft - cb <= 0 && u8Prev != '\n')
|
---|
2647 | DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
2648 | }
|
---|
2649 |
|
---|
2650 | /*
|
---|
2651 | * Advance
|
---|
2652 | */
|
---|
2653 | cbLeft -= (int)cb;
|
---|
2654 | rc = DBGCCmdHlpEval(pCmdHlp, &pDbgc->DumpPos, "(%Dv) + %x", &pDbgc->DumpPos, cb);
|
---|
2655 | if (RT_FAILURE(rc))
|
---|
2656 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Expression: (%Dv) + %x\n", &pDbgc->DumpPos, cb);
|
---|
2657 | if (cbLeft <= 0)
|
---|
2658 | break;
|
---|
2659 | }
|
---|
2660 |
|
---|
2661 | NOREF(pCmd);
|
---|
2662 | return VINF_SUCCESS;
|
---|
2663 | }
|
---|
2664 |
|
---|
2665 |
|
---|
2666 | /**
|
---|
2667 | * Best guess at which paging mode currently applies to the guest
|
---|
2668 | * paging structures.
|
---|
2669 | *
|
---|
2670 | * This have to come up with a decent answer even when the guest
|
---|
2671 | * is in non-paged protected mode or real mode.
|
---|
2672 | *
|
---|
2673 | * @returns cr3.
|
---|
2674 | * @param pDbgc The DBGC instance.
|
---|
2675 | * @param pfPAE Where to store the page address extension indicator.
|
---|
2676 | * @param pfLME Where to store the long mode enabled indicator.
|
---|
2677 | * @param pfPSE Where to store the page size extension indicator.
|
---|
2678 | * @param pfPGE Where to store the page global enabled indicator.
|
---|
2679 | * @param pfNXE Where to store the no-execution enabled indicator.
|
---|
2680 | */
|
---|
2681 | static RTGCPHYS dbgcGetGuestPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, bool *pfPSE, bool *pfPGE, bool *pfNXE)
|
---|
2682 | {
|
---|
2683 | PVMCPU pVCpu = VMMR3GetCpuByIdU(pDbgc->pUVM, pDbgc->idCpu);
|
---|
2684 | RTGCUINTREG cr4 = CPUMGetGuestCR4(pVCpu);
|
---|
2685 | *pfPSE = !!(cr4 & X86_CR4_PSE);
|
---|
2686 | *pfPGE = !!(cr4 & X86_CR4_PGE);
|
---|
2687 | if (cr4 & X86_CR4_PAE)
|
---|
2688 | {
|
---|
2689 | *pfPSE = true;
|
---|
2690 | *pfPAE = true;
|
---|
2691 | }
|
---|
2692 | else
|
---|
2693 | *pfPAE = false;
|
---|
2694 |
|
---|
2695 | *pfLME = CPUMGetGuestMode(pVCpu) == CPUMMODE_LONG;
|
---|
2696 | *pfNXE = false; /* GUEST64 GUESTNX */
|
---|
2697 | return CPUMGetGuestCR3(pVCpu);
|
---|
2698 | }
|
---|
2699 |
|
---|
2700 |
|
---|
2701 | /**
|
---|
2702 | * Determine the shadow paging mode.
|
---|
2703 | *
|
---|
2704 | * @returns cr3.
|
---|
2705 | * @param pDbgc The DBGC instance.
|
---|
2706 | * @param pfPAE Where to store the page address extension indicator.
|
---|
2707 | * @param pfLME Where to store the long mode enabled indicator.
|
---|
2708 | * @param pfPSE Where to store the page size extension indicator.
|
---|
2709 | * @param pfPGE Where to store the page global enabled indicator.
|
---|
2710 | * @param pfNXE Where to store the no-execution enabled indicator.
|
---|
2711 | */
|
---|
2712 | static RTHCPHYS dbgcGetShadowPageMode(PDBGC pDbgc, bool *pfPAE, bool *pfLME, bool *pfPSE, bool *pfPGE, bool *pfNXE)
|
---|
2713 | {
|
---|
2714 | PVMCPU pVCpu = VMMR3GetCpuByIdU(pDbgc->pUVM, pDbgc->idCpu);
|
---|
2715 |
|
---|
2716 | *pfPSE = true;
|
---|
2717 | *pfPGE = false;
|
---|
2718 | switch (PGMGetShadowMode(pVCpu))
|
---|
2719 | {
|
---|
2720 | default:
|
---|
2721 | case PGMMODE_32_BIT:
|
---|
2722 | *pfPAE = *pfLME = *pfNXE = false;
|
---|
2723 | break;
|
---|
2724 | case PGMMODE_PAE:
|
---|
2725 | *pfLME = *pfNXE = false;
|
---|
2726 | *pfPAE = true;
|
---|
2727 | break;
|
---|
2728 | case PGMMODE_PAE_NX:
|
---|
2729 | *pfLME = false;
|
---|
2730 | *pfPAE = *pfNXE = true;
|
---|
2731 | break;
|
---|
2732 | case PGMMODE_AMD64:
|
---|
2733 | *pfNXE = false;
|
---|
2734 | *pfPAE = *pfLME = true;
|
---|
2735 | break;
|
---|
2736 | case PGMMODE_AMD64_NX:
|
---|
2737 | *pfPAE = *pfLME = *pfNXE = true;
|
---|
2738 | break;
|
---|
2739 | }
|
---|
2740 | return PGMGetHyperCR3(pVCpu);
|
---|
2741 | }
|
---|
2742 |
|
---|
2743 |
|
---|
2744 | /**
|
---|
2745 | * @callback_method_impl{FNDBGCCMD,
|
---|
2746 | * The 'dpd'\, 'dpda'\, 'dpdb'\, 'dpdg' and 'dpdh' commands.}
|
---|
2747 | */
|
---|
2748 | static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
2749 | {
|
---|
2750 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
2751 |
|
---|
2752 | /*
|
---|
2753 | * Validate input.
|
---|
2754 | */
|
---|
2755 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1);
|
---|
2756 | if (cArgs == 1 && pCmd->pszCmd[3] == 'a')
|
---|
2757 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
2758 | if (cArgs == 1 && pCmd->pszCmd[3] != 'a')
|
---|
2759 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_NUMBER
|
---|
2760 | || DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
2761 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
2762 |
|
---|
2763 | /*
|
---|
2764 | * Guest or shadow page directories? Get the paging parameters.
|
---|
2765 | */
|
---|
2766 | bool fGuest = pCmd->pszCmd[3] != 'h';
|
---|
2767 | if (!pCmd->pszCmd[3] || pCmd->pszCmd[3] == 'a')
|
---|
2768 | fGuest = paArgs[0].enmType == DBGCVAR_TYPE_NUMBER
|
---|
2769 | ? pDbgc->fRegCtxGuest
|
---|
2770 | : DBGCVAR_ISGCPOINTER(paArgs[0].enmType);
|
---|
2771 |
|
---|
2772 | bool fPAE, fLME, fPSE, fPGE, fNXE;
|
---|
2773 | uint64_t cr3 = fGuest
|
---|
2774 | ? dbgcGetGuestPageMode(pDbgc, &fPAE, &fLME, &fPSE, &fPGE, &fNXE)
|
---|
2775 | : dbgcGetShadowPageMode(pDbgc, &fPAE, &fLME, &fPSE, &fPGE, &fNXE);
|
---|
2776 | const unsigned cbEntry = fPAE ? sizeof(X86PTEPAE) : sizeof(X86PTE);
|
---|
2777 |
|
---|
2778 | /*
|
---|
2779 | * Setup default argument if none was specified.
|
---|
2780 | * Fix address / index confusion.
|
---|
2781 | */
|
---|
2782 | DBGCVAR VarDefault;
|
---|
2783 | if (!cArgs)
|
---|
2784 | {
|
---|
2785 | if (pCmd->pszCmd[3] == 'a')
|
---|
2786 | {
|
---|
2787 | if (fLME || fPAE)
|
---|
2788 | return DBGCCmdHlpPrintf(pCmdHlp, "Default argument for 'dpda' hasn't been fully implemented yet. Try with an address or use one of the other commands.\n");
|
---|
2789 | if (fGuest)
|
---|
2790 | DBGCVAR_INIT_GC_PHYS(&VarDefault, cr3);
|
---|
2791 | else
|
---|
2792 | DBGCVAR_INIT_HC_PHYS(&VarDefault, cr3);
|
---|
2793 | }
|
---|
2794 | else
|
---|
2795 | DBGCVAR_INIT_GC_FLAT(&VarDefault, 0);
|
---|
2796 | paArgs = &VarDefault;
|
---|
2797 | cArgs = 1;
|
---|
2798 | }
|
---|
2799 | else if (paArgs[0].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
2800 | {
|
---|
2801 | /* If it's a number (not an address), it's an index, so convert it to an address. */
|
---|
2802 | Assert(pCmd->pszCmd[3] != 'a');
|
---|
2803 | VarDefault = paArgs[0];
|
---|
2804 | if (fPAE)
|
---|
2805 | return DBGCCmdHlpPrintf(pCmdHlp, "PDE indexing is only implemented for 32-bit paging.\n");
|
---|
2806 | if (VarDefault.u.u64Number >= PAGE_SIZE / cbEntry)
|
---|
2807 | return DBGCCmdHlpPrintf(pCmdHlp, "PDE index is out of range [0..%d].\n", PAGE_SIZE / cbEntry - 1);
|
---|
2808 | VarDefault.u.u64Number <<= X86_PD_SHIFT;
|
---|
2809 | VarDefault.enmType = DBGCVAR_TYPE_GC_FLAT;
|
---|
2810 | paArgs = &VarDefault;
|
---|
2811 | }
|
---|
2812 |
|
---|
2813 | /*
|
---|
2814 | * Locate the PDE to start displaying at.
|
---|
2815 | *
|
---|
2816 | * The 'dpda' command takes the address of a PDE, while the others are guest
|
---|
2817 | * virtual address which PDEs should be displayed. So, 'dpda' is rather simple
|
---|
2818 | * while the others require us to do all the tedious walking thru the paging
|
---|
2819 | * hierarchy to find the intended PDE.
|
---|
2820 | */
|
---|
2821 | unsigned iEntry = ~0U; /* The page directory index. ~0U for 'dpta'. */
|
---|
2822 | DBGCVAR VarGCPtr; /* The GC address corresponding to the current PDE (iEntry != ~0U). */
|
---|
2823 | DBGCVAR VarPDEAddr; /* The address of the current PDE. */
|
---|
2824 | unsigned cEntries; /* The number of entries to display. */
|
---|
2825 | unsigned cEntriesMax; /* The max number of entries to display. */
|
---|
2826 | int rc;
|
---|
2827 | if (pCmd->pszCmd[3] == 'a')
|
---|
2828 | {
|
---|
2829 | VarPDEAddr = paArgs[0];
|
---|
2830 | switch (VarPDEAddr.enmRangeType)
|
---|
2831 | {
|
---|
2832 | case DBGCVAR_RANGE_BYTES: cEntries = VarPDEAddr.u64Range / cbEntry; break;
|
---|
2833 | case DBGCVAR_RANGE_ELEMENTS: cEntries = VarPDEAddr.u64Range; break;
|
---|
2834 | default: cEntries = 10; break;
|
---|
2835 | }
|
---|
2836 | cEntriesMax = PAGE_SIZE / cbEntry;
|
---|
2837 | }
|
---|
2838 | else
|
---|
2839 | {
|
---|
2840 | /*
|
---|
2841 | * Determine the range.
|
---|
2842 | */
|
---|
2843 | switch (paArgs[0].enmRangeType)
|
---|
2844 | {
|
---|
2845 | case DBGCVAR_RANGE_BYTES: cEntries = paArgs[0].u64Range / PAGE_SIZE; break;
|
---|
2846 | case DBGCVAR_RANGE_ELEMENTS: cEntries = paArgs[0].u64Range; break;
|
---|
2847 | default: cEntries = 10; break;
|
---|
2848 | }
|
---|
2849 |
|
---|
2850 | /*
|
---|
2851 | * Normalize the input address, it must be a flat GC address.
|
---|
2852 | */
|
---|
2853 | rc = DBGCCmdHlpEval(pCmdHlp, &VarGCPtr, "%%(%Dv)", &paArgs[0]);
|
---|
2854 | if (RT_FAILURE(rc))
|
---|
2855 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "%%(%Dv)", &paArgs[0]);
|
---|
2856 | if (VarGCPtr.enmType == DBGCVAR_TYPE_HC_FLAT)
|
---|
2857 | {
|
---|
2858 | VarGCPtr.u.GCFlat = (uintptr_t)VarGCPtr.u.pvHCFlat;
|
---|
2859 | VarGCPtr.enmType = DBGCVAR_TYPE_GC_FLAT;
|
---|
2860 | }
|
---|
2861 | if (fPAE)
|
---|
2862 | VarGCPtr.u.GCFlat &= ~(((RTGCPTR)1 << X86_PD_PAE_SHIFT) - 1);
|
---|
2863 | else
|
---|
2864 | VarGCPtr.u.GCFlat &= ~(((RTGCPTR)1 << X86_PD_SHIFT) - 1);
|
---|
2865 |
|
---|
2866 | /*
|
---|
2867 | * Do the paging walk until we get to the page directory.
|
---|
2868 | */
|
---|
2869 | DBGCVAR VarCur;
|
---|
2870 | if (fGuest)
|
---|
2871 | DBGCVAR_INIT_GC_PHYS(&VarCur, cr3);
|
---|
2872 | else
|
---|
2873 | DBGCVAR_INIT_HC_PHYS(&VarCur, cr3);
|
---|
2874 | if (fLME)
|
---|
2875 | {
|
---|
2876 | /* Page Map Level 4 Lookup. */
|
---|
2877 | /* Check if it's a valid address first? */
|
---|
2878 | VarCur.u.u64Number &= X86_PTE_PAE_PG_MASK;
|
---|
2879 | VarCur.u.u64Number += (((uint64_t)VarGCPtr.u.GCFlat >> X86_PML4_SHIFT) & X86_PML4_MASK) * sizeof(X86PML4E);
|
---|
2880 | X86PML4E Pml4e;
|
---|
2881 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pml4e, sizeof(Pml4e), &VarCur, NULL);
|
---|
2882 | if (RT_FAILURE(rc))
|
---|
2883 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PML4E memory at %DV.\n", &VarCur);
|
---|
2884 | if (!Pml4e.n.u1Present)
|
---|
2885 | return DBGCCmdHlpPrintf(pCmdHlp, "Page directory pointer table is not present for %Dv.\n", &VarGCPtr);
|
---|
2886 |
|
---|
2887 | VarCur.u.u64Number = Pml4e.u & X86_PML4E_PG_MASK;
|
---|
2888 | Assert(fPAE);
|
---|
2889 | }
|
---|
2890 | if (fPAE)
|
---|
2891 | {
|
---|
2892 | /* Page directory pointer table. */
|
---|
2893 | X86PDPE Pdpe;
|
---|
2894 | VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE) * sizeof(Pdpe);
|
---|
2895 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pdpe, sizeof(Pdpe), &VarCur, NULL);
|
---|
2896 | if (RT_FAILURE(rc))
|
---|
2897 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDPE memory at %DV.\n", &VarCur);
|
---|
2898 | if (!Pdpe.n.u1Present)
|
---|
2899 | return DBGCCmdHlpPrintf(pCmdHlp, "Page directory is not present for %Dv.\n", &VarGCPtr);
|
---|
2900 |
|
---|
2901 | iEntry = (VarGCPtr.u.GCFlat >> X86_PD_PAE_SHIFT) & X86_PD_PAE_MASK;
|
---|
2902 | VarPDEAddr = VarCur;
|
---|
2903 | VarPDEAddr.u.u64Number = Pdpe.u & X86_PDPE_PG_MASK;
|
---|
2904 | VarPDEAddr.u.u64Number += iEntry * sizeof(X86PDEPAE);
|
---|
2905 | }
|
---|
2906 | else
|
---|
2907 | {
|
---|
2908 | /* 32-bit legacy - CR3 == page directory. */
|
---|
2909 | iEntry = (VarGCPtr.u.GCFlat >> X86_PD_SHIFT) & X86_PD_MASK;
|
---|
2910 | VarPDEAddr = VarCur;
|
---|
2911 | VarPDEAddr.u.u64Number += iEntry * sizeof(X86PDE);
|
---|
2912 | }
|
---|
2913 | cEntriesMax = (PAGE_SIZE - iEntry) / cbEntry;
|
---|
2914 | }
|
---|
2915 |
|
---|
2916 | /* adjust cEntries */
|
---|
2917 | cEntries = RT_MAX(1, cEntries);
|
---|
2918 | cEntries = RT_MIN(cEntries, cEntriesMax);
|
---|
2919 |
|
---|
2920 | /*
|
---|
2921 | * The display loop.
|
---|
2922 | */
|
---|
2923 | DBGCCmdHlpPrintf(pCmdHlp, iEntry != ~0U ? "%DV (index %#x):\n" : "%DV:\n",
|
---|
2924 | &VarPDEAddr, iEntry);
|
---|
2925 | do
|
---|
2926 | {
|
---|
2927 | /*
|
---|
2928 | * Read.
|
---|
2929 | */
|
---|
2930 | X86PDEPAE Pde;
|
---|
2931 | Pde.u = 0;
|
---|
2932 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pde, cbEntry, &VarPDEAddr, NULL);
|
---|
2933 | if (RT_FAILURE(rc))
|
---|
2934 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Reading PDE memory at %DV.\n", &VarPDEAddr);
|
---|
2935 |
|
---|
2936 | /*
|
---|
2937 | * Display.
|
---|
2938 | */
|
---|
2939 | if (iEntry != ~0U)
|
---|
2940 | {
|
---|
2941 | DBGCCmdHlpPrintf(pCmdHlp, "%03x %DV: ", iEntry, &VarGCPtr);
|
---|
2942 | iEntry++;
|
---|
2943 | }
|
---|
2944 | if (fPSE && Pde.b.u1Size)
|
---|
2945 | DBGCCmdHlpPrintf(pCmdHlp,
|
---|
2946 | fPAE
|
---|
2947 | ? "%016llx big phys=%016llx %s %s %s %s %s avl=%02x %s %s %s %s %s"
|
---|
2948 | : "%08llx big phys=%08llx %s %s %s %s %s avl=%02x %s %s %s %s %s",
|
---|
2949 | Pde.u,
|
---|
2950 | Pde.u & X86_PDE_PAE_PG_MASK,
|
---|
2951 | Pde.b.u1Present ? "p " : "np",
|
---|
2952 | Pde.b.u1Write ? "w" : "r",
|
---|
2953 | Pde.b.u1User ? "u" : "s",
|
---|
2954 | Pde.b.u1Accessed ? "a " : "na",
|
---|
2955 | Pde.b.u1Dirty ? "d " : "nd",
|
---|
2956 | Pde.b.u3Available,
|
---|
2957 | Pde.b.u1Global ? (fPGE ? "g" : "G") : " ",
|
---|
2958 | Pde.b.u1WriteThru ? "pwt" : " ",
|
---|
2959 | Pde.b.u1CacheDisable ? "pcd" : " ",
|
---|
2960 | Pde.b.u1PAT ? "pat" : "",
|
---|
2961 | Pde.b.u1NoExecute ? (fNXE ? "nx" : "NX") : " ");
|
---|
2962 | else
|
---|
2963 | DBGCCmdHlpPrintf(pCmdHlp,
|
---|
2964 | fPAE
|
---|
2965 | ? "%016llx 4kb phys=%016llx %s %s %s %s %s avl=%02x %s %s %s %s"
|
---|
2966 | : "%08llx 4kb phys=%08llx %s %s %s %s %s avl=%02x %s %s %s %s",
|
---|
2967 | Pde.u,
|
---|
2968 | Pde.u & X86_PDE_PAE_PG_MASK,
|
---|
2969 | Pde.n.u1Present ? "p " : "np",
|
---|
2970 | Pde.n.u1Write ? "w" : "r",
|
---|
2971 | Pde.n.u1User ? "u" : "s",
|
---|
2972 | Pde.n.u1Accessed ? "a " : "na",
|
---|
2973 | Pde.u & RT_BIT(6) ? "6 " : " ",
|
---|
2974 | Pde.n.u3Available,
|
---|
2975 | Pde.u & RT_BIT(8) ? "8" : " ",
|
---|
2976 | Pde.n.u1WriteThru ? "pwt" : " ",
|
---|
2977 | Pde.n.u1CacheDisable ? "pcd" : " ",
|
---|
2978 | Pde.u & RT_BIT(7) ? "7" : "",
|
---|
2979 | Pde.n.u1NoExecute ? (fNXE ? "nx" : "NX") : " ");
|
---|
2980 | if (Pde.u & UINT64_C(0x7fff000000000000))
|
---|
2981 | DBGCCmdHlpPrintf(pCmdHlp, " weird=%RX64", (Pde.u & UINT64_C(0x7fff000000000000)));
|
---|
2982 | rc = DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
2983 | if (RT_FAILURE(rc))
|
---|
2984 | return rc;
|
---|
2985 |
|
---|
2986 | /*
|
---|
2987 | * Advance.
|
---|
2988 | */
|
---|
2989 | VarPDEAddr.u.u64Number += cbEntry;
|
---|
2990 | if (iEntry != ~0U)
|
---|
2991 | VarGCPtr.u.GCFlat += fPAE ? RT_BIT_32(X86_PD_PAE_SHIFT) : RT_BIT_32(X86_PD_SHIFT);
|
---|
2992 | } while (cEntries-- > 0);
|
---|
2993 |
|
---|
2994 | return VINF_SUCCESS;
|
---|
2995 | }
|
---|
2996 |
|
---|
2997 |
|
---|
2998 | /**
|
---|
2999 | * @callback_method_impl{FNDBGCCMD, The 'dpdb' command.}
|
---|
3000 | */
|
---|
3001 | static DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3002 | {
|
---|
3003 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3004 | int rc1 = pCmdHlp->pfnExec(pCmdHlp, "dpdg %DV", &paArgs[0]);
|
---|
3005 | int rc2 = pCmdHlp->pfnExec(pCmdHlp, "dpdh %DV", &paArgs[0]);
|
---|
3006 | if (RT_FAILURE(rc1))
|
---|
3007 | return rc1;
|
---|
3008 | NOREF(pCmd); NOREF(paArgs); NOREF(cArgs);
|
---|
3009 | return rc2;
|
---|
3010 | }
|
---|
3011 |
|
---|
3012 |
|
---|
3013 | /**
|
---|
3014 | * @callback_method_impl{FNDBGCCMD, The 'dph*' commands and main part of 'm'.}
|
---|
3015 | */
|
---|
3016 | static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3017 | {
|
---|
3018 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
3019 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3020 |
|
---|
3021 | /*
|
---|
3022 | * Figure the context and base flags.
|
---|
3023 | */
|
---|
3024 | uint32_t fFlags = DBGFPGDMP_FLAGS_PAGE_INFO | DBGFPGDMP_FLAGS_PRINT_CR3;
|
---|
3025 | if (pCmd->pszCmd[0] == 'm')
|
---|
3026 | fFlags |= DBGFPGDMP_FLAGS_GUEST | DBGFPGDMP_FLAGS_SHADOW;
|
---|
3027 | else if (pCmd->pszCmd[3] == '\0')
|
---|
3028 | fFlags |= pDbgc->fRegCtxGuest ? DBGFPGDMP_FLAGS_GUEST : DBGFPGDMP_FLAGS_SHADOW;
|
---|
3029 | else if (pCmd->pszCmd[3] == 'g')
|
---|
3030 | fFlags |= DBGFPGDMP_FLAGS_GUEST;
|
---|
3031 | else if (pCmd->pszCmd[3] == 'h')
|
---|
3032 | fFlags |= DBGFPGDMP_FLAGS_SHADOW;
|
---|
3033 | else
|
---|
3034 | AssertFailed();
|
---|
3035 |
|
---|
3036 | if (pDbgc->cPagingHierarchyDumps == 0)
|
---|
3037 | fFlags |= DBGFPGDMP_FLAGS_HEADER;
|
---|
3038 | pDbgc->cPagingHierarchyDumps = (pDbgc->cPagingHierarchyDumps + 1) % 42;
|
---|
3039 |
|
---|
3040 | /*
|
---|
3041 | * Get the range.
|
---|
3042 | */
|
---|
3043 | PCDBGCVAR pRange = cArgs > 0 ? &paArgs[0] : pDbgc->pLastPos;
|
---|
3044 | RTGCPTR GCPtrFirst = NIL_RTGCPTR;
|
---|
3045 | int rc = DBGCCmdHlpVarToFlatAddr(pCmdHlp, pRange, &GCPtrFirst);
|
---|
3046 | if (RT_FAILURE(rc))
|
---|
3047 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to convert %DV to a flat address: %Rrc", pRange, rc);
|
---|
3048 |
|
---|
3049 | uint64_t cbRange;
|
---|
3050 | rc = DBGCCmdHlpVarGetRange(pCmdHlp, pRange, PAGE_SIZE, PAGE_SIZE * 8, &cbRange);
|
---|
3051 | if (RT_FAILURE(rc))
|
---|
3052 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to obtain the range of %DV: %Rrc", pRange, rc);
|
---|
3053 |
|
---|
3054 | RTGCPTR GCPtrLast = RTGCPTR_MAX - GCPtrFirst;
|
---|
3055 | if (cbRange >= GCPtrLast)
|
---|
3056 | GCPtrLast = RTGCPTR_MAX;
|
---|
3057 | else if (!cbRange)
|
---|
3058 | GCPtrLast = GCPtrFirst;
|
---|
3059 | else
|
---|
3060 | GCPtrLast = GCPtrFirst + cbRange - 1;
|
---|
3061 |
|
---|
3062 | /*
|
---|
3063 | * Do we have a CR3?
|
---|
3064 | */
|
---|
3065 | uint64_t cr3 = 0;
|
---|
3066 | if (cArgs > 1)
|
---|
3067 | {
|
---|
3068 | if ((fFlags & (DBGFPGDMP_FLAGS_GUEST | DBGFPGDMP_FLAGS_SHADOW)) == (DBGFPGDMP_FLAGS_GUEST | DBGFPGDMP_FLAGS_SHADOW))
|
---|
3069 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "No CR3 or mode arguments when dumping both context, please.");
|
---|
3070 | if (paArgs[1].enmType != DBGCVAR_TYPE_NUMBER)
|
---|
3071 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "The CR3 argument is not a number: %DV", &paArgs[1]);
|
---|
3072 | cr3 = paArgs[1].u.u64Number;
|
---|
3073 | }
|
---|
3074 | else
|
---|
3075 | fFlags |= DBGFPGDMP_FLAGS_CURRENT_CR3;
|
---|
3076 |
|
---|
3077 | /*
|
---|
3078 | * Do we have a mode?
|
---|
3079 | */
|
---|
3080 | if (cArgs > 2)
|
---|
3081 | {
|
---|
3082 | if (paArgs[2].enmType != DBGCVAR_TYPE_STRING)
|
---|
3083 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "The mode argument is not a string: %DV", &paArgs[2]);
|
---|
3084 | static const struct MODETOFLAGS
|
---|
3085 | {
|
---|
3086 | const char *pszName;
|
---|
3087 | uint32_t fFlags;
|
---|
3088 | } s_aModeToFlags[] =
|
---|
3089 | {
|
---|
3090 | { "ept", DBGFPGDMP_FLAGS_EPT },
|
---|
3091 | { "legacy", 0 },
|
---|
3092 | { "legacy-np", DBGFPGDMP_FLAGS_NP },
|
---|
3093 | { "pse", DBGFPGDMP_FLAGS_PSE },
|
---|
3094 | { "pse-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_NP },
|
---|
3095 | { "pae", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE },
|
---|
3096 | { "pae-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_NP },
|
---|
3097 | { "pae-nx", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_NXE },
|
---|
3098 | { "pae-nx-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_NXE | DBGFPGDMP_FLAGS_NP },
|
---|
3099 | { "long", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME },
|
---|
3100 | { "long-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME | DBGFPGDMP_FLAGS_NP },
|
---|
3101 | { "long-nx", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME | DBGFPGDMP_FLAGS_NXE },
|
---|
3102 | { "long-nx-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME | DBGFPGDMP_FLAGS_NXE | DBGFPGDMP_FLAGS_NP }
|
---|
3103 | };
|
---|
3104 | int i = RT_ELEMENTS(s_aModeToFlags);
|
---|
3105 | while (i-- > 0)
|
---|
3106 | if (!strcmp(s_aModeToFlags[i].pszName, paArgs[2].u.pszString))
|
---|
3107 | {
|
---|
3108 | fFlags |= s_aModeToFlags[i].fFlags;
|
---|
3109 | break;
|
---|
3110 | }
|
---|
3111 | if (i < 0)
|
---|
3112 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Unknown mode: \"%s\"", paArgs[2].u.pszString);
|
---|
3113 | }
|
---|
3114 | else
|
---|
3115 | fFlags |= DBGFPGDMP_FLAGS_CURRENT_MODE;
|
---|
3116 |
|
---|
3117 | /*
|
---|
3118 | * Call the worker.
|
---|
3119 | */
|
---|
3120 | rc = DBGFR3PagingDumpEx(pUVM, pDbgc->idCpu, fFlags, cr3, GCPtrFirst, GCPtrLast, 99 /*cMaxDepth*/,
|
---|
3121 | DBGCCmdHlpGetDbgfOutputHlp(pCmdHlp));
|
---|
3122 | if (RT_FAILURE(rc))
|
---|
3123 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "DBGFR3PagingDumpEx: %Rrc\n", rc);
|
---|
3124 | return VINF_SUCCESS;
|
---|
3125 | }
|
---|
3126 |
|
---|
3127 |
|
---|
3128 |
|
---|
3129 | /**
|
---|
3130 | * @callback_method_impl{FNDBGCCMD, The 'dpg*' commands.}
|
---|
3131 | */
|
---|
3132 | static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3133 | {
|
---|
3134 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
3135 |
|
---|
3136 | /*
|
---|
3137 | * Validate input.
|
---|
3138 | */
|
---|
3139 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 1);
|
---|
3140 | if (pCmd->pszCmd[3] == 'a')
|
---|
3141 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
3142 | else
|
---|
3143 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_NUMBER
|
---|
3144 | || DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
3145 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3146 |
|
---|
3147 | /*
|
---|
3148 | * Guest or shadow page tables? Get the paging parameters.
|
---|
3149 | */
|
---|
3150 | bool fGuest = pCmd->pszCmd[3] != 'h';
|
---|
3151 | if (!pCmd->pszCmd[3] || pCmd->pszCmd[3] == 'a')
|
---|
3152 | fGuest = paArgs[0].enmType == DBGCVAR_TYPE_NUMBER
|
---|
3153 | ? pDbgc->fRegCtxGuest
|
---|
3154 | : DBGCVAR_ISGCPOINTER(paArgs[0].enmType);
|
---|
3155 |
|
---|
3156 | bool fPAE, fLME, fPSE, fPGE, fNXE;
|
---|
3157 | uint64_t cr3 = fGuest
|
---|
3158 | ? dbgcGetGuestPageMode(pDbgc, &fPAE, &fLME, &fPSE, &fPGE, &fNXE)
|
---|
3159 | : dbgcGetShadowPageMode(pDbgc, &fPAE, &fLME, &fPSE, &fPGE, &fNXE);
|
---|
3160 | const unsigned cbEntry = fPAE ? sizeof(X86PTEPAE) : sizeof(X86PTE);
|
---|
3161 |
|
---|
3162 | /*
|
---|
3163 | * Locate the PTE to start displaying at.
|
---|
3164 | *
|
---|
3165 | * The 'dpta' command takes the address of a PTE, while the others are guest
|
---|
3166 | * virtual address which PTEs should be displayed. So, 'pdta' is rather simple
|
---|
3167 | * while the others require us to do all the tedious walking thru the paging
|
---|
3168 | * hierarchy to find the intended PTE.
|
---|
3169 | */
|
---|
3170 | unsigned iEntry = ~0U; /* The page table index. ~0U for 'dpta'. */
|
---|
3171 | DBGCVAR VarGCPtr; /* The GC address corresponding to the current PTE (iEntry != ~0U). */
|
---|
3172 | DBGCVAR VarPTEAddr; /* The address of the current PTE. */
|
---|
3173 | unsigned cEntries; /* The number of entries to display. */
|
---|
3174 | unsigned cEntriesMax; /* The max number of entries to display. */
|
---|
3175 | int rc;
|
---|
3176 | if (pCmd->pszCmd[3] == 'a')
|
---|
3177 | {
|
---|
3178 | VarPTEAddr = paArgs[0];
|
---|
3179 | switch (VarPTEAddr.enmRangeType)
|
---|
3180 | {
|
---|
3181 | case DBGCVAR_RANGE_BYTES: cEntries = VarPTEAddr.u64Range / cbEntry; break;
|
---|
3182 | case DBGCVAR_RANGE_ELEMENTS: cEntries = VarPTEAddr.u64Range; break;
|
---|
3183 | default: cEntries = 10; break;
|
---|
3184 | }
|
---|
3185 | cEntriesMax = PAGE_SIZE / cbEntry;
|
---|
3186 | }
|
---|
3187 | else
|
---|
3188 | {
|
---|
3189 | /*
|
---|
3190 | * Determine the range.
|
---|
3191 | */
|
---|
3192 | switch (paArgs[0].enmRangeType)
|
---|
3193 | {
|
---|
3194 | case DBGCVAR_RANGE_BYTES: cEntries = paArgs[0].u64Range / PAGE_SIZE; break;
|
---|
3195 | case DBGCVAR_RANGE_ELEMENTS: cEntries = paArgs[0].u64Range; break;
|
---|
3196 | default: cEntries = 10; break;
|
---|
3197 | }
|
---|
3198 |
|
---|
3199 | /*
|
---|
3200 | * Normalize the input address, it must be a flat GC address.
|
---|
3201 | */
|
---|
3202 | rc = DBGCCmdHlpEval(pCmdHlp, &VarGCPtr, "%%(%Dv)", &paArgs[0]);
|
---|
3203 | if (RT_FAILURE(rc))
|
---|
3204 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "%%(%Dv)", &paArgs[0]);
|
---|
3205 | if (VarGCPtr.enmType == DBGCVAR_TYPE_HC_FLAT)
|
---|
3206 | {
|
---|
3207 | VarGCPtr.u.GCFlat = (uintptr_t)VarGCPtr.u.pvHCFlat;
|
---|
3208 | VarGCPtr.enmType = DBGCVAR_TYPE_GC_FLAT;
|
---|
3209 | }
|
---|
3210 | VarGCPtr.u.GCFlat &= ~(RTGCPTR)PAGE_OFFSET_MASK;
|
---|
3211 |
|
---|
3212 | /*
|
---|
3213 | * Do the paging walk until we get to the page table.
|
---|
3214 | */
|
---|
3215 | DBGCVAR VarCur;
|
---|
3216 | if (fGuest)
|
---|
3217 | DBGCVAR_INIT_GC_PHYS(&VarCur, cr3);
|
---|
3218 | else
|
---|
3219 | DBGCVAR_INIT_HC_PHYS(&VarCur, cr3);
|
---|
3220 | if (fLME)
|
---|
3221 | {
|
---|
3222 | /* Page Map Level 4 Lookup. */
|
---|
3223 | /* Check if it's a valid address first? */
|
---|
3224 | VarCur.u.u64Number &= X86_PTE_PAE_PG_MASK;
|
---|
3225 | VarCur.u.u64Number += (((uint64_t)VarGCPtr.u.GCFlat >> X86_PML4_SHIFT) & X86_PML4_MASK) * sizeof(X86PML4E);
|
---|
3226 | X86PML4E Pml4e;
|
---|
3227 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pml4e, sizeof(Pml4e), &VarCur, NULL);
|
---|
3228 | if (RT_FAILURE(rc))
|
---|
3229 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PML4E memory at %DV.\n", &VarCur);
|
---|
3230 | if (!Pml4e.n.u1Present)
|
---|
3231 | return DBGCCmdHlpPrintf(pCmdHlp, "Page directory pointer table is not present for %Dv.\n", &VarGCPtr);
|
---|
3232 |
|
---|
3233 | VarCur.u.u64Number = Pml4e.u & X86_PML4E_PG_MASK;
|
---|
3234 | Assert(fPAE);
|
---|
3235 | }
|
---|
3236 | if (fPAE)
|
---|
3237 | {
|
---|
3238 | /* Page directory pointer table. */
|
---|
3239 | X86PDPE Pdpe;
|
---|
3240 | VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PDPT_SHIFT) & X86_PDPT_MASK_PAE) * sizeof(Pdpe);
|
---|
3241 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pdpe, sizeof(Pdpe), &VarCur, NULL);
|
---|
3242 | if (RT_FAILURE(rc))
|
---|
3243 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDPE memory at %DV.\n", &VarCur);
|
---|
3244 | if (!Pdpe.n.u1Present)
|
---|
3245 | return DBGCCmdHlpPrintf(pCmdHlp, "Page directory is not present for %Dv.\n", &VarGCPtr);
|
---|
3246 |
|
---|
3247 | VarCur.u.u64Number = Pdpe.u & X86_PDPE_PG_MASK;
|
---|
3248 |
|
---|
3249 | /* Page directory (PAE). */
|
---|
3250 | X86PDEPAE Pde;
|
---|
3251 | VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PD_PAE_SHIFT) & X86_PD_PAE_MASK) * sizeof(Pde);
|
---|
3252 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pde, sizeof(Pde), &VarCur, NULL);
|
---|
3253 | if (RT_FAILURE(rc))
|
---|
3254 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDE memory at %DV.\n", &VarCur);
|
---|
3255 | if (!Pde.n.u1Present)
|
---|
3256 | return DBGCCmdHlpPrintf(pCmdHlp, "Page table is not present for %Dv.\n", &VarGCPtr);
|
---|
3257 | if (fPSE && Pde.n.u1Size)
|
---|
3258 | return pCmdHlp->pfnExec(pCmdHlp, "dpd%s %Dv L3", &pCmd->pszCmd[3], &VarGCPtr);
|
---|
3259 |
|
---|
3260 | iEntry = (VarGCPtr.u.GCFlat >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK;
|
---|
3261 | VarPTEAddr = VarCur;
|
---|
3262 | VarPTEAddr.u.u64Number = Pde.u & X86_PDE_PAE_PG_MASK;
|
---|
3263 | VarPTEAddr.u.u64Number += iEntry * sizeof(X86PTEPAE);
|
---|
3264 | }
|
---|
3265 | else
|
---|
3266 | {
|
---|
3267 | /* Page directory (legacy). */
|
---|
3268 | X86PDE Pde;
|
---|
3269 | VarCur.u.u64Number += ((VarGCPtr.u.GCFlat >> X86_PD_SHIFT) & X86_PD_MASK) * sizeof(Pde);
|
---|
3270 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pde, sizeof(Pde), &VarCur, NULL);
|
---|
3271 | if (RT_FAILURE(rc))
|
---|
3272 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PDE memory at %DV.\n", &VarCur);
|
---|
3273 | if (!Pde.n.u1Present)
|
---|
3274 | return DBGCCmdHlpPrintf(pCmdHlp, "Page table is not present for %Dv.\n", &VarGCPtr);
|
---|
3275 | if (fPSE && Pde.n.u1Size)
|
---|
3276 | return pCmdHlp->pfnExec(pCmdHlp, "dpd%s %Dv L3", &pCmd->pszCmd[3], &VarGCPtr);
|
---|
3277 |
|
---|
3278 | iEntry = (VarGCPtr.u.GCFlat >> X86_PT_SHIFT) & X86_PT_MASK;
|
---|
3279 | VarPTEAddr = VarCur;
|
---|
3280 | VarPTEAddr.u.u64Number = Pde.u & X86_PDE_PG_MASK;
|
---|
3281 | VarPTEAddr.u.u64Number += iEntry * sizeof(X86PTE);
|
---|
3282 | }
|
---|
3283 | cEntriesMax = (PAGE_SIZE - iEntry) / cbEntry;
|
---|
3284 | }
|
---|
3285 |
|
---|
3286 | /* adjust cEntries */
|
---|
3287 | cEntries = RT_MAX(1, cEntries);
|
---|
3288 | cEntries = RT_MIN(cEntries, cEntriesMax);
|
---|
3289 |
|
---|
3290 | /*
|
---|
3291 | * The display loop.
|
---|
3292 | */
|
---|
3293 | DBGCCmdHlpPrintf(pCmdHlp, iEntry != ~0U ? "%DV (base %DV / index %#x):\n" : "%DV:\n",
|
---|
3294 | &VarPTEAddr, &VarGCPtr, iEntry);
|
---|
3295 | do
|
---|
3296 | {
|
---|
3297 | /*
|
---|
3298 | * Read.
|
---|
3299 | */
|
---|
3300 | X86PTEPAE Pte;
|
---|
3301 | Pte.u = 0;
|
---|
3302 | rc = pCmdHlp->pfnMemRead(pCmdHlp, &Pte, cbEntry, &VarPTEAddr, NULL);
|
---|
3303 | if (RT_FAILURE(rc))
|
---|
3304 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "Reading PTE memory at %DV.\n", &VarPTEAddr);
|
---|
3305 |
|
---|
3306 | /*
|
---|
3307 | * Display.
|
---|
3308 | */
|
---|
3309 | if (iEntry != ~0U)
|
---|
3310 | {
|
---|
3311 | DBGCCmdHlpPrintf(pCmdHlp, "%03x %DV: ", iEntry, &VarGCPtr);
|
---|
3312 | iEntry++;
|
---|
3313 | }
|
---|
3314 | DBGCCmdHlpPrintf(pCmdHlp,
|
---|
3315 | fPAE
|
---|
3316 | ? "%016llx 4kb phys=%016llx %s %s %s %s %s avl=%02x %s %s %s %s %s"
|
---|
3317 | : "%08llx 4kb phys=%08llx %s %s %s %s %s avl=%02x %s %s %s %s %s",
|
---|
3318 | Pte.u,
|
---|
3319 | Pte.u & X86_PTE_PAE_PG_MASK,
|
---|
3320 | Pte.n.u1Present ? "p " : "np",
|
---|
3321 | Pte.n.u1Write ? "w" : "r",
|
---|
3322 | Pte.n.u1User ? "u" : "s",
|
---|
3323 | Pte.n.u1Accessed ? "a " : "na",
|
---|
3324 | Pte.n.u1Dirty ? "d " : "nd",
|
---|
3325 | Pte.n.u3Available,
|
---|
3326 | Pte.n.u1Global ? (fPGE ? "g" : "G") : " ",
|
---|
3327 | Pte.n.u1WriteThru ? "pwt" : " ",
|
---|
3328 | Pte.n.u1CacheDisable ? "pcd" : " ",
|
---|
3329 | Pte.n.u1PAT ? "pat" : " ",
|
---|
3330 | Pte.n.u1NoExecute ? (fNXE ? "nx" : "NX") : " "
|
---|
3331 | );
|
---|
3332 | if (Pte.u & UINT64_C(0x7fff000000000000))
|
---|
3333 | DBGCCmdHlpPrintf(pCmdHlp, " weird=%RX64", (Pte.u & UINT64_C(0x7fff000000000000)));
|
---|
3334 | rc = DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
3335 | if (RT_FAILURE(rc))
|
---|
3336 | return rc;
|
---|
3337 |
|
---|
3338 | /*
|
---|
3339 | * Advance.
|
---|
3340 | */
|
---|
3341 | VarPTEAddr.u.u64Number += cbEntry;
|
---|
3342 | if (iEntry != ~0U)
|
---|
3343 | VarGCPtr.u.GCFlat += PAGE_SIZE;
|
---|
3344 | } while (cEntries-- > 0);
|
---|
3345 |
|
---|
3346 | return VINF_SUCCESS;
|
---|
3347 | }
|
---|
3348 |
|
---|
3349 |
|
---|
3350 | /**
|
---|
3351 | * @callback_method_impl{FNDBGCCMD, The 'dptb' command.}
|
---|
3352 | */
|
---|
3353 | static DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3354 | {
|
---|
3355 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3356 | int rc1 = pCmdHlp->pfnExec(pCmdHlp, "dptg %DV", &paArgs[0]);
|
---|
3357 | int rc2 = pCmdHlp->pfnExec(pCmdHlp, "dpth %DV", &paArgs[0]);
|
---|
3358 | if (RT_FAILURE(rc1))
|
---|
3359 | return rc1;
|
---|
3360 | NOREF(pCmd); NOREF(cArgs);
|
---|
3361 | return rc2;
|
---|
3362 | }
|
---|
3363 |
|
---|
3364 |
|
---|
3365 | /**
|
---|
3366 | * @callback_method_impl{FNDBGCCMD, The 'dt' command.}
|
---|
3367 | */
|
---|
3368 | static DECLCALLBACK(int) dbgcCmdDumpTSS(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3369 | {
|
---|
3370 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
3371 | int rc;
|
---|
3372 |
|
---|
3373 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3374 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs <= 1);
|
---|
3375 | if (cArgs == 1)
|
---|
3376 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType != DBGCVAR_TYPE_STRING
|
---|
3377 | && paArgs[0].enmType != DBGCVAR_TYPE_SYMBOL);
|
---|
3378 |
|
---|
3379 | /*
|
---|
3380 | * Check if the command indicates the type.
|
---|
3381 | */
|
---|
3382 | enum { kTss16, kTss32, kTss64, kTssToBeDetermined } enmTssType = kTssToBeDetermined;
|
---|
3383 | if (!strcmp(pCmd->pszCmd, "dt16"))
|
---|
3384 | enmTssType = kTss16;
|
---|
3385 | else if (!strcmp(pCmd->pszCmd, "dt32"))
|
---|
3386 | enmTssType = kTss32;
|
---|
3387 | else if (!strcmp(pCmd->pszCmd, "dt64"))
|
---|
3388 | enmTssType = kTss64;
|
---|
3389 |
|
---|
3390 | /*
|
---|
3391 | * We can get a TSS selector (number), a far pointer using a TSS selector, or some kind of TSS pointer.
|
---|
3392 | */
|
---|
3393 | uint32_t SelTss = UINT32_MAX;
|
---|
3394 | DBGCVAR VarTssAddr;
|
---|
3395 | if (cArgs == 0)
|
---|
3396 | {
|
---|
3397 | /** @todo consider querying the hidden bits instead (missing API). */
|
---|
3398 | uint16_t SelTR;
|
---|
3399 | rc = DBGFR3RegCpuQueryU16(pUVM, pDbgc->idCpu, DBGFREG_TR, &SelTR);
|
---|
3400 | if (RT_FAILURE(rc))
|
---|
3401 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to query TR, rc=%Rrc\n", rc);
|
---|
3402 | DBGCVAR_INIT_GC_FAR(&VarTssAddr, SelTR, 0);
|
---|
3403 | SelTss = SelTR;
|
---|
3404 | }
|
---|
3405 | else if (paArgs[0].enmType == DBGCVAR_TYPE_NUMBER)
|
---|
3406 | {
|
---|
3407 | if (paArgs[0].u.u64Number < 0xffff)
|
---|
3408 | DBGCVAR_INIT_GC_FAR(&VarTssAddr, (RTSEL)paArgs[0].u.u64Number, 0);
|
---|
3409 | else
|
---|
3410 | {
|
---|
3411 | if (paArgs[0].enmRangeType == DBGCVAR_RANGE_ELEMENTS)
|
---|
3412 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Element count doesn't combine with a TSS address.\n");
|
---|
3413 | DBGCVAR_INIT_GC_FLAT(&VarTssAddr, paArgs[0].u.u64Number);
|
---|
3414 | if (paArgs[0].enmRangeType == DBGCVAR_RANGE_BYTES)
|
---|
3415 | {
|
---|
3416 | VarTssAddr.enmRangeType = paArgs[0].enmRangeType;
|
---|
3417 | VarTssAddr.u64Range = paArgs[0].u64Range;
|
---|
3418 | }
|
---|
3419 | }
|
---|
3420 | }
|
---|
3421 | else
|
---|
3422 | VarTssAddr = paArgs[0];
|
---|
3423 |
|
---|
3424 | /*
|
---|
3425 | * Deal with TSS:ign by means of the GDT.
|
---|
3426 | */
|
---|
3427 | if (VarTssAddr.enmType == DBGCVAR_TYPE_GC_FAR)
|
---|
3428 | {
|
---|
3429 | SelTss = VarTssAddr.u.GCFar.sel;
|
---|
3430 | DBGFSELINFO SelInfo;
|
---|
3431 | rc = DBGFR3SelQueryInfo(pUVM, pDbgc->idCpu, VarTssAddr.u.GCFar.sel, DBGFSELQI_FLAGS_DT_GUEST, &SelInfo);
|
---|
3432 | if (RT_FAILURE(rc))
|
---|
3433 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "DBGFR3SelQueryInfo(,%u,%d,,) -> %Rrc.\n",
|
---|
3434 | pDbgc->idCpu, VarTssAddr.u.GCFar.sel, rc);
|
---|
3435 |
|
---|
3436 | if (SelInfo.u.Raw.Gen.u1DescType)
|
---|
3437 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "%04x is not a TSS selector. (!sys)\n", VarTssAddr.u.GCFar.sel);
|
---|
3438 |
|
---|
3439 | switch (SelInfo.u.Raw.Gen.u4Type)
|
---|
3440 | {
|
---|
3441 | case X86_SEL_TYPE_SYS_286_TSS_BUSY:
|
---|
3442 | case X86_SEL_TYPE_SYS_286_TSS_AVAIL:
|
---|
3443 | if (enmTssType == kTssToBeDetermined)
|
---|
3444 | enmTssType = kTss16;
|
---|
3445 | break;
|
---|
3446 |
|
---|
3447 | case X86_SEL_TYPE_SYS_386_TSS_BUSY: /* AMD64 too */
|
---|
3448 | case X86_SEL_TYPE_SYS_386_TSS_AVAIL:
|
---|
3449 | if (enmTssType == kTssToBeDetermined)
|
---|
3450 | enmTssType = SelInfo.fFlags & DBGFSELINFO_FLAGS_LONG_MODE ? kTss64 : kTss32;
|
---|
3451 | break;
|
---|
3452 |
|
---|
3453 | default:
|
---|
3454 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "%04x is not a TSS selector. (type=%x)\n",
|
---|
3455 | VarTssAddr.u.GCFar.sel, SelInfo.u.Raw.Gen.u4Type);
|
---|
3456 | }
|
---|
3457 |
|
---|
3458 | DBGCVAR_INIT_GC_FLAT(&VarTssAddr, SelInfo.GCPtrBase);
|
---|
3459 | DBGCVAR_SET_RANGE(&VarTssAddr, DBGCVAR_RANGE_BYTES, RT_MAX(SelInfo.cbLimit + 1, SelInfo.cbLimit));
|
---|
3460 | }
|
---|
3461 |
|
---|
3462 | /*
|
---|
3463 | * Determine the TSS type if none is currently given.
|
---|
3464 | */
|
---|
3465 | if (enmTssType == kTssToBeDetermined)
|
---|
3466 | {
|
---|
3467 | if ( VarTssAddr.u64Range > 0
|
---|
3468 | && VarTssAddr.u64Range < sizeof(X86TSS32) - 4)
|
---|
3469 | enmTssType = kTss16;
|
---|
3470 | else
|
---|
3471 | {
|
---|
3472 | uint64_t uEfer;
|
---|
3473 | rc = DBGFR3RegCpuQueryU64(pUVM, pDbgc->idCpu, DBGFREG_MSR_K6_EFER, &uEfer);
|
---|
3474 | if ( RT_FAILURE(rc)
|
---|
3475 | || !(uEfer & MSR_K6_EFER_LMA) )
|
---|
3476 | enmTssType = kTss32;
|
---|
3477 | else
|
---|
3478 | enmTssType = kTss64;
|
---|
3479 | }
|
---|
3480 | }
|
---|
3481 |
|
---|
3482 | /*
|
---|
3483 | * Figure the min/max sizes.
|
---|
3484 | * ASSUMES max TSS size is 64 KB.
|
---|
3485 | */
|
---|
3486 | uint32_t cbTssMin;
|
---|
3487 | uint32_t cbTssMax;
|
---|
3488 | switch (enmTssType)
|
---|
3489 | {
|
---|
3490 | case kTss16:
|
---|
3491 | cbTssMin = cbTssMax = X86_SEL_TYPE_SYS_286_TSS_LIMIT_MIN + 1;
|
---|
3492 | break;
|
---|
3493 | case kTss32:
|
---|
3494 | cbTssMin = X86_SEL_TYPE_SYS_386_TSS_LIMIT_MIN + 1;
|
---|
3495 | cbTssMax = _64K;
|
---|
3496 | break;
|
---|
3497 | case kTss64:
|
---|
3498 | cbTssMin = X86_SEL_TYPE_SYS_386_TSS_LIMIT_MIN + 1;
|
---|
3499 | cbTssMax = _64K;
|
---|
3500 | break;
|
---|
3501 | default:
|
---|
3502 | AssertFailedReturn(VERR_INTERNAL_ERROR);
|
---|
3503 | }
|
---|
3504 | uint32_t cbTss = VarTssAddr.enmRangeType == DBGCVAR_RANGE_BYTES ? (uint32_t)VarTssAddr.u64Range : 0;
|
---|
3505 | if (cbTss == 0)
|
---|
3506 | cbTss = cbTssMin;
|
---|
3507 | else if (cbTss < cbTssMin)
|
---|
3508 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Minimum TSS size is %u bytes, you specified %llu (%llx) bytes.\n",
|
---|
3509 | cbTssMin, VarTssAddr.u64Range, VarTssAddr.u64Range);
|
---|
3510 | else if (cbTss > cbTssMax)
|
---|
3511 | cbTss = cbTssMax;
|
---|
3512 | DBGCVAR_SET_RANGE(&VarTssAddr, DBGCVAR_RANGE_BYTES, cbTss);
|
---|
3513 |
|
---|
3514 | /*
|
---|
3515 | * Read the TSS into a temporary buffer.
|
---|
3516 | */
|
---|
3517 | uint8_t abBuf[_64K];
|
---|
3518 | size_t cbTssRead;
|
---|
3519 | rc = DBGCCmdHlpMemRead(pCmdHlp, abBuf, cbTss, &VarTssAddr, &cbTssRead);
|
---|
3520 | if (RT_FAILURE(rc))
|
---|
3521 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to read TSS at %Dv: %Rrc\n", &VarTssAddr, rc);
|
---|
3522 | if (cbTssRead < cbTssMin)
|
---|
3523 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to read essential parts of the TSS (read %zu, min %zu).\n",
|
---|
3524 | cbTssRead, cbTssMin);
|
---|
3525 | if (cbTssRead < cbTss)
|
---|
3526 | memset(&abBuf[cbTssRead], 0xff, cbTss - cbTssRead);
|
---|
3527 |
|
---|
3528 |
|
---|
3529 | /*
|
---|
3530 | * Format the TSS.
|
---|
3531 | */
|
---|
3532 | uint16_t offIoBitmap;
|
---|
3533 | switch (enmTssType)
|
---|
3534 | {
|
---|
3535 | case kTss16:
|
---|
3536 | {
|
---|
3537 | PCX86TSS16 pTss = (PCX86TSS16)&abBuf[0];
|
---|
3538 | if (SelTss != UINT32_MAX)
|
---|
3539 | DBGCCmdHlpPrintf(pCmdHlp, "%04x TSS16 at %Dv\n", SelTss, &VarTssAddr);
|
---|
3540 | else
|
---|
3541 | DBGCCmdHlpPrintf(pCmdHlp, "TSS16 at %Dv\n", &VarTssAddr);
|
---|
3542 | DBGCCmdHlpPrintf(pCmdHlp,
|
---|
3543 | "ax=%04x bx=%04x cx=%04x dx=%04x si=%04x di=%04x\n"
|
---|
3544 | "ip=%04x sp=%04x bp=%04x\n"
|
---|
3545 | "cs=%04x ss=%04x ds=%04x es=%04x flags=%04x\n"
|
---|
3546 | "ss:sp0=%04x:%04x ss:sp1=%04x:%04x ss:sp2=%04x:%04x\n"
|
---|
3547 | "prev=%04x ldtr=%04x\n"
|
---|
3548 | ,
|
---|
3549 | pTss->ax, pTss->bx, pTss->cx, pTss->dx, pTss->si, pTss->di,
|
---|
3550 | pTss->ip, pTss->sp, pTss->bp,
|
---|
3551 | pTss->cs, pTss->ss, pTss->ds, pTss->es, pTss->flags,
|
---|
3552 | pTss->ss0, pTss->sp0, pTss->ss1, pTss->sp1, pTss->ss2, pTss->sp2,
|
---|
3553 | pTss->selPrev, pTss->selLdt);
|
---|
3554 | if (pTss->cs != 0)
|
---|
3555 | pCmdHlp->pfnExec(pCmdHlp, "u %04x:%04x L 0", pTss->cs, pTss->ip);
|
---|
3556 | offIoBitmap = 0;
|
---|
3557 | break;
|
---|
3558 | }
|
---|
3559 |
|
---|
3560 | case kTss32:
|
---|
3561 | {
|
---|
3562 | PCX86TSS32 pTss = (PCX86TSS32)&abBuf[0];
|
---|
3563 | if (SelTss != UINT32_MAX)
|
---|
3564 | DBGCCmdHlpPrintf(pCmdHlp, "%04x TSS32 at %Dv (min=%04x)\n", SelTss, &VarTssAddr, cbTssMin);
|
---|
3565 | else
|
---|
3566 | DBGCCmdHlpPrintf(pCmdHlp, "TSS32 at %Dv (min=%04x)\n", &VarTssAddr, cbTssMin);
|
---|
3567 | DBGCCmdHlpPrintf(pCmdHlp,
|
---|
3568 | "eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\n"
|
---|
3569 | "eip=%08x esp=%08x ebp=%08x\n"
|
---|
3570 | "cs=%04x ss=%04x ds=%04x es=%04x fs=%04x gs=%04x eflags=%08x\n"
|
---|
3571 | "ss:esp0=%04x:%08x ss:esp1=%04x:%08x ss:esp2=%04x:%08x\n"
|
---|
3572 | "prev=%04x ldtr=%04x cr3=%08x debug=%u iomap=%04x\n"
|
---|
3573 | ,
|
---|
3574 | pTss->eax, pTss->ebx, pTss->ecx, pTss->edx, pTss->esi, pTss->edi,
|
---|
3575 | pTss->eip, pTss->esp, pTss->ebp,
|
---|
3576 | pTss->cs, pTss->ss, pTss->ds, pTss->es, pTss->fs, pTss->gs, pTss->eflags,
|
---|
3577 | pTss->ss0, pTss->esp0, pTss->ss1, pTss->esp1, pTss->ss2, pTss->esp2,
|
---|
3578 | pTss->selPrev, pTss->selLdt, pTss->cr3, pTss->fDebugTrap, pTss->offIoBitmap);
|
---|
3579 | if (pTss->cs != 0)
|
---|
3580 | pCmdHlp->pfnExec(pCmdHlp, "u %04x:%08x L 0", pTss->cs, pTss->eip);
|
---|
3581 | offIoBitmap = pTss->offIoBitmap;
|
---|
3582 | break;
|
---|
3583 | }
|
---|
3584 |
|
---|
3585 | case kTss64:
|
---|
3586 | {
|
---|
3587 | PCX86TSS64 pTss = (PCX86TSS64)&abBuf[0];
|
---|
3588 | if (SelTss != UINT32_MAX)
|
---|
3589 | DBGCCmdHlpPrintf(pCmdHlp, "%04x TSS64 at %Dv (min=%04x)\n", SelTss, &VarTssAddr, cbTssMin);
|
---|
3590 | else
|
---|
3591 | DBGCCmdHlpPrintf(pCmdHlp, "TSS64 at %Dv (min=%04x)\n", &VarTssAddr, cbTssMin);
|
---|
3592 | DBGCCmdHlpPrintf(pCmdHlp,
|
---|
3593 | "rsp0=%016RX16 rsp1=%016RX16 rsp2=%016RX16\n"
|
---|
3594 | "ist1=%016RX16 ist2=%016RX16\n"
|
---|
3595 | "ist3=%016RX16 ist4=%016RX16\n"
|
---|
3596 | "ist5=%016RX16 ist6=%016RX16\n"
|
---|
3597 | "ist7=%016RX16 iomap=%04x\n"
|
---|
3598 | ,
|
---|
3599 | pTss->rsp0, pTss->rsp1, pTss->rsp2,
|
---|
3600 | pTss->ist1, pTss->ist2,
|
---|
3601 | pTss->ist3, pTss->ist4,
|
---|
3602 | pTss->ist5, pTss->ist6,
|
---|
3603 | pTss->ist7, pTss->offIoBitmap);
|
---|
3604 | offIoBitmap = pTss->offIoBitmap;
|
---|
3605 | break;
|
---|
3606 | }
|
---|
3607 |
|
---|
3608 | default:
|
---|
3609 | AssertFailedReturn(VERR_INTERNAL_ERROR);
|
---|
3610 | }
|
---|
3611 |
|
---|
3612 | /*
|
---|
3613 | * Dump the interrupt redirection bitmap.
|
---|
3614 | */
|
---|
3615 | if (enmTssType != kTss16)
|
---|
3616 | {
|
---|
3617 | if ( offIoBitmap > cbTssMin
|
---|
3618 | && offIoBitmap < cbTss) /** @todo check exactly what the edge cases are here. */
|
---|
3619 | {
|
---|
3620 | if (offIoBitmap - cbTssMin >= 32)
|
---|
3621 | {
|
---|
3622 | DBGCCmdHlpPrintf(pCmdHlp, "Interrupt redirection:\n");
|
---|
3623 | uint8_t const *pbIntRedirBitmap = &abBuf[offIoBitmap - 32];
|
---|
3624 | uint32_t iStart = 0;
|
---|
3625 | bool fPrev = ASMBitTest(pbIntRedirBitmap, 0); /* LE/BE issue */
|
---|
3626 | for (uint32_t i = 0; i < 256; i++)
|
---|
3627 | {
|
---|
3628 | bool fThis = ASMBitTest(pbIntRedirBitmap, i);
|
---|
3629 | if (fThis != fPrev)
|
---|
3630 | {
|
---|
3631 | DBGCCmdHlpPrintf(pCmdHlp, "%02x-%02x %s\n", iStart, i - 1, fPrev ? "Protected mode" : "Redirected");
|
---|
3632 | fPrev = fThis;
|
---|
3633 | iStart = i;
|
---|
3634 | }
|
---|
3635 | }
|
---|
3636 | if (iStart != 255)
|
---|
3637 | DBGCCmdHlpPrintf(pCmdHlp, "%02x-%02x %s\n", iStart, 255, fPrev ? "Protected mode" : "Redirected");
|
---|
3638 | }
|
---|
3639 | else
|
---|
3640 | DBGCCmdHlpPrintf(pCmdHlp, "Invalid interrupt redirection bitmap size: %u (%#x), expected 32 bytes.\n",
|
---|
3641 | offIoBitmap - cbTssMin, offIoBitmap - cbTssMin);
|
---|
3642 | }
|
---|
3643 | else if (offIoBitmap > 0)
|
---|
3644 | DBGCCmdHlpPrintf(pCmdHlp, "No interrupt redirection bitmap (-%#x)\n", cbTssMin - offIoBitmap);
|
---|
3645 | else
|
---|
3646 | DBGCCmdHlpPrintf(pCmdHlp, "No interrupt redirection bitmap\n");
|
---|
3647 | }
|
---|
3648 |
|
---|
3649 | /*
|
---|
3650 | * Dump the I/O permission bitmap if present. The IOPM cannot start below offset 0x64
|
---|
3651 | * (that applies to both 32-bit and 64-bit TSSs since their size is the same).
|
---|
3652 | */
|
---|
3653 | if (enmTssType != kTss16)
|
---|
3654 | {
|
---|
3655 | if (offIoBitmap < cbTss && offIoBitmap >= 0x64)
|
---|
3656 | {
|
---|
3657 | uint32_t cPorts = RT_MIN((cbTss - offIoBitmap) * 8, _64K);
|
---|
3658 | DBGCVAR VarAddr;
|
---|
3659 | DBGCCmdHlpEval(pCmdHlp, &VarAddr, "%DV + %#x", &VarTssAddr, offIoBitmap);
|
---|
3660 | DBGCCmdHlpPrintf(pCmdHlp, "I/O bitmap at %DV - %#x ports:\n", &VarAddr, cPorts);
|
---|
3661 |
|
---|
3662 | uint8_t const *pbIoBitmap = &abBuf[offIoBitmap];
|
---|
3663 | uint32_t iStart = 0;
|
---|
3664 | bool fPrev = ASMBitTest(pbIoBitmap, 0);
|
---|
3665 | uint32_t cLine = 0;
|
---|
3666 | for (uint32_t i = 1; i < cPorts; i++)
|
---|
3667 | {
|
---|
3668 | bool fThis = ASMBitTest(pbIoBitmap, i);
|
---|
3669 | if (fThis != fPrev)
|
---|
3670 | {
|
---|
3671 | cLine++;
|
---|
3672 | DBGCCmdHlpPrintf(pCmdHlp, "%04x-%04x %s%s", iStart, i-1,
|
---|
3673 | fPrev ? "GP" : "OK", (cLine % 6) == 0 ? "\n" : " ");
|
---|
3674 | fPrev = fThis;
|
---|
3675 | iStart = i;
|
---|
3676 | }
|
---|
3677 | }
|
---|
3678 | if (iStart != _64K-1)
|
---|
3679 | DBGCCmdHlpPrintf(pCmdHlp, "%04x-%04x %s\n", iStart, _64K-1, fPrev ? "GP" : "OK");
|
---|
3680 | }
|
---|
3681 | else if (offIoBitmap > 0)
|
---|
3682 | DBGCCmdHlpPrintf(pCmdHlp, "No I/O bitmap (-%#x)\n", cbTssMin - offIoBitmap);
|
---|
3683 | else
|
---|
3684 | DBGCCmdHlpPrintf(pCmdHlp, "No I/O bitmap\n");
|
---|
3685 | }
|
---|
3686 |
|
---|
3687 | return VINF_SUCCESS;
|
---|
3688 | }
|
---|
3689 |
|
---|
3690 |
|
---|
3691 | /**
|
---|
3692 | * @callback_method_impl{FNDBGFR3TYPEDUMP, The 'dti' command dumper callback.}
|
---|
3693 | */
|
---|
3694 | static DECLCALLBACK(int) dbgcCmdDumpTypeInfoCallback(uint32_t off, const char *pszField, uint32_t iLvl,
|
---|
3695 | const char *pszType, uint32_t fTypeFlags,
|
---|
3696 | uint32_t cElements, void *pvUser)
|
---|
3697 | {
|
---|
3698 | PDBGCCMDHLP pCmdHlp = (PDBGCCMDHLP)pvUser;
|
---|
3699 |
|
---|
3700 | /* Pad with spaces to match the level. */
|
---|
3701 | for (uint32_t i = 0; i < iLvl; i++)
|
---|
3702 | DBGCCmdHlpPrintf(pCmdHlp, " ");
|
---|
3703 |
|
---|
3704 | size_t cbWritten = 0;
|
---|
3705 | DBGCCmdHlpPrintfEx(pCmdHlp, &cbWritten, "+0x%04x %s", off, pszField);
|
---|
3706 | while (cbWritten < 32)
|
---|
3707 | {
|
---|
3708 | /* Fill with spaces to get proper aligning. */
|
---|
3709 | DBGCCmdHlpPrintf(pCmdHlp, " ");
|
---|
3710 | cbWritten++;
|
---|
3711 | }
|
---|
3712 |
|
---|
3713 | DBGCCmdHlpPrintf(pCmdHlp, ": ");
|
---|
3714 | if (fTypeFlags & DBGFTYPEREGMEMBER_F_ARRAY)
|
---|
3715 | DBGCCmdHlpPrintf(pCmdHlp, "[%u] ", cElements);
|
---|
3716 | if (fTypeFlags & DBGFTYPEREGMEMBER_F_POINTER)
|
---|
3717 | DBGCCmdHlpPrintf(pCmdHlp, "Ptr ");
|
---|
3718 | DBGCCmdHlpPrintf(pCmdHlp, "%s\n", pszType);
|
---|
3719 |
|
---|
3720 | return VINF_SUCCESS;
|
---|
3721 | }
|
---|
3722 |
|
---|
3723 |
|
---|
3724 | /**
|
---|
3725 | * @callback_method_impl{FNDBGCCMD, The 'dti' command.}
|
---|
3726 | */
|
---|
3727 | static DECLCALLBACK(int) dbgcCmdDumpTypeInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3728 | {
|
---|
3729 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
3730 | int rc;
|
---|
3731 |
|
---|
3732 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3733 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 1 || cArgs == 2);
|
---|
3734 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_STRING);
|
---|
3735 | if (cArgs == 2)
|
---|
3736 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[1].enmType == DBGCVAR_TYPE_NUMBER);
|
---|
3737 |
|
---|
3738 | uint32_t cLvlMax = cArgs == 2 ? (uint32_t)paArgs[1].u.u64Number : UINT32_MAX;
|
---|
3739 | return DBGFR3TypeDumpEx(pUVM, paArgs[0].u.pszString, 0 /* fFlags */, cLvlMax,
|
---|
3740 | dbgcCmdDumpTypeInfoCallback, pCmdHlp);
|
---|
3741 | }
|
---|
3742 |
|
---|
3743 |
|
---|
3744 | static void dbgcCmdDumpTypedValCallbackBuiltin(PDBGCCMDHLP pCmdHlp, DBGFTYPEBUILTIN enmType, size_t cbType,
|
---|
3745 | PDBGFTYPEVALBUF pValBuf)
|
---|
3746 | {
|
---|
3747 | switch (enmType)
|
---|
3748 | {
|
---|
3749 | case DBGFTYPEBUILTIN_UINT8:
|
---|
3750 | DBGCCmdHlpPrintf(pCmdHlp, "%RU8", pValBuf->u8);
|
---|
3751 | break;
|
---|
3752 | case DBGFTYPEBUILTIN_INT8:
|
---|
3753 | DBGCCmdHlpPrintf(pCmdHlp, "%RI8", pValBuf->i8);
|
---|
3754 | break;
|
---|
3755 | case DBGFTYPEBUILTIN_UINT16:
|
---|
3756 | DBGCCmdHlpPrintf(pCmdHlp, "%RU16", pValBuf->u16);
|
---|
3757 | break;
|
---|
3758 | case DBGFTYPEBUILTIN_INT16:
|
---|
3759 | DBGCCmdHlpPrintf(pCmdHlp, "%RI16", pValBuf->i16);
|
---|
3760 | break;
|
---|
3761 | case DBGFTYPEBUILTIN_UINT32:
|
---|
3762 | DBGCCmdHlpPrintf(pCmdHlp, "%RU32", pValBuf->u32);
|
---|
3763 | break;
|
---|
3764 | case DBGFTYPEBUILTIN_INT32:
|
---|
3765 | DBGCCmdHlpPrintf(pCmdHlp, "%RI32", pValBuf->i32);
|
---|
3766 | break;
|
---|
3767 | case DBGFTYPEBUILTIN_UINT64:
|
---|
3768 | DBGCCmdHlpPrintf(pCmdHlp, "%RU64", pValBuf->u64);
|
---|
3769 | break;
|
---|
3770 | case DBGFTYPEBUILTIN_INT64:
|
---|
3771 | DBGCCmdHlpPrintf(pCmdHlp, "%RI64", pValBuf->i64);
|
---|
3772 | break;
|
---|
3773 | case DBGFTYPEBUILTIN_PTR32:
|
---|
3774 | DBGCCmdHlpPrintf(pCmdHlp, "%RX32", pValBuf->GCPtr);
|
---|
3775 | break;
|
---|
3776 | case DBGFTYPEBUILTIN_PTR64:
|
---|
3777 | DBGCCmdHlpPrintf(pCmdHlp, "%RX64", pValBuf->GCPtr);
|
---|
3778 | break;
|
---|
3779 | case DBGFTYPEBUILTIN_PTR:
|
---|
3780 | if (cbType == sizeof(uint32_t))
|
---|
3781 | DBGCCmdHlpPrintf(pCmdHlp, "%RX32", pValBuf->GCPtr);
|
---|
3782 | else if (cbType == sizeof(uint64_t))
|
---|
3783 | DBGCCmdHlpPrintf(pCmdHlp, "%RX64", pValBuf->GCPtr);
|
---|
3784 | else
|
---|
3785 | DBGCCmdHlpPrintf(pCmdHlp, "<Unsupported pointer width %u>", cbType);
|
---|
3786 | break;
|
---|
3787 | case DBGFTYPEBUILTIN_SIZE:
|
---|
3788 | if (cbType == sizeof(uint32_t))
|
---|
3789 | DBGCCmdHlpPrintf(pCmdHlp, "%RU32", pValBuf->size);
|
---|
3790 | else if (cbType == sizeof(uint64_t))
|
---|
3791 | DBGCCmdHlpPrintf(pCmdHlp, "%RU64", pValBuf->size);
|
---|
3792 | else
|
---|
3793 | DBGCCmdHlpPrintf(pCmdHlp, "<Unsupported size width %u>", cbType);
|
---|
3794 | break;
|
---|
3795 | case DBGFTYPEBUILTIN_FLOAT32:
|
---|
3796 | case DBGFTYPEBUILTIN_FLOAT64:
|
---|
3797 | case DBGFTYPEBUILTIN_COMPOUND:
|
---|
3798 | default:
|
---|
3799 | AssertMsgFailed(("Invalid built-in type: %d\n", enmType));
|
---|
3800 | }
|
---|
3801 | }
|
---|
3802 |
|
---|
3803 | /**
|
---|
3804 | * @callback_method_impl{FNDBGFR3TYPEDUMP, The 'dtv' command dumper callback.}
|
---|
3805 | */
|
---|
3806 | static DECLCALLBACK(int) dbgcCmdDumpTypedValCallback(uint32_t off, const char *pszField, uint32_t iLvl,
|
---|
3807 | DBGFTYPEBUILTIN enmType, size_t cbType,
|
---|
3808 | PDBGFTYPEVALBUF pValBuf, uint32_t cValBufs,
|
---|
3809 | void *pvUser)
|
---|
3810 | {
|
---|
3811 | PDBGCCMDHLP pCmdHlp = (PDBGCCMDHLP)pvUser;
|
---|
3812 |
|
---|
3813 | /* Pad with spaces to match the level. */
|
---|
3814 | for (uint32_t i = 0; i < iLvl; i++)
|
---|
3815 | DBGCCmdHlpPrintf(pCmdHlp, " ");
|
---|
3816 |
|
---|
3817 | size_t cbWritten = 0;
|
---|
3818 | DBGCCmdHlpPrintfEx(pCmdHlp, &cbWritten, "+0x%04x %s", off, pszField);
|
---|
3819 | while (cbWritten < 32)
|
---|
3820 | {
|
---|
3821 | /* Fill with spaces to get proper aligning. */
|
---|
3822 | DBGCCmdHlpPrintf(pCmdHlp, " ");
|
---|
3823 | cbWritten++;
|
---|
3824 | }
|
---|
3825 |
|
---|
3826 | DBGCCmdHlpPrintf(pCmdHlp, ": ");
|
---|
3827 | if (cValBufs > 1)
|
---|
3828 | DBGCCmdHlpPrintf(pCmdHlp, "[%u] [ ", cValBufs);
|
---|
3829 |
|
---|
3830 | for (uint32_t i = 0; i < cValBufs; i++)
|
---|
3831 | {
|
---|
3832 | dbgcCmdDumpTypedValCallbackBuiltin(pCmdHlp, enmType, cbType, pValBuf);
|
---|
3833 | if (i < cValBufs - 1)
|
---|
3834 | DBGCCmdHlpPrintf(pCmdHlp, " , ");
|
---|
3835 | pValBuf++;
|
---|
3836 | }
|
---|
3837 |
|
---|
3838 | if (cValBufs > 1)
|
---|
3839 | DBGCCmdHlpPrintf(pCmdHlp, " ]");
|
---|
3840 | DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
3841 |
|
---|
3842 | return VINF_SUCCESS;
|
---|
3843 | }
|
---|
3844 |
|
---|
3845 |
|
---|
3846 | /**
|
---|
3847 | * @callback_method_impl{FNDBGCCMD, The 'dtv' command.}
|
---|
3848 | */
|
---|
3849 | static DECLCALLBACK(int) dbgcCmdDumpTypedVal(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3850 | {
|
---|
3851 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
3852 | int rc;
|
---|
3853 |
|
---|
3854 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3855 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs == 2 || cArgs == 3);
|
---|
3856 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[0].enmType == DBGCVAR_TYPE_STRING);
|
---|
3857 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISGCPOINTER(paArgs[1].enmType));
|
---|
3858 | if (cArgs == 3)
|
---|
3859 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[2].enmType == DBGCVAR_TYPE_NUMBER);
|
---|
3860 |
|
---|
3861 | /*
|
---|
3862 | * Make DBGF address and fix the range.
|
---|
3863 | */
|
---|
3864 | DBGFADDRESS Address;
|
---|
3865 | rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[1], &Address);
|
---|
3866 | if (RT_FAILURE(rc))
|
---|
3867 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "VarToDbgfAddr(,%Dv,)\n", &paArgs[1]);
|
---|
3868 |
|
---|
3869 | uint32_t cLvlMax = cArgs == 3 ? (uint32_t)paArgs[2].u.u64Number : UINT32_MAX;
|
---|
3870 | return DBGFR3TypeValDumpEx(pUVM, &Address, paArgs[0].u.pszString, 0 /* fFlags */, cLvlMax,
|
---|
3871 | dbgcCmdDumpTypedValCallback, pCmdHlp);
|
---|
3872 | }
|
---|
3873 |
|
---|
3874 | /**
|
---|
3875 | * @callback_method_impl{FNDBGCCMD, The 'm' command.}
|
---|
3876 | */
|
---|
3877 | static DECLCALLBACK(int) dbgcCmdMemoryInfo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
3878 | {
|
---|
3879 | DBGCCmdHlpPrintf(pCmdHlp, "Address: %DV\n", &paArgs[0]);
|
---|
3880 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
3881 | return dbgcCmdDumpPageHierarchy(pCmd, pCmdHlp, pUVM, paArgs, cArgs);
|
---|
3882 | }
|
---|
3883 |
|
---|
3884 |
|
---|
3885 | /**
|
---|
3886 | * Converts one or more variables into a byte buffer for a
|
---|
3887 | * given unit size.
|
---|
3888 | *
|
---|
3889 | * @returns VBox status codes:
|
---|
3890 | * @retval VERR_TOO_MUCH_DATA if the buffer is too small, bitched.
|
---|
3891 | * @retval VERR_INTERNAL_ERROR on bad variable type, bitched.
|
---|
3892 | * @retval VINF_SUCCESS on success.
|
---|
3893 | *
|
---|
3894 | * @param pvBuf The buffer to convert into.
|
---|
3895 | * @param pcbBuf The buffer size on input. The size of the result on output.
|
---|
3896 | * @param cbUnit The unit size to apply when converting.
|
---|
3897 | * The high bit is used to indicate unicode string.
|
---|
3898 | * @param paVars The array of variables to convert.
|
---|
3899 | * @param cVars The number of variables.
|
---|
3900 | */
|
---|
3901 | int dbgcVarsToBytes(PDBGCCMDHLP pCmdHlp, void *pvBuf, uint32_t *pcbBuf, size_t cbUnit, PCDBGCVAR paVars, unsigned cVars)
|
---|
3902 | {
|
---|
3903 | union
|
---|
3904 | {
|
---|
3905 | uint8_t *pu8;
|
---|
3906 | uint16_t *pu16;
|
---|
3907 | uint32_t *pu32;
|
---|
3908 | uint64_t *pu64;
|
---|
3909 | } u, uEnd;
|
---|
3910 | u.pu8 = (uint8_t *)pvBuf;
|
---|
3911 | uEnd.pu8 = u.pu8 + *pcbBuf;
|
---|
3912 |
|
---|
3913 | unsigned i;
|
---|
3914 | for (i = 0; i < cVars && u.pu8 < uEnd.pu8; i++)
|
---|
3915 | {
|
---|
3916 | switch (paVars[i].enmType)
|
---|
3917 | {
|
---|
3918 | case DBGCVAR_TYPE_GC_FAR:
|
---|
3919 | case DBGCVAR_TYPE_GC_FLAT:
|
---|
3920 | case DBGCVAR_TYPE_GC_PHYS:
|
---|
3921 | case DBGCVAR_TYPE_HC_FLAT:
|
---|
3922 | case DBGCVAR_TYPE_HC_PHYS:
|
---|
3923 | case DBGCVAR_TYPE_NUMBER:
|
---|
3924 | {
|
---|
3925 | uint64_t u64 = paVars[i].u.u64Number;
|
---|
3926 | switch (cbUnit & 0x1f)
|
---|
3927 | {
|
---|
3928 | case 1:
|
---|
3929 | do
|
---|
3930 | {
|
---|
3931 | *u.pu8++ = u64;
|
---|
3932 | u64 >>= 8;
|
---|
3933 | } while (u64);
|
---|
3934 | break;
|
---|
3935 | case 2:
|
---|
3936 | do
|
---|
3937 | {
|
---|
3938 | *u.pu16++ = u64;
|
---|
3939 | u64 >>= 16;
|
---|
3940 | } while (u64);
|
---|
3941 | break;
|
---|
3942 | case 4:
|
---|
3943 | *u.pu32++ = u64;
|
---|
3944 | u64 >>= 32;
|
---|
3945 | if (u64)
|
---|
3946 | *u.pu32++ = u64;
|
---|
3947 | break;
|
---|
3948 | case 8:
|
---|
3949 | *u.pu64++ = u64;
|
---|
3950 | break;
|
---|
3951 | }
|
---|
3952 | break;
|
---|
3953 | }
|
---|
3954 |
|
---|
3955 | case DBGCVAR_TYPE_STRING:
|
---|
3956 | case DBGCVAR_TYPE_SYMBOL:
|
---|
3957 | {
|
---|
3958 | const char *psz = paVars[i].u.pszString;
|
---|
3959 | size_t cbString = strlen(psz);
|
---|
3960 | if (cbUnit & RT_BIT_32(31))
|
---|
3961 | {
|
---|
3962 | /* Explode char to unit. */
|
---|
3963 | if (cbString > (uintptr_t)(uEnd.pu8 - u.pu8) * (cbUnit & 0x1f))
|
---|
3964 | {
|
---|
3965 | pCmdHlp->pfnVBoxError(pCmdHlp, VERR_TOO_MUCH_DATA, "Max %d bytes.\n", uEnd.pu8 - (uint8_t *)pvBuf);
|
---|
3966 | return VERR_TOO_MUCH_DATA;
|
---|
3967 | }
|
---|
3968 | while (*psz)
|
---|
3969 | {
|
---|
3970 | switch (cbUnit & 0x1f)
|
---|
3971 | {
|
---|
3972 | case 1: *u.pu8++ = *psz; break;
|
---|
3973 | case 2: *u.pu16++ = *psz; break;
|
---|
3974 | case 4: *u.pu32++ = *psz; break;
|
---|
3975 | case 8: *u.pu64++ = *psz; break;
|
---|
3976 | }
|
---|
3977 | psz++;
|
---|
3978 | }
|
---|
3979 | }
|
---|
3980 | else
|
---|
3981 | {
|
---|
3982 | /* Raw copy with zero padding if the size isn't aligned. */
|
---|
3983 | if (cbString > (uintptr_t)(uEnd.pu8 - u.pu8))
|
---|
3984 | {
|
---|
3985 | pCmdHlp->pfnVBoxError(pCmdHlp, VERR_TOO_MUCH_DATA, "Max %d bytes.\n", uEnd.pu8 - (uint8_t *)pvBuf);
|
---|
3986 | return VERR_TOO_MUCH_DATA;
|
---|
3987 | }
|
---|
3988 |
|
---|
3989 | size_t cbCopy = cbString & ~(cbUnit - 1);
|
---|
3990 | memcpy(u.pu8, psz, cbCopy);
|
---|
3991 | u.pu8 += cbCopy;
|
---|
3992 | psz += cbCopy;
|
---|
3993 |
|
---|
3994 | size_t cbReminder = cbString & (cbUnit - 1);
|
---|
3995 | if (cbReminder)
|
---|
3996 | {
|
---|
3997 | memcpy(u.pu8, psz, cbString & (cbUnit - 1));
|
---|
3998 | memset(u.pu8 + cbReminder, 0, cbUnit - cbReminder);
|
---|
3999 | u.pu8 += cbUnit;
|
---|
4000 | }
|
---|
4001 | }
|
---|
4002 | break;
|
---|
4003 | }
|
---|
4004 |
|
---|
4005 | default:
|
---|
4006 | *pcbBuf = u.pu8 - (uint8_t *)pvBuf;
|
---|
4007 | pCmdHlp->pfnVBoxError(pCmdHlp, VERR_INTERNAL_ERROR,
|
---|
4008 | "i=%d enmType=%d\n", i, paVars[i].enmType);
|
---|
4009 | return VERR_INTERNAL_ERROR;
|
---|
4010 | }
|
---|
4011 | }
|
---|
4012 | *pcbBuf = u.pu8 - (uint8_t *)pvBuf;
|
---|
4013 | if (i != cVars)
|
---|
4014 | {
|
---|
4015 | pCmdHlp->pfnVBoxError(pCmdHlp, VERR_TOO_MUCH_DATA, "Max %d bytes.\n", uEnd.pu8 - (uint8_t *)pvBuf);
|
---|
4016 | return VERR_TOO_MUCH_DATA;
|
---|
4017 | }
|
---|
4018 | return VINF_SUCCESS;
|
---|
4019 | }
|
---|
4020 |
|
---|
4021 |
|
---|
4022 | /**
|
---|
4023 | * @callback_method_impl{FNDBGCCMD, The 'eb'\, 'ew'\, 'ed' and 'eq' commands.}
|
---|
4024 | */
|
---|
4025 | static DECLCALLBACK(int) dbgcCmdEditMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
4026 | {
|
---|
4027 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
4028 | unsigned iArg;
|
---|
4029 |
|
---|
4030 | /*
|
---|
4031 | * Validate input.
|
---|
4032 | */
|
---|
4033 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs >= 2);
|
---|
4034 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, DBGCVAR_ISPOINTER(paArgs[0].enmType));
|
---|
4035 | for (iArg = 1; iArg < cArgs; iArg++)
|
---|
4036 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, paArgs[iArg].enmType == DBGCVAR_TYPE_NUMBER);
|
---|
4037 | DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM);
|
---|
4038 |
|
---|
4039 | /*
|
---|
4040 | * Figure out the element size.
|
---|
4041 | */
|
---|
4042 | unsigned cbElement;
|
---|
4043 | switch (pCmd->pszCmd[1])
|
---|
4044 | {
|
---|
4045 | default:
|
---|
4046 | case 'b': cbElement = 1; break;
|
---|
4047 | case 'w': cbElement = 2; break;
|
---|
4048 | case 'd': cbElement = 4; break;
|
---|
4049 | case 'q': cbElement = 8; break;
|
---|
4050 | }
|
---|
4051 |
|
---|
4052 | /*
|
---|
4053 | * Do setting.
|
---|
4054 | */
|
---|
4055 | DBGCVAR Addr = paArgs[0];
|
---|
4056 | for (iArg = 1;;)
|
---|
4057 | {
|
---|
4058 | size_t cbWritten;
|
---|
4059 | int rc = pCmdHlp->pfnMemWrite(pCmdHlp, &paArgs[iArg].u, cbElement, &Addr, &cbWritten);
|
---|
4060 | if (RT_FAILURE(rc))
|
---|
4061 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Writing memory at %DV.\n", &Addr);
|
---|
4062 | if (cbWritten != cbElement)
|
---|
4063 | return DBGCCmdHlpFail(pCmdHlp, pCmd, "Only wrote %u out of %u bytes!\n", cbWritten, cbElement);
|
---|
4064 |
|
---|
4065 | /* advance. */
|
---|
4066 | iArg++;
|
---|
4067 | if (iArg >= cArgs)
|
---|
4068 | break;
|
---|
4069 | rc = DBGCCmdHlpEval(pCmdHlp, &Addr, "%Dv + %#x", &Addr, cbElement);
|
---|
4070 | if (RT_FAILURE(rc))
|
---|
4071 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "%%(%Dv)", &paArgs[0]);
|
---|
4072 | }
|
---|
4073 |
|
---|
4074 | return VINF_SUCCESS;
|
---|
4075 | }
|
---|
4076 |
|
---|
4077 |
|
---|
4078 | /**
|
---|
4079 | * Executes the search.
|
---|
4080 | *
|
---|
4081 | * @returns VBox status code.
|
---|
4082 | * @param pCmdHlp The command helpers.
|
---|
4083 | * @param pUVM The user mode VM handle.
|
---|
4084 | * @param pAddress The address to start searching from. (undefined on output)
|
---|
4085 | * @param cbRange The address range to search. Must not wrap.
|
---|
4086 | * @param pabBytes The byte pattern to search for.
|
---|
4087 | * @param cbBytes The size of the pattern.
|
---|
4088 | * @param cbUnit The search unit.
|
---|
4089 | * @param cMaxHits The max number of hits.
|
---|
4090 | * @param pResult Where to store the result if it's a function invocation.
|
---|
4091 | */
|
---|
4092 | static int dbgcCmdWorkerSearchMemDoIt(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PDBGFADDRESS pAddress, RTGCUINTPTR cbRange,
|
---|
4093 | const uint8_t *pabBytes, uint32_t cbBytes,
|
---|
4094 | uint32_t cbUnit, uint64_t cMaxHits, PDBGCVAR pResult)
|
---|
4095 | {
|
---|
4096 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
4097 |
|
---|
4098 | /*
|
---|
4099 | * Do the search.
|
---|
4100 | */
|
---|
4101 | uint64_t cHits = 0;
|
---|
4102 | for (;;)
|
---|
4103 | {
|
---|
4104 | /* search */
|
---|
4105 | DBGFADDRESS HitAddress;
|
---|
4106 | int rc = DBGFR3MemScan(pUVM, pDbgc->idCpu, pAddress, cbRange, 1, pabBytes, cbBytes, &HitAddress);
|
---|
4107 | if (RT_FAILURE(rc))
|
---|
4108 | {
|
---|
4109 | if (rc != VERR_DBGF_MEM_NOT_FOUND)
|
---|
4110 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3MemScan\n");
|
---|
4111 |
|
---|
4112 | /* update the current address so we can save it (later). */
|
---|
4113 | pAddress->off += cbRange;
|
---|
4114 | pAddress->FlatPtr += cbRange;
|
---|
4115 | cbRange = 0;
|
---|
4116 | break;
|
---|
4117 | }
|
---|
4118 |
|
---|
4119 | /* report result */
|
---|
4120 | DBGCVAR VarCur;
|
---|
4121 | rc = DBGCCmdHlpVarFromDbgfAddr(pCmdHlp, &HitAddress, &VarCur);
|
---|
4122 | if (RT_FAILURE(rc))
|
---|
4123 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGCCmdHlpVarFromDbgfAddr\n");
|
---|
4124 | if (!pResult)
|
---|
4125 | pCmdHlp->pfnExec(pCmdHlp, "db %DV LB 10", &VarCur);
|
---|
4126 | else
|
---|
4127 | DBGCVAR_ASSIGN(pResult, &VarCur);
|
---|
4128 |
|
---|
4129 | /* advance */
|
---|
4130 | cbRange -= HitAddress.FlatPtr - pAddress->FlatPtr;
|
---|
4131 | *pAddress = HitAddress;
|
---|
4132 | pAddress->FlatPtr += cbBytes;
|
---|
4133 | pAddress->off += cbBytes;
|
---|
4134 | if (cbRange <= cbBytes)
|
---|
4135 | {
|
---|
4136 | cbRange = 0;
|
---|
4137 | break;
|
---|
4138 | }
|
---|
4139 | cbRange -= cbBytes;
|
---|
4140 |
|
---|
4141 | if (++cHits >= cMaxHits)
|
---|
4142 | {
|
---|
4143 | /// @todo save the search.
|
---|
4144 | break;
|
---|
4145 | }
|
---|
4146 | }
|
---|
4147 |
|
---|
4148 | /*
|
---|
4149 | * Save the search so we can resume it...
|
---|
4150 | */
|
---|
4151 | if (pDbgc->abSearch != pabBytes)
|
---|
4152 | {
|
---|
4153 | memcpy(pDbgc->abSearch, pabBytes, cbBytes);
|
---|
4154 | pDbgc->cbSearch = cbBytes;
|
---|
4155 | pDbgc->cbSearchUnit = cbUnit;
|
---|
4156 | }
|
---|
4157 | pDbgc->cMaxSearchHits = cMaxHits;
|
---|
4158 | pDbgc->SearchAddr = *pAddress;
|
---|
4159 | pDbgc->cbSearchRange = cbRange;
|
---|
4160 |
|
---|
4161 | return cHits ? VINF_SUCCESS : VERR_DBGC_COMMAND_FAILED;
|
---|
4162 | }
|
---|
4163 |
|
---|
4164 |
|
---|
4165 | /**
|
---|
4166 | * Resumes the previous search.
|
---|
4167 | *
|
---|
4168 | * @returns VBox status code.
|
---|
4169 | * @param pCmdHlp Pointer to the command helper functions.
|
---|
4170 | * @param pUVM The user mode VM handle.
|
---|
4171 | * @param pResult Where to store the result of a function invocation.
|
---|
4172 | */
|
---|
4173 | static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PDBGCVAR pResult)
|
---|
4174 | {
|
---|
4175 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
4176 |
|
---|
4177 | /*
|
---|
4178 | * Make sure there is a previous command.
|
---|
4179 | */
|
---|
4180 | if (!pDbgc->cbSearch)
|
---|
4181 | {
|
---|
4182 | DBGCCmdHlpPrintf(pCmdHlp, "Error: No previous search\n");
|
---|
4183 | return VERR_DBGC_COMMAND_FAILED;
|
---|
4184 | }
|
---|
4185 |
|
---|
4186 | /*
|
---|
4187 | * Make range and address adjustments.
|
---|
4188 | */
|
---|
4189 | DBGFADDRESS Address = pDbgc->SearchAddr;
|
---|
4190 | if (Address.FlatPtr == ~(RTGCUINTPTR)0)
|
---|
4191 | {
|
---|
4192 | Address.FlatPtr -= Address.off;
|
---|
4193 | Address.off = 0;
|
---|
4194 | }
|
---|
4195 |
|
---|
4196 | RTGCUINTPTR cbRange = pDbgc->cbSearchRange;
|
---|
4197 | if (!cbRange)
|
---|
4198 | cbRange = ~(RTGCUINTPTR)0;
|
---|
4199 | if (Address.FlatPtr + cbRange < pDbgc->SearchAddr.FlatPtr)
|
---|
4200 | cbRange = ~(RTGCUINTPTR)0 - pDbgc->SearchAddr.FlatPtr + !!pDbgc->SearchAddr.FlatPtr;
|
---|
4201 |
|
---|
4202 | return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pUVM, &Address, cbRange, pDbgc->abSearch, pDbgc->cbSearch,
|
---|
4203 | pDbgc->cbSearchUnit, pDbgc->cMaxSearchHits, pResult);
|
---|
4204 | }
|
---|
4205 |
|
---|
4206 |
|
---|
4207 | /**
|
---|
4208 | * Search memory, worker for the 's' and 's?' functions.
|
---|
4209 | *
|
---|
4210 | * @returns VBox status code.
|
---|
4211 | * @param pCmdHlp Pointer to the command helper functions.
|
---|
4212 | * @param pUVM The user mode VM handle.
|
---|
4213 | * @param pAddress Where to start searching. If no range, search till end of address space.
|
---|
4214 | * @param cMaxHits The maximum number of hits.
|
---|
4215 | * @param chType The search type.
|
---|
4216 | * @param paPatArgs The pattern variable array.
|
---|
4217 | * @param cPatArgs Number of pattern variables.
|
---|
4218 | * @param pResult Where to store the result of a function invocation.
|
---|
4219 | */
|
---|
4220 | static int dbgcCmdWorkerSearchMem(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR pAddress, uint64_t cMaxHits, char chType,
|
---|
4221 | PCDBGCVAR paPatArgs, unsigned cPatArgs, PDBGCVAR pResult)
|
---|
4222 | {
|
---|
4223 | if (pResult)
|
---|
4224 | DBGCVAR_INIT_GC_FLAT(pResult, 0);
|
---|
4225 |
|
---|
4226 | /*
|
---|
4227 | * Convert the search pattern into bytes and DBGFR3MemScan can deal with.
|
---|
4228 | */
|
---|
4229 | uint32_t cbUnit;
|
---|
4230 | switch (chType)
|
---|
4231 | {
|
---|
4232 | case 'a':
|
---|
4233 | case 'b': cbUnit = 1; break;
|
---|
4234 | case 'u': cbUnit = 2 | RT_BIT_32(31); break;
|
---|
4235 | case 'w': cbUnit = 2; break;
|
---|
4236 | case 'd': cbUnit = 4; break;
|
---|
4237 | case 'q': cbUnit = 8; break;
|
---|
4238 | default:
|
---|
4239 | return pCmdHlp->pfnVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "chType=%c\n", chType);
|
---|
4240 | }
|
---|
4241 | uint8_t abBytes[RT_SIZEOFMEMB(DBGC, abSearch)];
|
---|
4242 | uint32_t cbBytes = sizeof(abBytes);
|
---|
4243 | int rc = dbgcVarsToBytes(pCmdHlp, abBytes, &cbBytes, cbUnit, paPatArgs, cPatArgs);
|
---|
4244 | if (RT_FAILURE(rc))
|
---|
4245 | return VERR_DBGC_COMMAND_FAILED;
|
---|
4246 |
|
---|
4247 | /*
|
---|
4248 | * Make DBGF address and fix the range.
|
---|
4249 | */
|
---|
4250 | DBGFADDRESS Address;
|
---|
4251 | rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, pAddress, &Address);
|
---|
4252 | if (RT_FAILURE(rc))
|
---|
4253 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "VarToDbgfAddr(,%Dv,)\n", pAddress);
|
---|
4254 |
|
---|
4255 | RTGCUINTPTR cbRange;
|
---|
4256 | switch (pAddress->enmRangeType)
|
---|
4257 | {
|
---|
4258 | case DBGCVAR_RANGE_BYTES:
|
---|
4259 | cbRange = pAddress->u64Range;
|
---|
4260 | if (cbRange != pAddress->u64Range)
|
---|
4261 | cbRange = ~(RTGCUINTPTR)0;
|
---|
4262 | break;
|
---|
4263 |
|
---|
4264 | case DBGCVAR_RANGE_ELEMENTS:
|
---|
4265 | cbRange = (RTGCUINTPTR)(pAddress->u64Range * cbUnit);
|
---|
4266 | if ( cbRange != pAddress->u64Range * cbUnit
|
---|
4267 | || cbRange < pAddress->u64Range)
|
---|
4268 | cbRange = ~(RTGCUINTPTR)0;
|
---|
4269 | break;
|
---|
4270 |
|
---|
4271 | default:
|
---|
4272 | cbRange = ~(RTGCUINTPTR)0;
|
---|
4273 | break;
|
---|
4274 | }
|
---|
4275 | if (Address.FlatPtr + cbRange < Address.FlatPtr)
|
---|
4276 | cbRange = ~(RTGCUINTPTR)0 - Address.FlatPtr + !!Address.FlatPtr;
|
---|
4277 |
|
---|
4278 | /*
|
---|
4279 | * Ok, do it.
|
---|
4280 | */
|
---|
4281 | return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pUVM, &Address, cbRange, abBytes, cbBytes, cbUnit, cMaxHits, pResult);
|
---|
4282 | }
|
---|
4283 |
|
---|
4284 |
|
---|
4285 | /**
|
---|
4286 | * @callback_method_impl{FNDBGCCMD, The 's' command.}
|
---|
4287 | */
|
---|
4288 | static DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
4289 | {
|
---|
4290 | /* check that the parser did what it's supposed to do. */
|
---|
4291 | //if ( cArgs <= 2
|
---|
4292 | // && paArgs[0].enmType != DBGCVAR_TYPE_STRING)
|
---|
4293 | // return DBGCCmdHlpPrintf(pCmdHlp, "parser error\n");
|
---|
4294 |
|
---|
4295 | /*
|
---|
4296 | * Repeat previous search?
|
---|
4297 | */
|
---|
4298 | if (cArgs == 0)
|
---|
4299 | return dbgcCmdWorkerSearchMemResume(pCmdHlp, pUVM, NULL);
|
---|
4300 |
|
---|
4301 | /*
|
---|
4302 | * Parse arguments.
|
---|
4303 | */
|
---|
4304 |
|
---|
4305 | return -1;
|
---|
4306 | }
|
---|
4307 |
|
---|
4308 |
|
---|
4309 | /**
|
---|
4310 | * @callback_method_impl{FNDBGCCMD, The 's?' command.}
|
---|
4311 | */
|
---|
4312 | static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
4313 | {
|
---|
4314 | /* check that the parser did what it's supposed to do. */
|
---|
4315 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, 0, cArgs >= 2 && DBGCVAR_ISGCPOINTER(paArgs[0].enmType));
|
---|
4316 | return dbgcCmdWorkerSearchMem(pCmdHlp, pUVM, &paArgs[0], 25, pCmd->pszCmd[1], paArgs + 1, cArgs - 1, NULL);
|
---|
4317 | }
|
---|
4318 |
|
---|
4319 |
|
---|
4320 | /**
|
---|
4321 | * Matching function for interrupts event names.
|
---|
4322 | *
|
---|
4323 | * This parses the interrupt number and length.
|
---|
4324 | *
|
---|
4325 | * @returns True if match, false if not.
|
---|
4326 | * @param pPattern The user specified pattern to match.
|
---|
4327 | * @param pszEvtName The event name.
|
---|
4328 | * @param pCmdHlp Command helpers for warning about malformed stuff.
|
---|
4329 | * @param piFirst Where to return start interrupt number on success.
|
---|
4330 | * @param pcInts Where to return the number of interrupts on success.
|
---|
4331 | */
|
---|
4332 | static bool dbgcEventIsMatchingInt(PCDBGCVAR pPattern, const char *pszEvtName, PDBGCCMDHLP pCmdHlp,
|
---|
4333 | uint8_t *piFirst, uint16_t *pcInts)
|
---|
4334 | {
|
---|
4335 | /*
|
---|
4336 | * Ignore trailing hex digits when comparing with the event base name.
|
---|
4337 | */
|
---|
4338 | const char *pszPattern = pPattern->u.pszString;
|
---|
4339 | const char *pszEnd = RTStrEnd(pszPattern, RTSTR_MAX);
|
---|
4340 | while ( (uintptr_t)pszEnd > (uintptr_t)pszPattern
|
---|
4341 | && RT_C_IS_XDIGIT(pszEnd[-1]))
|
---|
4342 | pszEnd -= 1;
|
---|
4343 | if (RTStrSimplePatternNMatch(pszPattern, pszEnd - pszPattern, pszEvtName, RTSTR_MAX))
|
---|
4344 | {
|
---|
4345 | /*
|
---|
4346 | * Parse the index and length.
|
---|
4347 | */
|
---|
4348 | if (!*pszEnd)
|
---|
4349 | *piFirst = 0;
|
---|
4350 | else
|
---|
4351 | {
|
---|
4352 | int rc = RTStrToUInt8Full(pszEnd, 16, piFirst);
|
---|
4353 | if (rc != VINF_SUCCESS)
|
---|
4354 | {
|
---|
4355 | if (RT_FAILURE(rc))
|
---|
4356 | *piFirst = 0;
|
---|
4357 | DBGCCmdHlpPrintf(pCmdHlp, "Warning: %Rrc parsing '%s' - interpreting it as %#x\n", rc, pszEnd, *piFirst);
|
---|
4358 | }
|
---|
4359 | }
|
---|
4360 |
|
---|
4361 | if (pPattern->enmRangeType == DBGCVAR_RANGE_NONE)
|
---|
4362 | *pcInts = 1;
|
---|
4363 | else
|
---|
4364 | *pcInts = RT_MAX(RT_MIN((uint16_t)pPattern->u64Range, 256 - *piFirst), 1);
|
---|
4365 | return true;
|
---|
4366 | }
|
---|
4367 | return false;
|
---|
4368 | }
|
---|
4369 |
|
---|
4370 |
|
---|
4371 | /**
|
---|
4372 | * Updates a DBGC event config.
|
---|
4373 | *
|
---|
4374 | * @returns VINF_SUCCESS or VERR_NO_MEMORY.
|
---|
4375 | * @param ppEvtCfg The event configuration entry to update.
|
---|
4376 | * @param pszCmd The new command. Leave command alone if NULL.
|
---|
4377 | * @param enmEvtState The new event state.
|
---|
4378 | * @param fChangeCmdOnly Whether to only update the command.
|
---|
4379 | */
|
---|
4380 | static int dbgcEventUpdate(PDBGCEVTCFG *ppEvtCfg, const char *pszCmd, DBGCEVTSTATE enmEvtState, bool fChangeCmdOnly)
|
---|
4381 | {
|
---|
4382 | PDBGCEVTCFG pEvtCfg = *ppEvtCfg;
|
---|
4383 |
|
---|
4384 | /*
|
---|
4385 | * If we've got a command string, update the command too.
|
---|
4386 | */
|
---|
4387 | if (pszCmd)
|
---|
4388 | {
|
---|
4389 | size_t cchCmd = strlen(pszCmd);
|
---|
4390 | if ( !cchCmd
|
---|
4391 | && ( !fChangeCmdOnly
|
---|
4392 | ? enmEvtState == kDbgcEvtState_Disabled
|
---|
4393 | : !pEvtCfg || pEvtCfg->enmState == kDbgcEvtState_Disabled))
|
---|
4394 | {
|
---|
4395 | /* NULL entry is fine if no command and disabled. */
|
---|
4396 | RTMemFree(pEvtCfg);
|
---|
4397 | *ppEvtCfg = NULL;
|
---|
4398 | }
|
---|
4399 | else
|
---|
4400 | {
|
---|
4401 | if (!pEvtCfg || pEvtCfg->cchCmd < cchCmd)
|
---|
4402 | {
|
---|
4403 | RTMemFree(pEvtCfg);
|
---|
4404 | *ppEvtCfg = pEvtCfg = (PDBGCEVTCFG)RTMemAlloc(RT_OFFSETOF(DBGCEVTCFG, szCmd[cchCmd + 1]));
|
---|
4405 | if (!pEvtCfg)
|
---|
4406 | return VERR_NO_MEMORY;
|
---|
4407 | }
|
---|
4408 | pEvtCfg->enmState = enmEvtState;
|
---|
4409 | pEvtCfg->cchCmd = cchCmd;
|
---|
4410 | memcpy(pEvtCfg->szCmd, pszCmd, cchCmd + 1);
|
---|
4411 | }
|
---|
4412 | }
|
---|
4413 | /*
|
---|
4414 | * Update existing or enable new. If NULL and not enabled, we can keep it that way.
|
---|
4415 | */
|
---|
4416 | else if (pEvtCfg || enmEvtState != kDbgcEvtState_Disabled)
|
---|
4417 | {
|
---|
4418 | if (!pEvtCfg)
|
---|
4419 | {
|
---|
4420 | *ppEvtCfg = pEvtCfg = (PDBGCEVTCFG)RTMemAlloc(sizeof(DBGCEVTCFG));
|
---|
4421 | if (!pEvtCfg)
|
---|
4422 | return VERR_NO_MEMORY;
|
---|
4423 | pEvtCfg->cchCmd = 0;
|
---|
4424 | pEvtCfg->szCmd[0] = '\0';
|
---|
4425 | }
|
---|
4426 | pEvtCfg->enmState = enmEvtState;
|
---|
4427 | }
|
---|
4428 |
|
---|
4429 | return VINF_SUCCESS;
|
---|
4430 | }
|
---|
4431 |
|
---|
4432 |
|
---|
4433 | /**
|
---|
4434 | * Record one settings change for a plain event.
|
---|
4435 | *
|
---|
4436 | * @returns The new @a cIntCfgs value.
|
---|
4437 | * @param paEventCfgs The event setttings array. Must have DBGFEVENT_END
|
---|
4438 | * entries.
|
---|
4439 | * @param cEventCfgs The current number of entries in @a paEventCfgs.
|
---|
4440 | * @param enmType The event to change the settings for.
|
---|
4441 | * @param enmEvtState The new event state.
|
---|
4442 | * @param iSxEvt Index into the g_aDbgcSxEvents array.
|
---|
4443 | *
|
---|
4444 | * @remarks We use abUnused[0] for the enmEvtState, while abUnused[1] and
|
---|
4445 | * abUnused[2] are used for iSxEvt.
|
---|
4446 | */
|
---|
4447 | static uint32_t dbgcEventAddPlainConfig(PDBGFEVENTCONFIG paEventCfgs, uint32_t cEventCfgs, DBGFEVENTTYPE enmType,
|
---|
4448 | DBGCEVTSTATE enmEvtState, uint16_t iSxEvt)
|
---|
4449 | {
|
---|
4450 | uint32_t iCfg;
|
---|
4451 | for (iCfg = 0; iCfg < cEventCfgs; iCfg++)
|
---|
4452 | if (paEventCfgs[iCfg].enmType == enmType)
|
---|
4453 | break;
|
---|
4454 | if (iCfg == cEventCfgs)
|
---|
4455 | {
|
---|
4456 | Assert(cEventCfgs < DBGFEVENT_END);
|
---|
4457 | paEventCfgs[iCfg].enmType = enmType;
|
---|
4458 | cEventCfgs++;
|
---|
4459 | }
|
---|
4460 | paEventCfgs[iCfg].fEnabled = enmEvtState > kDbgcEvtState_Disabled;
|
---|
4461 | paEventCfgs[iCfg].abUnused[0] = enmEvtState;
|
---|
4462 | paEventCfgs[iCfg].abUnused[1] = (uint8_t)iSxEvt;
|
---|
4463 | paEventCfgs[iCfg].abUnused[2] = (uint8_t)(iSxEvt >> 8);
|
---|
4464 | return cEventCfgs;
|
---|
4465 | }
|
---|
4466 |
|
---|
4467 |
|
---|
4468 | /**
|
---|
4469 | * Record one or more interrupt event config changes.
|
---|
4470 | *
|
---|
4471 | * @returns The new @a cIntCfgs value.
|
---|
4472 | * @param paIntCfgs Interrupt confiruation array. Must have 256 entries.
|
---|
4473 | * @param cIntCfgs The current number of entries in @a paIntCfgs.
|
---|
4474 | * @param iInt The interrupt number to start with.
|
---|
4475 | * @param cInts The number of interrupts to change.
|
---|
4476 | * @param pszName The settings name (hwint/swint).
|
---|
4477 | * @param enmEvtState The new event state.
|
---|
4478 | * @param bIntOp The new DBGF interrupt state.
|
---|
4479 | */
|
---|
4480 | static uint32_t dbgcEventAddIntConfig(PDBGFINTERRUPTCONFIG paIntCfgs, uint32_t cIntCfgs, uint8_t iInt, uint16_t cInts,
|
---|
4481 | const char *pszName, DBGCEVTSTATE enmEvtState, uint8_t bIntOp)
|
---|
4482 | {
|
---|
4483 | bool const fHwInt = *pszName == 'h';
|
---|
4484 |
|
---|
4485 | bIntOp |= (uint8_t)enmEvtState << 4;
|
---|
4486 | uint8_t const bSoftState = !fHwInt ? bIntOp : DBGFINTERRUPTSTATE_DONT_TOUCH;
|
---|
4487 | uint8_t const bHardState = fHwInt ? bIntOp : DBGFINTERRUPTSTATE_DONT_TOUCH;
|
---|
4488 |
|
---|
4489 | while (cInts > 0)
|
---|
4490 | {
|
---|
4491 | uint32_t iCfg;
|
---|
4492 | for (iCfg = 0; iCfg < cIntCfgs; iCfg++)
|
---|
4493 | if (paIntCfgs[iCfg].iInterrupt == iInt)
|
---|
4494 | break;
|
---|
4495 | if (iCfg == cIntCfgs)
|
---|
4496 | break;
|
---|
4497 | if (fHwInt)
|
---|
4498 | paIntCfgs[iCfg].enmHardState = bHardState;
|
---|
4499 | else
|
---|
4500 | paIntCfgs[iCfg].enmSoftState = bSoftState;
|
---|
4501 | iInt++;
|
---|
4502 | cInts--;
|
---|
4503 | }
|
---|
4504 |
|
---|
4505 | while (cInts > 0)
|
---|
4506 | {
|
---|
4507 | Assert(cIntCfgs < 256);
|
---|
4508 | paIntCfgs[cIntCfgs].iInterrupt = iInt;
|
---|
4509 | paIntCfgs[cIntCfgs].enmHardState = bHardState;
|
---|
4510 | paIntCfgs[cIntCfgs].enmSoftState = bSoftState;
|
---|
4511 | cIntCfgs++;
|
---|
4512 | iInt++;
|
---|
4513 | cInts--;
|
---|
4514 | }
|
---|
4515 |
|
---|
4516 | return cIntCfgs;
|
---|
4517 | }
|
---|
4518 |
|
---|
4519 |
|
---|
4520 | /**
|
---|
4521 | * Applies event settings changes to DBGC and DBGF.
|
---|
4522 | *
|
---|
4523 | * @returns VBox status code (fully bitched)
|
---|
4524 | * @param pCmdHlp The command helpers.
|
---|
4525 | * @param pUVM The user mode VM handle.
|
---|
4526 | * @param paIntCfgs Interrupt configuration array. We use the upper 4
|
---|
4527 | * bits of the settings for the DBGCEVTSTATE. This
|
---|
4528 | * will be cleared.
|
---|
4529 | * @param cIntCfgs Number of interrupt configuration changes.
|
---|
4530 | * @param paEventCfgs The generic event configuration array. We use the
|
---|
4531 | * abUnused[0] member for the DBGCEVTSTATE, and
|
---|
4532 | * abUnused[2:1] for the g_aDbgcSxEvents index.
|
---|
4533 | * @param cEventCfgs The number of generic event settings changes.
|
---|
4534 | * @param pszCmd The commands to associate with the changed events.
|
---|
4535 | * If this is NULL, don't touch the command.
|
---|
4536 | * @param fChangeCmdOnly Whether to only change the commands (sx-).
|
---|
4537 | */
|
---|
4538 | static int dbgcEventApplyChanges(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PDBGFINTERRUPTCONFIG paIntCfgs, uint32_t cIntCfgs,
|
---|
4539 | PCDBGFEVENTCONFIG paEventCfgs, uint32_t cEventCfgs, const char *pszCmd, bool fChangeCmdOnly)
|
---|
4540 | {
|
---|
4541 | int rc;
|
---|
4542 |
|
---|
4543 | /*
|
---|
4544 | * Apply changes to DBGC. This can only fail with out of memory error.
|
---|
4545 | */
|
---|
4546 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
4547 | if (cIntCfgs)
|
---|
4548 | for (uint32_t iCfg = 0; iCfg < cIntCfgs; iCfg++)
|
---|
4549 | {
|
---|
4550 | DBGCEVTSTATE enmEvtState = (DBGCEVTSTATE)(paIntCfgs[iCfg].enmHardState >> 4);
|
---|
4551 | paIntCfgs[iCfg].enmHardState &= 0xf;
|
---|
4552 | if (paIntCfgs[iCfg].enmHardState != DBGFINTERRUPTSTATE_DONT_TOUCH)
|
---|
4553 | {
|
---|
4554 | rc = dbgcEventUpdate(&pDbgc->apHardInts[paIntCfgs[iCfg].iInterrupt], pszCmd, enmEvtState, fChangeCmdOnly);
|
---|
4555 | if (RT_FAILURE(rc))
|
---|
4556 | return rc;
|
---|
4557 | }
|
---|
4558 |
|
---|
4559 | enmEvtState = (DBGCEVTSTATE)(paIntCfgs[iCfg].enmSoftState >> 4);
|
---|
4560 | paIntCfgs[iCfg].enmSoftState &= 0xf;
|
---|
4561 | if (paIntCfgs[iCfg].enmSoftState != DBGFINTERRUPTSTATE_DONT_TOUCH)
|
---|
4562 | {
|
---|
4563 | rc = dbgcEventUpdate(&pDbgc->apSoftInts[paIntCfgs[iCfg].iInterrupt], pszCmd, enmEvtState, fChangeCmdOnly);
|
---|
4564 | if (RT_FAILURE(rc))
|
---|
4565 | return rc;
|
---|
4566 | }
|
---|
4567 | }
|
---|
4568 |
|
---|
4569 | if (cEventCfgs)
|
---|
4570 | {
|
---|
4571 | for (uint32_t iCfg = 0; iCfg < cEventCfgs; iCfg++)
|
---|
4572 | {
|
---|
4573 | Assert((unsigned)paEventCfgs[iCfg].enmType < RT_ELEMENTS(pDbgc->apEventCfgs));
|
---|
4574 | uint16_t iSxEvt = RT_MAKE_U16(paEventCfgs[iCfg].abUnused[1], paEventCfgs[iCfg].abUnused[2]);
|
---|
4575 | Assert(iSxEvt < RT_ELEMENTS(g_aDbgcSxEvents));
|
---|
4576 | rc = dbgcEventUpdate(&pDbgc->apEventCfgs[iSxEvt], pszCmd, (DBGCEVTSTATE)paEventCfgs[iCfg].abUnused[0], fChangeCmdOnly);
|
---|
4577 | if (RT_FAILURE(rc))
|
---|
4578 | return rc;
|
---|
4579 | }
|
---|
4580 | }
|
---|
4581 |
|
---|
4582 | /*
|
---|
4583 | * Apply changes to DBGF.
|
---|
4584 | */
|
---|
4585 | if (!fChangeCmdOnly)
|
---|
4586 | {
|
---|
4587 | if (cIntCfgs)
|
---|
4588 | {
|
---|
4589 | rc = DBGFR3InterruptConfigEx(pUVM, paIntCfgs, cIntCfgs);
|
---|
4590 | if (RT_FAILURE(rc))
|
---|
4591 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3InterruptConfigEx: %Rrc\n", rc);
|
---|
4592 | }
|
---|
4593 | if (cEventCfgs)
|
---|
4594 | {
|
---|
4595 | rc = DBGFR3EventConfigEx(pUVM, paEventCfgs, cEventCfgs);
|
---|
4596 | if (RT_FAILURE(rc))
|
---|
4597 | return DBGCCmdHlpVBoxError(pCmdHlp, rc, "DBGFR3EventConfigEx: %Rrc\n", rc);
|
---|
4598 | }
|
---|
4599 | }
|
---|
4600 |
|
---|
4601 | return VINF_SUCCESS;
|
---|
4602 | }
|
---|
4603 |
|
---|
4604 |
|
---|
4605 | /**
|
---|
4606 | * @callback_method_impl{FNDBGCCMD, The 'sx[eni-]' commands.}
|
---|
4607 | */
|
---|
4608 | static DECLCALLBACK(int) dbgcCmdEventCtrl(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
4609 | {
|
---|
4610 | /*
|
---|
4611 | * Figure out which command this is.
|
---|
4612 | */
|
---|
4613 | uint8_t bIntOp;
|
---|
4614 | DBGCEVTSTATE enmEvtState;
|
---|
4615 | bool fChangeCmdOnly;
|
---|
4616 | switch (pCmd->pszCmd[2])
|
---|
4617 | {
|
---|
4618 | case 'e': bIntOp = DBGFINTERRUPTSTATE_ENABLED; enmEvtState = kDbgcEvtState_Enabled; fChangeCmdOnly = false; break;
|
---|
4619 | case 'n': bIntOp = DBGFINTERRUPTSTATE_ENABLED; enmEvtState = kDbgcEvtState_Notify; fChangeCmdOnly = false; break;
|
---|
4620 | case '-': bIntOp = DBGFINTERRUPTSTATE_ENABLED; enmEvtState = kDbgcEvtState_Invalid; fChangeCmdOnly = true; break;
|
---|
4621 | case 'i': bIntOp = DBGFINTERRUPTSTATE_DISABLED; enmEvtState = kDbgcEvtState_Disabled; fChangeCmdOnly = false; break;
|
---|
4622 | default:
|
---|
4623 | return DBGCCmdHlpVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "pszCmd=%s\n", pCmd->pszCmd);
|
---|
4624 | }
|
---|
4625 |
|
---|
4626 | /*
|
---|
4627 | * Command option.
|
---|
4628 | */
|
---|
4629 | unsigned iArg = 0;
|
---|
4630 | const char *pszCmd = NULL;
|
---|
4631 | if ( cArgs >= iArg + 2
|
---|
4632 | && paArgs[iArg].enmType == DBGCVAR_TYPE_STRING
|
---|
4633 | && paArgs[iArg + 1].enmType == DBGCVAR_TYPE_STRING
|
---|
4634 | && strcmp(paArgs[iArg].u.pszString, "-c") == 0)
|
---|
4635 | {
|
---|
4636 | pszCmd = paArgs[iArg + 1].u.pszString;
|
---|
4637 | iArg += 2;
|
---|
4638 | }
|
---|
4639 | if (fChangeCmdOnly && !pszCmd)
|
---|
4640 | return DBGCCmdHlpVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "The 'sx-' requires the '-c cmd' arguments.\n");
|
---|
4641 |
|
---|
4642 | /*
|
---|
4643 | * The remaining arguments are event specifiers to which the operation should be applied.
|
---|
4644 | */
|
---|
4645 | uint32_t cIntCfgs = 0;
|
---|
4646 | DBGFINTERRUPTCONFIG aIntCfgs[256];
|
---|
4647 | uint32_t cEventCfgs = 0;
|
---|
4648 | DBGFEVENTCONFIG aEventCfgs[DBGFEVENT_END];
|
---|
4649 |
|
---|
4650 | for (; iArg < cArgs; iArg++)
|
---|
4651 | {
|
---|
4652 | DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, iArg, paArgs[iArg].enmType == DBGCVAR_TYPE_STRING
|
---|
4653 | || paArgs[iArg].enmType == DBGCVAR_TYPE_SYMBOL);
|
---|
4654 | uint32_t cHits = 0;
|
---|
4655 | for (uint32_t iEvt = 0; iEvt < RT_ELEMENTS(g_aDbgcSxEvents); iEvt++)
|
---|
4656 | if (g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Plain)
|
---|
4657 | {
|
---|
4658 | if ( RTStrSimplePatternMatch(paArgs[iArg].u.pszString, g_aDbgcSxEvents[iEvt].pszName)
|
---|
4659 | || ( g_aDbgcSxEvents[iEvt].pszAltNm
|
---|
4660 | && RTStrSimplePatternMatch(paArgs[iArg].u.pszString, g_aDbgcSxEvents[iEvt].pszAltNm)) )
|
---|
4661 | {
|
---|
4662 | cEventCfgs = dbgcEventAddPlainConfig(aEventCfgs, cEventCfgs, g_aDbgcSxEvents[iEvt].enmType,
|
---|
4663 | enmEvtState, iEvt);
|
---|
4664 | cHits++;
|
---|
4665 | }
|
---|
4666 | }
|
---|
4667 | else
|
---|
4668 | {
|
---|
4669 | Assert(g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Interrupt);
|
---|
4670 | uint8_t iInt;
|
---|
4671 | uint16_t cInts;
|
---|
4672 | if (dbgcEventIsMatchingInt(&paArgs[iArg], g_aDbgcSxEvents[iEvt].pszName, pCmdHlp, &iInt, &cInts))
|
---|
4673 | {
|
---|
4674 | cIntCfgs = dbgcEventAddIntConfig(aIntCfgs, cIntCfgs, iInt, cInts, g_aDbgcSxEvents[iEvt].pszName,
|
---|
4675 | enmEvtState, bIntOp);
|
---|
4676 | cHits++;
|
---|
4677 | }
|
---|
4678 | }
|
---|
4679 | if (!cHits)
|
---|
4680 | return DBGCCmdHlpVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "Unknown event: '%s'\n", paArgs[iArg].u.pszString);
|
---|
4681 | }
|
---|
4682 |
|
---|
4683 | /*
|
---|
4684 | * Apply the changes.
|
---|
4685 | */
|
---|
4686 | return dbgcEventApplyChanges(pCmdHlp, pUVM, aIntCfgs, cIntCfgs, aEventCfgs, cEventCfgs, pszCmd, fChangeCmdOnly);
|
---|
4687 | }
|
---|
4688 |
|
---|
4689 |
|
---|
4690 | /**
|
---|
4691 | * @callback_method_impl{FNDBGCCMD, The 'sxr' commands.}
|
---|
4692 | */
|
---|
4693 | static DECLCALLBACK(int) dbgcCmdEventCtrlReset(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
4694 | {
|
---|
4695 | uint32_t cEventCfgs = 0;
|
---|
4696 | DBGFEVENTCONFIG aEventCfgs[DBGFEVENT_END];
|
---|
4697 | uint32_t cIntCfgs = 0;
|
---|
4698 | DBGFINTERRUPTCONFIG aIntCfgs[256];
|
---|
4699 |
|
---|
4700 | if (cArgs == 0)
|
---|
4701 | {
|
---|
4702 | /*
|
---|
4703 | * All events.
|
---|
4704 | */
|
---|
4705 | for (uint32_t iInt = 0; iInt < 256; iInt++)
|
---|
4706 | {
|
---|
4707 | aIntCfgs[iInt].iInterrupt = iInt;
|
---|
4708 | aIntCfgs[iInt].enmHardState = DBGFINTERRUPTSTATE_DONT_TOUCH;
|
---|
4709 | aIntCfgs[iInt].enmSoftState = DBGFINTERRUPTSTATE_DONT_TOUCH;
|
---|
4710 | }
|
---|
4711 | cIntCfgs = 256;
|
---|
4712 |
|
---|
4713 | for (uint32_t iEvt = 0; iEvt < RT_ELEMENTS(g_aDbgcSxEvents); iEvt++)
|
---|
4714 | if (g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Plain)
|
---|
4715 | {
|
---|
4716 | aEventCfgs[cEventCfgs].enmType = g_aDbgcSxEvents[iEvt].enmType;
|
---|
4717 | aEventCfgs[cEventCfgs].fEnabled = g_aDbgcSxEvents[iEvt].enmDefault > kDbgcEvtState_Disabled;
|
---|
4718 | aEventCfgs[cEventCfgs].abUnused[0] = g_aDbgcSxEvents[iEvt].enmDefault;
|
---|
4719 | aEventCfgs[cEventCfgs].abUnused[1] = (uint8_t)iEvt;
|
---|
4720 | aEventCfgs[cEventCfgs].abUnused[2] = (uint8_t)(iEvt >> 8);
|
---|
4721 | cEventCfgs++;
|
---|
4722 | }
|
---|
4723 | else
|
---|
4724 | {
|
---|
4725 | uint8_t const bState = ( g_aDbgcSxEvents[iEvt].enmDefault > kDbgcEvtState_Disabled
|
---|
4726 | ? DBGFINTERRUPTSTATE_ENABLED : DBGFINTERRUPTSTATE_DISABLED)
|
---|
4727 | | ((uint8_t)g_aDbgcSxEvents[iEvt].enmDefault << 4);
|
---|
4728 | if (strcmp(g_aDbgcSxEvents[iEvt].pszName, "hwint") == 0)
|
---|
4729 | for (uint32_t iInt = 0; iInt < 256; iInt++)
|
---|
4730 | aIntCfgs[iInt].enmHardState = bState;
|
---|
4731 | else
|
---|
4732 | for (uint32_t iInt = 0; iInt < 256; iInt++)
|
---|
4733 | aIntCfgs[iInt].enmSoftState = bState;
|
---|
4734 | }
|
---|
4735 | }
|
---|
4736 | else
|
---|
4737 | {
|
---|
4738 | /*
|
---|
4739 | * Selected events.
|
---|
4740 | */
|
---|
4741 | for (uint32_t iArg = 0; iArg < cArgs; iArg++)
|
---|
4742 | {
|
---|
4743 | unsigned cHits = 0;
|
---|
4744 | for (uint32_t iEvt = 0; iEvt < RT_ELEMENTS(g_aDbgcSxEvents); iEvt++)
|
---|
4745 | if (g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Plain)
|
---|
4746 | {
|
---|
4747 | if ( RTStrSimplePatternMatch(paArgs[iArg].u.pszString, g_aDbgcSxEvents[iEvt].pszName)
|
---|
4748 | || ( g_aDbgcSxEvents[iEvt].pszAltNm
|
---|
4749 | && RTStrSimplePatternMatch(paArgs[iArg].u.pszString, g_aDbgcSxEvents[iEvt].pszAltNm)) )
|
---|
4750 | {
|
---|
4751 | cEventCfgs = dbgcEventAddPlainConfig(aEventCfgs, cEventCfgs, g_aDbgcSxEvents[iEvt].enmType,
|
---|
4752 | g_aDbgcSxEvents[iEvt].enmDefault, iEvt);
|
---|
4753 | cHits++;
|
---|
4754 | }
|
---|
4755 | }
|
---|
4756 | else
|
---|
4757 | {
|
---|
4758 | Assert(g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Interrupt);
|
---|
4759 | uint8_t iInt;
|
---|
4760 | uint16_t cInts;
|
---|
4761 | if (dbgcEventIsMatchingInt(&paArgs[iArg], g_aDbgcSxEvents[iEvt].pszName, pCmdHlp, &iInt, &cInts))
|
---|
4762 | {
|
---|
4763 | cIntCfgs = dbgcEventAddIntConfig(aIntCfgs, cIntCfgs, iInt, cInts, g_aDbgcSxEvents[iEvt].pszName,
|
---|
4764 | g_aDbgcSxEvents[iEvt].enmDefault,
|
---|
4765 | g_aDbgcSxEvents[iEvt].enmDefault > kDbgcEvtState_Disabled
|
---|
4766 | ? DBGFINTERRUPTSTATE_ENABLED : DBGFINTERRUPTSTATE_DISABLED);
|
---|
4767 | cHits++;
|
---|
4768 | }
|
---|
4769 | }
|
---|
4770 | if (!cHits)
|
---|
4771 | return DBGCCmdHlpVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "Unknown event: '%s'\n", paArgs[iArg].u.pszString);
|
---|
4772 | }
|
---|
4773 | }
|
---|
4774 |
|
---|
4775 | /*
|
---|
4776 | * Apply the reset changes.
|
---|
4777 | */
|
---|
4778 | return dbgcEventApplyChanges(pCmdHlp, pUVM, aIntCfgs, cIntCfgs, aEventCfgs, cEventCfgs, "", false);
|
---|
4779 | }
|
---|
4780 |
|
---|
4781 |
|
---|
4782 | /**
|
---|
4783 | * Used during DBGC initialization to configure events with defaults.
|
---|
4784 | *
|
---|
4785 | * @returns VBox status code.
|
---|
4786 | * @param pDbgc The DBGC instance.
|
---|
4787 | */
|
---|
4788 | void dbgcEventInit(PDBGC pDbgc)
|
---|
4789 | {
|
---|
4790 | if (pDbgc->pUVM)
|
---|
4791 | dbgcCmdEventCtrlReset(NULL, &pDbgc->CmdHlp, pDbgc->pUVM, NULL, 0);
|
---|
4792 | }
|
---|
4793 |
|
---|
4794 |
|
---|
4795 | /**
|
---|
4796 | * Used during DBGC termination to disable all events.
|
---|
4797 | *
|
---|
4798 | * @param pDbgc The DBGC instance.
|
---|
4799 | */
|
---|
4800 | void dbgcEventTerm(PDBGC pDbgc)
|
---|
4801 | {
|
---|
4802 | /** @todo need to do more than just reset later. */
|
---|
4803 | if (pDbgc->pUVM && VMR3GetStateU(pDbgc->pUVM) < VMSTATE_DESTROYING)
|
---|
4804 | dbgcCmdEventCtrlReset(NULL, &pDbgc->CmdHlp, pDbgc->pUVM, NULL, 0);
|
---|
4805 | }
|
---|
4806 |
|
---|
4807 |
|
---|
4808 | static void dbgcEventDisplay(PDBGCCMDHLP pCmdHlp, const char *pszName, DBGCEVTSTATE enmDefault, PDBGCEVTCFG const *ppEvtCfg)
|
---|
4809 | {
|
---|
4810 | PDBGCEVTCFG pEvtCfg = *ppEvtCfg;
|
---|
4811 |
|
---|
4812 | const char *pszState;
|
---|
4813 | switch (pEvtCfg ? pEvtCfg->enmState : kDbgcEvtState_Disabled)
|
---|
4814 | {
|
---|
4815 | case kDbgcEvtState_Disabled: pszState = "ignore"; break;
|
---|
4816 | case kDbgcEvtState_Enabled: pszState = "enabled"; break;
|
---|
4817 | case kDbgcEvtState_Notify: pszState = "notify"; break;
|
---|
4818 | default:
|
---|
4819 | AssertFailed();
|
---|
4820 | pszState = "invalid";
|
---|
4821 | break;
|
---|
4822 | }
|
---|
4823 |
|
---|
4824 | if (pEvtCfg && pEvtCfg->cchCmd > 0)
|
---|
4825 | DBGCCmdHlpPrintf(pCmdHlp, "%-22s %-7s \"%s\"\n", pszName, pszState, pEvtCfg->szCmd);
|
---|
4826 | else
|
---|
4827 | DBGCCmdHlpPrintf(pCmdHlp, "%-22s %s\n", pszName, pszState);
|
---|
4828 | }
|
---|
4829 |
|
---|
4830 |
|
---|
4831 | static void dbgcEventDisplayRange(PDBGCCMDHLP pCmdHlp, const char *pszBaseNm, DBGCEVTSTATE enmDefault,
|
---|
4832 | PDBGCEVTCFG const *papEvtCfgs, unsigned iCfg, unsigned cCfgs)
|
---|
4833 | {
|
---|
4834 | do
|
---|
4835 | {
|
---|
4836 | PCDBGCEVTCFG pFirstCfg = papEvtCfgs[iCfg];
|
---|
4837 | if (pFirstCfg && pFirstCfg->enmState == kDbgcEvtState_Disabled && pFirstCfg->cchCmd == 0)
|
---|
4838 | pFirstCfg = NULL;
|
---|
4839 |
|
---|
4840 | unsigned const iFirstCfg = iCfg;
|
---|
4841 | iCfg++;
|
---|
4842 | while (iCfg < cCfgs)
|
---|
4843 | {
|
---|
4844 | PCDBGCEVTCFG pCurCfg = papEvtCfgs[iCfg];
|
---|
4845 | if (pCurCfg && pCurCfg->enmState == kDbgcEvtState_Disabled && pCurCfg->cchCmd == 0)
|
---|
4846 | pCurCfg = NULL;
|
---|
4847 | if (pCurCfg != pFirstCfg)
|
---|
4848 | {
|
---|
4849 | if (!pCurCfg || !pFirstCfg)
|
---|
4850 | break;
|
---|
4851 | if (pCurCfg->enmState != pFirstCfg->enmState)
|
---|
4852 | break;
|
---|
4853 | if (pCurCfg->cchCmd != pFirstCfg->cchCmd)
|
---|
4854 | break;
|
---|
4855 | if (memcmp(pCurCfg->szCmd, pFirstCfg->szCmd, pFirstCfg->cchCmd) != 0)
|
---|
4856 | break;
|
---|
4857 | }
|
---|
4858 | iCfg++;
|
---|
4859 | }
|
---|
4860 |
|
---|
4861 | char szName[16];
|
---|
4862 | unsigned cEntries = iCfg - iFirstCfg;
|
---|
4863 | if (cEntries == 1)
|
---|
4864 | RTStrPrintf(szName, sizeof(szName), "%s%02x", pszBaseNm, iFirstCfg);
|
---|
4865 | else
|
---|
4866 | RTStrPrintf(szName, sizeof(szName), "%s%02x L %#x", pszBaseNm, iFirstCfg, cEntries);
|
---|
4867 | dbgcEventDisplay(pCmdHlp, szName, enmDefault, &papEvtCfgs[iFirstCfg]);
|
---|
4868 |
|
---|
4869 | cCfgs -= cEntries;
|
---|
4870 | } while (cCfgs > 0);
|
---|
4871 | }
|
---|
4872 |
|
---|
4873 |
|
---|
4874 | /**
|
---|
4875 | * @callback_method_impl{FNDBGCCMD, The 'sx' commands.}
|
---|
4876 | */
|
---|
4877 | static DECLCALLBACK(int) dbgcCmdEventCtrlList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
4878 | {
|
---|
4879 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
4880 |
|
---|
4881 | if (cArgs == 0)
|
---|
4882 | {
|
---|
4883 | /*
|
---|
4884 | * All events.
|
---|
4885 | */
|
---|
4886 | for (uint32_t iEvt = 0; iEvt < RT_ELEMENTS(g_aDbgcSxEvents); iEvt++)
|
---|
4887 | if (g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Plain)
|
---|
4888 | dbgcEventDisplay(pCmdHlp, g_aDbgcSxEvents[iEvt].pszName, g_aDbgcSxEvents[iEvt].enmDefault,
|
---|
4889 | &pDbgc->apEventCfgs[iEvt]);
|
---|
4890 | else if (strcmp(g_aDbgcSxEvents[iEvt].pszName, "hwint") == 0)
|
---|
4891 | dbgcEventDisplayRange(pCmdHlp, g_aDbgcSxEvents[iEvt].pszName, g_aDbgcSxEvents[iEvt].enmDefault,
|
---|
4892 | pDbgc->apHardInts, 0, 256);
|
---|
4893 | else
|
---|
4894 | dbgcEventDisplayRange(pCmdHlp, g_aDbgcSxEvents[iEvt].pszName, g_aDbgcSxEvents[iEvt].enmDefault,
|
---|
4895 | pDbgc->apSoftInts, 0, 256);
|
---|
4896 | }
|
---|
4897 | else
|
---|
4898 | {
|
---|
4899 | /*
|
---|
4900 | * Selected events.
|
---|
4901 | */
|
---|
4902 | for (uint32_t iArg = 0; iArg < cArgs; iArg++)
|
---|
4903 | {
|
---|
4904 | unsigned cHits = 0;
|
---|
4905 | for (uint32_t iEvt = 0; iEvt < RT_ELEMENTS(g_aDbgcSxEvents); iEvt++)
|
---|
4906 | if (g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Plain)
|
---|
4907 | {
|
---|
4908 | if ( RTStrSimplePatternMatch(paArgs[iArg].u.pszString, g_aDbgcSxEvents[iEvt].pszName)
|
---|
4909 | || ( g_aDbgcSxEvents[iEvt].pszAltNm
|
---|
4910 | && RTStrSimplePatternMatch(paArgs[iArg].u.pszString, g_aDbgcSxEvents[iEvt].pszAltNm)) )
|
---|
4911 | {
|
---|
4912 | dbgcEventDisplay(pCmdHlp, g_aDbgcSxEvents[iEvt].pszName, g_aDbgcSxEvents[iEvt].enmDefault,
|
---|
4913 | &pDbgc->apEventCfgs[iEvt]);
|
---|
4914 | cHits++;
|
---|
4915 | }
|
---|
4916 | }
|
---|
4917 | else
|
---|
4918 | {
|
---|
4919 | Assert(g_aDbgcSxEvents[iEvt].enmKind == kDbgcSxEventKind_Interrupt);
|
---|
4920 | uint8_t iInt;
|
---|
4921 | uint16_t cInts;
|
---|
4922 | if (dbgcEventIsMatchingInt(&paArgs[iArg], g_aDbgcSxEvents[iEvt].pszName, pCmdHlp, &iInt, &cInts))
|
---|
4923 | {
|
---|
4924 | if (strcmp(g_aDbgcSxEvents[iEvt].pszName, "hwint") == 0)
|
---|
4925 | dbgcEventDisplayRange(pCmdHlp, g_aDbgcSxEvents[iEvt].pszName, g_aDbgcSxEvents[iEvt].enmDefault,
|
---|
4926 | pDbgc->apHardInts, iInt, cInts);
|
---|
4927 | else
|
---|
4928 | dbgcEventDisplayRange(pCmdHlp, g_aDbgcSxEvents[iEvt].pszName, g_aDbgcSxEvents[iEvt].enmDefault,
|
---|
4929 | pDbgc->apSoftInts, iInt, cInts);
|
---|
4930 | cHits++;
|
---|
4931 | }
|
---|
4932 | }
|
---|
4933 | if (cHits == 0)
|
---|
4934 | return DBGCCmdHlpVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "Unknown event: '%s'\n", paArgs[iArg].u.pszString);
|
---|
4935 | }
|
---|
4936 | }
|
---|
4937 |
|
---|
4938 | return VINF_SUCCESS;
|
---|
4939 | }
|
---|
4940 |
|
---|
4941 |
|
---|
4942 |
|
---|
4943 | /**
|
---|
4944 | * List near symbol.
|
---|
4945 | *
|
---|
4946 | * @returns VBox status code.
|
---|
4947 | * @param pCmdHlp Pointer to command helper functions.
|
---|
4948 | * @param pUVM The user mode VM handle.
|
---|
4949 | * @param pArg Pointer to the address or symbol to lookup.
|
---|
4950 | */
|
---|
4951 | static int dbgcDoListNear(PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR pArg)
|
---|
4952 | {
|
---|
4953 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
4954 |
|
---|
4955 | RTDBGSYMBOL Symbol;
|
---|
4956 | int rc;
|
---|
4957 | if (pArg->enmType == DBGCVAR_TYPE_SYMBOL)
|
---|
4958 | {
|
---|
4959 | /*
|
---|
4960 | * Lookup the symbol address.
|
---|
4961 | */
|
---|
4962 | rc = DBGFR3AsSymbolByName(pUVM, pDbgc->hDbgAs, pArg->u.pszString, &Symbol, NULL);
|
---|
4963 | if (RT_FAILURE(rc))
|
---|
4964 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3AsSymbolByName(,,%s,)\n", pArg->u.pszString);
|
---|
4965 |
|
---|
4966 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%RTptr %s\n", Symbol.Value, Symbol.szName);
|
---|
4967 | }
|
---|
4968 | else
|
---|
4969 | {
|
---|
4970 | /*
|
---|
4971 | * Convert it to a flat GC address and lookup that address.
|
---|
4972 | */
|
---|
4973 | DBGCVAR AddrVar;
|
---|
4974 | rc = DBGCCmdHlpEval(pCmdHlp, &AddrVar, "%%(%DV)", pArg);
|
---|
4975 | if (RT_FAILURE(rc))
|
---|
4976 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "%%(%DV)\n", pArg);
|
---|
4977 |
|
---|
4978 | RTINTPTR offDisp;
|
---|
4979 | DBGFADDRESS Addr;
|
---|
4980 | rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, AddrVar.u.GCFlat),
|
---|
4981 | RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, &offDisp, &Symbol, NULL);
|
---|
4982 | if (RT_FAILURE(rc))
|
---|
4983 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3ASymbolByAddr(,,%RGv,,)\n", AddrVar.u.GCFlat);
|
---|
4984 |
|
---|
4985 | if (!offDisp)
|
---|
4986 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%DV %s", &AddrVar, Symbol.szName);
|
---|
4987 | else if (offDisp > 0)
|
---|
4988 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%DV %s + %RGv", &AddrVar, Symbol.szName, offDisp);
|
---|
4989 | else
|
---|
4990 | rc = DBGCCmdHlpPrintf(pCmdHlp, "%DV %s - %RGv", &AddrVar, Symbol.szName, -offDisp);
|
---|
4991 | if (Symbol.cb > 0)
|
---|
4992 | rc = DBGCCmdHlpPrintf(pCmdHlp, " (LB %RGv)\n", Symbol.cb);
|
---|
4993 | else
|
---|
4994 | rc = DBGCCmdHlpPrintf(pCmdHlp, "\n");
|
---|
4995 | }
|
---|
4996 |
|
---|
4997 | return rc;
|
---|
4998 | }
|
---|
4999 |
|
---|
5000 |
|
---|
5001 | /**
|
---|
5002 | * @callback_method_impl{FNDBGCCMD, The 'ln' (listnear) command.}
|
---|
5003 | */
|
---|
5004 | static DECLCALLBACK(int) dbgcCmdListNear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
5005 | {
|
---|
5006 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
5007 | if (!cArgs)
|
---|
5008 | {
|
---|
5009 | /*
|
---|
5010 | * Current cs:eip symbol.
|
---|
5011 | */
|
---|
5012 | DBGCVAR AddrVar;
|
---|
5013 | const char *pszFmtExpr = pDbgc->fRegCtxGuest ? "%%(cs:eip)" : "%%(.cs:.eip)";
|
---|
5014 | int rc = DBGCCmdHlpEval(pCmdHlp, &AddrVar, pszFmtExpr);
|
---|
5015 | if (RT_FAILURE(rc))
|
---|
5016 | return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "%s\n", pszFmtExpr + 1);
|
---|
5017 | return dbgcDoListNear(pCmdHlp, pUVM, &AddrVar);
|
---|
5018 | }
|
---|
5019 |
|
---|
5020 | /** @todo Fix the darn parser, it's resolving symbols specified as arguments before we get in here. */
|
---|
5021 | /*
|
---|
5022 | * Iterate arguments.
|
---|
5023 | */
|
---|
5024 | for (unsigned iArg = 0; iArg < cArgs; iArg++)
|
---|
5025 | {
|
---|
5026 | int rc = dbgcDoListNear(pCmdHlp, pUVM, &paArgs[iArg]);
|
---|
5027 | if (RT_FAILURE(rc))
|
---|
5028 | return rc;
|
---|
5029 | }
|
---|
5030 |
|
---|
5031 | NOREF(pCmd);
|
---|
5032 | return VINF_SUCCESS;
|
---|
5033 | }
|
---|
5034 |
|
---|
5035 |
|
---|
5036 | /**
|
---|
5037 | * Matches the module patters against a module name.
|
---|
5038 | *
|
---|
5039 | * @returns true if matching, otherwise false.
|
---|
5040 | * @param pszName The module name.
|
---|
5041 | * @param paArgs The module pattern argument list.
|
---|
5042 | * @param cArgs Number of arguments.
|
---|
5043 | */
|
---|
5044 | static bool dbgcCmdListModuleMatch(const char *pszName, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
5045 | {
|
---|
5046 | for (uint32_t i = 0; i < cArgs; i++)
|
---|
5047 | if (RTStrSimplePatternMatch(paArgs[i].u.pszString, pszName))
|
---|
5048 | return true;
|
---|
5049 | return false;
|
---|
5050 | }
|
---|
5051 |
|
---|
5052 |
|
---|
5053 | /**
|
---|
5054 | * @callback_method_impl{FNDBGCCMD, The 'ln' (list near) command.}
|
---|
5055 | */
|
---|
5056 | static DECLCALLBACK(int) dbgcCmdListModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
|
---|
5057 | {
|
---|
5058 | bool const fMappings = pCmd->pszCmd[2] == 'o';
|
---|
5059 | bool const fVerbose = pCmd->pszCmd[strlen(pCmd->pszCmd) - 1] == 'v';
|
---|
5060 | PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
|
---|
5061 |
|
---|
5062 | /*
|
---|
5063 | * Iterate the modules in the current address space and print info about
|
---|
5064 | * those matching the input.
|
---|
5065 | */
|
---|
5066 | RTDBGAS hAs = DBGFR3AsResolveAndRetain(pUVM, pDbgc->hDbgAs);
|
---|
5067 | uint32_t cMods = RTDbgAsModuleCount(hAs);
|
---|
5068 | for (uint32_t iMod = 0; iMod < cMods; iMod++)
|
---|
5069 | {
|
---|
5070 | RTDBGMOD hMod = RTDbgAsModuleByIndex(hAs, iMod);
|
---|
5071 | if (hMod != NIL_RTDBGMOD)
|
---|
5072 | {
|
---|
5073 | bool const fDeferred = RTDbgModIsDeferred(hMod);
|
---|
5074 | bool const fExports = RTDbgModIsExports(hMod);
|
---|
5075 | uint32_t const cSegs = fDeferred ? 1 : RTDbgModSegmentCount(hMod);
|
---|
5076 | const char * const pszName = RTDbgModName(hMod);
|
---|
5077 | const char * const pszImgFile = RTDbgModImageFile(hMod);
|
---|
5078 | const char * const pszImgFileUsed = RTDbgModImageFileUsed(hMod);
|
---|
5079 | const char * const pszDbgFile = RTDbgModDebugFile(hMod);
|
---|
5080 | if ( cArgs == 0
|
---|
5081 | || dbgcCmdListModuleMatch(pszName, paArgs, cArgs))
|
---|
5082 | {
|
---|
5083 | /*
|
---|
5084 | * Find the mapping with the lower address, preferring a full
|
---|
5085 | * image mapping, for the main line.
|
---|
5086 | */
|
---|
5087 | RTDBGASMAPINFO aMappings[128];
|
---|
5088 | uint32_t cMappings = RT_ELEMENTS(aMappings);
|
---|
5089 | int rc = RTDbgAsModuleQueryMapByIndex(hAs, iMod, &aMappings[0], &cMappings, 0 /*fFlags*/);
|
---|
5090 | if (RT_SUCCESS(rc))
|
---|
5091 | {
|
---|
5092 | bool fFull = false;
|
---|
5093 | RTUINTPTR uMin = RTUINTPTR_MAX;
|
---|
5094 | for (uint32_t iMap = 0; iMap < cMappings; iMap++)
|
---|
5095 | if ( aMappings[iMap].Address < uMin
|
---|
5096 | && ( !fFull
|
---|
5097 | || aMappings[iMap].iSeg == NIL_RTDBGSEGIDX))
|
---|
5098 | uMin = aMappings[iMap].Address;
|
---|
5099 | if (!fVerbose || !pszImgFile)
|
---|
5100 | DBGCCmdHlpPrintf(pCmdHlp, "%RGv %04x %s%s\n", (RTGCUINTPTR)uMin, cSegs, pszName,
|
---|
5101 | fExports ? " (exports)" : fDeferred ? " (deferred)" : "");
|
---|
5102 | else
|
---|
5103 | DBGCCmdHlpPrintf(pCmdHlp, "%RGv %04x %-12s %s%s\n", (RTGCUINTPTR)uMin, cSegs, pszName, pszImgFile,
|
---|
5104 | fExports ? " (exports)" : fDeferred ? " (deferred)" : "");
|
---|
5105 | if (fVerbose && pszImgFileUsed)
|
---|
5106 | DBGCCmdHlpPrintf(pCmdHlp, " Local image: %s\n", pszImgFileUsed);
|
---|
5107 | if (fVerbose && pszDbgFile)
|
---|
5108 | DBGCCmdHlpPrintf(pCmdHlp, " Debug file: %s\n", pszDbgFile);
|
---|
5109 |
|
---|
5110 | if (fMappings)
|
---|
5111 | {
|
---|
5112 | /* sort by address first - not very efficient. */
|
---|
5113 | for (uint32_t i = 0; i + 1 < cMappings; i++)
|
---|
5114 | for (uint32_t j = i + 1; j < cMappings; j++)
|
---|
5115 | if (aMappings[j].Address < aMappings[i].Address)
|
---|
5116 | {
|
---|
5117 | RTDBGASMAPINFO Tmp = aMappings[j];
|
---|
5118 | aMappings[j] = aMappings[i];
|
---|
5119 | aMappings[i] = Tmp;
|
---|
5120 | }
|
---|
5121 |
|
---|
5122 | /* print */
|
---|
5123 | if ( cMappings == 1
|
---|
5124 | && aMappings[0].iSeg == NIL_RTDBGSEGIDX
|
---|
5125 | && !fDeferred)
|
---|
5126 | {
|
---|
5127 | for (uint32_t iSeg = 0; iSeg < cSegs; iSeg++)
|
---|
5128 | {
|
---|
5129 | RTDBGSEGMENT SegInfo;
|
---|
5130 | rc = RTDbgModSegmentByIndex(hMod, iSeg, &SegInfo);
|
---|
5131 | if (RT_SUCCESS(rc))
|
---|
5132 | {
|
---|
5133 | if (SegInfo.uRva != RTUINTPTR_MAX)
|
---|
5134 | DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv #%02x %s\n",
|
---|
5135 | (RTGCUINTPTR)(aMappings[0].Address + SegInfo.uRva),
|
---|
5136 | (RTGCUINTPTR)SegInfo.cb, iSeg, SegInfo.szName);
|
---|
5137 | else
|
---|
5138 | DBGCCmdHlpPrintf(pCmdHlp, " %*s %RGv #%02x %s\n",
|
---|
5139 | sizeof(RTGCUINTPTR)*2, "noload",
|
---|
5140 | (RTGCUINTPTR)SegInfo.cb, iSeg, SegInfo.szName);
|
---|
5141 | }
|
---|
5142 | else
|
---|
5143 | DBGCCmdHlpPrintf(pCmdHlp, " Error query segment #%u: %Rrc\n", iSeg, rc);
|
---|
5144 | }
|
---|
5145 | }
|
---|
5146 | else
|
---|
5147 | {
|
---|
5148 | for (uint32_t iMap = 0; iMap < cMappings; iMap++)
|
---|
5149 | if (aMappings[iMap].iSeg == NIL_RTDBGSEGIDX)
|
---|
5150 | DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv <everything>\n",
|
---|
5151 | (RTGCUINTPTR)aMappings[iMap].Address,
|
---|
5152 | (RTGCUINTPTR)RTDbgModImageSize(hMod));
|
---|
5153 | else if (!fDeferred)
|
---|
5154 | {
|
---|
5155 | RTDBGSEGMENT SegInfo;
|
---|
5156 | rc = RTDbgModSegmentByIndex(hMod, aMappings[iMap].iSeg, &SegInfo);
|
---|
5157 | if (RT_FAILURE(rc))
|
---|
5158 | {
|
---|
5159 | RT_ZERO(SegInfo);
|
---|
5160 | strcpy(SegInfo.szName, "error");
|
---|
5161 | }
|
---|
5162 | DBGCCmdHlpPrintf(pCmdHlp, " %RGv %RGv #%02x %s\n",
|
---|
5163 | (RTGCUINTPTR)aMappings[iMap].Address,
|
---|
5164 | (RTGCUINTPTR)SegInfo.cb,
|
---|
5165 | aMappings[iMap].iSeg, SegInfo.szName);
|
---|
5166 | }
|
---|
5167 | else
|
---|
5168 | DBGCCmdHlpPrintf(pCmdHlp, " %RGv #%02x\n",
|
---|
5169 | (RTGCUINTPTR)aMappings[iMap].Address, aMappings[iMap].iSeg);
|
---|
5170 | }
|
---|
5171 | }
|
---|
5172 | }
|
---|
5173 | else
|
---|
5174 | DBGCCmdHlpPrintf(pCmdHlp, "%.*s %04x %s (rc=%Rrc)\n",
|
---|
5175 | sizeof(RTGCPTR) * 2, "???????????", cSegs, pszName, rc);
|
---|
5176 | /** @todo missing address space API for enumerating the mappings. */
|
---|
5177 | }
|
---|
5178 | RTDbgModRelease(hMod);
|
---|
5179 | }
|
---|
5180 | }
|
---|
5181 | RTDbgAsRelease(hAs);
|
---|
5182 |
|
---|
5183 | NOREF(pCmd);
|
---|
5184 | return VINF_SUCCESS;
|
---|
5185 | }
|
---|
5186 |
|
---|
5187 |
|
---|
5188 |
|
---|
5189 | /**
|
---|
5190 | * @callback_method_impl{FNDBGCFUNC, Reads a unsigned 8-bit value.}
|
---|
5191 | */
|
---|
5192 | static DECLCALLBACK(int) dbgcFuncReadU8(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5193 | PDBGCVAR pResult)
|
---|
5194 | {
|
---|
5195 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5196 | AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
|
---|
5197 | AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
|
---|
5198 |
|
---|
5199 | uint8_t b;
|
---|
5200 | int rc = DBGCCmdHlpMemRead(pCmdHlp, &b, sizeof(b), &paArgs[0], NULL);
|
---|
5201 | if (RT_FAILURE(rc))
|
---|
5202 | return rc;
|
---|
5203 | DBGCVAR_INIT_NUMBER(pResult, b);
|
---|
5204 |
|
---|
5205 | NOREF(pFunc);
|
---|
5206 | return VINF_SUCCESS;
|
---|
5207 | }
|
---|
5208 |
|
---|
5209 |
|
---|
5210 | /**
|
---|
5211 | * @callback_method_impl{FNDBGCFUNC, Reads a unsigned 16-bit value.}
|
---|
5212 | */
|
---|
5213 | static DECLCALLBACK(int) dbgcFuncReadU16(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5214 | PDBGCVAR pResult)
|
---|
5215 | {
|
---|
5216 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5217 | AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
|
---|
5218 | AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
|
---|
5219 |
|
---|
5220 | uint16_t u16;
|
---|
5221 | int rc = DBGCCmdHlpMemRead(pCmdHlp, &u16, sizeof(u16), &paArgs[0], NULL);
|
---|
5222 | if (RT_FAILURE(rc))
|
---|
5223 | return rc;
|
---|
5224 | DBGCVAR_INIT_NUMBER(pResult, u16);
|
---|
5225 |
|
---|
5226 | NOREF(pFunc);
|
---|
5227 | return VINF_SUCCESS;
|
---|
5228 | }
|
---|
5229 |
|
---|
5230 |
|
---|
5231 | /**
|
---|
5232 | * @callback_method_impl{FNDBGCFUNC, Reads a unsigned 32-bit value.}
|
---|
5233 | */
|
---|
5234 | static DECLCALLBACK(int) dbgcFuncReadU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5235 | PDBGCVAR pResult)
|
---|
5236 | {
|
---|
5237 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5238 | AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
|
---|
5239 | AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
|
---|
5240 |
|
---|
5241 | uint32_t u32;
|
---|
5242 | int rc = DBGCCmdHlpMemRead(pCmdHlp, &u32, sizeof(u32), &paArgs[0], NULL);
|
---|
5243 | if (RT_FAILURE(rc))
|
---|
5244 | return rc;
|
---|
5245 | DBGCVAR_INIT_NUMBER(pResult, u32);
|
---|
5246 |
|
---|
5247 | NOREF(pFunc);
|
---|
5248 | return VINF_SUCCESS;
|
---|
5249 | }
|
---|
5250 |
|
---|
5251 |
|
---|
5252 | /**
|
---|
5253 | * @callback_method_impl{FNDBGCFUNC, Reads a unsigned 64-bit value.}
|
---|
5254 | */
|
---|
5255 | static DECLCALLBACK(int) dbgcFuncReadU64(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5256 | PDBGCVAR pResult)
|
---|
5257 | {
|
---|
5258 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5259 | AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
|
---|
5260 | AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
|
---|
5261 |
|
---|
5262 | uint64_t u64;
|
---|
5263 | int rc = DBGCCmdHlpMemRead(pCmdHlp, &u64, sizeof(u64), &paArgs[0], NULL);
|
---|
5264 | if (RT_FAILURE(rc))
|
---|
5265 | return rc;
|
---|
5266 | DBGCVAR_INIT_NUMBER(pResult, u64);
|
---|
5267 |
|
---|
5268 | NOREF(pFunc);
|
---|
5269 | return VINF_SUCCESS;
|
---|
5270 | }
|
---|
5271 |
|
---|
5272 |
|
---|
5273 | /**
|
---|
5274 | * @callback_method_impl{FNDBGCFUNC, Reads a unsigned pointer-sized value.}
|
---|
5275 | */
|
---|
5276 | static DECLCALLBACK(int) dbgcFuncReadPtr(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5277 | PDBGCVAR pResult)
|
---|
5278 | {
|
---|
5279 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5280 | AssertReturn(DBGCVAR_ISPOINTER(paArgs[0].enmType), VERR_DBGC_PARSE_BUG);
|
---|
5281 | AssertReturn(paArgs[0].enmRangeType == DBGCVAR_RANGE_NONE, VERR_DBGC_PARSE_BUG);
|
---|
5282 |
|
---|
5283 | CPUMMODE enmMode = DBGCCmdHlpGetCpuMode(pCmdHlp);
|
---|
5284 | if (enmMode == CPUMMODE_LONG)
|
---|
5285 | return dbgcFuncReadU64(pFunc, pCmdHlp, pUVM, paArgs, cArgs, pResult);
|
---|
5286 | return dbgcFuncReadU32(pFunc, pCmdHlp, pUVM, paArgs, cArgs, pResult);
|
---|
5287 | }
|
---|
5288 |
|
---|
5289 |
|
---|
5290 | /**
|
---|
5291 | * @callback_method_impl{FNDBGCFUNC, The hi(value) function implementation.}
|
---|
5292 | */
|
---|
5293 | static DECLCALLBACK(int) dbgcFuncHi(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5294 | PDBGCVAR pResult)
|
---|
5295 | {
|
---|
5296 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5297 |
|
---|
5298 | uint16_t uHi;
|
---|
5299 | switch (paArgs[0].enmType)
|
---|
5300 | {
|
---|
5301 | case DBGCVAR_TYPE_GC_FLAT: uHi = (uint16_t)(paArgs[0].u.GCFlat >> 16); break;
|
---|
5302 | case DBGCVAR_TYPE_GC_FAR: uHi = (uint16_t)paArgs[0].u.GCFar.sel; break;
|
---|
5303 | case DBGCVAR_TYPE_GC_PHYS: uHi = (uint16_t)(paArgs[0].u.GCPhys >> 16); break;
|
---|
5304 | case DBGCVAR_TYPE_HC_FLAT: uHi = (uint16_t)((uintptr_t)paArgs[0].u.pvHCFlat >> 16); break;
|
---|
5305 | case DBGCVAR_TYPE_HC_PHYS: uHi = (uint16_t)(paArgs[0].u.HCPhys >> 16); break;
|
---|
5306 | case DBGCVAR_TYPE_NUMBER: uHi = (uint16_t)(paArgs[0].u.u64Number >> 16); break;
|
---|
5307 | default:
|
---|
5308 | AssertFailedReturn(VERR_DBGC_PARSE_BUG);
|
---|
5309 | }
|
---|
5310 | DBGCVAR_INIT_NUMBER(pResult, uHi);
|
---|
5311 | DBGCVAR_SET_RANGE(pResult, paArgs[0].enmRangeType, paArgs[0].u64Range);
|
---|
5312 |
|
---|
5313 | NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM);
|
---|
5314 | return VINF_SUCCESS;
|
---|
5315 | }
|
---|
5316 |
|
---|
5317 |
|
---|
5318 | /**
|
---|
5319 | * @callback_method_impl{FNDBGCFUNC, The low(value) function implementation.}
|
---|
5320 | */
|
---|
5321 | static DECLCALLBACK(int) dbgcFuncLow(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5322 | PDBGCVAR pResult)
|
---|
5323 | {
|
---|
5324 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5325 |
|
---|
5326 | uint16_t uLow;
|
---|
5327 | switch (paArgs[0].enmType)
|
---|
5328 | {
|
---|
5329 | case DBGCVAR_TYPE_GC_FLAT: uLow = (uint16_t)paArgs[0].u.GCFlat; break;
|
---|
5330 | case DBGCVAR_TYPE_GC_FAR: uLow = (uint16_t)paArgs[0].u.GCFar.off; break;
|
---|
5331 | case DBGCVAR_TYPE_GC_PHYS: uLow = (uint16_t)paArgs[0].u.GCPhys; break;
|
---|
5332 | case DBGCVAR_TYPE_HC_FLAT: uLow = (uint16_t)(uintptr_t)paArgs[0].u.pvHCFlat; break;
|
---|
5333 | case DBGCVAR_TYPE_HC_PHYS: uLow = (uint16_t)paArgs[0].u.HCPhys; break;
|
---|
5334 | case DBGCVAR_TYPE_NUMBER: uLow = (uint16_t)paArgs[0].u.u64Number; break;
|
---|
5335 | default:
|
---|
5336 | AssertFailedReturn(VERR_DBGC_PARSE_BUG);
|
---|
5337 | }
|
---|
5338 | DBGCVAR_INIT_NUMBER(pResult, uLow);
|
---|
5339 | DBGCVAR_SET_RANGE(pResult, paArgs[0].enmRangeType, paArgs[0].u64Range);
|
---|
5340 |
|
---|
5341 | NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM);
|
---|
5342 | return VINF_SUCCESS;
|
---|
5343 | }
|
---|
5344 |
|
---|
5345 |
|
---|
5346 | /**
|
---|
5347 | * @callback_method_impl{FNDBGCFUNC,The low(value) function implementation.}
|
---|
5348 | */
|
---|
5349 | static DECLCALLBACK(int) dbgcFuncNot(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
|
---|
5350 | PDBGCVAR pResult)
|
---|
5351 | {
|
---|
5352 | AssertReturn(cArgs == 1, VERR_DBGC_PARSE_BUG);
|
---|
5353 | NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM);
|
---|
5354 | return DBGCCmdHlpEval(pCmdHlp, pResult, "!(%Dv)", &paArgs[0]);
|
---|
5355 | }
|
---|
5356 |
|
---|
5357 |
|
---|
5358 | /** Generic pointer argument wo/ range. */
|
---|
5359 | static const DBGCVARDESC g_aArgPointerWoRange[] =
|
---|
5360 | {
|
---|
5361 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
5362 | { 1, 1, DBGCVAR_CAT_POINTER_NO_RANGE, 0, "value", "Address or number." },
|
---|
5363 | };
|
---|
5364 |
|
---|
5365 | /** Generic pointer or number argument. */
|
---|
5366 | static const DBGCVARDESC g_aArgPointerNumber[] =
|
---|
5367 | {
|
---|
5368 | /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */
|
---|
5369 | { 1, 1, DBGCVAR_CAT_POINTER_NUMBER, 0, "value", "Address or number." },
|
---|
5370 | };
|
---|
5371 |
|
---|
5372 |
|
---|
5373 |
|
---|
5374 | /** Function descriptors for the CodeView / WinDbg emulation.
|
---|
5375 | * The emulation isn't attempting to be identical, only somewhat similar.
|
---|
5376 | */
|
---|
5377 | const DBGCFUNC g_aFuncsCodeView[] =
|
---|
5378 | {
|
---|
5379 | { "by", 1, 1, &g_aArgPointerWoRange[0], RT_ELEMENTS(g_aArgPointerWoRange), 0, dbgcFuncReadU8, "address", "Reads a byte at the given address." },
|
---|
5380 | { "dwo", 1, 1, &g_aArgPointerWoRange[0], RT_ELEMENTS(g_aArgPointerWoRange), 0, dbgcFuncReadU32, "address", "Reads a 32-bit value at the given address." },
|
---|
5381 | { "hi", 1, 1, &g_aArgPointerNumber[0], RT_ELEMENTS(g_aArgPointerNumber), 0, dbgcFuncHi, "value", "Returns the high 16-bit bits of a value." },
|
---|
5382 | { "low", 1, 1, &g_aArgPointerNumber[0], RT_ELEMENTS(g_aArgPointerNumber), 0, dbgcFuncLow, "value", "Returns the low 16-bit bits of a value." },
|
---|
5383 | { "not", 1, 1, &g_aArgPointerNumber[0], RT_ELEMENTS(g_aArgPointerNumber), 0, dbgcFuncNot, "address", "Boolean NOT." },
|
---|
5384 | { "poi", 1, 1, &g_aArgPointerWoRange[0], RT_ELEMENTS(g_aArgPointerWoRange), 0, dbgcFuncReadPtr, "address", "Reads a pointer sized (CS) value at the given address." },
|
---|
5385 | { "qwo", 1, 1, &g_aArgPointerWoRange[0], RT_ELEMENTS(g_aArgPointerWoRange), 0, dbgcFuncReadU64, "address", "Reads a 32-bit value at the given address." },
|
---|
5386 | { "wo", 1, 1, &g_aArgPointerWoRange[0], RT_ELEMENTS(g_aArgPointerWoRange), 0, dbgcFuncReadU16, "address", "Reads a 16-bit value at the given address." },
|
---|
5387 | };
|
---|
5388 |
|
---|
5389 | /** The number of functions in the CodeView/WinDbg emulation. */
|
---|
5390 | const uint32_t g_cFuncsCodeView = RT_ELEMENTS(g_aFuncsCodeView);
|
---|
5391 |
|
---|