core/src/commands.cpp
changeset 86 849a0b46c767
parent 83 2a78c4ff2eab
child 94 8df58d8c99e8
equal deleted inserted replaced
85:6a26ca985d90 86:849a0b46c767
   281 		DoScanDirL();
   281 		DoScanDirL();
   282 		}
   282 		}
   283 	else
   283 	else
   284 		{
   284 		{
   285 		CDir* files;
   285 		CDir* files;
   286 		LeaveIfErr(FsL().GetDir(iFileName, iOptAll ? KEntryAttMaskSupported : KEntryAttNormal | KEntryAttDir, ESortByName, files), _L("Couldn't read whole directory into memory - try using -1"));
   286 		TInt err = FsL().GetDir(iFileName, iOptAll ? KEntryAttMaskSupported : KEntryAttNormal | KEntryAttDir, ESortByName, files);
       
   287 		if (err == KErrNoMemory) LeaveIfErr(err, _L("Couldn't read whole directory into memory - try using --one option"));
       
   288 		else LeaveIfErr(err, _L("Couldn't read directory"));
   287 		CleanupStack::PushL(files);
   289 		CleanupStack::PushL(files);
   288 		PrintDirContentL(*files);
   290 		PrintDirContentL(*files);
   289 		CleanupStack::PopAndDestroy(files);
   291 		CleanupStack::PopAndDestroy(files);
   290 		}
   292 		}
   291 	}
   293 	}
  2518 	aOptions.AppendBoolL(iUseTimestampFormat, KCmdDateOptTimestamp);
  2520 	aOptions.AppendBoolL(iUseTimestampFormat, KCmdDateOptTimestamp);
  2519 	aOptions.AppendBoolL(iUseY2k, KCmdDateOptY2k);
  2521 	aOptions.AppendBoolL(iUseY2k, KCmdDateOptY2k);
  2520 	}
  2522 	}
  2521 
  2523 
  2522 
  2524 
       
  2525 #ifdef FSHELL_CORE_SUPPORT_FSCK
       
  2526 
  2523 //
  2527 //
  2524 // CCmdFsck.
  2528 // CCmdFsck.
  2525 //
  2529 //
  2526 
  2530 
  2527 CCommandBase* CCmdFsck::NewLC()
  2531 CCommandBase* CCmdFsck::NewLC()
  2582 	{
  2586 	{
  2583 	_LIT(KCmdFsckArg, "drive_letter");
  2587 	_LIT(KCmdFsckArg, "drive_letter");
  2584 	aArguments.AppendStringL(iDriveLetter, KCmdFsckArg);
  2588 	aArguments.AppendStringL(iDriveLetter, KCmdFsckArg);
  2585 	}
  2589 	}
  2586 
  2590 
       
  2591 #endif // FSHELL_CORE_SUPPORT_FSCK
       
  2592 
  2587 
  2593 
  2588 //
  2594 //
  2589 // CCmdDriver.
  2595 // CCmdDriver.
  2590 //
  2596 //
  2591 
  2597 
  2689 	aArguments.AppendEnumL((TInt&)iType, KCmdDriverArg2);
  2695 	aArguments.AppendEnumL((TInt&)iType, KCmdDriverArg2);
  2690 	aArguments.AppendStringL(iDriverName, KCmdDriverArg3);
  2696 	aArguments.AppendStringL(iDriverName, KCmdDriverArg3);
  2691 	}
  2697 	}
  2692 
  2698 
  2693 
  2699 
       
  2700 #ifdef FSHELL_CORE_SUPPORT_CHUNKINFO
       
  2701 
  2694 //
  2702 //
  2695 // CCmdChunkInfo.
  2703 // CCmdChunkInfo.
  2696 //
  2704 //
  2697 
  2705 
  2698 CCommandBase* CCmdChunkInfo::NewLC()
  2706 CCommandBase* CCmdChunkInfo::NewLC()
  2714 	{
  2722 	{
  2715 	}
  2723 	}
  2716 
  2724 
  2717 void CCmdChunkInfo::ListChunksL()
  2725 void CCmdChunkInfo::ListChunksL()
  2718 	{
  2726 	{
  2719 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  2720 	TInt bufSize = 1024;
  2727 	TInt bufSize = 1024;
  2721 	TInt err = KErrNone;
  2728 	TInt err = KErrNone;
  2722 	HBufC8* addressesBuf;
  2729 	HBufC8* addressesBuf;
  2723 	do
  2730 	do
  2724 		{
  2731 		{
  2792 				}
  2799 				}
  2793 			}
  2800 			}
  2794 		}
  2801 		}
  2795 
  2802 
  2796 	CleanupStack::PopAndDestroy(addressesBuf);
  2803 	CleanupStack::PopAndDestroy(addressesBuf);
  2797 #endif
       
  2798 	}
  2804 	}
  2799 
  2805 
  2800 void CCmdChunkInfo::PrintChunkInfoL()
  2806 void CCmdChunkInfo::PrintChunkInfoL()
  2801 	{
  2807 	{
  2802 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  2803 	TChunkKernelInfo chunkInfo;
  2808 	TChunkKernelInfo chunkInfo;
  2804 	TPckg<TChunkKernelInfo> chunkInfoPckg(chunkInfo);
  2809 	TPckg<TChunkKernelInfo> chunkInfoPckg(chunkInfo);
  2805 	TInt err = iMemAccess.GetObjectInfo(EChunk, (TUint8*)iAddress, chunkInfoPckg);
  2810 	TInt err = iMemAccess.GetObjectInfo(EChunk, (TUint8*)iAddress, chunkInfoPckg);
  2806 	if (err)
  2811 	if (err)
  2807 		{
  2812 		{
  2868 		if (err)
  2873 		if (err)
  2869 			{
  2874 			{
  2870 			PrintWarning(_L("Unable to read RHeap info: %d"), err);
  2875 			PrintWarning(_L("Unable to read RHeap info: %d"), err);
  2871 			}
  2876 			}
  2872 		}
  2877 		}
  2873 #endif
       
  2874 	}
  2878 	}
  2875 
  2879 
  2876 void CCmdChunkInfo::PrintSizeL(const TDesC& aCaption, TInt aSize)
  2880 void CCmdChunkInfo::PrintSizeL(const TDesC& aCaption, TInt aSize)
  2877 	{
  2881 	{
  2878 	if (iHumanReadable)
  2882 	if (iHumanReadable)
  2912 	Write(iFormatter->Descriptor());
  2916 	Write(iFormatter->Descriptor());
  2913 	}
  2917 	}
  2914 
  2918 
  2915 void CCmdChunkInfo::DoRunL()
  2919 void CCmdChunkInfo::DoRunL()
  2916 	{
  2920 	{
  2917 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  2918 	iFormatter = CTextFormatter::NewL(Stdout());
  2921 	iFormatter = CTextFormatter::NewL(Stdout());
  2919 	iBuf = IoUtils::CTextBuffer::NewL(0x100);
  2922 	iBuf = IoUtils::CTextBuffer::NewL(0x100);
  2920 	LoadMemoryAccessL();
  2923 	LoadMemoryAccessL();
  2921 
  2924 
  2922 	RIoConsoleWriteHandle stdout = Stdout();
  2925 	RIoConsoleWriteHandle stdout = Stdout();
  2939 				stdout.ClearScreen();
  2942 				stdout.ClearScreen();
  2940 				}
  2943 				}
  2941 			DoPrintL();
  2944 			DoPrintL();
  2942 			}
  2945 			}
  2943 		}
  2946 		}
  2944 #else
       
  2945 	PrintError(KErrNotSupported, _L("Unable to fetch chunk information because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
       
  2946 	User::Leave(KErrNotSupported);
       
  2947 #endif
       
  2948 	}
  2947 	}
  2949 
  2948 
  2950 void CCmdChunkInfo::OptionsL(RCommandOptionList& aOptions)
  2949 void CCmdChunkInfo::OptionsL(RCommandOptionList& aOptions)
  2951 	{
  2950 	{
  2952 	_LIT(KCmdChunkInfoOptRate, "rate");
  2951 	_LIT(KCmdChunkInfoOptRate, "rate");
  2967 	{
  2966 	{
  2968 	_LIT(KCmdChunkInfoArg, "chunk_address");
  2967 	_LIT(KCmdChunkInfoArg, "chunk_address");
  2969 	aArguments.AppendUintL(iAddress, KCmdChunkInfoArg);
  2968 	aArguments.AppendUintL(iAddress, KCmdChunkInfoArg);
  2970 	}
  2969 	}
  2971 
  2970 
       
  2971 #endif // FSHELL_CORE_SUPPORT_CHUNKINFO
       
  2972 
       
  2973 
       
  2974 #ifdef FSHELL_CORE_SUPPORT_SVRINFO
  2972 
  2975 
  2973 //
  2976 //
  2974 // CCmdSvrInfo.
  2977 // CCmdSvrInfo.
  2975 //
  2978 //
  2976 
  2979 
  2992 	{
  2995 	{
  2993 	}
  2996 	}
  2994 
  2997 
  2995 void CCmdSvrInfo::ListServersL()
  2998 void CCmdSvrInfo::ListServersL()
  2996 	{
  2999 	{
  2997 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  2998 	TInt bufSize = 1024;
  3000 	TInt bufSize = 1024;
  2999 	TInt err = KErrNone;
  3001 	TInt err = KErrNone;
  3000 	HBufC8* addressesBuf;
  3002 	HBufC8* addressesBuf;
  3001 	do
  3003 	do
  3002 		{
  3004 		{
  3044 				}
  3046 				}
  3045 			}
  3047 			}
  3046 		}
  3048 		}
  3047 
  3049 
  3048 	CleanupStack::PopAndDestroy(addressesBuf);
  3050 	CleanupStack::PopAndDestroy(addressesBuf);
  3049 
       
  3050 #endif
       
  3051 	}
  3051 	}
  3052 
  3052 
  3053 void CCmdSvrInfo::ListSessionsL()
  3053 void CCmdSvrInfo::ListSessionsL()
  3054 	{
  3054 	{
  3055 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  3056 	TPckg<TServerKernelInfo> serverInfoPckg(iServerInfo);
  3055 	TPckg<TServerKernelInfo> serverInfoPckg(iServerInfo);
  3057 	TInt err = iMemAccess.GetObjectInfo(EServer, (TUint8*)iAddress, serverInfoPckg);
  3056 	TInt err = iMemAccess.GetObjectInfo(EServer, (TUint8*)iAddress, serverInfoPckg);
  3058 	if (err)
  3057 	if (err)
  3059 		{
  3058 		{
  3060 		PrintError(err, _L("Unable to get info for server 0x%08x"), iAddress);
  3059 		PrintError(err, _L("Unable to get info for server 0x%08x"), iAddress);
  3108 					PrintWarning(_L("Unable to get info for session owner 0x%08x (%d)"), iSessionInfo.iAddressOfKernelOwner, err);
  3107 					PrintWarning(_L("Unable to get info for session owner 0x%08x (%d)"), iSessionInfo.iAddressOfKernelOwner, err);
  3109 					}
  3108 					}
  3110 				}
  3109 				}
  3111 			}
  3110 			}
  3112 		}
  3111 		}
  3113 #endif
       
  3114 	}
  3112 	}
  3115 
  3113 
  3116 const TDesC& CCmdSvrInfo::Name() const
  3114 const TDesC& CCmdSvrInfo::Name() const
  3117 	{
  3115 	{
  3118 	_LIT(KCmdSvrInfoName, "svrinfo");
  3116 	_LIT(KCmdSvrInfoName, "svrinfo");
  3119 	return KCmdSvrInfoName;
  3117 	return KCmdSvrInfoName;
  3120 	}
  3118 	}
  3121 
  3119 
  3122 void CCmdSvrInfo::DoRunL()
  3120 void CCmdSvrInfo::DoRunL()
  3123 	{
  3121 	{
  3124 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  3125 	iFormatter = CTextFormatter::NewL(Stdout());
  3122 	iFormatter = CTextFormatter::NewL(Stdout());
  3126 	iBuf = IoUtils::CTextBuffer::NewL(0x100);
  3123 	iBuf = IoUtils::CTextBuffer::NewL(0x100);
  3127 	LoadMemoryAccessL();
  3124 	LoadMemoryAccessL();
  3128 
  3125 
  3129 	if (iAddress == 0)
  3126 	if (iAddress == 0)
  3135 		ListSessionsL();
  3132 		ListSessionsL();
  3136 		}
  3133 		}
  3137 
  3134 
  3138 	iFormatter->TabulateL(0, 2, iBuf->Descriptor(), ETruncateLongestColumn);
  3135 	iFormatter->TabulateL(0, 2, iBuf->Descriptor(), ETruncateLongestColumn);
  3139 	Write(iFormatter->Descriptor());
  3136 	Write(iFormatter->Descriptor());
  3140 #else
       
  3141 	PrintError(KErrNotSupported, _L("Unable to fetch server information because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
       
  3142 	User::Leave(KErrNotSupported);
       
  3143 #endif
       
  3144 	}
  3137 	}
  3145 
  3138 
  3146 void CCmdSvrInfo::ArgumentsL(RCommandArgumentList& aArguments)
  3139 void CCmdSvrInfo::ArgumentsL(RCommandArgumentList& aArguments)
  3147 	{
  3140 	{
  3148 	_LIT(KCmdSvrInfoArg, "server_address");
  3141 	_LIT(KCmdSvrInfoArg, "server_address");
  3149 	aArguments.AppendUintL(iAddress, KCmdSvrInfoArg);
  3142 	aArguments.AppendUintL(iAddress, KCmdSvrInfoArg);
  3150 	}
  3143 	}
  3151 
  3144 
       
  3145 #endif // FSHELL_CORE_SUPPORT_SVRINFO
  3152 
  3146 
  3153 //
  3147 //
  3154 // CCmdTickle.
  3148 // CCmdTickle.
  3155 //
  3149 //
  3156 	
  3150 	
  4144 
  4138 
  4145 //
  4139 //
  4146 // CCmdReadMem.
  4140 // CCmdReadMem.
  4147 //
  4141 //
  4148 
  4142 
       
  4143 #ifdef FSHELL_CORE_SUPPORT_READMEM
       
  4144 
  4149 CCommandBase* CCmdReadMem::NewLC()
  4145 CCommandBase* CCmdReadMem::NewLC()
  4150 	{
  4146 	{
  4151 	CCmdReadMem* self = new(ELeave) CCmdReadMem();
  4147 	CCmdReadMem* self = new(ELeave) CCmdReadMem();
  4152 	CleanupStack::PushL(self);
  4148 	CleanupStack::PushL(self);
  4153 	self->BaseConstructL();
  4149 	self->BaseConstructL();
  4168 	return KName;
  4164 	return KName;
  4169 	}
  4165 	}
  4170 
  4166 
  4171 void CCmdReadMem::DoRunL()
  4167 void CCmdReadMem::DoRunL()
  4172 	{
  4168 	{
  4173 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  4174 	LoadMemoryAccessL();
  4169 	LoadMemoryAccessL();
  4175 
  4170 
  4176 	if (iFileName.Length() > 0)
  4171 	if (iFileName.Length() > 0)
  4177 		{
  4172 		{
  4178 		LeaveIfErr(iFile.Create(FsL(), iFileName, EFileWrite), _L("Unable to create \"%S\""), &iFileName);
  4173 		LeaveIfErr(iFile.Create(FsL(), iFileName, EFileWrite), _L("Unable to create \"%S\""), &iFileName);
  4208 			{
  4203 			{
  4209 			Dump(buf, *this, dumpPos);
  4204 			Dump(buf, *this, dumpPos);
  4210 			}
  4205 			}
  4211 		bytesRead += bytesToRead;
  4206 		bytesRead += bytesToRead;
  4212 		}
  4207 		}
  4213 
       
  4214 #else
       
  4215 	PrintError(KErrNotSupported, _L("Unable to read memory because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
       
  4216 	User::Leave(KErrNotSupported);
       
  4217 #endif
       
  4218 	}
  4208 	}
  4219 
  4209 
  4220 void CCmdReadMem::OptionsL(RCommandOptionList& aOptions)
  4210 void CCmdReadMem::OptionsL(RCommandOptionList& aOptions)
  4221 	{
  4211 	{
  4222 	_LIT(KCmdOptThreadId, "thread_id");
  4212 	_LIT(KCmdOptThreadId, "thread_id");
  4231 
  4221 
  4232 	aArguments.AppendUintL(iAddress, KCmdArgAddress);
  4222 	aArguments.AppendUintL(iAddress, KCmdArgAddress);
  4233 	aArguments.AppendUintL(iSize, KCmdArgSize);
  4223 	aArguments.AppendUintL(iSize, KCmdArgSize);
  4234 	aArguments.AppendFileNameL(iFileName, KCmdArgFileName);
  4224 	aArguments.AppendFileNameL(iFileName, KCmdArgFileName);
  4235 	}
  4225 	}
       
  4226 
       
  4227 #endif // FSHELL_CORE_SUPPORT_READMEM
  4236 
  4228 
  4237 
  4229 
  4238 //
  4230 //
  4239 // CCmdE32Header.
  4231 // CCmdE32Header.
  4240 //
  4232 //
  4408 
  4400 
  4409 //
  4401 //
  4410 // CCmdObjInfo.
  4402 // CCmdObjInfo.
  4411 //
  4403 //
  4412 
  4404 
       
  4405 #ifdef FSHELL_CORE_SUPPORT_OBJINFO
       
  4406 
  4413 CCommandBase* CCmdObjInfo::NewLC()
  4407 CCommandBase* CCmdObjInfo::NewLC()
  4414 	{
  4408 	{
  4415 	CCmdObjInfo* self = new(ELeave) CCmdObjInfo();
  4409 	CCmdObjInfo* self = new(ELeave) CCmdObjInfo();
  4416 	CleanupStack::PushL(self);
  4410 	CleanupStack::PushL(self);
  4417 	self->BaseConstructL();
  4411 	self->BaseConstructL();
  4429 const TDesC& CCmdObjInfo::Name() const
  4423 const TDesC& CCmdObjInfo::Name() const
  4430 	{
  4424 	{
  4431 	_LIT(KName, "objinfo");
  4425 	_LIT(KName, "objinfo");
  4432 	return KName;
  4426 	return KName;
  4433 	}
  4427 	}
  4434 
       
  4435 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  4436 
  4428 
  4437 #define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
  4429 #define CASE_RETURN_LIT(XXX) case XXX: { _LIT(_KLit, #XXX); return &_KLit; }
  4438 #define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
  4430 #define DEFAULT_RETURN_LIT(XXX) default: { _LIT(_KLit, XXX); return &_KLit; }
  4439 
  4431 
  4440 EXPORT_C const TDesC* StringifyObjectType(TObjectType aObjectType)
  4432 EXPORT_C const TDesC* StringifyObjectType(TObjectType aObjectType)
  4591 		}
  4583 		}
  4592 
  4584 
  4593 	CleanupStack::PopAndDestroy(addressesBuf);
  4585 	CleanupStack::PopAndDestroy(addressesBuf);
  4594 	}
  4586 	}
  4595 
  4587 
  4596 #endif // FSHELL_MEMORY_ACCESS_SUPPORT
       
  4597 
       
  4598 void CCmdObjInfo::DoRunL()
  4588 void CCmdObjInfo::DoRunL()
  4599 	{
  4589 	{
  4600 #ifdef FSHELL_MEMORY_ACCESS_SUPPORT
       
  4601 	LoadMemoryAccessL();
  4590 	LoadMemoryAccessL();
  4602 
  4591 
  4603 	if (iObjectAddress)
  4592 	if (iObjectAddress)
  4604 		{
  4593 		{
  4605 		PrintObjectDetailsL(iObjectAddress);
  4594 		PrintObjectDetailsL(iObjectAddress);
  4638 		}
  4627 		}
  4639 	else if (iThreadId)
  4628 	else if (iThreadId)
  4640 		{
  4629 		{
  4641 		PrintReferencedObjectDetailsL(EOwnerThread, iThreadId);
  4630 		PrintReferencedObjectDetailsL(EOwnerThread, iThreadId);
  4642 		}
  4631 		}
  4643 
       
  4644 #else
       
  4645 	PrintError(KErrNotSupported, _L("Unable to fetch object information because fshell was not built with FSHELL_MEMORY_ACCESS_SUPPORT defined. That probably means this plaform doesn't support the MemoryAccess device driver."));
       
  4646 	User::Leave(KErrNotSupported);
       
  4647 #endif
       
  4648 	}
  4632 	}
  4649 
  4633 
  4650 void CCmdObjInfo::OptionsL(RCommandOptionList& aOptions)
  4634 void CCmdObjInfo::OptionsL(RCommandOptionList& aOptions)
  4651 	{
  4635 	{
  4652 	_LIT(KCmdOptReferencers, "referencers");
  4636 	_LIT(KCmdOptReferencers, "referencers");
  4663 void CCmdObjInfo::ArgumentsL(RCommandArgumentList& aArguments)
  4647 void CCmdObjInfo::ArgumentsL(RCommandArgumentList& aArguments)
  4664 	{
  4648 	{
  4665 	_LIT(KCmdArgObjectAddress, "object_address");
  4649 	_LIT(KCmdArgObjectAddress, "object_address");
  4666 	aArguments.AppendUintL(iObjectAddress, KCmdArgObjectAddress);
  4650 	aArguments.AppendUintL(iObjectAddress, KCmdArgObjectAddress);
  4667 	}
  4651 	}
       
  4652 
       
  4653 #endif // FSHELL_CORE_SUPPORT_OBJINFO
  4668 
  4654 
  4669 //
  4655 //
  4670 // CCmdTouch.
  4656 // CCmdTouch.
  4671 //
  4657 //
  4672 
  4658