1 | /* $Id: DBGFStack.cpp 73495 2018-08-04 19:42:07Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DBGF - Debugger Facility, Call Stack Analyser.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 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_DBGF
|
---|
23 | #include <VBox/vmm/dbgf.h>
|
---|
24 | #include <VBox/vmm/selm.h>
|
---|
25 | #include <VBox/vmm/mm.h>
|
---|
26 | #include "DBGFInternal.h"
|
---|
27 | #include <VBox/vmm/vm.h>
|
---|
28 | #include <VBox/vmm/uvm.h>
|
---|
29 | #include <VBox/err.h>
|
---|
30 | #include <VBox/log.h>
|
---|
31 | #include <iprt/param.h>
|
---|
32 | #include <iprt/assert.h>
|
---|
33 | #include <iprt/alloca.h>
|
---|
34 | #include <iprt/mem.h>
|
---|
35 | #include <iprt/string.h>
|
---|
36 | #include <iprt/formats/pecoff.h>
|
---|
37 |
|
---|
38 |
|
---|
39 | /*********************************************************************************************************************************
|
---|
40 | * Structures and Typedefs *
|
---|
41 | *********************************************************************************************************************************/
|
---|
42 | static DECLCALLBACK(int) dbgfR3StackReadCallback(PRTDBGUNWINDSTATE pThis, RTUINTPTR uSp, size_t cbToRead, void *pvDst);
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Unwind context.
|
---|
46 | *
|
---|
47 | * @note Using a constructor and destructor here for simple+safe cleanup.
|
---|
48 | */
|
---|
49 | typedef struct DBGFUNWINDCTX
|
---|
50 | {
|
---|
51 | PUVM m_pUVM;
|
---|
52 | VMCPUID m_idCpu;
|
---|
53 | RTDBGAS m_hAs;
|
---|
54 | PCCPUMCTX m_pInitialCtx;
|
---|
55 | bool m_fIsHostRing0;
|
---|
56 | uint64_t m_uOsScratch; /**< For passing to DBGFOSREG::pfnStackUnwindAssist. */
|
---|
57 |
|
---|
58 | RTDBGMOD m_hCached;
|
---|
59 | RTUINTPTR m_uCachedMapping;
|
---|
60 | RTUINTPTR m_cbCachedMapping;
|
---|
61 | RTDBGSEGIDX m_idxCachedSegMapping;
|
---|
62 |
|
---|
63 | RTDBGUNWINDSTATE m_State;
|
---|
64 |
|
---|
65 | DBGFUNWINDCTX(PUVM pUVM, VMCPUID idCpu, PCCPUMCTX pInitialCtx, RTDBGAS hAs)
|
---|
66 | {
|
---|
67 | m_State.u32Magic = RTDBGUNWINDSTATE_MAGIC;
|
---|
68 | m_State.enmArch = RTLDRARCH_AMD64;
|
---|
69 | m_State.pfnReadStack = dbgfR3StackReadCallback;
|
---|
70 | m_State.pvUser = this;
|
---|
71 | RT_ZERO(m_State.u);
|
---|
72 | if (pInitialCtx)
|
---|
73 | {
|
---|
74 | m_State.u.x86.auRegs[X86_GREG_xAX] = pInitialCtx->rax;
|
---|
75 | m_State.u.x86.auRegs[X86_GREG_xCX] = pInitialCtx->rcx;
|
---|
76 | m_State.u.x86.auRegs[X86_GREG_xDX] = pInitialCtx->rdx;
|
---|
77 | m_State.u.x86.auRegs[X86_GREG_xBX] = pInitialCtx->rbx;
|
---|
78 | m_State.u.x86.auRegs[X86_GREG_xSP] = pInitialCtx->rsp;
|
---|
79 | m_State.u.x86.auRegs[X86_GREG_xBP] = pInitialCtx->rbp;
|
---|
80 | m_State.u.x86.auRegs[X86_GREG_xSI] = pInitialCtx->rsi;
|
---|
81 | m_State.u.x86.auRegs[X86_GREG_xDI] = pInitialCtx->rdi;
|
---|
82 | m_State.u.x86.auRegs[X86_GREG_x8 ] = pInitialCtx->r8;
|
---|
83 | m_State.u.x86.auRegs[X86_GREG_x9 ] = pInitialCtx->r9;
|
---|
84 | m_State.u.x86.auRegs[X86_GREG_x10] = pInitialCtx->r10;
|
---|
85 | m_State.u.x86.auRegs[X86_GREG_x11] = pInitialCtx->r11;
|
---|
86 | m_State.u.x86.auRegs[X86_GREG_x12] = pInitialCtx->r12;
|
---|
87 | m_State.u.x86.auRegs[X86_GREG_x13] = pInitialCtx->r13;
|
---|
88 | m_State.u.x86.auRegs[X86_GREG_x14] = pInitialCtx->r14;
|
---|
89 | m_State.u.x86.auRegs[X86_GREG_x15] = pInitialCtx->r15;
|
---|
90 | m_State.uPc = pInitialCtx->rip;
|
---|
91 | m_State.u.x86.uRFlags = pInitialCtx->rflags.u;
|
---|
92 | m_State.u.x86.auSegs[X86_SREG_ES] = pInitialCtx->es.Sel;
|
---|
93 | m_State.u.x86.auSegs[X86_SREG_CS] = pInitialCtx->cs.Sel;
|
---|
94 | m_State.u.x86.auSegs[X86_SREG_SS] = pInitialCtx->ss.Sel;
|
---|
95 | m_State.u.x86.auSegs[X86_SREG_DS] = pInitialCtx->ds.Sel;
|
---|
96 | m_State.u.x86.auSegs[X86_SREG_GS] = pInitialCtx->gs.Sel;
|
---|
97 | m_State.u.x86.auSegs[X86_SREG_FS] = pInitialCtx->fs.Sel;
|
---|
98 | m_State.u.x86.fRealOrV86 = CPUMIsGuestInRealOrV86ModeEx(pInitialCtx);
|
---|
99 | }
|
---|
100 | else if (hAs == DBGF_AS_R0)
|
---|
101 | VMMR3InitR0StackUnwindState(pUVM, idCpu, &m_State);
|
---|
102 |
|
---|
103 | m_pUVM = pUVM;
|
---|
104 | m_idCpu = idCpu;
|
---|
105 | m_hAs = DBGFR3AsResolveAndRetain(pUVM, hAs);
|
---|
106 | m_pInitialCtx = pInitialCtx;
|
---|
107 | m_fIsHostRing0 = hAs == DBGF_AS_R0;
|
---|
108 | m_uOsScratch = 0;
|
---|
109 |
|
---|
110 | m_hCached = NIL_RTDBGMOD;
|
---|
111 | m_uCachedMapping = 0;
|
---|
112 | m_cbCachedMapping = 0;
|
---|
113 | m_idxCachedSegMapping = NIL_RTDBGSEGIDX;
|
---|
114 | }
|
---|
115 |
|
---|
116 | ~DBGFUNWINDCTX();
|
---|
117 |
|
---|
118 | } DBGFUNWINDCTX;
|
---|
119 | /** Pointer to unwind context. */
|
---|
120 | typedef DBGFUNWINDCTX *PDBGFUNWINDCTX;
|
---|
121 |
|
---|
122 |
|
---|
123 | static void dbgfR3UnwindCtxFlushCache(PDBGFUNWINDCTX pUnwindCtx)
|
---|
124 | {
|
---|
125 | if (pUnwindCtx->m_hCached != NIL_RTDBGMOD)
|
---|
126 | {
|
---|
127 | RTDbgModRelease(pUnwindCtx->m_hCached);
|
---|
128 | pUnwindCtx->m_hCached = NIL_RTDBGMOD;
|
---|
129 | }
|
---|
130 | pUnwindCtx->m_cbCachedMapping = 0;
|
---|
131 | pUnwindCtx->m_idxCachedSegMapping = NIL_RTDBGSEGIDX;
|
---|
132 | }
|
---|
133 |
|
---|
134 |
|
---|
135 | DBGFUNWINDCTX::~DBGFUNWINDCTX()
|
---|
136 | {
|
---|
137 | dbgfR3UnwindCtxFlushCache(this);
|
---|
138 | if (m_hAs != NIL_RTDBGAS)
|
---|
139 | {
|
---|
140 | RTDbgAsRelease(m_hAs);
|
---|
141 | m_hAs = NIL_RTDBGAS;
|
---|
142 | }
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * @interface_method_impl{RTDBGUNWINDSTATE,pfnReadStack}
|
---|
148 | */
|
---|
149 | static DECLCALLBACK(int) dbgfR3StackReadCallback(PRTDBGUNWINDSTATE pThis, RTUINTPTR uSp, size_t cbToRead, void *pvDst)
|
---|
150 | {
|
---|
151 | Assert( pThis->enmArch == RTLDRARCH_AMD64
|
---|
152 | || pThis->enmArch == RTLDRARCH_X86_32);
|
---|
153 |
|
---|
154 | PDBGFUNWINDCTX pUnwindCtx = (PDBGFUNWINDCTX)pThis->pvUser;
|
---|
155 | DBGFADDRESS SrcAddr;
|
---|
156 | int rc = VINF_SUCCESS;
|
---|
157 | if (pUnwindCtx->m_fIsHostRing0)
|
---|
158 | DBGFR3AddrFromHostR0(&SrcAddr, uSp);
|
---|
159 | else
|
---|
160 | {
|
---|
161 | if ( pThis->enmArch == RTLDRARCH_X86_32
|
---|
162 | || pThis->enmArch == RTLDRARCH_X86_16)
|
---|
163 | {
|
---|
164 | if (!pThis->u.x86.fRealOrV86)
|
---|
165 | rc = DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &SrcAddr, pThis->u.x86.auSegs[X86_SREG_SS], uSp);
|
---|
166 | else
|
---|
167 | DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &SrcAddr, uSp + ((uint32_t)pThis->u.x86.auSegs[X86_SREG_SS] << 4));
|
---|
168 | }
|
---|
169 | else
|
---|
170 | DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &SrcAddr, uSp);
|
---|
171 | }
|
---|
172 | if (RT_SUCCESS(rc))
|
---|
173 | rc = DBGFR3MemRead(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &SrcAddr, pvDst, cbToRead);
|
---|
174 | if (RT_SUCCESS(rc))
|
---|
175 | return rc;
|
---|
176 | return -rc; /* Ignore read errors. */
|
---|
177 | }
|
---|
178 |
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * Sets PC and SP.
|
---|
182 | *
|
---|
183 | * @returns true.
|
---|
184 | * @param pUnwindCtx The unwind context.
|
---|
185 | * @param pAddrPC The program counter (PC) value to set.
|
---|
186 | * @param pAddrStack The stack pointer (SP) value to set.
|
---|
187 | */
|
---|
188 | static bool dbgfR3UnwindCtxSetPcAndSp(PDBGFUNWINDCTX pUnwindCtx, PCDBGFADDRESS pAddrPC, PCDBGFADDRESS pAddrStack)
|
---|
189 | {
|
---|
190 | Assert( pUnwindCtx->m_State.enmArch == RTLDRARCH_AMD64
|
---|
191 | || pUnwindCtx->m_State.enmArch == RTLDRARCH_X86_32);
|
---|
192 |
|
---|
193 | if (!DBGFADDRESS_IS_FAR(pAddrPC))
|
---|
194 | pUnwindCtx->m_State.uPc = pAddrPC->FlatPtr;
|
---|
195 | else
|
---|
196 | {
|
---|
197 | pUnwindCtx->m_State.uPc = pAddrPC->off;
|
---|
198 | pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_CS] = pAddrPC->Sel;
|
---|
199 | }
|
---|
200 | if (!DBGFADDRESS_IS_FAR(pAddrStack))
|
---|
201 | pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xSP] = pAddrStack->FlatPtr;
|
---|
202 | else
|
---|
203 | {
|
---|
204 | pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xSP] = pAddrStack->off;
|
---|
205 | pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_SS] = pAddrStack->Sel;
|
---|
206 | }
|
---|
207 | return true;
|
---|
208 | }
|
---|
209 |
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Tries to unwind one frame using unwind info.
|
---|
213 | *
|
---|
214 | * @returns true on success, false on failure.
|
---|
215 | * @param pUnwindCtx The unwind context.
|
---|
216 | */
|
---|
217 | static bool dbgfR3UnwindCtxDoOneFrame(PDBGFUNWINDCTX pUnwindCtx)
|
---|
218 | {
|
---|
219 | /*
|
---|
220 | * Need to load it into the cache?
|
---|
221 | */
|
---|
222 | RTUINTPTR offCache = pUnwindCtx->m_State.uPc - pUnwindCtx->m_uCachedMapping;
|
---|
223 | if (offCache >= pUnwindCtx->m_cbCachedMapping)
|
---|
224 | {
|
---|
225 | RTDBGMOD hDbgMod = NIL_RTDBGMOD;
|
---|
226 | RTUINTPTR uBase = 0;
|
---|
227 | RTDBGSEGIDX idxSeg = NIL_RTDBGSEGIDX;
|
---|
228 | int rc = RTDbgAsModuleByAddr(pUnwindCtx->m_hAs, pUnwindCtx->m_State.uPc, &hDbgMod, &uBase, &idxSeg);
|
---|
229 | if (RT_SUCCESS(rc))
|
---|
230 | {
|
---|
231 | dbgfR3UnwindCtxFlushCache(pUnwindCtx);
|
---|
232 | pUnwindCtx->m_hCached = hDbgMod;
|
---|
233 | pUnwindCtx->m_uCachedMapping = uBase;
|
---|
234 | pUnwindCtx->m_idxCachedSegMapping = idxSeg;
|
---|
235 | pUnwindCtx->m_cbCachedMapping = idxSeg == NIL_RTDBGSEGIDX ? RTDbgModImageSize(hDbgMod)
|
---|
236 | : RTDbgModSegmentSize(hDbgMod, idxSeg);
|
---|
237 | offCache = pUnwindCtx->m_State.uPc - uBase;
|
---|
238 | }
|
---|
239 | else
|
---|
240 | return false;
|
---|
241 | }
|
---|
242 |
|
---|
243 | /*
|
---|
244 | * Do the lookup.
|
---|
245 | */
|
---|
246 | AssertCompile(UINT32_MAX == NIL_RTDBGSEGIDX);
|
---|
247 | int rc = RTDbgModUnwindFrame(pUnwindCtx->m_hCached, pUnwindCtx->m_idxCachedSegMapping, offCache, &pUnwindCtx->m_State);
|
---|
248 | if (RT_SUCCESS(rc))
|
---|
249 | return true;
|
---|
250 | return false;
|
---|
251 | }
|
---|
252 |
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Read stack memory, will init entire buffer.
|
---|
256 | */
|
---|
257 | DECLINLINE(int) dbgfR3StackRead(PUVM pUVM, VMCPUID idCpu, void *pvBuf, PCDBGFADDRESS pSrcAddr, size_t cb, size_t *pcbRead)
|
---|
258 | {
|
---|
259 | int rc = DBGFR3MemRead(pUVM, idCpu, pSrcAddr, pvBuf, cb);
|
---|
260 | if (RT_FAILURE(rc))
|
---|
261 | {
|
---|
262 | /* fallback: byte by byte and zero the ones we fail to read. */
|
---|
263 | size_t cbRead;
|
---|
264 | for (cbRead = 0; cbRead < cb; cbRead++)
|
---|
265 | {
|
---|
266 | DBGFADDRESS Addr = *pSrcAddr;
|
---|
267 | rc = DBGFR3MemRead(pUVM, idCpu, DBGFR3AddrAdd(&Addr, cbRead), (uint8_t *)pvBuf + cbRead, 1);
|
---|
268 | if (RT_FAILURE(rc))
|
---|
269 | break;
|
---|
270 | }
|
---|
271 | if (cbRead)
|
---|
272 | rc = VINF_SUCCESS;
|
---|
273 | memset((char *)pvBuf + cbRead, 0, cb - cbRead);
|
---|
274 | *pcbRead = cbRead;
|
---|
275 | }
|
---|
276 | else
|
---|
277 | *pcbRead = cb;
|
---|
278 | return rc;
|
---|
279 | }
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * Collects sure registers on frame exit.
|
---|
283 | *
|
---|
284 | * @returns VINF_SUCCESS or VERR_NO_MEMORY.
|
---|
285 | * @param pUVM The user mode VM handle for the allocation.
|
---|
286 | * @param pFrame The frame in question.
|
---|
287 | * @param pState The unwind state.
|
---|
288 | */
|
---|
289 | static int dbgfR3StackWalkCollectRegisterChanges(PUVM pUVM, PDBGFSTACKFRAME pFrame, PRTDBGUNWINDSTATE pState)
|
---|
290 | {
|
---|
291 | pFrame->cSureRegs = 0;
|
---|
292 | pFrame->paSureRegs = NULL;
|
---|
293 |
|
---|
294 | if ( pState->enmArch == RTLDRARCH_AMD64
|
---|
295 | || pState->enmArch == RTLDRARCH_X86_32
|
---|
296 | || pState->enmArch == RTLDRARCH_X86_16)
|
---|
297 | {
|
---|
298 | if (pState->u.x86.Loaded.fAll)
|
---|
299 | {
|
---|
300 | /*
|
---|
301 | * Count relevant registers.
|
---|
302 | */
|
---|
303 | uint32_t cRegs = 0;
|
---|
304 | if (pState->u.x86.Loaded.s.fRegs)
|
---|
305 | for (uint32_t f = 1; f < RT_BIT_32(RT_ELEMENTS(pState->u.x86.auRegs)); f <<= 1)
|
---|
306 | if (pState->u.x86.Loaded.s.fRegs & f)
|
---|
307 | cRegs++;
|
---|
308 | if (pState->u.x86.Loaded.s.fSegs)
|
---|
309 | for (uint32_t f = 1; f < RT_BIT_32(RT_ELEMENTS(pState->u.x86.auSegs)); f <<= 1)
|
---|
310 | if (pState->u.x86.Loaded.s.fSegs & f)
|
---|
311 | cRegs++;
|
---|
312 | if (pState->u.x86.Loaded.s.fRFlags)
|
---|
313 | cRegs++;
|
---|
314 | if (pState->u.x86.Loaded.s.fErrCd)
|
---|
315 | cRegs++;
|
---|
316 | if (cRegs > 0)
|
---|
317 | {
|
---|
318 | /*
|
---|
319 | * Allocate the arrays.
|
---|
320 | */
|
---|
321 | PDBGFREGVALEX paSureRegs = (PDBGFREGVALEX)MMR3HeapAllocZU(pUVM, MM_TAG_DBGF_STACK, sizeof(DBGFREGVALEX) * cRegs);
|
---|
322 | AssertReturn(paSureRegs, VERR_NO_MEMORY);
|
---|
323 | pFrame->paSureRegs = paSureRegs;
|
---|
324 | pFrame->cSureRegs = cRegs;
|
---|
325 |
|
---|
326 | /*
|
---|
327 | * Popuplate the arrays.
|
---|
328 | */
|
---|
329 | uint32_t iReg = 0;
|
---|
330 | if (pState->u.x86.Loaded.s.fRegs)
|
---|
331 | for (uint32_t i = 0; i < RT_ELEMENTS(pState->u.x86.auRegs); i++)
|
---|
332 | if (pState->u.x86.Loaded.s.fRegs & RT_BIT(i))
|
---|
333 | {
|
---|
334 | paSureRegs[iReg].Value.u64 = pState->u.x86.auRegs[i];
|
---|
335 | paSureRegs[iReg].enmType = DBGFREGVALTYPE_U64;
|
---|
336 | paSureRegs[iReg].enmReg = (DBGFREG)(DBGFREG_RAX + i);
|
---|
337 | iReg++;
|
---|
338 | }
|
---|
339 |
|
---|
340 | if (pState->u.x86.Loaded.s.fSegs)
|
---|
341 | for (uint32_t i = 0; i < RT_ELEMENTS(pState->u.x86.auSegs); i++)
|
---|
342 | if (pState->u.x86.Loaded.s.fSegs & RT_BIT(i))
|
---|
343 | {
|
---|
344 | paSureRegs[iReg].Value.u16 = pState->u.x86.auSegs[i];
|
---|
345 | paSureRegs[iReg].enmType = DBGFREGVALTYPE_U16;
|
---|
346 | switch (i)
|
---|
347 | {
|
---|
348 | case X86_SREG_ES: paSureRegs[iReg].enmReg = DBGFREG_ES; break;
|
---|
349 | case X86_SREG_CS: paSureRegs[iReg].enmReg = DBGFREG_CS; break;
|
---|
350 | case X86_SREG_SS: paSureRegs[iReg].enmReg = DBGFREG_SS; break;
|
---|
351 | case X86_SREG_DS: paSureRegs[iReg].enmReg = DBGFREG_DS; break;
|
---|
352 | case X86_SREG_FS: paSureRegs[iReg].enmReg = DBGFREG_FS; break;
|
---|
353 | case X86_SREG_GS: paSureRegs[iReg].enmReg = DBGFREG_GS; break;
|
---|
354 | default: AssertFailedBreak();
|
---|
355 | }
|
---|
356 | iReg++;
|
---|
357 | }
|
---|
358 |
|
---|
359 | if (iReg < cRegs)
|
---|
360 | {
|
---|
361 | if (pState->u.x86.Loaded.s.fRFlags)
|
---|
362 | {
|
---|
363 | paSureRegs[iReg].Value.u64 = pState->u.x86.uRFlags;
|
---|
364 | paSureRegs[iReg].enmType = DBGFREGVALTYPE_U64;
|
---|
365 | paSureRegs[iReg].enmReg = DBGFREG_RFLAGS;
|
---|
366 | iReg++;
|
---|
367 | }
|
---|
368 | if (pState->u.x86.Loaded.s.fErrCd)
|
---|
369 | {
|
---|
370 | paSureRegs[iReg].Value.u64 = pState->u.x86.uErrCd;
|
---|
371 | paSureRegs[iReg].enmType = DBGFREGVALTYPE_U64;
|
---|
372 | paSureRegs[iReg].enmReg = DBGFREG_END;
|
---|
373 | paSureRegs[iReg].pszName = "trap-errcd";
|
---|
374 | iReg++;
|
---|
375 | }
|
---|
376 | }
|
---|
377 | Assert(iReg == cRegs);
|
---|
378 | }
|
---|
379 | }
|
---|
380 | }
|
---|
381 |
|
---|
382 | return VINF_SUCCESS;
|
---|
383 | }
|
---|
384 |
|
---|
385 |
|
---|
386 | /**
|
---|
387 | * Internal worker routine.
|
---|
388 | *
|
---|
389 | * On x86 the typical stack frame layout is like this:
|
---|
390 | * .. ..
|
---|
391 | * 16 parameter 2
|
---|
392 | * 12 parameter 1
|
---|
393 | * 8 parameter 0
|
---|
394 | * 4 return address
|
---|
395 | * 0 old ebp; current ebp points here
|
---|
396 | */
|
---|
397 | DECL_NO_INLINE(static, int) dbgfR3StackWalk(PDBGFUNWINDCTX pUnwindCtx, PDBGFSTACKFRAME pFrame, bool fFirst)
|
---|
398 | {
|
---|
399 | /*
|
---|
400 | * Stop if we got a read error in the previous run.
|
---|
401 | */
|
---|
402 | if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_LAST)
|
---|
403 | return VERR_NO_MORE_FILES;
|
---|
404 |
|
---|
405 | /*
|
---|
406 | * Advance the frame (except for the first).
|
---|
407 | */
|
---|
408 | if (!fFirst) /** @todo we can probably eliminate this fFirst business... */
|
---|
409 | {
|
---|
410 | /* frame, pc and stack is taken from the existing frames return members. */
|
---|
411 | pFrame->AddrFrame = pFrame->AddrReturnFrame;
|
---|
412 | pFrame->AddrPC = pFrame->AddrReturnPC;
|
---|
413 | pFrame->pSymPC = pFrame->pSymReturnPC;
|
---|
414 | pFrame->pLinePC = pFrame->pLineReturnPC;
|
---|
415 |
|
---|
416 | /* increment the frame number. */
|
---|
417 | pFrame->iFrame++;
|
---|
418 |
|
---|
419 | /* UNWIND_INFO_RET -> USED_UNWIND; return type */
|
---|
420 | if (!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET))
|
---|
421 | pFrame->fFlags &= ~DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO;
|
---|
422 | else
|
---|
423 | {
|
---|
424 | pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO;
|
---|
425 | pFrame->fFlags &= ~DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET;
|
---|
426 | if (pFrame->enmReturnFrameReturnType != RTDBGRETURNTYPE_INVALID)
|
---|
427 | {
|
---|
428 | pFrame->enmReturnType = pFrame->enmReturnFrameReturnType;
|
---|
429 | pFrame->enmReturnFrameReturnType = RTDBGRETURNTYPE_INVALID;
|
---|
430 | }
|
---|
431 | }
|
---|
432 | pFrame->fFlags &= ~DBGFSTACKFRAME_FLAGS_TRAP_FRAME;
|
---|
433 | }
|
---|
434 |
|
---|
435 | /*
|
---|
436 | * Figure the return address size and use the old PC to guess stack item size.
|
---|
437 | */
|
---|
438 | /** @todo this is bogus... */
|
---|
439 | unsigned cbRetAddr = RTDbgReturnTypeSize(pFrame->enmReturnType);
|
---|
440 | unsigned cbStackItem;
|
---|
441 | switch (pFrame->AddrPC.fFlags & DBGFADDRESS_FLAGS_TYPE_MASK)
|
---|
442 | {
|
---|
443 | case DBGFADDRESS_FLAGS_FAR16: cbStackItem = 2; break;
|
---|
444 | case DBGFADDRESS_FLAGS_FAR32: cbStackItem = 4; break;
|
---|
445 | case DBGFADDRESS_FLAGS_FAR64: cbStackItem = 8; break;
|
---|
446 | case DBGFADDRESS_FLAGS_RING0: cbStackItem = sizeof(RTHCUINTPTR); break;
|
---|
447 | default:
|
---|
448 | switch (pFrame->enmReturnType)
|
---|
449 | {
|
---|
450 | case RTDBGRETURNTYPE_FAR16:
|
---|
451 | case RTDBGRETURNTYPE_IRET16:
|
---|
452 | case RTDBGRETURNTYPE_IRET32_V86:
|
---|
453 | case RTDBGRETURNTYPE_NEAR16: cbStackItem = 2; break;
|
---|
454 |
|
---|
455 | case RTDBGRETURNTYPE_FAR32:
|
---|
456 | case RTDBGRETURNTYPE_IRET32:
|
---|
457 | case RTDBGRETURNTYPE_IRET32_PRIV:
|
---|
458 | case RTDBGRETURNTYPE_NEAR32: cbStackItem = 4; break;
|
---|
459 |
|
---|
460 | case RTDBGRETURNTYPE_FAR64:
|
---|
461 | case RTDBGRETURNTYPE_IRET64:
|
---|
462 | case RTDBGRETURNTYPE_NEAR64: cbStackItem = 8; break;
|
---|
463 |
|
---|
464 | default:
|
---|
465 | AssertMsgFailed(("%d\n", pFrame->enmReturnType));
|
---|
466 | cbStackItem = 4;
|
---|
467 | break;
|
---|
468 | }
|
---|
469 | }
|
---|
470 |
|
---|
471 | /*
|
---|
472 | * Read the raw frame data.
|
---|
473 | * We double cbRetAddr in case we have a far return.
|
---|
474 | */
|
---|
475 | union
|
---|
476 | {
|
---|
477 | uint64_t *pu64;
|
---|
478 | uint32_t *pu32;
|
---|
479 | uint16_t *pu16;
|
---|
480 | uint8_t *pb;
|
---|
481 | void *pv;
|
---|
482 | } u, uRet, uArgs, uBp;
|
---|
483 | size_t cbRead = cbRetAddr*2 + cbStackItem + sizeof(pFrame->Args);
|
---|
484 | u.pv = alloca(cbRead);
|
---|
485 | uBp = u;
|
---|
486 | uRet.pb = u.pb + cbStackItem;
|
---|
487 | uArgs.pb = u.pb + cbStackItem + cbRetAddr;
|
---|
488 |
|
---|
489 | Assert(DBGFADDRESS_IS_VALID(&pFrame->AddrFrame));
|
---|
490 | int rc = dbgfR3StackRead(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, u.pv, &pFrame->AddrFrame, cbRead, &cbRead);
|
---|
491 | if ( RT_FAILURE(rc)
|
---|
492 | || cbRead < cbRetAddr + cbStackItem)
|
---|
493 | pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_LAST;
|
---|
494 |
|
---|
495 | /*
|
---|
496 | * Return Frame address.
|
---|
497 | *
|
---|
498 | * If we used unwind info to get here, the unwind register context will be
|
---|
499 | * positioned after the return instruction has been executed. We start by
|
---|
500 | * picking up the rBP register here for return frame and will try improve
|
---|
501 | * on it further down by using unwind info.
|
---|
502 | */
|
---|
503 | pFrame->AddrReturnFrame = pFrame->AddrFrame;
|
---|
504 | if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
|
---|
505 | {
|
---|
506 | if ( pFrame->enmReturnType == RTDBGRETURNTYPE_IRET32_PRIV
|
---|
507 | || pFrame->enmReturnType == RTDBGRETURNTYPE_IRET64)
|
---|
508 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnFrame,
|
---|
509 | pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_SS], pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xBP]);
|
---|
510 | else if (pFrame->enmReturnType == RTDBGRETURNTYPE_IRET32_V86)
|
---|
511 | DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &pFrame->AddrReturnFrame,
|
---|
512 | ((uint32_t)pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_SS] << 4)
|
---|
513 | + pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xBP]);
|
---|
514 | else
|
---|
515 | {
|
---|
516 | pFrame->AddrReturnFrame.off = pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xBP];
|
---|
517 | pFrame->AddrReturnFrame.FlatPtr += pFrame->AddrReturnFrame.off - pFrame->AddrFrame.off;
|
---|
518 | }
|
---|
519 | }
|
---|
520 | else
|
---|
521 | {
|
---|
522 | switch (cbStackItem)
|
---|
523 | {
|
---|
524 | case 2: pFrame->AddrReturnFrame.off = *uBp.pu16; break;
|
---|
525 | case 4: pFrame->AddrReturnFrame.off = *uBp.pu32; break;
|
---|
526 | case 8: pFrame->AddrReturnFrame.off = *uBp.pu64; break;
|
---|
527 | default: AssertMsgFailedReturn(("cbStackItem=%d\n", cbStackItem), VERR_DBGF_STACK_IPE_1);
|
---|
528 | }
|
---|
529 |
|
---|
530 | /* Watcom tries to keep the frame pointer odd for far returns. */
|
---|
531 | if ( cbStackItem <= 4
|
---|
532 | && !(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO))
|
---|
533 | {
|
---|
534 | if (pFrame->AddrReturnFrame.off & 1)
|
---|
535 | {
|
---|
536 | pFrame->AddrReturnFrame.off &= ~(RTGCUINTPTR)1;
|
---|
537 | if (pFrame->enmReturnType == RTDBGRETURNTYPE_NEAR16)
|
---|
538 | {
|
---|
539 | pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN;
|
---|
540 | pFrame->enmReturnType = RTDBGRETURNTYPE_FAR16;
|
---|
541 | cbRetAddr = 4;
|
---|
542 | }
|
---|
543 | else if (pFrame->enmReturnType == RTDBGRETURNTYPE_NEAR32)
|
---|
544 | {
|
---|
545 | pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN;
|
---|
546 | pFrame->enmReturnType = RTDBGRETURNTYPE_FAR32;
|
---|
547 | cbRetAddr = 8;
|
---|
548 | }
|
---|
549 | }
|
---|
550 | else if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN)
|
---|
551 | {
|
---|
552 | if (pFrame->enmReturnType == RTDBGRETURNTYPE_FAR16)
|
---|
553 | {
|
---|
554 | pFrame->enmReturnType = RTDBGRETURNTYPE_NEAR16;
|
---|
555 | cbRetAddr = 2;
|
---|
556 | }
|
---|
557 | else if (pFrame->enmReturnType == RTDBGRETURNTYPE_NEAR32)
|
---|
558 | {
|
---|
559 | pFrame->enmReturnType = RTDBGRETURNTYPE_FAR32;
|
---|
560 | cbRetAddr = 4;
|
---|
561 | }
|
---|
562 | pFrame->fFlags &= ~DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN;
|
---|
563 | }
|
---|
564 | uArgs.pb = u.pb + cbStackItem + cbRetAddr;
|
---|
565 | }
|
---|
566 |
|
---|
567 | pFrame->AddrReturnFrame.FlatPtr += pFrame->AddrReturnFrame.off - pFrame->AddrFrame.off;
|
---|
568 | }
|
---|
569 |
|
---|
570 | /*
|
---|
571 | * Return Stack Address.
|
---|
572 | */
|
---|
573 | pFrame->AddrReturnStack = pFrame->AddrReturnFrame;
|
---|
574 | if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
|
---|
575 | {
|
---|
576 | if ( pFrame->enmReturnType == RTDBGRETURNTYPE_IRET32_PRIV
|
---|
577 | || pFrame->enmReturnType == RTDBGRETURNTYPE_IRET64)
|
---|
578 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnStack,
|
---|
579 | pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_SS], pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xSP]);
|
---|
580 | else if (pFrame->enmReturnType == RTDBGRETURNTYPE_IRET32_V86)
|
---|
581 | DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &pFrame->AddrReturnStack,
|
---|
582 | ((uint32_t)pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_SS] << 4)
|
---|
583 | + pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xSP]);
|
---|
584 | else
|
---|
585 | {
|
---|
586 | pFrame->AddrReturnStack.off = pUnwindCtx->m_State.u.x86.auRegs[X86_GREG_xSP];
|
---|
587 | pFrame->AddrReturnStack.FlatPtr += pFrame->AddrReturnStack.off - pFrame->AddrStack.off;
|
---|
588 | }
|
---|
589 | }
|
---|
590 | else
|
---|
591 | {
|
---|
592 | pFrame->AddrReturnStack.off += cbStackItem + cbRetAddr;
|
---|
593 | pFrame->AddrReturnStack.FlatPtr += cbStackItem + cbRetAddr;
|
---|
594 | }
|
---|
595 |
|
---|
596 | /*
|
---|
597 | * Return PC.
|
---|
598 | */
|
---|
599 | pFrame->AddrReturnPC = pFrame->AddrPC;
|
---|
600 | if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
|
---|
601 | {
|
---|
602 | if (RTDbgReturnTypeIsNear(pFrame->enmReturnType))
|
---|
603 | {
|
---|
604 | pFrame->AddrReturnPC.off = pUnwindCtx->m_State.uPc;
|
---|
605 | pFrame->AddrReturnPC.FlatPtr += pFrame->AddrReturnPC.off - pFrame->AddrPC.off;
|
---|
606 | }
|
---|
607 | else
|
---|
608 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC,
|
---|
609 | pUnwindCtx->m_State.u.x86.auSegs[X86_SREG_CS], pUnwindCtx->m_State.uPc);
|
---|
610 | }
|
---|
611 | else
|
---|
612 | switch (pFrame->enmReturnType)
|
---|
613 | {
|
---|
614 | case RTDBGRETURNTYPE_NEAR16:
|
---|
615 | if (DBGFADDRESS_IS_VALID(&pFrame->AddrReturnPC))
|
---|
616 | {
|
---|
617 | pFrame->AddrReturnPC.FlatPtr += *uRet.pu16 - pFrame->AddrReturnPC.off;
|
---|
618 | pFrame->AddrReturnPC.off = *uRet.pu16;
|
---|
619 | }
|
---|
620 | else
|
---|
621 | DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &pFrame->AddrReturnPC, *uRet.pu16);
|
---|
622 | break;
|
---|
623 | case RTDBGRETURNTYPE_NEAR32:
|
---|
624 | if (DBGFADDRESS_IS_VALID(&pFrame->AddrReturnPC))
|
---|
625 | {
|
---|
626 | pFrame->AddrReturnPC.FlatPtr += *uRet.pu32 - pFrame->AddrReturnPC.off;
|
---|
627 | pFrame->AddrReturnPC.off = *uRet.pu32;
|
---|
628 | }
|
---|
629 | else
|
---|
630 | DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &pFrame->AddrReturnPC, *uRet.pu32);
|
---|
631 | break;
|
---|
632 | case RTDBGRETURNTYPE_NEAR64:
|
---|
633 | if (DBGFADDRESS_IS_VALID(&pFrame->AddrReturnPC))
|
---|
634 | {
|
---|
635 | pFrame->AddrReturnPC.FlatPtr += *uRet.pu64 - pFrame->AddrReturnPC.off;
|
---|
636 | pFrame->AddrReturnPC.off = *uRet.pu64;
|
---|
637 | }
|
---|
638 | else
|
---|
639 | DBGFR3AddrFromFlat(pUnwindCtx->m_pUVM, &pFrame->AddrReturnPC, *uRet.pu64);
|
---|
640 | break;
|
---|
641 | case RTDBGRETURNTYPE_FAR16:
|
---|
642 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[1], uRet.pu16[0]);
|
---|
643 | break;
|
---|
644 | case RTDBGRETURNTYPE_FAR32:
|
---|
645 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[2], uRet.pu32[0]);
|
---|
646 | break;
|
---|
647 | case RTDBGRETURNTYPE_FAR64:
|
---|
648 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[4], uRet.pu64[0]);
|
---|
649 | break;
|
---|
650 | case RTDBGRETURNTYPE_IRET16:
|
---|
651 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[1], uRet.pu16[0]);
|
---|
652 | break;
|
---|
653 | case RTDBGRETURNTYPE_IRET32:
|
---|
654 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[2], uRet.pu32[0]);
|
---|
655 | break;
|
---|
656 | case RTDBGRETURNTYPE_IRET32_PRIV:
|
---|
657 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[2], uRet.pu32[0]);
|
---|
658 | break;
|
---|
659 | case RTDBGRETURNTYPE_IRET32_V86:
|
---|
660 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[2], uRet.pu32[0]);
|
---|
661 | break;
|
---|
662 | case RTDBGRETURNTYPE_IRET64:
|
---|
663 | DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &pFrame->AddrReturnPC, uRet.pu16[4], uRet.pu64[0]);
|
---|
664 | break;
|
---|
665 | default:
|
---|
666 | AssertMsgFailed(("enmReturnType=%d\n", pFrame->enmReturnType));
|
---|
667 | return VERR_INVALID_PARAMETER;
|
---|
668 | }
|
---|
669 |
|
---|
670 |
|
---|
671 | pFrame->pSymReturnPC = DBGFR3AsSymbolByAddrA(pUnwindCtx->m_pUVM, pUnwindCtx->m_hAs, &pFrame->AddrReturnPC,
|
---|
672 | RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL | RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED,
|
---|
673 | NULL /*poffDisp*/, NULL /*phMod*/);
|
---|
674 | pFrame->pLineReturnPC = DBGFR3AsLineByAddrA(pUnwindCtx->m_pUVM, pUnwindCtx->m_hAs, &pFrame->AddrReturnPC,
|
---|
675 | NULL /*poffDisp*/, NULL /*phMod*/);
|
---|
676 |
|
---|
677 | /*
|
---|
678 | * Frame bitness flag.
|
---|
679 | */
|
---|
680 | /** @todo use previous return type for this? */
|
---|
681 | pFrame->fFlags &= ~(DBGFSTACKFRAME_FLAGS_16BIT | DBGFSTACKFRAME_FLAGS_32BIT | DBGFSTACKFRAME_FLAGS_64BIT);
|
---|
682 | switch (cbStackItem)
|
---|
683 | {
|
---|
684 | case 2: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_16BIT; break;
|
---|
685 | case 4: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_32BIT; break;
|
---|
686 | case 8: pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_64BIT; break;
|
---|
687 | default: AssertMsgFailedReturn(("cbStackItem=%d\n", cbStackItem), VERR_DBGF_STACK_IPE_2);
|
---|
688 | }
|
---|
689 |
|
---|
690 | /*
|
---|
691 | * The arguments.
|
---|
692 | */
|
---|
693 | memcpy(&pFrame->Args, uArgs.pv, sizeof(pFrame->Args));
|
---|
694 |
|
---|
695 | /*
|
---|
696 | * Collect register changes.
|
---|
697 | * Then call the OS layer to assist us (e.g. NT trap frames).
|
---|
698 | */
|
---|
699 | if (pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO)
|
---|
700 | {
|
---|
701 | rc = dbgfR3StackWalkCollectRegisterChanges(pUnwindCtx->m_pUVM, pFrame, &pUnwindCtx->m_State);
|
---|
702 | if (RT_FAILURE(rc))
|
---|
703 | return rc;
|
---|
704 |
|
---|
705 | if ( pUnwindCtx->m_pInitialCtx
|
---|
706 | && pUnwindCtx->m_hAs != NIL_RTDBGAS)
|
---|
707 | {
|
---|
708 | rc = dbgfR3OSStackUnwindAssist(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, pFrame, &pUnwindCtx->m_State,
|
---|
709 | pUnwindCtx->m_pInitialCtx, pUnwindCtx->m_hAs, &pUnwindCtx->m_uOsScratch);
|
---|
710 | if (RT_FAILURE(rc))
|
---|
711 | return rc;
|
---|
712 | }
|
---|
713 | }
|
---|
714 |
|
---|
715 | /*
|
---|
716 | * Try use unwind information to locate the return frame pointer (for the
|
---|
717 | * next loop iteration).
|
---|
718 | */
|
---|
719 | Assert(!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET));
|
---|
720 | pFrame->enmReturnFrameReturnType = RTDBGRETURNTYPE_INVALID;
|
---|
721 | if (!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_LAST))
|
---|
722 | {
|
---|
723 | /* Set PC and SP if we didn't unwind our way here (context will then point
|
---|
724 | and the return PC and SP already). */
|
---|
725 | if (!(pFrame->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO))
|
---|
726 | {
|
---|
727 | dbgfR3UnwindCtxSetPcAndSp(pUnwindCtx, &pFrame->AddrReturnPC, &pFrame->AddrReturnStack);
|
---|
728 | }
|
---|
729 | /** @todo Reevaluate CS if the previous frame return type isn't near. */
|
---|
730 | if ( pUnwindCtx->m_State.enmArch == RTLDRARCH_AMD64
|
---|
731 | || pUnwindCtx->m_State.enmArch == RTLDRARCH_X86_32
|
---|
732 | || pUnwindCtx->m_State.enmArch == RTLDRARCH_X86_16)
|
---|
733 | pUnwindCtx->m_State.u.x86.Loaded.fAll = 0;
|
---|
734 | else
|
---|
735 | AssertFailed();
|
---|
736 | if (dbgfR3UnwindCtxDoOneFrame(pUnwindCtx))
|
---|
737 | {
|
---|
738 | if (pUnwindCtx->m_fIsHostRing0)
|
---|
739 | DBGFR3AddrFromHostR0(&pFrame->AddrReturnFrame, pUnwindCtx->m_State.u.x86.FrameAddr.off);
|
---|
740 | else
|
---|
741 | {
|
---|
742 | DBGFADDRESS AddrReturnFrame = pFrame->AddrReturnFrame;
|
---|
743 | rc = DBGFR3AddrFromSelOff(pUnwindCtx->m_pUVM, pUnwindCtx->m_idCpu, &AddrReturnFrame,
|
---|
744 | pUnwindCtx->m_State.u.x86.FrameAddr.sel, pUnwindCtx->m_State.u.x86.FrameAddr.off);
|
---|
745 | if (RT_SUCCESS(rc))
|
---|
746 | pFrame->AddrReturnFrame = AddrReturnFrame;
|
---|
747 | }
|
---|
748 | pFrame->enmReturnFrameReturnType = pUnwindCtx->m_State.enmRetType;
|
---|
749 | pFrame->fFlags |= DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET;
|
---|
750 | }
|
---|
751 | }
|
---|
752 |
|
---|
753 | return VINF_SUCCESS;
|
---|
754 | }
|
---|
755 |
|
---|
756 |
|
---|
757 | /**
|
---|
758 | * Walks the entire stack allocating memory as we walk.
|
---|
759 | */
|
---|
760 | static DECLCALLBACK(int) dbgfR3StackWalkCtxFull(PUVM pUVM, VMCPUID idCpu, PCCPUMCTX pCtx, RTDBGAS hAs,
|
---|
761 | DBGFCODETYPE enmCodeType,
|
---|
762 | PCDBGFADDRESS pAddrFrame,
|
---|
763 | PCDBGFADDRESS pAddrStack,
|
---|
764 | PCDBGFADDRESS pAddrPC,
|
---|
765 | RTDBGRETURNTYPE enmReturnType,
|
---|
766 | PCDBGFSTACKFRAME *ppFirstFrame)
|
---|
767 | {
|
---|
768 | DBGFUNWINDCTX UnwindCtx(pUVM, idCpu, pCtx, hAs);
|
---|
769 |
|
---|
770 | /* alloc first frame. */
|
---|
771 | PDBGFSTACKFRAME pCur = (PDBGFSTACKFRAME)MMR3HeapAllocZU(pUVM, MM_TAG_DBGF_STACK, sizeof(*pCur));
|
---|
772 | if (!pCur)
|
---|
773 | return VERR_NO_MEMORY;
|
---|
774 |
|
---|
775 | /*
|
---|
776 | * Initialize the frame.
|
---|
777 | */
|
---|
778 | pCur->pNextInternal = NULL;
|
---|
779 | pCur->pFirstInternal = pCur;
|
---|
780 |
|
---|
781 | int rc = VINF_SUCCESS;
|
---|
782 | if (pAddrPC)
|
---|
783 | pCur->AddrPC = *pAddrPC;
|
---|
784 | else if (enmCodeType != DBGFCODETYPE_GUEST)
|
---|
785 | DBGFR3AddrFromFlat(pUVM, &pCur->AddrPC, pCtx->rip);
|
---|
786 | else
|
---|
787 | rc = DBGFR3AddrFromSelOff(pUVM, idCpu, &pCur->AddrPC, pCtx->cs.Sel, pCtx->rip);
|
---|
788 | if (RT_SUCCESS(rc))
|
---|
789 | {
|
---|
790 | uint64_t fAddrMask;
|
---|
791 | if (enmCodeType == DBGFCODETYPE_RING0)
|
---|
792 | fAddrMask = HC_ARCH_BITS == 64 ? UINT64_MAX : UINT32_MAX;
|
---|
793 | else if (enmCodeType == DBGFCODETYPE_HYPER)
|
---|
794 | fAddrMask = UINT32_MAX;
|
---|
795 | else if (DBGFADDRESS_IS_FAR16(&pCur->AddrPC))
|
---|
796 | fAddrMask = UINT16_MAX;
|
---|
797 | else if (DBGFADDRESS_IS_FAR32(&pCur->AddrPC))
|
---|
798 | fAddrMask = UINT32_MAX;
|
---|
799 | else if (DBGFADDRESS_IS_FAR64(&pCur->AddrPC))
|
---|
800 | fAddrMask = UINT64_MAX;
|
---|
801 | else
|
---|
802 | {
|
---|
803 | PVMCPU pVCpu = VMMGetCpuById(pUVM->pVM, idCpu);
|
---|
804 | CPUMMODE enmCpuMode = CPUMGetGuestMode(pVCpu);
|
---|
805 | if (enmCpuMode == CPUMMODE_REAL)
|
---|
806 | {
|
---|
807 | fAddrMask = UINT16_MAX;
|
---|
808 | if (enmReturnType == RTDBGRETURNTYPE_INVALID)
|
---|
809 | pCur->enmReturnType = RTDBGRETURNTYPE_NEAR16;
|
---|
810 | }
|
---|
811 | else if ( enmCpuMode == CPUMMODE_PROTECTED
|
---|
812 | || !CPUMIsGuestIn64BitCode(pVCpu))
|
---|
813 | {
|
---|
814 | fAddrMask = UINT32_MAX;
|
---|
815 | if (enmReturnType == RTDBGRETURNTYPE_INVALID)
|
---|
816 | pCur->enmReturnType = RTDBGRETURNTYPE_NEAR32;
|
---|
817 | }
|
---|
818 | else
|
---|
819 | {
|
---|
820 | fAddrMask = UINT64_MAX;
|
---|
821 | if (enmReturnType == RTDBGRETURNTYPE_INVALID)
|
---|
822 | pCur->enmReturnType = RTDBGRETURNTYPE_NEAR64;
|
---|
823 | }
|
---|
824 | }
|
---|
825 |
|
---|
826 | if (enmReturnType == RTDBGRETURNTYPE_INVALID)
|
---|
827 | switch (pCur->AddrPC.fFlags & DBGFADDRESS_FLAGS_TYPE_MASK)
|
---|
828 | {
|
---|
829 | case DBGFADDRESS_FLAGS_FAR16: pCur->enmReturnType = RTDBGRETURNTYPE_NEAR16; break;
|
---|
830 | case DBGFADDRESS_FLAGS_FAR32: pCur->enmReturnType = RTDBGRETURNTYPE_NEAR32; break;
|
---|
831 | case DBGFADDRESS_FLAGS_FAR64: pCur->enmReturnType = RTDBGRETURNTYPE_NEAR64; break;
|
---|
832 | case DBGFADDRESS_FLAGS_RING0:
|
---|
833 | pCur->enmReturnType = HC_ARCH_BITS == 64 ? RTDBGRETURNTYPE_NEAR64 : RTDBGRETURNTYPE_NEAR32;
|
---|
834 | break;
|
---|
835 | default:
|
---|
836 | pCur->enmReturnType = RTDBGRETURNTYPE_NEAR32;
|
---|
837 | break;
|
---|
838 | }
|
---|
839 |
|
---|
840 |
|
---|
841 | if (pAddrStack)
|
---|
842 | pCur->AddrStack = *pAddrStack;
|
---|
843 | else if (enmCodeType != DBGFCODETYPE_GUEST)
|
---|
844 | DBGFR3AddrFromFlat(pUVM, &pCur->AddrStack, pCtx->rsp & fAddrMask);
|
---|
845 | else
|
---|
846 | rc = DBGFR3AddrFromSelOff(pUVM, idCpu, &pCur->AddrStack, pCtx->ss.Sel, pCtx->rsp & fAddrMask);
|
---|
847 |
|
---|
848 | Assert(!(pCur->fFlags & DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO));
|
---|
849 | if (pAddrFrame)
|
---|
850 | pCur->AddrFrame = *pAddrFrame;
|
---|
851 | else if (enmCodeType != DBGFCODETYPE_GUEST)
|
---|
852 | DBGFR3AddrFromFlat(pUVM, &pCur->AddrFrame, pCtx->rbp & fAddrMask);
|
---|
853 | else if (RT_SUCCESS(rc))
|
---|
854 | rc = DBGFR3AddrFromSelOff(pUVM, idCpu, &pCur->AddrFrame, pCtx->ss.Sel, pCtx->rbp & fAddrMask);
|
---|
855 |
|
---|
856 | /*
|
---|
857 | * Try unwind and get a better frame pointer and state.
|
---|
858 | */
|
---|
859 | if ( RT_SUCCESS(rc)
|
---|
860 | && dbgfR3UnwindCtxSetPcAndSp(&UnwindCtx, &pCur->AddrPC, &pCur->AddrStack)
|
---|
861 | && dbgfR3UnwindCtxDoOneFrame(&UnwindCtx))
|
---|
862 | {
|
---|
863 | pCur->enmReturnType = UnwindCtx.m_State.enmRetType;
|
---|
864 | pCur->fFlags |= DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO;
|
---|
865 | if (!UnwindCtx.m_fIsHostRing0)
|
---|
866 | rc = DBGFR3AddrFromSelOff(UnwindCtx.m_pUVM, UnwindCtx.m_idCpu, &pCur->AddrFrame,
|
---|
867 | UnwindCtx.m_State.u.x86.FrameAddr.sel, UnwindCtx.m_State.u.x86.FrameAddr.off);
|
---|
868 | else
|
---|
869 | DBGFR3AddrFromHostR0(&pCur->AddrFrame, UnwindCtx.m_State.u.x86.FrameAddr.off);
|
---|
870 | }
|
---|
871 | /*
|
---|
872 | * The first frame.
|
---|
873 | */
|
---|
874 | if (RT_SUCCESS(rc))
|
---|
875 | {
|
---|
876 | if (DBGFADDRESS_IS_VALID(&pCur->AddrPC))
|
---|
877 | {
|
---|
878 | pCur->pSymPC = DBGFR3AsSymbolByAddrA(pUVM, hAs, &pCur->AddrPC,
|
---|
879 | RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL | RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED,
|
---|
880 | NULL /*poffDisp*/, NULL /*phMod*/);
|
---|
881 | pCur->pLinePC = DBGFR3AsLineByAddrA(pUVM, hAs, &pCur->AddrPC, NULL /*poffDisp*/, NULL /*phMod*/);
|
---|
882 | }
|
---|
883 |
|
---|
884 | rc = dbgfR3StackWalk(&UnwindCtx, pCur, true /*fFirst*/);
|
---|
885 | }
|
---|
886 | }
|
---|
887 | else
|
---|
888 | pCur->enmReturnType = enmReturnType;
|
---|
889 | if (RT_FAILURE(rc))
|
---|
890 | {
|
---|
891 | DBGFR3StackWalkEnd(pCur);
|
---|
892 | return rc;
|
---|
893 | }
|
---|
894 |
|
---|
895 | /*
|
---|
896 | * The other frames.
|
---|
897 | */
|
---|
898 | DBGFSTACKFRAME Next = *pCur;
|
---|
899 | while (!(pCur->fFlags & (DBGFSTACKFRAME_FLAGS_LAST | DBGFSTACKFRAME_FLAGS_MAX_DEPTH | DBGFSTACKFRAME_FLAGS_LOOP)))
|
---|
900 | {
|
---|
901 | Next.cSureRegs = 0;
|
---|
902 | Next.paSureRegs = NULL;
|
---|
903 |
|
---|
904 | /* try walk. */
|
---|
905 | rc = dbgfR3StackWalk(&UnwindCtx, &Next, false /*fFirst*/);
|
---|
906 | if (RT_FAILURE(rc))
|
---|
907 | break;
|
---|
908 |
|
---|
909 | /* add the next frame to the chain. */
|
---|
910 | PDBGFSTACKFRAME pNext = (PDBGFSTACKFRAME)MMR3HeapAllocU(pUVM, MM_TAG_DBGF_STACK, sizeof(*pNext));
|
---|
911 | if (!pNext)
|
---|
912 | {
|
---|
913 | DBGFR3StackWalkEnd(pCur);
|
---|
914 | return VERR_NO_MEMORY;
|
---|
915 | }
|
---|
916 | *pNext = Next;
|
---|
917 | pCur->pNextInternal = pNext;
|
---|
918 | pCur = pNext;
|
---|
919 | Assert(pCur->pNextInternal == NULL);
|
---|
920 |
|
---|
921 | /* check for loop */
|
---|
922 | for (PCDBGFSTACKFRAME pLoop = pCur->pFirstInternal;
|
---|
923 | pLoop && pLoop != pCur;
|
---|
924 | pLoop = pLoop->pNextInternal)
|
---|
925 | if (pLoop->AddrFrame.FlatPtr == pCur->AddrFrame.FlatPtr)
|
---|
926 | {
|
---|
927 | pCur->fFlags |= DBGFSTACKFRAME_FLAGS_LOOP;
|
---|
928 | break;
|
---|
929 | }
|
---|
930 |
|
---|
931 | /* check for insane recursion */
|
---|
932 | if (pCur->iFrame >= 2048)
|
---|
933 | pCur->fFlags |= DBGFSTACKFRAME_FLAGS_MAX_DEPTH;
|
---|
934 | }
|
---|
935 |
|
---|
936 | *ppFirstFrame = pCur->pFirstInternal;
|
---|
937 | return rc;
|
---|
938 | }
|
---|
939 |
|
---|
940 |
|
---|
941 | /**
|
---|
942 | * Common worker for DBGFR3StackWalkBeginGuestEx, DBGFR3StackWalkBeginHyperEx,
|
---|
943 | * DBGFR3StackWalkBeginGuest and DBGFR3StackWalkBeginHyper.
|
---|
944 | */
|
---|
945 | static int dbgfR3StackWalkBeginCommon(PUVM pUVM,
|
---|
946 | VMCPUID idCpu,
|
---|
947 | DBGFCODETYPE enmCodeType,
|
---|
948 | PCDBGFADDRESS pAddrFrame,
|
---|
949 | PCDBGFADDRESS pAddrStack,
|
---|
950 | PCDBGFADDRESS pAddrPC,
|
---|
951 | RTDBGRETURNTYPE enmReturnType,
|
---|
952 | PCDBGFSTACKFRAME *ppFirstFrame)
|
---|
953 | {
|
---|
954 | /*
|
---|
955 | * Validate parameters.
|
---|
956 | */
|
---|
957 | *ppFirstFrame = NULL;
|
---|
958 | UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
|
---|
959 | PVM pVM = pUVM->pVM;
|
---|
960 | VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
|
---|
961 | AssertReturn(idCpu < pVM->cCpus, VERR_INVALID_CPU_ID);
|
---|
962 | if (pAddrFrame)
|
---|
963 | AssertReturn(DBGFR3AddrIsValid(pUVM, pAddrFrame), VERR_INVALID_PARAMETER);
|
---|
964 | if (pAddrStack)
|
---|
965 | AssertReturn(DBGFR3AddrIsValid(pUVM, pAddrStack), VERR_INVALID_PARAMETER);
|
---|
966 | if (pAddrPC)
|
---|
967 | AssertReturn(DBGFR3AddrIsValid(pUVM, pAddrPC), VERR_INVALID_PARAMETER);
|
---|
968 | AssertReturn(enmReturnType >= RTDBGRETURNTYPE_INVALID && enmReturnType < RTDBGRETURNTYPE_END, VERR_INVALID_PARAMETER);
|
---|
969 |
|
---|
970 | /*
|
---|
971 | * Get the CPUM context pointer and pass it on the specified EMT.
|
---|
972 | */
|
---|
973 | RTDBGAS hAs;
|
---|
974 | PCCPUMCTX pCtx;
|
---|
975 | switch (enmCodeType)
|
---|
976 | {
|
---|
977 | case DBGFCODETYPE_GUEST:
|
---|
978 | pCtx = CPUMQueryGuestCtxPtr(VMMGetCpuById(pVM, idCpu));
|
---|
979 | hAs = DBGF_AS_GLOBAL;
|
---|
980 | break;
|
---|
981 | case DBGFCODETYPE_HYPER:
|
---|
982 | pCtx = CPUMQueryGuestCtxPtr(VMMGetCpuById(pVM, idCpu));
|
---|
983 | hAs = DBGF_AS_RC_AND_GC_GLOBAL;
|
---|
984 | break;
|
---|
985 | case DBGFCODETYPE_RING0:
|
---|
986 | pCtx = NULL; /* No valid context present. */
|
---|
987 | hAs = DBGF_AS_R0;
|
---|
988 | break;
|
---|
989 | default:
|
---|
990 | AssertFailedReturn(VERR_INVALID_PARAMETER);
|
---|
991 | }
|
---|
992 | return VMR3ReqPriorityCallWaitU(pUVM, idCpu, (PFNRT)dbgfR3StackWalkCtxFull, 10,
|
---|
993 | pUVM, idCpu, pCtx, hAs, enmCodeType,
|
---|
994 | pAddrFrame, pAddrStack, pAddrPC, enmReturnType, ppFirstFrame);
|
---|
995 | }
|
---|
996 |
|
---|
997 |
|
---|
998 | /**
|
---|
999 | * Begins a guest stack walk, extended version.
|
---|
1000 | *
|
---|
1001 | * This will walk the current stack, constructing a list of info frames which is
|
---|
1002 | * returned to the caller. The caller uses DBGFR3StackWalkNext to traverse the
|
---|
1003 | * list and DBGFR3StackWalkEnd to release it.
|
---|
1004 | *
|
---|
1005 | * @returns VINF_SUCCESS on success.
|
---|
1006 | * @returns VERR_NO_MEMORY if we're out of memory.
|
---|
1007 | *
|
---|
1008 | * @param pUVM The user mode VM handle.
|
---|
1009 | * @param idCpu The ID of the virtual CPU which stack we want to walk.
|
---|
1010 | * @param enmCodeType Code type
|
---|
1011 | * @param pAddrFrame Frame address to start at. (Optional)
|
---|
1012 | * @param pAddrStack Stack address to start at. (Optional)
|
---|
1013 | * @param pAddrPC Program counter to start at. (Optional)
|
---|
1014 | * @param enmReturnType The return address type. (Optional)
|
---|
1015 | * @param ppFirstFrame Where to return the pointer to the first info frame.
|
---|
1016 | */
|
---|
1017 | VMMR3DECL(int) DBGFR3StackWalkBeginEx(PUVM pUVM,
|
---|
1018 | VMCPUID idCpu,
|
---|
1019 | DBGFCODETYPE enmCodeType,
|
---|
1020 | PCDBGFADDRESS pAddrFrame,
|
---|
1021 | PCDBGFADDRESS pAddrStack,
|
---|
1022 | PCDBGFADDRESS pAddrPC,
|
---|
1023 | RTDBGRETURNTYPE enmReturnType,
|
---|
1024 | PCDBGFSTACKFRAME *ppFirstFrame)
|
---|
1025 | {
|
---|
1026 | return dbgfR3StackWalkBeginCommon(pUVM, idCpu, enmCodeType, pAddrFrame, pAddrStack, pAddrPC, enmReturnType, ppFirstFrame);
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 |
|
---|
1030 | /**
|
---|
1031 | * Begins a guest stack walk.
|
---|
1032 | *
|
---|
1033 | * This will walk the current stack, constructing a list of info frames which is
|
---|
1034 | * returned to the caller. The caller uses DBGFR3StackWalkNext to traverse the
|
---|
1035 | * list and DBGFR3StackWalkEnd to release it.
|
---|
1036 | *
|
---|
1037 | * @returns VINF_SUCCESS on success.
|
---|
1038 | * @returns VERR_NO_MEMORY if we're out of memory.
|
---|
1039 | *
|
---|
1040 | * @param pUVM The user mode VM handle.
|
---|
1041 | * @param idCpu The ID of the virtual CPU which stack we want to walk.
|
---|
1042 | * @param enmCodeType Code type
|
---|
1043 | * @param ppFirstFrame Where to return the pointer to the first info frame.
|
---|
1044 | */
|
---|
1045 | VMMR3DECL(int) DBGFR3StackWalkBegin(PUVM pUVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFSTACKFRAME *ppFirstFrame)
|
---|
1046 | {
|
---|
1047 | return dbgfR3StackWalkBeginCommon(pUVM, idCpu, enmCodeType, NULL, NULL, NULL, RTDBGRETURNTYPE_INVALID, ppFirstFrame);
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | /**
|
---|
1051 | * Gets the next stack frame.
|
---|
1052 | *
|
---|
1053 | * @returns Pointer to the info for the next stack frame.
|
---|
1054 | * NULL if no more frames.
|
---|
1055 | *
|
---|
1056 | * @param pCurrent Pointer to the current stack frame.
|
---|
1057 | *
|
---|
1058 | */
|
---|
1059 | VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent)
|
---|
1060 | {
|
---|
1061 | return pCurrent
|
---|
1062 | ? pCurrent->pNextInternal
|
---|
1063 | : NULL;
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 |
|
---|
1067 | /**
|
---|
1068 | * Ends a stack walk process.
|
---|
1069 | *
|
---|
1070 | * This *must* be called after a successful first call to any of the stack
|
---|
1071 | * walker functions. If not called we will leak memory or other resources.
|
---|
1072 | *
|
---|
1073 | * @param pFirstFrame The frame returned by one of the begin functions.
|
---|
1074 | */
|
---|
1075 | VMMR3DECL(void) DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame)
|
---|
1076 | {
|
---|
1077 | if ( !pFirstFrame
|
---|
1078 | || !pFirstFrame->pFirstInternal)
|
---|
1079 | return;
|
---|
1080 |
|
---|
1081 | PDBGFSTACKFRAME pFrame = (PDBGFSTACKFRAME)pFirstFrame->pFirstInternal;
|
---|
1082 | while (pFrame)
|
---|
1083 | {
|
---|
1084 | PDBGFSTACKFRAME pCur = pFrame;
|
---|
1085 | pFrame = (PDBGFSTACKFRAME)pCur->pNextInternal;
|
---|
1086 | if (pFrame)
|
---|
1087 | {
|
---|
1088 | if (pCur->pSymReturnPC == pFrame->pSymPC)
|
---|
1089 | pFrame->pSymPC = NULL;
|
---|
1090 | if (pCur->pSymReturnPC == pFrame->pSymReturnPC)
|
---|
1091 | pFrame->pSymReturnPC = NULL;
|
---|
1092 |
|
---|
1093 | if (pCur->pSymPC == pFrame->pSymPC)
|
---|
1094 | pFrame->pSymPC = NULL;
|
---|
1095 | if (pCur->pSymPC == pFrame->pSymReturnPC)
|
---|
1096 | pFrame->pSymReturnPC = NULL;
|
---|
1097 |
|
---|
1098 | if (pCur->pLineReturnPC == pFrame->pLinePC)
|
---|
1099 | pFrame->pLinePC = NULL;
|
---|
1100 | if (pCur->pLineReturnPC == pFrame->pLineReturnPC)
|
---|
1101 | pFrame->pLineReturnPC = NULL;
|
---|
1102 |
|
---|
1103 | if (pCur->pLinePC == pFrame->pLinePC)
|
---|
1104 | pFrame->pLinePC = NULL;
|
---|
1105 | if (pCur->pLinePC == pFrame->pLineReturnPC)
|
---|
1106 | pFrame->pLineReturnPC = NULL;
|
---|
1107 | }
|
---|
1108 |
|
---|
1109 | RTDbgSymbolFree(pCur->pSymPC);
|
---|
1110 | RTDbgSymbolFree(pCur->pSymReturnPC);
|
---|
1111 | RTDbgLineFree(pCur->pLinePC);
|
---|
1112 | RTDbgLineFree(pCur->pLineReturnPC);
|
---|
1113 |
|
---|
1114 | if (pCur->paSureRegs)
|
---|
1115 | {
|
---|
1116 | MMR3HeapFree(pCur->paSureRegs);
|
---|
1117 | pCur->paSureRegs = NULL;
|
---|
1118 | pCur->cSureRegs = 0;
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | pCur->pNextInternal = NULL;
|
---|
1122 | pCur->pFirstInternal = NULL;
|
---|
1123 | pCur->fFlags = 0;
|
---|
1124 | MMR3HeapFree(pCur);
|
---|
1125 | }
|
---|
1126 | }
|
---|
1127 |
|
---|