2013-01-09 49 views
6

的Windows Phone 7模擬器有一個不錯的控制檯窗口功能,可以通過註冊表設置(EnableConsole)或通過XDE.exe控制檯窗口功能在Windows Phone 8模擬器

的decfg參數它的工作,即使沒有安裝調試器中啓用。這有助於查找運行時綁定問題,異常情況。

有沒有辦法在Windos 8手機模擬器中啓用控制檯窗口?

回答

1

我一直在尋找一個控制檯或任何其他方式來追蹤WP8仿真器上的應用程序執行,而無需連接調試器一段時間。看起來,由於它在hyper-v VM上運行,控制檯不再可用。

但是我找到了一些解決方法。您可以創建簡單的類,將您的消息記錄到應用程序的隔離存儲器(更多關於隔離存儲器here)。運行應用程序後,您可以使用Windows Phone Power Tools檢查獨立存儲的內容(幸運的是,它具有「刷新」選項,因此您可以在模擬器上執行一些操作,然後修改隔離存儲)。

12

WP8仿真器是對WP7仿真器的完全重寫,所以它不太可能支持相同的未公開的調試消息。在一天結束時,問題是:你想要登錄什麼?

  • 您是否試圖獲得特定於您的應用的信息?然後使用Pavel的想法通過WP8的CoreCon API共享IsoStore文件。
  • 您是否試圖在模擬器本身中獲取關於有趣事件的消息?模擬器登錄到ETW提供程序,並可以從該日誌中讀取。我會在這裏展示如何。
  • 您是否想要從WP8 OS獲取信息?然後生成ETL文件並對其進行檢查或直接使用分析API。

記錄應用程序特定的消息

比方說一些有趣的事情發生在你的應用程序一樣的重要按鈕的點擊。您需要將其記錄在您的應用程序中,並將該消息寫入IsoStore(或發送到自定義Web服務)。我使用MetroLog作爲我的WP8 & Win8日誌記錄,但只要文件寫入IsoStore,您就可以使用任何您想要的內容。檢出MetroLog @https://github.com/mbrit/MetroLog

然後,您可以使用CoreCon API來讀取文件。我上傳這些API OFR WP8的代碼示例@https://stackoverflow.com/a/13429709/81687


記錄模擬器的具體信息

你說你很希望看到,當仿真器被激活,當變焦設置,如果屏幕截圖失敗或觸摸事件發生。 WP8仿真器使用ETW提供商ff86852d-541c-4f7e-98c5-5761e8cb7074來記錄那些其他事件。您可以在這裏閱讀更多有關ETW的信息@http://msdn.microsoft.com/en-us/magazine/cc163437.aspx

首先,下載PerfView以啓動XDE.exe仿真器並開始捕獲ETW輸出。

PerfView start with all the aforementioned options

  • 工作目錄設置到XDE.exe爲WP8的位置。
  • 確保先從VS2012運行該仿真器以創建Hyper-V映像。或者,如果您知道如何自己拍攝影像並使用/ VHD參數。
  • 調用XDE.exe時,您可以從Hyper-V管理器獲取/ NAME參數。
  • 請務必設置額外的提供程序以包含「ff86852d-541c-4f7e-98c5-5761e8cb7074」。

現在從PerfView運行模擬器,做一些東西,關閉模擬器並停止收集信息。一旦你這樣做了,你可以看到模擬器中所有內容的日誌。一旦你在供應商ID下過濾它,有趣的東西就在「事件」日誌下。

PerfView events data

在上述打印畫面上可以看到的事件,當他們在模擬器中發生的事情。例如,事件76是模擬器的MicrophoneCaptureThreadStarted,它在分析會話中發生了27秒。有關事件代碼的完整列表,請參閱XDE.exe程序集中的Microsoft.Xde.Etw.WindowsPhoneEmulatorProvider c'tor。這是複製粘貼在這裏爲你說服:從Hyper-V

public WindowsPhoneEmulatorProvider() 
{ 
    this.m_provider = new EventProviderVersionTwo(new Guid("ff86852d-541c-4f7e-98c5-5761e8cb7074")); 
    this.XdeStarted = new EventDescriptor(0, 0, 9, 4, 0, 0, -9223372036854775808L); 
    this.XdeStopped = new EventDescriptor(1, 0, 0, 4, 0, 0, 0L); 
    this.DesktopResolutionChanged = new EventDescriptor(2, 0, 0, 4, 0, 0, 0L); 
    this.InvalidLanguageSpecified = new EventDescriptor(3, 0, 0, 2, 0, 0, 0L); 
    this.CantFindVhd = new EventDescriptor(5, 0, 0, 2, 0, 0, 0L); 
    this.DiffDiskVhdRequiresVhdPath = new EventDescriptor(6, 0, 0, 2, 0, 0, 0L); 
    this.InvalidVideoParam = new EventDescriptor(7, 0, 0, 2, 0, 0, 0L); 
    this.InvalidMemorySize = new EventDescriptor(8, 0, 0, 2, 0, 0, 0L); 
    this.CantFindVM = new EventDescriptor(9, 0, 0, 2, 0, 0, 0L); 
    this.UnableToSendKeyToVM = new EventDescriptor(10, 0, 0, 2, 0, 0, 0L); 
    this.FailedToCreateDiffVhd = new EventDescriptor(11, 0, 0, 2, 0, 0, 0L); 
    this.FailedToCreateVM = new EventDescriptor(12, 0, 0, 2, 0, 0, 0L); 
    this.FailedVMStop = new EventDescriptor(13, 0, 0, 2, 0, 0, 0L); 
    this.FailedStartVM = new EventDescriptor(14, 0, 0, 2, 0, 0, 0L); 
    this.UnableToConnectToGuest = new EventDescriptor(15, 0, 0, 2, 0, 0, 0L); 
    this.ConnectedToGuest = new EventDescriptor(0x10, 0, 0, 4, 0, 0, 0L); 
    this.GuestIndicatedResolution = new EventDescriptor(0x11, 0, 0, 4, 0, 0, 0L); 
    this.LoadedSkin = new EventDescriptor(0x12, 0, 0, 4, 0, 0, 0L); 
    this.ButtonPressed = new EventDescriptor(0x13, 0, 0, 4, 0, 0, 0L); 
    this.VirtualMachineStateChanged = new EventDescriptor(20, 0, 0, 4, 0, 0, 0L); 
    this.ProxyInitialized = new EventDescriptor(4, 0, 0, 4, 0, 0, 0L); 
    this.UsageShown = new EventDescriptor(0x16, 0, 0, 4, 0, 0, 0L); 
    this.DisplayOrientationSet = new EventDescriptor(0x17, 0, 0, 4, 0, 0, 0L); 
    this.ZoomSet = new EventDescriptor(0x18, 0, 0, 4, 0, 0, 0L); 
    this.ScreenshotSavedToFile = new EventDescriptor(0x19, 0, 0, 4, 0, 0, 0L); 
    this.KeySentToVM = new EventDescriptor(0x1a, 0, 0, 4, 0, 0, 0L); 
    this.MouseEventSentToVM = new EventDescriptor(0x1b, 0, 0, 4, 0, 0, 0L); 
    this.UnableToSendMouseEventToVM = new EventDescriptor(0x1c, 0, 0, 0, 0, 0, 0L); 
    this.BringToFrontExecuted = new EventDescriptor(0x1d, 0, 0, 4, 0, 0, 0L); 
    this.ConnectedToAccelerometer = new EventDescriptor(30, 0, 0, 4, 0, 0, 0L); 
    this.UnableToConnectToAccelermometer = new EventDescriptor(0x1f, 0, 0, 0, 0, 0, 0L); 
    this.InvalidWindowsDetected = new EventDescriptor(0x20, 0, 0, 2, 0, 0, 0L); 
    this.HyperVNotEnabled = new EventDescriptor(0x21, 0, 0, 2, 0, 0, 0L); 
    this.AskedToConnectExternalSwitches = new EventDescriptor(0x22, 0, 0, 4, 0, 0, 0L); 
    this.ConnectedToGuestNotifications = new EventDescriptor(0x23, 0, 0, 4, 0, 0, 0L); 
    this.UnableToConnectToGuestNotifications = new EventDescriptor(0x24, 0, 0, 2, 0, 0, 0L); 
    this.FailedToSetVmProperties = new EventDescriptor(0x25, 0, 0, 2, 0, 0, 0L); 
    this.FailedToInitializeSnapshots = new EventDescriptor(0x26, 0, 0, 2, 0, 0, 0L); 
    this.FailedToSetVhd = new EventDescriptor(0x27, 0, 0, 2, 0, 0, 0L); 
    this.RdpServerDisconnected = new EventDescriptor(40, 0, 0, 4, 0, 0, 0L); 
    this.ScreenshotFailed = new EventDescriptor(0x29, 0, 0, 2, 0, 0, 0L); 
    this.AccelerometerSendFailed = new EventDescriptor(0x2a, 0, 0, 2, 0, 0, 0L); 
    this.LocationSendFailed = new EventDescriptor(0x2b, 0, 0, 2, 0, 0, 0L); 
    this.SnapshotStarted = new EventDescriptor(0x2c, 0, 0, 0, 0, 0, 0L); 
    this.SnapshotSucceeded = new EventDescriptor(0x2d, 0, 0, 0, 0, 0, 0L); 
    this.SnapshotFailed = new EventDescriptor(0x2e, 0, 0, 2, 0, 0, 0L); 
    this.CloseAfterSilentSnapshot = new EventDescriptor(0x2f, 0, 0, 0, 0, 0, 0L); 
    this.ApplySnapshotFailed = new EventDescriptor(0x30, 0, 0, 2, 0, 0, 0L); 
    this.RemovingSnapshotAfterFailedConnect = new EventDescriptor(50, 0, 0, 0, 0, 0, 0L); 
    this.RemovingSnapshotAfterSettingsDidntMatch = new EventDescriptor(0x33, 0, 0, 0, 0, 0, 0L); 
    this.ConnectedToShellReadyPipe = new EventDescriptor(0x34, 0, 0, 4, 0, 0, 0L); 
    this.UnableToConnectToShellReadyPipe = new EventDescriptor(0x35, 0, 0, 2, 0, 0, 0L); 
    this.ConnectedToTouch = new EventDescriptor(0x36, 0, 0, 4, 0, 0, 0L); 
    this.UnableToConnectToTouch = new EventDescriptor(0x37, 0, 0, 2, 0, 0, 0L); 
    this.TouchSendFailed = new EventDescriptor(0x38, 0, 0, 2, 0, 0, 0L); 
    this.SendTextFailed = new EventDescriptor(0x39, 0, 0, 2, 0, 0, 0L); 
    this.ReceiveAudioFromGuestWithSpinFailed = new EventDescriptor(0x3a, 0, 0, 2, 0, 0, 0L); 
    this.SendMicrophoneDataToGuestFailed = new EventDescriptor(0x3b, 0, 0, 2, 0, 0, 0L); 
    this.LoadUserSettingsFailed = new EventDescriptor(60, 0, 0, 0, 0, 0, 0L); 
    this.SetGuestSystemTimeAndZoneFailed = new EventDescriptor(0x3d, 0, 0, 2, 0, 0, 0L); 
    this.HypervisorNotRunning = new EventDescriptor(0x3e, 0, 0, 2, 0, 0, 0L); 
    this.HyperVManagementServiceNotRunning = new EventDescriptor(0x3f, 0, 0, 2, 0, 0, 0L); 
    this.UserAlreadyInHyperVAdmin = new EventDescriptor(0x40, 0, 0, 4, 0, 0, 0L); 
    this.UserAddedToHyperVAdmins = new EventDescriptor(0x41, 0, 0, 4, 0, 0, 0L); 
    this.FailedToAddUserToHyperVAdmins = new EventDescriptor(0x42, 0, 0, 0, 0, 0, 0L); 
    this.SendKeyboardEvent = new EventDescriptor(0x43, 0, 0, 4, 0, 0, 0L); 
    this.SendKeyboardEventFailed = new EventDescriptor(0x44, 0, 0, 2, 0, 0, 0L); 
    this.AudioPlayThreadStarted = new EventDescriptor(0x45, 0, 0, 0, 0, 0, 0L); 
    this.AudioPlayThreadExited = new EventDescriptor(70, 0, 0, 0, 0, 0, 0L); 
    this.AudioDataReceivedFromGuest = new EventDescriptor(0x47, 0, 0, 0, 0, 0, 0L); 
    this.AudioGlitch = new EventDescriptor(0x48, 0, 0, 0, 0, 0, 0L); 
    this.AudioPaused = new EventDescriptor(0x49, 0, 0, 0, 0, 0, 0L); 
    this.AudioResumed = new EventDescriptor(0x4a, 0, 0, 0, 0, 0, 0L); 
    this.AudioDeviceChange = new EventDescriptor(0x4b, 0, 0, 0, 0, 0, 0L); 
    this.MicrophoneCaptureThreadStarted = new EventDescriptor(0x4c, 0, 0, 0, 0, 0, 0L); 
    this.MicrophoneCaptureThreadExited = new EventDescriptor(0x4d, 0, 0, 0, 0, 0, 0L); 
    this.MicrophoneDataSentToGuest = new EventDescriptor(0x4e, 0, 0, 0, 0, 0, 0L); 
    this.MicrophoneDeviceChange = new EventDescriptor(0x4f, 0, 0, 0, 0, 0, 0L); 
    this.GetNetworkInfoFailed = new EventDescriptor(90, 0, 0, 2, 0, 0, 0L); 
    this.IPRenewalInitiated = new EventDescriptor(0x5b, 0, 0, 4, 0, 0, 0L); 
} 

記錄事件託管OS

比方說,你想知道更多關於如何WP8即時編譯器組件或當它的垃圾採集。 VS2012附帶分析工具,用於分析,存儲和顯示該信息。例如,這裏是如何開始一個分析會話:

Starting a WP8 analysis session

一旦分析會話做,你可以看到你的應用程序下的「Perflogs中」文件夾有分析會話的數據。如果您已經對CPU /執行進行了剖析,那麼您可以在該文件夾中看到VSPX文件。將VSPX文件重命名爲ZIP並提取它包含的文件。在該ZIP中,您會找到一個ETL文件。該ETL文件是另一個ETW日誌,我們可以檢查PerfView。

ETL and VSPX files

當我們在PerfView打開這樣的文件ETL我們可以看到當每個類是即時編譯,花了多長時間和IL &本土的大小。例如我們的應用程序的App類在123.461ms即時編譯,爲1.2ms的與105的IL大小和天然大小的289

PerfView Jitting data

你也可以直接使用的評測API而不是使用VS2012捕獲這些數據。如果這是你想做的事情,你將不得不對VS2012的SilverlightProfiler。*。dll程序集進行反向工程,以便查看他們正在做什麼並在VS2012之外重新創建它。

+0

謝謝。將嘗試並讓你知道 – Lokeshwer

+0

偉大的工作... :) – StezPet