1 | /* $Id: bs3-cmn-MemPrintInfo.c 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * BS3Kit - Bs3MemPrintInfo
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2019 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 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #include "bs3kit-template-header.h"
|
---|
32 | #include "bs3-cmn-memory.h"
|
---|
33 | #include <iprt/asm.h>
|
---|
34 |
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Prints a slab control structure with allocation map.
|
---|
38 | *
|
---|
39 | * @param pCtl The slab control structure to print.
|
---|
40 | * @param pszPrefix The output prefix.
|
---|
41 | */
|
---|
42 | static void Bs3MemPrintInfoSlabCtl(PBS3SLABCTL pCtl, const char BS3_FAR *pszPrefix)
|
---|
43 | {
|
---|
44 | unsigned iChunk;
|
---|
45 | Bs3TestPrintf("%s / %#06x: %u of %u chunks free", pszPrefix, pCtl->cbChunk, pCtl->cFreeChunks, pCtl->cChunks);
|
---|
46 | for (iChunk = 0; iChunk < pCtl->cChunks; iChunk++)
|
---|
47 | {
|
---|
48 | if ((iChunk & 63) == 0)
|
---|
49 | Bs3TestPrintf("\n%s:", pszPrefix);
|
---|
50 | if (ASMBitTest(pCtl->bmAllocated, iChunk))
|
---|
51 | Bs3TestPrintf((iChunk & 7) != 0 ? "x" : " x");
|
---|
52 | else
|
---|
53 | Bs3TestPrintf((iChunk & 7) != 0 ? "-" : " -");
|
---|
54 | }
|
---|
55 | Bs3TestPrintf("\n");
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Prints a summary of a slab allocation list (i.e. the heap).
|
---|
62 | *
|
---|
63 | * @param paLists Array of BS3_MEM_SLAB_LIST_COUNT lists.
|
---|
64 | * @param pszPrefix The output prefix.
|
---|
65 | */
|
---|
66 | static void Bs3MemPrintInfoSlabList(PBS3SLABHEAD paLists, const char BS3_FAR *pszPrefix)
|
---|
67 | {
|
---|
68 | unsigned iSlab;
|
---|
69 | for (iSlab = 0; iSlab < BS3_MEM_SLAB_LIST_COUNT; iSlab++)
|
---|
70 | if (paLists[iSlab].cSlabs)
|
---|
71 | Bs3TestPrintf("%s / %#06x: %u slabs, %RU32 of %RU32 chunks free\n",
|
---|
72 | pszPrefix, paLists[iSlab].cbChunk, paLists[iSlab].cSlabs,
|
---|
73 | paLists[iSlab].cFreeChunks, paLists[iSlab].cChunks);
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | #undef Bs3MemPrintInfo
|
---|
78 | BS3_CMN_DEF(void, Bs3MemPrintInfo,(void))
|
---|
79 | {
|
---|
80 | Bs3MemPrintInfoSlabList(g_aBs3LowSlabLists, "Lower");
|
---|
81 | Bs3MemPrintInfoSlabList(g_aBs3LowSlabLists, "Upper");
|
---|
82 | Bs3MemPrintInfoSlabCtl(&g_Bs3Mem4KLow.Core, "4KLow");
|
---|
83 | Bs3MemPrintInfoSlabCtl(&g_Bs3Mem4KUpperTiled.Core, "Tiled");
|
---|
84 | }
|
---|
85 |
|
---|