perfsrv/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectThreadInfoObjects.cpp
author hgs
Tue, 26 Oct 2010 16:20:32 +0300
changeset 62 1c2bb2fc7c87
parent 51 98307c651589
permissions -rw-r--r--
201043
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
// System includes
hgs
parents:
diff changeset
    21
#include <f32file.h>
hgs
parents:
diff changeset
    22
#include <hal.h>
hgs
parents:
diff changeset
    23
#include <kernel/arm/arm_types.h>
hgs
parents:
diff changeset
    24
#include <memspy/driver/memspydriverclient.h>
hgs
parents:
diff changeset
    25
#include <memspy/engine/memspyengine.h>
hgs
parents:
diff changeset
    26
#include <memspy/engine/memspyengineutils.h>
hgs
parents:
diff changeset
    27
#include <memspy/engine/memspyengineoutputlist.h>
hgs
parents:
diff changeset
    28
#include <memspy/engine/memspyenginehelpercodesegment.h>
hgs
parents:
diff changeset
    29
#include <memspy/engine/memspyenginehelperactiveobject.h>
hgs
parents:
diff changeset
    30
#include <memspy/engine/memspyenginehelperchunk.h>
hgs
parents:
diff changeset
    31
#include <memspy/engine/memspyenginehelperheap.h>
hgs
parents:
diff changeset
    32
#include <memspy/engine/memspyenginehelperprocess.h>
hgs
parents:
diff changeset
    33
#include <memspy/engine/memspyengineobjectprocess.h>
hgs
parents:
diff changeset
    34
#include <memspy/engine/memspyengineobjectthread.h>
hgs
parents:
diff changeset
    35
#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
hgs
parents:
diff changeset
    36
#include <memspy/engine/memspyengineoutputsink.h>
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
// User includes
hgs
parents:
diff changeset
    39
#include "MemSpyEngineOutputListItem.h"
hgs
parents:
diff changeset
    40
hgs
parents:
diff changeset
    41
// Constants
hgs
parents:
diff changeset
    42
const TInt KMemSpyNumericFormatBufferSize = 20;
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
// Literal constants
hgs
parents:
diff changeset
    45
_LIT( KMemSpyNumericHexFormat, "0x%08x" );
hgs
parents:
diff changeset
    46
_LIT( KMemSpyNumericDecFormat, "%d" );
hgs
parents:
diff changeset
    47
_LIT( KMemSpyNumericLongFormat, "%Ld" );
hgs
parents:
diff changeset
    48
_LIT( KMemSpyCaptionYes, "Yes" );
hgs
parents:
diff changeset
    49
_LIT( KMemSpyCaptionNo, "No" );
hgs
parents:
diff changeset
    50
_LIT( KMemSpyCaptionOn, "On" );
hgs
parents:
diff changeset
    51
_LIT( KMemSpyCaptionOff, "Off" );
hgs
parents:
diff changeset
    52
_LIT( KMemSpyUnavailable, "Unavailable" );
hgs
parents:
diff changeset
    53
_LIT( KMemSpyDead, "Dead" );
hgs
parents:
diff changeset
    54
_LIT( KMemSpyNoItems, "(No items)" );
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
CMemSpyThreadInfoItemBase::CMemSpyThreadInfoItemBase( CMemSpyThreadInfoContainer& aContainer, TMemSpyThreadInfoItemType aType, TBool aAsyncConstruction )
hgs
parents:
diff changeset
    59
:   CMemSpyEngineObject( aContainer ), iContainer( aContainer ), iCallBack( CActive::EPriorityLow ), iType( aType )
hgs
parents:
diff changeset
    60
    {
hgs
parents:
diff changeset
    61
    if  ( aAsyncConstruction )
hgs
parents:
diff changeset
    62
        {
hgs
parents:
diff changeset
    63
        TCallBack callBackMethod( CallConstructL, this );
hgs
parents:
diff changeset
    64
        iCallBack.Set( callBackMethod );
hgs
parents:
diff changeset
    65
        iCallBack.CallBack();
hgs
parents:
diff changeset
    66
        }
hgs
parents:
diff changeset
    67
    }
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
hgs
parents:
diff changeset
    70
CMemSpyThreadInfoItemBase::~CMemSpyThreadInfoItemBase()
hgs
parents:
diff changeset
    71
    {
hgs
parents:
diff changeset
    72
    TRAP_IGNORE( iContainer.NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemDestroyed, iType ) );
hgs
parents:
diff changeset
    73
    //
hgs
parents:
diff changeset
    74
    iItems.ResetAndDestroy();
hgs
parents:
diff changeset
    75
    iItems.Close();
hgs
parents:
diff changeset
    76
    }
hgs
parents:
diff changeset
    77
hgs
parents:
diff changeset
    78
hgs
parents:
diff changeset
    79
TInt CMemSpyThreadInfoItemBase::CallConstructL( TAny* aSelf )
hgs
parents:
diff changeset
    80
    {
hgs
parents:
diff changeset
    81
    CMemSpyThreadInfoItemBase* self = reinterpret_cast< CMemSpyThreadInfoItemBase* >( aSelf );
hgs
parents:
diff changeset
    82
    self->iReady = EFalse;
hgs
parents:
diff changeset
    83
    
hgs
parents:
diff changeset
    84
    // Don't try to refresh dead thread
hgs
parents:
diff changeset
    85
    TInt err = KErrNone;
hgs
parents:
diff changeset
    86
    if ( !self->Container().Thread().IsDead() )
hgs
parents:
diff changeset
    87
        {
hgs
parents:
diff changeset
    88
        TRAP(err, self->ConstructL());
hgs
parents:
diff changeset
    89
        if  ( err != KErrNone )
hgs
parents:
diff changeset
    90
            {
hgs
parents:
diff changeset
    91
    #ifdef _DEBUG
hgs
parents:
diff changeset
    92
            RDebug::Printf( "CMemSpyThreadInfoItemBase::CallConstructL() - construction err: %d, iType: %d", err, self->iType );
hgs
parents:
diff changeset
    93
    #endif
hgs
parents:
diff changeset
    94
            self->AddItemL( KMemSpyUnavailable, KNullDesC );
hgs
parents:
diff changeset
    95
            self->iIsEmpty = ETrue;
hgs
parents:
diff changeset
    96
            }
hgs
parents:
diff changeset
    97
        else if ( self->MdcaCount() == 0 )
hgs
parents:
diff changeset
    98
            {
hgs
parents:
diff changeset
    99
            self->AddItemL( KMemSpyNoItems, KNullDesC );
hgs
parents:
diff changeset
   100
            self->iIsEmpty = ETrue;
hgs
parents:
diff changeset
   101
            }        
hgs
parents:
diff changeset
   102
        }
hgs
parents:
diff changeset
   103
    else
hgs
parents:
diff changeset
   104
        {
hgs
parents:
diff changeset
   105
        self->AddItemL( KMemSpyDead, KNullDesC );
hgs
parents:
diff changeset
   106
        self->iIsEmpty = ETrue;
hgs
parents:
diff changeset
   107
        }
hgs
parents:
diff changeset
   108
    //
hgs
parents:
diff changeset
   109
    self->iReady = ETrue;
hgs
parents:
diff changeset
   110
    return KErrNone;
hgs
parents:
diff changeset
   111
    }
hgs
parents:
diff changeset
   112
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
EXPORT_C TInt CMemSpyThreadInfoItemBase::MdcaCount() const
hgs
parents:
diff changeset
   115
    {
hgs
parents:
diff changeset
   116
    return iItems.Count();
hgs
parents:
diff changeset
   117
    }
hgs
parents:
diff changeset
   118
hgs
parents:
diff changeset
   119
hgs
parents:
diff changeset
   120
EXPORT_C TPtrC CMemSpyThreadInfoItemBase::MdcaPoint( TInt aIndex ) const
hgs
parents:
diff changeset
   121
    {
hgs
parents:
diff changeset
   122
    CItem* item = iItems[ aIndex ];
hgs
parents:
diff changeset
   123
    return TPtrC( item->Combined() );
hgs
parents:
diff changeset
   124
    }
hgs
parents:
diff changeset
   125
hgs
parents:
diff changeset
   126
EXPORT_C TPtrC CMemSpyThreadInfoItemBase::Caption(TInt aIndex ) const
hgs
parents:
diff changeset
   127
	{
hgs
parents:
diff changeset
   128
	CItem* item = iItems[ aIndex ];
hgs
parents:
diff changeset
   129
	return TPtrC( item->Caption() );
hgs
parents:
diff changeset
   130
	}
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
EXPORT_C TPtrC CMemSpyThreadInfoItemBase::Value(TInt aIndex ) const
hgs
parents:
diff changeset
   133
	{
hgs
parents:
diff changeset
   134
	CItem* item = iItems[ aIndex ];
hgs
parents:
diff changeset
   135
	return TPtrC( item->Value() );
hgs
parents:
diff changeset
   136
	}
hgs
parents:
diff changeset
   137
hgs
parents:
diff changeset
   138
EXPORT_C CMemSpyEngine& CMemSpyThreadInfoItemBase::Engine() const
hgs
parents:
diff changeset
   139
    {
hgs
parents:
diff changeset
   140
    return iContainer.Engine();
hgs
parents:
diff changeset
   141
    }
hgs
parents:
diff changeset
   142
hgs
parents:
diff changeset
   143
hgs
parents:
diff changeset
   144
EXPORT_C void CMemSpyThreadInfoItemBase::PrintL()
hgs
parents:
diff changeset
   145
    {
hgs
parents:
diff changeset
   146
    const TInt count = iItems.Count();
hgs
parents:
diff changeset
   147
    if  ( count > 0 && !iIsEmpty )
hgs
parents:
diff changeset
   148
        {
hgs
parents:
diff changeset
   149
        CMemSpyEngine& engine = Engine();
hgs
parents:
diff changeset
   150
        CMemSpyEngineOutputSink& sink = engine.Sink();
hgs
parents:
diff changeset
   151
hgs
parents:
diff changeset
   152
        HBufC* name = MemSpyEngineUtils::CleanupTextLC( Name() );
hgs
parents:
diff changeset
   153
        sink.OutputSectionHeadingL( *name, TChar('-') );
hgs
parents:
diff changeset
   154
        CleanupStack::PopAndDestroy( name );
hgs
parents:
diff changeset
   155
        sink.OutputPrefixSetLC( _L("  ") ); // Slight insertion
hgs
parents:
diff changeset
   156
hgs
parents:
diff changeset
   157
        // First pass to get max lengths
hgs
parents:
diff changeset
   158
        TInt maxLengthCaption = 0;
hgs
parents:
diff changeset
   159
        TInt maxLengthValue = 0;
hgs
parents:
diff changeset
   160
hgs
parents:
diff changeset
   161
        for( TInt j=0; j<count; j++ )
hgs
parents:
diff changeset
   162
            {
hgs
parents:
diff changeset
   163
            const CItem* item = iItems[ j ];
hgs
parents:
diff changeset
   164
            maxLengthCaption = Max( maxLengthCaption, item->Caption().Length() );
hgs
parents:
diff changeset
   165
            maxLengthValue = Max( maxLengthValue, item->Value().Length() );
hgs
parents:
diff changeset
   166
            }
hgs
parents:
diff changeset
   167
hgs
parents:
diff changeset
   168
        // Second pass - real this time - to print the values
hgs
parents:
diff changeset
   169
        HBufC* line = HBufC::NewLC( ( maxLengthCaption + maxLengthValue ) + 20 );
hgs
parents:
diff changeset
   170
        TPtr pLine( line->Des() );
hgs
parents:
diff changeset
   171
        //
hgs
parents:
diff changeset
   172
        for( TInt i=0; i<count; i++ )
hgs
parents:
diff changeset
   173
            {
hgs
parents:
diff changeset
   174
            const CItem* item = iItems[ i ];
hgs
parents:
diff changeset
   175
hgs
parents:
diff changeset
   176
            // Remove initial tabs in caption
hgs
parents:
diff changeset
   177
            HBufC* caption = MemSpyEngineUtils::CleanupTextLC( item->Caption() );
hgs
parents:
diff changeset
   178
        
hgs
parents:
diff changeset
   179
            // Create value item & replace any further tabs
hgs
parents:
diff changeset
   180
            HBufC* value = MemSpyEngineUtils::CleanupTextLC( item->Value() );
hgs
parents:
diff changeset
   181
hgs
parents:
diff changeset
   182
            // Now format the final line, with padding.
hgs
parents:
diff changeset
   183
            pLine.Justify( *caption, maxLengthCaption + 3, ELeft, TChar(' ') );
hgs
parents:
diff changeset
   184
            pLine.Append( *value );
hgs
parents:
diff changeset
   185
            CleanupStack::PopAndDestroy( 2, caption );
hgs
parents:
diff changeset
   186
hgs
parents:
diff changeset
   187
            // Sink output
hgs
parents:
diff changeset
   188
            sink.OutputLineL( pLine );
hgs
parents:
diff changeset
   189
            }
hgs
parents:
diff changeset
   190
        //
hgs
parents:
diff changeset
   191
        CleanupStack::PopAndDestroy( line );
hgs
parents:
diff changeset
   192
        sink.OutputBlankLineL();
hgs
parents:
diff changeset
   193
        CleanupStack::PopAndDestroy(); // clear prefix
hgs
parents:
diff changeset
   194
        }
hgs
parents:
diff changeset
   195
    }
hgs
parents:
diff changeset
   196
hgs
parents:
diff changeset
   197
hgs
parents:
diff changeset
   198
hgs
parents:
diff changeset
   199
void CMemSpyThreadInfoItemBase::AddItemL( const TDesC& aCaption, const TDesC& aValue )
hgs
parents:
diff changeset
   200
    {
hgs
parents:
diff changeset
   201
    CItem* item = CItem::NewLC( aCaption, aValue );
hgs
parents:
diff changeset
   202
    iItems.AppendL( item );
hgs
parents:
diff changeset
   203
    CleanupStack::Pop( item );
hgs
parents:
diff changeset
   204
    }
hgs
parents:
diff changeset
   205
hgs
parents:
diff changeset
   206
hgs
parents:
diff changeset
   207
void CMemSpyThreadInfoItemBase::AddItemHexL( const TDesC& aCaption, TUint aValue )
hgs
parents:
diff changeset
   208
    {
hgs
parents:
diff changeset
   209
    TBuf<KMemSpyNumericFormatBufferSize> val;
hgs
parents:
diff changeset
   210
    val.Format( KMemSpyNumericHexFormat, aValue );
hgs
parents:
diff changeset
   211
    AddItemL( aCaption, val );
hgs
parents:
diff changeset
   212
    }
hgs
parents:
diff changeset
   213
hgs
parents:
diff changeset
   214
hgs
parents:
diff changeset
   215
void CMemSpyThreadInfoItemBase::AddItemDecimalL( const TDesC& aCaption, TInt aValue )
hgs
parents:
diff changeset
   216
    {
hgs
parents:
diff changeset
   217
    TBuf<KMemSpyNumericFormatBufferSize> val;
hgs
parents:
diff changeset
   218
    val.Format( KMemSpyNumericDecFormat, aValue );
hgs
parents:
diff changeset
   219
    AddItemL( aCaption, val );
hgs
parents:
diff changeset
   220
    }
hgs
parents:
diff changeset
   221
hgs
parents:
diff changeset
   222
hgs
parents:
diff changeset
   223
void CMemSpyThreadInfoItemBase::AddItemLongL( const TDesC& aCaption, const TInt64& aValue )
hgs
parents:
diff changeset
   224
    {
hgs
parents:
diff changeset
   225
    TBuf<KMemSpyNumericFormatBufferSize> val;
hgs
parents:
diff changeset
   226
    val.Format( KMemSpyNumericLongFormat, aValue );
hgs
parents:
diff changeset
   227
    AddItemL( aCaption, val );
hgs
parents:
diff changeset
   228
    }
hgs
parents:
diff changeset
   229
hgs
parents:
diff changeset
   230
hgs
parents:
diff changeset
   231
void CMemSpyThreadInfoItemBase::AddItemYesNoL( const TDesC& aCaption, TBool aYes )
hgs
parents:
diff changeset
   232
    {
hgs
parents:
diff changeset
   233
    CItem* item = CItem::NewYesNoLC( aCaption, aYes );
hgs
parents:
diff changeset
   234
    iItems.AppendL( item );
hgs
parents:
diff changeset
   235
    CleanupStack::Pop( item );
hgs
parents:
diff changeset
   236
    }
hgs
parents:
diff changeset
   237
hgs
parents:
diff changeset
   238
hgs
parents:
diff changeset
   239
void CMemSpyThreadInfoItemBase::AddItemOnOffL( const TDesC& aCaption, TBool aOn )
hgs
parents:
diff changeset
   240
    {
hgs
parents:
diff changeset
   241
    CItem* item = CItem::NewOnOffLC( aCaption, aOn );
hgs
parents:
diff changeset
   242
    iItems.AppendL( item );
hgs
parents:
diff changeset
   243
    CleanupStack::Pop( item );
hgs
parents:
diff changeset
   244
    }
hgs
parents:
diff changeset
   245
hgs
parents:
diff changeset
   246
hgs
parents:
diff changeset
   247
void CMemSpyThreadInfoItemBase::AddItemPercentageL( const TDesC& aCaption, TInt aOneHundredPercentValue, TInt aValue )
hgs
parents:
diff changeset
   248
    {
hgs
parents:
diff changeset
   249
    const TMemSpyPercentText val( MemSpyEngineUtils::FormatPercentage( TReal( aOneHundredPercentValue ), TReal( aValue ) ) );
hgs
parents:
diff changeset
   250
    AddItemL( aCaption, val );
hgs
parents:
diff changeset
   251
    }
hgs
parents:
diff changeset
   252
hgs
parents:
diff changeset
   253
hgs
parents:
diff changeset
   254
EXPORT_C void CMemSpyThreadInfoItemBase::RebuildL()
hgs
parents:
diff changeset
   255
    {
hgs
parents:
diff changeset
   256
    Reset();
hgs
parents:
diff changeset
   257
    CallConstructL( this );
hgs
parents:
diff changeset
   258
    }
hgs
parents:
diff changeset
   259
hgs
parents:
diff changeset
   260
hgs
parents:
diff changeset
   261
EXPORT_C TBool CMemSpyThreadInfoItemBase::IsReady() const
hgs
parents:
diff changeset
   262
    {
hgs
parents:
diff changeset
   263
    return iReady;
hgs
parents:
diff changeset
   264
    }
hgs
parents:
diff changeset
   265
hgs
parents:
diff changeset
   266
hgs
parents:
diff changeset
   267
EXPORT_C TMemSpyThreadInfoItemType CMemSpyThreadInfoItemBase::Type() const
hgs
parents:
diff changeset
   268
    {
hgs
parents:
diff changeset
   269
    return iType;
hgs
parents:
diff changeset
   270
    }
hgs
parents:
diff changeset
   271
hgs
parents:
diff changeset
   272
hgs
parents:
diff changeset
   273
void CMemSpyThreadInfoItemBase::Reset()
hgs
parents:
diff changeset
   274
    {
hgs
parents:
diff changeset
   275
    iItems.ResetAndDestroy();
hgs
parents:
diff changeset
   276
    }
hgs
parents:
diff changeset
   277
hgs
parents:
diff changeset
   278
hgs
parents:
diff changeset
   279
void CMemSpyThreadInfoItemBase::StripProcessAndThreadNames( TDes& aText )
hgs
parents:
diff changeset
   280
    {
hgs
parents:
diff changeset
   281
    StripProcessName( aText );
hgs
parents:
diff changeset
   282
    StripThreadName( aText );
hgs
parents:
diff changeset
   283
    }
hgs
parents:
diff changeset
   284
hgs
parents:
diff changeset
   285
hgs
parents:
diff changeset
   286
void CMemSpyThreadInfoItemBase::StripProcessName( TDes& aText )
hgs
parents:
diff changeset
   287
    {
hgs
parents:
diff changeset
   288
    CMemSpyProcess& process = Container().Thread().Process();
hgs
parents:
diff changeset
   289
    const TPtrC processName( process.Name() );
hgs
parents:
diff changeset
   290
    TFullName temp;
hgs
parents:
diff changeset
   291
    //
hgs
parents:
diff changeset
   292
    _LIT( KProcessNameUidFormat1, "%S.exe[%08x]" );
hgs
parents:
diff changeset
   293
    temp.Format( KProcessNameUidFormat1, &processName, process.SID() );
hgs
parents:
diff changeset
   294
    const TBool stripped = MemSpyEngineUtils::StripText( aText, temp );
hgs
parents:
diff changeset
   295
    //
hgs
parents:
diff changeset
   296
    if  ( stripped == EFalse )
hgs
parents:
diff changeset
   297
        {
hgs
parents:
diff changeset
   298
        _LIT( KProcessNameUidFormat2, "%S[%08x]" );
hgs
parents:
diff changeset
   299
        temp.Format( KProcessNameUidFormat2, &processName, process.SID() );
hgs
parents:
diff changeset
   300
        MemSpyEngineUtils::StripText( aText, temp );
hgs
parents:
diff changeset
   301
        }
hgs
parents:
diff changeset
   302
    }
hgs
parents:
diff changeset
   303
hgs
parents:
diff changeset
   304
hgs
parents:
diff changeset
   305
void CMemSpyThreadInfoItemBase::StripThreadName( TDes& aText )
hgs
parents:
diff changeset
   306
    {
hgs
parents:
diff changeset
   307
    CMemSpyThread& thread = Container().Thread();
hgs
parents:
diff changeset
   308
    const TPtrC threadName( thread.Name() );
hgs
parents:
diff changeset
   309
    const TBool stripped = MemSpyEngineUtils::StripText( aText, threadName );
hgs
parents:
diff changeset
   310
    (void) stripped;
hgs
parents:
diff changeset
   311
    }
hgs
parents:
diff changeset
   312
hgs
parents:
diff changeset
   313
hgs
parents:
diff changeset
   314
CMemSpyThreadInfoItemBase::CItem& CMemSpyThreadInfoItemBase::Item( TInt aIndex )
hgs
parents:
diff changeset
   315
    {
hgs
parents:
diff changeset
   316
    CItem* item = iItems[ aIndex ];
hgs
parents:
diff changeset
   317
    return *item;
hgs
parents:
diff changeset
   318
    }
hgs
parents:
diff changeset
   319
hgs
parents:
diff changeset
   320
hgs
parents:
diff changeset
   321
const CMemSpyThreadInfoItemBase::CItem& CMemSpyThreadInfoItemBase::Item( TInt aIndex ) const
hgs
parents:
diff changeset
   322
    {
hgs
parents:
diff changeset
   323
    const CItem* item = iItems[ aIndex ];
hgs
parents:
diff changeset
   324
    return *item;
hgs
parents:
diff changeset
   325
    }
hgs
parents:
diff changeset
   326
hgs
parents:
diff changeset
   327
hgs
parents:
diff changeset
   328
hgs
parents:
diff changeset
   329
hgs
parents:
diff changeset
   330
hgs
parents:
diff changeset
   331
hgs
parents:
diff changeset
   332
hgs
parents:
diff changeset
   333
hgs
parents:
diff changeset
   334
hgs
parents:
diff changeset
   335
hgs
parents:
diff changeset
   336
hgs
parents:
diff changeset
   337
hgs
parents:
diff changeset
   338
hgs
parents:
diff changeset
   339
hgs
parents:
diff changeset
   340
hgs
parents:
diff changeset
   341
hgs
parents:
diff changeset
   342
hgs
parents:
diff changeset
   343
hgs
parents:
diff changeset
   344
hgs
parents:
diff changeset
   345
hgs
parents:
diff changeset
   346
CMemSpyThreadInfoItemBase::CItem::CItem()
hgs
parents:
diff changeset
   347
    {
hgs
parents:
diff changeset
   348
    }
hgs
parents:
diff changeset
   349
hgs
parents:
diff changeset
   350
hgs
parents:
diff changeset
   351
CMemSpyThreadInfoItemBase::CItem::~CItem()
hgs
parents:
diff changeset
   352
    {
hgs
parents:
diff changeset
   353
    delete iCaption;
hgs
parents:
diff changeset
   354
    delete iValue;
hgs
parents:
diff changeset
   355
    delete iCombined;
hgs
parents:
diff changeset
   356
    }
hgs
parents:
diff changeset
   357
hgs
parents:
diff changeset
   358
hgs
parents:
diff changeset
   359
void CMemSpyThreadInfoItemBase::CItem::ConstructL( const TDesC& aCaption, const TDesC& aValue )
hgs
parents:
diff changeset
   360
    {
hgs
parents:
diff changeset
   361
    iCaption = aCaption.AllocL();
hgs
parents:
diff changeset
   362
    iValue = aValue.AllocL();
hgs
parents:
diff changeset
   363
    //
hgs
parents:
diff changeset
   364
    UpdateCombinedL();
hgs
parents:
diff changeset
   365
    }
hgs
parents:
diff changeset
   366
hgs
parents:
diff changeset
   367
hgs
parents:
diff changeset
   368
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewLC( const CItem& aCopyMe )
hgs
parents:
diff changeset
   369
    {
hgs
parents:
diff changeset
   370
    CItem* self = new(ELeave) CItem();
hgs
parents:
diff changeset
   371
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
   372
    self->ConstructL( aCopyMe.Caption(), aCopyMe.Value() );
hgs
parents:
diff changeset
   373
    return self;
hgs
parents:
diff changeset
   374
    }
hgs
parents:
diff changeset
   375
hgs
parents:
diff changeset
   376
hgs
parents:
diff changeset
   377
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewLC( const TDesC& aCaption )
hgs
parents:
diff changeset
   378
    {
hgs
parents:
diff changeset
   379
    CItem* self = new(ELeave) CItem();
hgs
parents:
diff changeset
   380
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
   381
    self->ConstructL( aCaption, KNullDesC );
hgs
parents:
diff changeset
   382
    return self;
hgs
parents:
diff changeset
   383
    }
hgs
parents:
diff changeset
   384
hgs
parents:
diff changeset
   385
hgs
parents:
diff changeset
   386
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewLC( const TDesC& aCaption, const TDesC& aValue )
hgs
parents:
diff changeset
   387
    {
hgs
parents:
diff changeset
   388
    CItem* self = new(ELeave) CItem();
hgs
parents:
diff changeset
   389
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
   390
    self->ConstructL( aCaption, aValue );
hgs
parents:
diff changeset
   391
    return self;
hgs
parents:
diff changeset
   392
    }
hgs
parents:
diff changeset
   393
hgs
parents:
diff changeset
   394
hgs
parents:
diff changeset
   395
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewHexLC( const TDesC& aCaption, TUint aValue )
hgs
parents:
diff changeset
   396
    {
hgs
parents:
diff changeset
   397
    CItem* ret = CItem::NewLC( aCaption );
hgs
parents:
diff changeset
   398
    ret->SetHexL( aValue );
hgs
parents:
diff changeset
   399
    return ret;
hgs
parents:
diff changeset
   400
    }
hgs
parents:
diff changeset
   401
hgs
parents:
diff changeset
   402
hgs
parents:
diff changeset
   403
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewDecimalLC( const TDesC& aCaption, TInt aValue )
hgs
parents:
diff changeset
   404
    {
hgs
parents:
diff changeset
   405
    CItem* ret = CItem::NewLC( aCaption );
hgs
parents:
diff changeset
   406
    ret->SetDecimalL( aValue );
hgs
parents:
diff changeset
   407
    return ret;
hgs
parents:
diff changeset
   408
    }
hgs
parents:
diff changeset
   409
hgs
parents:
diff changeset
   410
hgs
parents:
diff changeset
   411
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewLongLC( const TDesC& aCaption, const TInt64& aValue )
hgs
parents:
diff changeset
   412
    {
hgs
parents:
diff changeset
   413
    CItem* ret = CItem::NewLC( aCaption );
hgs
parents:
diff changeset
   414
    ret->SetLongL( aValue );
hgs
parents:
diff changeset
   415
    return ret;
hgs
parents:
diff changeset
   416
    }
hgs
parents:
diff changeset
   417
hgs
parents:
diff changeset
   418
hgs
parents:
diff changeset
   419
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewYesNoLC( const TDesC& aCaption, TBool aYes )
hgs
parents:
diff changeset
   420
    {
hgs
parents:
diff changeset
   421
    CItem* ret = CItem::NewLC( aCaption );
hgs
parents:
diff changeset
   422
    ret->SetYesNoL( aYes );
hgs
parents:
diff changeset
   423
    return ret;
hgs
parents:
diff changeset
   424
    }
hgs
parents:
diff changeset
   425
hgs
parents:
diff changeset
   426
hgs
parents:
diff changeset
   427
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewOnOffLC( const TDesC& aCaption, TBool aOn )
hgs
parents:
diff changeset
   428
    {
hgs
parents:
diff changeset
   429
    CItem* ret = CItem::NewLC( aCaption );
hgs
parents:
diff changeset
   430
    ret->SetOnOffL( aOn );
hgs
parents:
diff changeset
   431
    return ret;
hgs
parents:
diff changeset
   432
    }
hgs
parents:
diff changeset
   433
hgs
parents:
diff changeset
   434
hgs
parents:
diff changeset
   435
CMemSpyThreadInfoItemBase::CItem* CMemSpyThreadInfoItemBase::CItem::NewPercentageLC( const TDesC& aCaption, TInt aOneHundredPercentValue, TInt aValue )
hgs
parents:
diff changeset
   436
    {
hgs
parents:
diff changeset
   437
    CItem* ret = CItem::NewLC( aCaption );
hgs
parents:
diff changeset
   438
    ret->SetPercentageL( aOneHundredPercentValue, aValue );
hgs
parents:
diff changeset
   439
    return ret;
hgs
parents:
diff changeset
   440
    }
hgs
parents:
diff changeset
   441
hgs
parents:
diff changeset
   442
hgs
parents:
diff changeset
   443
void CMemSpyThreadInfoItemBase::CItem::SetValueL( const TDesC& aValue )
hgs
parents:
diff changeset
   444
    {
hgs
parents:
diff changeset
   445
    if  ( iValue == NULL )
hgs
parents:
diff changeset
   446
        {
hgs
parents:
diff changeset
   447
        iValue = aValue.AllocL();
hgs
parents:
diff changeset
   448
        }
hgs
parents:
diff changeset
   449
    else
hgs
parents:
diff changeset
   450
        {
hgs
parents:
diff changeset
   451
        if  ( iValue->Des().MaxLength() < aValue.Length() )
hgs
parents:
diff changeset
   452
            {
hgs
parents:
diff changeset
   453
            iValue = iValue->ReAllocL( aValue.Length() );
hgs
parents:
diff changeset
   454
            }
hgs
parents:
diff changeset
   455
            
hgs
parents:
diff changeset
   456
        // Now its safe to assign new content
hgs
parents:
diff changeset
   457
        *iValue = aValue;
hgs
parents:
diff changeset
   458
        }
hgs
parents:
diff changeset
   459
        
hgs
parents:
diff changeset
   460
    UpdateCombinedL();
hgs
parents:
diff changeset
   461
    }
hgs
parents:
diff changeset
   462
hgs
parents:
diff changeset
   463
hgs
parents:
diff changeset
   464
void CMemSpyThreadInfoItemBase::CItem::SetHexL( TUint aValue )
hgs
parents:
diff changeset
   465
    {
hgs
parents:
diff changeset
   466
    TBuf<KMemSpyNumericFormatBufferSize> val;
hgs
parents:
diff changeset
   467
    val.Format( KMemSpyNumericHexFormat, aValue );
hgs
parents:
diff changeset
   468
    SetValueL( val );
hgs
parents:
diff changeset
   469
    }
hgs
parents:
diff changeset
   470
hgs
parents:
diff changeset
   471
hgs
parents:
diff changeset
   472
void CMemSpyThreadInfoItemBase::CItem::SetDecimalL( TInt aValue )
hgs
parents:
diff changeset
   473
    {
hgs
parents:
diff changeset
   474
    TBuf<KMemSpyNumericFormatBufferSize> val;
hgs
parents:
diff changeset
   475
    val.Format( KMemSpyNumericDecFormat, aValue );
hgs
parents:
diff changeset
   476
    SetValueL( val );
hgs
parents:
diff changeset
   477
    }
hgs
parents:
diff changeset
   478
hgs
parents:
diff changeset
   479
hgs
parents:
diff changeset
   480
void CMemSpyThreadInfoItemBase::CItem::SetLongL( const TInt64& aValue )
hgs
parents:
diff changeset
   481
    {
hgs
parents:
diff changeset
   482
    TBuf<KMemSpyNumericFormatBufferSize> val;
hgs
parents:
diff changeset
   483
    val.Format( KMemSpyNumericLongFormat, aValue );
hgs
parents:
diff changeset
   484
    SetValueL( val );
hgs
parents:
diff changeset
   485
    }
hgs
parents:
diff changeset
   486
hgs
parents:
diff changeset
   487
hgs
parents:
diff changeset
   488
void CMemSpyThreadInfoItemBase::CItem::SetYesNoL( TBool aYes )
hgs
parents:
diff changeset
   489
    {
hgs
parents:
diff changeset
   490
    if  ( aYes )
hgs
parents:
diff changeset
   491
        {
hgs
parents:
diff changeset
   492
        SetValueL( KMemSpyCaptionYes );
hgs
parents:
diff changeset
   493
        }
hgs
parents:
diff changeset
   494
    else
hgs
parents:
diff changeset
   495
        {
hgs
parents:
diff changeset
   496
        SetValueL( KMemSpyCaptionNo );
hgs
parents:
diff changeset
   497
        }
hgs
parents:
diff changeset
   498
    }
hgs
parents:
diff changeset
   499
hgs
parents:
diff changeset
   500
hgs
parents:
diff changeset
   501
void CMemSpyThreadInfoItemBase::CItem::SetOnOffL( TBool aOn )
hgs
parents:
diff changeset
   502
    {
hgs
parents:
diff changeset
   503
    if  ( aOn )
hgs
parents:
diff changeset
   504
        {
hgs
parents:
diff changeset
   505
        SetValueL( KMemSpyCaptionOn );
hgs
parents:
diff changeset
   506
        }
hgs
parents:
diff changeset
   507
    else
hgs
parents:
diff changeset
   508
        {
hgs
parents:
diff changeset
   509
        SetValueL( KMemSpyCaptionOff );
hgs
parents:
diff changeset
   510
        }
hgs
parents:
diff changeset
   511
    }
hgs
parents:
diff changeset
   512
hgs
parents:
diff changeset
   513
hgs
parents:
diff changeset
   514
void CMemSpyThreadInfoItemBase::CItem::SetPercentageL( TInt aOneHundredPercentValue, TInt aValue )
hgs
parents:
diff changeset
   515
    {
hgs
parents:
diff changeset
   516
    const TMemSpyPercentText val( MemSpyEngineUtils::FormatPercentage( TReal( aOneHundredPercentValue ), TReal( aValue ) ) );
hgs
parents:
diff changeset
   517
    SetValueL( val );
hgs
parents:
diff changeset
   518
    }
hgs
parents:
diff changeset
   519
hgs
parents:
diff changeset
   520
hgs
parents:
diff changeset
   521
void CMemSpyThreadInfoItemBase::CItem::UpdateCombinedL()
hgs
parents:
diff changeset
   522
    {
hgs
parents:
diff changeset
   523
    const TInt requiredLength = Caption().Length() + Value().Length() + 10;
hgs
parents:
diff changeset
   524
    //
hgs
parents:
diff changeset
   525
    if  ( iCombined == NULL )
hgs
parents:
diff changeset
   526
        {
hgs
parents:
diff changeset
   527
        iCombined = HBufC::NewL( requiredLength );
hgs
parents:
diff changeset
   528
        }
hgs
parents:
diff changeset
   529
    else if ( iCombined->Des().MaxLength() < requiredLength )
hgs
parents:
diff changeset
   530
        {
hgs
parents:
diff changeset
   531
        iCombined = iCombined->ReAllocL( requiredLength );
hgs
parents:
diff changeset
   532
        }
hgs
parents:
diff changeset
   533
        
hgs
parents:
diff changeset
   534
    TPtr pCombined( iCombined->Des() );
hgs
parents:
diff changeset
   535
    pCombined.Zero();
hgs
parents:
diff changeset
   536
    pCombined.Append( _L("\t") );
hgs
parents:
diff changeset
   537
    pCombined.Append( Caption() );
hgs
parents:
diff changeset
   538
    pCombined.Append( _L("\t\t") );
hgs
parents:
diff changeset
   539
    pCombined.Append( Value() );
hgs
parents:
diff changeset
   540
    }
hgs
parents:
diff changeset
   541
hgs
parents:
diff changeset
   542
hgs
parents:
diff changeset
   543
hgs
parents:
diff changeset
   544
hgs
parents:
diff changeset
   545
hgs
parents:
diff changeset
   546
hgs
parents:
diff changeset
   547
hgs
parents:
diff changeset
   548
hgs
parents:
diff changeset
   549
hgs
parents:
diff changeset
   550
hgs
parents:
diff changeset
   551
hgs
parents:
diff changeset
   552
hgs
parents:
diff changeset
   553
hgs
parents:
diff changeset
   554
hgs
parents:
diff changeset
   555
hgs
parents:
diff changeset
   556
hgs
parents:
diff changeset
   557
hgs
parents:
diff changeset
   558
hgs
parents:
diff changeset
   559
hgs
parents:
diff changeset
   560
hgs
parents:
diff changeset
   561
hgs
parents:
diff changeset
   562
hgs
parents:
diff changeset
   563
hgs
parents:
diff changeset
   564
hgs
parents:
diff changeset
   565
hgs
parents:
diff changeset
   566
hgs
parents:
diff changeset
   567
hgs
parents:
diff changeset
   568
hgs
parents:
diff changeset
   569
hgs
parents:
diff changeset
   570
hgs
parents:
diff changeset
   571
hgs
parents:
diff changeset
   572
hgs
parents:
diff changeset
   573
hgs
parents:
diff changeset
   574
hgs
parents:
diff changeset
   575
hgs
parents:
diff changeset
   576
hgs
parents:
diff changeset
   577
hgs
parents:
diff changeset
   578
hgs
parents:
diff changeset
   579
hgs
parents:
diff changeset
   580
CMemSpyThreadInfoGeneral::CMemSpyThreadInfoGeneral( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   581
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeGeneralInfo, aAsyncConstruction )
hgs
parents:
diff changeset
   582
    {
hgs
parents:
diff changeset
   583
    }
hgs
parents:
diff changeset
   584
hgs
parents:
diff changeset
   585
hgs
parents:
diff changeset
   586
void CMemSpyThreadInfoGeneral::ConstructL()
hgs
parents:
diff changeset
   587
    {
hgs
parents:
diff changeset
   588
    TBuf<50> temp;
hgs
parents:
diff changeset
   589
    RThread thread;
hgs
parents:
diff changeset
   590
    Container().Thread().OpenLC( thread );
hgs
parents:
diff changeset
   591
    const CMemSpyProcess& process = Container().Thread().Process();
hgs
parents:
diff changeset
   592
hgs
parents:
diff changeset
   593
    _LIT( KItem1, "Thread Id" );
hgs
parents:
diff changeset
   594
    AddItemLongL( KItem1, thread.Id() );
hgs
parents:
diff changeset
   595
hgs
parents:
diff changeset
   596
    _LIT( KItem1a, "Process Id" );
hgs
parents:
diff changeset
   597
    AddItemLongL( KItem1a, (TUint) process.Id() );
hgs
parents:
diff changeset
   598
  
hgs
parents:
diff changeset
   599
    _LIT( KItem1b, "SID" );
hgs
parents:
diff changeset
   600
    AddItemHexL( KItem1b, process.SID() );
hgs
parents:
diff changeset
   601
  
hgs
parents:
diff changeset
   602
    _LIT( KItem1c, "VID" );
hgs
parents:
diff changeset
   603
    AddItemHexL( KItem1c, process.VID() );
hgs
parents:
diff changeset
   604
hgs
parents:
diff changeset
   605
    _LIT( KItem2, "Thread Priority" );
hgs
parents:
diff changeset
   606
    CMemSpyThread::AppendPriority( temp, thread.Priority() );
hgs
parents:
diff changeset
   607
    AddItemL( KItem2, temp );
hgs
parents:
diff changeset
   608
    temp.Zero();
hgs
parents:
diff changeset
   609
   
hgs
parents:
diff changeset
   610
    _LIT( KItem3, "Process Priority" );
hgs
parents:
diff changeset
   611
    CMemSpyProcess::AppendPriority( temp, thread.ProcessPriority() );
hgs
parents:
diff changeset
   612
    AddItemL( KItem3, temp );
hgs
parents:
diff changeset
   613
    temp.Zero();
hgs
parents:
diff changeset
   614
   
hgs
parents:
diff changeset
   615
    _LIT( KItem4, "Request Count" );
hgs
parents:
diff changeset
   616
    AddItemDecimalL( KItem4, thread.RequestCount() );
hgs
parents:
diff changeset
   617
   
hgs
parents:
diff changeset
   618
    TInt processHandleCount = 0;
hgs
parents:
diff changeset
   619
    TInt threadHandleCount = 0;
hgs
parents:
diff changeset
   620
    thread.HandleCount( processHandleCount, threadHandleCount );
hgs
parents:
diff changeset
   621
hgs
parents:
diff changeset
   622
    _LIT( KItem5a, "Process Handles" );
hgs
parents:
diff changeset
   623
    AddItemDecimalL( KItem5a, processHandleCount );
hgs
parents:
diff changeset
   624
hgs
parents:
diff changeset
   625
    _LIT( KItem5b, "Thread Handles" );
hgs
parents:
diff changeset
   626
    AddItemDecimalL( KItem5b, threadHandleCount );
hgs
parents:
diff changeset
   627
hgs
parents:
diff changeset
   628
    // Thread handle info
hgs
parents:
diff changeset
   629
    THandleInfo handleInfo;
hgs
parents:
diff changeset
   630
    thread.HandleInfo( &handleInfo );
hgs
parents:
diff changeset
   631
hgs
parents:
diff changeset
   632
    _LIT( KItem5c, "Num. Proc. (Using)" );
hgs
parents:
diff changeset
   633
    AddItemDecimalL( KItem5c, handleInfo.iNumProcesses );
hgs
parents:
diff changeset
   634
hgs
parents:
diff changeset
   635
    _LIT( KItem5d, "Num. Thread (Using)" );
hgs
parents:
diff changeset
   636
    AddItemDecimalL( KItem5d, handleInfo.iNumThreads );
hgs
parents:
diff changeset
   637
hgs
parents:
diff changeset
   638
    _LIT( KItem5e, "Attributes" );
hgs
parents:
diff changeset
   639
    AddItemDecimalL( KItem5e, thread.Attributes() );
hgs
parents:
diff changeset
   640
    
hgs
parents:
diff changeset
   641
    // CPU time (request special kernel build)
hgs
parents:
diff changeset
   642
    TTimeIntervalMicroSeconds cpuTime;
hgs
parents:
diff changeset
   643
    if  ( thread.GetCpuTime( cpuTime ) == KErrNone )
hgs
parents:
diff changeset
   644
        {
hgs
parents:
diff changeset
   645
        _LIT( KItem5f, "CPU Time (us)" );
hgs
parents:
diff changeset
   646
        const TInt64 time = cpuTime.Int64();
hgs
parents:
diff changeset
   647
        AddItemLongL( KItem5f, time );
hgs
parents:
diff changeset
   648
        }
hgs
parents:
diff changeset
   649
hgs
parents:
diff changeset
   650
    // Exit info
hgs
parents:
diff changeset
   651
    _LIT( KItem6, "Exit Type" );
hgs
parents:
diff changeset
   652
    CMemSpyThread::AppendExitType( temp, thread.ExitType() );
hgs
parents:
diff changeset
   653
    AddItemL( KItem6, temp );
hgs
parents:
diff changeset
   654
    temp.Zero();
hgs
parents:
diff changeset
   655
hgs
parents:
diff changeset
   656
    if  ( thread.ExitType() != EExitPending )
hgs
parents:
diff changeset
   657
        {
hgs
parents:
diff changeset
   658
        _LIT( KItem7, "Exit Reason" );
hgs
parents:
diff changeset
   659
        AddItemDecimalL( KItem7, thread.ExitReason() );
hgs
parents:
diff changeset
   660
hgs
parents:
diff changeset
   661
        _LIT( KItem8, "Exit Category" );
hgs
parents:
diff changeset
   662
        const TExitCategoryName cat( thread.ExitCategory() );
hgs
parents:
diff changeset
   663
        AddItemL( KItem8, cat );
hgs
parents:
diff changeset
   664
        }
hgs
parents:
diff changeset
   665
hgs
parents:
diff changeset
   666
    // Registers
hgs
parents:
diff changeset
   667
    MakeRegisterListingL( thread );
hgs
parents:
diff changeset
   668
    
hgs
parents:
diff changeset
   669
    CleanupStack::PopAndDestroy( &thread );
hgs
parents:
diff changeset
   670
hgs
parents:
diff changeset
   671
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
   672
    }
hgs
parents:
diff changeset
   673
hgs
parents:
diff changeset
   674
hgs
parents:
diff changeset
   675
CMemSpyThreadInfoGeneral* CMemSpyThreadInfoGeneral::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   676
    {
hgs
parents:
diff changeset
   677
    CMemSpyThreadInfoGeneral* self = new(ELeave) CMemSpyThreadInfoGeneral( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
   678
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
   679
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
   680
        {
hgs
parents:
diff changeset
   681
        self->ConstructL();
hgs
parents:
diff changeset
   682
        }
hgs
parents:
diff changeset
   683
    return self;
hgs
parents:
diff changeset
   684
    }
hgs
parents:
diff changeset
   685
hgs
parents:
diff changeset
   686
hgs
parents:
diff changeset
   687
EXPORT_C TPtrC CMemSpyThreadInfoGeneral::Name() const
hgs
parents:
diff changeset
   688
    {
hgs
parents:
diff changeset
   689
    _LIT(KName, "\tGeneral");
hgs
parents:
diff changeset
   690
    return TPtrC( KName );
hgs
parents:
diff changeset
   691
    }
hgs
parents:
diff changeset
   692
hgs
parents:
diff changeset
   693
hgs
parents:
diff changeset
   694
void CMemSpyThreadInfoGeneral::MakeRegisterListingL( RThread& aThread )
hgs
parents:
diff changeset
   695
    {
hgs
parents:
diff changeset
   696
#ifndef __WINS__
hgs
parents:
diff changeset
   697
    _LIT(KRegFormatGeneral, "R%02d");
hgs
parents:
diff changeset
   698
    _LIT(KRegFormatSP, "SP");
hgs
parents:
diff changeset
   699
    _LIT(KRegFormatLR, "LR");
hgs
parents:
diff changeset
   700
    _LIT(KRegFormatPC, "PC");
hgs
parents:
diff changeset
   701
    _LIT(KRegFormatFlags, "Flags");
hgs
parents:
diff changeset
   702
    _LIT(KRegFormatDACR, "DACR"); // Data access control register
hgs
parents:
diff changeset
   703
    //
hgs
parents:
diff changeset
   704
    TArmRegSet regList;
hgs
parents:
diff changeset
   705
    TPckg<TArmRegSet> pRegList( regList );
hgs
parents:
diff changeset
   706
    //
hgs
parents:
diff changeset
   707
    aThread.Context( pRegList );
hgs
parents:
diff changeset
   708
	TArmReg* pReg = reinterpret_cast<TArmReg*>( &regList );
hgs
parents:
diff changeset
   709
    //
hgs
parents:
diff changeset
   710
    for( TInt i=0; i<KArmRegisterCount; i++ )
hgs
parents:
diff changeset
   711
        {
hgs
parents:
diff changeset
   712
        const TArmReg regValue = pReg[ i ];
hgs
parents:
diff changeset
   713
        //
hgs
parents:
diff changeset
   714
        if  ( i <= EArmR12 )
hgs
parents:
diff changeset
   715
            {
hgs
parents:
diff changeset
   716
            TBuf<128> buf;
hgs
parents:
diff changeset
   717
            buf.Format( KRegFormatGeneral, i );
hgs
parents:
diff changeset
   718
            AddItemHexL( buf, regValue );
hgs
parents:
diff changeset
   719
            }
hgs
parents:
diff changeset
   720
        else
hgs
parents:
diff changeset
   721
            {
hgs
parents:
diff changeset
   722
            TPtrC pCaption( KRegFormatGeneral );
hgs
parents:
diff changeset
   723
            //
hgs
parents:
diff changeset
   724
            if  ( i == EArmSp )
hgs
parents:
diff changeset
   725
                {
hgs
parents:
diff changeset
   726
                pCaption.Set( KRegFormatSP );
hgs
parents:
diff changeset
   727
                }
hgs
parents:
diff changeset
   728
            else if ( i == EArmLr )
hgs
parents:
diff changeset
   729
                {
hgs
parents:
diff changeset
   730
                pCaption.Set( KRegFormatLR );
hgs
parents:
diff changeset
   731
                }
hgs
parents:
diff changeset
   732
            else if ( i == EArmPc )
hgs
parents:
diff changeset
   733
                {
hgs
parents:
diff changeset
   734
                pCaption.Set( KRegFormatPC );
hgs
parents:
diff changeset
   735
                }
hgs
parents:
diff changeset
   736
            else if ( i == EArmFlags )
hgs
parents:
diff changeset
   737
                {
hgs
parents:
diff changeset
   738
                pCaption.Set( KRegFormatFlags );
hgs
parents:
diff changeset
   739
                }
hgs
parents:
diff changeset
   740
            else if ( i == EArmDacr )
hgs
parents:
diff changeset
   741
                {
hgs
parents:
diff changeset
   742
                pCaption.Set( KRegFormatDACR );
hgs
parents:
diff changeset
   743
                }
hgs
parents:
diff changeset
   744
            //
hgs
parents:
diff changeset
   745
            AddItemHexL( pCaption, regValue );
hgs
parents:
diff changeset
   746
            }
hgs
parents:
diff changeset
   747
        }
hgs
parents:
diff changeset
   748
#else
hgs
parents:
diff changeset
   749
    (void) aThread;
hgs
parents:
diff changeset
   750
#endif
hgs
parents:
diff changeset
   751
    }
hgs
parents:
diff changeset
   752
hgs
parents:
diff changeset
   753
hgs
parents:
diff changeset
   754
hgs
parents:
diff changeset
   755
hgs
parents:
diff changeset
   756
hgs
parents:
diff changeset
   757
hgs
parents:
diff changeset
   758
hgs
parents:
diff changeset
   759
hgs
parents:
diff changeset
   760
hgs
parents:
diff changeset
   761
hgs
parents:
diff changeset
   762
hgs
parents:
diff changeset
   763
hgs
parents:
diff changeset
   764
hgs
parents:
diff changeset
   765
hgs
parents:
diff changeset
   766
CMemSpyThreadInfoHeap::CMemSpyThreadInfoHeap( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   767
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeHeap, aAsyncConstruction )
hgs
parents:
diff changeset
   768
    {
hgs
parents:
diff changeset
   769
    }
hgs
parents:
diff changeset
   770
hgs
parents:
diff changeset
   771
hgs
parents:
diff changeset
   772
void CMemSpyThreadInfoHeap::ConstructL()
hgs
parents:
diff changeset
   773
    {
hgs
parents:
diff changeset
   774
    CMemSpyEngineHelperHeap& heapHelper = Engine().HelperHeap();
hgs
parents:
diff changeset
   775
hgs
parents:
diff changeset
   776
    // Get heap info first of all
hgs
parents:
diff changeset
   777
    TMemSpyHeapInfo info;
hgs
parents:
diff changeset
   778
    heapHelper.GetHeapInfoUserL( Container().Thread().Process().Id(), Container().Thread().Id(), info );
hgs
parents:
diff changeset
   779
    CMemSpyEngineOutputList* list = heapHelper.NewHeapSummaryShortLC( info );
hgs
parents:
diff changeset
   780
hgs
parents:
diff changeset
   781
    // Now add each item to our view
hgs
parents:
diff changeset
   782
    const TInt count = list->Count();
hgs
parents:
diff changeset
   783
    for( TInt i=0; i<count; i++ )
hgs
parents:
diff changeset
   784
        {
hgs
parents:
diff changeset
   785
        const CMemSpyEngineOutputListItem& item = list->Item( i );
hgs
parents:
diff changeset
   786
        //
hgs
parents:
diff changeset
   787
        AddItemL( item.Caption(), item.Value() );
hgs
parents:
diff changeset
   788
        }
hgs
parents:
diff changeset
   789
hgs
parents:
diff changeset
   790
    // Tidy up
hgs
parents:
diff changeset
   791
    CleanupStack::PopAndDestroy( list );
hgs
parents:
diff changeset
   792
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
   793
    }
hgs
parents:
diff changeset
   794
hgs
parents:
diff changeset
   795
hgs
parents:
diff changeset
   796
CMemSpyThreadInfoHeap* CMemSpyThreadInfoHeap::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   797
    {
hgs
parents:
diff changeset
   798
    CMemSpyThreadInfoHeap* self = new(ELeave) CMemSpyThreadInfoHeap( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
   799
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
   800
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
   801
        {
hgs
parents:
diff changeset
   802
        self->ConstructL();
hgs
parents:
diff changeset
   803
        }
hgs
parents:
diff changeset
   804
    return self;
hgs
parents:
diff changeset
   805
    }
hgs
parents:
diff changeset
   806
hgs
parents:
diff changeset
   807
hgs
parents:
diff changeset
   808
EXPORT_C TPtrC CMemSpyThreadInfoHeap::Name() const
hgs
parents:
diff changeset
   809
    {
hgs
parents:
diff changeset
   810
    _LIT(KName, "\tHeap");
hgs
parents:
diff changeset
   811
    return TPtrC( KName );
hgs
parents:
diff changeset
   812
    }
hgs
parents:
diff changeset
   813
hgs
parents:
diff changeset
   814
hgs
parents:
diff changeset
   815
hgs
parents:
diff changeset
   816
hgs
parents:
diff changeset
   817
hgs
parents:
diff changeset
   818
hgs
parents:
diff changeset
   819
hgs
parents:
diff changeset
   820
hgs
parents:
diff changeset
   821
hgs
parents:
diff changeset
   822
hgs
parents:
diff changeset
   823
hgs
parents:
diff changeset
   824
hgs
parents:
diff changeset
   825
hgs
parents:
diff changeset
   826
hgs
parents:
diff changeset
   827
hgs
parents:
diff changeset
   828
hgs
parents:
diff changeset
   829
CMemSpyThreadInfoActiveObjects::CMemSpyThreadInfoActiveObjects( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   830
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeActiveObject, aAsyncConstruction )
hgs
parents:
diff changeset
   831
    {
hgs
parents:
diff changeset
   832
    }
hgs
parents:
diff changeset
   833
hgs
parents:
diff changeset
   834
hgs
parents:
diff changeset
   835
CMemSpyThreadInfoActiveObjects::~CMemSpyThreadInfoActiveObjects()
hgs
parents:
diff changeset
   836
    {
hgs
parents:
diff changeset
   837
    delete iItems;
hgs
parents:
diff changeset
   838
    }
hgs
parents:
diff changeset
   839
hgs
parents:
diff changeset
   840
hgs
parents:
diff changeset
   841
void CMemSpyThreadInfoActiveObjects::ConstructL()
hgs
parents:
diff changeset
   842
    {
hgs
parents:
diff changeset
   843
    CMemSpyEngine& engine = Container().Thread().Process().Engine();
hgs
parents:
diff changeset
   844
    engine.ProcessSuspendLC( Container().Thread().Process().Id() );
hgs
parents:
diff changeset
   845
    //
hgs
parents:
diff changeset
   846
    CMemSpyEngineActiveObjectArray* activeObjects = engine.HelperActiveObject().ActiveObjectListL( Container().Thread() );
hgs
parents:
diff changeset
   847
    delete iItems;
hgs
parents:
diff changeset
   848
    iItems = activeObjects;
hgs
parents:
diff changeset
   849
    //
hgs
parents:
diff changeset
   850
    CleanupStack::PopAndDestroy(); // ProcessSuspendLC
hgs
parents:
diff changeset
   851
hgs
parents:
diff changeset
   852
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
   853
    }
hgs
parents:
diff changeset
   854
hgs
parents:
diff changeset
   855
hgs
parents:
diff changeset
   856
CMemSpyThreadInfoActiveObjects* CMemSpyThreadInfoActiveObjects::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   857
    {
hgs
parents:
diff changeset
   858
    CMemSpyThreadInfoActiveObjects* self = new(ELeave) CMemSpyThreadInfoActiveObjects( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
   859
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
   860
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
   861
        {
hgs
parents:
diff changeset
   862
        self->ConstructL();
hgs
parents:
diff changeset
   863
        }
hgs
parents:
diff changeset
   864
    return self;
hgs
parents:
diff changeset
   865
    }
hgs
parents:
diff changeset
   866
hgs
parents:
diff changeset
   867
hgs
parents:
diff changeset
   868
EXPORT_C TPtrC CMemSpyThreadInfoActiveObjects::Name() const
hgs
parents:
diff changeset
   869
    {
hgs
parents:
diff changeset
   870
    _LIT(KName, "\tActive Objects");
hgs
parents:
diff changeset
   871
    return TPtrC( KName );
hgs
parents:
diff changeset
   872
    }
hgs
parents:
diff changeset
   873
hgs
parents:
diff changeset
   874
hgs
parents:
diff changeset
   875
EXPORT_C TInt CMemSpyThreadInfoActiveObjects::MdcaCount() const
hgs
parents:
diff changeset
   876
    {
hgs
parents:
diff changeset
   877
    TInt count = 0;
hgs
parents:
diff changeset
   878
    //
hgs
parents:
diff changeset
   879
    if  ( iItems )
hgs
parents:
diff changeset
   880
        {
hgs
parents:
diff changeset
   881
        count = iItems->MdcaCount();
hgs
parents:
diff changeset
   882
        }
hgs
parents:
diff changeset
   883
    //
hgs
parents:
diff changeset
   884
    return count;
hgs
parents:
diff changeset
   885
    }
hgs
parents:
diff changeset
   886
hgs
parents:
diff changeset
   887
hgs
parents:
diff changeset
   888
EXPORT_C TPtrC CMemSpyThreadInfoActiveObjects::MdcaPoint(TInt aIndex) const
hgs
parents:
diff changeset
   889
    {
hgs
parents:
diff changeset
   890
    TPtrC ret( KNullDesC );
hgs
parents:
diff changeset
   891
    //
hgs
parents:
diff changeset
   892
    if  ( iItems )
hgs
parents:
diff changeset
   893
        {
hgs
parents:
diff changeset
   894
        ret.Set( iItems->MdcaPoint( aIndex ) );
hgs
parents:
diff changeset
   895
        }
hgs
parents:
diff changeset
   896
    //
hgs
parents:
diff changeset
   897
    return ret;
hgs
parents:
diff changeset
   898
    }
hgs
parents:
diff changeset
   899
hgs
parents:
diff changeset
   900
hgs
parents:
diff changeset
   901
hgs
parents:
diff changeset
   902
hgs
parents:
diff changeset
   903
hgs
parents:
diff changeset
   904
hgs
parents:
diff changeset
   905
hgs
parents:
diff changeset
   906
hgs
parents:
diff changeset
   907
hgs
parents:
diff changeset
   908
hgs
parents:
diff changeset
   909
hgs
parents:
diff changeset
   910
hgs
parents:
diff changeset
   911
CMemSpyThreadInfoOpenFiles::CMemSpyThreadInfoOpenFiles( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   912
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeOpenFiles, aAsyncConstruction )
hgs
parents:
diff changeset
   913
    {
hgs
parents:
diff changeset
   914
    }
hgs
parents:
diff changeset
   915
hgs
parents:
diff changeset
   916
hgs
parents:
diff changeset
   917
void CMemSpyThreadInfoOpenFiles::ConstructL()
hgs
parents:
diff changeset
   918
    {
hgs
parents:
diff changeset
   919
    _LIT(KSpace, " ");
hgs
parents:
diff changeset
   920
    //
hgs
parents:
diff changeset
   921
    const TThreadId myThreadId = Container().Thread().Id();
hgs
parents:
diff changeset
   922
    CMemSpyEngine& engine = Container().Thread().Process().Engine();
hgs
parents:
diff changeset
   923
    RFs& fsSession = engine.FsSession();
hgs
parents:
diff changeset
   924
    //
hgs
parents:
diff changeset
   925
    TMemSpySizeText valueBuf;
hgs
parents:
diff changeset
   926
    TBuf<128> timeBuf;
hgs
parents:
diff changeset
   927
    TOpenFileScan scanner( fsSession );
hgs
parents:
diff changeset
   928
    //
hgs
parents:
diff changeset
   929
    CFileList* list = NULL;
hgs
parents:
diff changeset
   930
    scanner.NextL( list );
hgs
parents:
diff changeset
   931
hgs
parents:
diff changeset
   932
    while( list != NULL )
hgs
parents:
diff changeset
   933
        {
hgs
parents:
diff changeset
   934
        if  ( scanner.ThreadId() == myThreadId )
hgs
parents:
diff changeset
   935
            {
hgs
parents:
diff changeset
   936
            CleanupStack::PushL( list );
hgs
parents:
diff changeset
   937
    
hgs
parents:
diff changeset
   938
            const TInt entryCount = list->Count();
hgs
parents:
diff changeset
   939
            for(TInt i=0; i<entryCount; i++)
hgs
parents:
diff changeset
   940
                {
hgs
parents:
diff changeset
   941
                const TEntry& entry = (*list)[ i ];
hgs
parents:
diff changeset
   942
hgs
parents:
diff changeset
   943
                // Get time and size format strings
hgs
parents:
diff changeset
   944
                valueBuf = MemSpyEngineUtils::FormatSizeText( entry.iSize );
hgs
parents:
diff changeset
   945
                MemSpyEngineUtils::FormatTimeL( timeBuf, entry.iModified );
hgs
parents:
diff changeset
   946
                timeBuf.Insert( 0, KSpace );
hgs
parents:
diff changeset
   947
                timeBuf.Insert( 0, valueBuf );
hgs
parents:
diff changeset
   948
hgs
parents:
diff changeset
   949
                // Get just file name
hgs
parents:
diff changeset
   950
                TParsePtrC parser( entry.iName );
hgs
parents:
diff changeset
   951
                const TPtrC pJustName( parser.NameAndExt() );
hgs
parents:
diff changeset
   952
hgs
parents:
diff changeset
   953
                // Create item 
hgs
parents:
diff changeset
   954
                AddItemL( pJustName, timeBuf );
hgs
parents:
diff changeset
   955
                }
hgs
parents:
diff changeset
   956
hgs
parents:
diff changeset
   957
            CleanupStack::Pop( list );
hgs
parents:
diff changeset
   958
            }
hgs
parents:
diff changeset
   959
hgs
parents:
diff changeset
   960
        delete list;
hgs
parents:
diff changeset
   961
        list = NULL;
hgs
parents:
diff changeset
   962
        scanner.NextL( list );
hgs
parents:
diff changeset
   963
        }
hgs
parents:
diff changeset
   964
hgs
parents:
diff changeset
   965
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
   966
    }
hgs
parents:
diff changeset
   967
hgs
parents:
diff changeset
   968
hgs
parents:
diff changeset
   969
CMemSpyThreadInfoOpenFiles* CMemSpyThreadInfoOpenFiles::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
   970
    {
hgs
parents:
diff changeset
   971
    CMemSpyThreadInfoOpenFiles* self = new(ELeave) CMemSpyThreadInfoOpenFiles( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
   972
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
   973
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
   974
        {
hgs
parents:
diff changeset
   975
        self->ConstructL();
hgs
parents:
diff changeset
   976
        }
hgs
parents:
diff changeset
   977
    return self;
hgs
parents:
diff changeset
   978
    }
hgs
parents:
diff changeset
   979
hgs
parents:
diff changeset
   980
hgs
parents:
diff changeset
   981
EXPORT_C TPtrC CMemSpyThreadInfoOpenFiles::Name() const
hgs
parents:
diff changeset
   982
    {
hgs
parents:
diff changeset
   983
    _LIT(KName, "\tOpen Files");
hgs
parents:
diff changeset
   984
    return TPtrC( KName );
hgs
parents:
diff changeset
   985
    }
hgs
parents:
diff changeset
   986
hgs
parents:
diff changeset
   987
hgs
parents:
diff changeset
   988
hgs
parents:
diff changeset
   989
hgs
parents:
diff changeset
   990
hgs
parents:
diff changeset
   991
hgs
parents:
diff changeset
   992
hgs
parents:
diff changeset
   993
hgs
parents:
diff changeset
   994
hgs
parents:
diff changeset
   995
hgs
parents:
diff changeset
   996
hgs
parents:
diff changeset
   997
hgs
parents:
diff changeset
   998
hgs
parents:
diff changeset
   999
hgs
parents:
diff changeset
  1000
hgs
parents:
diff changeset
  1001
hgs
parents:
diff changeset
  1002
CMemSpyThreadInfoStack::CMemSpyThreadInfoStack( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1003
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeStack, aAsyncConstruction )
hgs
parents:
diff changeset
  1004
    {
hgs
parents:
diff changeset
  1005
    }
hgs
parents:
diff changeset
  1006
hgs
parents:
diff changeset
  1007
hgs
parents:
diff changeset
  1008
void CMemSpyThreadInfoStack::ConstructL()
hgs
parents:
diff changeset
  1009
    {
hgs
parents:
diff changeset
  1010
    CMemSpyEngine& engine = Container().Thread().Process().Engine();
hgs
parents:
diff changeset
  1011
    engine.ProcessSuspendLC( Container().Thread().Process().Id() );
hgs
parents:
diff changeset
  1012
    //
hgs
parents:
diff changeset
  1013
    TMemSpyDriverStackInfo info;
hgs
parents:
diff changeset
  1014
    const TInt error = engine.Driver().GetStackInfo( Container().Thread().Id(), info );
hgs
parents:
diff changeset
  1015
    User::LeaveIfError( error );
hgs
parents:
diff changeset
  1016
    
hgs
parents:
diff changeset
  1017
    _LIT( KItem1, "Size" );
hgs
parents:
diff changeset
  1018
    AddItemDecimalL( KItem1, info.iUserStackSize );
hgs
parents:
diff changeset
  1019
hgs
parents:
diff changeset
  1020
#ifndef __WINS__
hgs
parents:
diff changeset
  1021
    const TInt userStackUsage = (TInt) ( info.iUserStackBase + info.iUserStackSize ) - info.iUserStackPointer;
hgs
parents:
diff changeset
  1022
    const TInt userStackHighWaterMarkUsage = (TInt) ( info.iUserStackBase + info.iUserStackSize ) - info.iUserStackHighWatermark;
hgs
parents:
diff changeset
  1023
hgs
parents:
diff changeset
  1024
    _LIT( KItem2, "Stack used" );
hgs
parents:
diff changeset
  1025
    AddItemDecimalL( KItem2, userStackUsage );
hgs
parents:
diff changeset
  1026
    
hgs
parents:
diff changeset
  1027
    _LIT( KItem3, "(percentage)" );
hgs
parents:
diff changeset
  1028
    AddItemPercentageL( KItem3, info.iUserStackSize, userStackUsage );
hgs
parents:
diff changeset
  1029
hgs
parents:
diff changeset
  1030
    _LIT( KItem4, "High watermark" );
hgs
parents:
diff changeset
  1031
    AddItemDecimalL( KItem4, userStackHighWaterMarkUsage );
hgs
parents:
diff changeset
  1032
    
hgs
parents:
diff changeset
  1033
    _LIT( KItem5, "(percentage)" );
hgs
parents:
diff changeset
  1034
    AddItemPercentageL( KItem5, info.iUserStackSize, userStackHighWaterMarkUsage );
hgs
parents:
diff changeset
  1035
#endif
hgs
parents:
diff changeset
  1036
hgs
parents:
diff changeset
  1037
    _LIT( KItem6, "Base address" );
hgs
parents:
diff changeset
  1038
    AddItemHexL( KItem6, info.iUserStackBase );
hgs
parents:
diff changeset
  1039
hgs
parents:
diff changeset
  1040
#ifndef __WINS__
hgs
parents:
diff changeset
  1041
    _LIT( KItem7, "Current pointer" );
hgs
parents:
diff changeset
  1042
    AddItemHexL( KItem7, info.iUserStackPointer );
hgs
parents:
diff changeset
  1043
#endif
hgs
parents:
diff changeset
  1044
    //
hgs
parents:
diff changeset
  1045
    CleanupStack::PopAndDestroy(); // ProcessSuspendLC
hgs
parents:
diff changeset
  1046
hgs
parents:
diff changeset
  1047
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  1048
    }
hgs
parents:
diff changeset
  1049
hgs
parents:
diff changeset
  1050
hgs
parents:
diff changeset
  1051
CMemSpyThreadInfoStack* CMemSpyThreadInfoStack::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1052
    {
hgs
parents:
diff changeset
  1053
    CMemSpyThreadInfoStack* self = new(ELeave) CMemSpyThreadInfoStack( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1054
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1055
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1056
        {
hgs
parents:
diff changeset
  1057
        self->ConstructL();
hgs
parents:
diff changeset
  1058
        }
hgs
parents:
diff changeset
  1059
    return self;
hgs
parents:
diff changeset
  1060
    }
hgs
parents:
diff changeset
  1061
hgs
parents:
diff changeset
  1062
hgs
parents:
diff changeset
  1063
EXPORT_C TPtrC CMemSpyThreadInfoStack::Name() const
hgs
parents:
diff changeset
  1064
    {
hgs
parents:
diff changeset
  1065
    _LIT(KName, "\tStack");
hgs
parents:
diff changeset
  1066
    return TPtrC( KName );
hgs
parents:
diff changeset
  1067
    }
hgs
parents:
diff changeset
  1068
hgs
parents:
diff changeset
  1069
hgs
parents:
diff changeset
  1070
hgs
parents:
diff changeset
  1071
hgs
parents:
diff changeset
  1072
hgs
parents:
diff changeset
  1073
hgs
parents:
diff changeset
  1074
hgs
parents:
diff changeset
  1075
hgs
parents:
diff changeset
  1076
hgs
parents:
diff changeset
  1077
hgs
parents:
diff changeset
  1078
hgs
parents:
diff changeset
  1079
hgs
parents:
diff changeset
  1080
hgs
parents:
diff changeset
  1081
hgs
parents:
diff changeset
  1082
hgs
parents:
diff changeset
  1083
hgs
parents:
diff changeset
  1084
hgs
parents:
diff changeset
  1085
hgs
parents:
diff changeset
  1086
hgs
parents:
diff changeset
  1087
hgs
parents:
diff changeset
  1088
hgs
parents:
diff changeset
  1089
hgs
parents:
diff changeset
  1090
hgs
parents:
diff changeset
  1091
hgs
parents:
diff changeset
  1092
hgs
parents:
diff changeset
  1093
hgs
parents:
diff changeset
  1094
hgs
parents:
diff changeset
  1095
hgs
parents:
diff changeset
  1096
hgs
parents:
diff changeset
  1097
hgs
parents:
diff changeset
  1098
CMemSpyThreadInfoChunk::CMemSpyThreadInfoChunk( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1099
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeChunk, aAsyncConstruction )
hgs
parents:
diff changeset
  1100
    {
hgs
parents:
diff changeset
  1101
    }
hgs
parents:
diff changeset
  1102
hgs
parents:
diff changeset
  1103
hgs
parents:
diff changeset
  1104
CMemSpyThreadInfoChunk::~CMemSpyThreadInfoChunk()
hgs
parents:
diff changeset
  1105
    {
hgs
parents:
diff changeset
  1106
    delete iList;
hgs
parents:
diff changeset
  1107
    }
hgs
parents:
diff changeset
  1108
hgs
parents:
diff changeset
  1109
hgs
parents:
diff changeset
  1110
void CMemSpyThreadInfoChunk::ConstructL()
hgs
parents:
diff changeset
  1111
    {
hgs
parents:
diff changeset
  1112
    CMemSpyEngine& engine = Container().Thread().Process().Engine();
hgs
parents:
diff changeset
  1113
    engine.ProcessSuspendLC( Container().Thread().Process().Id() );
hgs
parents:
diff changeset
  1114
    //
hgs
parents:
diff changeset
  1115
    CMemSpyEngineChunkList* list = engine.HelperChunk().ListForThreadL( Container().Thread().Id() );
hgs
parents:
diff changeset
  1116
    delete iList;
hgs
parents:
diff changeset
  1117
    iList = list;
hgs
parents:
diff changeset
  1118
    //
hgs
parents:
diff changeset
  1119
    CleanupStack::PopAndDestroy(); // ProcessSuspendLC
hgs
parents:
diff changeset
  1120
hgs
parents:
diff changeset
  1121
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  1122
    }
hgs
parents:
diff changeset
  1123
hgs
parents:
diff changeset
  1124
hgs
parents:
diff changeset
  1125
CMemSpyThreadInfoChunk* CMemSpyThreadInfoChunk::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1126
    {
hgs
parents:
diff changeset
  1127
    CMemSpyThreadInfoChunk* self = new(ELeave) CMemSpyThreadInfoChunk( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1128
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1129
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1130
        {
hgs
parents:
diff changeset
  1131
        self->ConstructL();
hgs
parents:
diff changeset
  1132
        }
hgs
parents:
diff changeset
  1133
    return self;
hgs
parents:
diff changeset
  1134
    }
hgs
parents:
diff changeset
  1135
hgs
parents:
diff changeset
  1136
hgs
parents:
diff changeset
  1137
EXPORT_C TPtrC CMemSpyThreadInfoChunk::Name() const
hgs
parents:
diff changeset
  1138
    {
hgs
parents:
diff changeset
  1139
    _LIT(KName, "\tChunks");
hgs
parents:
diff changeset
  1140
    return TPtrC( KName );
hgs
parents:
diff changeset
  1141
    }
hgs
parents:
diff changeset
  1142
hgs
parents:
diff changeset
  1143
hgs
parents:
diff changeset
  1144
EXPORT_C TInt CMemSpyThreadInfoChunk::MdcaCount() const
hgs
parents:
diff changeset
  1145
    {
hgs
parents:
diff changeset
  1146
    TInt count = 0;
hgs
parents:
diff changeset
  1147
    //
hgs
parents:
diff changeset
  1148
    if  ( iList )
hgs
parents:
diff changeset
  1149
        {
hgs
parents:
diff changeset
  1150
        count = iList->MdcaCount();
hgs
parents:
diff changeset
  1151
        }
hgs
parents:
diff changeset
  1152
    //
hgs
parents:
diff changeset
  1153
    return count;
hgs
parents:
diff changeset
  1154
    }
hgs
parents:
diff changeset
  1155
hgs
parents:
diff changeset
  1156
hgs
parents:
diff changeset
  1157
EXPORT_C TPtrC CMemSpyThreadInfoChunk::MdcaPoint(TInt aIndex) const
hgs
parents:
diff changeset
  1158
    {
hgs
parents:
diff changeset
  1159
    TPtrC ret( KNullDesC );
hgs
parents:
diff changeset
  1160
    //
hgs
parents:
diff changeset
  1161
    if  ( iList )
hgs
parents:
diff changeset
  1162
        {
hgs
parents:
diff changeset
  1163
        ret.Set( iList->MdcaPoint( aIndex ) );
hgs
parents:
diff changeset
  1164
        }
hgs
parents:
diff changeset
  1165
    //
hgs
parents:
diff changeset
  1166
    return ret;
hgs
parents:
diff changeset
  1167
    }
hgs
parents:
diff changeset
  1168
hgs
parents:
diff changeset
  1169
hgs
parents:
diff changeset
  1170
hgs
parents:
diff changeset
  1171
hgs
parents:
diff changeset
  1172
hgs
parents:
diff changeset
  1173
hgs
parents:
diff changeset
  1174
hgs
parents:
diff changeset
  1175
hgs
parents:
diff changeset
  1176
hgs
parents:
diff changeset
  1177
hgs
parents:
diff changeset
  1178
hgs
parents:
diff changeset
  1179
hgs
parents:
diff changeset
  1180
hgs
parents:
diff changeset
  1181
hgs
parents:
diff changeset
  1182
hgs
parents:
diff changeset
  1183
hgs
parents:
diff changeset
  1184
hgs
parents:
diff changeset
  1185
hgs
parents:
diff changeset
  1186
CMemSpyThreadInfoCodeSeg::CMemSpyThreadInfoCodeSeg( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1187
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeCodeSeg, aAsyncConstruction )
hgs
parents:
diff changeset
  1188
    {
hgs
parents:
diff changeset
  1189
    }
hgs
parents:
diff changeset
  1190
hgs
parents:
diff changeset
  1191
hgs
parents:
diff changeset
  1192
CMemSpyThreadInfoCodeSeg::~CMemSpyThreadInfoCodeSeg()
hgs
parents:
diff changeset
  1193
    {
hgs
parents:
diff changeset
  1194
    delete iList;
hgs
parents:
diff changeset
  1195
    }
hgs
parents:
diff changeset
  1196
hgs
parents:
diff changeset
  1197
hgs
parents:
diff changeset
  1198
void CMemSpyThreadInfoCodeSeg::ConstructL()
hgs
parents:
diff changeset
  1199
    {
hgs
parents:
diff changeset
  1200
    CMemSpyEngine& engine = Container().Thread().Process().Engine();
hgs
parents:
diff changeset
  1201
    engine.ProcessSuspendLC( Container().Thread().Process().Id() );
hgs
parents:
diff changeset
  1202
    //
hgs
parents:
diff changeset
  1203
    CMemSpyEngineCodeSegList* list = engine.HelperCodeSegment().CodeSegmentListL( Container().Thread().Process().Id() );
hgs
parents:
diff changeset
  1204
    delete iList;
hgs
parents:
diff changeset
  1205
    iList = list;
hgs
parents:
diff changeset
  1206
    //
hgs
parents:
diff changeset
  1207
    CleanupStack::PopAndDestroy(); // ProcessSuspendLC
hgs
parents:
diff changeset
  1208
hgs
parents:
diff changeset
  1209
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  1210
    }
hgs
parents:
diff changeset
  1211
hgs
parents:
diff changeset
  1212
hgs
parents:
diff changeset
  1213
CMemSpyThreadInfoCodeSeg* CMemSpyThreadInfoCodeSeg::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1214
    {
hgs
parents:
diff changeset
  1215
    CMemSpyThreadInfoCodeSeg* self = new(ELeave) CMemSpyThreadInfoCodeSeg( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1216
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1217
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1218
        {
hgs
parents:
diff changeset
  1219
        self->ConstructL();
hgs
parents:
diff changeset
  1220
        }
hgs
parents:
diff changeset
  1221
    return self;
hgs
parents:
diff changeset
  1222
    }
hgs
parents:
diff changeset
  1223
hgs
parents:
diff changeset
  1224
hgs
parents:
diff changeset
  1225
EXPORT_C TPtrC CMemSpyThreadInfoCodeSeg::Name() const
hgs
parents:
diff changeset
  1226
    {
hgs
parents:
diff changeset
  1227
    _LIT(KName, "\tCode Segments");
hgs
parents:
diff changeset
  1228
    return TPtrC( KName );
hgs
parents:
diff changeset
  1229
    }
hgs
parents:
diff changeset
  1230
hgs
parents:
diff changeset
  1231
hgs
parents:
diff changeset
  1232
EXPORT_C TInt CMemSpyThreadInfoCodeSeg::MdcaCount() const
hgs
parents:
diff changeset
  1233
    {
hgs
parents:
diff changeset
  1234
    TInt count = 0;
hgs
parents:
diff changeset
  1235
    //
hgs
parents:
diff changeset
  1236
    if  ( iList )
hgs
parents:
diff changeset
  1237
        {
hgs
parents:
diff changeset
  1238
        count = iList->MdcaCount();
hgs
parents:
diff changeset
  1239
        }
hgs
parents:
diff changeset
  1240
    //
hgs
parents:
diff changeset
  1241
    return count;
hgs
parents:
diff changeset
  1242
    }
hgs
parents:
diff changeset
  1243
hgs
parents:
diff changeset
  1244
hgs
parents:
diff changeset
  1245
EXPORT_C TPtrC CMemSpyThreadInfoCodeSeg::MdcaPoint(TInt aIndex) const
hgs
parents:
diff changeset
  1246
    {
hgs
parents:
diff changeset
  1247
    TPtrC ret( KNullDesC );
hgs
parents:
diff changeset
  1248
    //
hgs
parents:
diff changeset
  1249
    if  ( iList )
hgs
parents:
diff changeset
  1250
        {
hgs
parents:
diff changeset
  1251
        ret.Set( iList->MdcaPoint( aIndex ) );
hgs
parents:
diff changeset
  1252
        }
hgs
parents:
diff changeset
  1253
    //
hgs
parents:
diff changeset
  1254
    return ret;
hgs
parents:
diff changeset
  1255
    }
hgs
parents:
diff changeset
  1256
hgs
parents:
diff changeset
  1257
hgs
parents:
diff changeset
  1258
hgs
parents:
diff changeset
  1259
hgs
parents:
diff changeset
  1260
hgs
parents:
diff changeset
  1261
hgs
parents:
diff changeset
  1262
hgs
parents:
diff changeset
  1263
hgs
parents:
diff changeset
  1264
hgs
parents:
diff changeset
  1265
hgs
parents:
diff changeset
  1266
hgs
parents:
diff changeset
  1267
hgs
parents:
diff changeset
  1268
hgs
parents:
diff changeset
  1269
hgs
parents:
diff changeset
  1270
hgs
parents:
diff changeset
  1271
hgs
parents:
diff changeset
  1272
hgs
parents:
diff changeset
  1273
hgs
parents:
diff changeset
  1274
hgs
parents:
diff changeset
  1275
hgs
parents:
diff changeset
  1276
hgs
parents:
diff changeset
  1277
hgs
parents:
diff changeset
  1278
hgs
parents:
diff changeset
  1279
hgs
parents:
diff changeset
  1280
hgs
parents:
diff changeset
  1281
CMemSpyThreadInfoHandleObjectBase::CMemSpyThreadInfoHandleObjectBase( CMemSpyThreadInfoContainer& aContainer, TMemSpyThreadInfoItemType aItemType, TMemSpyDriverContainerType aContainerType, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1282
:   CMemSpyThreadInfoItemBase( aContainer, aItemType, aAsyncConstruction ), iContainerType( aContainerType )
hgs
parents:
diff changeset
  1283
    {
hgs
parents:
diff changeset
  1284
    }
hgs
parents:
diff changeset
  1285
hgs
parents:
diff changeset
  1286
hgs
parents:
diff changeset
  1287
CMemSpyThreadInfoHandleObjectBase::~CMemSpyThreadInfoHandleObjectBase()
hgs
parents:
diff changeset
  1288
    {
hgs
parents:
diff changeset
  1289
#ifdef _DEBUG
hgs
parents:
diff changeset
  1290
    RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::~CMemSpyThreadInfoHandleObjectBase() - this: 0x%08x", this );
hgs
parents:
diff changeset
  1291
#endif
hgs
parents:
diff changeset
  1292
    iInfoItems.Close();
hgs
parents:
diff changeset
  1293
    }
hgs
parents:
diff changeset
  1294
hgs
parents:
diff changeset
  1295
hgs
parents:
diff changeset
  1296
void CMemSpyThreadInfoHandleObjectBase::ConstructL()
hgs
parents:
diff changeset
  1297
    {
hgs
parents:
diff changeset
  1298
#ifdef _DEBUG
hgs
parents:
diff changeset
  1299
    RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::ConstructL() - START" );
hgs
parents:
diff changeset
  1300
#endif
hgs
parents:
diff changeset
  1301
    iInfoItems.Reset();
hgs
parents:
diff changeset
  1302
    //
hgs
parents:
diff changeset
  1303
    CMemSpyProcess& process = Container().Thread().Process();
hgs
parents:
diff changeset
  1304
    CMemSpyEngine& engine = process.Engine();
hgs
parents:
diff changeset
  1305
    engine.ProcessSuspendLC( process.Id() );
hgs
parents:
diff changeset
  1306
    //
hgs
parents:
diff changeset
  1307
    RArray<THandleWrapper> handles;
hgs
parents:
diff changeset
  1308
    CleanupClosePushL( handles );
hgs
parents:
diff changeset
  1309
    GetHandlesL( handles );
hgs
parents:
diff changeset
  1310
#ifdef _DEBUG
hgs
parents:
diff changeset
  1311
    RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::ConstructL() - got %d handle entries...", handles.Count() );
hgs
parents:
diff changeset
  1312
#endif
hgs
parents:
diff changeset
  1313
    //
hgs
parents:
diff changeset
  1314
    TFullName name;
hgs
parents:
diff changeset
  1315
    TMemSpyDriverHandleInfoGeneric info;
hgs
parents:
diff changeset
  1316
    //
hgs
parents:
diff changeset
  1317
    const TInt count = handles.Count();
hgs
parents:
diff changeset
  1318
    for (TInt i=0; i<count; i++)
hgs
parents:
diff changeset
  1319
    	{
hgs
parents:
diff changeset
  1320
    	const THandleWrapper& handleWrapper = handles[ i ];
hgs
parents:
diff changeset
  1321
        //
hgs
parents:
diff changeset
  1322
    	const TInt r = engine.Driver().GetGenericHandleInfo( Container().Thread().Id(), handleWrapper.iType, handleWrapper.iHandle, info );
hgs
parents:
diff changeset
  1323
        //
hgs
parents:
diff changeset
  1324
#ifdef _DEBUG
hgs
parents:
diff changeset
  1325
        RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::ConstructL() - handle[%3d] 0x%08x, type: %d, refCount: %d, r: %d", i, handleWrapper.iHandle, handleWrapper.iType, handleWrapper.iRefCount, r );
hgs
parents:
diff changeset
  1326
#endif
hgs
parents:
diff changeset
  1327
        //
hgs
parents:
diff changeset
  1328
        if  (r == KErrNone)
hgs
parents:
diff changeset
  1329
    		{
hgs
parents:
diff changeset
  1330
            name.Copy( info.iName );
hgs
parents:
diff changeset
  1331
#ifdef _DEBUG
hgs
parents:
diff changeset
  1332
            RDebug::Print( _L( "CMemSpyThreadInfoHandleObjectBase::ConstructL() - HANDLE [%3d] %S"), handleWrapper.iRefCount, &name );
hgs
parents:
diff changeset
  1333
#endif
hgs
parents:
diff changeset
  1334
            StripProcessAndThreadNames( name );
hgs
parents:
diff changeset
  1335
            //
hgs
parents:
diff changeset
  1336
            iInfoItems.AppendL( info );
hgs
parents:
diff changeset
  1337
            HandleContainerItemL( info, handleWrapper.iRefCount, name );
hgs
parents:
diff changeset
  1338
            }
hgs
parents:
diff changeset
  1339
     	}
hgs
parents:
diff changeset
  1340
hgs
parents:
diff changeset
  1341
    CleanupStack::PopAndDestroy( &handles );
hgs
parents:
diff changeset
  1342
    CleanupStack::PopAndDestroy(); // ProcessSuspendLC
hgs
parents:
diff changeset
  1343
hgs
parents:
diff changeset
  1344
    HandleAllItemsLocatedL();
hgs
parents:
diff changeset
  1345
hgs
parents:
diff changeset
  1346
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  1347
    }
hgs
parents:
diff changeset
  1348
hgs
parents:
diff changeset
  1349
hgs
parents:
diff changeset
  1350
TBool CMemSpyThreadInfoHandleObjectBase::THandleWrapper::Match( const THandleWrapper& aLeft, const THandleWrapper& aRight )
hgs
parents:
diff changeset
  1351
    {
hgs
parents:
diff changeset
  1352
    return ( aLeft.iHandle == aRight.iHandle );
hgs
parents:
diff changeset
  1353
    }
hgs
parents:
diff changeset
  1354
hgs
parents:
diff changeset
  1355
hgs
parents:
diff changeset
  1356
EXPORT_C TInt CMemSpyThreadInfoHandleObjectBase::DetailsIndexByEntry( const TMemSpyDriverHandleInfoGeneric& aEntry ) const
hgs
parents:
diff changeset
  1357
    {
hgs
parents:
diff changeset
  1358
#ifdef _DEBUG
hgs
parents:
diff changeset
  1359
    RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::DetailsIndexByEntry() - START - this: 0x%08x, aEntry.iHandle: 0x%08x", this, aEntry.iHandle );
hgs
parents:
diff changeset
  1360
#endif
hgs
parents:
diff changeset
  1361
    //
hgs
parents:
diff changeset
  1362
    const TInt ret = DetailsIndexByHandle( aEntry.iHandle );
hgs
parents:
diff changeset
  1363
    //
hgs
parents:
diff changeset
  1364
#ifdef _DEBUG
hgs
parents:
diff changeset
  1365
    RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::DetailsIndexByEntry() - END - ret: %d", ret );
hgs
parents:
diff changeset
  1366
#endif
hgs
parents:
diff changeset
  1367
    return ret;
hgs
parents:
diff changeset
  1368
    }
hgs
parents:
diff changeset
  1369
hgs
parents:
diff changeset
  1370
hgs
parents:
diff changeset
  1371
EXPORT_C TInt CMemSpyThreadInfoHandleObjectBase::DetailsIndexByHandle( TAny* aHandle ) const
hgs
parents:
diff changeset
  1372
    {
hgs
parents:
diff changeset
  1373
#ifdef _DEBUG
hgs
parents:
diff changeset
  1374
    RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::DetailsIndexByHandle() - START - this: 0x%08x, aHandle: 0x%08x", this, aHandle );
hgs
parents:
diff changeset
  1375
#endif
hgs
parents:
diff changeset
  1376
    TInt ret = KErrNotFound;
hgs
parents:
diff changeset
  1377
    //
hgs
parents:
diff changeset
  1378
    const TInt count = DetailsCount();
hgs
parents:
diff changeset
  1379
    for(TInt i=0; i<count; i++)
hgs
parents:
diff changeset
  1380
        {
hgs
parents:
diff changeset
  1381
        const TMemSpyDriverHandleInfoGeneric& item = DetailsAt( i );
hgs
parents:
diff changeset
  1382
        if  ( item.iHandle == aHandle )
hgs
parents:
diff changeset
  1383
            {
hgs
parents:
diff changeset
  1384
            ret = i;
hgs
parents:
diff changeset
  1385
            break;
hgs
parents:
diff changeset
  1386
            }
hgs
parents:
diff changeset
  1387
        }
hgs
parents:
diff changeset
  1388
    //
hgs
parents:
diff changeset
  1389
#ifdef _DEBUG
hgs
parents:
diff changeset
  1390
    RDebug::Printf( "CMemSpyThreadInfoHandleObjectBase::DetailsIndexByHandle() - END - ret: %d", ret );
hgs
parents:
diff changeset
  1391
#endif
hgs
parents:
diff changeset
  1392
    return ret;
hgs
parents:
diff changeset
  1393
    }
hgs
parents:
diff changeset
  1394
hgs
parents:
diff changeset
  1395
hgs
parents:
diff changeset
  1396
hgs
parents:
diff changeset
  1397
hgs
parents:
diff changeset
  1398
hgs
parents:
diff changeset
  1399
hgs
parents:
diff changeset
  1400
hgs
parents:
diff changeset
  1401
hgs
parents:
diff changeset
  1402
hgs
parents:
diff changeset
  1403
hgs
parents:
diff changeset
  1404
hgs
parents:
diff changeset
  1405
hgs
parents:
diff changeset
  1406
hgs
parents:
diff changeset
  1407
hgs
parents:
diff changeset
  1408
CMemSpyThreadInfoHandleByContainer::CMemSpyThreadInfoHandleByContainer( CMemSpyThreadInfoContainer& aContainer, TMemSpyThreadInfoItemType aItemType, TMemSpyDriverContainerType aContainerType, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1409
:   CMemSpyThreadInfoHandleObjectBase( aContainer, aItemType, aContainerType, aAsyncConstruction )
hgs
parents:
diff changeset
  1410
    {
hgs
parents:
diff changeset
  1411
    }
hgs
parents:
diff changeset
  1412
hgs
parents:
diff changeset
  1413
hgs
parents:
diff changeset
  1414
void CMemSpyThreadInfoHandleByContainer::GetHandlesL( RArray<THandleWrapper>& aArray )
hgs
parents:
diff changeset
  1415
    {
hgs
parents:
diff changeset
  1416
#ifdef _DEBUG
hgs
parents:
diff changeset
  1417
    RDebug::Printf( "CMemSpyThreadInfoHandleByContainer::GetHandlesL() - START - container: %d", ContainerType() );
hgs
parents:
diff changeset
  1418
#endif
hgs
parents:
diff changeset
  1419
hgs
parents:
diff changeset
  1420
    aArray.Reset();
hgs
parents:
diff changeset
  1421
hgs
parents:
diff changeset
  1422
    // Our handles will be stored here... duplicates are filtered out
hgs
parents:
diff changeset
  1423
    TInt r = KErrNone;
hgs
parents:
diff changeset
  1424
	TInt c = KMemSpyDefaultMaxHandleCount;
hgs
parents:
diff changeset
  1425
	TAny* handles[ KMemSpyDefaultMaxHandleCount ];
hgs
parents:
diff changeset
  1426
hgs
parents:
diff changeset
  1427
    CMemSpyProcess& process = Container().Thread().Process();
hgs
parents:
diff changeset
  1428
    CMemSpyEngine& engine = process.Engine();
hgs
parents:
diff changeset
  1429
    TIdentityRelation<CMemSpyThreadInfoHandleObjectBase::THandleWrapper> finder( THandleWrapper::Match );
hgs
parents:
diff changeset
  1430
hgs
parents:
diff changeset
  1431
    // First get the handles for the process
hgs
parents:
diff changeset
  1432
    if  ( r == KErrNone )
hgs
parents:
diff changeset
  1433
        {
hgs
parents:
diff changeset
  1434
        c = KMemSpyDefaultMaxHandleCount;
hgs
parents:
diff changeset
  1435
        r = engine.Driver().GetProcessHandlesByType( process.Id(), ContainerType(), handles, c );
hgs
parents:
diff changeset
  1436
        if  ( r == KErrNone && c > 0 )
hgs
parents:
diff changeset
  1437
    	    {
hgs
parents:
diff changeset
  1438
            c = Min( c, KMemSpyDefaultMaxHandleCount );
hgs
parents:
diff changeset
  1439
    	    for( TInt i=0; i<c; i++ )
hgs
parents:
diff changeset
  1440
    		    {
hgs
parents:
diff changeset
  1441
    		    TAny* handle = handles[ i ];
hgs
parents:
diff changeset
  1442
hgs
parents:
diff changeset
  1443
                // Create temporary entry that we'll use as the key in our array...
hgs
parents:
diff changeset
  1444
                CMemSpyThreadInfoHandleObjectBase::THandleWrapper entry( handle, ContainerType() );
hgs
parents:
diff changeset
  1445
                
hgs
parents:
diff changeset
  1446
                // Find existing duplicate entry (if there is one...)
hgs
parents:
diff changeset
  1447
                const TInt errorOrIndex = aArray.Find( entry, finder );
hgs
parents:
diff changeset
  1448
#ifdef _DEBUG
hgs
parents:
diff changeset
  1449
                RDebug::Printf( "CMemSpyThreadInfoHandleByContainer::GetHandlesL() - PROC[%03d/%03d] - handle: 0x%08x, foundIndex: %d", i+1, c, handle, errorOrIndex );
hgs
parents:
diff changeset
  1450
#endif
hgs
parents:
diff changeset
  1451
hgs
parents:
diff changeset
  1452
    		    if  ( errorOrIndex == KErrNotFound )
hgs
parents:
diff changeset
  1453
        		    {
hgs
parents:
diff changeset
  1454
        		    // Not a duplicate handle, so keep it
hgs
parents:
diff changeset
  1455
        		    aArray.AppendL( entry );
hgs
parents:
diff changeset
  1456
#ifdef _DEBUG
hgs
parents:
diff changeset
  1457
                    RDebug::Printf( "      new entry: 0x%08x", handle );
hgs
parents:
diff changeset
  1458
#endif
hgs
parents:
diff changeset
  1459
        		    }
hgs
parents:
diff changeset
  1460
                else if ( errorOrIndex >= 0 )
hgs
parents:
diff changeset
  1461
                    {
hgs
parents:
diff changeset
  1462
                    // Increment reference count for duplicates...
hgs
parents:
diff changeset
  1463
                    CMemSpyThreadInfoHandleObjectBase::THandleWrapper& existingEntry = aArray[ errorOrIndex ];
hgs
parents:
diff changeset
  1464
                    ++existingEntry.iRefCount;
hgs
parents:
diff changeset
  1465
#ifdef _DEBUG
hgs
parents:
diff changeset
  1466
                    RDebug::Printf( "      dupe entry - count is now: %d", existingEntry.iRefCount );
hgs
parents:
diff changeset
  1467
#endif
hgs
parents:
diff changeset
  1468
                    }
hgs
parents:
diff changeset
  1469
     		    }
hgs
parents:
diff changeset
  1470
            }
hgs
parents:
diff changeset
  1471
        }
hgs
parents:
diff changeset
  1472
hgs
parents:
diff changeset
  1473
    // Next get the handles for the thread
hgs
parents:
diff changeset
  1474
    if  ( r == KErrNone )
hgs
parents:
diff changeset
  1475
        {
hgs
parents:
diff changeset
  1476
        c = KMemSpyDefaultMaxHandleCount;
hgs
parents:
diff changeset
  1477
        r = engine.Driver().GetThreadHandlesByType( Container().Thread().Id(), ContainerType(), handles, c );
hgs
parents:
diff changeset
  1478
        if  ( r == KErrNone && c > 0 )
hgs
parents:
diff changeset
  1479
    	    {
hgs
parents:
diff changeset
  1480
            c = Min( c, KMemSpyDefaultMaxHandleCount );
hgs
parents:
diff changeset
  1481
    	    for( TInt i=0; i<c; i++ )
hgs
parents:
diff changeset
  1482
    		    {
hgs
parents:
diff changeset
  1483
    		    TAny* handle = handles[ i ];
hgs
parents:
diff changeset
  1484
hgs
parents:
diff changeset
  1485
                // Create temporary entry that we'll use as the key in our array...
hgs
parents:
diff changeset
  1486
                CMemSpyThreadInfoHandleObjectBase::THandleWrapper entry( handle, ContainerType() );
hgs
parents:
diff changeset
  1487
                
hgs
parents:
diff changeset
  1488
                // Find existing duplicate entry (if there is one...)
hgs
parents:
diff changeset
  1489
                const TInt errorOrIndex = aArray.Find( entry, finder );
hgs
parents:
diff changeset
  1490
#ifdef _DEBUG
hgs
parents:
diff changeset
  1491
                RDebug::Printf(  "CMemSpyThreadInfoHandleByContainer::GetHandlesL() - THRD[%03d/%03d] - handle: 0x%08x, foundIndex: %d", i+1, c, handle, errorOrIndex );
hgs
parents:
diff changeset
  1492
#endif
hgs
parents:
diff changeset
  1493
    		    
hgs
parents:
diff changeset
  1494
    		    if  ( errorOrIndex == KErrNotFound )
hgs
parents:
diff changeset
  1495
        		    {
hgs
parents:
diff changeset
  1496
        		    // Not a duplicate handle, so keep it
hgs
parents:
diff changeset
  1497
        		    aArray.AppendL( entry );
hgs
parents:
diff changeset
  1498
#ifdef _DEBUG
hgs
parents:
diff changeset
  1499
                    RDebug::Printf( "      new entry: 0x%08x", handle );
hgs
parents:
diff changeset
  1500
#endif
hgs
parents:
diff changeset
  1501
        		    }
hgs
parents:
diff changeset
  1502
                else if ( errorOrIndex >= 0 )
hgs
parents:
diff changeset
  1503
                    {
hgs
parents:
diff changeset
  1504
                    // Increment reference count for duplicates...
hgs
parents:
diff changeset
  1505
                    CMemSpyThreadInfoHandleObjectBase::THandleWrapper& existingEntry = aArray[ errorOrIndex ];
hgs
parents:
diff changeset
  1506
                    ++existingEntry.iRefCount;
hgs
parents:
diff changeset
  1507
#ifdef _DEBUG
hgs
parents:
diff changeset
  1508
                    RDebug::Printf( "      dupe entry - count is now: %d", existingEntry.iRefCount );
hgs
parents:
diff changeset
  1509
#endif
hgs
parents:
diff changeset
  1510
                    }
hgs
parents:
diff changeset
  1511
     		    }
hgs
parents:
diff changeset
  1512
            }
hgs
parents:
diff changeset
  1513
        }
hgs
parents:
diff changeset
  1514
hgs
parents:
diff changeset
  1515
#ifdef _DEBUG
hgs
parents:
diff changeset
  1516
    RDebug::Printf(  "CMemSpyThreadInfoHandleByContainer::GetHandlesL() - final handle listing: " );
hgs
parents:
diff changeset
  1517
hgs
parents:
diff changeset
  1518
    const TInt finalCount = aArray.Count();
hgs
parents:
diff changeset
  1519
    for( TInt i=0; i<finalCount; i++ )
hgs
parents:
diff changeset
  1520
        {
hgs
parents:
diff changeset
  1521
        const THandleWrapper& handle = aArray[ i ];
hgs
parents:
diff changeset
  1522
        RDebug::Printf(  "entry[%03d/%03d] - handle: 0x%08x, type: %d, refCount: %d", i+1, finalCount, handle.iHandle, handle.iType, handle.iRefCount );
hgs
parents:
diff changeset
  1523
        }
hgs
parents:
diff changeset
  1524
hgs
parents:
diff changeset
  1525
    RDebug::Printf( "CMemSpyThreadInfoHandleByContainer::GetHandlesL() - END - container: %d, finalCount: %d", ContainerType(), finalCount );
hgs
parents:
diff changeset
  1526
#endif
hgs
parents:
diff changeset
  1527
    }
hgs
parents:
diff changeset
  1528
hgs
parents:
diff changeset
  1529
hgs
parents:
diff changeset
  1530
hgs
parents:
diff changeset
  1531
hgs
parents:
diff changeset
  1532
hgs
parents:
diff changeset
  1533
hgs
parents:
diff changeset
  1534
hgs
parents:
diff changeset
  1535
hgs
parents:
diff changeset
  1536
hgs
parents:
diff changeset
  1537
hgs
parents:
diff changeset
  1538
hgs
parents:
diff changeset
  1539
hgs
parents:
diff changeset
  1540
hgs
parents:
diff changeset
  1541
hgs
parents:
diff changeset
  1542
hgs
parents:
diff changeset
  1543
hgs
parents:
diff changeset
  1544
hgs
parents:
diff changeset
  1545
hgs
parents:
diff changeset
  1546
hgs
parents:
diff changeset
  1547
hgs
parents:
diff changeset
  1548
hgs
parents:
diff changeset
  1549
hgs
parents:
diff changeset
  1550
hgs
parents:
diff changeset
  1551
hgs
parents:
diff changeset
  1552
hgs
parents:
diff changeset
  1553
hgs
parents:
diff changeset
  1554
hgs
parents:
diff changeset
  1555
hgs
parents:
diff changeset
  1556
hgs
parents:
diff changeset
  1557
hgs
parents:
diff changeset
  1558
hgs
parents:
diff changeset
  1559
hgs
parents:
diff changeset
  1560
hgs
parents:
diff changeset
  1561
hgs
parents:
diff changeset
  1562
hgs
parents:
diff changeset
  1563
hgs
parents:
diff changeset
  1564
hgs
parents:
diff changeset
  1565
hgs
parents:
diff changeset
  1566
hgs
parents:
diff changeset
  1567
hgs
parents:
diff changeset
  1568
hgs
parents:
diff changeset
  1569
hgs
parents:
diff changeset
  1570
hgs
parents:
diff changeset
  1571
hgs
parents:
diff changeset
  1572
hgs
parents:
diff changeset
  1573
hgs
parents:
diff changeset
  1574
hgs
parents:
diff changeset
  1575
hgs
parents:
diff changeset
  1576
hgs
parents:
diff changeset
  1577
CMemSpyThreadInfoServer::CMemSpyThreadInfoServer( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1578
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeServer, EMemSpyDriverContainerTypeServer, aAsyncConstruction )
hgs
parents:
diff changeset
  1579
    {
hgs
parents:
diff changeset
  1580
    }
hgs
parents:
diff changeset
  1581
hgs
parents:
diff changeset
  1582
hgs
parents:
diff changeset
  1583
CMemSpyThreadInfoServer* CMemSpyThreadInfoServer::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1584
    {
hgs
parents:
diff changeset
  1585
    CMemSpyThreadInfoServer* self = new(ELeave) CMemSpyThreadInfoServer( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1586
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1587
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1588
        {
hgs
parents:
diff changeset
  1589
        self->ConstructL();
hgs
parents:
diff changeset
  1590
        }
hgs
parents:
diff changeset
  1591
    return self;
hgs
parents:
diff changeset
  1592
    }
hgs
parents:
diff changeset
  1593
hgs
parents:
diff changeset
  1594
hgs
parents:
diff changeset
  1595
EXPORT_C TPtrC CMemSpyThreadInfoServer::Name() const
hgs
parents:
diff changeset
  1596
    {
hgs
parents:
diff changeset
  1597
    _LIT(KName, "\tServers Running in Thread");
hgs
parents:
diff changeset
  1598
    return TPtrC( KName );
hgs
parents:
diff changeset
  1599
    }
hgs
parents:
diff changeset
  1600
hgs
parents:
diff changeset
  1601
hgs
parents:
diff changeset
  1602
void CMemSpyThreadInfoServer::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& /*aItem*/, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  1603
    {
hgs
parents:
diff changeset
  1604
    AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  1605
    }
hgs
parents:
diff changeset
  1606
hgs
parents:
diff changeset
  1607
hgs
parents:
diff changeset
  1608
EXPORT_C TPtrC CMemSpyThreadInfoServer::SessionType( TIpcSessionType aType )
hgs
parents:
diff changeset
  1609
    {
hgs
parents:
diff changeset
  1610
    _LIT( KUnsharable, "Unsharable" );
hgs
parents:
diff changeset
  1611
    _LIT( KSharable, "Sharable" );
hgs
parents:
diff changeset
  1612
    _LIT( KGlobalSharable, "Global Sharable" );
hgs
parents:
diff changeset
  1613
    //
hgs
parents:
diff changeset
  1614
    TPtrC pType(KNullDesC);
hgs
parents:
diff changeset
  1615
    switch( aType )
hgs
parents:
diff changeset
  1616
        {
hgs
parents:
diff changeset
  1617
    case EIpcSession_Unsharable:
hgs
parents:
diff changeset
  1618
        pType.Set( KUnsharable );
hgs
parents:
diff changeset
  1619
        break;
hgs
parents:
diff changeset
  1620
    case EIpcSession_Sharable:
hgs
parents:
diff changeset
  1621
        pType.Set( KSharable );
hgs
parents:
diff changeset
  1622
        break;
hgs
parents:
diff changeset
  1623
    case EIpcSession_GlobalSharable:
hgs
parents:
diff changeset
  1624
        pType.Set( KGlobalSharable );
hgs
parents:
diff changeset
  1625
        break;
hgs
parents:
diff changeset
  1626
    default:
hgs
parents:
diff changeset
  1627
        pType.Set( KMemSpyUnavailable );
hgs
parents:
diff changeset
  1628
        break;
hgs
parents:
diff changeset
  1629
        }
hgs
parents:
diff changeset
  1630
    //
hgs
parents:
diff changeset
  1631
    return pType;
hgs
parents:
diff changeset
  1632
    }
hgs
parents:
diff changeset
  1633
hgs
parents:
diff changeset
  1634
hgs
parents:
diff changeset
  1635
hgs
parents:
diff changeset
  1636
hgs
parents:
diff changeset
  1637
hgs
parents:
diff changeset
  1638
hgs
parents:
diff changeset
  1639
hgs
parents:
diff changeset
  1640
hgs
parents:
diff changeset
  1641
hgs
parents:
diff changeset
  1642
hgs
parents:
diff changeset
  1643
hgs
parents:
diff changeset
  1644
hgs
parents:
diff changeset
  1645
hgs
parents:
diff changeset
  1646
hgs
parents:
diff changeset
  1647
hgs
parents:
diff changeset
  1648
hgs
parents:
diff changeset
  1649
hgs
parents:
diff changeset
  1650
hgs
parents:
diff changeset
  1651
hgs
parents:
diff changeset
  1652
hgs
parents:
diff changeset
  1653
hgs
parents:
diff changeset
  1654
hgs
parents:
diff changeset
  1655
hgs
parents:
diff changeset
  1656
hgs
parents:
diff changeset
  1657
CMemSpyThreadInfoSession::CMemSpyThreadInfoSession( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1658
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeSession, EMemSpyDriverContainerTypeSession, aAsyncConstruction )
hgs
parents:
diff changeset
  1659
    {
hgs
parents:
diff changeset
  1660
    }
hgs
parents:
diff changeset
  1661
hgs
parents:
diff changeset
  1662
hgs
parents:
diff changeset
  1663
CMemSpyThreadInfoSession::~CMemSpyThreadInfoSession()
hgs
parents:
diff changeset
  1664
    {
hgs
parents:
diff changeset
  1665
    iServerNames.ResetAndDestroy();
hgs
parents:
diff changeset
  1666
    iServerNames.Close();
hgs
parents:
diff changeset
  1667
    }
hgs
parents:
diff changeset
  1668
hgs
parents:
diff changeset
  1669
hgs
parents:
diff changeset
  1670
CMemSpyThreadInfoSession* CMemSpyThreadInfoSession::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1671
    {
hgs
parents:
diff changeset
  1672
    CMemSpyThreadInfoSession* self = new(ELeave) CMemSpyThreadInfoSession( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1673
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1674
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1675
        {
hgs
parents:
diff changeset
  1676
        self->ConstructL();
hgs
parents:
diff changeset
  1677
        }
hgs
parents:
diff changeset
  1678
    return self;
hgs
parents:
diff changeset
  1679
    }
hgs
parents:
diff changeset
  1680
hgs
parents:
diff changeset
  1681
hgs
parents:
diff changeset
  1682
EXPORT_C TPtrC CMemSpyThreadInfoSession::Name() const
hgs
parents:
diff changeset
  1683
    {
hgs
parents:
diff changeset
  1684
    _LIT(KName, "\tClient <-> Server\nConnections");
hgs
parents:
diff changeset
  1685
    return TPtrC( KName );
hgs
parents:
diff changeset
  1686
    }
hgs
parents:
diff changeset
  1687
hgs
parents:
diff changeset
  1688
hgs
parents:
diff changeset
  1689
void CMemSpyThreadInfoSession::Reset()
hgs
parents:
diff changeset
  1690
    {
hgs
parents:
diff changeset
  1691
    CMemSpyThreadInfoHandleByContainer::Reset();
hgs
parents:
diff changeset
  1692
    iServerNames.ResetAndDestroy();
hgs
parents:
diff changeset
  1693
    }
hgs
parents:
diff changeset
  1694
hgs
parents:
diff changeset
  1695
hgs
parents:
diff changeset
  1696
EXPORT_C TInt CMemSpyThreadInfoSession::ConnectionCount( const TDesC& aName ) const
hgs
parents:
diff changeset
  1697
    {
hgs
parents:
diff changeset
  1698
    TInt ret = 0;
hgs
parents:
diff changeset
  1699
hgs
parents:
diff changeset
  1700
#ifdef _DEBUG
hgs
parents:
diff changeset
  1701
    RDebug::Print( _L("CMemSpyThreadInfoSession::ConnectionCount() - START - aName: %S"), &aName );
hgs
parents:
diff changeset
  1702
#endif
hgs
parents:
diff changeset
  1703
hgs
parents:
diff changeset
  1704
    // See if we have an entry with that name...
hgs
parents:
diff changeset
  1705
    TInt foundIndex = 0;
hgs
parents:
diff changeset
  1706
    TRAP(ret, foundIndex = FindServerL(aName));
hgs
parents:
diff changeset
  1707
    
hgs
parents:
diff changeset
  1708
    if (ret == KErrNone)
hgs
parents:
diff changeset
  1709
        {
hgs
parents:
diff changeset
  1710
        // If we did, get the count
hgs
parents:
diff changeset
  1711
        if  ( foundIndex >=0 && foundIndex < iServerNames.Count() )
hgs
parents:
diff changeset
  1712
            {
hgs
parents:
diff changeset
  1713
            ret = iServerNames[ foundIndex ]->iCount;
hgs
parents:
diff changeset
  1714
            }
hgs
parents:
diff changeset
  1715
        }
hgs
parents:
diff changeset
  1716
hgs
parents:
diff changeset
  1717
#ifdef _DEBUG
hgs
parents:
diff changeset
  1718
    RDebug::Printf( "CMemSpyThreadInfoSession::ConnectionCount() - END - ret: %d", ret );
hgs
parents:
diff changeset
  1719
#endif
hgs
parents:
diff changeset
  1720
    //
hgs
parents:
diff changeset
  1721
    return ret;
hgs
parents:
diff changeset
  1722
    }
hgs
parents:
diff changeset
  1723
hgs
parents:
diff changeset
  1724
TInt CMemSpyThreadInfoSession::FindServerL( const TDesC& aName ) const
hgs
parents:
diff changeset
  1725
    {
hgs
parents:
diff changeset
  1726
    TIdentityRelation<CSessionInfoEntry> comparer( CompareEntries );
hgs
parents:
diff changeset
  1727
    HBufC* name = aName.AllocLC();
hgs
parents:
diff changeset
  1728
    CSessionInfoEntry* entry = new(ELeave) CSessionInfoEntry( name );
hgs
parents:
diff changeset
  1729
    CleanupStack::Pop( name ); // don't destroy it as name is now owned by entry 
hgs
parents:
diff changeset
  1730
    CleanupStack::PushL( entry );
hgs
parents:
diff changeset
  1731
    const TInt foundIndex = iServerNames.Find( entry, comparer );
hgs
parents:
diff changeset
  1732
    User::LeaveIfError(foundIndex); // so we only return a real index
hgs
parents:
diff changeset
  1733
    CleanupStack::PopAndDestroy( entry );
hgs
parents:
diff changeset
  1734
    return foundIndex;
hgs
parents:
diff changeset
  1735
    }
hgs
parents:
diff changeset
  1736
hgs
parents:
diff changeset
  1737
void CMemSpyThreadInfoSession::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  1738
    {
hgs
parents:
diff changeset
  1739
    // Check whether we have the item already
hgs
parents:
diff changeset
  1740
    TIdentityRelation<CSessionInfoEntry> comparer( CompareEntries );
hgs
parents:
diff changeset
  1741
hgs
parents:
diff changeset
  1742
    // Prepare object, just in case we don't find it...
hgs
parents:
diff changeset
  1743
    HBufC* name = aFullName.AllocLC();
hgs
parents:
diff changeset
  1744
hgs
parents:
diff changeset
  1745
#ifdef _DEBUG
hgs
parents:
diff changeset
  1746
    TBuf<KMaxName> origName; origName.Copy( aItem.iName );
hgs
parents:
diff changeset
  1747
    RDebug::Print( _L("CMemSpyThreadInfoSession::HandleContainerItemL() - START - handle: 0x%08x, type: %d, origName: %S, modName: %S"), aItem.iHandle, aItem.iType, &origName, name );
hgs
parents:
diff changeset
  1748
#else
hgs
parents:
diff changeset
  1749
    (void) aItem;
hgs
parents:
diff changeset
  1750
#endif
hgs
parents:
diff changeset
  1751
hgs
parents:
diff changeset
  1752
    CSessionInfoEntry* entry = new(ELeave) CSessionInfoEntry( name );
hgs
parents:
diff changeset
  1753
    CleanupStack::Pop( name );
hgs
parents:
diff changeset
  1754
    CleanupStack::PushL( entry );
hgs
parents:
diff changeset
  1755
hgs
parents:
diff changeset
  1756
    // Search
hgs
parents:
diff changeset
  1757
    const TInt foundIndex = iServerNames.Find( entry, comparer );
hgs
parents:
diff changeset
  1758
    if  ( foundIndex == KErrNotFound )
hgs
parents:
diff changeset
  1759
        {
hgs
parents:
diff changeset
  1760
        // Make new entry
hgs
parents:
diff changeset
  1761
        iServerNames.AppendL( entry );
hgs
parents:
diff changeset
  1762
        CleanupStack::Pop( entry );
hgs
parents:
diff changeset
  1763
        }
hgs
parents:
diff changeset
  1764
    else if ( foundIndex >= 0 )
hgs
parents:
diff changeset
  1765
        {
hgs
parents:
diff changeset
  1766
        // Existing entry, increment count
hgs
parents:
diff changeset
  1767
        CleanupStack::PopAndDestroy( entry );
hgs
parents:
diff changeset
  1768
        entry = iServerNames[ foundIndex ];
hgs
parents:
diff changeset
  1769
        ++entry->iCount;
hgs
parents:
diff changeset
  1770
        }
hgs
parents:
diff changeset
  1771
    else
hgs
parents:
diff changeset
  1772
        {
hgs
parents:
diff changeset
  1773
        CleanupStack::PopAndDestroy( entry );
hgs
parents:
diff changeset
  1774
        }
hgs
parents:
diff changeset
  1775
 
hgs
parents:
diff changeset
  1776
#ifdef _DEBUG
hgs
parents:
diff changeset
  1777
    RDebug::Printf( "CMemSpyThreadInfoSession::HandleContainerItemL() - END - foundIndex: %d", foundIndex );
hgs
parents:
diff changeset
  1778
#endif
hgs
parents:
diff changeset
  1779
    }
hgs
parents:
diff changeset
  1780
hgs
parents:
diff changeset
  1781
hgs
parents:
diff changeset
  1782
void CMemSpyThreadInfoSession::HandleAllItemsLocatedL()
hgs
parents:
diff changeset
  1783
    {
hgs
parents:
diff changeset
  1784
    _LIT(KSecondLineFormatStringCount1, "1 connection");
hgs
parents:
diff changeset
  1785
    _LIT(KSecondLineFormatStringCountMoreThanOne, "%d connections");
hgs
parents:
diff changeset
  1786
    TBuf<50> buf;
hgs
parents:
diff changeset
  1787
hgs
parents:
diff changeset
  1788
    // All items have been found, now create listbox entries
hgs
parents:
diff changeset
  1789
    const TInt count = iServerNames.Count();
hgs
parents:
diff changeset
  1790
    for( TInt i=0; i<count; i++ )
hgs
parents:
diff changeset
  1791
        {
hgs
parents:
diff changeset
  1792
        CSessionInfoEntry* entry = iServerNames[ i ];
hgs
parents:
diff changeset
  1793
hgs
parents:
diff changeset
  1794
        if  ( entry->iCount == 1 )
hgs
parents:
diff changeset
  1795
            {
hgs
parents:
diff changeset
  1796
            buf.Copy( KSecondLineFormatStringCount1 );
hgs
parents:
diff changeset
  1797
            }
hgs
parents:
diff changeset
  1798
        else
hgs
parents:
diff changeset
  1799
            {
hgs
parents:
diff changeset
  1800
            buf.Format( KSecondLineFormatStringCountMoreThanOne, entry->iCount );
hgs
parents:
diff changeset
  1801
            }
hgs
parents:
diff changeset
  1802
hgs
parents:
diff changeset
  1803
        AddItemL( *entry->iName, buf );
hgs
parents:
diff changeset
  1804
        }
hgs
parents:
diff changeset
  1805
    }
hgs
parents:
diff changeset
  1806
hgs
parents:
diff changeset
  1807
hgs
parents:
diff changeset
  1808
TBool CMemSpyThreadInfoSession::CompareEntries( const CSessionInfoEntry& aLeft, const CSessionInfoEntry& aRight )
hgs
parents:
diff changeset
  1809
    {
hgs
parents:
diff changeset
  1810
    return ( aLeft.iName->CompareF( *aRight.iName ) == 0 );
hgs
parents:
diff changeset
  1811
    }
hgs
parents:
diff changeset
  1812
hgs
parents:
diff changeset
  1813
hgs
parents:
diff changeset
  1814
hgs
parents:
diff changeset
  1815
hgs
parents:
diff changeset
  1816
hgs
parents:
diff changeset
  1817
hgs
parents:
diff changeset
  1818
hgs
parents:
diff changeset
  1819
hgs
parents:
diff changeset
  1820
hgs
parents:
diff changeset
  1821
hgs
parents:
diff changeset
  1822
hgs
parents:
diff changeset
  1823
hgs
parents:
diff changeset
  1824
hgs
parents:
diff changeset
  1825
hgs
parents:
diff changeset
  1826
hgs
parents:
diff changeset
  1827
hgs
parents:
diff changeset
  1828
hgs
parents:
diff changeset
  1829
hgs
parents:
diff changeset
  1830
hgs
parents:
diff changeset
  1831
hgs
parents:
diff changeset
  1832
hgs
parents:
diff changeset
  1833
hgs
parents:
diff changeset
  1834
hgs
parents:
diff changeset
  1835
hgs
parents:
diff changeset
  1836
hgs
parents:
diff changeset
  1837
hgs
parents:
diff changeset
  1838
CMemSpyThreadInfoSemaphore::CMemSpyThreadInfoSemaphore( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1839
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeSemaphore, EMemSpyDriverContainerTypeSemaphore, aAsyncConstruction )
hgs
parents:
diff changeset
  1840
    {
hgs
parents:
diff changeset
  1841
    }
hgs
parents:
diff changeset
  1842
hgs
parents:
diff changeset
  1843
hgs
parents:
diff changeset
  1844
CMemSpyThreadInfoSemaphore* CMemSpyThreadInfoSemaphore::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1845
    {
hgs
parents:
diff changeset
  1846
    CMemSpyThreadInfoSemaphore* self = new(ELeave) CMemSpyThreadInfoSemaphore( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1847
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1848
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1849
        {
hgs
parents:
diff changeset
  1850
        self->ConstructL();
hgs
parents:
diff changeset
  1851
        }
hgs
parents:
diff changeset
  1852
    return self;
hgs
parents:
diff changeset
  1853
    }
hgs
parents:
diff changeset
  1854
hgs
parents:
diff changeset
  1855
hgs
parents:
diff changeset
  1856
EXPORT_C TPtrC CMemSpyThreadInfoSemaphore::Name() const
hgs
parents:
diff changeset
  1857
    {
hgs
parents:
diff changeset
  1858
    _LIT(KName, "\tSemaphores");
hgs
parents:
diff changeset
  1859
    return TPtrC( KName );
hgs
parents:
diff changeset
  1860
    }
hgs
parents:
diff changeset
  1861
hgs
parents:
diff changeset
  1862
hgs
parents:
diff changeset
  1863
void CMemSpyThreadInfoSemaphore::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  1864
    {
hgs
parents:
diff changeset
  1865
    _LIT( KFormatSpec, "Count: %d" );
hgs
parents:
diff changeset
  1866
    TBuf<50> buf;
hgs
parents:
diff changeset
  1867
    buf.AppendFormat( KFormatSpec, aItem.iCount );
hgs
parents:
diff changeset
  1868
hgs
parents:
diff changeset
  1869
    AddItemL( aFullName, buf );
hgs
parents:
diff changeset
  1870
    }
hgs
parents:
diff changeset
  1871
hgs
parents:
diff changeset
  1872
hgs
parents:
diff changeset
  1873
hgs
parents:
diff changeset
  1874
hgs
parents:
diff changeset
  1875
hgs
parents:
diff changeset
  1876
hgs
parents:
diff changeset
  1877
hgs
parents:
diff changeset
  1878
hgs
parents:
diff changeset
  1879
hgs
parents:
diff changeset
  1880
hgs
parents:
diff changeset
  1881
hgs
parents:
diff changeset
  1882
hgs
parents:
diff changeset
  1883
hgs
parents:
diff changeset
  1884
hgs
parents:
diff changeset
  1885
hgs
parents:
diff changeset
  1886
hgs
parents:
diff changeset
  1887
hgs
parents:
diff changeset
  1888
hgs
parents:
diff changeset
  1889
hgs
parents:
diff changeset
  1890
hgs
parents:
diff changeset
  1891
hgs
parents:
diff changeset
  1892
hgs
parents:
diff changeset
  1893
hgs
parents:
diff changeset
  1894
hgs
parents:
diff changeset
  1895
CMemSpyThreadInfoMutex::CMemSpyThreadInfoMutex( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1896
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeMutex, EMemSpyDriverContainerTypeMutex, aAsyncConstruction )
hgs
parents:
diff changeset
  1897
    {
hgs
parents:
diff changeset
  1898
    }
hgs
parents:
diff changeset
  1899
hgs
parents:
diff changeset
  1900
hgs
parents:
diff changeset
  1901
CMemSpyThreadInfoMutex* CMemSpyThreadInfoMutex::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1902
    {
hgs
parents:
diff changeset
  1903
    CMemSpyThreadInfoMutex* self = new(ELeave) CMemSpyThreadInfoMutex( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1904
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1905
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1906
        {
hgs
parents:
diff changeset
  1907
        self->ConstructL();
hgs
parents:
diff changeset
  1908
        }
hgs
parents:
diff changeset
  1909
    return self;
hgs
parents:
diff changeset
  1910
    }
hgs
parents:
diff changeset
  1911
hgs
parents:
diff changeset
  1912
hgs
parents:
diff changeset
  1913
EXPORT_C TPtrC CMemSpyThreadInfoMutex::Name() const
hgs
parents:
diff changeset
  1914
    {
hgs
parents:
diff changeset
  1915
    _LIT(KName, "\tMutexes");
hgs
parents:
diff changeset
  1916
    return TPtrC( KName );
hgs
parents:
diff changeset
  1917
    }
hgs
parents:
diff changeset
  1918
hgs
parents:
diff changeset
  1919
hgs
parents:
diff changeset
  1920
void CMemSpyThreadInfoMutex::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  1921
    {
hgs
parents:
diff changeset
  1922
    _LIT( KFormatSpec, "Count: %d" );
hgs
parents:
diff changeset
  1923
    TBuf<50> buf;
hgs
parents:
diff changeset
  1924
    buf.AppendFormat( KFormatSpec, aItem.iCount );
hgs
parents:
diff changeset
  1925
hgs
parents:
diff changeset
  1926
    AddItemL( aFullName, buf );
hgs
parents:
diff changeset
  1927
    }
hgs
parents:
diff changeset
  1928
hgs
parents:
diff changeset
  1929
hgs
parents:
diff changeset
  1930
hgs
parents:
diff changeset
  1931
hgs
parents:
diff changeset
  1932
hgs
parents:
diff changeset
  1933
hgs
parents:
diff changeset
  1934
hgs
parents:
diff changeset
  1935
hgs
parents:
diff changeset
  1936
hgs
parents:
diff changeset
  1937
hgs
parents:
diff changeset
  1938
hgs
parents:
diff changeset
  1939
hgs
parents:
diff changeset
  1940
hgs
parents:
diff changeset
  1941
hgs
parents:
diff changeset
  1942
hgs
parents:
diff changeset
  1943
hgs
parents:
diff changeset
  1944
hgs
parents:
diff changeset
  1945
hgs
parents:
diff changeset
  1946
hgs
parents:
diff changeset
  1947
hgs
parents:
diff changeset
  1948
hgs
parents:
diff changeset
  1949
hgs
parents:
diff changeset
  1950
hgs
parents:
diff changeset
  1951
hgs
parents:
diff changeset
  1952
CMemSpyThreadInfoTimer::CMemSpyThreadInfoTimer( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1953
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeTimer, EMemSpyDriverContainerTypeTimer, aAsyncConstruction )
hgs
parents:
diff changeset
  1954
    {
hgs
parents:
diff changeset
  1955
    }
hgs
parents:
diff changeset
  1956
hgs
parents:
diff changeset
  1957
hgs
parents:
diff changeset
  1958
CMemSpyThreadInfoTimer* CMemSpyThreadInfoTimer::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  1959
    {
hgs
parents:
diff changeset
  1960
    CMemSpyThreadInfoTimer* self = new(ELeave) CMemSpyThreadInfoTimer( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  1961
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  1962
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  1963
        {
hgs
parents:
diff changeset
  1964
        self->ConstructL();
hgs
parents:
diff changeset
  1965
        }
hgs
parents:
diff changeset
  1966
    return self;
hgs
parents:
diff changeset
  1967
    }
hgs
parents:
diff changeset
  1968
hgs
parents:
diff changeset
  1969
hgs
parents:
diff changeset
  1970
EXPORT_C TPtrC CMemSpyThreadInfoTimer::Name() const
hgs
parents:
diff changeset
  1971
    {
hgs
parents:
diff changeset
  1972
    _LIT(KName, "\tTimers");
hgs
parents:
diff changeset
  1973
    return TPtrC( KName );
hgs
parents:
diff changeset
  1974
    }
hgs
parents:
diff changeset
  1975
hgs
parents:
diff changeset
  1976
hgs
parents:
diff changeset
  1977
void CMemSpyThreadInfoTimer::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt /*aRefCount*/, TDes& /*aFullName*/ )
hgs
parents:
diff changeset
  1978
    {
hgs
parents:
diff changeset
  1979
    // Get useful strings
hgs
parents:
diff changeset
  1980
    TBuf<20> state;
hgs
parents:
diff changeset
  1981
    GetTimerState( aItem.iTimerState, state );
hgs
parents:
diff changeset
  1982
    TBuf<20> type;
hgs
parents:
diff changeset
  1983
    GetTimerType( aItem.iTimerType, type );
hgs
parents:
diff changeset
  1984
hgs
parents:
diff changeset
  1985
    AddItemL( type, state );
hgs
parents:
diff changeset
  1986
    }
hgs
parents:
diff changeset
  1987
hgs
parents:
diff changeset
  1988
hgs
parents:
diff changeset
  1989
void CMemSpyThreadInfoTimer::GetTimerState( TMemSpyDriverTimerState aState, TDes& aBuf )
hgs
parents:
diff changeset
  1990
    {
hgs
parents:
diff changeset
  1991
    switch( aState )
hgs
parents:
diff changeset
  1992
        {
hgs
parents:
diff changeset
  1993
    default:
hgs
parents:
diff changeset
  1994
    case EMemSpyDriverTimerStateUnknown: 
hgs
parents:
diff changeset
  1995
        {
hgs
parents:
diff changeset
  1996
        _LIT(KStateUnknown, "Unknown");
hgs
parents:
diff changeset
  1997
        aBuf.Copy( KStateUnknown );
hgs
parents:
diff changeset
  1998
        }
hgs
parents:
diff changeset
  1999
        break;
hgs
parents:
diff changeset
  2000
    case EMemSpyDriverTimerStateIdle:
hgs
parents:
diff changeset
  2001
        {
hgs
parents:
diff changeset
  2002
        _LIT(KStateIdle, "Idle");
hgs
parents:
diff changeset
  2003
        aBuf.Copy( KStateIdle );
hgs
parents:
diff changeset
  2004
        }
hgs
parents:
diff changeset
  2005
        break;
hgs
parents:
diff changeset
  2006
    case EMemSpyDriverTimerStateWaiting: 
hgs
parents:
diff changeset
  2007
        {
hgs
parents:
diff changeset
  2008
        _LIT(KStateWaiting, "Waiting");
hgs
parents:
diff changeset
  2009
        aBuf.Copy( KStateWaiting );
hgs
parents:
diff changeset
  2010
        }
hgs
parents:
diff changeset
  2011
        break;
hgs
parents:
diff changeset
  2012
    case EMemSpyDriverTimerStateWaitHighRes: 
hgs
parents:
diff changeset
  2013
        {
hgs
parents:
diff changeset
  2014
        _LIT(KStateWaitHighRes, "Waiting, High Res.");
hgs
parents:
diff changeset
  2015
        aBuf.Copy( KStateWaitHighRes );
hgs
parents:
diff changeset
  2016
        }
hgs
parents:
diff changeset
  2017
        break;
hgs
parents:
diff changeset
  2018
        }
hgs
parents:
diff changeset
  2019
    }
hgs
parents:
diff changeset
  2020
hgs
parents:
diff changeset
  2021
hgs
parents:
diff changeset
  2022
void CMemSpyThreadInfoTimer::GetTimerType( TMemSpyDriverTimerType aType, TDes& aBuf )
hgs
parents:
diff changeset
  2023
    {
hgs
parents:
diff changeset
  2024
    switch( aType )
hgs
parents:
diff changeset
  2025
        {
hgs
parents:
diff changeset
  2026
    case EMemSpyDriverTimerTypeRelative:
hgs
parents:
diff changeset
  2027
        {
hgs
parents:
diff changeset
  2028
        _LIT( KType, "Relative" );
hgs
parents:
diff changeset
  2029
        aBuf.Copy( KType );
hgs
parents:
diff changeset
  2030
        }
hgs
parents:
diff changeset
  2031
        break;
hgs
parents:
diff changeset
  2032
    case EMemSpyDriverTimerTypeAbsolute:
hgs
parents:
diff changeset
  2033
        {
hgs
parents:
diff changeset
  2034
        _LIT( KType, "Absolute" );
hgs
parents:
diff changeset
  2035
        aBuf.Copy( KType );
hgs
parents:
diff changeset
  2036
        }
hgs
parents:
diff changeset
  2037
        break;
hgs
parents:
diff changeset
  2038
    case EMemSpyDriverTimerTypeHighRes:
hgs
parents:
diff changeset
  2039
        {
hgs
parents:
diff changeset
  2040
        _LIT( KType, "High Res." );
hgs
parents:
diff changeset
  2041
        aBuf.Copy( KType );
hgs
parents:
diff changeset
  2042
        }
hgs
parents:
diff changeset
  2043
        break;
hgs
parents:
diff changeset
  2044
    case EMemSpyDriverTimerTypeInactivity:
hgs
parents:
diff changeset
  2045
        {
hgs
parents:
diff changeset
  2046
        _LIT( KType, "Inactivity" );
hgs
parents:
diff changeset
  2047
        aBuf.Copy( KType );
hgs
parents:
diff changeset
  2048
        }
hgs
parents:
diff changeset
  2049
        break;
hgs
parents:
diff changeset
  2050
    default:
hgs
parents:
diff changeset
  2051
        {
hgs
parents:
diff changeset
  2052
        _LIT( KType, "Unknown" );
hgs
parents:
diff changeset
  2053
        aBuf.Copy( KType );
hgs
parents:
diff changeset
  2054
        }
hgs
parents:
diff changeset
  2055
        break;
hgs
parents:
diff changeset
  2056
        }
hgs
parents:
diff changeset
  2057
    }
hgs
parents:
diff changeset
  2058
hgs
parents:
diff changeset
  2059
hgs
parents:
diff changeset
  2060
hgs
parents:
diff changeset
  2061
hgs
parents:
diff changeset
  2062
hgs
parents:
diff changeset
  2063
hgs
parents:
diff changeset
  2064
hgs
parents:
diff changeset
  2065
hgs
parents:
diff changeset
  2066
hgs
parents:
diff changeset
  2067
hgs
parents:
diff changeset
  2068
hgs
parents:
diff changeset
  2069
hgs
parents:
diff changeset
  2070
hgs
parents:
diff changeset
  2071
hgs
parents:
diff changeset
  2072
hgs
parents:
diff changeset
  2073
hgs
parents:
diff changeset
  2074
hgs
parents:
diff changeset
  2075
hgs
parents:
diff changeset
  2076
hgs
parents:
diff changeset
  2077
CMemSpyThreadInfoLDD::CMemSpyThreadInfoLDD( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2078
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeLDD, EMemSpyDriverContainerTypeLogicalDevice, aAsyncConstruction )
hgs
parents:
diff changeset
  2079
    {
hgs
parents:
diff changeset
  2080
    }
hgs
parents:
diff changeset
  2081
hgs
parents:
diff changeset
  2082
hgs
parents:
diff changeset
  2083
CMemSpyThreadInfoLDD* CMemSpyThreadInfoLDD::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2084
    {
hgs
parents:
diff changeset
  2085
    CMemSpyThreadInfoLDD* self = new(ELeave) CMemSpyThreadInfoLDD( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2086
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2087
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2088
        {
hgs
parents:
diff changeset
  2089
        self->ConstructL();
hgs
parents:
diff changeset
  2090
        }
hgs
parents:
diff changeset
  2091
    return self;
hgs
parents:
diff changeset
  2092
    }
hgs
parents:
diff changeset
  2093
hgs
parents:
diff changeset
  2094
hgs
parents:
diff changeset
  2095
EXPORT_C TPtrC CMemSpyThreadInfoLDD::Name() const
hgs
parents:
diff changeset
  2096
    {
hgs
parents:
diff changeset
  2097
    _LIT(KName, "\tLogical Device Drivers");
hgs
parents:
diff changeset
  2098
    return TPtrC( KName );
hgs
parents:
diff changeset
  2099
    }
hgs
parents:
diff changeset
  2100
hgs
parents:
diff changeset
  2101
hgs
parents:
diff changeset
  2102
void CMemSpyThreadInfoLDD::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  2103
    {
hgs
parents:
diff changeset
  2104
    _LIT( KFormatSpec, "Open channels: %d" );
hgs
parents:
diff changeset
  2105
    TBuf<50> buf;
hgs
parents:
diff changeset
  2106
    buf.AppendFormat( KFormatSpec, aItem.iOpenChannels );
hgs
parents:
diff changeset
  2107
hgs
parents:
diff changeset
  2108
    AddItemL( aFullName, buf );
hgs
parents:
diff changeset
  2109
    }
hgs
parents:
diff changeset
  2110
hgs
parents:
diff changeset
  2111
hgs
parents:
diff changeset
  2112
hgs
parents:
diff changeset
  2113
hgs
parents:
diff changeset
  2114
hgs
parents:
diff changeset
  2115
hgs
parents:
diff changeset
  2116
hgs
parents:
diff changeset
  2117
hgs
parents:
diff changeset
  2118
hgs
parents:
diff changeset
  2119
hgs
parents:
diff changeset
  2120
hgs
parents:
diff changeset
  2121
hgs
parents:
diff changeset
  2122
hgs
parents:
diff changeset
  2123
hgs
parents:
diff changeset
  2124
hgs
parents:
diff changeset
  2125
hgs
parents:
diff changeset
  2126
hgs
parents:
diff changeset
  2127
hgs
parents:
diff changeset
  2128
hgs
parents:
diff changeset
  2129
hgs
parents:
diff changeset
  2130
hgs
parents:
diff changeset
  2131
hgs
parents:
diff changeset
  2132
hgs
parents:
diff changeset
  2133
hgs
parents:
diff changeset
  2134
hgs
parents:
diff changeset
  2135
CMemSpyThreadInfoPDD::CMemSpyThreadInfoPDD( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2136
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypePDD, EMemSpyDriverContainerTypePhysicalDevice, aAsyncConstruction )
hgs
parents:
diff changeset
  2137
    {
hgs
parents:
diff changeset
  2138
    }
hgs
parents:
diff changeset
  2139
hgs
parents:
diff changeset
  2140
hgs
parents:
diff changeset
  2141
CMemSpyThreadInfoPDD* CMemSpyThreadInfoPDD::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2142
    {
hgs
parents:
diff changeset
  2143
    CMemSpyThreadInfoPDD* self = new(ELeave) CMemSpyThreadInfoPDD( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2144
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2145
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2146
        {
hgs
parents:
diff changeset
  2147
        self->ConstructL();
hgs
parents:
diff changeset
  2148
        }
hgs
parents:
diff changeset
  2149
    return self;
hgs
parents:
diff changeset
  2150
    }
hgs
parents:
diff changeset
  2151
hgs
parents:
diff changeset
  2152
hgs
parents:
diff changeset
  2153
EXPORT_C TPtrC CMemSpyThreadInfoPDD::Name() const
hgs
parents:
diff changeset
  2154
    {
hgs
parents:
diff changeset
  2155
    _LIT(KName, "\tPhysical Device Drivers");
hgs
parents:
diff changeset
  2156
    return TPtrC( KName );
hgs
parents:
diff changeset
  2157
    }
hgs
parents:
diff changeset
  2158
hgs
parents:
diff changeset
  2159
hgs
parents:
diff changeset
  2160
void CMemSpyThreadInfoPDD::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& /*aItem*/, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  2161
    {
hgs
parents:
diff changeset
  2162
    AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2163
    }
hgs
parents:
diff changeset
  2164
hgs
parents:
diff changeset
  2165
hgs
parents:
diff changeset
  2166
hgs
parents:
diff changeset
  2167
hgs
parents:
diff changeset
  2168
hgs
parents:
diff changeset
  2169
hgs
parents:
diff changeset
  2170
hgs
parents:
diff changeset
  2171
hgs
parents:
diff changeset
  2172
hgs
parents:
diff changeset
  2173
hgs
parents:
diff changeset
  2174
hgs
parents:
diff changeset
  2175
hgs
parents:
diff changeset
  2176
hgs
parents:
diff changeset
  2177
hgs
parents:
diff changeset
  2178
hgs
parents:
diff changeset
  2179
hgs
parents:
diff changeset
  2180
hgs
parents:
diff changeset
  2181
hgs
parents:
diff changeset
  2182
hgs
parents:
diff changeset
  2183
hgs
parents:
diff changeset
  2184
hgs
parents:
diff changeset
  2185
hgs
parents:
diff changeset
  2186
CMemSpyThreadInfoLogicalChannel::CMemSpyThreadInfoLogicalChannel( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2187
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeLogicalChannel, EMemSpyDriverContainerTypeLogicalChannel, aAsyncConstruction )
hgs
parents:
diff changeset
  2188
    {
hgs
parents:
diff changeset
  2189
    }
hgs
parents:
diff changeset
  2190
hgs
parents:
diff changeset
  2191
hgs
parents:
diff changeset
  2192
CMemSpyThreadInfoLogicalChannel* CMemSpyThreadInfoLogicalChannel::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2193
    {
hgs
parents:
diff changeset
  2194
    CMemSpyThreadInfoLogicalChannel* self = new(ELeave) CMemSpyThreadInfoLogicalChannel( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2195
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2196
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2197
        {
hgs
parents:
diff changeset
  2198
        self->ConstructL();
hgs
parents:
diff changeset
  2199
        }
hgs
parents:
diff changeset
  2200
    return self;
hgs
parents:
diff changeset
  2201
    }
hgs
parents:
diff changeset
  2202
hgs
parents:
diff changeset
  2203
hgs
parents:
diff changeset
  2204
EXPORT_C TPtrC CMemSpyThreadInfoLogicalChannel::Name() const
hgs
parents:
diff changeset
  2205
    {
hgs
parents:
diff changeset
  2206
    _LIT(KName, "\tLogical DD Channels");
hgs
parents:
diff changeset
  2207
    return TPtrC( KName );
hgs
parents:
diff changeset
  2208
    }
hgs
parents:
diff changeset
  2209
hgs
parents:
diff changeset
  2210
hgs
parents:
diff changeset
  2211
void CMemSpyThreadInfoLogicalChannel::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& /*aItem*/, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  2212
    {
hgs
parents:
diff changeset
  2213
    AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2214
    }
hgs
parents:
diff changeset
  2215
hgs
parents:
diff changeset
  2216
hgs
parents:
diff changeset
  2217
hgs
parents:
diff changeset
  2218
hgs
parents:
diff changeset
  2219
hgs
parents:
diff changeset
  2220
hgs
parents:
diff changeset
  2221
hgs
parents:
diff changeset
  2222
hgs
parents:
diff changeset
  2223
hgs
parents:
diff changeset
  2224
hgs
parents:
diff changeset
  2225
hgs
parents:
diff changeset
  2226
hgs
parents:
diff changeset
  2227
hgs
parents:
diff changeset
  2228
hgs
parents:
diff changeset
  2229
hgs
parents:
diff changeset
  2230
hgs
parents:
diff changeset
  2231
hgs
parents:
diff changeset
  2232
hgs
parents:
diff changeset
  2233
hgs
parents:
diff changeset
  2234
hgs
parents:
diff changeset
  2235
hgs
parents:
diff changeset
  2236
CMemSpyThreadInfoChangeNotifier::CMemSpyThreadInfoChangeNotifier( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2237
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeChangeNotifier, EMemSpyDriverContainerTypeChangeNotifier, aAsyncConstruction )
hgs
parents:
diff changeset
  2238
    {
hgs
parents:
diff changeset
  2239
    }
hgs
parents:
diff changeset
  2240
hgs
parents:
diff changeset
  2241
hgs
parents:
diff changeset
  2242
CMemSpyThreadInfoChangeNotifier* CMemSpyThreadInfoChangeNotifier::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2243
    {
hgs
parents:
diff changeset
  2244
    CMemSpyThreadInfoChangeNotifier* self = new(ELeave) CMemSpyThreadInfoChangeNotifier( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2245
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2246
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2247
        {
hgs
parents:
diff changeset
  2248
        self->ConstructL();
hgs
parents:
diff changeset
  2249
        }
hgs
parents:
diff changeset
  2250
    return self;
hgs
parents:
diff changeset
  2251
    }
hgs
parents:
diff changeset
  2252
hgs
parents:
diff changeset
  2253
hgs
parents:
diff changeset
  2254
EXPORT_C TPtrC CMemSpyThreadInfoChangeNotifier::Name() const
hgs
parents:
diff changeset
  2255
    {
hgs
parents:
diff changeset
  2256
    _LIT(KName, "\tChange Notifiers");
hgs
parents:
diff changeset
  2257
    return TPtrC( KName );
hgs
parents:
diff changeset
  2258
    }
hgs
parents:
diff changeset
  2259
hgs
parents:
diff changeset
  2260
hgs
parents:
diff changeset
  2261
void CMemSpyThreadInfoChangeNotifier::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& /*aItem*/, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  2262
    {
hgs
parents:
diff changeset
  2263
    AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2264
    }
hgs
parents:
diff changeset
  2265
hgs
parents:
diff changeset
  2266
hgs
parents:
diff changeset
  2267
hgs
parents:
diff changeset
  2268
hgs
parents:
diff changeset
  2269
hgs
parents:
diff changeset
  2270
hgs
parents:
diff changeset
  2271
hgs
parents:
diff changeset
  2272
hgs
parents:
diff changeset
  2273
hgs
parents:
diff changeset
  2274
hgs
parents:
diff changeset
  2275
hgs
parents:
diff changeset
  2276
hgs
parents:
diff changeset
  2277
hgs
parents:
diff changeset
  2278
hgs
parents:
diff changeset
  2279
hgs
parents:
diff changeset
  2280
hgs
parents:
diff changeset
  2281
hgs
parents:
diff changeset
  2282
hgs
parents:
diff changeset
  2283
hgs
parents:
diff changeset
  2284
hgs
parents:
diff changeset
  2285
hgs
parents:
diff changeset
  2286
CMemSpyThreadInfoUndertaker::CMemSpyThreadInfoUndertaker( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2287
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeUndertaker, EMemSpyDriverContainerTypeUndertaker, aAsyncConstruction )
hgs
parents:
diff changeset
  2288
    {
hgs
parents:
diff changeset
  2289
    }
hgs
parents:
diff changeset
  2290
hgs
parents:
diff changeset
  2291
hgs
parents:
diff changeset
  2292
CMemSpyThreadInfoUndertaker* CMemSpyThreadInfoUndertaker::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2293
    {
hgs
parents:
diff changeset
  2294
    CMemSpyThreadInfoUndertaker* self = new(ELeave) CMemSpyThreadInfoUndertaker( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2295
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2296
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2297
        {
hgs
parents:
diff changeset
  2298
        self->ConstructL();
hgs
parents:
diff changeset
  2299
        }
hgs
parents:
diff changeset
  2300
    return self;
hgs
parents:
diff changeset
  2301
    }
hgs
parents:
diff changeset
  2302
hgs
parents:
diff changeset
  2303
hgs
parents:
diff changeset
  2304
EXPORT_C TPtrC CMemSpyThreadInfoUndertaker::Name() const
hgs
parents:
diff changeset
  2305
    {
hgs
parents:
diff changeset
  2306
    _LIT(KName, "\tUndertakers");
hgs
parents:
diff changeset
  2307
    return TPtrC( KName );
hgs
parents:
diff changeset
  2308
    }
hgs
parents:
diff changeset
  2309
hgs
parents:
diff changeset
  2310
hgs
parents:
diff changeset
  2311
void CMemSpyThreadInfoUndertaker::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& /*aItem*/, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  2312
    {
hgs
parents:
diff changeset
  2313
    AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2314
    }
hgs
parents:
diff changeset
  2315
hgs
parents:
diff changeset
  2316
hgs
parents:
diff changeset
  2317
hgs
parents:
diff changeset
  2318
hgs
parents:
diff changeset
  2319
hgs
parents:
diff changeset
  2320
hgs
parents:
diff changeset
  2321
hgs
parents:
diff changeset
  2322
hgs
parents:
diff changeset
  2323
hgs
parents:
diff changeset
  2324
hgs
parents:
diff changeset
  2325
hgs
parents:
diff changeset
  2326
hgs
parents:
diff changeset
  2327
hgs
parents:
diff changeset
  2328
hgs
parents:
diff changeset
  2329
hgs
parents:
diff changeset
  2330
hgs
parents:
diff changeset
  2331
hgs
parents:
diff changeset
  2332
CMemSpyThreadInfoOwnedThreadHandles::CMemSpyThreadInfoOwnedThreadHandles( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2333
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeOwnedThreadHandles, EMemSpyDriverContainerTypeThread, aAsyncConstruction )
hgs
parents:
diff changeset
  2334
    {
hgs
parents:
diff changeset
  2335
    }
hgs
parents:
diff changeset
  2336
hgs
parents:
diff changeset
  2337
hgs
parents:
diff changeset
  2338
CMemSpyThreadInfoOwnedThreadHandles* CMemSpyThreadInfoOwnedThreadHandles::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2339
    {
hgs
parents:
diff changeset
  2340
    CMemSpyThreadInfoOwnedThreadHandles* self = new(ELeave) CMemSpyThreadInfoOwnedThreadHandles( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2341
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2342
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2343
        {
hgs
parents:
diff changeset
  2344
        self->ConstructL();
hgs
parents:
diff changeset
  2345
        }
hgs
parents:
diff changeset
  2346
    return self;
hgs
parents:
diff changeset
  2347
    }
hgs
parents:
diff changeset
  2348
hgs
parents:
diff changeset
  2349
hgs
parents:
diff changeset
  2350
EXPORT_C TPtrC CMemSpyThreadInfoOwnedThreadHandles::Name() const
hgs
parents:
diff changeset
  2351
    {
hgs
parents:
diff changeset
  2352
    _LIT(KName, "\tHandles to other\nThreads");
hgs
parents:
diff changeset
  2353
    return TPtrC( KName );
hgs
parents:
diff changeset
  2354
    }
hgs
parents:
diff changeset
  2355
hgs
parents:
diff changeset
  2356
hgs
parents:
diff changeset
  2357
void CMemSpyThreadInfoOwnedThreadHandles::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt aRefCount, TDes& aFullName )
hgs
parents:
diff changeset
  2358
    {
hgs
parents:
diff changeset
  2359
    const TInt bracketPosStart = aFullName.LocateF( TChar('[') );
hgs
parents:
diff changeset
  2360
    const TInt doubleColonPos = aFullName.FindF( _L("::" ) );
hgs
parents:
diff changeset
  2361
    //
hgs
parents:
diff changeset
  2362
    if  ( bracketPosStart >= 0 && doubleColonPos > bracketPosStart && doubleColonPos < aFullName.Length() - 2 )
hgs
parents:
diff changeset
  2363
        {
hgs
parents:
diff changeset
  2364
        // Process
hgs
parents:
diff changeset
  2365
        TPtrC pProcessName( aFullName.Left( bracketPosStart ) );
hgs
parents:
diff changeset
  2366
        HBufC* caption = HBufC::NewLC( KMaxName + 10 );
hgs
parents:
diff changeset
  2367
        TPtr pCaption( caption->Des() );
hgs
parents:
diff changeset
  2368
        pCaption.AppendFormat( _L("[%2d] %S"), aRefCount, &pProcessName );
hgs
parents:
diff changeset
  2369
        
hgs
parents:
diff changeset
  2370
        // Thread id & thread name
hgs
parents:
diff changeset
  2371
        TPtrC pThreadName( aFullName.Mid( doubleColonPos + 2 ) );
hgs
parents:
diff changeset
  2372
        HBufC* value = HBufC::NewLC( KMaxName + 10 );
hgs
parents:
diff changeset
  2373
        TPtr pValue( value->Des() );
hgs
parents:
diff changeset
  2374
        pValue.AppendFormat( _L("[%3d] %S"), aItem.iId, &pThreadName );
hgs
parents:
diff changeset
  2375
hgs
parents:
diff changeset
  2376
        // Add it & tidy up
hgs
parents:
diff changeset
  2377
        AddItemL( pCaption, pValue );
hgs
parents:
diff changeset
  2378
        CleanupStack::PopAndDestroy( 2, caption );
hgs
parents:
diff changeset
  2379
        }
hgs
parents:
diff changeset
  2380
    else
hgs
parents:
diff changeset
  2381
        {
hgs
parents:
diff changeset
  2382
        AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2383
        }
hgs
parents:
diff changeset
  2384
    }
hgs
parents:
diff changeset
  2385
hgs
parents:
diff changeset
  2386
hgs
parents:
diff changeset
  2387
hgs
parents:
diff changeset
  2388
hgs
parents:
diff changeset
  2389
hgs
parents:
diff changeset
  2390
hgs
parents:
diff changeset
  2391
hgs
parents:
diff changeset
  2392
hgs
parents:
diff changeset
  2393
hgs
parents:
diff changeset
  2394
CMemSpyThreadInfoOwnedProcessHandles::CMemSpyThreadInfoOwnedProcessHandles( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2395
:   CMemSpyThreadInfoHandleByContainer( aContainer, EMemSpyThreadInfoItemTypeOwnedProcessHandles, EMemSpyDriverContainerTypeProcess, aAsyncConstruction )
hgs
parents:
diff changeset
  2396
    {
hgs
parents:
diff changeset
  2397
    }
hgs
parents:
diff changeset
  2398
hgs
parents:
diff changeset
  2399
hgs
parents:
diff changeset
  2400
CMemSpyThreadInfoOwnedProcessHandles* CMemSpyThreadInfoOwnedProcessHandles::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2401
    {
hgs
parents:
diff changeset
  2402
    CMemSpyThreadInfoOwnedProcessHandles* self = new(ELeave) CMemSpyThreadInfoOwnedProcessHandles( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2403
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2404
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2405
        {
hgs
parents:
diff changeset
  2406
        self->ConstructL();
hgs
parents:
diff changeset
  2407
        }
hgs
parents:
diff changeset
  2408
    return self;
hgs
parents:
diff changeset
  2409
    }
hgs
parents:
diff changeset
  2410
hgs
parents:
diff changeset
  2411
hgs
parents:
diff changeset
  2412
EXPORT_C TPtrC CMemSpyThreadInfoOwnedProcessHandles::Name() const
hgs
parents:
diff changeset
  2413
    {
hgs
parents:
diff changeset
  2414
    _LIT(KName, "\tHandles to other\nProcesses");
hgs
parents:
diff changeset
  2415
    return TPtrC( KName );
hgs
parents:
diff changeset
  2416
    }
hgs
parents:
diff changeset
  2417
hgs
parents:
diff changeset
  2418
hgs
parents:
diff changeset
  2419
void CMemSpyThreadInfoOwnedProcessHandles::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt aRefCount, TDes& aFullName )
hgs
parents:
diff changeset
  2420
    {
hgs
parents:
diff changeset
  2421
    const TInt bracketPosStart = aFullName.LocateF( TChar('[') );
hgs
parents:
diff changeset
  2422
    const TInt doubleColonPos = aFullName.FindF( _L("::" ) );
hgs
parents:
diff changeset
  2423
    //
hgs
parents:
diff changeset
  2424
    if  ( bracketPosStart >= 0 && doubleColonPos > bracketPosStart && doubleColonPos < aFullName.Length() - 2 )
hgs
parents:
diff changeset
  2425
        {
hgs
parents:
diff changeset
  2426
        // Process
hgs
parents:
diff changeset
  2427
        TPtrC pProcessName( aFullName.Left( bracketPosStart ) );
hgs
parents:
diff changeset
  2428
        HBufC* caption = HBufC::NewLC( KMaxName + 10 );
hgs
parents:
diff changeset
  2429
        TPtr pCaption( caption->Des() );
hgs
parents:
diff changeset
  2430
        pCaption.AppendFormat( _L("[%2d] %S"), aRefCount, &pProcessName );
hgs
parents:
diff changeset
  2431
        
hgs
parents:
diff changeset
  2432
        // Thread id & thread name
hgs
parents:
diff changeset
  2433
        TPtrC pThreadName( aFullName.Mid( doubleColonPos + 2 ) );
hgs
parents:
diff changeset
  2434
        HBufC* value = HBufC::NewLC( KMaxName + 10 );
hgs
parents:
diff changeset
  2435
        TPtr pValue( value->Des() );
hgs
parents:
diff changeset
  2436
        pValue.AppendFormat( _L("[%3d] %S"), aItem.iId, &pThreadName );
hgs
parents:
diff changeset
  2437
hgs
parents:
diff changeset
  2438
        // Add it & tidy up
hgs
parents:
diff changeset
  2439
        AddItemL( pCaption, pValue );
hgs
parents:
diff changeset
  2440
        CleanupStack::PopAndDestroy( 2, caption );
hgs
parents:
diff changeset
  2441
        }
hgs
parents:
diff changeset
  2442
    else
hgs
parents:
diff changeset
  2443
        {
hgs
parents:
diff changeset
  2444
        AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2445
        }
hgs
parents:
diff changeset
  2446
    }
hgs
parents:
diff changeset
  2447
hgs
parents:
diff changeset
  2448
hgs
parents:
diff changeset
  2449
hgs
parents:
diff changeset
  2450
hgs
parents:
diff changeset
  2451
hgs
parents:
diff changeset
  2452
hgs
parents:
diff changeset
  2453
hgs
parents:
diff changeset
  2454
hgs
parents:
diff changeset
  2455
hgs
parents:
diff changeset
  2456
hgs
parents:
diff changeset
  2457
hgs
parents:
diff changeset
  2458
hgs
parents:
diff changeset
  2459
hgs
parents:
diff changeset
  2460
hgs
parents:
diff changeset
  2461
hgs
parents:
diff changeset
  2462
hgs
parents:
diff changeset
  2463
hgs
parents:
diff changeset
  2464
hgs
parents:
diff changeset
  2465
hgs
parents:
diff changeset
  2466
hgs
parents:
diff changeset
  2467
hgs
parents:
diff changeset
  2468
hgs
parents:
diff changeset
  2469
hgs
parents:
diff changeset
  2470
hgs
parents:
diff changeset
  2471
hgs
parents:
diff changeset
  2472
hgs
parents:
diff changeset
  2473
hgs
parents:
diff changeset
  2474
hgs
parents:
diff changeset
  2475
hgs
parents:
diff changeset
  2476
hgs
parents:
diff changeset
  2477
hgs
parents:
diff changeset
  2478
hgs
parents:
diff changeset
  2479
hgs
parents:
diff changeset
  2480
hgs
parents:
diff changeset
  2481
hgs
parents:
diff changeset
  2482
hgs
parents:
diff changeset
  2483
hgs
parents:
diff changeset
  2484
hgs
parents:
diff changeset
  2485
hgs
parents:
diff changeset
  2486
hgs
parents:
diff changeset
  2487
CMemSpyThreadInfoReferencedBy::CMemSpyThreadInfoReferencedBy( CMemSpyThreadInfoContainer& aContainer, TMemSpyThreadInfoItemType aItemType, TMemSpyDriverContainerType aContainerType, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2488
:   CMemSpyThreadInfoHandleObjectBase( aContainer, aItemType, aContainerType, aAsyncConstruction )
hgs
parents:
diff changeset
  2489
    {
hgs
parents:
diff changeset
  2490
    }
hgs
parents:
diff changeset
  2491
hgs
parents:
diff changeset
  2492
hgs
parents:
diff changeset
  2493
void CMemSpyThreadInfoReferencedBy::GetHandlesL( RArray<THandleWrapper>& aArray )
hgs
parents:
diff changeset
  2494
    {
hgs
parents:
diff changeset
  2495
    aArray.Reset();
hgs
parents:
diff changeset
  2496
    //
hgs
parents:
diff changeset
  2497
    TInt r = KErrNone;
hgs
parents:
diff changeset
  2498
    //
hgs
parents:
diff changeset
  2499
    CMemSpyProcess& process = Container().Thread().Process();
hgs
parents:
diff changeset
  2500
    CMemSpyEngine& engine = process.Engine();
hgs
parents:
diff changeset
  2501
    TIdentityRelation<CMemSpyThreadInfoHandleObjectBase::THandleWrapper> finder( THandleWrapper::Match );
hgs
parents:
diff changeset
  2502
hgs
parents:
diff changeset
  2503
    // We need to either search through:
hgs
parents:
diff changeset
  2504
    //
hgs
parents:
diff changeset
  2505
    // a) all thread & process handles looking for *this thread*, or
hgs
parents:
diff changeset
  2506
    // b) all thread & process handles looking for *this process*
hgs
parents:
diff changeset
  2507
    //
hgs
parents:
diff changeset
  2508
    // We abuse the "container type" as a means of deciding whether it is
hgs
parents:
diff changeset
  2509
    // the thread or the process we are looking for.
hgs
parents:
diff changeset
  2510
    //
hgs
parents:
diff changeset
  2511
    RMemSpyDriverClient& driver = engine.Driver();
hgs
parents:
diff changeset
  2512
    if  ( ContainerType() == EMemSpyDriverContainerTypeProcess )
hgs
parents:
diff changeset
  2513
        {
hgs
parents:
diff changeset
  2514
        const TUint id = Container().Thread().Process().Id();
hgs
parents:
diff changeset
  2515
        r = driver.GetReferencesToMyProcess( id );
hgs
parents:
diff changeset
  2516
        }
hgs
parents:
diff changeset
  2517
    else if ( ContainerType() == EMemSpyDriverContainerTypeThread )
hgs
parents:
diff changeset
  2518
        {
hgs
parents:
diff changeset
  2519
        const TUint id = Container().Thread().Id();
hgs
parents:
diff changeset
  2520
        r = driver.GetReferencesToMyThread( id );
hgs
parents:
diff changeset
  2521
        }
hgs
parents:
diff changeset
  2522
    else
hgs
parents:
diff changeset
  2523
        {
hgs
parents:
diff changeset
  2524
        ASSERT( EFalse );
hgs
parents:
diff changeset
  2525
        }
hgs
parents:
diff changeset
  2526
    User::LeaveIfError( r );
hgs
parents:
diff changeset
  2527
hgs
parents:
diff changeset
  2528
    RMemSpyMemStreamReader stream = driver.StreamOpenL();
hgs
parents:
diff changeset
  2529
    CleanupClosePushL( stream );
hgs
parents:
diff changeset
  2530
    
hgs
parents:
diff changeset
  2531
    // Extract thread matches
hgs
parents:
diff changeset
  2532
    const TInt threadCount = stream.ReadInt32L();
hgs
parents:
diff changeset
  2533
    for( TInt i=0; i<threadCount; i++ )
hgs
parents:
diff changeset
  2534
        {
hgs
parents:
diff changeset
  2535
        TAny* handle = (TAny*) stream.ReadUint32L();
hgs
parents:
diff changeset
  2536
hgs
parents:
diff changeset
  2537
        // Create temporary entry that we'll use as the key in our array...
hgs
parents:
diff changeset
  2538
        CMemSpyThreadInfoHandleObjectBase::THandleWrapper entry( handle, EMemSpyDriverContainerTypeThread );
hgs
parents:
diff changeset
  2539
        
hgs
parents:
diff changeset
  2540
        // Find existing duplicate entry (if there is one...)
hgs
parents:
diff changeset
  2541
        const TInt errorOrIndex = aArray.Find( entry, finder );
hgs
parents:
diff changeset
  2542
	    
hgs
parents:
diff changeset
  2543
	    if  ( errorOrIndex == KErrNotFound )
hgs
parents:
diff changeset
  2544
		    {
hgs
parents:
diff changeset
  2545
		    // Not a duplicate handle, so keep it
hgs
parents:
diff changeset
  2546
		    aArray.AppendL( entry );
hgs
parents:
diff changeset
  2547
		    }
hgs
parents:
diff changeset
  2548
        else if ( errorOrIndex >= 0 )
hgs
parents:
diff changeset
  2549
            {
hgs
parents:
diff changeset
  2550
            // Increment reference count for duplicates...
hgs
parents:
diff changeset
  2551
            CMemSpyThreadInfoHandleObjectBase::THandleWrapper& existingEntry = aArray[ errorOrIndex ];
hgs
parents:
diff changeset
  2552
            ++existingEntry.iRefCount;
hgs
parents:
diff changeset
  2553
            }
hgs
parents:
diff changeset
  2554
        }
hgs
parents:
diff changeset
  2555
    
hgs
parents:
diff changeset
  2556
    // Extract process matches
hgs
parents:
diff changeset
  2557
    const TInt processCount = stream.ReadInt32L();
hgs
parents:
diff changeset
  2558
    for( TInt i=0; i<processCount; i++ )
hgs
parents:
diff changeset
  2559
        {
hgs
parents:
diff changeset
  2560
        TAny* handle = (TAny*) stream.ReadUint32L();
hgs
parents:
diff changeset
  2561
hgs
parents:
diff changeset
  2562
        // Create temporary entry that we'll use as the key in our array...
hgs
parents:
diff changeset
  2563
        CMemSpyThreadInfoHandleObjectBase::THandleWrapper entry( handle, EMemSpyDriverContainerTypeProcess );
hgs
parents:
diff changeset
  2564
        
hgs
parents:
diff changeset
  2565
        // Find existing duplicate entry (if there is one...)
hgs
parents:
diff changeset
  2566
        const TInt errorOrIndex = aArray.Find( entry, finder );
hgs
parents:
diff changeset
  2567
	    
hgs
parents:
diff changeset
  2568
	    if  ( errorOrIndex == KErrNotFound )
hgs
parents:
diff changeset
  2569
		    {
hgs
parents:
diff changeset
  2570
		    // Not a duplicate handle, so keep it
hgs
parents:
diff changeset
  2571
		    aArray.AppendL( entry );
hgs
parents:
diff changeset
  2572
		    }
hgs
parents:
diff changeset
  2573
        else if ( errorOrIndex >= 0 )
hgs
parents:
diff changeset
  2574
            {
hgs
parents:
diff changeset
  2575
            // Increment reference count for duplicates...
hgs
parents:
diff changeset
  2576
            CMemSpyThreadInfoHandleObjectBase::THandleWrapper& existingEntry = aArray[ errorOrIndex ];
hgs
parents:
diff changeset
  2577
            ++existingEntry.iRefCount;
hgs
parents:
diff changeset
  2578
            }
hgs
parents:
diff changeset
  2579
        }
hgs
parents:
diff changeset
  2580
        
hgs
parents:
diff changeset
  2581
    // Tidy up
hgs
parents:
diff changeset
  2582
    CleanupStack::PopAndDestroy( &stream );
hgs
parents:
diff changeset
  2583
    }
hgs
parents:
diff changeset
  2584
hgs
parents:
diff changeset
  2585
hgs
parents:
diff changeset
  2586
hgs
parents:
diff changeset
  2587
hgs
parents:
diff changeset
  2588
hgs
parents:
diff changeset
  2589
hgs
parents:
diff changeset
  2590
hgs
parents:
diff changeset
  2591
hgs
parents:
diff changeset
  2592
hgs
parents:
diff changeset
  2593
hgs
parents:
diff changeset
  2594
hgs
parents:
diff changeset
  2595
hgs
parents:
diff changeset
  2596
hgs
parents:
diff changeset
  2597
hgs
parents:
diff changeset
  2598
hgs
parents:
diff changeset
  2599
hgs
parents:
diff changeset
  2600
hgs
parents:
diff changeset
  2601
hgs
parents:
diff changeset
  2602
hgs
parents:
diff changeset
  2603
hgs
parents:
diff changeset
  2604
CMemSpyThreadInfoOtherThreads::CMemSpyThreadInfoOtherThreads( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2605
:   CMemSpyThreadInfoReferencedBy( aContainer, EMemSpyThreadInfoItemTypeOtherThreads, EMemSpyDriverContainerTypeThread, aAsyncConstruction )
hgs
parents:
diff changeset
  2606
    {
hgs
parents:
diff changeset
  2607
    }
hgs
parents:
diff changeset
  2608
hgs
parents:
diff changeset
  2609
hgs
parents:
diff changeset
  2610
CMemSpyThreadInfoOtherThreads* CMemSpyThreadInfoOtherThreads::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2611
    {
hgs
parents:
diff changeset
  2612
    CMemSpyThreadInfoOtherThreads* self = new(ELeave) CMemSpyThreadInfoOtherThreads( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2613
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2614
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2615
        {
hgs
parents:
diff changeset
  2616
        self->ConstructL();
hgs
parents:
diff changeset
  2617
        }
hgs
parents:
diff changeset
  2618
    return self;
hgs
parents:
diff changeset
  2619
    }
hgs
parents:
diff changeset
  2620
hgs
parents:
diff changeset
  2621
hgs
parents:
diff changeset
  2622
EXPORT_C TPtrC CMemSpyThreadInfoOtherThreads::Name() const
hgs
parents:
diff changeset
  2623
    {
hgs
parents:
diff changeset
  2624
    _LIT(KName, "\tReferences this Thread");
hgs
parents:
diff changeset
  2625
    return TPtrC( KName );
hgs
parents:
diff changeset
  2626
    }
hgs
parents:
diff changeset
  2627
hgs
parents:
diff changeset
  2628
hgs
parents:
diff changeset
  2629
void CMemSpyThreadInfoOtherThreads::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& /*aItem*/, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  2630
    {
hgs
parents:
diff changeset
  2631
    AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2632
    }
hgs
parents:
diff changeset
  2633
hgs
parents:
diff changeset
  2634
hgs
parents:
diff changeset
  2635
hgs
parents:
diff changeset
  2636
hgs
parents:
diff changeset
  2637
hgs
parents:
diff changeset
  2638
hgs
parents:
diff changeset
  2639
hgs
parents:
diff changeset
  2640
hgs
parents:
diff changeset
  2641
hgs
parents:
diff changeset
  2642
hgs
parents:
diff changeset
  2643
hgs
parents:
diff changeset
  2644
hgs
parents:
diff changeset
  2645
hgs
parents:
diff changeset
  2646
hgs
parents:
diff changeset
  2647
hgs
parents:
diff changeset
  2648
hgs
parents:
diff changeset
  2649
hgs
parents:
diff changeset
  2650
hgs
parents:
diff changeset
  2651
hgs
parents:
diff changeset
  2652
hgs
parents:
diff changeset
  2653
CMemSpyThreadInfoOtherProcesses::CMemSpyThreadInfoOtherProcesses( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2654
:   CMemSpyThreadInfoReferencedBy( aContainer, EMemSpyThreadInfoItemTypeOtherProcesses, EMemSpyDriverContainerTypeProcess, aAsyncConstruction )
hgs
parents:
diff changeset
  2655
    {
hgs
parents:
diff changeset
  2656
    }
hgs
parents:
diff changeset
  2657
hgs
parents:
diff changeset
  2658
hgs
parents:
diff changeset
  2659
CMemSpyThreadInfoOtherProcesses* CMemSpyThreadInfoOtherProcesses::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2660
    {
hgs
parents:
diff changeset
  2661
    CMemSpyThreadInfoOtherProcesses* self = new(ELeave) CMemSpyThreadInfoOtherProcesses( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2662
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2663
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2664
        {
hgs
parents:
diff changeset
  2665
        self->ConstructL();
hgs
parents:
diff changeset
  2666
        }
hgs
parents:
diff changeset
  2667
    return self;
hgs
parents:
diff changeset
  2668
    }
hgs
parents:
diff changeset
  2669
hgs
parents:
diff changeset
  2670
hgs
parents:
diff changeset
  2671
EXPORT_C TPtrC CMemSpyThreadInfoOtherProcesses::Name() const
hgs
parents:
diff changeset
  2672
    {
hgs
parents:
diff changeset
  2673
    _LIT(KName, "\tReferences this Process");
hgs
parents:
diff changeset
  2674
    return TPtrC( KName );
hgs
parents:
diff changeset
  2675
    }
hgs
parents:
diff changeset
  2676
hgs
parents:
diff changeset
  2677
hgs
parents:
diff changeset
  2678
void CMemSpyThreadInfoOtherProcesses::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& /*aItem*/, TInt /*aRefCount*/, TDes& aFullName )
hgs
parents:
diff changeset
  2679
    {
hgs
parents:
diff changeset
  2680
    AddItemL( aFullName, KNullDesC );
hgs
parents:
diff changeset
  2681
    }
hgs
parents:
diff changeset
  2682
hgs
parents:
diff changeset
  2683
hgs
parents:
diff changeset
  2684
hgs
parents:
diff changeset
  2685
hgs
parents:
diff changeset
  2686
hgs
parents:
diff changeset
  2687
hgs
parents:
diff changeset
  2688
hgs
parents:
diff changeset
  2689
hgs
parents:
diff changeset
  2690
hgs
parents:
diff changeset
  2691
hgs
parents:
diff changeset
  2692
hgs
parents:
diff changeset
  2693
hgs
parents:
diff changeset
  2694
hgs
parents:
diff changeset
  2695
hgs
parents:
diff changeset
  2696
hgs
parents:
diff changeset
  2697
hgs
parents:
diff changeset
  2698
hgs
parents:
diff changeset
  2699
CMemSpyThreadInfoMemoryTracking::CMemSpyThreadInfoMemoryTracking( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2700
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeMemoryTracking, aAsyncConstruction ), iTotalIncludesSharedMemory( ETrue )
hgs
parents:
diff changeset
  2701
    {
hgs
parents:
diff changeset
  2702
    }
hgs
parents:
diff changeset
  2703
hgs
parents:
diff changeset
  2704
hgs
parents:
diff changeset
  2705
CMemSpyThreadInfoMemoryTracking::~CMemSpyThreadInfoMemoryTracking()
hgs
parents:
diff changeset
  2706
    {
hgs
parents:
diff changeset
  2707
#ifdef _DEBUG
hgs
parents:
diff changeset
  2708
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::~CMemSpyThreadInfoMemoryTracking() - START - this: 0x%08x, iTracker: 0x%08x", this, iTracker );
hgs
parents:
diff changeset
  2709
#endif
hgs
parents:
diff changeset
  2710
    //
hgs
parents:
diff changeset
  2711
    TrackingObserverRemove( *this );
hgs
parents:
diff changeset
  2712
    //
hgs
parents:
diff changeset
  2713
    delete iInfoHWM;
hgs
parents:
diff changeset
  2714
    delete iInfoPeak;
hgs
parents:
diff changeset
  2715
    delete iInfoCurrent;
hgs
parents:
diff changeset
  2716
    //
hgs
parents:
diff changeset
  2717
#ifdef _DEBUG
hgs
parents:
diff changeset
  2718
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::~CMemSpyThreadInfoMemoryTracking() - END - this: 0x%08x, iTracker: 0x%08x", this, iTracker );
hgs
parents:
diff changeset
  2719
#endif
hgs
parents:
diff changeset
  2720
    }
hgs
parents:
diff changeset
  2721
hgs
parents:
diff changeset
  2722
hgs
parents:
diff changeset
  2723
void CMemSpyThreadInfoMemoryTracking::ConstructL()
hgs
parents:
diff changeset
  2724
    {
hgs
parents:
diff changeset
  2725
#ifdef _DEBUG
hgs
parents:
diff changeset
  2726
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::ConstructL() - START - this: 0x%08x, iTracker: 0x%08x", this, iTracker );
hgs
parents:
diff changeset
  2727
#endif
hgs
parents:
diff changeset
  2728
    CMemSpyEngine& engine = Container().Thread().Process().Engine();
hgs
parents:
diff changeset
  2729
    //
hgs
parents:
diff changeset
  2730
    const TProcessId pid = Container().Thread().Process().Id();
hgs
parents:
diff changeset
  2731
    iTracker = engine.HelperProcess().TrackerOrNull( pid );
hgs
parents:
diff changeset
  2732
hgs
parents:
diff changeset
  2733
#ifdef _DEBUG
hgs
parents:
diff changeset
  2734
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::ConstructL() - requesting observer add... - this: 0x%08x, iTracker: 0x%08x", this, iTracker );
hgs
parents:
diff changeset
  2735
#endif
hgs
parents:
diff changeset
  2736
    TrackingObserverAddL( *this );
hgs
parents:
diff changeset
  2737
    //
hgs
parents:
diff changeset
  2738
#ifdef _DEBUG
hgs
parents:
diff changeset
  2739
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::ConstructL() - preparing info item... - this: 0x%08x, iTracker: 0x%08x", this, iTracker );
hgs
parents:
diff changeset
  2740
#endif
hgs
parents:
diff changeset
  2741
    if  ( iTracker )
hgs
parents:
diff changeset
  2742
        {
hgs
parents:
diff changeset
  2743
        delete iInfoCurrent;
hgs
parents:
diff changeset
  2744
        iInfoCurrent = NULL;
hgs
parents:
diff changeset
  2745
        iInfoCurrent = CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::NewLC( Container(), EFalse );
hgs
parents:
diff changeset
  2746
        CleanupStack::Pop( iInfoCurrent );
hgs
parents:
diff changeset
  2747
        //
hgs
parents:
diff changeset
  2748
        delete iInfoHWM;
hgs
parents:
diff changeset
  2749
        iInfoHWM = NULL;
hgs
parents:
diff changeset
  2750
        iInfoHWM = CMemSpyThreadInfoMemoryTrackingStatisticsHWM::NewLC( Container(), EFalse );
hgs
parents:
diff changeset
  2751
        CleanupStack::Pop( iInfoHWM );
hgs
parents:
diff changeset
  2752
        //
hgs
parents:
diff changeset
  2753
        delete iInfoPeak;
hgs
parents:
diff changeset
  2754
        iInfoPeak = NULL;
hgs
parents:
diff changeset
  2755
        iInfoPeak = CMemSpyThreadInfoMemoryTrackingStatisticsPeak::NewLC( Container(), EFalse );
hgs
parents:
diff changeset
  2756
        CleanupStack::Pop( iInfoPeak );
hgs
parents:
diff changeset
  2757
        }
hgs
parents:
diff changeset
  2758
    
hgs
parents:
diff changeset
  2759
#ifdef _DEBUG
hgs
parents:
diff changeset
  2760
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::ConstructL() - prepared info items - this: 0x%08x, iTracker: 0x%08x", this, iTracker );
hgs
parents:
diff changeset
  2761
#endif
hgs
parents:
diff changeset
  2762
hgs
parents:
diff changeset
  2763
    // Prepare items
hgs
parents:
diff changeset
  2764
    _LIT( KItem0, "Tracking" );
hgs
parents:
diff changeset
  2765
    AddItemOnOffL( KItem0, ( iTracker ) ? iTracker->AmTracking() : EFalse );
hgs
parents:
diff changeset
  2766
hgs
parents:
diff changeset
  2767
    TInt64 valCurrent( 0 );
hgs
parents:
diff changeset
  2768
    if  ( iTracker )
hgs
parents:
diff changeset
  2769
        {
hgs
parents:
diff changeset
  2770
        if  ( TotalIncludesSharedMemory() )
hgs
parents:
diff changeset
  2771
            {
hgs
parents:
diff changeset
  2772
            valCurrent = iTracker->InfoCurrent().TotalIncShared();
hgs
parents:
diff changeset
  2773
            }
hgs
parents:
diff changeset
  2774
        else
hgs
parents:
diff changeset
  2775
            {
hgs
parents:
diff changeset
  2776
            valCurrent = iTracker->InfoCurrent().TotalExcShared();
hgs
parents:
diff changeset
  2777
            }
hgs
parents:
diff changeset
  2778
        }
hgs
parents:
diff changeset
  2779
    _LIT( KItem1, "Total [Current]" );
hgs
parents:
diff changeset
  2780
    AddItemLongL( KItem1, valCurrent );
hgs
parents:
diff changeset
  2781
hgs
parents:
diff changeset
  2782
    TInt64 valHWM( 0 );
hgs
parents:
diff changeset
  2783
    if  ( iTracker )
hgs
parents:
diff changeset
  2784
        {
hgs
parents:
diff changeset
  2785
        if  ( TotalIncludesSharedMemory() )
hgs
parents:
diff changeset
  2786
            {
hgs
parents:
diff changeset
  2787
            valHWM = iTracker->InfoHWMIncShared().TotalIncShared();
hgs
parents:
diff changeset
  2788
            }
hgs
parents:
diff changeset
  2789
        else
hgs
parents:
diff changeset
  2790
            {
hgs
parents:
diff changeset
  2791
            valHWM = iTracker->InfoHWMExcShared().TotalExcShared();
hgs
parents:
diff changeset
  2792
            }
hgs
parents:
diff changeset
  2793
        }
hgs
parents:
diff changeset
  2794
    _LIT( KItem2, "Total [HWM]" );
hgs
parents:
diff changeset
  2795
    AddItemLongL( KItem2, valHWM );
hgs
parents:
diff changeset
  2796
hgs
parents:
diff changeset
  2797
    TInt64 valPeak( 0 );
hgs
parents:
diff changeset
  2798
    if  ( iTracker )
hgs
parents:
diff changeset
  2799
        {
hgs
parents:
diff changeset
  2800
        if  ( TotalIncludesSharedMemory() )
hgs
parents:
diff changeset
  2801
            {
hgs
parents:
diff changeset
  2802
            valPeak = iTracker->InfoPeaks().TotalIncShared();
hgs
parents:
diff changeset
  2803
            }
hgs
parents:
diff changeset
  2804
        else
hgs
parents:
diff changeset
  2805
            {
hgs
parents:
diff changeset
  2806
            valPeak = iTracker->InfoPeaks().TotalExcShared();
hgs
parents:
diff changeset
  2807
            }
hgs
parents:
diff changeset
  2808
        }
hgs
parents:
diff changeset
  2809
    _LIT( KItem3, "Total [Peaks]" );
hgs
parents:
diff changeset
  2810
    AddItemLongL( KItem3, valPeak );
hgs
parents:
diff changeset
  2811
hgs
parents:
diff changeset
  2812
    //
hgs
parents:
diff changeset
  2813
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  2814
#ifdef _DEBUG
hgs
parents:
diff changeset
  2815
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::ConstructL() - END - this: 0x%08x", this );
hgs
parents:
diff changeset
  2816
#endif
hgs
parents:
diff changeset
  2817
    }
hgs
parents:
diff changeset
  2818
hgs
parents:
diff changeset
  2819
hgs
parents:
diff changeset
  2820
CMemSpyThreadInfoMemoryTracking* CMemSpyThreadInfoMemoryTracking::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  2821
    {
hgs
parents:
diff changeset
  2822
    CMemSpyThreadInfoMemoryTracking* self = new(ELeave) CMemSpyThreadInfoMemoryTracking( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  2823
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  2824
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  2825
        {
hgs
parents:
diff changeset
  2826
        self->ConstructL();
hgs
parents:
diff changeset
  2827
        }
hgs
parents:
diff changeset
  2828
    return self;
hgs
parents:
diff changeset
  2829
    }
hgs
parents:
diff changeset
  2830
hgs
parents:
diff changeset
  2831
hgs
parents:
diff changeset
  2832
EXPORT_C TPtrC CMemSpyThreadInfoMemoryTracking::Name() const
hgs
parents:
diff changeset
  2833
    {
hgs
parents:
diff changeset
  2834
    _LIT(KName, "\tMemory Tracking");
hgs
parents:
diff changeset
  2835
    return TPtrC( KName );
hgs
parents:
diff changeset
  2836
    }
hgs
parents:
diff changeset
  2837
hgs
parents:
diff changeset
  2838
hgs
parents:
diff changeset
  2839
EXPORT_C TBool CMemSpyThreadInfoMemoryTracking::TrackingActive() const
hgs
parents:
diff changeset
  2840
    {
hgs
parents:
diff changeset
  2841
    return ( iTracker != NULL ? iTracker->AmTracking() : EFalse );
hgs
parents:
diff changeset
  2842
    }
hgs
parents:
diff changeset
  2843
hgs
parents:
diff changeset
  2844
hgs
parents:
diff changeset
  2845
EXPORT_C TBool CMemSpyThreadInfoMemoryTracking::TotalIncludesSharedMemory() const
hgs
parents:
diff changeset
  2846
    {
hgs
parents:
diff changeset
  2847
    return iTotalIncludesSharedMemory;
hgs
parents:
diff changeset
  2848
    }
hgs
parents:
diff changeset
  2849
hgs
parents:
diff changeset
  2850
hgs
parents:
diff changeset
  2851
EXPORT_C void CMemSpyThreadInfoMemoryTracking::TrackingSetTotalIncludesSharedMemoryL( TBool aIncludesSharedMemory )
hgs
parents:
diff changeset
  2852
    {
hgs
parents:
diff changeset
  2853
    iTotalIncludesSharedMemory = aIncludesSharedMemory;
hgs
parents:
diff changeset
  2854
hgs
parents:
diff changeset
  2855
    if  ( iTracker )
hgs
parents:
diff changeset
  2856
        {
hgs
parents:
diff changeset
  2857
        iInfoCurrent->SetTotalIncludesSharedMemoryL( aIncludesSharedMemory );
hgs
parents:
diff changeset
  2858
        iInfoHWM->SetTotalIncludesSharedMemoryL( aIncludesSharedMemory );
hgs
parents:
diff changeset
  2859
        iInfoPeak->SetTotalIncludesSharedMemoryL( aIncludesSharedMemory );
hgs
parents:
diff changeset
  2860
        
hgs
parents:
diff changeset
  2861
        // Update totals
hgs
parents:
diff changeset
  2862
        TRAP_IGNORE( UpdateCaptionsL( iTracker->InfoCurrent(), iTracker->InfoHWMIncShared(), iTracker->InfoHWMExcShared() ) );
hgs
parents:
diff changeset
  2863
        }
hgs
parents:
diff changeset
  2864
    }
hgs
parents:
diff changeset
  2865
hgs
parents:
diff changeset
  2866
hgs
parents:
diff changeset
  2867
EXPORT_C void CMemSpyThreadInfoMemoryTracking::TrackingStartL()
hgs
parents:
diff changeset
  2868
    {
hgs
parents:
diff changeset
  2869
    if  ( iTracker == NULL )
hgs
parents:
diff changeset
  2870
        {
hgs
parents:
diff changeset
  2871
        CMemSpyProcess& process = Container().Thread().Process();
hgs
parents:
diff changeset
  2872
        CMemSpyEngine& engine = process.Engine();
hgs
parents:
diff changeset
  2873
        iTracker = &engine.HelperProcess().TrackerL( process );
hgs
parents:
diff changeset
  2874
hgs
parents:
diff changeset
  2875
        // Make sure we are also listening to the tracker!
hgs
parents:
diff changeset
  2876
        TrackingObserverAddL( *this );
hgs
parents:
diff changeset
  2877
        //
hgs
parents:
diff changeset
  2878
        CMemSpyThreadInfoMemoryTrackingStatisticsCurrent* infoCurrent = CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::NewLC( Container(), EFalse );
hgs
parents:
diff changeset
  2879
        CMemSpyThreadInfoMemoryTrackingStatisticsHWM* infoHWM = CMemSpyThreadInfoMemoryTrackingStatisticsHWM::NewLC( Container(), EFalse );
hgs
parents:
diff changeset
  2880
        CMemSpyThreadInfoMemoryTrackingStatisticsPeak* infoPeak = CMemSpyThreadInfoMemoryTrackingStatisticsPeak::NewLC( Container(), EFalse );
hgs
parents:
diff changeset
  2881
        //
hgs
parents:
diff changeset
  2882
        iInfoCurrent = infoCurrent;
hgs
parents:
diff changeset
  2883
        iInfoHWM = infoHWM;
hgs
parents:
diff changeset
  2884
        iInfoPeak = infoPeak;
hgs
parents:
diff changeset
  2885
        //
hgs
parents:
diff changeset
  2886
        CleanupStack::Pop( iInfoPeak );
hgs
parents:
diff changeset
  2887
        CleanupStack::Pop( infoHWM );
hgs
parents:
diff changeset
  2888
        CleanupStack::Pop( infoCurrent );
hgs
parents:
diff changeset
  2889
        //
hgs
parents:
diff changeset
  2890
        TrackingSetTotalIncludesSharedMemoryL( iTotalIncludesSharedMemory );
hgs
parents:
diff changeset
  2891
        }
hgs
parents:
diff changeset
  2892
hgs
parents:
diff changeset
  2893
    iTracker->StartL();
hgs
parents:
diff changeset
  2894
hgs
parents:
diff changeset
  2895
    UpdateCaptionsL();
hgs
parents:
diff changeset
  2896
    }
hgs
parents:
diff changeset
  2897
hgs
parents:
diff changeset
  2898
hgs
parents:
diff changeset
  2899
EXPORT_C void CMemSpyThreadInfoMemoryTracking::TrackingStopL()
hgs
parents:
diff changeset
  2900
    {
hgs
parents:
diff changeset
  2901
    if  ( iTracker != NULL )
hgs
parents:
diff changeset
  2902
        {
hgs
parents:
diff changeset
  2903
        iTracker->Stop();
hgs
parents:
diff changeset
  2904
        }
hgs
parents:
diff changeset
  2905
hgs
parents:
diff changeset
  2906
    UpdateCaptionsL();
hgs
parents:
diff changeset
  2907
    }
hgs
parents:
diff changeset
  2908
hgs
parents:
diff changeset
  2909
hgs
parents:
diff changeset
  2910
EXPORT_C void CMemSpyThreadInfoMemoryTracking::TrackingResetHWML()
hgs
parents:
diff changeset
  2911
    {
hgs
parents:
diff changeset
  2912
    if  ( iTracker != NULL )
hgs
parents:
diff changeset
  2913
        {
hgs
parents:
diff changeset
  2914
        iTracker->ResetHWML();
hgs
parents:
diff changeset
  2915
        }
hgs
parents:
diff changeset
  2916
    }
hgs
parents:
diff changeset
  2917
hgs
parents:
diff changeset
  2918
hgs
parents:
diff changeset
  2919
EXPORT_C void CMemSpyThreadInfoMemoryTracking::TrackingObserverAddL( MMemSpyEngineProcessMemoryTrackerObserver& aObserver )
hgs
parents:
diff changeset
  2920
    {
hgs
parents:
diff changeset
  2921
#ifdef _DEBUG
hgs
parents:
diff changeset
  2922
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::TrackingObserverAddL() - START - iTracker: 0x%08x, this: 0x%08x", iTracker, this );
hgs
parents:
diff changeset
  2923
#endif
hgs
parents:
diff changeset
  2924
hgs
parents:
diff changeset
  2925
    if  ( iTracker != NULL )
hgs
parents:
diff changeset
  2926
        {
hgs
parents:
diff changeset
  2927
        iTracker->AddObserverL( aObserver );
hgs
parents:
diff changeset
  2928
        }
hgs
parents:
diff changeset
  2929
hgs
parents:
diff changeset
  2930
#ifdef _DEBUG
hgs
parents:
diff changeset
  2931
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::TrackingObserverAddL() - END - iTracker: 0x%08x, this: 0x%08x", iTracker, this );
hgs
parents:
diff changeset
  2932
#endif
hgs
parents:
diff changeset
  2933
    }
hgs
parents:
diff changeset
  2934
hgs
parents:
diff changeset
  2935
hgs
parents:
diff changeset
  2936
EXPORT_C void CMemSpyThreadInfoMemoryTracking::TrackingObserverRemove( MMemSpyEngineProcessMemoryTrackerObserver& aObserver )
hgs
parents:
diff changeset
  2937
    {
hgs
parents:
diff changeset
  2938
#ifdef _DEBUG
hgs
parents:
diff changeset
  2939
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::TrackingObserverRemove() - START - iTracker: 0x%08x, this: 0x%08x", iTracker, this );
hgs
parents:
diff changeset
  2940
#endif
hgs
parents:
diff changeset
  2941
hgs
parents:
diff changeset
  2942
    if  ( iTracker != NULL )
hgs
parents:
diff changeset
  2943
        {
hgs
parents:
diff changeset
  2944
        iTracker->RemoveObserver( aObserver );
hgs
parents:
diff changeset
  2945
        }
hgs
parents:
diff changeset
  2946
hgs
parents:
diff changeset
  2947
#ifdef _DEBUG
hgs
parents:
diff changeset
  2948
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::TrackingObserverRemove() - END - iTracker: 0x%08x, this: 0x%08x", iTracker, this );
hgs
parents:
diff changeset
  2949
#endif
hgs
parents:
diff changeset
  2950
    }
hgs
parents:
diff changeset
  2951
hgs
parents:
diff changeset
  2952
hgs
parents:
diff changeset
  2953
EXPORT_C MDesCArray& CMemSpyThreadInfoMemoryTracking::InfoCurrent()
hgs
parents:
diff changeset
  2954
    {
hgs
parents:
diff changeset
  2955
    return *iInfoCurrent;
hgs
parents:
diff changeset
  2956
    }
hgs
parents:
diff changeset
  2957
hgs
parents:
diff changeset
  2958
hgs
parents:
diff changeset
  2959
EXPORT_C MDesCArray& CMemSpyThreadInfoMemoryTracking::InfoHWM()
hgs
parents:
diff changeset
  2960
    {
hgs
parents:
diff changeset
  2961
    return *iInfoHWM;
hgs
parents:
diff changeset
  2962
    }
hgs
parents:
diff changeset
  2963
hgs
parents:
diff changeset
  2964
hgs
parents:
diff changeset
  2965
EXPORT_C MDesCArray& CMemSpyThreadInfoMemoryTracking::InfoPeak()
hgs
parents:
diff changeset
  2966
    {
hgs
parents:
diff changeset
  2967
    return *iInfoPeak;
hgs
parents:
diff changeset
  2968
    }
hgs
parents:
diff changeset
  2969
hgs
parents:
diff changeset
  2970
hgs
parents:
diff changeset
  2971
void CMemSpyThreadInfoMemoryTracking::HandleMemoryTrackingStartedL()
hgs
parents:
diff changeset
  2972
    {
hgs
parents:
diff changeset
  2973
    __ASSERT_ALWAYS( iTracker, MemSpyEngineUtils::Panic( EMemSpyEnginePanicTrackerNull1 ) );
hgs
parents:
diff changeset
  2974
    CMemSpyThreadInfoItemBase::CItem& trackingItem = Item( 0 );
hgs
parents:
diff changeset
  2975
    trackingItem.SetOnOffL( iTracker->AmTracking() );
hgs
parents:
diff changeset
  2976
    //
hgs
parents:
diff changeset
  2977
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  2978
    }
hgs
parents:
diff changeset
  2979
hgs
parents:
diff changeset
  2980
hgs
parents:
diff changeset
  2981
void CMemSpyThreadInfoMemoryTracking::HandleMemoryTrackingStoppedL()
hgs
parents:
diff changeset
  2982
    {
hgs
parents:
diff changeset
  2983
    __ASSERT_ALWAYS( iTracker, MemSpyEngineUtils::Panic( EMemSpyEnginePanicTrackerNull2 ) );
hgs
parents:
diff changeset
  2984
    CMemSpyThreadInfoItemBase::CItem& trackingItem = Item( 0 );
hgs
parents:
diff changeset
  2985
    trackingItem.SetOnOffL( iTracker->AmTracking() );
hgs
parents:
diff changeset
  2986
    //
hgs
parents:
diff changeset
  2987
    Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  2988
    }
hgs
parents:
diff changeset
  2989
hgs
parents:
diff changeset
  2990
hgs
parents:
diff changeset
  2991
void CMemSpyThreadInfoMemoryTracking::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& aInfoCurrent, const TMemSpyDriverProcessInspectionInfo& aHWMInfoIncShared, const TMemSpyDriverProcessInspectionInfo& aHWMInfoExcShared )
hgs
parents:
diff changeset
  2992
    {
hgs
parents:
diff changeset
  2993
#ifdef _DEBUG
hgs
parents:
diff changeset
  2994
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::HandleMemoryChangedL() - START - this: 0x%08x", this );
hgs
parents:
diff changeset
  2995
#endif 
hgs
parents:
diff changeset
  2996
hgs
parents:
diff changeset
  2997
    __ASSERT_ALWAYS( iTracker, MemSpyEngineUtils::Panic( EMemSpyEnginePanicTrackerNull3 ) );
hgs
parents:
diff changeset
  2998
    UpdateCaptionsL( aInfoCurrent, aHWMInfoIncShared, aHWMInfoExcShared );
hgs
parents:
diff changeset
  2999
hgs
parents:
diff changeset
  3000
#ifdef _DEBUG
hgs
parents:
diff changeset
  3001
    RDebug::Printf( "CMemSpyThreadInfoMemoryTracking::HandleMemoryChangedL() - END - this: 0x%08x", this );
hgs
parents:
diff changeset
  3002
#endif 
hgs
parents:
diff changeset
  3003
    }
hgs
parents:
diff changeset
  3004
hgs
parents:
diff changeset
  3005
hgs
parents:
diff changeset
  3006
void CMemSpyThreadInfoMemoryTracking::UpdateCaptionsL()
hgs
parents:
diff changeset
  3007
    {
hgs
parents:
diff changeset
  3008
    if  ( iTracker )
hgs
parents:
diff changeset
  3009
        {
hgs
parents:
diff changeset
  3010
        UpdateCaptionsL( iTracker->InfoCurrent(), iTracker->InfoHWMIncShared(), iTracker->InfoHWMExcShared() );
hgs
parents:
diff changeset
  3011
        }
hgs
parents:
diff changeset
  3012
    }
hgs
parents:
diff changeset
  3013
hgs
parents:
diff changeset
  3014
hgs
parents:
diff changeset
  3015
void CMemSpyThreadInfoMemoryTracking::UpdateCaptionsL( const TMemSpyDriverProcessInspectionInfo& aInfoCurrent, const TMemSpyDriverProcessInspectionInfo& aHWMInfoIncShared, const TMemSpyDriverProcessInspectionInfo& aHWMInfoExcShared )
hgs
parents:
diff changeset
  3016
    {
hgs
parents:
diff changeset
  3017
    if  ( iTracker )
hgs
parents:
diff changeset
  3018
        {
hgs
parents:
diff changeset
  3019
        // Update caption
hgs
parents:
diff changeset
  3020
        Item( 0 ).SetOnOffL( TrackingActive() );
hgs
parents:
diff changeset
  3021
  
hgs
parents:
diff changeset
  3022
        if  ( TotalIncludesSharedMemory() )
hgs
parents:
diff changeset
  3023
            {
hgs
parents:
diff changeset
  3024
            Item( 1 ).SetLongL( aInfoCurrent.TotalIncShared() );
hgs
parents:
diff changeset
  3025
            Item( 2 ).SetLongL( aHWMInfoIncShared.TotalIncShared() );
hgs
parents:
diff changeset
  3026
            Item( 3 ).SetLongL( iTracker->InfoPeaks().TotalIncShared() );
hgs
parents:
diff changeset
  3027
            }
hgs
parents:
diff changeset
  3028
        else
hgs
parents:
diff changeset
  3029
            {
hgs
parents:
diff changeset
  3030
            Item( 1 ).SetLongL( aInfoCurrent.TotalExcShared() );
hgs
parents:
diff changeset
  3031
            Item( 2 ).SetLongL( aHWMInfoExcShared.TotalExcShared() );
hgs
parents:
diff changeset
  3032
            Item( 3 ).SetLongL( iTracker->InfoPeaks().TotalExcShared() );
hgs
parents:
diff changeset
  3033
            }
hgs
parents:
diff changeset
  3034
hgs
parents:
diff changeset
  3035
        Container().NotifyObserverL( MMemSpyThreadInfoContainerObserver::EInfoItemChanged, Type() );
hgs
parents:
diff changeset
  3036
        }
hgs
parents:
diff changeset
  3037
    }
hgs
parents:
diff changeset
  3038
hgs
parents:
diff changeset
  3039
hgs
parents:
diff changeset
  3040
hgs
parents:
diff changeset
  3041
hgs
parents:
diff changeset
  3042
hgs
parents:
diff changeset
  3043
hgs
parents:
diff changeset
  3044
hgs
parents:
diff changeset
  3045
hgs
parents:
diff changeset
  3046
hgs
parents:
diff changeset
  3047
hgs
parents:
diff changeset
  3048
hgs
parents:
diff changeset
  3049
hgs
parents:
diff changeset
  3050
hgs
parents:
diff changeset
  3051
hgs
parents:
diff changeset
  3052
hgs
parents:
diff changeset
  3053
hgs
parents:
diff changeset
  3054
hgs
parents:
diff changeset
  3055
hgs
parents:
diff changeset
  3056
hgs
parents:
diff changeset
  3057
hgs
parents:
diff changeset
  3058
hgs
parents:
diff changeset
  3059
hgs
parents:
diff changeset
  3060
hgs
parents:
diff changeset
  3061
hgs
parents:
diff changeset
  3062
hgs
parents:
diff changeset
  3063
hgs
parents:
diff changeset
  3064
hgs
parents:
diff changeset
  3065
hgs
parents:
diff changeset
  3066
hgs
parents:
diff changeset
  3067
hgs
parents:
diff changeset
  3068
hgs
parents:
diff changeset
  3069
hgs
parents:
diff changeset
  3070
CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::CMemSpyThreadInfoMemoryTrackingStatisticsCurrent( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  3071
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeMemoryTrackingCurrent, aAsyncConstruction ), iTotalIncludesSharedMemory( ETrue )
hgs
parents:
diff changeset
  3072
    {
hgs
parents:
diff changeset
  3073
    }
hgs
parents:
diff changeset
  3074
hgs
parents:
diff changeset
  3075
hgs
parents:
diff changeset
  3076
CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::~CMemSpyThreadInfoMemoryTrackingStatisticsCurrent()
hgs
parents:
diff changeset
  3077
    {
hgs
parents:
diff changeset
  3078
    if  ( iTracker )
hgs
parents:
diff changeset
  3079
        {
hgs
parents:
diff changeset
  3080
        iTracker->RemoveObserver( *this );
hgs
parents:
diff changeset
  3081
        }
hgs
parents:
diff changeset
  3082
    }
hgs
parents:
diff changeset
  3083
hgs
parents:
diff changeset
  3084
hgs
parents:
diff changeset
  3085
void CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::ConstructL()
62
hgs
parents: 51
diff changeset
  3086
    {    
51
hgs
parents:
diff changeset
  3087
    if  ( iTracker )
hgs
parents:
diff changeset
  3088
        {
hgs
parents:
diff changeset
  3089
        iTracker->RemoveObserver( *this );
hgs
parents:
diff changeset
  3090
        }
hgs
parents:
diff changeset
  3091
    iTracker = &Container().Engine().HelperProcess().TrackerL( Container().Thread().Process() );
hgs
parents:
diff changeset
  3092
    if  ( iTracker )
hgs
parents:
diff changeset
  3093
        {
hgs
parents:
diff changeset
  3094
        iTracker->AddObserverL( *this );
hgs
parents:
diff changeset
  3095
        //
hgs
parents:
diff changeset
  3096
        _LIT( KItem1, "Stack Memory" );
hgs
parents:
diff changeset
  3097
        AddItemDecimalL( KItem1, iTracker->InfoCurrent().iMemoryStack );
hgs
parents:
diff changeset
  3098
        //
hgs
parents:
diff changeset
  3099
        _LIT( KItem2, "Heap Memory" );
hgs
parents:
diff changeset
  3100
        AddItemDecimalL( KItem2, iTracker->InfoCurrent().iMemoryHeap );
hgs
parents:
diff changeset
  3101
        //
hgs
parents:
diff changeset
  3102
        _LIT( KItem3, "Local Chunk Memory" );
hgs
parents:
diff changeset
  3103
        AddItemDecimalL( KItem3, iTracker->InfoCurrent().iMemoryChunkLocal );
hgs
parents:
diff changeset
  3104
        //
hgs
parents:
diff changeset
  3105
        _LIT( KItem4, "Shared Chunk Memory" );
hgs
parents:
diff changeset
  3106
        AddItemDecimalL( KItem4, iTracker->InfoCurrent().iMemoryChunkShared );
hgs
parents:
diff changeset
  3107
        //
hgs
parents:
diff changeset
  3108
        _LIT( KItem5, "Global Data Memory" );
hgs
parents:
diff changeset
  3109
        AddItemDecimalL( KItem5, iTracker->InfoCurrent().iMemoryGlobalData );
hgs
parents:
diff changeset
  3110
        //
hgs
parents:
diff changeset
  3111
        _LIT( KItem6, "Total" );
hgs
parents:
diff changeset
  3112
        if  ( iTotalIncludesSharedMemory )
hgs
parents:
diff changeset
  3113
            {
hgs
parents:
diff changeset
  3114
            AddItemLongL( KItem6, iTracker->InfoCurrent().TotalIncShared() );
hgs
parents:
diff changeset
  3115
            }
hgs
parents:
diff changeset
  3116
        else
hgs
parents:
diff changeset
  3117
            {
hgs
parents:
diff changeset
  3118
            AddItemLongL( KItem6, iTracker->InfoCurrent().TotalExcShared() );
hgs
parents:
diff changeset
  3119
            }
hgs
parents:
diff changeset
  3120
        }
hgs
parents:
diff changeset
  3121
    }
hgs
parents:
diff changeset
  3122
hgs
parents:
diff changeset
  3123
hgs
parents:
diff changeset
  3124
CMemSpyThreadInfoMemoryTrackingStatisticsCurrent* CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  3125
    {
hgs
parents:
diff changeset
  3126
    CMemSpyThreadInfoMemoryTrackingStatisticsCurrent* self = new(ELeave) CMemSpyThreadInfoMemoryTrackingStatisticsCurrent( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  3127
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  3128
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  3129
        {
hgs
parents:
diff changeset
  3130
        self->ConstructL();
hgs
parents:
diff changeset
  3131
        }
hgs
parents:
diff changeset
  3132
    return self;
hgs
parents:
diff changeset
  3133
    }
hgs
parents:
diff changeset
  3134
hgs
parents:
diff changeset
  3135
hgs
parents:
diff changeset
  3136
TPtrC CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::Name() const
hgs
parents:
diff changeset
  3137
    {
hgs
parents:
diff changeset
  3138
    _LIT(KName, "\tCurrent Statistics");
hgs
parents:
diff changeset
  3139
    return TPtrC( KName );
hgs
parents:
diff changeset
  3140
    }
hgs
parents:
diff changeset
  3141
hgs
parents:
diff changeset
  3142
hgs
parents:
diff changeset
  3143
void CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::SetTotalIncludesSharedMemoryL( TBool aIncludesSharedMemory )
hgs
parents:
diff changeset
  3144
    {
hgs
parents:
diff changeset
  3145
    iTotalIncludesSharedMemory = aIncludesSharedMemory;
hgs
parents:
diff changeset
  3146
    
hgs
parents:
diff changeset
  3147
    // Update totals
hgs
parents:
diff changeset
  3148
    HandleMemoryChangedL( iTracker->ProcessId(), iTracker->InfoCurrent(), iTracker->InfoHWMIncShared(), iTracker->InfoHWMExcShared() );
hgs
parents:
diff changeset
  3149
    }
hgs
parents:
diff changeset
  3150
hgs
parents:
diff changeset
  3151
hgs
parents:
diff changeset
  3152
void CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::HandleMemoryTrackingStartedL()
hgs
parents:
diff changeset
  3153
    {
hgs
parents:
diff changeset
  3154
    }
hgs
parents:
diff changeset
  3155
hgs
parents:
diff changeset
  3156
hgs
parents:
diff changeset
  3157
void CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::HandleMemoryTrackingStoppedL()
hgs
parents:
diff changeset
  3158
    {
hgs
parents:
diff changeset
  3159
    }
hgs
parents:
diff changeset
  3160
hgs
parents:
diff changeset
  3161
hgs
parents:
diff changeset
  3162
void CMemSpyThreadInfoMemoryTrackingStatisticsCurrent::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& aInfoCurrent, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoIncShared*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoExcShared*/ )
hgs
parents:
diff changeset
  3163
    {
hgs
parents:
diff changeset
  3164
    Item( 0 ).SetDecimalL( aInfoCurrent.iMemoryStack );
hgs
parents:
diff changeset
  3165
    Item( 1 ).SetDecimalL( aInfoCurrent.iMemoryHeap );
hgs
parents:
diff changeset
  3166
    Item( 2 ).SetDecimalL( aInfoCurrent.iMemoryChunkLocal );
hgs
parents:
diff changeset
  3167
    Item( 3 ).SetDecimalL( aInfoCurrent.iMemoryChunkShared );
hgs
parents:
diff changeset
  3168
    Item( 4 ).SetDecimalL( aInfoCurrent.iMemoryGlobalData );
hgs
parents:
diff changeset
  3169
    //
hgs
parents:
diff changeset
  3170
    if  ( iTotalIncludesSharedMemory )
hgs
parents:
diff changeset
  3171
        {
hgs
parents:
diff changeset
  3172
        Item( 5 ).SetLongL( aInfoCurrent.TotalIncShared() );
hgs
parents:
diff changeset
  3173
        }
hgs
parents:
diff changeset
  3174
    else
hgs
parents:
diff changeset
  3175
        {
hgs
parents:
diff changeset
  3176
        Item( 5 ).SetLongL( aInfoCurrent.TotalExcShared() );
hgs
parents:
diff changeset
  3177
        }
hgs
parents:
diff changeset
  3178
    }
hgs
parents:
diff changeset
  3179
hgs
parents:
diff changeset
  3180
hgs
parents:
diff changeset
  3181
hgs
parents:
diff changeset
  3182
hgs
parents:
diff changeset
  3183
hgs
parents:
diff changeset
  3184
hgs
parents:
diff changeset
  3185
hgs
parents:
diff changeset
  3186
hgs
parents:
diff changeset
  3187
hgs
parents:
diff changeset
  3188
hgs
parents:
diff changeset
  3189
hgs
parents:
diff changeset
  3190
hgs
parents:
diff changeset
  3191
hgs
parents:
diff changeset
  3192
hgs
parents:
diff changeset
  3193
hgs
parents:
diff changeset
  3194
hgs
parents:
diff changeset
  3195
hgs
parents:
diff changeset
  3196
hgs
parents:
diff changeset
  3197
hgs
parents:
diff changeset
  3198
CMemSpyThreadInfoMemoryTrackingStatisticsPeak::CMemSpyThreadInfoMemoryTrackingStatisticsPeak( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  3199
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeMemoryTrackingPeak, aAsyncConstruction ), iTotalIncludesSharedMemory( ETrue )
hgs
parents:
diff changeset
  3200
    {
hgs
parents:
diff changeset
  3201
    }
hgs
parents:
diff changeset
  3202
hgs
parents:
diff changeset
  3203
hgs
parents:
diff changeset
  3204
CMemSpyThreadInfoMemoryTrackingStatisticsPeak::~CMemSpyThreadInfoMemoryTrackingStatisticsPeak()
hgs
parents:
diff changeset
  3205
    {
hgs
parents:
diff changeset
  3206
    if  ( iTracker )
hgs
parents:
diff changeset
  3207
        {
hgs
parents:
diff changeset
  3208
        iTracker->RemoveObserver( *this );
hgs
parents:
diff changeset
  3209
        }
hgs
parents:
diff changeset
  3210
    }
hgs
parents:
diff changeset
  3211
hgs
parents:
diff changeset
  3212
hgs
parents:
diff changeset
  3213
void CMemSpyThreadInfoMemoryTrackingStatisticsPeak::ConstructL()
hgs
parents:
diff changeset
  3214
    {
hgs
parents:
diff changeset
  3215
    if  ( iTracker )
hgs
parents:
diff changeset
  3216
        {
hgs
parents:
diff changeset
  3217
        iTracker->RemoveObserver( *this );
hgs
parents:
diff changeset
  3218
        }
hgs
parents:
diff changeset
  3219
    iTracker = &Container().Engine().HelperProcess().TrackerL( Container().Thread().Process() );
hgs
parents:
diff changeset
  3220
    if  ( iTracker )
hgs
parents:
diff changeset
  3221
        {
hgs
parents:
diff changeset
  3222
        iTracker->AddObserverL( *this );
hgs
parents:
diff changeset
  3223
        //
hgs
parents:
diff changeset
  3224
        _LIT( KItem1, "Stack Memory" );
hgs
parents:
diff changeset
  3225
        AddItemDecimalL( KItem1, iTracker->InfoPeaks().iMemoryStack );
hgs
parents:
diff changeset
  3226
        //
hgs
parents:
diff changeset
  3227
        _LIT( KItem2, "Heap Memory" );
hgs
parents:
diff changeset
  3228
        AddItemDecimalL( KItem2, iTracker->InfoPeaks().iMemoryHeap );
hgs
parents:
diff changeset
  3229
        //
hgs
parents:
diff changeset
  3230
        _LIT( KItem3, "Local Chunk Memory" );
hgs
parents:
diff changeset
  3231
        AddItemDecimalL( KItem3, iTracker->InfoPeaks().iMemoryChunkLocal );
hgs
parents:
diff changeset
  3232
        //
hgs
parents:
diff changeset
  3233
        _LIT( KItem4, "Shared Chunk Memory" );
hgs
parents:
diff changeset
  3234
        AddItemDecimalL( KItem4, iTracker->InfoPeaks().iMemoryChunkShared );
hgs
parents:
diff changeset
  3235
        //
hgs
parents:
diff changeset
  3236
        _LIT( KItem5, "Global Data Memory" );
hgs
parents:
diff changeset
  3237
        AddItemDecimalL( KItem5, iTracker->InfoPeaks().iMemoryGlobalData );
hgs
parents:
diff changeset
  3238
        //
hgs
parents:
diff changeset
  3239
        _LIT( KItem6, "Total" );
hgs
parents:
diff changeset
  3240
        if  ( iTotalIncludesSharedMemory )
hgs
parents:
diff changeset
  3241
            {
hgs
parents:
diff changeset
  3242
            AddItemLongL( KItem6, iTracker->InfoPeaks().TotalIncShared() );
hgs
parents:
diff changeset
  3243
            }
hgs
parents:
diff changeset
  3244
        else
hgs
parents:
diff changeset
  3245
            {
hgs
parents:
diff changeset
  3246
            AddItemLongL( KItem6, iTracker->InfoPeaks().TotalExcShared() );
hgs
parents:
diff changeset
  3247
            }
hgs
parents:
diff changeset
  3248
        }
hgs
parents:
diff changeset
  3249
    }
hgs
parents:
diff changeset
  3250
hgs
parents:
diff changeset
  3251
hgs
parents:
diff changeset
  3252
CMemSpyThreadInfoMemoryTrackingStatisticsPeak* CMemSpyThreadInfoMemoryTrackingStatisticsPeak::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  3253
    {
hgs
parents:
diff changeset
  3254
    CMemSpyThreadInfoMemoryTrackingStatisticsPeak* self = new(ELeave) CMemSpyThreadInfoMemoryTrackingStatisticsPeak( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  3255
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  3256
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  3257
        {
hgs
parents:
diff changeset
  3258
        self->ConstructL();
hgs
parents:
diff changeset
  3259
        }
hgs
parents:
diff changeset
  3260
    return self;
hgs
parents:
diff changeset
  3261
    }
hgs
parents:
diff changeset
  3262
hgs
parents:
diff changeset
  3263
hgs
parents:
diff changeset
  3264
TPtrC CMemSpyThreadInfoMemoryTrackingStatisticsPeak::Name() const
hgs
parents:
diff changeset
  3265
    {
hgs
parents:
diff changeset
  3266
    _LIT(KName, "\tPeak Statistics");
hgs
parents:
diff changeset
  3267
    return TPtrC( KName );
hgs
parents:
diff changeset
  3268
    }
hgs
parents:
diff changeset
  3269
hgs
parents:
diff changeset
  3270
hgs
parents:
diff changeset
  3271
void CMemSpyThreadInfoMemoryTrackingStatisticsPeak::SetTotalIncludesSharedMemoryL( TBool aIncludesSharedMemory )
hgs
parents:
diff changeset
  3272
    {
hgs
parents:
diff changeset
  3273
    iTotalIncludesSharedMemory = aIncludesSharedMemory;
hgs
parents:
diff changeset
  3274
    
hgs
parents:
diff changeset
  3275
    // Update totals
hgs
parents:
diff changeset
  3276
    HandleMemoryChangedL( iTracker->ProcessId(), iTracker->InfoCurrent(), iTracker->InfoHWMIncShared(), iTracker->InfoHWMExcShared() );
hgs
parents:
diff changeset
  3277
    }
hgs
parents:
diff changeset
  3278
hgs
parents:
diff changeset
  3279
hgs
parents:
diff changeset
  3280
void CMemSpyThreadInfoMemoryTrackingStatisticsPeak::HandleMemoryTrackingStartedL()
hgs
parents:
diff changeset
  3281
    {
hgs
parents:
diff changeset
  3282
    }
hgs
parents:
diff changeset
  3283
hgs
parents:
diff changeset
  3284
hgs
parents:
diff changeset
  3285
void CMemSpyThreadInfoMemoryTrackingStatisticsPeak::HandleMemoryTrackingStoppedL()
hgs
parents:
diff changeset
  3286
    {
hgs
parents:
diff changeset
  3287
    }
hgs
parents:
diff changeset
  3288
hgs
parents:
diff changeset
  3289
hgs
parents:
diff changeset
  3290
void CMemSpyThreadInfoMemoryTrackingStatisticsPeak::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& /*aInfoCurrent*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoIncShared*/, const TMemSpyDriverProcessInspectionInfo& /*aHWMInfoExcShared*/ )
hgs
parents:
diff changeset
  3291
    {
hgs
parents:
diff changeset
  3292
    Item( 0 ).SetDecimalL( iTracker->InfoPeaks().iMemoryStack );
hgs
parents:
diff changeset
  3293
    Item( 1 ).SetDecimalL( iTracker->InfoPeaks().iMemoryHeap );
hgs
parents:
diff changeset
  3294
    Item( 2 ).SetDecimalL( iTracker->InfoPeaks().iMemoryChunkLocal );
hgs
parents:
diff changeset
  3295
    Item( 3 ).SetDecimalL( iTracker->InfoPeaks().iMemoryChunkShared );
hgs
parents:
diff changeset
  3296
    Item( 4 ).SetDecimalL( iTracker->InfoPeaks().iMemoryGlobalData );
hgs
parents:
diff changeset
  3297
    //
hgs
parents:
diff changeset
  3298
    if ( iTotalIncludesSharedMemory )
hgs
parents:
diff changeset
  3299
        {
hgs
parents:
diff changeset
  3300
        Item( 5 ).SetLongL( iTracker->InfoPeaks().TotalIncShared() );
hgs
parents:
diff changeset
  3301
        }
hgs
parents:
diff changeset
  3302
    else
hgs
parents:
diff changeset
  3303
        {
hgs
parents:
diff changeset
  3304
        Item( 5 ).SetLongL( iTracker->InfoPeaks().TotalExcShared() );
hgs
parents:
diff changeset
  3305
        }
hgs
parents:
diff changeset
  3306
    }
hgs
parents:
diff changeset
  3307
hgs
parents:
diff changeset
  3308
hgs
parents:
diff changeset
  3309
hgs
parents:
diff changeset
  3310
hgs
parents:
diff changeset
  3311
hgs
parents:
diff changeset
  3312
hgs
parents:
diff changeset
  3313
hgs
parents:
diff changeset
  3314
hgs
parents:
diff changeset
  3315
hgs
parents:
diff changeset
  3316
hgs
parents:
diff changeset
  3317
hgs
parents:
diff changeset
  3318
hgs
parents:
diff changeset
  3319
hgs
parents:
diff changeset
  3320
hgs
parents:
diff changeset
  3321
hgs
parents:
diff changeset
  3322
hgs
parents:
diff changeset
  3323
CMemSpyThreadInfoMemoryTrackingStatisticsHWM::CMemSpyThreadInfoMemoryTrackingStatisticsHWM( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  3324
:   CMemSpyThreadInfoItemBase( aContainer, EMemSpyThreadInfoItemTypeMemoryTrackingHWM, aAsyncConstruction ), iTotalIncludesSharedMemory( ETrue )
hgs
parents:
diff changeset
  3325
    {
hgs
parents:
diff changeset
  3326
    }
hgs
parents:
diff changeset
  3327
hgs
parents:
diff changeset
  3328
hgs
parents:
diff changeset
  3329
CMemSpyThreadInfoMemoryTrackingStatisticsHWM::~CMemSpyThreadInfoMemoryTrackingStatisticsHWM()
hgs
parents:
diff changeset
  3330
    {
hgs
parents:
diff changeset
  3331
    if  ( iTracker )
hgs
parents:
diff changeset
  3332
        {
hgs
parents:
diff changeset
  3333
        iTracker->RemoveObserver( *this );
hgs
parents:
diff changeset
  3334
        }
hgs
parents:
diff changeset
  3335
    }
hgs
parents:
diff changeset
  3336
hgs
parents:
diff changeset
  3337
hgs
parents:
diff changeset
  3338
void CMemSpyThreadInfoMemoryTrackingStatisticsHWM::ConstructL()
hgs
parents:
diff changeset
  3339
    {
hgs
parents:
diff changeset
  3340
    if  ( iTracker )
hgs
parents:
diff changeset
  3341
        {
hgs
parents:
diff changeset
  3342
        iTracker->RemoveObserver( *this );
hgs
parents:
diff changeset
  3343
        }
hgs
parents:
diff changeset
  3344
    iTracker = &Container().Engine().HelperProcess().TrackerL( Container().Thread().Process() );
hgs
parents:
diff changeset
  3345
    if  ( iTracker )
hgs
parents:
diff changeset
  3346
        {
hgs
parents:
diff changeset
  3347
        iTracker->AddObserverL( *this );
hgs
parents:
diff changeset
  3348
        //
hgs
parents:
diff changeset
  3349
        _LIT( KItem1, "Stack Memory" );
hgs
parents:
diff changeset
  3350
        _LIT( KItem2, "Heap Memory" );
hgs
parents:
diff changeset
  3351
        _LIT( KItem3, "Local Chunk Memory" );
hgs
parents:
diff changeset
  3352
        _LIT( KItem4, "Shared Chunk Memory" );
hgs
parents:
diff changeset
  3353
        _LIT( KItem5, "Global Data Memory" );
hgs
parents:
diff changeset
  3354
        _LIT( KItem6, "Total" );
hgs
parents:
diff changeset
  3355
        //
hgs
parents:
diff changeset
  3356
        if  ( iTotalIncludesSharedMemory )
hgs
parents:
diff changeset
  3357
            {
hgs
parents:
diff changeset
  3358
            AddItemDecimalL( KItem1, iTracker->InfoHWMIncShared().iMemoryStack );
hgs
parents:
diff changeset
  3359
            AddItemDecimalL( KItem2, iTracker->InfoHWMIncShared().iMemoryHeap );
hgs
parents:
diff changeset
  3360
            AddItemDecimalL( KItem3, iTracker->InfoHWMIncShared().iMemoryChunkLocal );
hgs
parents:
diff changeset
  3361
            AddItemDecimalL( KItem4, iTracker->InfoHWMIncShared().iMemoryChunkShared );
hgs
parents:
diff changeset
  3362
            AddItemDecimalL( KItem5, iTracker->InfoHWMIncShared().iMemoryGlobalData );
hgs
parents:
diff changeset
  3363
            AddItemLongL(    KItem6, iTracker->InfoHWMIncShared().TotalIncShared() );
hgs
parents:
diff changeset
  3364
            }
hgs
parents:
diff changeset
  3365
        else
hgs
parents:
diff changeset
  3366
            {
hgs
parents:
diff changeset
  3367
            AddItemDecimalL( KItem1, iTracker->InfoHWMExcShared().iMemoryStack );
hgs
parents:
diff changeset
  3368
            AddItemDecimalL( KItem2, iTracker->InfoHWMExcShared().iMemoryHeap );
hgs
parents:
diff changeset
  3369
            AddItemDecimalL( KItem3, iTracker->InfoHWMExcShared().iMemoryChunkLocal );
hgs
parents:
diff changeset
  3370
            AddItemDecimalL( KItem4, iTracker->InfoHWMExcShared().iMemoryChunkShared );
hgs
parents:
diff changeset
  3371
            AddItemDecimalL( KItem5, iTracker->InfoHWMExcShared().iMemoryGlobalData );
hgs
parents:
diff changeset
  3372
            AddItemLongL(    KItem6, iTracker->InfoHWMExcShared().TotalExcShared() );
hgs
parents:
diff changeset
  3373
            }
hgs
parents:
diff changeset
  3374
        }
hgs
parents:
diff changeset
  3375
    }
hgs
parents:
diff changeset
  3376
hgs
parents:
diff changeset
  3377
hgs
parents:
diff changeset
  3378
CMemSpyThreadInfoMemoryTrackingStatisticsHWM* CMemSpyThreadInfoMemoryTrackingStatisticsHWM::NewLC( CMemSpyThreadInfoContainer& aContainer, TBool aAsyncConstruction )
hgs
parents:
diff changeset
  3379
    {
hgs
parents:
diff changeset
  3380
    CMemSpyThreadInfoMemoryTrackingStatisticsHWM* self = new(ELeave) CMemSpyThreadInfoMemoryTrackingStatisticsHWM( aContainer, aAsyncConstruction );
hgs
parents:
diff changeset
  3381
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
  3382
    if  ( !aAsyncConstruction )
hgs
parents:
diff changeset
  3383
        {
hgs
parents:
diff changeset
  3384
        self->ConstructL();
hgs
parents:
diff changeset
  3385
        }
hgs
parents:
diff changeset
  3386
    return self;
hgs
parents:
diff changeset
  3387
    }
hgs
parents:
diff changeset
  3388
hgs
parents:
diff changeset
  3389
hgs
parents:
diff changeset
  3390
void CMemSpyThreadInfoMemoryTrackingStatisticsHWM::SetTotalIncludesSharedMemoryL( TBool aIncludesSharedMemory )
hgs
parents:
diff changeset
  3391
    {
hgs
parents:
diff changeset
  3392
    iTotalIncludesSharedMemory = aIncludesSharedMemory;
hgs
parents:
diff changeset
  3393
    
hgs
parents:
diff changeset
  3394
    // Update totals
hgs
parents:
diff changeset
  3395
    HandleMemoryChangedL( iTracker->ProcessId(), iTracker->InfoCurrent(), iTracker->InfoHWMIncShared(), iTracker->InfoHWMExcShared() );
hgs
parents:
diff changeset
  3396
    }
hgs
parents:
diff changeset
  3397
hgs
parents:
diff changeset
  3398
hgs
parents:
diff changeset
  3399
TPtrC CMemSpyThreadInfoMemoryTrackingStatisticsHWM::Name() const
hgs
parents:
diff changeset
  3400
    {
hgs
parents:
diff changeset
  3401
    _LIT(KName, "\tHigh-Water-Mark Statistics");
hgs
parents:
diff changeset
  3402
    return TPtrC( KName );
hgs
parents:
diff changeset
  3403
    }
hgs
parents:
diff changeset
  3404
hgs
parents:
diff changeset
  3405
hgs
parents:
diff changeset
  3406
void CMemSpyThreadInfoMemoryTrackingStatisticsHWM::HandleMemoryTrackingStartedL()
hgs
parents:
diff changeset
  3407
    {
hgs
parents:
diff changeset
  3408
    }
hgs
parents:
diff changeset
  3409
hgs
parents:
diff changeset
  3410
hgs
parents:
diff changeset
  3411
void CMemSpyThreadInfoMemoryTrackingStatisticsHWM::HandleMemoryTrackingStoppedL()
hgs
parents:
diff changeset
  3412
    {
hgs
parents:
diff changeset
  3413
    }
hgs
parents:
diff changeset
  3414
hgs
parents:
diff changeset
  3415
hgs
parents:
diff changeset
  3416
void CMemSpyThreadInfoMemoryTrackingStatisticsHWM::HandleMemoryChangedL( const TProcessId& /*aPid*/, const TMemSpyDriverProcessInspectionInfo& /*aInfoCurrent*/, const TMemSpyDriverProcessInspectionInfo& aHWMInfoIncShared, const TMemSpyDriverProcessInspectionInfo& aHWMInfoExcShared )
hgs
parents:
diff changeset
  3417
    {
hgs
parents:
diff changeset
  3418
    if  ( iTotalIncludesSharedMemory )
hgs
parents:
diff changeset
  3419
        {
hgs
parents:
diff changeset
  3420
        Item( 0 ).SetDecimalL( aHWMInfoIncShared.iMemoryStack );
hgs
parents:
diff changeset
  3421
        Item( 1 ).SetDecimalL( aHWMInfoIncShared.iMemoryHeap );
hgs
parents:
diff changeset
  3422
        Item( 2 ).SetDecimalL( aHWMInfoIncShared.iMemoryChunkLocal );
hgs
parents:
diff changeset
  3423
        Item( 3 ).SetDecimalL( aHWMInfoIncShared.iMemoryChunkShared );
hgs
parents:
diff changeset
  3424
        Item( 4 ).SetDecimalL( aHWMInfoIncShared.iMemoryGlobalData );
hgs
parents:
diff changeset
  3425
        Item( 5 ).SetLongL(    aHWMInfoIncShared.TotalIncShared() );
hgs
parents:
diff changeset
  3426
        }
hgs
parents:
diff changeset
  3427
    else
hgs
parents:
diff changeset
  3428
        {
hgs
parents:
diff changeset
  3429
        Item( 0 ).SetDecimalL( aHWMInfoExcShared.iMemoryStack );
hgs
parents:
diff changeset
  3430
        Item( 1 ).SetDecimalL( aHWMInfoExcShared.iMemoryHeap );
hgs
parents:
diff changeset
  3431
        Item( 2 ).SetDecimalL( aHWMInfoExcShared.iMemoryChunkLocal );
hgs
parents:
diff changeset
  3432
        Item( 3 ).SetDecimalL( aHWMInfoExcShared.iMemoryChunkShared );
hgs
parents:
diff changeset
  3433
        Item( 4 ).SetDecimalL( aHWMInfoExcShared.iMemoryGlobalData );
hgs
parents:
diff changeset
  3434
        Item( 5 ).SetLongL(    aHWMInfoExcShared.TotalExcShared() );
hgs
parents:
diff changeset
  3435
        }
hgs
parents:
diff changeset
  3436
    }