VirtualBox

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

Last change on this file since 93115 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

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