VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/VMMGuruMeditation.cpp@ 45177

Last change on this file since 45177 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 27.8 KB
Line 
1/* $Id: VMMGuruMeditation.cpp 44528 2013-02-04 14:27:54Z vboxsync $ */
2/** @file
3 * VMM - The Virtual Machine Monitor, Guru Meditation Code.
4 */
5
6/*
7 * Copyright (C) 2006-2013 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* Header Files *
20*******************************************************************************/
21#define LOG_GROUP LOG_GROUP_VMM
22#include <VBox/vmm/vmm.h>
23#include <VBox/vmm/pdmapi.h>
24#include <VBox/vmm/pdmcritsect.h>
25#include <VBox/vmm/trpm.h>
26#include <VBox/vmm/dbgf.h>
27#include "VMMInternal.h"
28#include <VBox/vmm/vm.h>
29#include <VBox/vmm/mm.h>
30#include <VBox/vmm/iom.h>
31#include <VBox/vmm/em.h>
32
33#include <VBox/err.h>
34#include <VBox/param.h>
35#include <VBox/version.h>
36#include <VBox/vmm/hm.h>
37#include <iprt/assert.h>
38#include <iprt/time.h>
39#include <iprt/stream.h>
40#include <iprt/string.h>
41#include <iprt/stdarg.h>
42
43
44/*******************************************************************************
45* Structures and Typedefs *
46*******************************************************************************/
47/**
48 * Structure to pass to DBGFR3Info() and for doing all other
49 * output during fatal dump.
50 */
51typedef struct VMMR3FATALDUMPINFOHLP
52{
53 /** The helper core. */
54 DBGFINFOHLP Core;
55 /** The release logger instance. */
56 PRTLOGGER pRelLogger;
57 /** The saved release logger flags. */
58 uint32_t fRelLoggerFlags;
59 /** The logger instance. */
60 PRTLOGGER pLogger;
61 /** The saved logger flags. */
62 uint32_t fLoggerFlags;
63 /** The saved logger destination flags. */
64 uint32_t fLoggerDestFlags;
65 /** Whether to output to stderr or not. */
66 bool fStdErr;
67 /** Whether we're still recording the summary or not. */
68 bool fRecSummary;
69 /** Buffer for the summary. */
70 char szSummary[4096-2];
71 /** The current summary offset. */
72 size_t offSummary;
73} VMMR3FATALDUMPINFOHLP, *PVMMR3FATALDUMPINFOHLP;
74/** Pointer to a VMMR3FATALDUMPINFOHLP structure. */
75typedef const VMMR3FATALDUMPINFOHLP *PCVMMR3FATALDUMPINFOHLP;
76
77
78/**
79 * Print formatted string.
80 *
81 * @param pHlp Pointer to this structure.
82 * @param pszFormat The format string.
83 * @param ... Arguments.
84 */
85static DECLCALLBACK(void) vmmR3FatalDumpInfoHlp_pfnPrintf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)
86{
87 va_list args;
88 va_start(args, pszFormat);
89 pHlp->pfnPrintfV(pHlp, pszFormat, args);
90 va_end(args);
91}
92
93
94/**
95 * Print formatted string.
96 *
97 * @param pHlp Pointer to this structure.
98 * @param pszFormat The format string.
99 * @param args Argument list.
100 */
101static DECLCALLBACK(void) vmmR3FatalDumpInfoHlp_pfnPrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
102{
103 PVMMR3FATALDUMPINFOHLP pMyHlp = (PVMMR3FATALDUMPINFOHLP)pHlp;
104
105 if (pMyHlp->pRelLogger)
106 {
107 va_list args2;
108 va_copy(args2, args);
109 RTLogLoggerV(pMyHlp->pRelLogger, pszFormat, args2);
110 va_end(args2);
111 }
112 if (pMyHlp->pLogger)
113 {
114 va_list args2;
115 va_copy(args2, args);
116 RTLogLoggerV(pMyHlp->pLogger, pszFormat, args);
117 va_end(args2);
118 }
119 if (pMyHlp->fStdErr)
120 {
121 va_list args2;
122 va_copy(args2, args);
123 RTStrmPrintfV(g_pStdErr, pszFormat, args);
124 va_end(args2);
125 }
126 if (pMyHlp->fRecSummary)
127 {
128 size_t cchLeft = sizeof(pMyHlp->szSummary) - pMyHlp->offSummary;
129 if (cchLeft > 1)
130 {
131 va_list args2;
132 va_copy(args2, args);
133 size_t cch = RTStrPrintfV(&pMyHlp->szSummary[pMyHlp->offSummary], cchLeft, pszFormat, args);
134 va_end(args2);
135 Assert(cch <= cchLeft);
136 pMyHlp->offSummary += cch;
137 }
138 }
139}
140
141
142/**
143 * Initializes the fatal dump output helper.
144 *
145 * @param pHlp The structure to initialize.
146 */
147static void vmmR3FatalDumpInfoHlpInit(PVMMR3FATALDUMPINFOHLP pHlp)
148{
149 RT_BZERO(pHlp, sizeof(*pHlp));
150
151 pHlp->Core.pfnPrintf = vmmR3FatalDumpInfoHlp_pfnPrintf;
152 pHlp->Core.pfnPrintfV = vmmR3FatalDumpInfoHlp_pfnPrintfV;
153
154 /*
155 * The loggers.
156 */
157 pHlp->pRelLogger = RTLogRelDefaultInstance();
158#ifdef LOG_ENABLED
159 pHlp->pLogger = RTLogDefaultInstance();
160#else
161 if (pHlp->pRelLogger)
162 pHlp->pLogger = RTLogGetDefaultInstance();
163 else
164 pHlp->pLogger = RTLogDefaultInstance();
165#endif
166
167 if (pHlp->pRelLogger)
168 {
169 pHlp->fRelLoggerFlags = pHlp->pRelLogger->fFlags;
170 pHlp->pRelLogger->fFlags &= ~RTLOGFLAGS_DISABLED;
171 pHlp->pRelLogger->fFlags |= RTLOGFLAGS_BUFFERED;
172 }
173
174 if (pHlp->pLogger)
175 {
176 pHlp->fLoggerFlags = pHlp->pLogger->fFlags;
177 pHlp->fLoggerDestFlags = pHlp->pLogger->fDestFlags;
178 pHlp->pLogger->fFlags &= ~RTLOGFLAGS_DISABLED;
179 pHlp->pLogger->fFlags |= RTLOGFLAGS_BUFFERED;
180#ifndef DEBUG_sandervl
181 pHlp->pLogger->fDestFlags |= RTLOGDEST_DEBUGGER;
182#endif
183 }
184
185 /*
186 * Check if we need write to stderr.
187 */
188 pHlp->fStdErr = (!pHlp->pRelLogger || !(pHlp->pRelLogger->fDestFlags & (RTLOGDEST_STDOUT | RTLOGDEST_STDERR)))
189 && (!pHlp->pLogger || !(pHlp->pLogger->fDestFlags & (RTLOGDEST_STDOUT | RTLOGDEST_STDERR)));
190#ifdef DEBUG_sandervl
191 pHlp->fStdErr = false; /* takes too long to display here */
192#endif
193
194 /*
195 * Init the summary recording.
196 */
197 pHlp->fRecSummary = true;
198 pHlp->offSummary = 0;
199 pHlp->szSummary[0] = '\0';
200}
201
202
203/**
204 * Deletes the fatal dump output helper.
205 *
206 * @param pHlp The structure to delete.
207 */
208static void vmmR3FatalDumpInfoHlpDelete(PVMMR3FATALDUMPINFOHLP pHlp)
209{
210 if (pHlp->pRelLogger)
211 {
212 RTLogFlush(pHlp->pRelLogger);
213 pHlp->pRelLogger->fFlags = pHlp->fRelLoggerFlags;
214 }
215
216 if (pHlp->pLogger)
217 {
218 RTLogFlush(pHlp->pLogger);
219 pHlp->pLogger->fFlags = pHlp->fLoggerFlags;
220 pHlp->pLogger->fDestFlags = pHlp->fLoggerDestFlags;
221 }
222}
223
224
225/**
226 * Dumps the VM state on a fatal error.
227 *
228 * @param pVM Pointer to the VM.
229 * @param pVCpu Pointer to the VMCPU.
230 * @param rcErr VBox status code.
231 */
232VMMR3DECL(void) VMMR3FatalDump(PVM pVM, PVMCPU pVCpu, int rcErr)
233{
234 /*
235 * Create our output helper and sync it with the log settings.
236 * This helper will be used for all the output.
237 */
238 VMMR3FATALDUMPINFOHLP Hlp;
239 PCDBGFINFOHLP pHlp = &Hlp.Core;
240 vmmR3FatalDumpInfoHlpInit(&Hlp);
241
242 /* Release owned locks to make sure other VCPUs can continue in case they were waiting for one. */
243 PDMR3CritSectLeaveAll(pVM);
244
245 /*
246 * Header.
247 */
248 pHlp->pfnPrintf(pHlp,
249 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
250 "!!\n"
251 "!! Guru Meditation %d (%Rrc)\n"
252 "!!\n",
253 rcErr, rcErr);
254
255 /*
256 * Continue according to context.
257 */
258 bool fDoneHyper = false;
259 switch (rcErr)
260 {
261 /*
262 * Hypervisor errors.
263 */
264 case VERR_VMM_RING0_ASSERTION:
265 case VINF_EM_DBG_HYPER_ASSERTION:
266 case VERR_VMM_RING3_CALL_DISABLED:
267 {
268 const char *pszMsg1 = VMMR3GetRZAssertMsg1(pVM);
269 while (pszMsg1 && *pszMsg1 == '\n')
270 pszMsg1++;
271 const char *pszMsg2 = VMMR3GetRZAssertMsg2(pVM);
272 while (pszMsg2 && *pszMsg2 == '\n')
273 pszMsg2++;
274 pHlp->pfnPrintf(pHlp,
275 "%s"
276 "%s",
277 pszMsg1,
278 pszMsg2);
279 if ( !pszMsg2
280 || !*pszMsg2
281 || strchr(pszMsg2, '\0')[-1] != '\n')
282 pHlp->pfnPrintf(pHlp, "\n");
283 /* fall thru */
284 }
285 case VERR_TRPM_DONT_PANIC:
286 case VERR_TRPM_PANIC:
287 case VINF_EM_RAW_STALE_SELECTOR:
288 case VINF_EM_RAW_IRET_TRAP:
289 case VINF_EM_DBG_HYPER_BREAKPOINT:
290 case VINF_EM_DBG_HYPER_STEPPED:
291 case VERR_VMM_HYPER_CR3_MISMATCH:
292 {
293 /*
294 * Active trap? This is only of partial interest when in hardware
295 * assisted virtualization mode, thus the different messages.
296 */
297 uint32_t uEIP = CPUMGetHyperEIP(pVCpu);
298 TRPMEVENT enmType;
299 uint8_t u8TrapNo = 0xce;
300 RTGCUINT uErrorCode = 0xdeadface;
301 RTGCUINTPTR uCR2 = 0xdeadface;
302 int rc2 = TRPMQueryTrapAll(pVCpu, &u8TrapNo, &enmType, &uErrorCode, &uCR2);
303 if (!HMIsEnabled(pVM))
304 {
305 if (RT_SUCCESS(rc2))
306 pHlp->pfnPrintf(pHlp,
307 "!! TRAP=%02x ERRCD=%RGv CR2=%RGv EIP=%RX32 Type=%d\n",
308 u8TrapNo, uErrorCode, uCR2, uEIP, enmType);
309 else
310 pHlp->pfnPrintf(pHlp,
311 "!! EIP=%RX32 NOTRAP\n",
312 uEIP);
313 }
314 else if (RT_SUCCESS(rc2))
315 pHlp->pfnPrintf(pHlp,
316 "!! ACTIVE TRAP=%02x ERRCD=%RGv CR2=%RGv PC=%RGr Type=%d (Guest!)\n",
317 u8TrapNo, uErrorCode, uCR2, CPUMGetGuestRIP(pVCpu), enmType);
318
319 /*
320 * Dump the relevant hypervisor registers and stack.
321 */
322 if (HMIsEnabled(pVM))
323 {
324 if ( rcErr == VERR_VMM_RING0_ASSERTION /* fInRing3Call has already been cleared here. */
325 || pVCpu->vmm.s.CallRing3JmpBufR0.fInRing3Call)
326 {
327 /* Dump the jmpbuf. */
328 pHlp->pfnPrintf(pHlp,
329 "!!\n"
330 "!! CallRing3JmpBuf:\n"
331 "!!\n");
332 pHlp->pfnPrintf(pHlp,
333 "SavedEsp=%RHv SavedEbp=%RHv SpResume=%RHv SpCheck=%RHv\n",
334 pVCpu->vmm.s.CallRing3JmpBufR0.SavedEsp,
335 pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp,
336 pVCpu->vmm.s.CallRing3JmpBufR0.SpResume,
337 pVCpu->vmm.s.CallRing3JmpBufR0.SpCheck);
338 pHlp->pfnPrintf(pHlp,
339 "pvSavedStack=%RHv cbSavedStack=%#x fInRing3Call=%RTbool\n",
340 pVCpu->vmm.s.CallRing3JmpBufR0.pvSavedStack,
341 pVCpu->vmm.s.CallRing3JmpBufR0.cbSavedStack,
342 pVCpu->vmm.s.CallRing3JmpBufR0.fInRing3Call);
343 pHlp->pfnPrintf(pHlp,
344 "cbUsedMax=%#x cbUsedAvg=%#x cbUsedTotal=%#llx cUsedTotal=%#llx\n",
345 pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedMax,
346 pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedAvg,
347 pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedTotal,
348 pVCpu->vmm.s.CallRing3JmpBufR0.cUsedTotal);
349
350 /* Dump the resume register frame on the stack. */
351 PRTHCUINTPTR pBP;
352#ifdef VMM_R0_SWITCH_STACK
353 pBP = (PRTHCUINTPTR)&pVCpu->vmm.s.pbEMTStackR3[ pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp
354 - MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3)];
355#else
356 pBP = (PRTHCUINTPTR)&pVCpu->vmm.s.pbEMTStackR3[ pVCpu->vmm.s.CallRing3JmpBufR0.cbSavedStack
357 - pVCpu->vmm.s.CallRing3JmpBufR0.SpCheck
358 + pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp];
359#endif
360#if HC_ARCH_BITS == 32
361 pHlp->pfnPrintf(pHlp,
362 "eax=volatile ebx=%08x ecx=volatile edx=volatile esi=%08x edi=%08x\n"
363 "eip=%08x esp=%08x ebp=%08x efl=%08x\n"
364 ,
365 pBP[-3], pBP[-2], pBP[-1],
366 pBP[1], pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp - 8, pBP[0], pBP[-4]);
367#else
368# ifdef RT_OS_WINDOWS
369 pHlp->pfnPrintf(pHlp,
370 "rax=volatile rbx=%016RX64 rcx=volatile rdx=volatile\n"
371 "rsi=%016RX64 rdi=%016RX64 r8=volatile r9=volatile \n"
372 "r10=volatile r11=volatile r12=%016RX64 r13=%016RX64\n"
373 "r14=%016RX64 r15=%016RX64\n"
374 "rip=%016RX64 rsp=%016RX64 rbp=%016RX64 rfl=%08RX64\n"
375 ,
376 pBP[-7],
377 pBP[-6], pBP[-5],
378 pBP[-4], pBP[-3],
379 pBP[-2], pBP[-1],
380 pBP[1], pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp - 16, pBP[0], pBP[-8]);
381# else
382 pHlp->pfnPrintf(pHlp,
383 "rax=volatile rbx=%016RX64 rcx=volatile rdx=volatile\n"
384 "rsi=volatile rdi=volatile r8=volatile r9=volatile \n"
385 "r10=volatile r11=volatile r12=%016RX64 r13=%016RX64\n"
386 "r14=%016RX64 r15=%016RX64\n"
387 "rip=%016RX64 rsp=%016RX64 rbp=%016RX64 rflags=%08RX64\n"
388 ,
389 pBP[-5],
390 pBP[-4], pBP[-3],
391 pBP[-2], pBP[-1],
392 pBP[1], pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp - 16, pBP[0], pBP[-6]);
393# endif
394#endif
395
396 /* Callstack. */
397 DBGFADDRESS pc;
398 pc.fFlags = DBGFADDRESS_FLAGS_RING0 | DBGFADDRESS_FLAGS_VALID;
399#if HC_ARCH_BITS == 64
400 pc.FlatPtr = pc.off = pVCpu->vmm.s.CallRing3JmpBufR0.rip;
401#else
402 pc.FlatPtr = pc.off = pVCpu->vmm.s.CallRing3JmpBufR0.eip;
403#endif
404 pc.Sel = DBGF_SEL_FLAT;
405
406 DBGFADDRESS ebp;
407 ebp.fFlags = DBGFADDRESS_FLAGS_RING0 | DBGFADDRESS_FLAGS_VALID;
408 ebp.FlatPtr = ebp.off = pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp;
409 ebp.Sel = DBGF_SEL_FLAT;
410
411 DBGFADDRESS esp;
412 esp.fFlags = DBGFADDRESS_FLAGS_RING0 | DBGFADDRESS_FLAGS_VALID;
413 esp.Sel = DBGF_SEL_FLAT;
414 esp.FlatPtr = esp.off = pVCpu->vmm.s.CallRing3JmpBufR0.SavedEsp;
415
416 PCDBGFSTACKFRAME pFirstFrame;
417 rc2 = DBGFR3StackWalkBeginEx(pVM->pUVM, pVCpu->idCpu, DBGFCODETYPE_RING0, &ebp, &esp, &pc,
418 DBGFRETURNTYPE_INVALID, &pFirstFrame);
419 if (RT_SUCCESS(rc2))
420 {
421 pHlp->pfnPrintf(pHlp,
422 "!!\n"
423 "!! Call Stack:\n"
424 "!!\n");
425#if HC_ARCH_BITS == 32
426 pHlp->pfnPrintf(pHlp, "EBP Ret EBP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP Symbol [line]\n");
427#else
428 pHlp->pfnPrintf(pHlp, "RBP Ret RBP Ret RIP RIP Symbol [line]\n");
429#endif
430 for (PCDBGFSTACKFRAME pFrame = pFirstFrame;
431 pFrame;
432 pFrame = DBGFR3StackWalkNext(pFrame))
433 {
434#if HC_ARCH_BITS == 32
435 pHlp->pfnPrintf(pHlp,
436 "%RHv %RHv %04RX32:%RHv %RHv %RHv %RHv %RHv",
437 (RTHCUINTPTR)pFrame->AddrFrame.off,
438 (RTHCUINTPTR)pFrame->AddrReturnFrame.off,
439 (RTHCUINTPTR)pFrame->AddrReturnPC.Sel,
440 (RTHCUINTPTR)pFrame->AddrReturnPC.off,
441 pFrame->Args.au32[0],
442 pFrame->Args.au32[1],
443 pFrame->Args.au32[2],
444 pFrame->Args.au32[3]);
445 pHlp->pfnPrintf(pHlp, " %RTsel:%08RHv", pFrame->AddrPC.Sel, pFrame->AddrPC.off);
446#else
447 pHlp->pfnPrintf(pHlp,
448 "%RHv %RHv %RHv %RHv",
449 (RTHCUINTPTR)pFrame->AddrFrame.off,
450 (RTHCUINTPTR)pFrame->AddrReturnFrame.off,
451 (RTHCUINTPTR)pFrame->AddrReturnPC.off,
452 (RTHCUINTPTR)pFrame->AddrPC.off);
453#endif
454 if (pFrame->pSymPC)
455 {
456 RTGCINTPTR offDisp = pFrame->AddrPC.FlatPtr - pFrame->pSymPC->Value;
457 if (offDisp > 0)
458 pHlp->pfnPrintf(pHlp, " %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp);
459 else if (offDisp < 0)
460 pHlp->pfnPrintf(pHlp, " %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp);
461 else
462 pHlp->pfnPrintf(pHlp, " %s", pFrame->pSymPC->szName);
463 }
464 if (pFrame->pLinePC)
465 pHlp->pfnPrintf(pHlp, " [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo);
466 pHlp->pfnPrintf(pHlp, "\n");
467 }
468 DBGFR3StackWalkEnd(pFirstFrame);
469 }
470
471 /* raw stack */
472 Hlp.fRecSummary = false;
473 pHlp->pfnPrintf(pHlp,
474 "!!\n"
475 "!! Raw stack (mind the direction). \n"
476 "!! pbEMTStackR0=%RHv pbEMTStackBottomR0=%RHv VMM_STACK_SIZE=%#x\n"
477 "!! pbEmtStackR3=%p\n"
478 "!!\n"
479 "%.*Rhxd\n",
480 MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3),
481 MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3) + VMM_STACK_SIZE,
482 VMM_STACK_SIZE,
483 pVCpu->vmm.s.pbEMTStackR3,
484 VMM_STACK_SIZE, pVCpu->vmm.s.pbEMTStackR3);
485 }
486 else
487 {
488 pHlp->pfnPrintf(pHlp,
489 "!! Skipping ring-0 registers and stack, rcErr=%Rrc\n", rcErr);
490 }
491 }
492 else
493 {
494 /*
495 * Try figure out where eip is.
496 */
497 /* core code? */
498 if (uEIP - (RTGCUINTPTR)pVM->vmm.s.pvCoreCodeRC < pVM->vmm.s.cbCoreCode)
499 pHlp->pfnPrintf(pHlp,
500 "!! EIP is in CoreCode, offset %#x\n",
501 uEIP - (RTGCUINTPTR)pVM->vmm.s.pvCoreCodeRC);
502 else
503 { /* ask PDM */ /** @todo ask DBGFR3Sym later? */
504 char szModName[64];
505 RTRCPTR RCPtrMod;
506 char szNearSym1[260];
507 RTRCPTR RCPtrNearSym1;
508 char szNearSym2[260];
509 RTRCPTR RCPtrNearSym2;
510 int rc = PDMR3LdrQueryRCModFromPC(pVM, uEIP,
511 &szModName[0], sizeof(szModName), &RCPtrMod,
512 &szNearSym1[0], sizeof(szNearSym1), &RCPtrNearSym1,
513 &szNearSym2[0], sizeof(szNearSym2), &RCPtrNearSym2);
514 if (RT_SUCCESS(rc))
515 pHlp->pfnPrintf(pHlp,
516 "!! EIP in %s (%RRv) at rva %x near symbols:\n"
517 "!! %RRv rva %RRv off %08x %s\n"
518 "!! %RRv rva %RRv off -%08x %s\n",
519 szModName, RCPtrMod, (unsigned)(uEIP - RCPtrMod),
520 RCPtrNearSym1, RCPtrNearSym1 - RCPtrMod, (unsigned)(uEIP - RCPtrNearSym1), szNearSym1,
521 RCPtrNearSym2, RCPtrNearSym2 - RCPtrMod, (unsigned)(RCPtrNearSym2 - uEIP), szNearSym2);
522 else
523 pHlp->pfnPrintf(pHlp,
524 "!! EIP is not in any code known to VMM!\n");
525 }
526
527 /* Disassemble the instruction. */
528 char szInstr[256];
529 rc2 = DBGFR3DisasInstrEx(pVM->pUVM, pVCpu->idCpu, 0, 0,
530 DBGF_DISAS_FLAGS_CURRENT_HYPER | DBGF_DISAS_FLAGS_DEFAULT_MODE,
531 &szInstr[0], sizeof(szInstr), NULL);
532 if (RT_SUCCESS(rc2))
533 pHlp->pfnPrintf(pHlp,
534 "!! %s\n", szInstr);
535
536 /* Dump the hypervisor cpu state. */
537 pHlp->pfnPrintf(pHlp,
538 "!!\n"
539 "!!\n"
540 "!!\n");
541 rc2 = DBGFR3Info(pVM->pUVM, "cpumhyper", "verbose", pHlp);
542 fDoneHyper = true;
543
544 /* Callstack. */
545 PCDBGFSTACKFRAME pFirstFrame;
546 rc2 = DBGFR3StackWalkBegin(pVM->pUVM, pVCpu->idCpu, DBGFCODETYPE_HYPER, &pFirstFrame);
547 if (RT_SUCCESS(rc2))
548 {
549 pHlp->pfnPrintf(pHlp,
550 "!!\n"
551 "!! Call Stack:\n"
552 "!!\n"
553 "EBP Ret EBP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP Symbol [line]\n");
554 for (PCDBGFSTACKFRAME pFrame = pFirstFrame;
555 pFrame;
556 pFrame = DBGFR3StackWalkNext(pFrame))
557 {
558 pHlp->pfnPrintf(pHlp,
559 "%08RX32 %08RX32 %04RX32:%08RX32 %08RX32 %08RX32 %08RX32 %08RX32",
560 (uint32_t)pFrame->AddrFrame.off,
561 (uint32_t)pFrame->AddrReturnFrame.off,
562 (uint32_t)pFrame->AddrReturnPC.Sel,
563 (uint32_t)pFrame->AddrReturnPC.off,
564 pFrame->Args.au32[0],
565 pFrame->Args.au32[1],
566 pFrame->Args.au32[2],
567 pFrame->Args.au32[3]);
568 pHlp->pfnPrintf(pHlp, " %RTsel:%08RGv", pFrame->AddrPC.Sel, pFrame->AddrPC.off);
569 if (pFrame->pSymPC)
570 {
571 RTGCINTPTR offDisp = pFrame->AddrPC.FlatPtr - pFrame->pSymPC->Value;
572 if (offDisp > 0)
573 pHlp->pfnPrintf(pHlp, " %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp);
574 else if (offDisp < 0)
575 pHlp->pfnPrintf(pHlp, " %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp);
576 else
577 pHlp->pfnPrintf(pHlp, " %s", pFrame->pSymPC->szName);
578 }
579 if (pFrame->pLinePC)
580 pHlp->pfnPrintf(pHlp, " [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo);
581 pHlp->pfnPrintf(pHlp, "\n");
582 }
583 DBGFR3StackWalkEnd(pFirstFrame);
584 }
585
586 /* raw stack */
587 Hlp.fRecSummary = false;
588 pHlp->pfnPrintf(pHlp,
589 "!!\n"
590 "!! Raw stack (mind the direction). pbEMTStackRC=%RRv pbEMTStackBottomRC=%RRv\n"
591 "!!\n"
592 "%.*Rhxd\n",
593 pVCpu->vmm.s.pbEMTStackRC, pVCpu->vmm.s.pbEMTStackBottomRC,
594 VMM_STACK_SIZE, pVCpu->vmm.s.pbEMTStackR3);
595 } /* !HMIsEnabled */
596 break;
597 }
598
599 case VERR_IEM_INSTR_NOT_IMPLEMENTED:
600 case VERR_IEM_ASPECT_NOT_IMPLEMENTED:
601 {
602 DBGFR3Info(pVM->pUVM, "cpumguest", NULL, pHlp);
603 DBGFR3Info(pVM->pUVM, "cpumguestinstr", NULL, pHlp);
604 break;
605 }
606
607 default:
608 {
609 break;
610 }
611
612 } /* switch (rcErr) */
613 Hlp.fRecSummary = false;
614
615
616 /*
617 * Generic info dumper loop.
618 */
619 static struct
620 {
621 const char *pszInfo;
622 const char *pszArgs;
623 } const aInfo[] =
624 {
625 { "mappings", NULL },
626 { "hma", NULL },
627 { "cpumguest", "verbose" },
628 { "cpumguestinstr", "verbose" },
629 { "cpumhyper", "verbose" },
630 { "cpumhost", "verbose" },
631 { "mode", "all" },
632 { "cpuid", "verbose" },
633 { "handlers", "phys virt hyper stats" },
634 { "timers", NULL },
635 { "activetimers", NULL },
636 };
637 for (unsigned i = 0; i < RT_ELEMENTS(aInfo); i++)
638 {
639 if (fDoneHyper && !strcmp(aInfo[i].pszInfo, "cpumhyper"))
640 continue;
641 pHlp->pfnPrintf(pHlp,
642 "!!\n"
643 "!! {%s, %s}\n"
644 "!!\n",
645 aInfo[i].pszInfo, aInfo[i].pszArgs);
646 DBGFR3Info(pVM->pUVM, aInfo[i].pszInfo, aInfo[i].pszArgs, pHlp);
647 }
648
649 /* All other info items */
650 DBGFR3InfoMulti(pVM,
651 "*",
652 "mappings|hma|cpum|cpumguest|cpumguestinstr|cpumhyper|cpumhost|mode|cpuid"
653 "|pgmpd|pgmcr3|timers|activetimers|handlers|help",
654 "!!\n"
655 "!! {%s}\n"
656 "!!\n",
657 pHlp);
658
659
660 /* done */
661 pHlp->pfnPrintf(pHlp,
662 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
663
664
665 /*
666 * Repeat the summary to stderr so we don't have to scroll half a mile up.
667 */
668 if (Hlp.szSummary[0])
669 RTStrmPrintf(g_pStdErr,
670 "%s"
671 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",
672 Hlp.szSummary);
673
674 /*
675 * Delete the output instance (flushing and restoring of flags).
676 */
677 vmmR3FatalDumpInfoHlpDelete(&Hlp);
678}
679
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette