memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapData.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:37:10 +0100
branchRCL_3
changeset 44 52e343bb8f80
parent 43 ca8a1b6995f6
child 49 7fdc9a71d314
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "MemSpyDriverLogChanHeapData.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
// System includes
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <u32hal.h>
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <e32rom.h>
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <memspy/driver/memspydriverobjectsshared.h>
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <memspy/driver/memspydriverconstants.h>
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
// Shared includes
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "MemSpyDriverOpCodes.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "MemSpyDriverObjectsInternal.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
// User includes
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "MemSpyDriverHeap.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include "MemSpyDriverUtils.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "MemSpyDriverDevice.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include "MemSpyDriverOSAdaption.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include "MemSpyDriverHeapWalker.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "MemSpyDriverUserEventMonitor.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "MemSpyDriverSuspensionManager.h"
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
DMemSpyDriverLogChanHeapData::DMemSpyDriverLogChanHeapData( DMemSpyDriverDevice& aDevice, DThread& aThread )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
:	DMemSpyDriverLogChanHeapBase( aDevice, aThread ), iKernelHeap( aDevice.OSAdaption() )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::DMemSpyDriverLogChanHeapData() - this: 0x%08x", this ));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
DMemSpyDriverLogChanHeapData::~DMemSpyDriverLogChanHeapData()
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::~DMemSpyDriverLogChanHeapData() - START - this: 0x%08x", this ));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::~DMemSpyDriverLogChanHeapData() - END - this: 0x%08x", this ));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
	}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
TInt DMemSpyDriverLogChanHeapData::Request( TInt aFunction, TAny* a1, TAny* a2 )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
	{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
	TInt r = DMemSpyDriverLogChanHeapBase::Request( aFunction, a1, a2 );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    if  ( r == KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
        {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
	    switch( aFunction )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
		    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
        case EMemSpyDriverOpCodeHeapDataGetUser:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
            r = GetHeapDataUser( (TMemSpyDriverInternalHeapDataParams*) a1 );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
            break;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
        case EMemSpyDriverOpCodeHeapDataGetKernelInit:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
            r = GetHeapDataKernelInit( (TMemSpyHeapInfo*) a1, (TDes8*) a2 );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
            break;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
        case EMemSpyDriverOpCodeHeapDataGetKernelFetch:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
            r = GetHeapDataKernelFetch( (TDes8*) a1 );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
            break;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
        default:
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
            r = KErrNotSupported;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
		    break;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
		    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    //
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
    return r;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
	}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
TBool DMemSpyDriverLogChanHeapData::IsHandler( TInt aFunction ) const
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    return ( aFunction > EMemSpyDriverOpCodeHeapDataBase && aFunction < EMemSpyDriverOpCodeHeapDataEnd );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
TInt DMemSpyDriverLogChanHeapData::GetHeapDataUser( TMemSpyDriverInternalHeapDataParams* aParams )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser() - START"));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
	TMemSpyDriverInternalHeapDataParams params;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, &params, sizeof(TMemSpyDriverInternalHeapDataParams) );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    //
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    if  ( r == KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
        {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - thread id: %d, remaining: %8d, vtable: 0x%08x", params.iTid, params.iRemaining, params.iRHeapVTable));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
        // Work out if we need to read the user or kernel heap data. 
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
        //
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
        // NB: The two 'get heap data' functions return either an error ( < KErrNone ) or then
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
        // return the length of the descriptor data that was written to the client's address
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
        // space.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
        //
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
        r = GetHeapDataUser( params );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
        // Write back to user space if everything went okay. Remember that the 
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
        // return value above will be the length of data that was written to the
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
        // client if there was no error.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
        if  ( r >= KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
            {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
            const TInt clientDescriptorLength = r;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
            // Make sure we update client's remaining data
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
            r = Kern::ThreadRawWrite( &ClientThread(), aParams, &params, sizeof(TMemSpyDriverInternalHeapDataParams) );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
            
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
            // ... and if that went okay, then we return the length of the descriptor data
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
            // back to the client.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
            if  ( r == KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
                {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
                r = clientDescriptorLength;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
                }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
            }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    else
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
        {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - params read error: %d", r));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
    // Done
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser() - END - ret: %d", r));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
    return r;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
TInt DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit( TMemSpyHeapInfo* aInfo, TDes8* aFreeCells )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    // First phase is to 
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    //
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    // a) Open kernel heap
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    // b) Make a copy of the heap data
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
    // c) Walk copy in order to extract statistics (meta data, i.e. TMemSpyHeapInfo)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    //
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    // The driver leaves kernel context with the copy of the kernel heap still associated with MemSpy's process.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    // The second driver call will copy the chunk data to user side and release the kernel side chunk.
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   165
    const TBool isInit = iKernelHeap.ChunkIsInitialised();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   166
    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - START - isInit: %d", isInit ));
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   167
    __ASSERT_ALWAYS( !isInit, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicKernelHeapDataInitError ) );
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    iKernelHeap.Reset();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    NKern::ThreadEnterCS();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   172
    // We must identify if we have a debug kernel allocator
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   173
    const TBool debugAllocator = IsDebugKernel();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   174
    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - debugAllocator: %d", debugAllocator ) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   175
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    TFullName heapChunkName;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    TInt r = OpenKernelHeap( iKernelHeap, &heapChunkName );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - open err: %d", r));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    if  ( r == KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
        {
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   182
        r = GetHeapInfoKernel( iKernelHeap, debugAllocator, heapChunkName, aInfo, aFreeCells );
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - base class get heap info: %d", r) );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
        // If everything was okay, we can now return back to user-side, indicating the amount of heap data
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
        // that they must prepare to read (in the next operation).
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
        if  ( r == KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
            {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
            // Indicate how big a buffer the user-side must prepare.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
            r = OSAdaption().DChunk().GetSize( iKernelHeap.Chunk() );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
            TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - user side buffer needs to be: %d", r) );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
            }
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   193
        else if ( iKernelHeap.ChunkIsInitialised() )
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
            {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
            // Error scenario - must close heap
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   196
            iKernelHeap.DisassociateWithKernelChunk();
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
            }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    NKern::ThreadLeaveCS();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - END - ret: %d", r));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
    return r;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
TInt DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch( TDes8* aSink )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch() - START"));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    NKern::ThreadEnterCS();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
    // We should already have an initialised copy of the kernel heap
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   214
    const TBool isInit = iKernelHeap.ChunkIsInitialised();
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch() - isInit: %d", isInit ));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    __ASSERT_ALWAYS( isInit, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicKernelHeapDataFetchError ) );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
    // Get user side (MemSpy) descriptor length info
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
    TInt destLen;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    TInt destMax;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    TUint8* destPtr = NULL;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    TInt r = Kern::ThreadGetDesInfo( &ClientThread(), aSink, destLen, destMax, destPtr, ETrue );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", aSink, destPtr, destLen, destMax, r ));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    if  ( r == KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
        {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        // Calculate start of real heap data (skipping over embedded RHeap object)
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
        const TUint8* startOfHeapOffset = iKernelHeap.Base();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - startOfHeapOffset:    0x%08x", startOfHeapOffset));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        const TUint heapSize = iKernelHeap.Size();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - heapSize:               %8d", heapSize));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
        if ( destMax >= heapSize )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
            {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
            }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
        else
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
            {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
            // Not enough space
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
            r = KErrOverflow;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
            TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - not enough space in client descriptor" ));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
            }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
        // The remaining number of bytes should allow us to calculate the position
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
        // to read from.
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
        const TInt amountToRead = Min( heapSize, destMax );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
        const TAny* readAddress = startOfHeapOffset;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - amountToRead:         %d", amountToRead));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - readAddress:          0x%08x", readAddress));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
        const TPtrC8 pKernelHeapData( (const TUint8*) readAddress, amountToRead );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
        // Copy kernel heap data to MemSpy
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - about to do write to user-space..."));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
        r = Kern::ThreadDesWrite( &ClientThread(), aSink, pKernelHeapData, 0, KChunkShiftBy0 | KTruncateToMaxLength, &ClientThread() );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch - write result: %d", r));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    // Free heap resource
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
    iKernelHeap.DisassociateWithKernelChunk();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
    NKern::ThreadLeaveCS();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch() - END - ret: %d", r));
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    return r;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   282
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
TInt DMemSpyDriverLogChanHeapData::GetHeapDataUser( TMemSpyDriverInternalHeapDataParams& aParams )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
    {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser() - START") );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
	TInt r = OpenTempObject( aParams.iTid, EThread );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
	if  ( r != KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
		{
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    	Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser() - END - thread not found");
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
		return r;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
		}
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
    else 
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
        {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
        const DMemSpyDriverLogChanHeapBase::TDrmMatchType drmMatchType = IsDrmThread( TempObjectAsThread() );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
        if  ( drmMatchType != DMemSpyDriverLogChanHeapBase::EMatchTypeNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
            {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
            // Check whether it's a DRM thread...
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
            DThread* thread = (DThread*) TempObject();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    	    Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser() - END - Not allowing dump of DRM heap - matchType: %d, thread: %O", drmMatchType, thread );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
            CloseTempObject();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
		    return KErrAccessDenied;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
            }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
        }
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   307
    
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    // Check that the process' thread's are suspended
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    DThread* thread = (DThread*) TempObject();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    if  ( SuspensionManager().IsSuspended( *thread ) )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
        {
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   312
        // Find the chunk with the correct handle
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - thread: %O", thread) );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
        RMemSpyDriverRHeapUser heap( OSAdaption() );
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   315
        const TBool allocatorIsReallyRHeap = GetUserHeapHandle( *thread, heap, aParams.iRHeapVTable );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   316
        if  ( allocatorIsReallyRHeap )
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
            {
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   318
            const TInt chunkHandle = heap.iChunkHandle;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   319
	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunkHandle: 0x%08x, thread: %O", chunkHandle, thread) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   320
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   321
  	        NKern::ThreadEnterCS();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   322
 	        NKern::LockSystem();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   323
            DChunk* chunk = (DChunk*) Kern::ObjectFromHandle( thread, chunkHandle, EChunk );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   324
            NKern::UnlockSystem();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   325
	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunk: 0x%08x", chunk ) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   326
  	        NKern::ThreadLeaveCS();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   327
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   328
            if  ( chunk != NULL )
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
                {
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   330
                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunkBase: 0x%08x, size: %8d, maxLen: %8d, chunk: %O", chunk->iBase, chunk->iSize, chunk->iMaxSize, chunk) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   331
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   332
                // If the client specified a checksum value, then we must walk the heap just to make sure
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   333
                // it hasn't changed. Expensive operation, but good for paranoia purposes...
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   334
                if  ( aParams.iChecksum != 0 )
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   335
                    {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   336
                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - checksum validation requested - expecting: 0x%08x", aParams.iChecksum ) );
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   338
                    RMemSpyDriverRHeapUser rHeap( OSAdaption() );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   339
                    DChunk* userHeapChunk = NULL;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   340
                    r = OpenUserHeap( *thread, aParams.iRHeapVTable, rHeap, userHeapChunk );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   341
                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - opening client heap returned: %d", r) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   342
                    if  ( r == KErrNone )
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   343
                        {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   344
                        TMemSpyHeapWalkerNullObserver observer; 
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   345
                        RMemSpyDriverHeapWalker heapWalker( rHeap, aParams.iDebugAllocator );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   346
                        heapWalker.SetObserver( &observer );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   347
                        
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   348
                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - starting traversal..." ));
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   349
#if ( defined( TRACE_TYPE_USERHEAP ) && defined( TRACE_TYPE_HEAPWALK ) )
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   350
                        heapWalker.SetPrintDebug();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   351
#endif
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   352
                        r = heapWalker.Traverse();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   353
                        const TUint32 calculatedChecksum = heapWalker.Stats().iFreeCellCRC;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   354
                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - finished traversal - err: %d, checksum: 0x%08x", r, calculatedChecksum ));
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   356
                        // Release resources
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   357
                        rHeap.DisassociateWithKernelChunk();
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   359
                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - comparing CALCULATED: 0x%08x vs EXPECTED: 0x%08x", calculatedChecksum, aParams.iChecksum ));
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   360
                        if  ( calculatedChecksum != aParams.iChecksum )
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   361
                            {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   362
                            Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - comparing CALCULATED: 0x%08x vs EXPECTED: 0x%08x for thread %O", calculatedChecksum, aParams.iChecksum, thread );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   363
                            r = KErrCorrupt;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   364
                            }
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   365
                        }
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   366
                    else
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   367
                        {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   368
                        // Couldn't verify checksum in this situation...
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   369
                        }
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   370
                    }
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   371
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   372
                // Get user side (MemSpy) descriptor length info
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
                if  ( r == KErrNone )
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
                    {
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   375
                    TInt destLen;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   376
                    TInt destMax;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   377
                    TUint8* destPtr = NULL;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   378
                    r = Kern::ThreadGetDesInfo( &ClientThread(), aParams.iDes, destLen, destMax, destPtr, ETrue );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   379
                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", aParams.iDes, destPtr, destLen, destMax, r ));
43
ca8a1b6995f6 Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 0
diff changeset
   380
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   381
                    if  ( r == KErrNone )
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   382
                        {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   383
                        // Calculate start of real heap data (skipping over embedded RHeap object)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   384
                        const TUint8* startOfHeapOffset = heap.iBase;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   385
        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - startOfHeapOffset:    0x%08x", startOfHeapOffset) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   386
            
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   387
                        // Deal with initial case
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   388
                        const TUint heapSize = heap.Size();
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   389
        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - heapSize:               %8d", heapSize) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   390
                        if  ( aParams.iRemaining < 0 )
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   391
                            {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   392
                            // Initial case, remaining initialised to -1
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   393
                            aParams.iRemaining = heapSize;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   394
                            }
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   396
                        // The remaining number of bytes should allow us to calculate the position
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   397
                        // to read from.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   398
                        const TInt amountToRead = Min( aParams.iRemaining, destMax );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   399
        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - amountToRead:           %8d", amountToRead) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   400
                        const TInt readOffset = ( heapSize - aParams.iRemaining );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   401
        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - readOffset:             %8d", readOffset) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   402
                        const TAny* readAddress = startOfHeapOffset + readOffset;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   403
        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - readAddress:          0x%08x", readAddress) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   404
            
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   405
                        // Do the read from the heap we are spying on into MemSpy's address space
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   406
                        r = Kern::ThreadRawRead( thread, readAddress, destPtr, amountToRead );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   407
        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - read result: %d", r) );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   408
                        //
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   409
                        if  (r == KErrNone)
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   410
                            {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   411
                            // Client takes care of updating descriptor length.
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   412
                            r = amountToRead;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   413
                            }
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   414
                        else if ( r == KErrBadDescriptor )
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   415
                            {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   416
                            MemSpyDriverUtils::PanicThread( ClientThread(), EPanicBadDescriptor );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   417
                            }
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   418
            
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   419
                        // Update remaining bytes
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   420
                        aParams.iRemaining -= amountToRead;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   421
                        aParams.iReadAddress = (TUint) readAddress;
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
                        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
                    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
                }
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   425
            else
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   426
                {
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   427
    	        Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunk not found! thread: %O", thread );
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   428
                r = KErrNotFound;
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   429
                }
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   430
            }
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
        else
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
            {
44
52e343bb8f80 Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents: 43
diff changeset
   433
    	    Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - couldnt find heap - vtable mis-match? thread: %O", thread );
0
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
            r = KErrNotSupported;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
            }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
    else
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
        {
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
        Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - parent process not suspended => KErrAccessDenied - thread: %O", thread );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
        r = KErrAccessDenied;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
        }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
	CloseTempObject();
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser() - END - ret: %d", r) );
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    return r;
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    }
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
a03f92240627 Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450