47 |
47 |
48 |
48 |
49 |
49 |
50 |
50 |
51 |
51 |
52 |
52 DObject* DMemSpyDriverLogChanContainerBase::CheckedOpen(TMemSpyDriverContainerType aContainerType, DObject* aObject, TBool aQuick) |
53 |
53 { |
54 |
54 __ASSERT_CRITICAL; |
55 DObject* DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer( TMemSpyDriverContainerType aContainerType, DObject* aSearchFor, TBool aQuick ) |
55 __ASSERT_DEBUG(aObject != NULL, MemSpyDriverUtils::Fault( __LINE__ )); |
56 { |
56 const TObjectType expectedType = ObjectTypeFromMemSpyContainerType(aContainerType); |
57 __ASSERT_DEBUG( aSearchFor != NULL, MemSpyDriverUtils::Fault( __LINE__ ) ); |
57 |
58 const TObjectType expectedType = ObjectTypeFromMemSpyContainerType( aContainerType ); |
58 // Quick mode means we just check container ids and we trust that the object will exist. |
59 TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - START - aSearchFor: 0x%08x, expectedType: %d", aSearchFor, expectedType )); |
59 // [TomS: not entirely convinced we can ever be certain of that] |
60 |
60 TInt err = KErrNotFound; |
61 DObject* ret = NULL; |
61 if (aQuick) |
62 |
62 { |
63 // Quick mode means we just check container ids and we trust that the object |
63 LOG("quick CheckedOpen of %08x", aObject); |
64 // will exist. |
64 const TObjectType objectType = OSAdaption().DThread().GetObjectType(*aObject); |
65 if ( aQuick ) |
65 if (objectType == expectedType) |
66 { |
66 { |
67 const TObjectType objectType = OSAdaption().DThread().GetObjectType( *aSearchFor ); |
67 err = aObject->Open(); |
68 TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - aSearchFor.iContainerID: %d", objectType ) ); |
|
69 if ( objectType == expectedType ) |
|
70 { |
|
71 ret = aSearchFor; |
|
72 } |
68 } |
73 } |
69 } |
74 else |
70 else |
75 { |
71 { |
76 // Full check to see if the specified object is part of the container |
72 DObjectCon* container = Kern::Containers()[expectedType]; |
77 DObjectCon* container = Kern::Containers()[ expectedType ]; |
|
78 container->Wait(); |
73 container->Wait(); |
79 NKern::LockSystem(); |
|
80 |
|
81 const TInt count = container->Count(); |
74 const TInt count = container->Count(); |
82 for(TInt i=0; i<count; i++) |
75 for (TInt i = 0; i < count; i++) |
83 { |
76 { |
84 DObject* object = (*container)[ i ]; |
77 DObject* object = (*container)[i]; |
85 |
78 if (object == aObject) |
86 // Do the two match? |
|
87 if ( object == aSearchFor ) |
|
88 { |
79 { |
89 TRACE( Kern::Printf(" found match: %O", object)); |
80 err = aObject->Open(); |
90 |
81 break; |
91 ret = object; |
82 } |
92 break; |
83 } |
93 } |
84 container->Signal(); |
94 } |
85 } |
95 |
86 |
96 NKern::UnlockSystem(); |
87 LOG("CheckedOpen(%d, 0x%08x, quick=%d) returned error %d", aContainerType, aObject, aQuick, err); |
97 container->Signal(); |
88 return (err == KErrNone) ? aObject : NULL; |
98 } |
89 } |
99 |
|
100 TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - END - ret: 0x%08x", ret )); |
|
101 TRACE( Kern::Printf(" ") ); |
|
102 return ret; |
|
103 } |
|
104 |
90 |
105 |
91 |
106 |
92 |
107 TObjectType DMemSpyDriverLogChanContainerBase::ObjectTypeFromMemSpyContainerType( TMemSpyDriverContainerType aType ) |
93 TObjectType DMemSpyDriverLogChanContainerBase::ObjectTypeFromMemSpyContainerType( TMemSpyDriverContainerType aType ) |
108 { |
94 { |