dbgagents/trkagent/eka2driver/TrkKernelDriver.cpp
author ravikurupati
Tue, 02 Mar 2010 10:33:16 +0530
changeset 0 c6b0df440bee
permissions -rw-r--r--
Initial contribution of EPL licensed sources
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     1
/*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     2
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     3
* All rights reserved.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     4
* This component and the accompanying materials are made available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     6
* which accompanies this distribution, and is available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     8
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     9
* Initial Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    11
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    12
* Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    13
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    14
* Description: 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    15
*
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    16
*/
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    17
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    18
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    19
#ifdef __WINS__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    20
#error - this driver cannot be built for emulation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    21
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    22
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    23
#include <e32def.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    24
#include <e32cmn.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    25
#include <u32std.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    26
#include <kernel.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    27
#include <kern_priv.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    28
#include <nk_trace.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    29
//#include <mmboot.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    30
#include <arm.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    31
#include <cache.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    32
#include <platform.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    33
#include <nkern.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    34
#include <u32hal.h>
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    35
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    36
#include "TrkKernelDriver.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    37
#include "TrkDriver.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    38
#include "TrkEventHandler.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    39
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    40
#define KTrkAppSecurUid 0x200170BB
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    41
#define KTrkExeSecurUid 0x200159E2
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    42
#define KTrkSrvSecurUid 0x200170B7
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    43
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    44
// Uncomment the line below for reading kernel thread registers.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    45
// There is a problem using NKern::Lock before calling UserContextType on old releases like S60 3.0
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    46
// So for now, disabling the supporting reading kern thread registers as we are not really supporting
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    47
// device driver debugging anyway.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    48
//#define SUPPORT_KERNCONTEXT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    49
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    50
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    51
// Static function definitions
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    52
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    53
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    54
static TInt Bitcount(TUint32 val)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    55
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    56
	TInt nbits;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    57
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    58
	for (nbits = 0; val != 0; nbits++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    59
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    60
		val &= val - 1;		// delete rightmost 1-bit in val
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    61
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    62
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    63
	return nbits;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    64
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    65
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    66
static TUint8 tolower(TUint8 c)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    67
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    68
	if (c >= 'A' && c <= 'Z')
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    69
		c = c + ('a' - 'A');
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    70
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    71
	return c;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    72
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    73
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    74
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    75
static TInt _strnicmp(const TUint8 *s1, const TUint8 *s2, int n)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    76
{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    77
    int i;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    78
    TUint8 c1, c2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    79
    for (i=0; i<n; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    80
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    81
        c1 = tolower(*s1++);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    82
        c2 = tolower(*s2++);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    83
        if (c1 < c2) return -1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    84
        if (c1 > c2) return 1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    85
        if (!c1) return 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    86
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    87
    return 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    88
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    89
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    90
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    91
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    92
// DMetroTrkDriverFactory implementation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    93
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    94
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    95
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    96
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    97
// DMetroTrkDriverFactory constructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    98
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    99
DMetroTrkDriverFactory::DMetroTrkDriverFactory()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   100
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   101
    iVersion = TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   102
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   103
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   104
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   105
// DMetroTrkDriverFactory::Create
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   106
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   107
TInt DMetroTrkDriverFactory::Create(DLogicalChannelBase*& aChannel)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   108
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   109
	if (iOpenChannels != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   110
		return KErrInUse; // a channel is already open
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   111
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   112
	aChannel = new DMetroTrkChannel(this);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   113
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   114
	return aChannel ? KErrNone : KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   115
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   116
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   117
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   118
// DMetroTrkDriverFactory::Install
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   119
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   120
TInt DMetroTrkDriverFactory::Install()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   121
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   122
    return(SetName(&KMetroTrkDriverName));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   123
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   124
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   125
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   126
// DMetroTrkDriverFactory::Install
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   127
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   128
void DMetroTrkDriverFactory::GetCaps(TDes8& aDes) const
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   129
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   130
    TCapsMetroTrkDriver b;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   131
    b.iVersion = TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   132
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   133
    Kern::InfoCopy(aDes,(TUint8*)&b, sizeof(b));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   134
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   135
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   136
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   137
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   138
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   139
// DMetroTrkChannel implementation
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   140
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   141
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   142
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   143
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   144
// DMetroTrkChannel constructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   145
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   146
DMetroTrkChannel::DMetroTrkChannel(DLogicalDevice* aLogicalDevice)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   147
	: iExcludedROMAddressStart(ROM_LINEAR_BASE),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   148
      iExcludedROMAddressEnd(0),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   149
   	  iBreakPointList(NUMBER_OF_TEMP_BREAKPOINTS, 0),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   150
  	  iNextBreakId(NUMBER_OF_TEMP_BREAKPOINTS),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   151
      iEventInfo(NULL),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   152
  	  iEventQueue(NUMBER_OF_EVENTS_TO_QUEUE, 0),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   153
  	  iTraceEventQueue(NUMBER_OF_EVENTS_TO_QUEUE, 0),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   154
      iRequestGetEventStatus(NULL),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   155
   	  iPageSize(0x1000),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   156
   	  iNotifyLibLoadedEvent(ETrue),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   157
   	  iMultipleMemModel(EFalse),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   158
   	  iExcInfoValid(EFalse),
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   159
   	  iDebugging(ETrue)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   160
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   161
	LOG_MSG("DMetroTrkChannel::DMetroTrkChannel()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   162
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   163
	iDevice = aLogicalDevice;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   164
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   165
	iClientThread = &Kern::CurrentThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   166
	TInt err = iClientThread->Open();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   167
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   168
	iBreakPointList.Reset();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   169
	TBreakEntry emptyTempBreak;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   170
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   171
	for (TInt i = 0; i < NUMBER_OF_TEMP_BREAKPOINTS; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   172
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   173
		emptyTempBreak.iId = i;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   174
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   175
		if (KErrNone != iBreakPointList.Append(emptyTempBreak))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   176
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   177
			LOG_MSG("Error appending blank temp break entry");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   178
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   179
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   180
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   181
	SEventInfo emptyEvent;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   182
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   183
	for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   184
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   185
		if (KErrNone != iEventQueue.Append(emptyEvent))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   186
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   187
			LOG_MSG("Error appending blank event entry");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   188
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   189
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   190
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   191
	for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   192
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   193
		if (KErrNone != iTraceEventQueue.Append(emptyEvent))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   194
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   195
			LOG_MSG("Error appending blank trace event entry");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   196
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   197
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   198
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   199
	TTrkLibName emptyLib;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   200
	for (TInt i=0; i<NUMBER_OF_LIBS_TO_REGISTER; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   201
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   202
        if (KErrNone != iLibraryNotifyList.Append(emptyLib))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   203
        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   204
            LOG_MSG("Error appending blank empty lib entry");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   205
        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   206
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   207
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   208
	iPageSize = Kern::RoundToPageSize(1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   209
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   210
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   211
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   212
// DMetroTrkChannel destructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   213
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   214
DMetroTrkChannel::~DMetroTrkChannel()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   215
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   216
	LOG_MSG("DMetroTrkChannel::~DMetroTrkChannel()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   217
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   218
	iDebugging = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   219
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   220
	Kern::SafeClose((DObject*&)iClientThread, NULL);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   221
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   222
	ClearAllBreakPoints();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   223
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   224
	// close the breakpoint list and free the memory associated with it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   225
	iBreakPointList.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   226
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   227
	// close the event queue and free the memory associated with it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   228
	iEventQueue.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   229
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   230
	// close the trace event queue and free the memory associated with it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   231
	iTraceEventQueue.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   232
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   233
	//close the debug process list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   234
	iDebugProcessList.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   235
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   236
	//close the process notify list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   237
	iProcessNotifyList.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   238
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   239
	//close the code modifier
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   240
	DebugSupport::CloseCodeModifier();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   241
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   242
	// PANIC_BACKPORT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   243
	// Resume all the frozen threads with semaphores.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   244
	for(TInt i=0; i<iFrozenThreadSemaphores.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   245
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   246
		NKern::FSSignal(iFrozenThreadSemaphores[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   247
		NKern::ThreadEnterCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   248
		delete iFrozenThreadSemaphores[i];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   249
		NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   250
		iFrozenThreadSemaphores.Remove(i);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   251
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   252
	//Reset the array and delete the objects that its members point to
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   253
	iFrozenThreadSemaphores.ResetAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   254
	// END PANIC_BACKPORT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   255
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   256
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   257
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   258
// DMetroTrkChannel::DoCreate
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   259
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   260
TInt DMetroTrkChannel::DoCreate(TInt /*aUnit*/, const TDesC* anInfo, const TVersion& aVer)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   261
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   262
	LOG_MSG("DMetroTrkChannel::DoCreate()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   263
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   264
  	if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber), aVer))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   265
		return KErrNotSupported; 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   266
  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   267
  	// Do the security check here so that any arbitrary application doesn't make 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   268
  	// use of Trk kernel driver.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   269
  	if (!DoSecurityCheck())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   270
  	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   271
  		return KErrPermissionDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   272
  	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   273
  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   274
  	if (anInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   275
  	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   276
  		// this is the end address of the user library. 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   277
  		// this doesn't seem to be valid for EKA2.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   278
  		// right now we dont need this for EKA2 since we are not worried
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   279
  		// about kernel being stopped as kernel is multithreaded.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   280
  		// just retaining this for future use.		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   281
		TBuf8<32> buf;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   282
		TInt err = Kern::ThreadRawRead(iClientThread, anInfo, &buf, 32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   283
		if(err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   284
			return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   285
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   286
		//iExcludedROMAddressEnd = *(TUint32 *)(&(buf.Ptr()[20]));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   287
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   288
  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   289
  	//check whether the memory model is multiple or not.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   290
  	TUint32 memModelAttrib = (TUint32)Kern::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   291
	if ((memModelAttrib & EMemModelTypeMask) == EMemModelTypeMultiple) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   292
    { 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   293
        //Multiple memory model
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   294
        iMultipleMemModel = ETrue;        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   295
    } 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   296
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   297
	TUint caps; //ignored for now
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   298
	TInt err = DebugSupport::InitialiseCodeModifier(caps, NUMBER_OF_MAX_BREAKPOINTS);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   299
	//if code modifier initializer failed, 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   300
	//return here, since we can't set an breakpoints
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   301
	if(err != KErrNone) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   302
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   303
		       
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   304
	//Setup the driver for receiving client messages
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   305
	iDFCQue = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   306
	TBuf8<KMaxInfoName> trkDFC = _L8("TRK DFC");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   307
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   308
	err = Kern::DfcQCreate(iDFCQue, 27, &trkDFC);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   309
	if (err == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   310
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   311
		SetDfcQ(iDFCQue);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   312
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   313
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   314
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   315
		SetDfcQ(Kern::DfcQue0());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   316
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   317
	iMsgQ.Receive();  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   318
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   319
	iEventHandler = new DMetroTrkEventHandler;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   320
	if (!iEventHandler)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   321
		return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   322
	err = iEventHandler->Create(iDevice, this, iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   323
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   324
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   325
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   326
	return iEventHandler->Start();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   327
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   328
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   329
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   330
// DMetroTrkChannel::DoCancel
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   331
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   332
void DMetroTrkChannel::DoCancel(TInt aReqNo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   333
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   334
	LOG_MSG("DMetroTrkChannel::DoCancel()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   335
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   336
	switch(aReqNo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   337
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   338
		case RMetroTrkDriver::ERequestGetEventCancel:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   339
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   340
			Kern::RequestComplete(iClientThread, iRequestGetEventStatus, KErrCancel);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   341
			iEventInfo = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   342
			iRequestGetEventStatus = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   343
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   344
		break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   345
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   346
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   347
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   348
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   349
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   350
// DMetroTrkChannel::DoRequest
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   351
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   352
void DMetroTrkChannel::DoRequest(TInt aReqNo, TRequestStatus* aStatus, TAny* a1, TAny* a2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   353
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   354
	LOG_MSG("DMetroTrkChannel::DoRequest()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   355
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   356
	switch(aReqNo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   357
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   358
		case RMetroTrkDriver::ERequestGetEvent:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   359
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   360
			// check to see if we have any queued up events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   361
			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   362
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   363
				if (SEventInfo::EUnknown != iEventQueue[i].iEventType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   364
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   365
					LOG_MSG("DoRequest - slot NOT empty");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   366
					// iClientThread is the user side debugger thread, so use it to write the info to it memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   367
					TInt err = Kern::ThreadRawWrite(iClientThread, a1, (TUint8 *)&iEventQueue[i], sizeof(SEventInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   368
					if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   369
						LOG_MSG2("Error writing event info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   370
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   371
					// signal the debugger thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   372
					Kern::RequestComplete(iClientThread, aStatus, KErrNone);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   373
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   374
					iEventQueue[i].Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   375
					return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   376
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   377
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   378
				LOG_MSG("DoRequest - slot empty");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   379
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   380
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   381
			// check to see if we have any queued up trace events
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   382
			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   383
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   384
				if (SEventInfo::EUnknown != iTraceEventQueue[i].iEventType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   385
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   386
					LOG_MSG("DoRequest - slot NOT empty");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   387
					// iClientThread is the user side debugger thread, so use it to write the info to it memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   388
					TInt err = Kern::ThreadRawWrite(iClientThread, a1, (TUint8 *)&iTraceEventQueue[i], sizeof(SEventInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   389
					if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   390
						LOG_MSG2("Error writing trace event info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   391
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   392
					// signal the debugger thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   393
					Kern::RequestComplete(iClientThread, aStatus, KErrNone);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   394
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   395
					iTraceEventQueue[i].Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   396
					return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   397
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   398
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   399
				LOG_MSG("DoRequest - trace slot empty");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   400
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   401
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   402
			// store the pointer so we can modify it later
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   403
			iEventInfo = (SEventInfo *)a1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   404
			iRequestGetEventStatus = aStatus;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   405
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   406
		}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   407
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   408
			Kern::RequestComplete(iClientThread, aStatus, KErrNotSupported);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   409
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   410
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   411
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   412
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   413
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   414
// DMetroTrkChannel::DoControl
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   415
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   416
TInt DMetroTrkChannel::DoControl(TInt aFunction, TAny* a1, TAny* a2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   417
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   418
	LOG_MSG("DMetroTrkChannel::DoControl()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   419
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   420
	LOG_MSG2("DoControl Function %d", aFunction);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   421
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   422
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   423
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   424
	switch(aFunction)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   425
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   426
		case RMetroTrkDriver::EControlSetBreak:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   427
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   428
			err = SetBreak((TUint32)a1, (TMetroTrkBreakInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   429
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   430
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   431
		case RMetroTrkDriver::EControlClearBreak:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   432
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   433
			err = DoClearBreak((TInt32)a1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   434
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   435
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   436
		case RMetroTrkDriver::EControlChangeBreakThread:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   437
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   438
			err = DoChangeBreakThread((TUint32)a1, (TInt32)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   439
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   440
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   441
		case RMetroTrkDriver::EControlSuspendThread:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   442
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   443
			err = DoSuspendThread(ThreadFromId((TUint32)a1));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   444
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   445
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   446
		case RMetroTrkDriver::EControlResumeThread:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   447
		{			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   448
			err = DoResumeThread(ThreadFromId((TUint32)a1));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   449
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   450
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   451
		case RMetroTrkDriver::EControlStepRange:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   452
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   453
			err = StepRange(ThreadFromId((TUint32)a1), (TMetroTrkStepInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   454
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   455
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   456
		case RMetroTrkDriver::EControlReadMemory:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   457
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   458
			err = ReadMemory(ThreadFromId((TUint32)a1), (TMetroTrkMemoryInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   459
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   460
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   461
		case RMetroTrkDriver::EControlWriteMemory:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   462
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   463
			err = WriteMemory(ThreadFromId((TUint32)a1), (TMetroTrkMemoryInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   464
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   465
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   466
		case RMetroTrkDriver::EControlReadRegisters:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   467
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   468
			err = ReadRegisters(ThreadFromId((TUint32)a1), (TMetroTrkRegisterInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   469
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   470
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   471
		case RMetroTrkDriver::EControlWriteRegisters:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   472
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   473
			err = WriteRegisters(ThreadFromId((TUint32)a1), (TMetroTrkRegisterInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   474
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   475
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   476
		case RMetroTrkDriver::EControlGetProcessInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   477
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   478
			err = GetProcessInfo((TInt)a1, (TMetroTrkTaskInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   479
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   480
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   481
		case RMetroTrkDriver::EControlGetThreadInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   482
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   483
			err = GetThreadInfo((TInt)a1, (TMetroTrkTaskInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   484
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   485
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   486
		case RMetroTrkDriver::EControlGetProcessAddresses:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   487
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   488
			err = GetProcessAddresses(ThreadFromId((TUint32)a1), (TMetroTrkProcessInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   489
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   490
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   491
		case RMetroTrkDriver::EControlGetStaticLibraryInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   492
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   493
			err = GetStaticLibraryInfo((TInt)a1, (SEventInfo*)a2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   494
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   495
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   496
		case RMetroTrkDriver::EControlEnableLibLoadedEvent:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   497
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   498
			iNotifyLibLoadedEvent = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   499
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   500
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   501
		case RMetroTrkDriver::EControlDisableLibLoadedEvent:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   502
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   503
			iNotifyLibLoadedEvent = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   504
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   505
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   506
		case RMetroTrkDriver::EControlGetLibraryInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   507
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   508
			err = GetLibraryInfo((TMetroTrkLibInfo*)a1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   509
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   510
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   511
		case RMetroTrkDriver::EControlGetExeInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   512
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   513
			err = GetExeInfo((TMetroTrkExeInfo*)a1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   514
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   515
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   516
		case RMetroTrkDriver::EControlGetProcUidInfo:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   517
		{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   518
			err = GetProcUidInfo((TMetroTrkProcUidInfo*)a1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   519
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   520
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   521
		case RMetroTrkDriver::EControlDetachProcess:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   522
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   523
		    err = DetachProcess(ProcessFromId((TInt32)a1));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   524
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   525
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   526
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   527
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   528
			return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   529
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   530
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   531
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   532
	if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   533
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   534
		LOG_MSG2("Error %d from control function", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   535
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   536
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   537
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   538
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   539
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   540
void DMetroTrkChannel::HandleMsg(TMessageBase* aMsg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   541
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   542
	LOG_MSG("DMetroTrkChannel::HandleMsg()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   543
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   544
	TThreadMessage& m = *(TThreadMessage*)aMsg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   545
	TInt id = m.iValue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   546
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   547
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   548
	if (id == (TInt)ECloseMsg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   549
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   550
		if (iEventHandler)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   551
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   552
			iDebugging = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   553
			iEventHandler->Stop();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   554
			iEventHandler->Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   555
			iEventHandler = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   556
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   557
		m.Complete(KErrNone, EFalse);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   558
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   559
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   560
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   561
	if (id == KMaxTInt)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   562
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   563
		// DoCancel
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   564
		DoCancel(m.Int0());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   565
		m.Complete(KErrNone, ETrue); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   566
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   567
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   568
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   569
	if (id < 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   570
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   571
		// DoRequest
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   572
		TRequestStatus* pStatus = (TRequestStatus*)m.Ptr0();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   573
		DoRequest(~id, pStatus, m.Ptr1(), m.Ptr2());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   574
		m.Complete(KErrNone, ETrue);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   575
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   576
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   577
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   578
		// DoControl
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   579
		TInt err = DoControl(id, m.Ptr0(), m.Ptr1());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   580
		m.Complete(err, ETrue);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   581
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   582
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   583
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   584
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   585
// DMetroTrkChannel::AddProcess
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   586
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   587
void DMetroTrkChannel::AddProcess(DProcess *aProcess, DThread *aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   588
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   589
	LOG_MSG("DMetroTrkChannel::AddProcess()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   590
	// check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   591
	if (!iDebugging) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   592
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   593
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   594
	if (aProcess)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   595
	{		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   596
		if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   597
			LOG_MSG("Creator thread not available");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   598
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   599
		// check to see if this process is being started by debug agent.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   600
		// If this is the case, we don't need to notify the agent since the debug agent already knows about it.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   601
		if (aThread && aThread->iOwningProcess->iId == iClientThread->iOwningProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   602
			return;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   603
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   604
		SEventInfo processEventInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   605
		processEventInfo.iEventType = processEventInfo.EProcessAdded; 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   606
		processEventInfo.iProcessId = aProcess->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   607
		processEventInfo.iFileName.Copy(*aProcess->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   608
		processEventInfo.iUid = aProcess->iUids.iUid[2].iUid; 		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   609
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   610
		// Kernel hasn't created teh code segment yet for this process,
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   611
		// so queue this event separately and wait for start thread event to notify.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   612
		iProcessNotifyList.Append(processEventInfo);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   613
	}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   614
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   615
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   616
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   617
// DMetroTrkChannel::StartThread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   618
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   619
void DMetroTrkChannel::StartThread(DThread *aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   620
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   621
	LOG_MSG("DMetroTrkChannel::StartThread()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   622
	// check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   623
	if (!iDebugging) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   624
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   625
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   626
	// Using the lib loaded event flag for notifying processes as well.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   627
	// Check if lib loaded event is disabled. Lib loaded event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   628
	// is disabled temporarily in some situations, when the engine
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   629
	// is performing some complex operations  like installing sis 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   630
	// files, in which case, suspending the thread for lib loaded 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   631
	// events would end up in a dead lock. This is due  to the fact 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   632
	// that the active object that handles the event notification 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   633
	// wouldn't get a chance to run since the code in TRK engine  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   634
	// which handles the commands from the host debugger is also 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   635
	// done in an active object which runs in the same thread. 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   636
	if (!iNotifyLibLoadedEvent)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   637
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   638
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   639
	if (aThread && aThread->iOwningProcess)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   640
	{				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   641
		DCodeSeg* codeSeg = aThread->iOwningProcess->iCodeSeg;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   642
		if (codeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   643
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   644
			TModuleMemoryInfo processMemoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   645
			TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, aThread->iOwningProcess);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   646
			if (err == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   647
			{						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   648
				for (TInt i = 0; i < iProcessNotifyList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   649
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   650
					if (iProcessNotifyList[i].iProcessId == aThread->iOwningProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   651
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   652
						// Suspend the thread so that the host debugger can set breakpoints.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   653
						Kern::ThreadSuspend(*aThread, 1); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   654
						iProcessNotifyList[i].iThreadId = aThread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   655
						iProcessNotifyList[i].iCodeAddress = processMemoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   656
						iProcessNotifyList[i].iDataAddress = processMemoryInfo.iInitialisedDataBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   657
						// Notify the process added event now that we have the code segment for the process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   658
						NotifyEvent(iProcessNotifyList[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   659
						// Now remove from the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   660
						iProcessNotifyList.Remove(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   661
						break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   662
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   663
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   664
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   665
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   666
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   667
				LOG_MSG2("Error in getting memory info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   668
			}			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   669
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   670
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   671
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   672
			LOG_MSG2("Invalid code segment found for the started thread: %d", aThread->iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   673
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   674
	}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   675
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   676
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   677
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   678
// DMetroTrkChannel::RemoveProcess
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   679
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   680
void DMetroTrkChannel::RemoveProcess(DProcess *aProcess)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   681
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   682
	LOG_MSG("DMetroTrkChannel::RemoveProcess()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   683
	// check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   684
	if (!iDebugging) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   685
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   686
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   687
	// this is called when a process dies.  we want to mark any breakpoints in this
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   688
	// process space as obsolete.  the main reason for this is so we don't return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   689
	// an error when the host debugger tries to clear breakpoints for the process
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   690
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   691
	TUint32 codeAddress = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   692
	TUint32 codeSize = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   693
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   694
	LOG_MSG2("Process being removed, Name %S", aProcess->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   695
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   696
	DCodeSeg* codeSeg = aProcess->iCodeSeg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   697
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   698
	if (codeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   699
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   700
		TModuleMemoryInfo processMemoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   701
		TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, aProcess);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   702
		if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   703
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   704
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   705
			codeAddress = processMemoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   706
			codeSize = processMemoryInfo.iCodeSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   707
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   708
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   709
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   710
			LOG_MSG2("Error in getting memory info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   711
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   712
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   713
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   714
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   715
	if (!codeAddress || !codeSize)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   716
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   717
		LOG_MSG2("Code segment not available for process %d", aProcess->iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   718
		// make sure there is not already a breakpoint at this address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   719
		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   720
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   721
			if (iDebugProcessList[i].iId == aProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   722
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   723
				codeAddress = iDebugProcessList[i].iCodeAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   724
				codeSize = iDebugProcessList[i].iCodeSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   725
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   726
				//now remove from the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   727
				iDebugProcessList.Remove(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   728
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   729
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   730
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   731
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   732
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   733
	if (!codeAddress || !codeSize)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   734
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   735
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   736
	// first invalidate all breakpoints that were set in the library code
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   737
	for (TInt i=0; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   738
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   739
		if ((iBreakPointList[i].iAddress >= codeAddress) && (iBreakPointList[i].iAddress < (codeAddress + codeSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   740
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   741
			LOG_MSG2("Disabling process breakpoint at address %x", iBreakPointList[i].iAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   742
			iBreakPointList[i].iObsoleteLibraryBreakpoint = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   743
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   744
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   745
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   746
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   747
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   748
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   749
// DMetroTrkChannel::AddLibrary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   750
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   751
void DMetroTrkChannel::AddLibrary(DLibrary *aLibrary, DThread *aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   752
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   753
	LOG_MSG("DMetroTrkChannel::AddLibrary()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   754
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   755
	LOG_MSG2(("Lib loaded: %S"), aLibrary->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   756
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   757
	// check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   758
	if (!iDebugging) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   759
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   760
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   761
	// Check if lib loaded event is disabled. Lib loaded event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   762
	// is disabled temporarily in some situations, when the engine
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   763
	// is performing some complex operations  like installing sis 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   764
	// files, in which case, suspending the thread for lib loaded 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   765
	// events would end up in a dead lock. This is due  to the fact 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   766
	// that the active object that handles the event notification 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   767
	// wouldn't get a chance to run since the code in TRK engine  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   768
	// which handles the commands from the host debugger is also 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   769
	// done in an active object which runs in the same thread. 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   770
	if (!iNotifyLibLoadedEvent)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   771
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   772
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   773
	TBool isDebugging = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   774
	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   775
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   776
		if (iDebugProcessList[i].iId == aThread->iOwningProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   777
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   778
			isDebugging = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   779
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   780
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   781
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   782
	if (isDebugging == EFalse)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   783
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   784
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   785
	if (aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   786
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   787
		// make sure this is not the debugger thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   788
		if ((aThread != iClientThread) && (aThread->iOwningProcess->iId != iClientThread->iOwningProcess->iId))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   789
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   790
			SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   791
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   792
			Kern::ThreadSuspend(*aThread, 1); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   793
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   794
			info.iEventType = SEventInfo::ELibraryLoaded;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   795
			info.iProcessId = aThread->iOwningProcess->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   796
			info.iThreadId = aThread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   797
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   798
			//get the code address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   799
			DCodeSeg* codeSeg = aLibrary->iCodeSeg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   800
			if (!codeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   801
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   802
				LOG_MSG2("Code segment not available for library %S", aLibrary->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   803
				return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   804
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   805
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   806
			TModuleMemoryInfo memoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   807
			TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL); //NULL for DProcess should be ok;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   808
			if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   809
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   810
				LOG_MSG2("Error in getting memory info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   811
				return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   812
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   813
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   814
			info.iCodeAddress = memoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   815
			info.iDataAddress = memoryInfo.iInitialisedDataBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   816
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   817
			info.iFileName.Copy(*(aLibrary->iName)); //just the name, without uid info.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   818
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   819
			// now remove this library if its in our notify list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   820
			for (TInt i =0; i<iLibraryNotifyList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   821
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   822
				if (!iLibraryNotifyList[i].iEmptySlot &&
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   823
				    !_strnicmp(iLibraryNotifyList[i].iName.Ptr(), info.iFileName.Ptr(), info.iFileName.Length()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   824
				{										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   825
					iLibraryNotifyList[i].iEmptySlot = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   826
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   827
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   828
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   829
			// now check to see if any libs are loaded because of this library load event.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   830
			CheckLibraryNotifyList(info.iProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   831
			//queue up or complete the event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   832
			NotifyEvent(info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   833
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   834
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   835
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   836
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   837
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   838
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   839
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   840
// DMetroTrkChannel::RemoveLibrary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   841
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   842
void DMetroTrkChannel::RemoveLibrary(DLibrary *aLibrary)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   843
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   844
	LOG_MSG("DMetroTrkChannel::RemoveLibrary()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   845
	LOG_MSG2(("Lib unloaded: %S"), aLibrary->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   846
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   847
	// check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   848
	if (!iDebugging) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   849
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   850
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   851
	// this is called when all handles to this library have been closed.  this can happen when a process dies, or when a dll is
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   852
	// unloaded while the process lives on.  in former case, we don't need to notify the host debugger because that process is
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   853
	// dying anyway.  for the latter case, we do need to notify the host so it can unload the symbolics, etc.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   854
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   855
	DThread* aThread = &Kern::CurrentThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   856
   
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   857
	if ((aThread) &&
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   858
       (aThread != iClientThread) && 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   859
       (aThread->iOwningProcess->iId != iClientThread->iOwningProcess->iId))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   860
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   861
		//the library gets unloaded only when the mapcount is 0.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   862
		if (aLibrary->iMapCount != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   863
			return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   864
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   865
		DCodeSeg* codeSeg = aLibrary->iCodeSeg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   866
		if (!codeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   867
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   868
			LOG_MSG2("Code segment not available for library %S", aLibrary->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   869
			return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   870
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   871
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   872
		TModuleMemoryInfo processMemoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   873
		TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, NULL); //passing NULL for the DProcess argument should be ok;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   874
		if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   875
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   876
			LOG_MSG2("Error in getting memory info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   877
			return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   878
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   879
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   880
		TUint32 codeAddress = processMemoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   881
		TUint32 codeSize = processMemoryInfo.iCodeSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   882
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   883
		// first invalidate all breakpoints that were set in the library code
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   884
		for (TInt i=0; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   885
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   886
			if ((iBreakPointList[i].iAddress >= codeAddress) && (iBreakPointList[i].iAddress < (codeAddress + codeSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   887
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   888
				LOG_MSG2("Disabling library breakpoint at address %x", iBreakPointList[i].iAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   889
				iBreakPointList[i].iObsoleteLibraryBreakpoint = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   890
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   891
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   892
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   893
	   	DProcess *process = &Kern::CurrentProcess();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   894
	   	if (process)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   895
	   	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   896
			RArray<SCodeSegEntry>* dynamicCode = &(process->iDynamicCode);			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   897
			if (dynamicCode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   898
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   899
				for (TInt j=0; j<dynamicCode->Count(); j++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   900
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   901
					if ((*dynamicCode)[j].iLib == aLibrary)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   902
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   903
						SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   904
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   905
						info.iEventType = SEventInfo::ELibraryUnloaded;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   906
						info.iFileName.Copy(*(aLibrary->iName)); //lib name without uid info
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   907
						//info.iFileName.ZeroTerminate();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   908
						info.iProcessId = process->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   909
						info.iThreadId = 0xFFFFFFFF; // don't care!
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   910
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   911
						//queue up or complete the event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   912
						NotifyEvent(info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   913
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   914
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   915
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   916
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   917
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   918
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   919
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   920
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   921
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   922
// DMetroTrkChannel::AddCodeSegment
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   923
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   924
void DMetroTrkChannel::AddCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   925
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   926
	LOG_MSG("DMetroTrkChannel::AddCodeSegment()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   927
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   928
	// Check if lib loaded event is disabled. Lib loaded event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   929
	// is disabled temporarily in some situations, when the engine
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   930
	// is performing some complex operations  like installing sis 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   931
	// files, in which case, suspending the thread for lib loaded 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   932
	// events would end up in a dead lock. This is due  to the fact 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   933
	// that the active object that handles the event notification 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   934
	// wouldn't get a chance to run since the code in TRK engine  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   935
	// which handles the commands from the host debugger is also 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   936
	// done in an active object which runs in the same thread. 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   937
	if (!iNotifyLibLoadedEvent)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   938
		return;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   939
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   940
	TBool isDebugging = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   941
	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   942
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   943
		if (iDebugProcessList[i].iId == aProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   944
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   945
			isDebugging = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   946
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   947
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   948
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   949
	if (isDebugging == EFalse)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   950
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   951
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   952
	if (aCodeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   953
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   954
		const TUint8* ptr = aCodeSeg->iFileName->Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   955
		if (aCodeSeg->IsDll())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   956
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   957
			LOG_MSG2("DLL code segment is loaded: %s", ptr);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   958
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   959
			DThread* mainThread = aProcess->FirstThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   960
			if (mainThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   961
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   962
				// make sure this is not the debugger thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   963
				if ((mainThread->iId != iClientThread->iId) && (aProcess->iId != iClientThread->iOwningProcess->iId))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   964
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   965
					SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   966
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   967
					//DoSuspendThread(mainThread); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   968
					Kern::ThreadSuspend(*mainThread, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   969
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   970
					info.iEventType = SEventInfo::ELibraryLoaded;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   971
					info.iProcessId = aProcess->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   972
					info.iThreadId = mainThread->iId;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   973
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   974
					TModuleMemoryInfo memoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   975
					TInt err = aCodeSeg->GetMemoryInfo(memoryInfo, NULL); //NULL for DProcess should be ok;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   976
					if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   977
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   978
						LOG_MSG2("Error in getting memory info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   979
						return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   980
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   981
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   982
					info.iCodeAddress = memoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   983
					info.iDataAddress = memoryInfo.iInitialisedDataBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   984
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   985
					info.iFileName.Copy(aCodeSeg->iRootName); //just the name, without uid info.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   986
								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   987
					//queue up or complete the event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   988
					NotifyEvent(info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   989
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   990
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   991
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   992
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   993
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   994
				LOG_MSG2("Invalid main thread for this process: %d", aProcess->iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   995
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   996
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   997
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   998
		else 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   999
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1000
			if (aCodeSeg->IsExe())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1001
				LOG_MSG2("EXE code segment is loaded: %s", ptr);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1002
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1003
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1004
	}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1005
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1006
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1007
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1008
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1009
// DMetroTrkChannel::RemoveCodeSegment
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1010
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1011
void DMetroTrkChannel::RemoveCodeSegment(DCodeSeg *aCodeSeg, DProcess *aProcess)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1012
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1013
	LOG_MSG("DMetroTrkChannel::RemoveCodeSegment()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1014
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1015
	// We don't do anything right now as we are not using the code segment events.		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1016
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1017
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1018
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1019
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1020
// DMetroTrkChannel::HandleEventKillThread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1021
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1022
TBool DMetroTrkChannel::HandleEventKillThread(DThread* aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1023
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1024
	LOG_MSG("DMetroTrkChannel::HandleEventKillThread");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1025
	// check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1026
	if (!iDebugging) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1027
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1028
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1029
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1030
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1031
		LOG_MSG("Invalid thread handle");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1032
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1033
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1034
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1035
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1036
	DThread* currentThread = &Kern::CurrentThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1037
	if (!currentThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1038
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1039
		LOG_MSG("Error getting current thread");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1040
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1041
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1042
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1043
	//Kern::ThreadSuspend(*currentThread, 1); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1044
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1045
	if (aThread->iExitType != EExitPanic)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1046
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1047
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1048
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1049
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1050
	SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1051
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1052
	info.iProcessId = aThread->iOwningProcess->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1053
	info.iThreadId = aThread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1054
	info.iCurrentPC = ReadRegister(aThread, 14);//PC_REGISTER); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1055
	info.iPanicCategory.Copy(aThread->iExitCategory);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1056
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1057
	info.iExceptionNumber = 100;//aThread->iExitReason;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1058
	info.iPanicReason = aThread->iExitReason;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1059
	info.iEventType = SEventInfo::EThreadPanic;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1060
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1061
	// if its not an invalide opcode exception, check to see if we are debugging 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1062
	// the process.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1063
	TBool isDebugging = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1064
	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1065
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1066
		if (iDebugProcessList[i].iId == info.iProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1067
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1068
			isDebugging = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1069
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1070
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1071
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1072
	if (!isDebugging)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1073
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1074
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1075
#define DOFREEZE 1
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1076
	// PANIC_BACKPORT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1077
#if DOFREEZE
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1078
	NKern::ThreadEnterCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1079
	NFastSemaphore* sem = new NFastSemaphore();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1080
	NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1081
//	sem->iOwningThread = &(Kern::CurrentThread().iNThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1082
	sem->iOwningThread = &aThread->iNThread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1083
	iFrozenThreadSemaphores.Append(sem);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1084
	// First do the notify, then FSWait
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1085
	NotifyEvent(info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1086
	NKern::FSWait(sem);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1087
	return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1088
#else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1089
	NotifyEvent(info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1090
	LOG_MSG("DMetroTrkChannel::HandleEventKillThread - Panic Do Nothing");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1091
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1092
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1093
	// END PANIC_BACKPORT	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1094
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1095
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1096
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1097
// DMetroTrkChannel::HandleSwException
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1098
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1099
TBool DMetroTrkChannel::HandleSwException(TExcType aExcType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1100
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1101
	LOG_MSG("DMetroTrkChannel::HandleSwException");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1102
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1103
	SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1104
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1105
	DThread* currentThread = &Kern::CurrentThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1106
	if (!currentThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1107
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1108
		LOG_MSG("Error getting current thread");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1109
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1110
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1111
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1112
	info.iProcessId = currentThread->iOwningProcess->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1113
	info.iThreadId = currentThread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1114
	info.iCurrentPC = ReadRegister(currentThread, PC_REGISTER);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1115
	info.iExceptionNumber = aExcType;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1116
	info.iEventType = SEventInfo::EThreadException;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1117
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1118
	if (info.iExceptionNumber != EExcInvalidOpCode) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1119
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1120
		// if its not an invalide opcode exception, check to see if we are debugging 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1121
		// the process.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1122
		TBool isDebugging = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1123
		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1124
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1125
			if (iDebugProcessList[i].iId == info.iProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1126
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1127
				isDebugging = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1128
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1129
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1130
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1131
		if (!isDebugging)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1132
			return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1133
	}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1134
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1135
	NThread nThread = currentThread->iNThread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1136
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1137
	if (nThread.iSuspendCount == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1138
		Kern::ThreadSuspend(*currentThread, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1139
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1140
	HandleException(info, currentThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1141
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1142
	return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1143
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1144
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1145
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1146
// DMetroTrkChannel::HandleHwException
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1147
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1148
TBool DMetroTrkChannel::HandleHwException(TArmExcInfo* aExcInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1149
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1150
	LOG_MSG("DMetroTrkChannel::HandleHwException()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1151
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1152
	SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1153
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1154
	DThread* currentThread = &Kern::CurrentThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1155
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1156
	if (!currentThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1157
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1158
		LOG_MSG("Error getting current thread");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1159
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1160
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1161
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1162
	//store the exception info as its needed to read the context for system threads
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1163
	iExcInfoValid = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1164
	iCurrentExcInfo = *aExcInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1165
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1166
	info.iProcessId = currentThread->iOwningProcess->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1167
	info.iThreadId = currentThread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1168
	info.iCurrentPC = aExcInfo->iR15;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1169
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1170
	switch (aExcInfo->iExcCode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1171
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1172
		case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1173
			info.iExceptionNumber = EExcCodeAbort;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1174
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1175
		case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1176
			info.iExceptionNumber = EExcDataAbort;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1177
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1178
		case 2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1179
			info.iExceptionNumber = EExcInvalidOpCode;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1180
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1181
		default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1182
			return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1183
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1184
	}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1185
	info.iEventType = SEventInfo::EThreadException;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1186
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1187
	if (info.iExceptionNumber != EExcInvalidOpCode) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1188
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1189
		// if its not an invalide opcode exception, check to see if we are debugging 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1190
		// the process.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1191
		TBool isDebugging = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1192
		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1193
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1194
			if (iDebugProcessList[i].iId == info.iProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1195
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1196
				isDebugging = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1197
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1198
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1199
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1200
		if (!isDebugging)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1201
			return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1202
	}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1203
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1204
	NThread nThread = currentThread->iNThread;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1205
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1206
	if (nThread.iSuspendCount == 0) //don't suspend the thread if its already suspended.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1207
		Kern::ThreadSuspend(*currentThread, 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1208
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1209
	HandleException(info, currentThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1210
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1211
	return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1212
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1213
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1214
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1215
// DMetroTrkChannel::HandleException
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1216
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1217
void DMetroTrkChannel::HandleException(SEventInfo& aEventInfo, DThread* aCurrentThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1218
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1219
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1220
	// see if it was a breakpoint that stopped the thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1221
	if (((TInt)2 == aEventInfo.iExceptionNumber) || ((TInt)EExcInvalidOpCode == aEventInfo.iExceptionNumber))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1222
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1223
		TUint32 inst = KArmBreakPoint;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1224
		TInt instSize = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1225
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1226
		// change these for thumb mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1227
		if (ReadRegister(aCurrentThread, STATUS_REGISTER) & ECpuThumb)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1228
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1229
			inst = KThumbBreakPoint;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1230
			instSize = 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1231
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1232
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1233
		TUint32 instruction = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1234
		err = Kern::ThreadRawRead(aCurrentThread, (TUint32 *)aEventInfo.iCurrentPC, (TUint8 *)&instruction, instSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1235
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1236
		if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1237
			LOG_MSG2("Error reading instruction at currentpc: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1238
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1239
		if (!memcompare((TUint8 *)&inst, instSize, (TUint8 *)&instruction, instSize))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1240
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1241
			// the exception was a breakpoint instruction.  see if we have a breakpoint at that address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1242
			for (TInt i=0; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1243
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1244
				TBreakEntry breakEntry = iBreakPointList[i];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1245
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1246
				if (breakEntry.iAddress == aEventInfo.iCurrentPC)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1247
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1248
					LOG_MSG2("Breakpoint with Id %d has been hit", breakEntry.iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1249
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1250
					//change the event type to breakpoint type
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1251
					aEventInfo.iEventType = SEventInfo::EThreadBreakPoint;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1252
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1253
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1254
					// enable any breakpoints we had to disable for this thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1255
					err = DoEnableDisabledBreak(aEventInfo.iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1256
					if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1257
						LOG_MSG2("Error %d enabling disabled breakpoints", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1258
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1259
					// see if this is a temp breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1260
					if (i < NUMBER_OF_TEMP_BREAKPOINTS)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1261
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1262
						// this was a temp breakpoint, so we need to clear it now
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1263
						err = DoClearBreak(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1264
						if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1265
							LOG_MSG2("Error %d clearing temp breakpoint", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1266
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1267
						// if we're not out of range yet, go ahead and single step again
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1268
						// if we are out of range, either continue or report the event depending
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1269
						// on the iResumeOnceOutOfRange flag
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1270
						if ((aEventInfo.iCurrentPC > breakEntry.iRangeStart) && (aEventInfo.iCurrentPC < breakEntry.iRangeEnd))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1271
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1272
							LOG_MSG("PC is still in range, stepping will continue");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1273
							err = DoStepRange(aCurrentThread, breakEntry.iRangeStart, breakEntry.iRangeEnd, breakEntry.iSteppingInto, breakEntry.iResumeOnceOutOfRange, breakEntry.iSteppingInto);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1274
							if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1275
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1276
								LOG_MSG2("Error in DoStepRange: %d.  Resuming thread.", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1277
								err = DoResumeThread(aCurrentThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1278
								if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1279
									LOG_MSG2("Error in DoResumeThread: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1280
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1281
							return;												
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1282
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1283
						else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1284
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1285
							if (breakEntry.iResumeOnceOutOfRange)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1286
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1287
								LOG_MSG("PC is out of range, continuing thread");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1288
								DoResumeThread(aCurrentThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1289
								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1290
								return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1291
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1292
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1293
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1294
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1295
					// if the breakpoint is thread specific, make sure it's the right thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1296
					// if not, just continue the thread.  take special care if it's the debugger
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1297
					// thread.  if it hits a regular breakpoint, we NEVER want to stop at it.  if
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1298
					// it hits a temp breakpoint, we're probably just stepping past a real breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1299
					// and we do need to handle it.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1300
					if (((breakEntry.iThreadId != aEventInfo.iThreadId) && breakEntry.iThreadSpecific)/*(breakEntry.iThreadId != 0xFFFFFFFF))*/ ||
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1301
						((aEventInfo.iProcessId == iClientThread->iOwningProcess->iId) && (breakEntry.iThreadId != aEventInfo.iThreadId)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1302
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1303
						LOG_MSG("breakpoint does not match threadId, calling DoResumeThread");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1304
						err = DoResumeThread(aCurrentThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1305
						if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1306
							LOG_MSG2("Error in DoResumeThread: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1307
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1308
						return;					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1309
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1310
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1311
					//normal user break point, just notify the event
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1312
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1313
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1314
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1315
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1316
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1317
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1318
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1319
	NotifyEvent(aEventInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1320
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1321
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1322
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1323
// DMetroTrkChannel::HandleUserTrace
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1324
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1325
TBool DMetroTrkChannel::HandleUserTrace(TText* aStr, TInt aLen)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1326
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1327
	LOG_MSG("DMetroTrkChannel::HandleUserTrace()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1328
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1329
// handle user trace events only for app trk.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1330
#ifndef __OEM_TRK__ 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1331
	// check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1332
	if (!iDebugging) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1333
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1334
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1335
	DThread* currentThread = &Kern::CurrentThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1336
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1337
	if (!currentThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1338
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1339
		LOG_MSG("Error getting current thread");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1340
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1341
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1342
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1343
	if (currentThread->iOwningProcess->iId == iClientThread->iOwningProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1344
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1345
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1346
	// only send traces for processes you are debugging	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1347
	TBool isDebugging = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1348
	for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1349
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1350
		if (iDebugProcessList[i].iId == currentThread->iOwningProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1351
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1352
			isDebugging = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1353
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1354
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1355
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1356
	if (!isDebugging)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1357
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1358
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1359
	if (aLen > 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1360
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1361
		SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1362
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1363
		// This is a temporary solution for grabbing the rdebug printfs.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1364
		// With the current TRK implementation, we don't have a mechanism for 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1365
		// using dynamically allocated buffers between the engine and the driver. 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1366
		// So for now we are limiting the printf strings to 256 bytes.		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1367
		TUint8 traceStr[260];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1368
		info.iTraceDataLen = aLen;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1369
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1370
		if (info.iTraceDataLen > 256)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1371
			info.iTraceDataLen  = 256;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1372
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1373
		XTRAPD(r, XT_DEFAULT, kumemget(traceStr, aStr, info.iTraceDataLen));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1374
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1375
		if (r == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1376
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1377
			info.iEventType = SEventInfo::EUserTrace;			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1378
			traceStr[info.iTraceDataLen] = '\r';
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1379
			traceStr[info.iTraceDataLen+1] = '\n';
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1380
			info.iTraceDataLen += 2; // account for \r and \n.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1381
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1382
			info.iTraceData.Copy((TUint8*)traceStr, info.iTraceDataLen);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1383
			NotifyEvent(info, ETrue);										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1384
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1385
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1386
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1387
			return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1388
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1389
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1390
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1391
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1392
	return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1393
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1394
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1395
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1396
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1397
// DMetroTrkChannel::SetBreak
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1398
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1399
TInt DMetroTrkChannel::SetBreak(TUint32 aThreadId, TMetroTrkBreakInfo* aBreakInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1400
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1401
	LOG_MSG("DMetroTrkChannel::SetBreak()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1402
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1403
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1404
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1405
	if (!aBreakInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1406
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1407
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1408
	//User side memory is not accessible directly
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1409
	TMetroTrkBreakInfo info(0, 0, 0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1410
	err = Kern::ThreadRawRead(iClientThread, aBreakInfo, (TUint8*)&info, sizeof(TMetroTrkBreakInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1411
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1412
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1413
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1414
	if (!info.iId) //first check if the iId address is valid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1415
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1416
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1417
	if (err == KErrNone) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1418
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1419
		TInt32 iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1420
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1421
		err = DoSetBreak(info.iProcessId, aThreadId, info.iAddress, info.iThumbMode, iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1422
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1423
		if (err == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1424
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1425
			err = Kern::ThreadRawWrite(iClientThread, (TUint8 *)info.iId, &iId, sizeof(TInt32), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1426
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1427
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1428
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1429
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1430
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1431
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1432
// DMetroTrkChannel::StepRange
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1433
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1434
TInt DMetroTrkChannel::StepRange(DThread* aThread, TMetroTrkStepInfo* aStepInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1435
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1436
	LOG_MSG("DMetroTrkChannel::StepRange()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1437
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1438
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1439
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1440
	if (!aStepInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1441
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1442
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1443
	TMetroTrkStepInfo info(0, 0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1444
	err = Kern::ThreadRawRead(iClientThread, aStepInfo, (TUint8*)&info, sizeof(TMetroTrkStepInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1445
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1446
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1447
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1448
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1449
	err = DoStepRange(aThread, info.iStartAddress, info.iStopAddress, info.iStepInto, EFalse, ETrue);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1450
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1451
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1452
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1453
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1454
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1455
// DMetroTrkChannel::ReadMemory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1456
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1457
TInt DMetroTrkChannel::ReadMemory(DThread* aThread, TMetroTrkMemoryInfo* aMemoryInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1458
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1459
	LOG_MSG("DMetroTrkChannel::ReadMemory()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1460
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1461
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1462
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1463
	if (!aMemoryInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1464
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1465
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1466
#ifndef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1467
	if (!IsBeingDebugged(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1468
		return KErrPermissionDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1469
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1470
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1471
	TMetroTrkMemoryInfo info(0, 0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1472
	err = Kern::ThreadRawRead(iClientThread, aMemoryInfo, (TUint8*)&info, sizeof(TMetroTrkMemoryInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1473
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1474
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1475
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1476
	if (!info.iData)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1477
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1478
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1479
	TUint8 *data = (TUint8*)Kern::Alloc(info.iLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1480
	if (!data)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1481
		return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1482
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1483
	TPtr8 dataDes(data, info.iLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1484
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1485
	err = DoReadMemory(aThread, info.iAddress, info.iLength, dataDes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1486
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1487
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1488
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1489
	err = Kern::ThreadDesWrite(iClientThread, info.iData, dataDes, 0, KChunkShiftBy0, iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1490
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1491
	Kern::Free(data);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1492
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1493
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1494
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1495
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1496
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1497
// DMetroTrkChannel::WriteMemory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1498
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1499
TInt DMetroTrkChannel::WriteMemory(DThread* aThread, TMetroTrkMemoryInfo* aMemoryInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1500
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1501
	LOG_MSG("DMetroTrkChannel::WriteMemory()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1502
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1503
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1504
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1505
	if (!aMemoryInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1506
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1507
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1508
#ifndef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1509
	if (!IsBeingDebugged(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1510
		return KErrPermissionDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1511
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1512
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1513
	TMetroTrkMemoryInfo info(0, 0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1514
	err = Kern::ThreadRawRead(iClientThread, aMemoryInfo, (TUint8*)&info, sizeof(TMetroTrkMemoryInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1515
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1516
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1517
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1518
	if (!info.iData)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1519
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1520
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1521
	TUint8 *data = (TUint8*)Kern::Alloc(info.iLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1522
	if (!data)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1523
		return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1524
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1525
	TPtr8 dataDes(data, info.iLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1526
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1527
	err = Kern::ThreadDesRead(iClientThread, info.iData, dataDes, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1528
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1529
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1530
							
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1531
	err = DoWriteMemory(aThread, info.iAddress, info.iLength, dataDes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1532
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1533
	Kern::Free(data);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1534
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1535
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1536
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1537
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1538
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1539
// DMetroTrkChannel::ReadRegisters
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1540
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1541
TInt DMetroTrkChannel::ReadRegisters(DThread* aThread, TMetroTrkRegisterInfo* aRegisterInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1542
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1543
	LOG_MSG("DMetroTrkChannel::ReadRegisters()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1544
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1545
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1546
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1547
	if (!aRegisterInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1548
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1549
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1550
#ifndef __OEM_TRK__	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1551
	if (!IsBeingDebugged(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1552
		return KErrPermissionDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1553
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1554
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1555
	TMetroTrkRegisterInfo info(0, 0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1556
	err = Kern::ThreadRawRead(iClientThread, aRegisterInfo, (TUint8*)&info, sizeof(TMetroTrkRegisterInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1557
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1558
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1559
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1560
	if (!info.iValues)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1561
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1562
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1563
	TUint length = (info.iLastRegister - info.iFirstRegister + 1) * 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1564
	TUint8 *values = (TUint8*)Kern::Alloc(length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1565
	if (!values)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1566
		return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1567
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1568
	TPtr8 valuesDes(values, length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1569
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1570
	err = DoReadRegisters(aThread, info.iFirstRegister, info.iLastRegister, valuesDes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1571
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1572
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1573
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1574
	err = Kern::ThreadDesWrite(iClientThread, info.iValues, valuesDes, 0, KChunkShiftBy0, iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1575
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1576
	Kern::Free(values);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1577
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1578
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1579
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1580
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1581
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1582
// DMetroTrkChannel::WriteRegisters
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1583
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1584
TInt DMetroTrkChannel::WriteRegisters(DThread* aThread, TMetroTrkRegisterInfo* aRegisterInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1585
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1586
	LOG_MSG("DMetroTrkChannel::WriteRegisters()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1587
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1588
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1589
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1590
	if (!aRegisterInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1591
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1592
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1593
#ifndef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1594
	if (!IsBeingDebugged(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1595
		return KErrPermissionDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1596
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1597
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1598
	TMetroTrkRegisterInfo info(0, 0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1599
	err = Kern::ThreadRawRead(iClientThread, aRegisterInfo, (TUint8*)&info, sizeof(TMetroTrkRegisterInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1600
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1601
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1602
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1603
	if (!info.iValues)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1604
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1605
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1606
	TUint length = (info.iLastRegister - info.iFirstRegister + 1) * 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1607
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1608
	TUint8 *values = (TUint8*)Kern::Alloc(length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1609
	if (!values)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1610
		return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1611
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1612
	TPtr8 valuesDes(values, length);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1613
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1614
	err = Kern::ThreadDesRead(iClientThread, info.iValues, valuesDes, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1615
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1616
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1617
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1618
	err = DoWriteRegisters(aThread, info.iFirstRegister, info.iLastRegister, valuesDes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1619
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1620
	Kern::Free(values);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1621
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1622
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1623
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1624
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1625
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1626
// DMetroTrkChannel::GetProcessInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1627
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1628
TInt DMetroTrkChannel::GetProcessInfo(TInt aIndex, TMetroTrkTaskInfo* aTaskInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1629
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1630
	LOG_MSG("DMetroTrkChannel::GetProcessInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1631
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1632
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1633
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1634
	if (!aTaskInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1635
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1636
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1637
	TMetroTrkTaskInfo info(0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1638
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1639
	err = DoGetProcessInfo(aIndex, &info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1640
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1641
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1642
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1643
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1644
	err = Kern::ThreadRawWrite(iClientThread, aTaskInfo, &info, sizeof(TMetroTrkTaskInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1645
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1646
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1647
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1648
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1649
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1650
// DMetroTrkChannel::GetThreadInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1651
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1652
TInt DMetroTrkChannel::GetThreadInfo(TInt aIndex, TMetroTrkTaskInfo* aTaskInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1653
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1654
	LOG_MSG("DMetroTrkChannel::GetThreadInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1655
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1656
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1657
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1658
	if (!aTaskInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1659
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1660
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1661
	TMetroTrkTaskInfo info(0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1662
	err = Kern::ThreadRawRead(iClientThread, aTaskInfo, (TUint8*)&info, sizeof(TMetroTrkTaskInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1663
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1664
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1665
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1666
	err = DoGetThreadInfo(aIndex, &info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1667
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1668
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1669
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1670
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1671
	err = Kern::ThreadRawWrite(iClientThread, aTaskInfo, &info, sizeof(TMetroTrkTaskInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1672
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1673
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1674
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1675
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1676
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1677
// DMetroTrkChannel::GetProcessAddresses
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1678
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1679
TInt DMetroTrkChannel::GetProcessAddresses(DThread* aThread, TMetroTrkProcessInfo* aProcessInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1680
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1681
	LOG_MSG("DMetroTrkChannel::GetProcessAddresses()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1682
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1683
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1684
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1685
	if  (!aProcessInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1686
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1687
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1688
	TMetroTrkProcessInfo info(0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1689
	err = Kern::ThreadRawRead(iClientThread, aProcessInfo, (TUint8*)&info, sizeof(TMetroTrkProcessInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1690
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1691
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1692
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1693
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1694
	if (!info.iCodeAddress || !info.iDataAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1695
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1696
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1697
	TUint32 codeAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1698
	TUint32 dataAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1699
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1700
	err = DoGetProcessAddresses(aThread, codeAddress, dataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1701
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1702
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1703
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1704
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1705
	err = Kern::ThreadRawWrite(iClientThread, info.iCodeAddress, (TUint8*)&codeAddress, sizeof(TUint32), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1706
	err = Kern::ThreadRawWrite(iClientThread, info.iDataAddress, (TUint8*)&dataAddress, sizeof(TUint32), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1707
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1708
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1709
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1710
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1711
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1712
// DMetroTrkChannel::GetStaticLibraryInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1713
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1714
TInt DMetroTrkChannel::GetStaticLibraryInfo(TInt aIndex, SEventInfo* aEventInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1715
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1716
	LOG_MSG("DMetroTrkChannel::GetStaticLibraryInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1717
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1718
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1719
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1720
	if (!aEventInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1721
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1722
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1723
	SEventInfo info;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1724
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1725
	err = Kern::ThreadRawRead(iClientThread, aEventInfo, (TUint8*)&info, sizeof(SEventInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1726
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1727
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1728
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1729
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1730
	err = DoGetStaticLibraryInfo(aIndex, &info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1731
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1732
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1733
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1734
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1735
	err = Kern::ThreadRawWrite(iClientThread, aEventInfo, &info, sizeof(SEventInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1736
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1737
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1738
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1739
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1740
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1741
// DMetroTrkChannel::GetLibInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1742
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1743
TInt DMetroTrkChannel::GetLibraryInfo(TMetroTrkLibInfo* aLibInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1744
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1745
	LOG_MSG("DMetroTrkChannel::GetLibraryInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1746
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1747
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1748
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1749
	if (!aLibInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1750
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1751
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1752
	TMetroTrkLibInfo info(0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1753
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1754
	err = Kern::ThreadRawRead(iClientThread, aLibInfo, (TUint8*)&info, sizeof(TMetroTrkLibInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1755
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1756
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1757
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1758
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1759
	if (!info.iFileName)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1760
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1761
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1762
	TUint8 *dllName = (TUint8*)Kern::Alloc(info.iFileNameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1763
	if (!dllName)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1764
		return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1765
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1766
	TPtr8 dllNameDes(dllName, info.iFileNameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1767
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1768
	err = Kern::ThreadDesRead(iClientThread, info.iFileName, dllNameDes, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1769
	if (!err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1770
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1771
		err = DoGetLibraryInfo(dllNameDes, &info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1772
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1773
		if (!err)		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1774
			err = Kern::ThreadRawWrite(iClientThread, aLibInfo, &info, sizeof(TMetroTrkLibInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1775
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1776
		// we couldn't find the library info, so add to our list to look for 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1777
		// when a library is loaded or a process is loaded.	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1778
		if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1779
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1780
            for (TInt i=0; i<NUMBER_OF_LIBS_TO_REGISTER; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1781
            {                
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1782
                if (!iLibraryNotifyList[i].iName.Length() && iLibraryNotifyList[i].iEmptySlot)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1783
		        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1784
                    iLibraryNotifyList[i].iName.Copy(dllNameDes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1785
                    iLibraryNotifyList[i].iEmptySlot = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1786
                    break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1787
		        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1788
		        else if (!iLibraryNotifyList[i].iEmptySlot && !_strnicmp(iLibraryNotifyList[i].iName.Ptr(), dllNameDes.Ptr(), dllNameDes.Length()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1789
		        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1790
		        	break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1791
		        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1792
            }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1793
		}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1794
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1795
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1796
	// now free the allocated memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1797
	Kern::Free(dllName);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1798
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1799
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1800
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1801
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1802
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1803
// DMetroTrkChannel::GetExeInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1804
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1805
TInt DMetroTrkChannel::GetExeInfo(TMetroTrkExeInfo* aExeInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1806
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1807
	LOG_MSG("DMetroTrkChannel::GetExeInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1808
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1809
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1810
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1811
	if (!aExeInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1812
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1813
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1814
	TMetroTrkExeInfo info(0, 0, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1815
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1816
	err = Kern::ThreadRawRead(iClientThread, aExeInfo, (TUint8*)&info, sizeof(TMetroTrkExeInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1817
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1818
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1819
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1820
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1821
	if (!info.iFileName)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1822
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1823
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1824
	TUint8 *exeName = (TUint8*)Kern::Alloc(info.iFileNameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1825
	if (!exeName)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1826
		return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1827
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1828
	TPtr8 exeNameDes(exeName, info.iFileNameLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1829
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1830
	err = Kern::ThreadDesRead(iClientThread, info.iFileName, exeNameDes, 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1831
	if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1832
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1833
			err = DoGetExeInfo(exeNameDes, &info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1834
		if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1835
		{		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1836
			err = Kern::ThreadRawWrite(iClientThread, aExeInfo, &info, sizeof(TMetroTrkExeInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1837
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1838
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1839
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1840
	Kern::Free(exeName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1841
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1842
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1843
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1844
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1845
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1846
// DMetroTrkChannel::GetProcUidInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1847
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1848
TInt DMetroTrkChannel::GetProcUidInfo(TMetroTrkProcUidInfo* aProcUidInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1849
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1850
	LOG_MSG("DMetroTrkChannel::GetProcUidInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1851
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1852
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1853
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1854
	if (!aProcUidInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1855
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1856
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1857
	TMetroTrkProcUidInfo info(0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1858
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1859
	err = Kern::ThreadRawRead(iClientThread, aProcUidInfo, (TUint8*)&info, sizeof(TMetroTrkProcUidInfo));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1860
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1861
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1862
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1863
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1864
	err = DoGetProcUidInfo(&info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1865
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1866
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1867
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1868
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1869
	err = Kern::ThreadRawWrite(iClientThread, aProcUidInfo, &info, sizeof(TMetroTrkProcUidInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1870
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1871
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1872
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1873
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1874
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1875
//DMetroTrkChannel::DetachProcess
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1876
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1877
TInt DMetroTrkChannel::DetachProcess(DProcess *aProcess)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1878
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1879
    LOG_MSG("DMetroTrkChannel::DetachProcess()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1880
    // check to see if we are still debugging, otherwise just return
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1881
    if (!iDebugging || !aProcess) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1882
        return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1883
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1884
    // This is called when a process has been detached.  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1885
    // We want to mark any breakpoints in this process space as clear.      
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1886
    TUint32 codeAddress = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1887
    TUint32 codeSize = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1888
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1889
    LOG_MSG2("Process being Detached, Name %S", aProcess->iName);    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1890
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1891
    // make sure there is not already a breakpoint at this address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1892
    for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1893
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1894
        if (iDebugProcessList[i].iId == aProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1895
        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1896
            codeAddress = iDebugProcessList[i].iCodeAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1897
            codeSize = iDebugProcessList[i].iCodeSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1898
            //now remove from the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1899
            iDebugProcessList.Remove(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1900
            break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1901
        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1902
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1903
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1904
    if (!codeAddress || !codeSize)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1905
        return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1906
        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1907
    // first invalidate all breakpoints that were set in the library code
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1908
    for (TInt i=0; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1909
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1910
        if ((iBreakPointList[i].iAddress >= codeAddress) && (iBreakPointList[i].iAddress < (codeAddress + codeSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1911
        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1912
            LOG_MSG2("Clearing process breakpoint at address %x", iBreakPointList[i].iAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1913
            // clear the break here
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1914
            TInt32 err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1915
            err = DoClearBreak(iBreakPointList[i].iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1916
            
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1917
            //If not able to clear the break point host debugger  make obselete.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1918
            if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1919
            {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1920
                LOG_MSG2("Clearing process breakpoint at address %x failed", iBreakPointList[i].iAddress);                
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1921
            }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1922
        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1923
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1924
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1925
    return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1926
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1927
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1928
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1929
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1930
// DMetroTrkChannel::DoSetBreak
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1931
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1932
TInt DMetroTrkChannel::DoSetBreak(const TUint32 aProcessId, const TUint32 aThreadId, const TUint32 aAddress, const TBool aThumbMode, TInt32 &aId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1933
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1934
	LOG_MSG("DMetroTrkChannel::DoSetBreak()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1935
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1936
	// do not allow breakpoints in the excluded ROM region
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1937
	//if ((aAddress >= iExcludedROMAddressStart) && (aAddress < iExcludedROMAddressEnd))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1938
	//{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1939
	//	return KErrNotSupported;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1940
	//}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1941
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1942
	// make sure there is not already a breakpoint at this address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1943
	for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1944
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1945
		if (iBreakPointList[i].iAddress == aAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1946
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1947
			return KErrAlreadyExists;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1948
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1949
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1950
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1951
	// increment the break id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1952
	aId = iNextBreakId++;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1953
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1954
	// create the new breakpoint entry
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1955
	TBreakEntry breakEntry(aId, aThreadId, aAddress, aThumbMode);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1956
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1957
	// IDE currently sends non-thread specific breakpoints (threadId == 0xffffffff)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1958
	// if this changes, we will get a real thread ID
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1959
	// This check must be done before calling DoEnableBreak as it will replace the 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1960
	// the breakentry threadId with a real one
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1961
	if (aThreadId == 0xFFFFFFFF)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1962
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1963
	    breakEntry.iThreadSpecific = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1964
	    breakEntry.iThreadId = aProcessId+1; //process wide break, just use the main thread id for this process		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1965
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1966
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1967
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1968
		breakEntry.iThreadSpecific = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1969
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1970
        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1971
	TInt err = DoEnableBreak(breakEntry, ETrue);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1972
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1973
	if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1974
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1975
		ReturnIfError(iBreakPointList.Append(breakEntry));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1976
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1977
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1978
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1979
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1980
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1981
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1982
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1983
// DMetroTrkChannel::DoEnableBreak
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1984
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1985
TInt DMetroTrkChannel::DoEnableBreak(TBreakEntry &aEntry, TBool aSaveOldInstruction)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1986
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1987
	LOG_MSG("DMetroTrkChannel::DoEnableBreak()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1988
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1989
	// default to arm mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1990
	TUint32 inst = KArmBreakPoint;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1991
	TInt instSize = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1992
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1993
	if (aEntry.iThumbMode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1994
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1995
		LOG_MSG("Thumb Breakpoint");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1996
		inst = KThumbBreakPoint;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1997
		instSize = 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1998
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1999
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2000
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2001
  			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2002
	// Get thread id from the process that we are debugging
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2003
	TProcessInfo * proc = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2004
	TUint32 threadId = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2005
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2006
	threadId = aEntry.iThreadId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2007
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2008
	if (!threadId || threadId==0xFFFFFFFF) //threadId=0xFFFFFFFF is special case with CW debugger.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2009
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2010
		for (TInt i=0; i<iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2011
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2012
			proc = &iDebugProcessList[i];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2013
			if ( proc && (proc->iCodeAddress <= aEntry.iAddress) && (aEntry.iAddress <= (proc->iCodeAddress + proc->iCodeSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2014
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2015
				threadId = proc->iId+1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2016
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2017
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2018
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2019
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2020
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2021
	DThread* threadObj = ThreadFromId(threadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2022
	//if we don't have the right thread id for the address, 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2023
	//then try with the thread id of the process that we are debugging 	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2024
	if (!threadObj && iDebugProcessList.Count())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2025
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2026
		proc = &iDebugProcessList[0];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2027
		if (proc)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2028
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2029
			threadId = proc->iId+1;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2030
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2031
		threadObj = ThreadFromId(threadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2032
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2033
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2034
	if (threadObj)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2035
	{		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2036
		if (aSaveOldInstruction)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2037
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2038
			TUint32 instruction;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2039
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2040
			// read the instruction at the address so we can store it in the break entry for when we clear this breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2041
			// trap exceptions in case the address is invalid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2042
			XTRAPD(r, XT_DEFAULT, err = TryToReadMemory(threadObj, (TAny *)aEntry.iAddress, (TAny *)&instruction, instSize));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2043
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2044
			ReturnIfError((KErrNone == r) ? err : r);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2045
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2046
			aEntry.iInstruction.Copy((TUint8 *)&instruction, instSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2047
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2048
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2049
		aEntry.iThreadId = threadId; //set the thread ID here 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2050
		XTRAPD(r, XT_DEFAULT, err = DebugSupport::ModifyCode(threadObj, aEntry.iAddress, instSize, inst, DebugSupport::EBreakpointGlobal));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2051
		err = (DebugSupport::EBreakpointGlobal == r) ? KErrNone : r;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2052
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2053
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2054
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2055
		err = KErrBadHandle;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2056
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2057
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2058
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2059
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2060
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2061
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2062
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2063
// DMetroTrkChannel::DoClearBreak
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2064
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2065
TInt DMetroTrkChannel::DoClearBreak(const TInt32 aId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2066
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2067
	LOG_MSG("DMetroTrkChannel::DoClearBreak()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2068
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2069
	// find the break entry matching this id.  note that the breakpoints are already sorted in ascending order by id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2070
	TBreakEntry entry;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2071
	entry.iId = aId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2072
	TInt index = iBreakPointList.FindInSignedKeyOrder(entry);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2073
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2074
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2075
	if (index >= 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2076
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2077
		// if this breakpoint was set in a library and that library has already been unloaded, don't try to clear it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2078
		if (!iBreakPointList[index].iObsoleteLibraryBreakpoint)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2079
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2080
			LOG_MSG2("Clearing breakpoint at address %x", iBreakPointList[index].iAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2081
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2082
			DThread* threadObj = ThreadFromId(iBreakPointList[index].iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2083
			// In case of multiple memory model, if the thread doesn't exist any more, don't try to clear it.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2084
			// For example it might be in a static library which was unloaded when the thread exited,
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2085
			// but we didn't get told so we didn't mark it as iObsoleteLibraryBreakpoint.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2086
			if (threadObj != NULL)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2087
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2088
				XTRAPD(r, XT_DEFAULT, err = DebugSupport::RestoreCode(threadObj, iBreakPointList[index].iAddress));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2089
				err = (KErrNone == r) ? err : r;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2090
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2091
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2092
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2093
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2094
				err = KErrBadHandle;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2095
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2096
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2097
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2098
		if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2099
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2100
			// if this is a temp breakpoint, just clear out the values, otherwise remove it from the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2101
			if (index < NUMBER_OF_TEMP_BREAKPOINTS)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2102
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2103
				iBreakPointList[index].Reset();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2104
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2105
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2106
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2107
				iBreakPointList.Remove(index);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2108
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2109
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2110
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2111
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2112
			LOG_MSG2("Error clearing breakpoint %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2113
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2114
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2115
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2116
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2117
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2118
	LOG_MSG2("Break Id %d not found", aId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2119
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2120
	return KErrNotFound;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2121
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2122
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2123
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2124
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2125
// DMetroTrkChannel::DoChangeBreakThread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2126
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2127
TInt DMetroTrkChannel::DoChangeBreakThread(TUint32 aThreadId, TInt32 aId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2128
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2129
	LOG_MSG("DMetroTrkChannel::DoChangeBreakThread()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2130
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2131
	// find the break entry matching this id.  note that the breakpoints are already sorted in ascending order by id
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2132
	TBreakEntry entry;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2133
	entry.iId = aId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2134
	TInt index = iBreakPointList.FindInSignedKeyOrder(entry);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2135
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2136
	if (index >=0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2137
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2138
		// change the thread id for this breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2139
		iBreakPointList[index].iThreadId = aThreadId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2140
		return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2141
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2142
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2143
	return KErrNotFound;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2144
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2145
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2146
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2147
// DMetroTrkChannel::DoSuspendThread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2148
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2149
TInt DMetroTrkChannel::DoSuspendThread(DThread *aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2150
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2151
	LOG_MSG("DMetroTrkChannel::DoSuspendThread()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2152
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2153
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2154
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2155
		LOG_MSG("Invalid dthread object");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2156
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2157
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2158
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2159
	NThread nThread = aThread->iNThread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2160
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2161
	if (nThread.iSuspendCount == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2162
		Kern::ThreadSuspend(*aThread, 1); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2163
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2164
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2165
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2166
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2167
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2168
// DMetroTrkChannel::DoResumeThread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2169
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2170
TInt DMetroTrkChannel::DoResumeThread(DThread *aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2171
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2172
	LOG_MSG("DMetroTrkChannel::DoResumeThread()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2173
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2174
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2175
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2176
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2177
	// get the current PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2178
	TUint32 currentPC = ReadRegister(aThread, PC_REGISTER);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2179
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2180
	// if there is a breakpoint at the current PC, we need to single step past it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2181
	for (TInt i=NUMBER_OF_TEMP_BREAKPOINTS; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2182
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2183
		if (iBreakPointList[i].iAddress == currentPC)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2184
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2185
			return DoStepRange(aThread, currentPC, currentPC+1, ETrue, ETrue);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2186
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2187
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2188
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2189
	// PANIC_BACKPORT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2190
	// if frozen use semaphore
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2191
	for(TInt i=0; i<iFrozenThreadSemaphores.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2192
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2193
		if(iFrozenThreadSemaphores[i]->iOwningThread == &aThread->iNThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2194
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2195
			NKern::FSSignal(iFrozenThreadSemaphores[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2196
			NKern::ThreadEnterCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2197
			delete iFrozenThreadSemaphores[i];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2198
			NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2199
			iFrozenThreadSemaphores.Remove(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2200
			return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2201
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2202
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2203
	// END PANIC_BACKPORT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2204
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2205
	// else use ThreadResume
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2206
	Kern::ThreadResume(*aThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2207
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2208
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2209
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2210
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2211
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2212
// DMetroTrkChannel::DoStepRange
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2213
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2214
TInt DMetroTrkChannel::DoStepRange(DThread *aThread, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto, TBool aResumeOnceOutOfRange, TBool aUserRequest)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2215
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2216
	LOG_MSG("DMetroTrkChannel::DoStepRange()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2217
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2218
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2219
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2220
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2221
	TUint32 startAddress = (aStartAddress & 0x1) ? aStartAddress + 1 : aStartAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2222
	TUint32 stopAddress = (aStopAddress & 0x1) ? aStopAddress + 1 : aStopAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2223
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2224
	// don't allow the user to step in the excluded ROM region.  this could be called
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2225
	// internally however.  for example, the the special breakpoints we set to handle
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2226
	// panics, exceptions, and library loaded events are in the user library, and we
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2227
	// will need to step past the breakpoint before continuing the thread.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2228
	//if (aUserRequest && (startAddress >= iExcludedROMAddressStart) && (startAddress < iExcludedROMAddressEnd))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2229
	//{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2230
	//	return KErrNotSupported;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2231
	//}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2232
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2233
	// set the temp breakpoint, and disable the breakpoint at the current PC if necessary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2234
	// if its not a user request, and we are just trying to resume from a breakpoint, 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2235
	// then we don't need to check for stubs. The last parameter aUserRequest tells 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2236
	// ModifyBreaksForStep to check for stubs or not. In some cases, the check for stubs 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2237
	// is true even if its not a user request.For example, this is true in cases where 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2238
	// we are doing a step range and the instruction in the range modified PC.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2239
	// in this case, DoStepRange will be called from the exception handler where 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2240
	// we need to check for the stubs for the valid behavior. So truly, we don't need to check 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2241
	// for stubs only when resuming from  a breakpoint.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2242
	ReturnIfError(ModifyBreaksForStep(aThread, startAddress, stopAddress, aStepInto, aResumeOnceOutOfRange, aUserRequest));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2243
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2244
	// PANIC_BACKPORT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2245
	// if frozen use semaphore
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2246
	for(TInt i=0; i<iFrozenThreadSemaphores.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2247
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2248
		if(iFrozenThreadSemaphores[i]->iOwningThread == &aThread->iNThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2249
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2250
			NKern::FSSignal(iFrozenThreadSemaphores[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2251
			NKern::ThreadEnterCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2252
			delete iFrozenThreadSemaphores[i];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2253
			NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2254
			iFrozenThreadSemaphores.Remove(i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2255
			return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2256
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2257
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2258
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2259
	// END PANIC_BACKPORT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2260
	// else use ThreadResume
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2261
	Kern::ThreadResume(*aThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2262
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2263
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2264
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2265
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2266
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2267
// DMetroTrkChannel::DoReadMemory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2268
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2269
TInt DMetroTrkChannel::DoReadMemory(DThread *aThread, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2270
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2271
	LOG_MSG("DMetroTrkChannel::DoReadMemory()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2272
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2273
	// make sure the parameters are valid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2274
	if (aLength > aData.MaxSize())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2275
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2276
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2277
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2278
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2279
	// trap exceptions in case the address is invalid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2280
	XTRAPD(r, XT_DEFAULT, err = TryToReadMemory(aThread, (TAny *)aAddress, (TAny *)aData.Ptr(), aLength));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2281
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2282
	err = (KErrNone == r) ? err : r;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2283
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2284
	if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2285
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2286
		aData.SetLength(aLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2287
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2288
		TPtr8 data((TUint8 *)aData.Ptr(), aLength, aLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2289
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2290
		// if we have any breakpoints in this range, put the actual instruction in the buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2291
		for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2292
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2293
			if ((iBreakPointList[i].iAddress >= aAddress) && (iBreakPointList[i].iAddress < (aAddress + aLength)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2294
			{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2295
				TInt instSize = (TInt)(iBreakPointList[i].iThumbMode ? 2 : 4);								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2296
				memcpy((TAny*)&data[iBreakPointList[i].iAddress - aAddress], (TAny *)iBreakPointList[i].iInstruction.Ptr(), instSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2297
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2298
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2299
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2300
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2301
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2302
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2303
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2304
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2305
// DMetroTrkChannel::DoWriteMemory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2306
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2307
TInt DMetroTrkChannel::DoWriteMemory(DThread *aThread, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2308
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2309
	LOG_MSG("DMetroTrkChannel::DoWriteMemory()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2310
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2311
	// make sure the parameters are valid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2312
	if (aLength > aData.Length())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2313
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2314
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2315
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2316
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2317
	// trap exceptions in case the address is invalid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2318
	XTRAPD(r, XT_DEFAULT,  err = TryToWriteMemory(aThread, (TAny *)aAddress, (TAny *)aData.Ptr(), aLength));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2319
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2320
	err = (KErrNone == r) ? err : r;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2321
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2322
	// reset any breakpoints we may have just overwritten
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2323
	if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2324
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2325
		TPtr8 data((TUint8 *)aData.Ptr(), aLength, aLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2326
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2327
		for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2328
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2329
			if ((iBreakPointList[i].iAddress >= aAddress) && (iBreakPointList[i].iAddress < (aAddress + aLength)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2330
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2331
				// default to arm mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2332
				TUint32 inst = KArmBreakPoint;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2333
				TInt instSize = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2334
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2335
				if (iBreakPointList[i].iThumbMode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2336
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2337
					inst = KThumbBreakPoint;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2338
					instSize = 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2339
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2340
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2341
				iBreakPointList[i].iInstruction.Copy(&data[iBreakPointList[i].iAddress - aAddress], instSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2342
				//memcpy((TAny*)iBreakPointList[i].iAddress, (TAny *)&inst, instSize);			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2343
				TryToWriteMemory(aThread, (TAny*)iBreakPointList[i].iAddress, (TAny *)&inst, instSize);			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2344
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2345
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2346
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2347
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2348
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2349
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2350
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2351
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2352
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2353
// DMetroTrkChannel::DoReadRegisters
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2354
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2355
TInt DMetroTrkChannel::DoReadRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDes8 &aValues)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2356
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2357
	LOG_MSG("DMetroTrkChannel::DoReadRegisters()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2358
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2359
	// make sure the parameters are valid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2360
	if (!aThread || (aFirstRegister < 0) || (aLastRegister >= (TInt16)(sizeof(TArmRegSet)/sizeof(TArmReg))))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2361
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2362
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2363
	// make sure the descriptor is big enough to hold the requested data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2364
	if ((TInt)((aLastRegister - aFirstRegister + 1) * sizeof(TArmReg)) > (aValues.MaxSize()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2365
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2366
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2367
	TArmRegSet regSet;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2368
    TUint32 unused;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2369
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2370
#ifdef SUPPORT_KERNCONTEXT
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2371
	NKern::Lock(); // lock the kernel before callin UserContextType as its required by this function
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2372
	NThread nThread = aThread->iNThread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2373
	NThread::TUserContextType userContextType = nThread.UserContextType();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2374
	NKern::Unlock(); //unlock the kernel now
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2375
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2376
	if (userContextType == NThread::EContextNone || userContextType == NThread::EContextKernel)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2377
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2378
		//NKern::ThreadGetSystemContext(&aThread->iNThread, &regSet, unused);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2379
		if (!GetSystemThreadRegisters(&regSet))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2380
			return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2381
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2382
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2383
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2384
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2385
		NKern::ThreadGetUserContext(&aThread->iNThread, &regSet, unused);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2386
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2387
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2388
    TArmReg *reg = &regSet.iR0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2389
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2390
	if (!reg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2391
		return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2392
			    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2393
    for (TInt16 i = aFirstRegister; i <= aLastRegister; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2394
    	aValues.Append((TUint8 *)&reg[i], sizeof(TArmReg));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2395
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2396
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2397
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2398
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2399
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2400
// DMetroTrkChannel::DoWriteRegisters
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2401
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2402
TInt DMetroTrkChannel::DoWriteRegisters(DThread *aThread, const TInt16 aFirstRegister, const TInt16 aLastRegister, TDesC8 &aValues)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2403
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2404
	LOG_MSG("DMetroTrkChannel::DoWriteRegisters()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2405
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2406
	// make sure the parameters are valid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2407
	if (!aThread || (aFirstRegister < 0) || (aLastRegister >= (TInt16)(sizeof(TArmRegSet)/sizeof(TArmReg))))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2408
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2409
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2410
	// make sure the descriptor is big enough to hold the data to write
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2411
	if ((TInt)((aLastRegister - aFirstRegister + 1) * sizeof(TArmReg)) > (aValues.Length()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2412
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2413
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2414
    TArmRegSet regSet;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2415
    TUint32 unused;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2416
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2417
	NKern::ThreadGetUserContext(&aThread->iNThread, &regSet, unused);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2418
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2419
    TArmReg *reg = &regSet.iR0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2420
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2421
    for (TInt16 i = aFirstRegister; i <= aLastRegister; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2422
    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2423
    	#ifndef __OEM_TRK__	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2424
		if (IsRegisterSecure(i))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2425
			return KErrNotSupported;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2426
		#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2427
    	reg[i] = *(TUint32 *)&aValues[(i-aFirstRegister)*sizeof(TArmReg)];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2428
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2429
    	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2430
    	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2431
    NKern::ThreadSetUserContext(&aThread->iNThread, &regSet);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2432
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2433
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2434
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2435
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2436
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2437
// DMetroTrkChannel::DoGetProcessInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2438
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2439
TInt DMetroTrkChannel::DoGetProcessInfo(const TInt aIndex, TMetroTrkTaskInfo *aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2440
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2441
	LOG_MSG("DMetroTrkChannel::DoGetProcessInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2442
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2443
	DObjectCon *processes = Kern::Containers()[EProcess];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2444
	if (!processes)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2445
		return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2446
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2447
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2448
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2449
	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2450
	processes->Wait(); // Obtain the container mutex so the list does get changed under us
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2451
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2452
	// make sure the index is valid
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2453
	if ((aIndex >= 0) && (aIndex < processes->Count())) // >= because the index is zero based
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2454
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2455
		DProcess *process = (DProcess *)((*processes)[aIndex]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2456
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2457
		if (process)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2458
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2459
			process->Name(aInfo->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2460
			aInfo->iId = process->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2461
			aInfo->iPriority = (TUint32)process->iPriority;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2462
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2463
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2464
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2465
			LOG_MSG2("Process %d not found", aIndex);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2466
			err = KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2467
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2468
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2469
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2470
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2471
		err = KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2472
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2473
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2474
	processes->Signal();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2475
	NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2476
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2477
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2478
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2479
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2480
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2481
// DMetroTrkChannel::DoGetThreadInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2482
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2483
TInt DMetroTrkChannel::DoGetThreadInfo(const TInt aIndex, TMetroTrkTaskInfo *aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2484
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2485
	LOG_MSG("DMetroTrkChannel::DoGetThreadInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2486
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2487
	DObjectCon *threads = Kern::Containers()[EThread];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2488
	if (!threads)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2489
		return KErrGeneral;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2490
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2491
	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2492
	threads->Wait(); // Obtain the container mutex so the list does get changed under us
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2493
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2494
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2495
	if ((aIndex >= 0) && (aIndex < threads->Count()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2496
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2497
		DThread *thread = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2498
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2499
		TInt threadsForProcessCount = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2500
		TBool found = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2501
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2502
		for (TInt i=0; i<threads->Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2503
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2504
			thread = (DThread *)((*threads)[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2505
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2506
			if (thread && (aInfo->iOtherId == thread->iOwningProcess->iId))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2507
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2508
				if (threadsForProcessCount == aIndex)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2509
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2510
					thread->Name(aInfo->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2511
					aInfo->iId = thread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2512
					aInfo->iPriority = (TUint32)thread->iThreadPriority;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2513
					found = ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2514
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2515
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2516
				threadsForProcessCount++;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2517
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2518
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2519
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2520
		if (!found)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2521
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2522
			LOG_MSG("Thread for process matching index not found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2523
			err = KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2524
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2525
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2526
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2527
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2528
	{		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2529
		err = KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2530
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2531
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2532
	threads->Signal();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2533
	NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2534
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2535
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2536
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2537
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2538
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2539
// DMetroTrkChannel::DoGetProcessAddresses
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2540
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2541
TInt DMetroTrkChannel::DoGetProcessAddresses(DThread *aThread, TUint32 &aCodeAddress, TUint32 &aDataAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2542
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2543
	LOG_MSG("DMetroTrkChannel::DoGetProcessAddresses()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2544
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2545
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2546
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2547
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2548
#ifndef __OEM_TRK__			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2549
	if (HasManufacturerCaps(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2550
		return KErrPermissionDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2551
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2552
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2553
	DProcess *process = (DProcess *)aThread->iOwningProcess;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2554
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2555
	if (!process)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2556
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2557
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2558
	DCodeSeg* codeSeg = process->iCodeSeg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2559
	if (!codeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2560
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2561
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2562
	TModuleMemoryInfo processMemoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2563
	TInt err = codeSeg->GetMemoryInfo(processMemoryInfo, process);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2564
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2565
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2566
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2567
	aCodeAddress = processMemoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2568
	aDataAddress = processMemoryInfo.iInitialisedDataBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2569
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2570
	//add this process to the list of processes that we are debugging
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2571
	TProcessInfo processInfo(process->iId, aCodeAddress, processMemoryInfo.iCodeSize, aDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2572
	iDebugProcessList.Append(processInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2573
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2574
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2575
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2576
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2577
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2578
// DMetroTrkChannel::DoGetStaticLibraryInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2579
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2580
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2581
TInt DMetroTrkChannel::DoGetStaticLibraryInfo(const TInt aIndex, SEventInfo *aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2582
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2583
	LOG_MSG("DMetroTrkChannel::DoGetStaticLibraryInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2584
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2585
	if (!aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2586
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2587
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2588
	DThread *thread = ThreadFromId(aInfo->iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2589
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2590
	if (!thread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2591
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2592
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2593
	DProcess *process = (DProcess *)thread->iOwningProcess;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2594
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2595
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2596
	if (!process)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2597
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2598
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2599
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2600
	DCodeSeg *processCodeSeg = process->iCodeSeg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2601
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2602
	if (!processCodeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2603
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2604
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2605
	int count = processCodeSeg->iDepCount;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2606
	LOG_MSG2("code segment count %d", count);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2607
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2608
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2609
	if (aIndex < 0 || aIndex >= count)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2610
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2611
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2612
	DCodeSeg **codeSegList = processCodeSeg->iDeps;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2613
	if (!codeSegList)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2614
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2615
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2616
	DCodeSeg* codeSeg = codeSegList[aIndex];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2617
	if (!codeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2618
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2619
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2620
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2621
	if (!codeSeg->IsDll())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2622
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2623
		LOG_MSG(" -- code segment is not for a dll");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2624
		return KErrArgument;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2625
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2626
	TModuleMemoryInfo memoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2627
	TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL); //NULL for DProcess should be ok;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2628
	if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2629
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2630
		LOG_MSG2("Error in getting TModuleMemoryInfo info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2631
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2632
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2633
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2634
	aInfo->iEventType = SEventInfo::ELibraryLoaded;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2635
	aInfo->iFileName.Copy(*(codeSeg->iFileName)); //just the name, without uid info.		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2636
	aInfo->iCodeAddress = memoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2637
	aInfo->iDataAddress = memoryInfo.iInitialisedDataBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2638
	//this way, host debugger will not resume the thread, instead engine will resume
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2639
	//after going through the list of all static libraries..
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2640
	aInfo->iThreadId = 0xFFFFFFFF; 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2641
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2642
	LOG_MSG2("library name: %S", codeSeg->iFileName);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2643
	LOG_MSG2("code address: %x", aInfo->iCodeAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2644
	LOG_MSG2("data address: %x", aInfo->iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2645
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2646
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2647
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2648
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2649
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2650
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2651
// DMetroTrkChannel::DoGetLibraryInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2652
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2653
TInt DMetroTrkChannel::DoGetLibraryInfo(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2654
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2655
	LOG_MSG("DMetroTrkChannel::DoGetLibraryInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2656
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2657
	TInt err = KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2658
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2659
	if (!aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2660
		return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2661
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2662
	err = DoGetLibInfoFromCodeSegList(aDllName, aInfo);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2663
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2664
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2665
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2666
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2667
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2668
// DMetroTrkChannel::DoGetExeInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2669
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2670
TInt DMetroTrkChannel::DoGetExeInfo(TDesC8 &aExeName, TMetroTrkExeInfo* aExeInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2671
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2672
	LOG_MSG("DMetroTrkChannel::DoGetExeInfo()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2673
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2674
	DObjectCon *processes = Kern::Containers()[EProcess];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2675
	if (!processes)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2676
		return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2677
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2678
	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2679
	processes->Wait(); // Obtain the container mutex so the list does get changed under us
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2680
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2681
	TInt err = KErrNotFound; //set err to KErrNotFound
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2682
	for (TInt i=0;  i < processes->Count(); i++) // >= because the index is zero based
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2683
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2684
		DProcess *process = (DProcess *)((*processes)[i]);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2685
		if (process && (0x0 != aExeInfo->iUid) && (aExeInfo->iUid == process->iUids.iUid[2].iUid))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2686
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2687
			DCodeSeg* codeSeg = process->iCodeSeg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2688
			DThread* mainThread = process->FirstThread();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2689
			if (codeSeg && mainThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2690
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2691
				aExeInfo->iProcessID = process->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2692
				aExeInfo->iThreadID = mainThread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2693
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2694
				TModuleMemoryInfo memoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2695
				err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2696
				if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2697
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2698
					aExeInfo->iCodeAddress = memoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2699
					aExeInfo->iDataAddress = memoryInfo.iInitialisedDataBase;					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2700
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2701
				}								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2702
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2703
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2704
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2705
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2706
	processes->Signal();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2707
	NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2708
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2709
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2710
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2711
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2712
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2713
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2714
// DMetroTrkChannel::DoGetProcUidInfo
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2715
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2716
TInt DMetroTrkChannel::DoGetProcUidInfo(TMetroTrkProcUidInfo* aProcUidInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2717
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2718
	LOG_MSG("DMetroTrkChannel::DoGetProcUidInfo()");	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2719
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2720
	TInt err = KErrNotFound;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2721
	DProcess* process = ProcessFromId(aProcUidInfo->iProcessID);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2722
	if (process)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2723
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2724
		aProcUidInfo->iUid1 = process->iUids.iUid[0].iUid;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2725
		aProcUidInfo->iUid2 = process->iUids.iUid[1].iUid;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2726
		aProcUidInfo->iUid3 = process->iUids.iUid[2].iUid;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2727
		aProcUidInfo->iSecurID = process->iS.iSecureId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2728
		aProcUidInfo->iVendorID = process->iS.iVendorId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2729
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2730
		err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2731
	}								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2732
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2733
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2734
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2735
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2736
// DMetroTrkChannel::DoGetLibInfoFromCodeSegList
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2737
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2738
TInt DMetroTrkChannel::DoGetLibInfoFromCodeSegList(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2739
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2740
	LOG_MSG("DMetroTrkChannel::DoGetLibInfoFromCodeSegList()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2741
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2742
	TInt err = KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2743
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2744
	//get global code seg list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2745
	SDblQue* codeSegList = Kern::CodeSegList();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2746
	if (!codeSegList)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2747
		return KErrBadHandle;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2748
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2749
	//iterate through the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2750
	for (SDblQueLink* codeSegPtr = codeSegList->First(); codeSegPtr!=(SDblQueLink*) (codeSegList); codeSegPtr=codeSegPtr->iNext)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2751
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2752
		DEpocCodeSeg* codeSeg = (DEpocCodeSeg*)_LOFF(codeSegPtr,DCodeSeg, iLink);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2753
		if (codeSeg && codeSeg->IsDll())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2754
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2755
			if (codeSeg->iFileName) //If this is valid, the rootname will also be valid.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2756
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2757
				// some dll names from the code segment list have some characters towards the end.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2758
				// Not sure why.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2759
				// To account for this, we need to compare those strings that are 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2760
				// atleast as big as the dll we are looking for.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2761
				// Also the dll names in the code segment list don't have null terminator and so -1.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2762
				if (codeSeg->iRootName.Length() < aDllName.Length()-1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2763
					continue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2764
								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2765
				if (!_strnicmp(codeSeg->iRootName.Ptr(), aDllName.Ptr(), aDllName.Length()-1))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2766
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2767
					TModuleMemoryInfo memoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2768
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2769
					TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2770
					if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2771
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2772
						//there's been an error so return it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2773
						return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2774
					}							
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2775
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2776
					aInfo->iCodeAddress = memoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2777
					aInfo->iDataAddress = memoryInfo.iInitialisedDataBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2778
					if (codeSeg->iAttachProcess) //not valid if dll is used by multiple processes, so not reliable.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2779
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2780
						aInfo->iAttachProcessId = codeSeg->iAttachProcess->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2781
						if (codeSeg->iAttachProcess->FirstThread())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2782
							aInfo->iAttachThreadId = codeSeg->iAttachProcess->FirstThread()->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2783
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2784
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2785
					LOG_MSG2("Code segment found for lib: %s", aDllName.Ptr());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2786
					LOG_MSG2("code address: %x", aInfo->iCodeAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2787
					LOG_MSG2("data address: %x", aInfo->iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2788
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2789
					return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2790
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2791
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2792
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2793
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2794
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2795
	LOG_MSG2("Code segment not found for lib: %s", aDllName.Ptr());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2796
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2797
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2798
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2799
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2800
// DMetroTrkChannel::DoGetLibInfoFromKernLibContainer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2801
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2802
TInt DMetroTrkChannel::DoGetLibInfoFromKernLibContainer(TDesC8 &aDllName, TMetroTrkLibInfo *aInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2803
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2804
	LOG_MSG("DMetroTrkChannel::DoGetLibInfoFromKernLibContainer()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2805
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2806
	TInt err = KErrNone;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2807
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2808
	DObjectCon *libraries = Kern::Containers()[ELibrary];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2809
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2810
	if (!libraries)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2811
		return KErrGeneral;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2812
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2813
	NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2814
	libraries->Wait(); // Obtain the container mutex so the list does get changed under us
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2815
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2816
	for (TInt i=0; i<libraries->Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2817
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2818
		DLibrary *library = (DLibrary *)((*libraries)[i]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2819
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2820
		if (library)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2821
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2822
			TBuf<KMaxPath> libName;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2823
			libName.Copy(*(library->iName)); //just copy the name without the UID info.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2824
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2825
			if (libName.Length() < aDllName.Length()-1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2826
				continue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2827
								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2828
			if (!_strnicmp(libName.Ptr(), aDllName.Ptr(), aDllName.Length()-1))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2829
			{			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2830
				//get the code address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2831
				DCodeSeg* codeSeg = library->iCodeSeg;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2832
				if (codeSeg)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2833
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2834
					TModuleMemoryInfo memoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2835
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2836
					TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2837
					if (err == KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2838
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2839
						// there's been an error so return it					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2840
						aInfo->iCodeAddress = memoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2841
						aInfo->iDataAddress = memoryInfo.iInitialisedDataBase;						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2842
						// process id and thread id are in DLibrary object.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2843
					}					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2844
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2845
				else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2846
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2847
					LOG_MSG2("Code segment not available for library %S", library->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2848
					err = KErrNotFound;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2849
				}				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2850
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2851
			}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2852
		}										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2853
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2854
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2855
	libraries->Signal();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2856
	NKern::ThreadLeaveCS();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2857
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2858
	return err;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2859
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2860
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2861
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2862
// DMetroTrkChannel::DoSecurityCheck
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2863
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2864
TBool DMetroTrkChannel::DoSecurityCheck()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2865
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2866
	DProcess* clientProcess = iClientThread->iOwningProcess;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2867
	if (clientProcess)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2868
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2869
		// now we also check to make sure that TRK app has ALLFILES capability as well.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2870
		if (!iClientThread->HasCapability(ECapabilityAllFiles))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2871
			return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2872
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2873
		SSecurityInfo secureInfo = clientProcess->iS;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2874
		if ((secureInfo.iSecureId == KTrkSrvSecurUid) || (secureInfo.iSecureId == KTrkAppSecurUid) || (secureInfo.iSecureId == KTrkExeSecurUid))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2875
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2876
			return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2877
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2878
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2879
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2880
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2881
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2882
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2883
// DMetroTrkChannel::TryToReadMemory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2884
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2885
TInt DMetroTrkChannel::TryToReadMemory(DThread *aThread, TAny *aSrc, TAny *aDest, TInt16 aLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2886
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2887
	LOG_MSG("DMetroTrkChannel::TryToReadMemory()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2888
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2889
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2890
	// on some targets reading from 0xFFFFFFFF address causes a kernel fault.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2891
	// avoid reading the last 4 bytes in the 32 bit address space.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2892
	TUint32 srcAddr = (TUint32)(aSrc);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2893
	if ((srcAddr >= 0xFFFFFFFC) || (aLength > (0xFFFFFFFC-srcAddr)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2894
		return KErrAccessDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2895
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2896
#ifndef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2897
	if (IsAddressInRom((TUint32)(aSrc)) || IsAddressSecure((TUint32)(aSrc)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2898
		return KErrNotSupported;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2899
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2900
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2901
	//check if we have a valid thread object
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2902
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2903
		return KErrBadHandle;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2904
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2905
	LOG_MSG2("Using Kern::ThreadRawRead to read memory at address %x", aSrc);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2906
	err = Kern::ThreadRawRead(aThread, aSrc, aDest, aLength);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2907
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2908
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2909
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2910
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2911
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2912
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2913
// DMetroTrkChannel::TryToWriteMemory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2914
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2915
TInt DMetroTrkChannel::TryToWriteMemory(DThread *aThread, TAny *aDest, TAny *aSrc, TInt16 aLength)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2916
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2917
	LOG_MSG("DMetroTrkChannel::TryToWriteMemory()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2918
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2919
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2920
	// on some targets writing to 0xFFFFFFFF address causes a kernel fault.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2921
	// avoid writing the last 4 bytes in the 32 bit address space.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2922
	TUint32 destAddr = (TUint32)(aDest);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2923
	if ((destAddr>=0xFFFFFFFC) || (aLength > (0xFFFFFFFC-destAddr)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2924
		return KErrAccessDenied;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2925
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2926
#ifndef __OEM_TRK__
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2927
	if (IsAddressInRom((TUint32)(aDest)) || IsAddressSecure((TUint32)(aDest)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2928
		return KErrNotSupported;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2929
#endif
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2930
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2931
	//check if we have a valid thread object
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2932
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2933
		return KErrBadHandle;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2934
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2935
	LOG_MSG2("Using Kern::ThreadRawWrite to write memory at address %x", (TUint32)aDest);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2936
	err = Kern::ThreadRawWrite(aThread, aDest, aSrc, aLength, iClientThread);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2937
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2938
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2939
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2940
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2941
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2942
// DMetroTrkChannel::ReadRegister
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2943
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2944
TInt32 DMetroTrkChannel::ReadRegister(DThread *aThread, TInt aNum)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2945
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2946
	LOG_MSG("DMetroTrkChannel::ReadRegister()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2947
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2948
	if (!aThread || (aNum < 0) || (aNum >= (TInt16)(sizeof(TArmRegSet)/sizeof(TArmReg))))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2949
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2950
		LOG_MSG2("Invalid register number (%d) passed to ReadRegister", aNum);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2951
		return 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2952
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2953
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2954
	TArmRegSet regSet;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2955
    TUint32 unused;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2956
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2957
#ifdef SUPPORT_KERNCONTEXT	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2958
  	NKern::Lock(); // lock the kernel before callin UserContextType as its required by this function
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2959
	NThread nThread = aThread->iNThread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2960
	NThread::TUserContextType userContextType = nThread.UserContextType();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2961
	NKern::Unlock(); // unlock the kernel now
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2962
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2963
	if (userContextType == NThread::EContextNone || userContextType == NThread::EContextKernel)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2964
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2965
		//NKern::ThreadGetSystemContext(&aThread->iNThread, &regSet, unused);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2966
		if (!GetSystemThreadRegisters(&regSet))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2967
			return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2968
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2969
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2970
#endif	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2971
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2972
		NKern::ThreadGetUserContext(&aThread->iNThread, &regSet, unused);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2973
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2974
    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2975
    TArmReg *reg = &regSet.iR0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2976
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2977
	return ((TUint32 *)reg)[aNum];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2978
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2979
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2980
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2981
// DMetroTrkChannel::ShiftedRegValue
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2982
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2983
TUint32 DMetroTrkChannel::ShiftedRegValue(DThread *aThread, TUint32 aInstruction, TUint32 aCurrentPC, TUint32 aStatusRegister)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2984
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2985
	LOG_MSG("DMetroTrkChannel::ShiftedRegValue()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2986
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2987
	TUint32 shift = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2988
	if (aInstruction & 0x10)	// bit 4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2989
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2990
		shift = (ARM_RS(aInstruction) == PC_REGISTER ? aCurrentPC + 8 : aStatusRegister) & 0xFF;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2991
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2992
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2993
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2994
		shift = ARM_DATA_C(aInstruction);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2995
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2996
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2997
	TInt rm = ARM_RM(aInstruction);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2998
	TUint32 res = (rm == PC_REGISTER ? (aCurrentPC + ((aInstruction & 0x10) ? 12 : 8)) : ReadRegister(aThread, rm));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2999
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3000
	switch(ARM_DATA_SHIFT(aInstruction))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3001
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3002
		case 0:			// LSL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3003
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3004
			res = shift >= 32 ? 0 : res << shift;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3005
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3006
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3007
		case 1:			// LSR
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3008
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3009
			res = shift >= 32 ? 0 : res >> shift;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3010
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3011
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3012
		case 2:			// ASR
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3013
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3014
			if (shift >= 32)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3015
			shift = 31;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3016
			res = ((res & 0x80000000L) ? ~((~res) >> shift) : res >> shift);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3017
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3018
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3019
		case 3:			// ROR/RRX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3020
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3021
			shift &= 31;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3022
			if (shift == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3023
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3024
				res = (res >> 1) | ((aStatusRegister & ARM_CARRY_BIT) ? 0x80000000L : 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3025
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3026
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3027
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3028
				res = (res >> shift) | (res << (32 - shift));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3029
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3030
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3031
    	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3032
    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3033
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3034
  	return res & 0xFFFFFFFF;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3035
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3036
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3037
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3038
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3039
// DMetroTrkChannel::ModifyBreaksForStep
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3040
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3041
// Set a temporary breakpoint at the next instruction to be executed after the one at the current PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3042
// Disable the breakpoint at the current PC if one exists
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3043
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3044
TInt DMetroTrkChannel::ModifyBreaksForStep(DThread *aThread, TUint32 aRangeStart, TUint32 aRangeEnd, TBool aStepInto, TBool aResumeOnceOutOfRange, TBool aCheckForStubs)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3045
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3046
	LOG_MSG("DMetroTrkChannel::ModifyBreaksForStep()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3047
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3048
	if (!aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3049
		return KErrArgument;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3050
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3051
	LOG_MSG2("Range Start: %x", aRangeStart);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3052
	LOG_MSG2("Range End: %x", aRangeEnd);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3053
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3054
	// get the current PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3055
	TUint32 currentPC = ReadRegister(aThread, PC_REGISTER);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3056
	LOG_MSG2("Current PC: %x", currentPC);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3057
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3058
	// disable breakpoint at the current PC if necessary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3059
	ReturnIfError(DisableBreakAtAddress(currentPC));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3060
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3061
	// get the status register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3062
	TUint32 statusRegister = ReadRegister(aThread, STATUS_REGISTER);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3063
	LOG_MSG2("Current SR: %x", statusRegister);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3064
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3065
	TBool thumbMode = (statusRegister & ECpuThumb);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3066
	if (thumbMode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3067
		LOG_MSG("Thumb Mode");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3068
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3069
	TInt instSize = thumbMode ? 2 : 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3070
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3071
	TBool changingModes = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3072
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3073
	TUint32 breakAddress = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3074
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3075
	TInt rangeSize = aRangeEnd - currentPC;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3076
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3077
	const TInt KMaxInstructionBuffer = 80;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3078
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3079
	// scan the memory and see if any instruction might modify the PC.  if one does,
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3080
	// stop scanning and just set a breakpoint at that instruction (with the range set accordingly).
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3081
	// if none is found just set the breakpoint after the range.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3082
	// if there is only one instruction there is no need to parse the memory, just execute it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3083
	if ((rangeSize <= KMaxInstructionBuffer) && (rangeSize > instSize))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3084
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3085
		LOG_MSG("Scanning range for instructions that might modify the PC");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3086
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3087
		// set it to the end of the range by default
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3088
		breakAddress = aRangeEnd;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3089
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3090
		// get the instructions in range
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3091
		// we really should be dynamically allocating this memory, but this could be
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3092
		// called from another thread, so we can't
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3093
		TBuf8<KMaxInstructionBuffer> instructions;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3094
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3095
		ReturnIfError(DoReadMemory(aThread, currentPC, rangeSize, instructions));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3096
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3097
		for (TInt i = 0; i < (TInt)rangeSize/instSize; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3098
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3099
			if (InstructionModifiesPC(aThread, &instructions[i*instSize], thumbMode, aStepInto))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3100
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3101
				breakAddress = currentPC + i*instSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3102
				LOG_MSG2("Setting breakpoint at %x inside range", breakAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3103
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3104
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3105
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3106
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3107
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3108
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3109
	TUint32 newRangeEnd = aRangeEnd;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3110
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3111
	if ((breakAddress == 0) || (breakAddress == currentPC))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3112
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3113
		// either the range consists of a single instruction, or the instruction at the currentPC may modify the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3114
		// decode the instruction and see where we need to set the breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3115
		breakAddress = PCAfterInstructionExecutes(aThread, currentPC, statusRegister, instSize, aStepInto, newRangeEnd, changingModes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3116
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3117
		// check to see if this is one of the stubs (found in stubs.s)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3118
		if (aStepInto && aCheckForStubs)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3119
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3120
			TBuf8<16> destination;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3121
			TInt err = DoReadMemory(aThread, breakAddress, 16, destination);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3122
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3123
			if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3124
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3125
				TInt offset = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3126
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3127
				if (0 == destination.Find(KArm4Stub, sizeof(KArm4Stub)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3128
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3129
					LOG_MSG("Arm4 stub found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3130
					offset = 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3131
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3132
				else if ((0 == destination.Find(KArmIStub, sizeof(KArmIStub))) ||
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3133
						 (0 == destination.Find(KFastArmIStub, sizeof(KFastArmIStub))))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3134
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3135
					LOG_MSG("ArmI stub found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3136
					offset = 12;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3137
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3138
				else if ((0 == destination.Find(KThumbStub, sizeof(KThumbStub))) ||
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3139
						 (0 == destination.Find(KFastThumbStub, sizeof(KFastThumbStub))))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3140
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3141
					LOG_MSG("Thumb stub found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3142
					offset = 12;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3143
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3144
				else if ((0 == destination.Find(KThumbStub2, sizeof(KThumbStub2))) ||
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3145
						 (0 == destination.Find(KFastThumbStub2, sizeof(KFastThumbStub2))))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3146
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3147
					LOG_MSG("Thumb stub found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3148
					offset = 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3149
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3150
				//check to see if this is the stub generated with RVCT tools. 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3151
				//Look into genstubs.cpp for more details on this stub
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3152
				else if(0 == destination.Find(KRvctArm4Stub, sizeof(KRvctArm4Stub)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3153
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3154
					LOG_MSG("RVCT Arm4 stub found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3155
					offset = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3156
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3157
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3158
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3159
				if (offset != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3160
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3161
					if (offset == 4)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3162
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3163
						breakAddress = *(TUint32 *)&destination[offset];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3164
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3165
					else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3166
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3167
						err = DoReadMemory(aThread, *(TUint32 *)&destination[offset], 4, destination);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3168
						if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3169
							breakAddress = *(TUint32 *)destination.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3170
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3171
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3172
					if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3173
					{						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3174
						if (thumbMode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3175
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3176
							if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3177
								changingModes = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3178
							else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3179
								changingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3180
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3181
						else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3182
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3183
							if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3184
								changingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3185
							else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3186
								changingModes = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3187
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3188
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3189
						breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3190
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3191
					else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3192
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3193
						LOG_MSG("Error reading destination of stub");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3194
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3195
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3196
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3197
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3198
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3199
				LOG_MSG("Error reading memory while decoding branch instruction");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3200
			}					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3201
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3202
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3203
		// don't allow the user to step in a function in the excluded ROM region.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3204
		//if ((breakAddress >= iExcludedROMAddressStart) && (breakAddress < iExcludedROMAddressEnd))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3205
		//{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3206
		//	breakAddress = currentPC + instSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3207
		//	changingModes = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3208
		//}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3209
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3210
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3211
	// see if there is already a breakpoint at this address.  if there is, we do not need to set the temp breakpoint
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3212
	for (TInt i=NUMBER_OF_TEMP_BREAKPOINTS; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3213
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3214
		if (iBreakPointList[i].iAddress == breakAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3215
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3216
			return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3217
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3218
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3219
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3220
	for (TInt i=0; i<NUMBER_OF_TEMP_BREAKPOINTS; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3221
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3222
		if (iBreakPointList[i].iAddress == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3223
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3224
			iBreakPointList[i].iThreadId = aThread->iId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3225
			iBreakPointList[i].iAddress = breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3226
			iBreakPointList[i].iThumbMode = (thumbMode && !changingModes) || (!thumbMode && changingModes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3227
			iBreakPointList[i].iResumeOnceOutOfRange = aResumeOnceOutOfRange;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3228
			iBreakPointList[i].iSteppingInto = aStepInto;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3229
			iBreakPointList[i].iRangeStart = aRangeStart;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3230
			iBreakPointList[i].iRangeEnd = newRangeEnd;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3231
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3232
			// Temporary breakpoints are always thread specific
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3233
			iBreakPointList[i].iThreadSpecific = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3234
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3235
			LOG_MSG2("Adding temp breakpoint with id: %d", i);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3236
			LOG_MSG2("Adding temp breakpoint with thread id: %d", aThread->iId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3237
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3238
			return DoEnableBreak(iBreakPointList[i], ETrue);			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3239
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3240
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3241
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3242
	return KErrNoMemory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3243
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3244
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3245
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3246
// DMetroTrkChannel::ClearAllBreakPoints
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3247
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3248
void DMetroTrkChannel::ClearAllBreakPoints()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3249
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3250
	LOG_MSG("DMetroTrkChannel::ClearAllBreakPoints()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3251
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3252
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3253
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3254
	for (TInt i=0; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3255
	{		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3256
		if ((iBreakPointList[i].iAddress != 0) && !iBreakPointList[i].iObsoleteLibraryBreakpoint)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3257
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3258
			LOG_MSG2("Clearing breakpoint at address %x", iBreakPointList[i].iAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3259
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3260
			DThread* threadObj = ThreadFromId(iBreakPointList[i].iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3261
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3262
			if (threadObj != NULL)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3263
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3264
				XTRAPD(r, XT_DEFAULT, err = DebugSupport::RestoreCode(threadObj, iBreakPointList[i].iAddress));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3265
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3266
				err = (KErrNone == r) ? err : r;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3267
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3268
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3269
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3270
				err = KErrBadHandle;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3271
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3272
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3273
			if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3274
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3275
				LOG_MSG2("Error %d while clearing breakpoint", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3276
			}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3277
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3278
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3279
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3280
	iBreakPointList.Reset();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3281
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3282
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3283
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3284
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3285
// DMetroTrkChannel::DisableBreakAtAddress
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3286
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3287
TInt DMetroTrkChannel::DisableBreakAtAddress(TUint32 aAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3288
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3289
	LOG_MSG("DMetroTrkChannel::DisableBreakAtAddress()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3290
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3291
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3292
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3293
	for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3294
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3295
		if (iBreakPointList[i].iAddress == aAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3296
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3297
			iBreakPointList[i].iDisabledForStep = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3298
			LOG_MSG2("Disabling breakpoint at address %x", iBreakPointList[i].iAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3299
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3300
			DThread* threadObj = ThreadFromId(iBreakPointList[i].iThreadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3301
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3302
			//clear the breakpoint with code modifier
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3303
			//code modifier will restore the org instruction and also frees the shadow page if necessary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3304
			if (threadObj != NULL)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3305
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3306
				XTRAPD(r, XT_DEFAULT, err = DebugSupport::RestoreCode(threadObj, aAddress));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3307
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3308
				err = (KErrNone == r) ? err : r;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3309
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3310
			else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3311
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3312
				err = KErrBadHandle;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3313
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3314
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3315
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3316
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3317
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3318
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3319
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3320
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3321
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3322
// DMetroTrkChannel::InstructionModifiesPC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3323
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3324
TBool DMetroTrkChannel::InstructionModifiesPC(DThread *aThread, TUint8 *aInstruction, TBool aThumbMode, TBool aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3325
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3326
	LOG_MSG("DMetroTrkChannel::InstructionModifiesPC()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3327
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3328
	if (aThumbMode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3329
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3330
		TUint16 inst = *(TUint16 *)aInstruction;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3331
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3332
		switch(THUMB_OPCODE(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3333
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3334
			case 0x08:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3335
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3336
				if (aStepInto && (THUMB_INST_7_15(inst) == 0x08F))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3337
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3338
					// BLX(2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3339
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3340
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3341
				else if (THUMB_INST_7_15(inst) == 0x08E)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3342
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3343
					// BX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3344
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3345
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3346
				else if (((THUMB_INST_8_15(inst) == 0x46) || (THUMB_INST_8_15(inst) == 0x44)) && ((inst & 0x87) == 0x87))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3347
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3348
					// ADD or MOV with PC as the destination
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3349
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3350
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3351
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3352
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3353
			case 0x13:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3354
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3355
				if (THUMB_INST_8_15(inst) == 0x9F)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3356
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3357
					// LDR(4) with the PC as the destination
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3358
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3359
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3360
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3361
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3362
			case 0x17:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3363
			{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3364
				if (THUMB_INST_8_15(inst) == 0xBD)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3365
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3366
					// POP with the PC in the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3367
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3368
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3369
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3370
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3371
			case 0x1A:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3372
			case 0x1B:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3373
			{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3374
				if (THUMB_INST_8_15(inst) < 0xDE)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3375
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3376
					// B(1) conditional branch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3377
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3378
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3379
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3380
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3381
			case 0x1C:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3382
			{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3383
				// B(2) unconditional branch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3384
				return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3385
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3386
			case 0x1D:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3387
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3388
				// NOTE: Only return true for the suffix since it's the second instruction that actually does the branch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3389
				if (aStepInto && !(inst & 0x00000001))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3390
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3391
					// BLX(1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3392
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3393
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3394
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3395
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3396
			case 0x1F:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3397
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3398
				// NOTE: Only return true for the suffix since it's the second instruction that actually does the branch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3399
				if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3400
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3401
					// BL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3402
					return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3403
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3404
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3405
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3406
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3407
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3408
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3409
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3410
		// Arm mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3411
		TUint32 inst = *(TUint32 *)aInstruction;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3412
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3413
		switch(ARM_OPCODE(inst)) // bits 27-25
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3414
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3415
			case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3416
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3417
				switch((inst & 0x00000010) >> 4) // bit 4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3418
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3419
					case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3420
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3421
						switch((inst & 0x01800000) >> 23) // bits 24-23
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3422
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3423
							case 2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3424
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3425
								// move to/from status register.  pc updates not allowed
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3426
								// or TST, TEQ, CMP, CMN which don't modify the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3427
								break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3428
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3429
							default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3430
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3431
								// Data processing immediate shift
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3432
								if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3433
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3434
									// destination register is the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3435
									if (IsPreviousInstructionMovePCToLR(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3436
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3437
										return aStepInto;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3438
									}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3439
									else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3440
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3441
										return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3442
									}										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3443
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3444
								break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3445
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3446
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3447
						break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3448
					}					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3449
					case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3450
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3451
						switch((inst & 0x00000080) >> 7) // bit 7
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3452
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3453
							case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3454
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3455
								switch((inst & 0x01900000) >> 20) // bits 24-23 and bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3456
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3457
									case 0x10:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3458
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3459
										// from figure 3-3
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3460
										switch((inst & 0x000000F0) >> 4) // bits 7-4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3461
										{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3462
											case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3463
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3464
												if (((inst & 0x00400000) >> 22) == 0) // bit 22
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3465
												{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3466
													// BX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3467
													if (IsPreviousInstructionMovePCToLR(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3468
													{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3469
														return aStepInto;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3470
													}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3471
													else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3472
													{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3473
														return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3474
													}										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3475
												}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3476
												break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3477
											}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3478
											case 3:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3479
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3480
												// BLX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3481
												if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3482
												{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3483
													return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3484
												}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3485
												break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3486
											}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3487
											default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3488
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3489
												// either doesn't modify the PC or it is illegal to
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3490
												break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3491
											}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3492
										}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3493
										break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3494
									}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3495
									default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3496
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3497
										// Data processing register shift
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3498
										if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3499
										{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3500
											// TST, TEQ, CMP, CMN don't modify the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3501
											return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3502
										}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3503
										else if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3504
										{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3505
											// destination register is the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3506
											if (IsPreviousInstructionMovePCToLR(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3507
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3508
												return aStepInto;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3509
											}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3510
											else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3511
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3512
												return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3513
											}										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3514
										}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3515
										break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3516
									}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3517
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3518
								break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3519
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3520
							default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3521
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3522
								// from figure 3-2, updates to the PC illegal
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3523
								break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3524
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3525
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3526
						break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3527
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3528
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3529
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3530
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3531
			case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3532
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3533
				if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3534
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3535
					// cannot modify the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3536
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3537
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3538
				else if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3539
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3540
					// destination register is the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3541
					if (IsPreviousInstructionMovePCToLR(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3542
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3543
						return aStepInto;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3544
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3545
					else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3546
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3547
						return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3548
					}										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3549
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3550
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3551
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3552
			case 2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3553
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3554
				// load/store immediate offset
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3555
				if (ARM_LOAD(inst)) // bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3556
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3557
					// loading a register from memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3558
					if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3559
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3560
						// loading the PC register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3561
						if (IsPreviousInstructionMovePCToLR(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3562
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3563
							return aStepInto;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3564
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3565
						else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3566
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3567
							return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3568
						}										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3569
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3570
				}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3571
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3572
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3573
			case 3:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3574
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3575
				if (((inst & 0xF0000000) != 0xF) && ((inst & 0x00000010) == 0))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3576
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3577
					// load/store register offset
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3578
					if (ARM_LOAD(inst)) // bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3579
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3580
						// loading a register from memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3581
						if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3582
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3583
							// loading the PC register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3584
							if (IsPreviousInstructionMovePCToLR(aThread))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3585
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3586
								return aStepInto;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3587
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3588
							else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3589
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3590
								return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3591
							}										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3592
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3593
					}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3594
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3595
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3596
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3597
			case 4:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3598
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3599
				if ((inst & 0xF0000000) != 0xF)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3600
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3601
					// load/store multiple
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3602
					if (ARM_LOAD(inst)) // bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3603
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3604
						// loading a register from memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3605
						if (((inst & 0x00008000) >> 15))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3606
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3607
							// loading the PC register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3608
							return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3609
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3610
					}					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3611
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3612
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3613
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3614
			case 5:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3615
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3616
				if ((inst & 0xF0000000) == 0xF)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3617
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3618
					// BLX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3619
					if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3620
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3621
						return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3622
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3623
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3624
				else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3625
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3626
					if ((inst & 0x01000000)) // bit 24
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3627
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3628
						// BL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3629
						if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3630
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3631
							return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3632
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3633
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3634
					else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3635
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3636
						// B
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3637
						return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3638
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3639
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3640
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3641
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3642
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3643
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3644
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3645
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3646
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3647
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3648
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3649
// DMetroTrkChannel::PCAfterInstructionExecutes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3650
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3651
TUint32 DMetroTrkChannel::PCAfterInstructionExecutes(DThread *aThread, TUint32 aCurrentPC, TUint32 aStatusRegister, TInt aInstSize, TBool aStepInto, TUint32 &aNewRangeEnd, TBool &aChangingModes)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3652
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3653
	LOG_MSG("DMetroTrkChannel::PCAfterInstructionExecutes()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3654
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3655
	// by default we will set the breakpoint at the next instruction
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3656
	TUint32 breakAddress = aCurrentPC + aInstSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3657
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3658
	// get the instruction at the current PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3659
	TBuf8<4> instruction;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3660
	TInt err = DoReadMemory(aThread, aCurrentPC, aInstSize, instruction); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3661
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3662
	if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3663
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3664
		return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3665
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3666
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3667
	if (4 == aInstSize)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3668
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3669
		TUint32 inst = *(TUint32 *)instruction.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3670
		LOG_MSG2("Current instruction: %x", inst);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3671
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3672
		// check the conditions to see if this will actually get executed
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3673
		if (IsExecuted(((inst>>28) & 0x0000000F), aStatusRegister)) 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3674
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3675
			switch(ARM_OPCODE(inst)) // bits 27-25
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3676
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3677
				case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3678
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3679
					switch((inst & 0x00000010) >> 4) // bit 4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3680
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3681
						case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3682
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3683
							switch((inst & 0x01800000) >> 23) // bits 24-23
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3684
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3685
								case 2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3686
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3687
									// move to/from status register.  pc updates not allowed
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3688
									// or TST, TEQ, CMP, CMN which don't modify the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3689
									break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3690
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3691
								default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3692
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3693
									// Data processing immediate shift
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3694
									if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3695
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3696
										// destination register is the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3697
										if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3698
										{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3699
											return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3700
										}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3701
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3702
										TUint32 rn = aCurrentPC + 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3703
										if (ARM_RN(inst) != PC_REGISTER) // bits 19-16
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3704
										{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3705
											rn = ReadRegister(aThread, ARM_RN(inst));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3706
										}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3707
										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3708
										TUint32 shifter = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3709
										
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3710
										DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3711
									}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3712
									break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3713
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3714
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3715
							break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3716
						}					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3717
						case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3718
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3719
							switch((inst & 0x00000080) >> 7) // bit 7
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3720
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3721
								case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3722
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3723
									switch((inst & 0x01900000) >> 20) // bits 24-23 and bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3724
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3725
										case 0x10:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3726
										{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3727
											// from figure 3-3
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3728
											switch((inst & 0x000000F0) >> 4) // bits 7-4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3729
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3730
												case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3731
												{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3732
													if (((inst & 0x00400000) >> 22) == 0) // bit 22
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3733
													{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3734
														// BX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3735
														// this is a strange case.  normally this is used in the epilogue to branch the the link
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3736
														// register.  sometimes it is used to call a function, and the LR is stored in the previous
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3737
														// instruction.  since what we want to do is different for the two cases when stepping over,
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3738
														// we need to read the previous instruction to see what we should do
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3739
														if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3740
														{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3741
															return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3742
														}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3743
														
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3744
														breakAddress = ReadRegister(aThread, (inst & 0x0000000F));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3745
														
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3746
														if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3747
														{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3748
															aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3749
														}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3750
														
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3751
														breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3752
													}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3753
													break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3754
												}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3755
												case 3:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3756
												{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3757
													// BLX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3758
													if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3759
													{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3760
														breakAddress = ReadRegister(aThread, (inst & 0x0000000F));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3761
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3762
														if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3763
														{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3764
															aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3765
														}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3766
														
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3767
														breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3768
													}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3769
													break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3770
												}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3771
												default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3772
												{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3773
													// either doesn't modify the PC or it is illegal to
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3774
													break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3775
												}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3776
											}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3777
											break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3778
										}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3779
										default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3780
										{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3781
											// Data processing register shift
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3782
											if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3783
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3784
												// TST, TEQ, CMP, CMN don't modify the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3785
											}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3786
											else if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3787
											{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3788
												// destination register is the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3789
												if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3790
												{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3791
													return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3792
												}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3793
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3794
												TUint32 rn = aCurrentPC + 8;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3795
												if (ARM_RN(inst) != PC_REGISTER) // bits 19-16
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3796
												{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3797
													rn = ReadRegister(aThread, ARM_RN(inst));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3798
												}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3799
												
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3800
												TUint32 shifter = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3801
												
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3802
												DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3803
											}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3804
											break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3805
										}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3806
									}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3807
									break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3808
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3809
								default:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3810
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3811
									// from figure 3-2, updates to the PC illegal
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3812
									break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3813
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3814
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3815
							break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3816
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3817
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3818
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3819
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3820
				case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3821
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3822
					if (((inst & 0x01800000) >> 23) == 2) // bits 24-23
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3823
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3824
						// cannot modify the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3825
						break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3826
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3827
					else if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3828
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3829
						// destination register is the PC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3830
						if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3831
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3832
							return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3833
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3834
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3835
						TUint32 rn = ReadRegister(aThread, ARM_RN(inst)); // bits 19-16
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3836
						TUint32 shifter = ((ARM_DATA_IMM(inst) >> ARM_DATA_ROT(inst)) | (ARM_DATA_IMM(inst) << (32 - ARM_DATA_ROT(inst)))) & 0xffffffff;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3837
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3838
						DecodeDataProcessingInstruction(((inst & 0x01E00000) >> 21), rn, shifter, aStatusRegister, breakAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3839
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3840
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3841
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3842
				case 2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3843
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3844
					// load/store immediate offset
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3845
					if (ARM_LOAD(inst)) // bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3846
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3847
						// loading a register from memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3848
						if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3849
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3850
							// loading the PC register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3851
							if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3852
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3853
								return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3854
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3855
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3856
					    	TUint32 base = ReadRegister(aThread, ARM_RN(inst));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3857
					    	TUint32 offset = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3858
					    	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3859
					    	if (ARM_SINGLE_PRE(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3860
					    	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3861
					    		// Pre-indexing
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3862
					    		offset = ARM_SINGLE_IMM(inst);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3863
							    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3864
							    if (ARM_SINGLE_U(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3865
							    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3866
							    	base += offset;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3867
							    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3868
							    else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3869
							    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3870
							    	base -= offset;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3871
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3872
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3873
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3874
							TBuf8<4> destination;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3875
							TInt err = DoReadMemory(aThread, base, 4, destination);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3876
							
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3877
							if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3878
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3879
								breakAddress = *(TUint32 *)destination.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3880
							
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3881
								if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3882
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3883
									aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3884
								}								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3885
								breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3886
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3887
							else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3888
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3889
								LOG_MSG("Error reading memory in decoding step instruction");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3890
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3891
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3892
					}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3893
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3894
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3895
				case 3:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3896
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3897
					if (((inst & 0xF0000000) != 0xF) && ((inst & 0x00000010) == 0))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3898
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3899
						// load/store register offset
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3900
						if (ARM_LOAD(inst)) // bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3901
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3902
							// loading a register from memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3903
							if (ARM_RD(inst) == PC_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3904
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3905
								// loading the PC register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3906
								if (IsPreviousInstructionMovePCToLR(aThread) && !aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3907
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3908
									return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3909
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3910
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3911
						    	TUint32 base = (ARM_RN(inst) == PC_REGISTER) ? aCurrentPC + 8 : ReadRegister(aThread, ARM_RN(inst));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3912
						    	TUint32 offset = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3913
						    	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3914
						    	if (ARM_SINGLE_PRE(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3915
						    	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3916
							      	offset = ShiftedRegValue(aThread, inst, aCurrentPC, aStatusRegister);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3917
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3918
								    if (ARM_SINGLE_U(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3919
								    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3920
								    	base += offset;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3921
								    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3922
								    else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3923
								    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3924
								    	base -= offset;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3925
									}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3926
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3927
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3928
								TBuf8<4> destination;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3929
								TInt err = DoReadMemory(aThread, base, 4, destination);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3930
								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3931
								if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3932
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3933
									breakAddress = *(TUint32 *)destination.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3934
									
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3935
									if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3936
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3937
										aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3938
									}								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3939
									breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3940
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3941
								else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3942
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3943
									LOG_MSG("Error reading memory in decoding step instruction");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3944
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3945
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3946
						}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3947
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3948
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3949
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3950
				case 4:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3951
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3952
					if ((inst & 0xF0000000) != 0xF)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3953
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3954
						// load/store multiple
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3955
						if (ARM_LOAD(inst)) // bit 20
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3956
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3957
							// loading a register from memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3958
							if (((inst & 0x00008000) >> 15))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3959
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3960
								// loading the PC register
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3961
								TInt offset = 0;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3962
								if (ARM_BLOCK_U(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3963
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3964
									TUint32 reglist = ARM_BLOCK_REGLIST(inst);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3965
									offset = Bitcount(reglist) * 4 - 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3966
									if (ARM_BLOCK_PRE(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3967
										offset += 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3968
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3969
								else if (ARM_BLOCK_PRE(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3970
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3971
									offset = -4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3972
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3973
									
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3974
						    	TUint32 temp = ReadRegister(aThread, ARM_RN(inst));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3975
								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3976
								temp += offset;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3977
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3978
								TBuf8<4> destination;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3979
								TInt err = DoReadMemory(aThread, temp, 4, destination);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3980
								
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3981
								if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3982
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3983
									breakAddress = *(TUint32 *)destination.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3984
									if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3985
									{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3986
										aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3987
									}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3988
									breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3989
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3990
								else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3991
								{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3992
									LOG_MSG("Error reading memory in decoding step instruction");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3993
								}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3994
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3995
						}					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3996
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3997
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3998
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  3999
				case 5:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4000
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4001
					if ((inst & 0xF0000000) == 0xF)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4002
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4003
						// BLX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4004
						if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4005
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4006
							breakAddress = (TUint32)ARM_INSTR_B_DEST(inst, aCurrentPC);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4007
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4008
							if ((breakAddress & 0x00000001) == 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4009
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4010
								aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4011
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4012
							
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4013
							breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4014
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4015
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4016
					else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4017
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4018
						if ((inst & 0x01000000)) // bit 24
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4019
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4020
							// BL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4021
							if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4022
							{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4023
								breakAddress = (TUint32)ARM_INSTR_B_DEST(inst, aCurrentPC);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4024
							}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4025
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4026
						else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4027
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4028
							// B
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4029
							breakAddress = (TUint32)ARM_INSTR_B_DEST(inst, aCurrentPC);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4030
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4031
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4032
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4033
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4034
			}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4035
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4036
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4037
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4038
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4039
		// Thumb Mode
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4040
		TUint16 inst = *(TUint16 *)instruction.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4041
		LOG_MSG2("Current instruction: %x", inst);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4042
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4043
		switch(THUMB_OPCODE(inst))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4044
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4045
			case 0x08:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4046
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4047
				if (aStepInto && (THUMB_INST_7_15(inst) == 0x08F))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4048
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4049
					// BLX(2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4050
					breakAddress = ReadRegister(aThread, ((inst & 0x0078) >> 3));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4051
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4052
					if ((breakAddress & 0x00000001) == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4053
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4054
						aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4055
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4056
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4057
					breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4058
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4059
				else if (THUMB_INST_7_15(inst) == 0x08E)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4060
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4061
					// BX
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4062
					breakAddress = ReadRegister(aThread, ((inst & 0x0078) >> 3));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4063
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4064
					if ((breakAddress & 0x00000001) == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4065
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4066
						aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4067
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4068
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4069
					breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4070
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4071
				else if ((THUMB_INST_8_15(inst) == 0x46) && ((inst & 0x87) == 0x87))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4072
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4073
					// MOV with PC as the destination
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4074
					breakAddress = ReadRegister(aThread, ((inst & 0x0078) >> 3));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4075
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4076
				else if ((THUMB_INST_8_15(inst) == 0x44) && ((inst & 0x87) == 0x87))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4077
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4078
					// ADD with PC as the destination
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4079
					breakAddress = aCurrentPC + ReadRegister(aThread, ((inst & 0x0078) >> 3));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4080
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4081
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4082
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4083
			case 0x13:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4084
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4085
				//This instruction doesn't modify the PC.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4086
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4087
				//if (THUMB_INST_8_15(inst) == 0x9F)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4088
				//{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4089
					// LDR(4) with the PC as the destination
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4090
				//	breakAddress = ReadRegister(aThread, SP_REGISTER) + (4 * (inst & 0x00FF));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4091
				//}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4092
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4093
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4094
			case 0x17:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4095
			{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4096
				if (THUMB_INST_8_15(inst) == 0xBD)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4097
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4098
					// POP with the PC in the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4099
					TUint32 regList = (inst & 0x00FF);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4100
					TInt offset = ReadRegister(aThread, SP_REGISTER) + (Bitcount(regList) * 4);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4101
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4102
					TBuf8<4> destination;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4103
					TInt err = DoReadMemory(aThread, offset, 4, destination);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4104
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4105
					if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4106
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4107
						breakAddress = *(TUint32 *)destination.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4108
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4109
						if ((breakAddress & 0x00000001) == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4110
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4111
							aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4112
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4113
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4114
						breakAddress &= 0xFFFFFFFE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4115
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4116
					else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4117
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4118
						LOG_MSG("Error reading memory in decoding step instruction");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4119
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4120
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4121
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4122
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4123
			case 0x1A:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4124
			case 0x1B:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4125
			{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4126
				if (THUMB_INST_8_15(inst) < 0xDE)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4127
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4128
					// B(1) conditional branch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4129
					if (IsExecuted(((inst & 0x0F00) >> 8), aStatusRegister))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4130
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4131
						TUint32 offset = ((inst & 0x000000FF) << 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4132
						if (offset & 0x00000100)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4133
						{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4134
							offset |= 0xFFFFFF00;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4135
						}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4136
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4137
						breakAddress = aCurrentPC + 4 + offset;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4138
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4139
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4140
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4141
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4142
			case 0x1C:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4143
			{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4144
				// B(2) unconditional branch
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4145
				TUint32 offset = (inst & 0x000007FF) << 1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4146
				if (offset & 0x00000800)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4147
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4148
					offset |= 0xFFFFF800;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4149
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4150
				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4151
				breakAddress = aCurrentPC + 4 + offset;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4152
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4153
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4154
			case 0x1D:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4155
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4156
				if (aStepInto && !(inst & 0x0001))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4157
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4158
					// BLX(1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4159
					breakAddress = (ReadRegister(aThread, LINK_REGISTER) + ((inst & 0x07FF) << 1));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4160
					if ((breakAddress & 0x00000001) == 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4161
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4162
						aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4163
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4164
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4165
					breakAddress &= 0xFFFFFFFC;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4166
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4167
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4168
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4169
			case 0x1E:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4170
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4171
				// BL/BLX prefix - destination is encoded in this and the next instruction
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4172
				aNewRangeEnd += 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4173
                // BL Stepping Changes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4174
                if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4175
                {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4176
                    TBuf8<2> nextInstruction;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4177
                    TInt err = DoReadMemory(aThread, aCurrentPC+2, aInstSize, nextInstruction);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4178
                    if (KErrNone == err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4179
                    {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4180
                        TUint16 nextInst = *(TUint16*)nextInstruction.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4181
                        LOG_MSG2("Next instruction: %x", nextInst);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4182
                        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4183
                        // base new LR from first instruction
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4184
                        TUint32 newLR = inst & 0x07FF;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4185
                        newLR <<= 12;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4186
                        if (newLR & (TUint32)(0x0400 << 12))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4187
                        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4188
                            // sign-extend it
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4189
                            newLR |= 0xFF800000;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4190
                        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4191
                        newLR += aCurrentPC + 4;        // pc is pointing to first instruction + 4
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4192
                        TUint32 newPC = newLR + ((nextInst & 0x07FF) << 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4193
                        if (THUMB_OPCODE(nextInst) == 0x1D)         // H = 01 changing to ARM (BLX)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4194
                        {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4195
                            newPC &= 0xFFFFFFFC;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4196
                            aChangingModes = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4197
                        }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4198
                        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4199
                        breakAddress = newPC;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4200
                    }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4201
                }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4202
                else    // step over
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4203
                {
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4204
                    breakAddress += 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4205
                }
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4206
                // End of BL Stepping Changes
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4207
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4208
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4209
			case 0x1F:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4210
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4211
				if (aStepInto)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4212
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4213
					// BL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4214
					breakAddress = ReadRegister(aThread, LINK_REGISTER) + ((inst & 0x07FF) << 1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4215
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4216
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4217
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4218
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4219
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4220
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4221
	return breakAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4222
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4223
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4224
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4225
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4226
// DMetroTrkChannel::DecodeDataProcessingInstruction
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4227
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4228
void DMetroTrkChannel::DecodeDataProcessingInstruction(TUint8 aOpcode, TUint32 aOp1, TUint32 aOp2, TUint32 aStatusRegister, TUint32 &aBreakAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4229
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4230
	LOG_MSG("DMetroTrkChannel::DecodeDataProcessingInstruction()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4231
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4232
	switch(aOpcode)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4233
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4234
		case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4235
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4236
			// AND
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4237
			aBreakAddress = aOp1 & aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4238
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4239
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4240
		case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4241
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4242
			// EOR
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4243
			aBreakAddress = aOp1 ^ aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4244
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4245
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4246
		case 2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4247
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4248
			// SUB
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4249
			aBreakAddress = aOp1 - aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4250
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4251
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4252
		case 3:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4253
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4254
			// RSB
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4255
			aBreakAddress = aOp2 - aOp1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4256
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4257
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4258
		case 4:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4259
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4260
			// ADD
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4261
			aBreakAddress = aOp1 + aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4262
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4263
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4264
		case 5:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4265
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4266
			// ADC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4267
			aBreakAddress = aOp1 + aOp2 + (aStatusRegister & ARM_CARRY_BIT) ? 1 : 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4268
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4269
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4270
		case 6:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4271
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4272
			// SBC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4273
			aBreakAddress = aOp1 - aOp2 - (aStatusRegister & ARM_CARRY_BIT) ? 0 : 1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4274
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4275
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4276
		case 7:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4277
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4278
			// RSC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4279
			aBreakAddress = aOp2 - aOp1 - (aStatusRegister & ARM_CARRY_BIT) ? 0 : 1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4280
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4281
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4282
		case 12:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4283
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4284
			// ORR
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4285
			aBreakAddress = aOp1 | aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4286
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4287
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4288
		case 13:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4289
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4290
			// MOV
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4291
			aBreakAddress = aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4292
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4293
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4294
		case 14:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4295
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4296
			// BIC
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4297
			aBreakAddress = aOp1 & ~aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4298
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4299
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4300
		case 15:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4301
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4302
			// MVN
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4303
			aBreakAddress = ~aOp2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4304
			break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4305
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4306
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4307
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4308
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4309
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4310
// DMetroTrkChannel::IsPreviousInstructionMovePCToLR
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4311
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4312
TBool DMetroTrkChannel::IsPreviousInstructionMovePCToLR(DThread *aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4313
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4314
	LOG_MSG("DMetroTrkChannel::IsPreviousInstructionMovePCToLR()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4315
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4316
	// there are several types of instructions that modify the PC that aren't
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4317
	// designated as linked or non linked branches.  the way gcc generates the
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4318
	// code can tell us whether or not these instructions are to be treated as
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4319
	// linked branches.  the main cases are bx and any type of mov or load or
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4320
	// arithmatic operation that changes the PC.  if these are really just
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4321
	// function calls that will return, gcc will generate a mov	lr, pc
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4322
	// instruction as the previous instruction.  note that this is just for arm
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4323
	// and armi
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4324
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4325
	// get the address of the previous instruction
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4326
	TUint32 address = ReadRegister(aThread, PC_REGISTER) - 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4327
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4328
	TBuf8<4> previousInstruction;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4329
	TInt err = DoReadMemory(aThread, address, 4, previousInstruction);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4330
	if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4331
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4332
		LOG_MSG2("Error %d reading memory at address %x", address);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4333
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4334
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4335
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4336
	const TUint32 movePCToLRIgnoringCondition = 0x01A0E00F;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4337
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4338
	TUint32 inst = *(TUint32 *)previousInstruction.Ptr();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4339
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4340
	if ((inst & 0x0FFFFFFF) == movePCToLRIgnoringCondition)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4341
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4342
		return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4343
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4344
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4345
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4346
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4347
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4348
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4349
// DMetroTrkChannel::DoEnableDisabledBreak
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4350
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4351
// Restore the breakpoint that was disabled for stepping past it if necessary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4352
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4353
TInt DMetroTrkChannel::DoEnableDisabledBreak(TUint32 aThreadId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4354
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4355
	LOG_MSG("DMetroTrkChannel::DoEnableDisabledBreak()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4356
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4357
	for (TInt i = NUMBER_OF_TEMP_BREAKPOINTS; i < iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4358
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4359
//	    if (iBreakPointList[i].iDisabledForStep && ((iBreakPointList[i].iThreadId == aThreadId) || (iBreakPointList[i].iThreadId == 0xFFFFFFFF)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4360
	    //  Always re-enable non-Thread Specific breakpoints
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4361
		if (iBreakPointList[i].iDisabledForStep && ((iBreakPointList[i].iThreadId == aThreadId) || (iBreakPointList[i].iThreadSpecific == EFalse)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4362
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4363
			LOG_MSG2("Re-enabling breakpoint at address %x", iBreakPointList[i].iAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4364
			iBreakPointList[i].iDisabledForStep = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4365
			return DoEnableBreak(iBreakPointList[i], EFalse);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4366
		}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4367
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4368
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4369
	return KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4370
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4371
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4372
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4373
// DMetroTrkChannel::IsExecuted
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4374
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4375
// Determines whether or not an instruction will be executed
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4376
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4377
TBool DMetroTrkChannel::IsExecuted(TUint8 aCondition ,TUint32 aStatusRegister)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4378
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4379
	LOG_MSG("DMetroTrkChannel::IsExecuted()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4380
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4381
	TBool N = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000008;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4382
	TBool Z = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000004;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4383
	TBool C = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000002;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4384
	TBool V = ((aStatusRegister >> 28) & 0x0000000F) & 0x00000001;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4385
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4386
	switch(aCondition)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4387
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4388
		case 0:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4389
			return Z;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4390
		case 1:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4391
			return !Z;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4392
		case 2:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4393
			return C;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4394
		case 3:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4395
			return !C;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4396
		case 4:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4397
			return N;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4398
		case 5:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4399
			return !N;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4400
		case 6:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4401
			return V;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4402
		case 7:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4403
			return !V;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4404
		case 8:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4405
			return (C && !Z);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4406
		case 9:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4407
			return (!C || Z);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4408
		case 10:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4409
			return (N == V);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4410
		case 11:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4411
			return (N != V);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4412
		case 12:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4413
			return ((N == V) && !Z);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4414
		case 13:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4415
			return (Z || (N != V));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4416
		case 14:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4417
		case 15:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4418
			return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4419
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4420
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4421
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4422
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4423
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4424
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4425
TBool DMetroTrkChannel::IsAddressInRom(TUint32 aAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4426
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4427
	LOG_MSG("DMetroTrkChannel::IsAddressInRom()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4428
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4429
	TRomHeader romHeader = Epoc::RomHeader();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4430
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4431
	if ((aAddress >= romHeader.iRomBase ) && (aAddress < (romHeader.iRomBase + romHeader.iRomSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4432
		return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4433
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4434
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4435
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4436
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4437
TBool DMetroTrkChannel::IsAddressSecure(TUint32 aAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4438
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4439
	LOG_MSG("DMetroTrkChannel::IsAddressInRom()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4440
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4441
	// SHORT TERM FIX...
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4442
	// For now, don't allow access to Kernel memory...
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4443
	TLinAddr kernDataStartAddr =  iMultipleMemModel ? KSuperPageMultipleLinAddr: KSuperPageMovingLinAddr;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4444
	TLinAddr kernDataEndAddr = iMultipleMemModel ? KKernDataEndMultipleLinAddr: KKernDataEndMovingLinAddr;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4445
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4446
	if ((aAddress >= kernDataStartAddr) && (aAddress <= kernDataEndAddr))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4447
		return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4448
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4449
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4450
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4451
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4452
TBool DMetroTrkChannel::IsRegisterSecure(TInt registerIndex)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4453
{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4454
	LOG_MSG("DMetroTrkChannel::IsRegisterSecure()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4455
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4456
	if (registerIndex == SP_REGISTER || registerIndex == LINK_REGISTER || registerIndex == STATUS_REGISTER)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4457
		return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4458
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4459
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4460
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4461
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4462
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4463
// DMetroTrkChannel::AllocateShadowPageIfNecessary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4464
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4465
// Allocate a shadow page if the address is in ROM and no page has been allocated for that range yet
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4466
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4467
TInt DMetroTrkChannel::AllocateShadowPageIfNecessary(TUint32 aAddress, TUint32 &aPageAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4468
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4469
	LOG_MSG("DMetroTrkChannel::AllocateShadowPageIfNecessary()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4470
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4471
	// if this is in ROM, we need to shadow memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4472
	TBool inRom = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4473
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4474
	//find out if M::IsRomAddress is available from ekern or any other library
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4475
	//ReturnIfError(inRom = M::IsRomAddress((TAny *)aAddress));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4476
	TRomHeader romHeader = Epoc::RomHeader();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4477
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4478
	if ((aAddress >= romHeader.iRomBase ) && (aAddress < (romHeader.iRomBase + romHeader.iRomSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4479
		inRom = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4480
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4481
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4482
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4483
	if (inRom) // && (TSuperPage().iRomConfig[0].iType != KBdbBankTypeRamAsRom))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4484
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4485
		// if a shadow page has not already been allocated for this address range, do so now
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4486
		TUint32 pageAddress = (aAddress & ~(iPageSize-1));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4487
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4488
		TBool found = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4489
		for (TInt i=0; i<iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4490
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4491
			if (pageAddress == iBreakPointList[i].iPageAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4492
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4493
				LOG_MSG2("Shadow page already allocated at address %x", pageAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4494
				found = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4495
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4496
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4497
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4498
		if (!found)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4499
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4500
			LOG_MSG2("Allocating shadow page starting at address %x", pageAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4501
			err = Epoc::AllocShadowPage(pageAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4502
			if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4503
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4504
				LOG_MSG2("Error %d allocating shadow page", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4505
				return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4506
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4507
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4508
			//check to see if this is still necessary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4509
			//if ((ASSPID() & ASSP_ID_MASK) == XSCALE_ASSP_ID)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4510
				//FlushDataCache(); // workaround for cache flush problem on Lubbock/PXA255 base port
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4511
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4512
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4513
		// return the page address
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4514
		aPageAddress = pageAddress;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4515
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4516
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4517
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4518
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4519
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4520
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4521
// DMetroTrkChannel::FreeShadowPageIfNecessary
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4522
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4523
// Free a shadow page if the address is in ROM and no no other breakpoints are set in that page range
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4524
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4525
TInt DMetroTrkChannel::FreeShadowPageIfNecessary(TUint32 aAddress, TUint32 aPageAddress)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4526
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4527
	LOG_MSG("DMetroTrkChannel::FreeShadowPageIfNecessary()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4528
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4529
	TInt err = KErrNone;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4530
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4531
	TBool found = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4532
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4533
	TBool inRom = EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4534
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4535
	//find out if M::IsRomAddress is available from ekern or any other library
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4536
	//ReturnIfError(inRom = M::IsRomAddress((TAny *)aAddress));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4537
	TRomHeader romHeader = Epoc::RomHeader();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4538
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4539
	if ((aAddress >= romHeader.iRomBase ) && (aAddress < (romHeader.iRomBase + romHeader.iRomSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4540
		inRom = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4541
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4542
	if (inRom)// && (TSuperPage().iRomConfig[0].iType != KBdbBankTypeRamAsRom))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4543
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4544
		// if there are no other breakpoints in this shadow page, we can free it now
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4545
		for (TInt i = 0; i < iBreakPointList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4546
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4547
			if (aAddress != iBreakPointList[i].iAddress) // ignore the current entry
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4548
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4549
				if ((iBreakPointList[i].iAddress >= aPageAddress) &&
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4550
					(iBreakPointList[i].iAddress < (aPageAddress + iPageSize)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4551
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4552
					LOG_MSG("Still a breakpoint in this shadow page range");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4553
					found = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4554
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4555
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4556
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4557
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4558
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4559
		if (!found)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4560
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4561
			LOG_MSG2("Freeing shadow page starting at address %x", aPageAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4562
			err = Epoc::FreeShadowPage(aPageAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4563
			if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4564
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4565
				LOG_MSG2("Error %d freeing shadow page", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4566
				return KErrGeneral;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4567
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4568
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4569
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4570
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4571
	return err;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4572
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4573
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4574
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4575
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4576
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4577
// DMetroTrkChannel::NotifyEvent
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4578
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4579
void DMetroTrkChannel::NotifyEvent(SEventInfo aEventInfo, TBool isTraceEvent)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4580
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4581
	LOG_MSG("DMetroTrkChannel::NotifyEvent()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4582
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4583
	if (iEventInfo)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4584
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4585
		LOG_MSG2("Completing event, type: %d", aEventInfo.iEventType);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4586
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4587
		// iThread is the user side debugger thread, so use it to write the info to it memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4588
		TInt err = Kern::ThreadRawWrite(iClientThread, iEventInfo, (TUint8 *)&aEventInfo, sizeof(SEventInfo), iClientThread);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4589
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4590
		if (KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4591
			LOG_MSG2("Error writing event info: %d", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4592
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4593
		// clear this since we've completed the request
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4594
		iEventInfo = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4595
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4596
		// signal the debugger thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4597
		Kern::RequestComplete(iClientThread, iRequestGetEventStatus, KErrNone);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4598
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4599
	else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4600
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4601
		if (isTraceEvent)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4602
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4603
			LOG_MSG("Queuing trace event\r\n");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4604
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4605
			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4606
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4607
				if (SEventInfo::EUnknown == iTraceEventQueue[i].iEventType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4608
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4609
					iTraceEventQueue[i] = aEventInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4610
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4611
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4612
			}			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4613
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4614
		else
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4615
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4616
			LOG_MSG2("Queuing event, type: %d", aEventInfo.iEventType);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4617
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4618
			for (TInt i=0; i<NUMBER_OF_EVENTS_TO_QUEUE; i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4619
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4620
				if (SEventInfo::EUnknown == iEventQueue[i].iEventType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4621
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4622
					iEventQueue[i] = aEventInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4623
					break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4624
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4625
			}			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4626
		}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4627
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4628
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4629
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4630
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4631
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4632
// DMetroTrkChannel::ThreadFromId
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4633
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4634
DThread* DMetroTrkChannel::ThreadFromId(TUint32 aId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4635
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4636
	LOG_MSG("DMetroTrkChannel::ThreadFromId()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4637
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4638
	NKern::ThreadEnterCS();  // Prevent us from dying or suspending whilst holding a DMutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4639
	DObjectCon& threads = *Kern::Containers()[EThread];  // Get containing holding threads
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4640
	threads.Wait();  // Obtain the container mutex so the list does get changed under us
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4641
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4642
	DThread* thread = Kern::ThreadFromId(aId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4643
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4644
	threads.Signal();  // Release the container mutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4645
	NKern::ThreadLeaveCS();  // End of critical section
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4646
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4647
	return thread;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4648
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4649
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4650
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4651
// DMetroTrkChannel::ProcessFromId
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4652
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4653
DProcess* DMetroTrkChannel::ProcessFromId(TUint32 aId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4654
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4655
	LOG_MSG("DMetroTrkChannel::ProcessFromId()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4656
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4657
	NKern::ThreadEnterCS();  // Prevent us from dying or suspending whilst holding a DMutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4658
	DObjectCon& processes = *Kern::Containers()[EProcess];  // Get containing holding threads
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4659
	processes.Wait();  // Obtain the container mutex so the list does get changed under us
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4660
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4661
	DProcess* process = Kern::ProcessFromId(aId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4662
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4663
	processes.Signal();  // Release the container mutex
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4664
	NKern::ThreadLeaveCS();  // End of critical section
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4665
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4666
	return process;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4667
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4668
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4669
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4670
// DMetroTrkChannel::GetSystemThreadRegisters
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4671
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4672
TBool DMetroTrkChannel::GetSystemThreadRegisters(TArmRegSet* aArmRegSet)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4673
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4674
	if (iExcInfoValid)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4675
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4676
		aArmRegSet->iR0 = iCurrentExcInfo.iR0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4677
		aArmRegSet->iR1 = iCurrentExcInfo.iR1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4678
		aArmRegSet->iR2 = iCurrentExcInfo.iR2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4679
		aArmRegSet->iR3 = iCurrentExcInfo.iR3;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4680
		aArmRegSet->iR4 = iCurrentExcInfo.iR4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4681
		aArmRegSet->iR5 = iCurrentExcInfo.iR5;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4682
		aArmRegSet->iR6 = iCurrentExcInfo.iR6;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4683
		aArmRegSet->iR7 = iCurrentExcInfo.iR7;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4684
		aArmRegSet->iR8 = iCurrentExcInfo.iR8;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4685
		aArmRegSet->iR9 = iCurrentExcInfo.iR9;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4686
		aArmRegSet->iR10 = iCurrentExcInfo.iR10;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4687
		aArmRegSet->iR11 = iCurrentExcInfo.iR11;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4688
		aArmRegSet->iR12 = iCurrentExcInfo.iR12;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4689
		aArmRegSet->iR13 = iCurrentExcInfo.iR13;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4690
		aArmRegSet->iR14 = iCurrentExcInfo.iR14;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4691
		aArmRegSet->iR15 = iCurrentExcInfo.iR15;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4692
		aArmRegSet->iFlags = iCurrentExcInfo.iCpsr;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4693
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4694
		return ETrue;				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4695
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4696
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4697
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4698
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4699
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4700
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4701
TBool DMetroTrkChannel::HasManufacturerCaps(DThread* aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4702
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4703
	if (aThread && (aThread->HasCapability(ECapabilityTCB) || 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4704
		    		aThread->HasCapability(ECapabilityDRM) || 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4705
					aThread->HasCapability(ECapabilityAllFiles)))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4706
	{				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4707
		return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4708
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4709
	return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4710
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4711
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4712
TBool DMetroTrkChannel::IsBeingDebugged(const DThread* aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4713
{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4714
	TBool isDebugging = EFalse;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4715
	if (aThread)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4716
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4717
		for (TInt i = 0; i < iDebugProcessList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4718
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4719
			if (iDebugProcessList[i].iId == aThread->iOwningProcess->iId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4720
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4721
				isDebugging = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4722
				break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4723
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4724
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4725
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4726
	return isDebugging;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4727
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4728
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4729
void DMetroTrkChannel::CheckLibraryNotifyList(TUint32 aProcessId)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4730
{   
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4731
	SDblQue* codeSegList = Kern::CodeSegList();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4732
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4733
	for (TInt i=0; i<iLibraryNotifyList.Count(); i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4734
	{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4735
		if (!iLibraryNotifyList[i].iEmptySlot)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4736
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4737
			//iterate through the list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4738
			for (SDblQueLink* codeSegPtr = codeSegList->First(); codeSegPtr != (SDblQueLink*)(codeSegList); codeSegPtr = codeSegPtr->iNext)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4739
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4740
				DEpocCodeSeg* codeSeg = (DEpocCodeSeg*)_LOFF(codeSegPtr, DCodeSeg, iLink);   
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4741
				if (codeSeg && codeSeg->IsDll())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4742
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4743
					SEventInfo info;						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4744
					if (!_strnicmp(iLibraryNotifyList[i].iName.Ptr(), codeSeg->iRootName.Ptr(), codeSeg->iRootName.Length()))
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4745
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4746
						info.iFileName.Copy((codeSeg->iRootName.Ptr())); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4747
						LOG_MSG2("library name match: %S", &info.iFileName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4748
						TModuleMemoryInfo memoryInfo;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4749
						TInt err = codeSeg->GetMemoryInfo(memoryInfo, NULL);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4750
						if (err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4751
				  		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4752
				       		break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4753
				   		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4754
				   		// 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4755
				   		// check the process id from the DCodeSeg instead of using aProcessId
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4756
				   		// if the iAttachProcess from DCodeSeg is null, then we should use aProcessId
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4757
						info.iProcessId = aProcessId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4758
						info.iEventType = SEventInfo::ELibraryLoaded; 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4759
						info.iCodeAddress = memoryInfo.iCodeBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4760
						info.iDataAddress = memoryInfo.iInitialisedDataBase;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4761
						info.iThreadId = 0xFFFFFFFF; 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4762
						LOG_MSG2("info.iCodeAddress: %x", info.iCodeAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4763
						LOG_MSG2("info.iDataAddress: %x", info.iDataAddress);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4764
						LOG_MSG2("info.iProcessId: %d", info.iProcessId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4765
						NotifyEvent(info);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4766
						
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4767
						// now reset this entry					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4768
						iLibraryNotifyList[i].iEmptySlot = ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4769
						break;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4770
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4771
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4772
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4773
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4774
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4775
}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4776
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4777
DECLARE_STANDARD_LDD()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4778
{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4779
    return new DMetroTrkDriverFactory;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  4780
}