From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com [40.92.69.74]) by mx.groups.io with SMTP id smtpd.web09.98.1572975384959914355 for ; Tue, 05 Nov 2019 09:36:25 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=mbqyhiO8; spf=pass (domain: outlook.com, ip: 40.92.69.74, mailfrom: kilian_kegel@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T2eMHVZDLFNi+ppSNMkClUvNpWGG28NykTwv0CmjE/H6CNdRztlJPYwOtc7Gf1KckD6dlH1VJQ8cWxA9LISqdg9Aggk7myfDAV+pDo8EgYdqxbX3Z+VPm90Rm4eQWbcJ/phvIZmjuK/ap+1JCdsun32xyaadl3WG5cepqbq3ml8usBbm1BdP9gS2WObLw9lyE2X31ksBok1lbAPHn04o0UDgomkKDlEgy18DG4Ro+TFfVP6lPb64swJ1E0sOPpljR3mtRewAK/LyC5RYARkxJqpVgK7noSDK6kUfDYMqyq59AxnxITdbRw9ujZKsH3aEpF19JvdJFPZ/HcOPXrGhug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mKu8Y6P4wjgtOnL1YFCJmTpafpiwJf2Vz844ZzLxMHc=; b=kIx7qWcqd7h635AG73AWYQlDbCrSO5gmq3sK64Z5kEm6E62PEhbACPYp9yYiKSch7Yg6Sz/+q5kbz9KU6g42xJzjn7jWLalNOmmNxHBo6Mi7nVI3EcOsqU0uO8XgQ9Dkh0XcQSVJC6QTOiH2H425lg3rbjhpXJmDGIwKO+gZgUlSuf/HgX6m9GoOpwc5x9+evoYbZ4wpmYPyURkR3nLBWukf7m210SpmHNcXxxQ0VffheiQ7T4nExVpoCCQoI1I06DNduA79gisIwPnAHCn/Nz6xpJG8lDYvRFfhGqyX3LNWgKDxvPR2IwawDMNjWz1M3/4otPI1YpgSSZPS+/RSmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mKu8Y6P4wjgtOnL1YFCJmTpafpiwJf2Vz844ZzLxMHc=; b=mbqyhiO8n9mRRbk6YfFTU3YTUa1PO6Ih0pZTFqUSlF5y5ERmB3C6wHMZBKLx5JUC6/cl1AIp7xrVNG9q+eymowHQEz7o8m+MujILiuFCymYlL6moEYyc5X0/YudVyCH+A/RTNdSKR7GecbhLS0i+GfTbCsl4vHcvIyMQNCvWjaTAa2tGI8Pzc91Z6Pi6SPW8iqTU9iWYZYZIEfUgHiLCluugjFK3RQcZU+MrOClJycIjGMEbMT1bAGkvW5Vs1Kb9aWnpKgiHv9ayGkGGhZkQ+SohKDlKVDHfDRptXfrtxkHUijLpDWVQpQP+cF+Y2h3aSUPGr8bDOG3SNcQWbT1ISw== Received: from HE1EUR02FT012.eop-EUR02.prod.protection.outlook.com (10.152.10.59) by HE1EUR02HT053.eop-EUR02.prod.protection.outlook.com (10.152.11.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20; Tue, 5 Nov 2019 17:36:21 +0000 Received: from VI1PR0502MB3968.eurprd05.prod.outlook.com (10.152.10.58) by HE1EUR02FT012.mail.protection.outlook.com (10.152.10.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2387.20 via Frontend Transport; Tue, 5 Nov 2019 17:36:21 +0000 Received: from VI1PR0502MB3968.eurprd05.prod.outlook.com ([fe80::8972:3cf:bc11:b844]) by VI1PR0502MB3968.eurprd05.prod.outlook.com ([fe80::8972:3cf:bc11:b844%3]) with mapi id 15.20.2408.024; Tue, 5 Nov 2019 17:36:21 +0000 From: "Kilian Kegel" To: "liming.gao@intel.com" CC: "devel@edk2.groups.io" , "Richardson, Brian" , "Kinney, Michael D" Subject: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Thread-Topic: [edk2-devel] [[PATCH 1/1]] EmulatorPkg using CpuBreakPoint Thread-Index: AQHVk/+J8z3CQarrTkqSuX+dN7iWMQ== Date: Tue, 5 Nov 2019 17:36:21 +0000 Message-ID: References: <2d5ec4d308504c87b7b1390c1e2f1495@zhaoxin.com>,<4A89E2EF3DFEDB4C8BFDE51014F606A14E5325C1@SHSMSX104.ccr.corp.intel.com>, In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:E13B12B7BB020397904ADC7BAC75A6083A5012020E15154EA0775A57D25CD421;UpperCasedChecksum:FBA5315A911C548720F5482E7FEC5109A5BCC8836A03644A8BF22878B09617E2;SizeAsReceived:7152;Count:44 x-tmn: [JmNBjJitddfiLbV/2wqyy8Ebwx9tzTZz] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: d1c34179-0567-4ea1-8469-08d76216ac80 x-ms-traffictypediagnostic: HE1EUR02HT053: x-ms-exchange-purlcount: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: bmT7wNxa0IJ0OGvQTQVLI+WDnVA1PzwuDE7+5CsM4xyPUChLjerig0itXEgT4YxsRBaK+LX8FjUw9yxTeKZGFcKVMm4n9Qq3UHIFeKt0zBVDJSB8HFCQudpbfTrSqzCrDrLbfin/BVwTU/RXfvjpWsfioYdrBs+/Cv0P3OSEsZKAl0tB5r5vg/4ODqP1bc2rma49UD9oghwajzEpAWKhdHE4TPYLps5s9Jk50BQYusI= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: d1c34179-0567-4ea1-8469-08d76216ac80 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Nov 2019 17:36:21.8021 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR02HT053 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_VI1PR0502MB3968E000F5D41982DE3A4F66EB7E0VI1PR0502MB3968_" --_000_VI1PR0502MB3968E000F5D41982DE3A4F66EB7E0VI1PR0502MB3968_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi Liming, >Kilian: can you send the patch to edk2 mail list for code review? Regards, Kilian https://bugzilla.tianocore.org/show_bug.cgi?id=3D2319 diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.= c index 62a89f7617..53cda86f9a 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -409,7 +409,30 @@ Returns: FirmwareVolumesStr =3D (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume); SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tia= nocore.org/edk2/\n\r"); - + + if (1) { + int i; + SecPrint ("###########################################################= ###########################################\n"); + SecPrint ("add \"/debug\" command line switch, to connect to the debug= ger at the very beginning of POST emulation\n"); + SecPrint ("###########################################################= ###########################################\n"); + if (Argc > 1) { + for (i =3D 1; i < Argc; i++) { + if (0 =3D=3D strcmp("/debug", Argv[i])) { + //SecPrint("IF YOU WANT TO DEBUG from the very beginning of the = EMULATION:\n\t1. start the TASKMGR\n\t2. connect WinHost.exe to the debugge= r\n\t3. and press ENTER in this command box\nOR\n"); + SecPrint("\t1. start your debug engine\n"); + SecPrint("\t2. attache to process WinHost.exe\n"); + SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in line 431\n"); + SecPrint("\t5. and press ENTER in the WinHost command box\n"); + SecPrint("\t6. go back to the debug engine and RUN/SINGLE STEP t= he application\n"); + SecPrint("\t7. otherwise press enter to continue...\n"); + + getchar(); //wait for keyboard input + + SecPrint("");//now you can single step the entire boot/emulation= process, good luck... + } + } + } + } // // Determine the first thread available to this process. // ________________________________ From: Kilian Kegel Sent: Monday, October 28, 2019 2:01:23 PM To: liming.gao@intel.com Cc: devel@edk2.groups.io ; Richardson, Brian ; Kinney, Michael D Subject: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak() Hi Liming, If have observed in newer Windows 10 versions, when using __debugbreak()in = any application that Windows just terminates the app, instead offering to debug= it. So in WinHost.exe too. That=92s why I usually insert the code snippet below to run into getchar() when the program was started with the /debug command line switch. As long as the App waits for the next keystroke, I can start the debugger (= VS2019) and connect to WinHost.exe process for debugging. Do you have a better solution without modifying the source code? Thanks, Kilian if(1){ int i; SecPrint ("########################################################= ##############################################\n"); SecPrint ("add \"/debug\" command line switch, to connect to the de= bugger at the very beginning of POST emulation\n"); SecPrint ("########################################################= ##############################################\n"); if(Argc > 1){ for(i =3D 1 ; i < Argc ; i++){ if(0 =3D=3D strcmp("/debug", Argv[i])){ //SecPrint("IF YOU WANT TO DEBUG from the very begi= nning of the EMULATION:\n\t1. start the TASKMGR\n\t2. connect WinHost.exe t= o the debugger\n\t3. and press ENTER in this command box\nOR\n"); SecPrint("\t1. start Visual Studio\n"); SecPrint("\t2. DEBUG->ATTACH TO PROCESS (CTRL + ALT= + P) --> WinHost.exe\n"); SecPrint("\t3. Break All (CTRL + ALT + Break) --> = WinHost.exe\n"); SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in li= ne 445\n"); SecPrint("\t5. and press ENTER in this command box\= n"); SecPrint("\t6. go back to Visual Studio an RUN/SING= LE STEP the application\n"); SecPrint("\t7. otherwise press enter to continue...= \n"); getchar(); // // 1. SET A SOFTWARE BREAKPOINT TO THE NEXT LINE of= code below -->> SecPrint(""); // 2. switch to the command box and press ENTER // 3. start single stepping the entire boot/emulati= on process, good luck... // SecPrint("");//now you can single step the entire b= oot/emulation process, good luck... } } } } --_000_VI1PR0502MB3968E000F5D41982DE3A4F66EB7E0VI1PR0502MB3968_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

Hi Liming,

>Kilian: can you send the patch to edk2 mail list= for code review?

Regards,

Kilian

 

https://bugzilla.tianocore.org/show_bug.cgi?id=3D2319

 

diff --git a/EmulatorPkg/Win/Host/WinHost.c b/Emulat= orPkg/Win/Host/WinHost.c

index 62a89f7617..53cda86f9a 100644

--- a/EmulatorPkg/Win/Host/WinHost.c

+++ b/EmulatorPkg/Win/Host/WinHost.c

@@ -409,7 +409,30 @@ Returns:

   FirmwareVolumesStr =3D (CHAR16 *) PcdGe= tPtr (PcdEmuFirmwareVolume);

   SecPrint ("\n\rEDK II WIN Host Emu= lation Environment from http://www.tianocore.org/edk2/\n\r");

-

+  if (1) {

+    int i;

+    SecPrint ("############= ###########################################################################= ###############\n");

+    SecPrint ("add \"/= debug\" command line switch, to connect to the debugger at the very be= ginning of POST emulation\n");

+    SecPrint ("############= ###########################################################################= ###############\n");

+    if (Argc > 1) {

+      for (i =3D 1; i = < Argc; i++) {

+        if (= 0 =3D=3D strcmp("/debug", Argv[i])) {

+        = ;  //SecPrint("IF YOU WANT TO DEBUG from the very beginning of th= e EMULATION:\n\t1. start the TASKMGR\n\t2. connect WinHost.exe to the debug= ger\n\t3. and press ENTER in this command box\nOR\n");

+        = ;  SecPrint("\t1. start your debug engine\n");

+        = ;  SecPrint("\t2. attache to process WinHost.exe\n");

+        = ;  SecPrint("\t4. SET A SOFTWARE BREAKPOINT (F9) in line 431\n&qu= ot;);

+        = ;  SecPrint("\t5. and press ENTER in the WinHost command box\n&qu= ot;);

+        = ;  SecPrint("\t6. go back to the debug engine and RUN/SINGLE STEP= the application\n");

+        = ;  SecPrint("\t7. otherwise press enter to continue...\n");<= /p>

+

+        = ;  getchar();    //wait for keyboard input

+

+        = ;  SecPrint("");//now you can single step the entire boot/em= ulation process, good luck...

+        }

+      }

+    }

+  }

   //

   // Determine the first thread available= to this process.

   //




From: Kilian Kegel <kili= an_kegel@outlook.com>
Sent: Monday, October 28, 2019 2:01:23 PM
To: liming.gao@intel.com <liming.gao@intel.com>
Cc: devel@edk2.groups.io <devel@edk2.groups.io>; Richardson, B= rian <brian.richardson@intel.com>; Kinney, Michael D <michael.d.ki= nney@intel.com>
Subject: [edk2-devel] [edk2] [EmulatorPkg] using __debugbreak()
 

Hi Liming,

 

If have observed in newer Windows 10 versions, whe= n using __debugbreak()<= /b>in any

application that Windows just terminates the app, = instead offering to debug it.

So in WinHost.exe too.

 

That=92s why I usually insert the code snippet bel= ow to run into getchar()

when the program was started with the /debug comma= nd line switch.

As long as the App waits for the next keystroke, I= can start the debugger (VS2019)

and connect to WinHost.exe process for debugging.<= /p>

 

Do you have a better solution without modifying th= e source code?

 

Thanks,

Kilian

    if(1){

        int i;

 

        SecPrint ("##########= ###########################################################################= #################\n");

        SecPrint ("add \"= ;/debug\" command line switch, to connect to the debugger at the very = beginning of POST emulation\n");

        SecPrint ("##########= ###########################################################################= #################\n");

 

        if(Argc > 1){

            fo= r(i =3D 1 ; i < Argc ; i++){

           &nb= sp;    if(0 =3D=3D strcmp("/debug", Argv[i])){

           &nb= sp;            //Sec= Print("IF YOU WANT TO DEBUG from the very beginning of the EMULATION:\= n\t1. start the TASKMGR\n\t2. connect WinHost.exe to the debugger\n\t3. and= press ENTER in this command box\nOR\n");

           &nb= sp;            SecPr= int("\t1. start Visual Studio\n");

           &nb= sp;            SecPr= int("\t2. DEBUG->ATTACH TO PROCESS (CTRL + ALT + P) --> = WinHost.exe\n");

           &nb= sp;            SecPr= int("\t3. Break All  (CTRL + ALT + Break) --> WinHost.= exe\n");

           &nb= sp;            SecPrint(&= quot;\t4. SET A SOFTWARE BREAKPOINT (F9) in line 445\n");

           &nb= sp;            SecPr= int("\t5. and press ENTER in this command box\n");

           &nb= sp;            SecPr= int("\t6. go back to Visual Studio an RUN/SINGLE STEP the application\= n");

           &nb= sp;            SecPr= int("\t7. otherwise press enter to continue...\n");

           &nb= sp;            getch= ar();

           &nb= sp;            //

           &nb= sp;            // 1.= SET A SOFTWARE BREAKPOINT TO THE NEXT LINE of code below -->> SecPri= nt("");

           &nb= sp;            // 2.= switch to the command box and press ENTER

           &nb= sp;            // 3.= start single stepping the entire boot/emulation process, good luck...

           &nb= sp;            //

           &nb= sp;            SecPr= int("");//now you can single step the entire boot/emulation proce= ss, good luck...

           &nb= sp;       }

            }<= /span>

        }

    }

--_000_VI1PR0502MB3968E000F5D41982DE3A4F66EB7E0VI1PR0502MB3968_--