2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
29 #include <IOKit/IOKitDebug.h>
30 #include <IOKit/IOLib.h>
31 #include <IOKit/assert.h>
32 #include <IOKit/IODeviceTreeSupport.h>
33 #include <IOKit/IOService.h>
35 #include <libkern/c++/OSContainers.h>
36 #include <libkern/c++/OSCPPDebug.h>
46 int debug_malloc_size
;
47 int debug_iomalloc_size
;
48 int debug_container_malloc_size
;
49 // int debug_ivars_size; // in OSObject.cpp
51 void IOPrintPlane( const IORegistryPlane
* plane
)
53 IORegistryEntry
* next
;
54 IORegistryIterator
* iter
;
56 char format
[] = "%xxxs";
59 iter
= IORegistryIterator::iterateOver( plane
);
61 all
= iter
->iterateAll();
63 IOLog("Count %d\n", all
->getCount() );
69 while( (next
= iter
->getNextObjectRecursive())) {
70 sprintf( format
+ 1, "%ds", next
->getDepth( plane
));
72 if( (service
= OSDynamicCast(IOService
, next
)))
73 IOLog("<%ld>", service
->getBusyState());
74 IOLog( "%s\n", next
->getName());
79 void IOPrintMemory( void )
82 // OSMetaClass::printInstanceCounts();
85 "ivar kalloc() 0x%08x\n"
87 "containers kalloc() 0x%08x\n"
89 "----------------------------------------\n",
92 debug_container_malloc_size
,
99 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
101 #define super OSObject
102 OSDefineMetaClassAndStructors(IOKitDiagnostics
, OSObject
)
104 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
106 OSObject
* IOKitDiagnostics::diagnostics( void )
108 IOKitDiagnostics
* diags
;
110 diags
= new IOKitDiagnostics
;
111 if( diags
&& !diags
->init()) {
119 void IOKitDiagnostics::updateOffset( OSDictionary
* dict
,
120 UInt32 value
, const char * name
)
124 off
= OSNumber::withNumber( value
, 32 );
128 dict
->setObject( name
, off
);
133 bool IOKitDiagnostics::serialize(OSSerialize
*s
) const
138 dict
= OSDictionary::withCapacity( 5 );
142 updateOffset( dict
, debug_ivars_size
, "Instance allocation" );
143 updateOffset( dict
, debug_container_malloc_size
, "Container allocation" );
144 updateOffset( dict
, debug_iomalloc_size
, "IOMalloc allocation" );
146 dict
->setObject( "Classes", OSMetaClass::getClassDictionary() );
148 ok
= dict
->serialize( s
);
155 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */